FFmpeg
Loading...
Searching...
No Matches
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
50typedef struct FFITUTT35 {
52
55
56 const uint8_t *payload;
58} FFITUTT35;
59
70
71typedef struct FFITUTT35Aux {
72 /**
73 * A DOVIContext. Must be set to a valid pointer in order to be parsed
74 * and filled.
75 */
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 */
101int 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 */
AOM film grain synthesis.
Libavcodec external API header.
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define flags(name, subs,...)
Definition cbs_h264.c:74
static AVFrame * frame
reference-counted frame API
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
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
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:322
void ff_itut_t35_unref(FFITUTT35Meta *metadata)
Unref all references in metadata.
Definition itut35.c:393
A reference to a data buffer.
Definition buffer.h:82
main external API structure.
Definition avcodec.h:443
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
DOVIContext * dovi
A DOVIContext.
Definition itut35.h:76
AVBufferRef * lcevc
Definition itut35.h:63
AVBufferRef * a53_cc
Definition itut35.h:62
AVBufferRef * afd
Definition itut35.h:61
AVBufferRef * hdr_vivid
Definition itut35.h:66
AVBufferRef * hdr_plus
Definition itut35.h:64
AVBufferRef * hdr_smpte2094_app5
Definition itut35.h:65
AVFilmGrainAFGS1Params aom_film_grain
Definition itut35.h:68
AVBufferRef * dovi
Definition itut35.h:67
unsigned int provider_oriented_code
Definition itut35.h:54
const uint8_t * payload
Definition itut35.h:56
int country_code
Definition itut35.h:51
int provider_code
Definition itut35.h:53
size_t payload_size
Definition itut35.h:57
int size