FFmpeg
itut35.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVCODEC_ITUT35_H
20 #define AVCODEC_ITUT35_H
21 
22 #include <stdint.h>
23 #include <stddef.h>
24 
25 #include "libavutil/frame.h"
26 #include "avcodec.h"
27 #include "aom_film_grain.h"
28 #include "dovi_rpu.h"
29 
30 #define ITU_T_T35_COUNTRY_CODE_CN 0x26
31 #define ITU_T_T35_COUNTRY_CODE_UK 0xB4
32 #define ITU_T_T35_COUNTRY_CODE_US 0xB5
33 
34 // The Terminal Provider Code (or "Manufacturer Code") identifies the
35 // manufacturer within a country. An Assignment Authority appointed by the
36 // national body assigns this code nationally. The manufacturer code is always
37 // used in conjunction with a country code.
38 // - CN providers
39 #define ITU_T_T35_PROVIDER_CODE_HDR_VIVID 0x0004
40 // - UK providers
41 // https://www.cix.co.uk/~bpechey/H221/h221code.htm
42 #define ITU_T_T35_PROVIDER_CODE_VNOVA 0x5000
43 // - US providers
44 #define ITU_T_T35_PROVIDER_CODE_ATSC 0x0031
45 #define ITU_T_T35_PROVIDER_CODE_DOLBY 0x003B
46 #define ITU_T_T35_PROVIDER_CODE_AOM 0x5890
47 #define ITU_T_T35_PROVIDER_CODE_SAMSUNG 0x003C
48 #define ITU_T_T35_PROVIDER_CODE_SMPTE 0x0090
49 
50 typedef struct FFITUTT35 {
52 
54  unsigned int provider_oriented_code;
55 
56  const uint8_t *payload;
57  size_t payload_size;
58 } FFITUTT35;
59 
60 typedef struct FFITUTT35Meta {
70 
71 typedef struct FFITUTT35Aux {
72  /**
73  * A DOVIContext. Must be set to a valid pointer in order to be parsed
74  * and filled.
75  */
77 } FFITUTT35Aux;
78 
79 /**
80  * country_code is assumed to not be the first byte of the buffer and must
81  * be set by the caller beforehand.
82  */
83 #define FF_ITUT_T35_FLAG_COUNTRY_CODE (1 << 0)
84 
85 /**
86  * Parse a raw ITU-T T35 buffer to get the country code, provider code,
87  * and set them plus the pointer and size in the FFITUTT35 struct to the
88  * start of the actual payload.
89  *
90  * @param itut_t35 The struct to fill
91  * @param buf The input buffer
92  * @param size Size of the input buffer
93  * @param flags A combination of FF_ITUT_T35_FLAG_*
94  * @return 0 if nothing was done (e.g. the payload is of an unsupported
95  * type), 1 on success, or a negative AVERROR code on failure
96  *
97  * @note buf will remain owned by the caller, and no new allocations will
98  * be made. Any pointer in the resulting struct will be valid as long
99  * as buf is valid.
100  */
101 int ff_itut_t35_parse_buffer(FFITUTT35 *itut_t35, const uint8_t *buf,
102  size_t size, int flags);
103 
104 /**
105  * Parse a pre-processed ITU-T T35 payload to fill the metadata struct.
106  *
107  * @param itut_t35 The pre-filled struct
108  * @param aux A struct containing extra contexts required by certain
109  * payload types. Any pointer present is owned by the caller.
110  * May be NULL, in which case the relevant payloads will not
111  * be parsed.
112  * @param metadata A metadata struct. All the allocated buffer references
113  * are owned by the caller and must be freed accordingly.
114  * @param err_recognition A combination of AV_EF_* flags
115  * @return 0 on success, or a negative AVERROR code on failure
116  */
118  FFITUTT35Meta *metadata, int err_recognition);
119 
120 /**
121  * Parse a pre-processed ITU-T T35 payload to fill a frame's side data.
122  *
123  * @param itut_t35 The pre-filled struct
124  * @param aux A struct containing extra contexts required by certain
125  * payload types. Any pointer present is owned by the caller.
126  * May be NULL, in which case the relevant payloads will not
127  * be parsed.
128  * @param avctx The context that generated the frame
129  * @param frame A frame
130  * @return 0 on success, or a negative AVERROR code on failure
131  */
133  AVCodecContext *avctx, AVFrame *frame);
134 
135 /**
136  * Unref all references in metadata
137  */
139 
140 #endif /* AVCODEC_ITUT35_H */
flags
const SwsFlags flags[]
Definition: swscale.c:85
FFITUTT35::country_code
int country_code
Definition: itut35.h:51
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:466
FFITUTT35Meta::aom_film_grain
AVFilmGrainAFGS1Params aom_film_grain
Definition: itut35.h:68
FFITUTT35Meta::lcevc
AVBufferRef * lcevc
Definition: itut35.h:63
FFITUTT35Meta::hdr_smpte2094_app5
AVBufferRef * hdr_smpte2094_app5
Definition: itut35.h:65
DOVIContext
Definition: dovi_rpu.h:42
ff_itut_t35_parse_buffer
int ff_itut_t35_parse_buffer(FFITUTT35 *itut_t35, const uint8_t *buf, size_t size, int flags)
Parse a raw ITU-T T35 buffer to get the country code, provider code, and set them plus the pointer an...
Definition: itut35.c:34
ff_itut_t35_parse_payload_to_struct
int ff_itut_t35_parse_payload_to_struct(FFITUTT35 *itut_t35, FFITUTT35Aux *aux, FFITUTT35Meta *metadata, int err_recognition)
Parse a pre-processed ITU-T T35 payload to fill the metadata struct.
Definition: itut35.c:163
ff_itut_t35_parse_payload_to_frame
int ff_itut_t35_parse_payload_to_frame(FFITUTT35 *itut_t35, FFITUTT35Aux *aux, AVCodecContext *avctx, AVFrame *frame)
Parse a pre-processed ITU-T T35 payload to fill a frame's side data.
Definition: itut35.c:318
dovi_rpu.h
FFITUTT35::provider_code
int provider_code
Definition: itut35.h:53
FFITUTT35::payload
const uint8_t * payload
Definition: itut35.h:56
metadata
Stream codec metadata
Definition: ogg-flac-chained-meta.txt:2
FFITUTT35
Definition: itut35.h:50
aom_film_grain.h
size
int size
Definition: twinvq_data.h:10344
FFITUTT35Meta::dovi
AVBufferRef * dovi
Definition: itut35.h:67
frame.h
FFITUTT35Meta
Definition: itut35.h:60
ff_itut_t35_unref
void ff_itut_t35_unref(FFITUTT35Meta *metadata)
Unref all references in metadata.
Definition: itut35.c:395
avcodec.h
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
FFITUTT35Meta::afd
AVBufferRef * afd
Definition: itut35.h:61
FFITUTT35::payload_size
size_t payload_size
Definition: itut35.h:57
FFITUTT35Meta::hdr_plus
AVBufferRef * hdr_plus
Definition: itut35.h:64
AVCodecContext
main external API structure.
Definition: avcodec.h:443
FFITUTT35Aux::dovi
DOVIContext * dovi
A DOVIContext.
Definition: itut35.h:76
FFITUTT35Meta::a53_cc
AVBufferRef * a53_cc
Definition: itut35.h:62
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
FFITUTT35::provider_oriented_code
unsigned int provider_oriented_code
Definition: itut35.h:54
AVFilmGrainAFGS1Params
Definition: aom_film_grain.h:34
FFITUTT35Meta::hdr_vivid
AVBufferRef * hdr_vivid
Definition: itut35.h:66
FFITUTT35Aux
Definition: itut35.h:71