|
| 1 | +/* |
| 2 | + * HEIF codec. |
| 3 | + * Copyright (c) 2024 Dirk Farin <[email protected]> |
| 4 | + * |
| 5 | + * This file is part of libheif. |
| 6 | + * |
| 7 | + * libheif is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU Lesser General Public License as |
| 9 | + * published by the Free Software Foundation, either version 3 of |
| 10 | + * the License, or (at your option) any later version. |
| 11 | + * |
| 12 | + * libheif is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU Lesser General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Lesser General Public License |
| 18 | + * along with libheif. If not, see <http://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | + |
| 21 | +#include "evc_dec.h" |
| 22 | +#include "evc_boxes.h" |
| 23 | +#include "error.h" |
| 24 | +#include "context.h" |
| 25 | + |
| 26 | +#include <string> |
| 27 | + |
| 28 | + |
| 29 | +Result<std::vector<uint8_t>> Decoder_EVC::read_bitstream_configuration_data() const |
| 30 | +{ |
| 31 | + std::vector<uint8_t> data; |
| 32 | + m_evcC->get_header_nals(data); |
| 33 | + return data; |
| 34 | +} |
| 35 | + |
| 36 | + |
| 37 | +int Decoder_EVC::get_luma_bits_per_pixel() const |
| 38 | +{ |
| 39 | + return m_evcC->get_configuration().bit_depth_luma; |
| 40 | +} |
| 41 | + |
| 42 | + |
| 43 | +int Decoder_EVC::get_chroma_bits_per_pixel() const |
| 44 | +{ |
| 45 | + return m_evcC->get_configuration().bit_depth_chroma; |
| 46 | +} |
| 47 | + |
| 48 | + |
| 49 | +Error Decoder_EVC::get_coded_image_colorspace(heif_colorspace* out_colorspace, heif_chroma* out_chroma) const |
| 50 | +{ |
| 51 | + switch (m_evcC->get_configuration().chroma_format_idc) { |
| 52 | + case Box_evcC::CHROMA_FORMAT_MONOCHROME: |
| 53 | + *out_chroma = heif_chroma_monochrome; |
| 54 | + *out_colorspace = heif_colorspace_monochrome; |
| 55 | + return Error::Ok; |
| 56 | + case Box_evcC::CHROMA_FORMAT_420: |
| 57 | + *out_chroma = heif_chroma_420; |
| 58 | + *out_colorspace = heif_colorspace_YCbCr; |
| 59 | + return Error::Ok; |
| 60 | + case Box_evcC::CHROMA_FORMAT_422: |
| 61 | + *out_chroma = heif_chroma_422; |
| 62 | + *out_colorspace = heif_colorspace_YCbCr; |
| 63 | + return Error::Ok; |
| 64 | + case Box_evcC::CHROMA_FORMAT_444: |
| 65 | + *out_chroma = heif_chroma_444; |
| 66 | + *out_colorspace = heif_colorspace_YCbCr; |
| 67 | + return Error::Ok; |
| 68 | + default: |
| 69 | + *out_chroma = heif_chroma_undefined; |
| 70 | + *out_colorspace = heif_colorspace_undefined; |
| 71 | + return Error{heif_error_Invalid_input, heif_suberror_Decompression_invalid_data, "unsupported (impossible?) EVC chroma value"}; |
| 72 | + } |
| 73 | +} |
| 74 | + |
0 commit comments