/src/libheif/libheif/image-items/avif.cc
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * HEIF codec. |
3 | | * Copyright (c) 2017 Dirk Farin <dirk.farin@gmail.com> |
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 "pixelimage.h" |
22 | | #include "avif.h" |
23 | | #include "codecs/avif_dec.h" |
24 | | #include "codecs/avif_enc.h" |
25 | | #include "codecs/avif_boxes.h" |
26 | | #include "bitstream.h" |
27 | | #include "common_utils.h" |
28 | | #include "libheif/api_structs.h" |
29 | | #include "file.h" |
30 | | #include <iomanip> |
31 | | #include <limits> |
32 | | #include <string> |
33 | | #include <cstring> |
34 | | #include <utility> |
35 | | |
36 | | // https://aomediacodec.github.io/av1-spec/av1-spec.pdf |
37 | | |
38 | | |
39 | 289 | ImageItem_AVIF::ImageItem_AVIF(HeifContext* ctx, heif_item_id id) : ImageItem(ctx, id) |
40 | 289 | { |
41 | 289 | m_encoder = std::make_shared<Encoder_AVIF>(); |
42 | 289 | } |
43 | | |
44 | 0 | ImageItem_AVIF::ImageItem_AVIF(HeifContext* ctx) : ImageItem(ctx) |
45 | 0 | { |
46 | 0 | m_encoder = std::make_shared<Encoder_AVIF>(); |
47 | 0 | } |
48 | | |
49 | | |
50 | | Error ImageItem_AVIF::on_load_file() |
51 | 284 | { |
52 | 284 | auto av1C_box = get_property<Box_av1C>(); |
53 | 284 | if (!av1C_box) { |
54 | 1 | return Error{heif_error_Invalid_input, |
55 | 1 | heif_suberror_No_av1C_box}; |
56 | 1 | } |
57 | | |
58 | 283 | m_decoder = std::make_shared<Decoder_AVIF>(av1C_box); |
59 | | |
60 | 283 | DataExtent extent; |
61 | 283 | extent.set_from_image_item(get_context()->get_heif_file(), get_id()); |
62 | | |
63 | 283 | m_decoder->set_data_extent(std::move(extent)); |
64 | | |
65 | 283 | return Error::Ok; |
66 | 284 | } |
67 | | |
68 | | |
69 | | Result<std::vector<uint8_t>> ImageItem_AVIF::read_bitstream_configuration_data() const |
70 | 0 | { |
71 | 0 | return m_decoder->read_bitstream_configuration_data(); |
72 | 0 | } |
73 | | |
74 | | |
75 | | Result<std::shared_ptr<class Decoder>> ImageItem_AVIF::get_decoder() const |
76 | 109 | { |
77 | 109 | return {m_decoder}; |
78 | 109 | } |
79 | | |
80 | | |
81 | | std::shared_ptr<class Encoder> ImageItem_AVIF::get_encoder() const |
82 | 0 | { |
83 | 0 | return m_encoder; |
84 | 0 | } |