Go to the documentation of this file.
59 for (
i = 0;
i < buf_size;
i++) {
65 if ((buf[
i] & 3) == 3)
104 const uint8_t *buf,
int buf_size)
107 const uint8_t *buf_end = buf + buf_size;
123 while (buf < buf_end) {
126 bytes_left = buf_end - buf;
129 if (bytes_left >= 2) {
130 s->pict_type = (buf[1] >> 3) & 7;
132 vbv_delay = ((buf[1] & 0x07) << 13) | (buf[2] << 5) | (buf[3] >> 3);
136 if (bytes_left >= 7) {
137 int frame_rate_index;
139 pc->width = (buf[0] << 4) | (buf[1] >> 4);
140 pc->height = ((buf[1] & 0x0f) << 8) | buf[2];
146 frame_rate_index = buf[3] & 0xf;
148 bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6);
150 #if FF_API_TICKS_PER_FRAME
158 if (bytes_left >= 1) {
159 switch (buf[0] >> 4) {
161 if (bytes_left >= 6) {
162 int horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7);
163 int vert_size_ext = (buf[2] >> 5) & 3;
164 int bit_rate_ext = ((buf[2] & 0x1F)<<7) | (buf[3]>>1);
165 int frame_rate_ext_n = (buf[5] >> 5) & 3;
166 int frame_rate_ext_d = (buf[5] & 0x1f);
167 pc->progressive_sequence = buf[1] & (1 << 3);
170 switch ((buf[1] >> 1) & 3) {
176 pc->width = (
pc->width & 0xFFF) | (horiz_size_ext << 12);
177 pc->height = (
pc->height& 0xFFF) | ( vert_size_ext << 12);
178 bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18);
181 avctx->
framerate.
num =
pc->frame_rate.num * (frame_rate_ext_n + 1);
182 avctx->
framerate.
den =
pc->frame_rate.den * (frame_rate_ext_d + 1);
184 #if FF_API_TICKS_PER_FRAME
192 if (bytes_left >= 5) {
193 int top_field_first = buf[3] & (1 << 7);
194 int repeat_first_field = buf[3] & (1 << 1);
195 int progressive_frame = buf[4] & (1 << 7);
199 if (repeat_first_field) {
200 if (
pc->progressive_sequence) {
205 }
else if (progressive_frame) {
210 if (!
pc->progressive_sequence && !progressive_frame) {
218 s->picture_structure = buf[2] & 3;
223 switch (
s->picture_structure) {
260 s->width =
pc->width;
261 s->height =
pc->height;
275 const uint8_t **poutbuf,
int *poutbuf_size,
276 const uint8_t *buf,
int buf_size)
298 ff_dlog(
NULL,
"pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
302 *poutbuf_size = buf_size;
#define FF_ENABLE_DEPRECATION_WARNINGS
AVPixelFormat
Pixel format.
#define SLICE_MAX_START_CODE
void ff_parse_close(AVCodecParserContext *s)
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
uint32_t state
contains the last few bytes in MSB order
void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove, int fuzzy)
Fetch timestamps for a specific byte within the current access unit.
@ AV_FIELD_TT
Top coded_first, top displayed first.
@ AV_PICTURE_STRUCTURE_FRAME
coded as frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
const AVCodecParser ff_mpegvideo_parser
static enum AVPixelFormat pix_fmt
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static int mpegvideo_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int64_t rc_max_rate
maximum bitrate
@ AV_PICTURE_STRUCTURE_BOTTOM_FIELD
coded as bottom field
#define SLICE_MIN_START_CODE
Rational number (pair of numerator and denominator).
@ AV_PICTURE_STRUCTURE_TOP_FIELD
coded as top field
int64_t bit_rate
the average bitrate
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
static void mpegvideo_extract_headers(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t *buf, int buf_size)
static int mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s)
Find the end of the current frame in the bitstream.
#define PICTURE_START_CODE
@ AV_PICTURE_TYPE_NONE
Undefined.
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
#define PARSER_FLAG_COMPLETE_FRAMES
#define i(width, name, range_min, range_max)
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
const AVRational ff_mpeg12_frame_rate_tab[]
main external API structure.
attribute_deprecated int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
int coded_width
Bitstream width / height, may be different from width/height e.g.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static int mpegvideo_parse_init(AVCodecParserContext *s)
int width
picture width / height.
static int first_field(const struct video_data *s)
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding