76 if (sh && !
ctx->mpeg1_warned) {
78 "header but not a sequence extension: maybe it's "
79 "actually MPEG-1?\n");
80 ctx->mpeg1_warned = 1;
85 if (
ctx->display_aspect_ratio.num &&
ctx->display_aspect_ratio.den) {
89 ctx->display_aspect_ratio.den, 65535);
91 if (num == 4 && den == 3)
93 else if (num == 16 && den == 9)
95 else if (num == 221 && den == 100)
101 if (
ctx->frame_rate.num &&
ctx->frame_rate.den) {
102 int code, ext_n, ext_d;
105 &
code, &ext_n, &ext_d, 0);
108 se->frame_rate_extension_n = ext_n;
109 se->frame_rate_extension_d = ext_d;
112 if (
ctx->video_format >= 0 ||
113 ctx->colour_primaries >= 0 ||
114 ctx->transfer_characteristics >= 0 ||
115 ctx->matrix_coefficients >= 0) {
118 ctx->sequence_display_extension.extension_start_code =
120 ctx->sequence_display_extension.extension_start_code_identifier =
122 sde = &
ctx->sequence_display_extension.data.sequence_display;
127 .colour_description = 0,
128 .colour_primaries = 2,
129 .transfer_characteristics = 2,
130 .matrix_coefficients = 2,
132 .display_horizontal_size =
134 .display_vertical_size =
140 &
ctx->sequence_display_extension,
144 "display extension.\n");
149 if (
ctx->video_format >= 0)
152 if (
ctx->colour_primaries >= 0 ||
153 ctx->transfer_characteristics >= 0 ||
154 ctx->matrix_coefficients >= 0) {
157 if (
ctx->colour_primaries >= 0)
160 if (
ctx->transfer_characteristics >= 0)
163 if (
ctx->matrix_coefficients >= 0)
173 .fragment_name =
"frame",
174 .unit_name =
"start code",
182 #define VALIDITY_CHECK(name) do { \
184 av_log(bsf, AV_LOG_ERROR, "The value 0 for %s is " \
185 "forbidden.\n", #name); \
186 return AVERROR(EINVAL); \
192 #undef VALIDITY_CHECK
197 #define OFFSET(x) offsetof(MPEG2MetadataContext, x)
198 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
200 {
"display_aspect_ratio",
"Set display aspect ratio (table 6-3)",
202 { .dbl = 0.0 }, 0, 65535,
FLAGS },
204 {
"frame_rate",
"Set frame rate",
206 { .dbl = 0.0 }, 0, UINT_MAX,
FLAGS },
208 {
"video_format",
"Set video format (table 6-6)",
210 { .i64 = -1 }, -1, 7,
FLAGS },
211 {
"colour_primaries",
"Set colour primaries (table 6-7)",
213 { .i64 = -1 }, -1, 255,
FLAGS },
214 {
"transfer_characteristics",
"Set transfer characteristics (table 6-8)",
216 { .i64 = -1 }, -1, 255,
FLAGS },
217 {
"matrix_coefficients",
"Set matrix coefficients (table 6-9)",
219 { .i64 = -1 }, -1, 255,
FLAGS },
236 .
name =
"mpeg2_metadata",
static enum AVCodecID codec_ids[]
static av_cold int init(AVCodecContext *avctx)
int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, void *content, AVBufferRef *content_buf)
Insert a new unit into a fragment with the given content.
int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt)
Filter operation for CBS BSF.
int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type)
Initialise generic CBS BSF setup.
void ff_cbs_bsf_generic_close(AVBSFContext *bsf)
Close a generic CBS BSF instance.
#define se(name, range_min, range_max)
@ MPEG2_START_SEQUENCE_HEADER
@ MPEG2_EXTENSION_SEQUENCE_DISPLAY
@ MPEG2_EXTENSION_SEQUENCE
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
common internal and external API header
AVCodecID
Identify the syntax and semantics of the bitstream.
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define LIBAVUTIL_VERSION_INT
static const struct TransferCharacteristics transfer_characteristics[AVCOL_TRC_NB]
void ff_mpeg12_find_best_frame_rate(AVRational frame_rate, int *code, int *ext_n, int *ext_d, int nonstandard)
The bitstream filter state.
void * priv_data
Opaque filter-specific private data.
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
This structure stores compressed data.
Rational number (pair of numerator and denominator).
Coded bitstream fragment structure, combining one or more units.
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
int nb_units
Number of units in this fragment.
void * content
Pointer to the decomposed form of this unit.
CodedBitstreamUnitType type
Codec-specific type of this unit.
MPEG2RawExtensionData sequence_display_extension
AVRational display_aspect_ratio
int transfer_characteristics
MPEG2RawSequenceDisplayExtension sequence_display
MPEG2RawSequenceExtension sequence
union MPEG2RawExtensionData::@35 data
uint8_t extension_start_code_identifier
uint8_t transfer_characteristics
uint8_t colour_description
uint8_t matrix_coefficients