40 const uint8_t *buf_end = buf + buf_size;
42 int frame_rate_index, ext_type, bytes_left;
43 int frame_rate_ext_n, frame_rate_ext_d;
44 int top_field_first, repeat_first_field, progressive_frame;
45 int horiz_size_ext, vert_size_ext, bit_rate_ext;
55 while (buf < buf_end) {
58 bytes_left = buf_end -
buf;
61 if (bytes_left >= 2) {
64 vbv_delay = ((buf[1] & 0x07) << 13) | (buf[2] << 5) | (buf[3] >> 3);
68 if (bytes_left >= 7) {
69 pc->
width = (buf[0] << 4) | (buf[1] >> 4);
70 pc->
height = ((buf[1] & 0x0f) << 8) | buf[2];
76 frame_rate_index = buf[3] & 0xf;
78 bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6);
84 if (bytes_left >= 1) {
85 ext_type = (buf[0] >> 4);
88 if (bytes_left >= 6) {
89 horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7);
90 vert_size_ext = (buf[2] >> 5) & 3;
91 bit_rate_ext = ((buf[2] & 0x1F)<<7) | (buf[3]>>1);
92 frame_rate_ext_n = (buf[5] >> 5) & 3;
93 frame_rate_ext_d = (buf[5] & 0x1f);
97 chroma_format = (buf[1] >> 1) & 3;
98 switch (chroma_format) {
104 pc->
width = (pc->
width & 0xFFF) | (horiz_size_ext << 12);
105 pc->
height = (pc->
height& 0xFFF) | ( vert_size_ext << 12);
106 bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18);
116 if (bytes_left >= 5) {
117 top_field_first = buf[3] & (1 << 7);
118 repeat_first_field = buf[3] & (1 << 1);
119 progressive_frame = buf[4] & (1 << 7);
123 if (repeat_first_field) {
129 }
else if (progressive_frame) {
177 #if FF_API_AVCTX_TIMEBASE
185 const uint8_t **poutbuf,
int *poutbuf_size,
208 ff_dlog(
NULL,
"pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
212 *poutbuf_size = buf_size;
223 for(i=0; i<buf_size; i++){
224 state= (state<<8) | buf[i];
227 }
else if(found && state != 0x1B5 && state < 0x200 && state >= 0x100)
static enum AVPixelFormat pix_fmt
#define SLICE_MAX_START_CODE
static int mpegvideo_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
int coded_width
Bitstream width / height, may be different from width/height e.g.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int64_t bit_rate
the average bitrate
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.
int width
Dimensions of the decoded video intended for presentation.
enum AVFieldOrder field_order
int coded_width
Dimensions of the coded video.
#define SLICE_MIN_START_CODE
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static double av_q2d(AVRational a)
Convert an AVRational to a double.
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
#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.
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void ff_parse_close(AVCodecParserContext *s)
static const uint8_t start_code[]
int width
picture width / height.
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
static int mpegvideo_parse_init(AVCodecParserContext *s)
preferred ID for MPEG-1/2 video decoding
main external API structure.
Rational number (pair of numerator and denominator).
int ff_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.
AVCodecParser ff_mpegvideo_parser
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
static void mpegvideo_extract_headers(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t *buf, int buf_size)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
#define PARSER_FLAG_COMPLETE_FRAMES
static int mpegvideo_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
int format
The format of the coded data, corresponds to enum AVPixelFormat for video and for enum AVSampleFormat...
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
int repeat_pict
This field is used for proper frame duration computation in lavf.
#define PICTURE_START_CODE
AVPixelFormat
Pixel format.
int64_t rc_max_rate
maximum bitrate
const AVRational ff_mpeg12_frame_rate_tab[]