FFmpeg
cbs_sei.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_CBS_SEI_H
20 #define AVCODEC_CBS_SEI_H
21 
22 #include <stddef.h>
23 #include <stdint.h>
24 
25 #include "libavutil/buffer.h"
26 
27 #include "cbs.h"
28 #include "sei.h"
29 
30 
31 typedef struct SEIRawFillerPayload {
32  uint32_t payload_size;
34 
35 typedef struct SEIRawUserDataRegistered {
38  uint8_t *data;
40  size_t data_length;
42 
44  uint8_t uuid_iso_iec_11578[16];
45  uint8_t *data;
47  size_t data_length;
49 
51  uint16_t display_primaries_x[3];
52  uint16_t display_primaries_y[3];
53  uint16_t white_point_x;
54  uint16_t white_point_y;
58 
63 
67 
68 typedef struct SEIRawMessage {
69  uint32_t payload_type;
70  uint32_t payload_size;
71  void *payload;
73  uint8_t *extension_data;
77 
78 typedef struct SEIRawMessageList {
83 
84 
85 typedef struct SEIMessageState {
86  // The type of the payload being written.
87  uint32_t payload_type;
88  // When reading, contains the size of the payload to allow finding the
89  // end of variable-length fields (such as user_data_payload_byte[]).
90  // (When writing, the size will be derived from the total number of
91  // bytes actually written.)
92  uint32_t payload_size;
93  // When writing, indicates that payload extension data is present so
94  // all extended fields must be written. May be updated by the writer
95  // to indicate that extended fields have been written, so the extension
96  // end bits must be written too.
99 
100 struct GetBitContext;
101 struct PutBitContext;
102 
104  struct GetBitContext *rw,
105  void *current,
107 
109  struct PutBitContext *rw,
110  void *current,
112 
113 typedef struct SEIMessageTypeDescriptor {
114  // Payload type for the message. (-1 in this field ends a list.)
115  int type;
116  // Valid in a prefix SEI NAL unit (always for H.264).
117  uint8_t prefix;
118  // Valid in a suffix SEI NAL unit (never for H.264).
119  uint8_t suffix;
120  // Size of the decomposed structure.
121  size_t size;
122  // Read bitstream into SEI message.
124  // Write bitstream from SEI message.
127 
128 // Macro for the read/write pair. The clumsy cast is needed because the
129 // current pointer is typed in all of the read/write functions but has to
130 // be void here to fit all cases.
131 #define SEI_MESSAGE_RW(codec, name) \
132  .read = (SEIMessageReadFunction) cbs_ ## codec ## _read_ ## name, \
133  .write = (SEIMessageWriteFunction)cbs_ ## codec ## _write_ ## name
134 
135 // End-of-list sentinel element.
136 #define SEI_MESSAGE_TYPE_END { .type = -1 }
137 
138 
139 /**
140  * Find the type descriptor for the given payload type.
141  *
142  * Returns NULL if the payload type is not known.
143  */
145  int payload_type);
146 
147 /**
148  * Allocate a new payload for the given SEI message.
149  */
152 
153 /**
154  * Allocate a new empty SEI message in a message list.
155  *
156  * The new message is in place nb_messages - 1.
157  */
159 
160 /**
161  * Free all SEI messages in a message list.
162  */
164 
165 /**
166  * Add an SEI message to an access unit.
167  *
168  * Will add to an existing SEI NAL unit, or create a new one for the
169  * message if there is no suitable existing one.
170  *
171  * Takes a new reference to payload_buf, if set. If payload_buf is
172  * NULL then the new message will not be reference counted.
173  */
176  int prefix,
177  uint32_t payload_type,
178  void *payload_data,
179  AVBufferRef *payload_buf);
180 
181 /**
182  * Iterate over messages with the given payload type in an access unit.
183  *
184  * Set message to NULL in the first call. Returns 0 while more messages
185  * are available, AVERROR(ENOENT) when all messages have been found.
186  */
189  uint32_t payload_type,
191 
192 /**
193  * Delete all messages with the given payload type from an access unit.
194  */
197  uint32_t payload_type);
198 
199 #endif /* AVCODEC_CBS_SEI_H */
SEIRawMasteringDisplayColourVolume::display_primaries_x
uint16_t display_primaries_x[3]
Definition: cbs_sei.h:51
SEIRawUserDataRegistered::data_ref
AVBufferRef * data_ref
Definition: cbs_sei.h:39
SEIRawUserDataRegistered
Definition: cbs_sei.h:35
SEIMessageTypeDescriptor::size
size_t size
Definition: cbs_sei.h:121
ff_cbs_sei_find_message
int ff_cbs_sei_find_message(CodedBitstreamContext *ctx, CodedBitstreamFragment *au, uint32_t payload_type, SEIRawMessage **message)
Iterate over messages with the given payload type in an access unit.
Definition: cbs_sei.c:297
message
Definition: api-threadmessage-test.c:46
SEIRawMessage::extension_bit_length
size_t extension_bit_length
Definition: cbs_sei.h:75
SEIRawMessage
Definition: cbs_sei.h:68
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:173
SEIRawMessage::extension_data_ref
AVBufferRef * extension_data_ref
Definition: cbs_sei.h:74
SEIRawAlternativeTransferCharacteristics
Definition: cbs_sei.h:64
SEIMessageState::payload_type
uint32_t payload_type
Definition: cbs_sei.h:87
cbs.h
SEIMessageTypeDescriptor::suffix
uint8_t suffix
Definition: cbs_sei.h:119
SEIMessageReadFunction
int(* SEIMessageReadFunction)(CodedBitstreamContext *ctx, struct GetBitContext *rw, void *current, SEIMessageState *sei)
Definition: cbs_sei.h:103
SEIRawMessage::payload_size
uint32_t payload_size
Definition: cbs_sei.h:70
SEIRawContentLightLevelInfo
Definition: cbs_sei.h:59
SEIRawUserDataUnregistered::data
uint8_t * data
Definition: cbs_sei.h:45
GetBitContext
Definition: get_bits.h:62
SEIRawMasteringDisplayColourVolume::max_display_mastering_luminance
uint32_t max_display_mastering_luminance
Definition: cbs_sei.h:55
SEIRawMessage::extension_data
uint8_t * extension_data
Definition: cbs_sei.h:73
SEIRawUserDataUnregistered
Definition: cbs_sei.h:43
ff_cbs_sei_list_add
int ff_cbs_sei_list_add(SEIRawMessageList *list)
Allocate a new empty SEI message in a message list.
Definition: cbs_sei.c:74
SEIRawUserDataRegistered::itu_t_t35_country_code
uint8_t itu_t_t35_country_code
Definition: cbs_sei.h:36
SEIMessageWriteFunction
int(* SEIMessageWriteFunction)(CodedBitstreamContext *ctx, struct PutBitContext *rw, void *current, SEIMessageState *sei)
Definition: cbs_sei.h:108
CodedBitstreamFragment
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:121
SEIRawMessageList::nb_messages
int nb_messages
Definition: cbs_sei.h:80
SEIRawFillerPayload
Definition: cbs_sei.h:31
SEIRawMasteringDisplayColourVolume::white_point_y
uint16_t white_point_y
Definition: cbs_sei.h:54
SEIMessageState::payload_size
uint32_t payload_size
Definition: cbs_sei.h:92
SEIRawMessageList::nb_messages_allocated
int nb_messages_allocated
Definition: cbs_sei.h:81
SEIRawMessageList
Definition: cbs_sei.h:78
SEIRawUserDataUnregistered::data_length
size_t data_length
Definition: cbs_sei.h:47
ctx
AVFormatContext * ctx
Definition: movenc.c:48
PutBitContext
Definition: put_bits.h:49
SEIRawMessage::payload_type
uint32_t payload_type
Definition: cbs_sei.h:69
SEIRawMasteringDisplayColourVolume::min_display_mastering_luminance
uint32_t min_display_mastering_luminance
Definition: cbs_sei.h:56
SEIMessageTypeDescriptor
Definition: cbs_sei.h:113
SEIRawMasteringDisplayColourVolume
Definition: cbs_sei.h:50
sei.h
list
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining list
Definition: filter_design.txt:25
sei
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
Definition: cbs_h264_syntax_template.c:825
ff_cbs_sei_alloc_message_payload
int ff_cbs_sei_alloc_message_payload(SEIRawMessage *message, const SEIMessageTypeDescriptor *desc)
Allocate a new payload for the given SEI message.
Definition: cbs_sei.c:39
SEIRawFillerPayload::payload_size
uint32_t payload_size
Definition: cbs_sei.h:32
SEIRawMessage::payload_ref
AVBufferRef * payload_ref
Definition: cbs_sei.h:72
SEIRawUserDataRegistered::data
uint8_t * data
Definition: cbs_sei.h:38
SEIMessageTypeDescriptor::type
int type
Definition: cbs_sei.h:115
SEIMessageTypeDescriptor::write
SEIMessageWriteFunction write
Definition: cbs_sei.h:125
buffer.h
SEIRawUserDataRegistered::data_length
size_t data_length
Definition: cbs_sei.h:40
SEIRawUserDataRegistered::itu_t_t35_country_code_extension_byte
uint8_t itu_t_t35_country_code_extension_byte
Definition: cbs_sei.h:37
SEIRawMasteringDisplayColourVolume::white_point_x
uint16_t white_point_x
Definition: cbs_sei.h:53
SEIRawMessageList::messages
SEIRawMessage * messages
Definition: cbs_sei.h:79
SEIMessageTypeDescriptor::read
SEIMessageReadFunction read
Definition: cbs_sei.h:123
SEIRawMasteringDisplayColourVolume::display_primaries_y
uint16_t display_primaries_y[3]
Definition: cbs_sei.h:52
SEIRawContentLightLevelInfo::max_content_light_level
uint16_t max_content_light_level
Definition: cbs_sei.h:60
SEIRawAlternativeTransferCharacteristics::preferred_transfer_characteristics
uint8_t preferred_transfer_characteristics
Definition: cbs_sei.h:65
SEIRawMessage::payload
void * payload
Definition: cbs_sei.h:71
SEIMessageState
Definition: cbs_sei.h:85
ff_cbs_sei_add_message
int ff_cbs_sei_add_message(CodedBitstreamContext *ctx, CodedBitstreamFragment *au, int prefix, uint32_t payload_type, void *payload_data, AVBufferRef *payload_buf)
Add an SEI message to an access unit.
Definition: cbs_sei.c:247
ff_cbs_sei_find_type
const SEIMessageTypeDescriptor * ff_cbs_sei_find_type(CodedBitstreamContext *ctx, int payload_type)
Find the type descriptor for the given payload type.
Definition: cbs_h2645.c:1652
desc
const char * desc
Definition: libsvtav1.c:79
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
ff_cbs_sei_delete_message_type
void ff_cbs_sei_delete_message_type(CodedBitstreamContext *ctx, CodedBitstreamFragment *au, uint32_t payload_type)
Delete all messages with the given payload type from an access unit.
Definition: cbs_sei.c:350
SEIRawContentLightLevelInfo::max_pic_average_light_level
uint16_t max_pic_average_light_level
Definition: cbs_sei.h:61
ff_cbs_sei_free_message_list
void ff_cbs_sei_free_message_list(SEIRawMessageList *list)
Free all SEI messages in a message list.
Definition: cbs_sei.c:99
SEIRawUserDataUnregistered::data_ref
AVBufferRef * data_ref
Definition: cbs_sei.h:46
SEIRawUserDataUnregistered::uuid_iso_iec_11578
uint8_t uuid_iso_iec_11578[16]
Definition: cbs_sei.h:44
SEIMessageState::extension_present
uint8_t extension_present
Definition: cbs_sei.h:97
int
int
Definition: ffmpeg_filter.c:153
SEIMessageTypeDescriptor::prefix
uint8_t prefix
Definition: cbs_sei.h:117