xref: /third_party/ffmpeg/libavformat/av1.h (revision cabdff1a)
1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * AV1 helper functions for muxers
3cabdff1aSopenharmony_ci *
4cabdff1aSopenharmony_ci * This file is part of FFmpeg.
5cabdff1aSopenharmony_ci *
6cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
7cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
8cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
9cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
10cabdff1aSopenharmony_ci *
11cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
12cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
13cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14cabdff1aSopenharmony_ci * Lesser General Public License for more details.
15cabdff1aSopenharmony_ci *
16cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
17cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
18cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19cabdff1aSopenharmony_ci */
20cabdff1aSopenharmony_ci
21cabdff1aSopenharmony_ci#ifndef AVFORMAT_AV1_H
22cabdff1aSopenharmony_ci#define AVFORMAT_AV1_H
23cabdff1aSopenharmony_ci
24cabdff1aSopenharmony_ci#include <stdint.h>
25cabdff1aSopenharmony_ci
26cabdff1aSopenharmony_ci#include "avio.h"
27cabdff1aSopenharmony_ci
28cabdff1aSopenharmony_citypedef struct AV1SequenceParameters {
29cabdff1aSopenharmony_ci    uint8_t profile;
30cabdff1aSopenharmony_ci    uint8_t level;
31cabdff1aSopenharmony_ci    uint8_t tier;
32cabdff1aSopenharmony_ci    uint8_t bitdepth;
33cabdff1aSopenharmony_ci    uint8_t monochrome;
34cabdff1aSopenharmony_ci    uint8_t chroma_subsampling_x;
35cabdff1aSopenharmony_ci    uint8_t chroma_subsampling_y;
36cabdff1aSopenharmony_ci    uint8_t chroma_sample_position;
37cabdff1aSopenharmony_ci    uint8_t color_description_present_flag;
38cabdff1aSopenharmony_ci    uint8_t color_primaries;
39cabdff1aSopenharmony_ci    uint8_t transfer_characteristics;
40cabdff1aSopenharmony_ci    uint8_t matrix_coefficients;
41cabdff1aSopenharmony_ci    uint8_t color_range;
42cabdff1aSopenharmony_ci} AV1SequenceParameters;
43cabdff1aSopenharmony_ci
44cabdff1aSopenharmony_ci/**
45cabdff1aSopenharmony_ci * Filter out AV1 OBUs not meant to be present in ISOBMFF sample data and write
46cabdff1aSopenharmony_ci * the resulting bitstream to the provided AVIOContext.
47cabdff1aSopenharmony_ci *
48cabdff1aSopenharmony_ci * @param pb pointer to the AVIOContext where the filtered bitstream shall be
49cabdff1aSopenharmony_ci *           written; may be NULL, in which case nothing is written.
50cabdff1aSopenharmony_ci * @param buf input data buffer
51cabdff1aSopenharmony_ci * @param size size of the input data buffer
52cabdff1aSopenharmony_ci *
53cabdff1aSopenharmony_ci * @return the amount of bytes written (or would have been written in case
54cabdff1aSopenharmony_ci *         pb had been supplied) in case of success, a negative AVERROR
55cabdff1aSopenharmony_ci *         code in case of failure
56cabdff1aSopenharmony_ci * @note   One can use NULL for pb to just get the output size.
57cabdff1aSopenharmony_ci */
58cabdff1aSopenharmony_ciint ff_av1_filter_obus(AVIOContext *pb, const uint8_t *buf, int size);
59cabdff1aSopenharmony_ci
60cabdff1aSopenharmony_ci/**
61cabdff1aSopenharmony_ci * Filter out AV1 OBUs not meant to be present in ISOBMFF sample data and return
62cabdff1aSopenharmony_ci * the result in a data buffer, avoiding allocations and copies if possible.
63cabdff1aSopenharmony_ci *
64cabdff1aSopenharmony_ci * @param in input data buffer
65cabdff1aSopenharmony_ci * @param out pointer to pointer for the returned buffer. In case of success,
66cabdff1aSopenharmony_ci *            it is independently allocated if and only if `*out` differs from in.
67cabdff1aSopenharmony_ci * @param size size of the input data buffer. The size of the resulting output
68cabdff1aSopenharmony_ci *             data buffer will be written here
69cabdff1aSopenharmony_ci * @param offset offset of the returned data inside `*out`: It runs from
70cabdff1aSopenharmony_ci *               `*out + offset` (inclusive) to `*out + offset + size`
71cabdff1aSopenharmony_ci *               (exclusive); is zero if `*out` is independently allocated.
72cabdff1aSopenharmony_ci *
73cabdff1aSopenharmony_ci * @return 0 in case of success, a negative AVERROR code in case of failure.
74cabdff1aSopenharmony_ci *         On failure, *out and *size are unchanged
75cabdff1aSopenharmony_ci * @note *out will be treated as unintialized on input and will not be freed.
76cabdff1aSopenharmony_ci */
77cabdff1aSopenharmony_ciint ff_av1_filter_obus_buf(const uint8_t *in, uint8_t **out,
78cabdff1aSopenharmony_ci                           int *size, int *offset);
79cabdff1aSopenharmony_ci
80cabdff1aSopenharmony_ci/**
81cabdff1aSopenharmony_ci * Parses a Sequence Header from the the provided buffer.
82cabdff1aSopenharmony_ci *
83cabdff1aSopenharmony_ci * @param seq pointer to the AV1SequenceParameters where the parsed values will
84cabdff1aSopenharmony_ci *            be written
85cabdff1aSopenharmony_ci * @param buf input data buffer
86cabdff1aSopenharmony_ci * @param size size in bytes of the input data buffer
87cabdff1aSopenharmony_ci *
88cabdff1aSopenharmony_ci * @return >= 0 in case of success, a negative AVERROR code in case of failure
89cabdff1aSopenharmony_ci */
90cabdff1aSopenharmony_ciint ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int size);
91cabdff1aSopenharmony_ci
92cabdff1aSopenharmony_ci/**
93cabdff1aSopenharmony_ci * Writes AV1 extradata (Sequence Header and Metadata OBUs) to the provided
94cabdff1aSopenharmony_ci * AVIOContext.
95cabdff1aSopenharmony_ci *
96cabdff1aSopenharmony_ci * @param pb pointer to the AVIOContext where the av1C box shall be written
97cabdff1aSopenharmony_ci * @param buf input data buffer
98cabdff1aSopenharmony_ci * @param size size in bytes of the input data buffer
99cabdff1aSopenharmony_ci * @param write_seq_header If 1, Sequence Header OBU will be written inside the
100cabdff1aSopenharmony_ci *           av1C box. Otherwise, Sequence Header OBU will be omitted.
101cabdff1aSopenharmony_ci *
102cabdff1aSopenharmony_ci * @return >= 0 in case of success, a negative AVERROR code in case of failure
103cabdff1aSopenharmony_ci */
104cabdff1aSopenharmony_ciint ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, int write_seq_header);
105cabdff1aSopenharmony_ci
106cabdff1aSopenharmony_ci#endif /* AVFORMAT_AV1_H */
107