Go to the documentation of this file.
78 if (sh && !
ctx->mpeg1_warned) {
80 "header but not a sequence extension: maybe it's "
81 "actually MPEG-1?\n");
82 ctx->mpeg1_warned = 1;
87 if (
ctx->display_aspect_ratio.num &&
ctx->display_aspect_ratio.den) {
91 ctx->display_aspect_ratio.den, 65535);
93 if (num == 4 && den == 3)
95 else if (num == 16 && den == 9)
97 else if (num == 221 && den == 100)
103 if (
ctx->frame_rate.num &&
ctx->frame_rate.den) {
104 int code, ext_n, ext_d;
107 &
code, &ext_n, &ext_d, 0);
110 se->frame_rate_extension_n = ext_n;
111 se->frame_rate_extension_d = ext_d;
114 if (
ctx->video_format >= 0 ||
115 ctx->colour_primaries >= 0 ||
116 ctx->transfer_characteristics >= 0 ||
117 ctx->matrix_coefficients >= 0) {
120 ctx->sequence_display_extension.extension_start_code =
122 ctx->sequence_display_extension.extension_start_code_identifier =
124 sde = &
ctx->sequence_display_extension.data.sequence_display;
129 .colour_description = 0,
130 .colour_primaries = 2,
131 .transfer_characteristics = 2,
132 .matrix_coefficients = 2,
134 .display_horizontal_size =
136 .display_vertical_size =
142 &
ctx->sequence_display_extension,
146 "display extension.\n");
151 if (
ctx->video_format >= 0)
154 if (
ctx->colour_primaries >= 0 ||
155 ctx->transfer_characteristics >= 0 ||
156 ctx->matrix_coefficients >= 0) {
159 if (
ctx->colour_primaries >= 0)
162 if (
ctx->transfer_characteristics >= 0)
165 if (
ctx->matrix_coefficients >= 0)
217 #define VALIDITY_CHECK(name) do { \
219 av_log(bsf, AV_LOG_ERROR, "The value 0 for %s is " \
220 "forbidden.\n", #name); \
221 return AVERROR(EINVAL); \
227 #undef VALIDITY_CHECK
267 #define OFFSET(x) offsetof(MPEG2MetadataContext, x)
268 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
270 {
"display_aspect_ratio",
"Set display aspect ratio (table 6-3)",
272 { .dbl = 0.0 }, 0, 65535,
FLAGS },
274 {
"frame_rate",
"Set frame rate",
276 { .dbl = 0.0 }, 0, UINT_MAX,
FLAGS },
278 {
"video_format",
"Set video format (table 6-6)",
280 { .i64 = -1 }, -1, 7,
FLAGS },
281 {
"colour_primaries",
"Set colour primaries (table 6-7)",
283 { .i64 = -1 }, -1, 255,
FLAGS },
284 {
"transfer_characteristics",
"Set transfer characteristics (table 6-8)",
286 { .i64 = -1 }, -1, 255,
FLAGS },
287 {
"matrix_coefficients",
"Set matrix coefficients (table 6-9)",
289 { .i64 = -1 }, -1, 255,
FLAGS },
306 .
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)
MPEG2RawSequenceDisplayExtension sequence_display
Context structure for coded bitstream operations.
void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
@ MPEG2_EXTENSION_SEQUENCE
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.
@ MPEG2_EXTENSION_SEQUENCE_DISPLAY
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
@ MPEG2_START_SEQUENCE_HEADER
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
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.
union MPEG2RawExtensionData::@39 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.
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.
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.