Go to the documentation of this file.
77 if (sh && !
ctx->mpeg1_warned) {
79 "header but not a sequence extension: maybe it's "
80 "actually MPEG-1?\n");
81 ctx->mpeg1_warned = 1;
86 if (
ctx->display_aspect_ratio.num &&
ctx->display_aspect_ratio.den) {
90 ctx->display_aspect_ratio.den, 65535);
92 if (num == 4 && den == 3)
94 else if (num == 16 && den == 9)
96 else if (num == 221 && den == 100)
102 if (
ctx->frame_rate.num &&
ctx->frame_rate.den) {
103 int code, ext_n, ext_d;
106 &
code, &ext_n, &ext_d, 0);
109 se->frame_rate_extension_n = ext_n;
110 se->frame_rate_extension_d = ext_d;
113 if (
ctx->video_format >= 0 ||
114 ctx->colour_primaries >= 0 ||
115 ctx->transfer_characteristics >= 0 ||
116 ctx->matrix_coefficients >= 0) {
119 ctx->sequence_display_extension.extension_start_code =
121 ctx->sequence_display_extension.extension_start_code_identifier =
123 sde = &
ctx->sequence_display_extension.data.sequence_display;
128 .colour_description = 0,
129 .colour_primaries = 2,
130 .transfer_characteristics = 2,
131 .matrix_coefficients = 2,
133 .display_horizontal_size =
135 .display_vertical_size =
141 &
ctx->sequence_display_extension,
145 "display extension.\n");
150 if (
ctx->video_format >= 0)
153 if (
ctx->colour_primaries >= 0 ||
154 ctx->transfer_characteristics >= 0 ||
155 ctx->matrix_coefficients >= 0) {
158 if (
ctx->colour_primaries >= 0)
161 if (
ctx->transfer_characteristics >= 0)
164 if (
ctx->matrix_coefficients >= 0)
216 #define VALIDITY_CHECK(name) do { \
218 av_log(bsf, AV_LOG_ERROR, "The value 0 for %s is " \
219 "forbidden.\n", #name); \
220 return AVERROR(EINVAL); \
226 #undef VALIDITY_CHECK
266 #define OFFSET(x) offsetof(MPEG2MetadataContext, x)
267 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
269 {
"display_aspect_ratio",
"Set display aspect ratio (table 6-3)",
271 { .dbl = 0.0 }, 0, 65535,
FLAGS },
273 {
"frame_rate",
"Set frame rate",
275 { .dbl = 0.0 }, 0, UINT_MAX,
FLAGS },
277 {
"video_format",
"Set video format (table 6-6)",
279 { .i64 = -1 }, -1, 7,
FLAGS },
280 {
"colour_primaries",
"Set colour primaries (table 6-7)",
282 { .i64 = -1 }, -1, 255,
FLAGS },
283 {
"transfer_characteristics",
"Set transfer characteristics (table 6-8)",
285 { .i64 = -1 }, -1, 255,
FLAGS },
286 {
"matrix_coefficients",
"Set matrix coefficients (table 6-9)",
288 { .i64 = -1 }, -1, 255,
FLAGS },
305 .
name =
"mpeg2_metadata",
AVRational display_aspect_ratio
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVCodecParameters * par_in
Parameters of the input stream.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
static av_cold int init(AVCodecContext *avctx)
int ff_cbs_read_extradata(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVCodecParameters *par)
Read the extradata bitstream found in codec parameters into a fragment, then split into units and dec...
void * content
Pointer to the decomposed form of this unit.
int transfer_characteristics
#define se(name, range_min, range_max)
@ MPEG2_EXTENSION_SEQUENCE_DISPLAY
MPEG2RawSequenceDisplayExtension sequence_display
Context structure for coded bitstream operations.
void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
void ff_cbs_fragment_free(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Free the units array of a fragment in addition to what ff_cbs_fragment_reset does.
CodedBitstreamUnitType type
Codec-specific type of this unit.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
CodedBitstreamContext * cbc
The bitstream filter state.
void ff_mpeg12_find_best_frame_rate(AVRational frame_rate, int *code, int *ext_n, int *ext_d, int nonstandard)
int ff_cbs_write_extradata(CodedBitstreamContext *ctx, AVCodecParameters *par, CodedBitstreamFragment *frag)
Write the bitstream of a fragment to the extradata in codec parameters.
AVCodecParameters * par_out
Parameters of the output stream.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
uint8_t colour_description
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Coded bitstream fragment structure, combining one or more units.
int ff_cbs_write_packet(CodedBitstreamContext *ctx, AVPacket *pkt, CodedBitstreamFragment *frag)
Write the bitstream of a fragment to a packet.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
uint8_t matrix_coefficients
AVCodecID
Identify the syntax and semantics of the bitstream.
MPEG2RawSequenceExtension sequence
uint8_t extension_start_code_identifier
@ MPEG2_EXTENSION_SEQUENCE
static const struct TransferCharacteristics transfer_characteristics[AVCOL_TRC_NB]
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
uint8_t transfer_characteristics
void * priv_data
Opaque filter-specific private data.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
MPEG2RawExtensionData sequence_display_extension
int ff_cbs_init(CodedBitstreamContext **ctx_ptr, enum AVCodecID codec_id, void *log_ctx)
Create and initialise a new context for the given codec.
@ MPEG2_START_SEQUENCE_HEADER
void ff_cbs_fragment_reset(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Free the units contained in a fragment as well as the fragment's own data buffer, but not the units a...
int ff_cbs_read_packet(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVPacket *pkt)
Read the data bitstream from a packet into a fragment, then split into units and decompose.
int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, void *content, AVBufferRef *content_buf)
Insert a new unit into a fragment with the given content.
static enum AVCodecID codec_ids[]
This structure stores compressed data.
union MPEG2RawExtensionData::@62 data
CodedBitstreamFragment fragment
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
int nb_units
Number of units in this fragment.