/*
 * HEIF codec.
 * Copyright (c) 2026 Dirk Farin <dirk.farin@gmail.com>
 *
 * This file is part of libheif.
 *
 * libheif is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * libheif is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with libheif.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LIBHEIF_UNC_DECODER_BYTEALIGN_COMPONENT_INTERLEAVE_H
#define LIBHEIF_UNC_DECODER_BYTEALIGN_COMPONENT_INTERLEAVE_H

#include "unc_decoder.h"
#include <memory>
#include <vector>


class unc_decoder_bytealign_component_interleave : public unc_decoder
{
public:
  unc_decoder_bytealign_component_interleave(uint32_t width, uint32_t height,
                                              const std::shared_ptr<const Box_cmpd>& cmpd,
                                              const std::shared_ptr<const Box_uncC>& uncC,
                                              const std::vector<uint32_t>& uncC_index_to_comp_ids);

  Result<std::vector<uint64_t>> get_tile_data_sizes() const override;

  Error decode_tile(const std::vector<uint8_t>& tile_data,
                    std::shared_ptr<HeifPixelImage>& img,
                    uint32_t out_x0, uint32_t out_y0) override;
};


class unc_decoder_factory_bytealign_component_interleave : public unc_decoder_factory
{
private:
  bool can_decode(const std::shared_ptr<const Box_uncC>& uncC) const override;

  std::unique_ptr<unc_decoder> create(
      uint32_t width, uint32_t height,
      const std::shared_ptr<const Box_cmpd>& cmpd,
      const std::shared_ptr<const Box_uncC>& uncC,
      const std::vector<uint32_t>& uncC_index_to_comp_ids) const override;
};

#endif // LIBHEIF_UNC_DECODER_BYTEALIGN_COMPONENT_INTERLEAVE_H
