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;
53 while (buf < buf_end) {
56 bytes_left = buf_end -
buf;
59 if (bytes_left >= 2) {
62 vbv_delay = ((buf[1] & 0x07) << 13) | (buf[2] << 5) | (buf[3] >> 3);
66 if (bytes_left >= 7) {
67 pc->
width = (buf[0] << 4) | (buf[1] >> 4);
68 pc->
height = ((buf[1] & 0x0f) << 8) | buf[2];
73 frame_rate_index = buf[3] & 0xf;
75 bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6);
81 if (bytes_left >= 1) {
82 ext_type = (buf[0] >> 4);
85 if (bytes_left >= 6) {
86 horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7);
87 vert_size_ext = (buf[2] >> 5) & 3;
88 bit_rate_ext = ((buf[2] & 0x1F)<<7) | (buf[3]>>1);
89 frame_rate_ext_n = (buf[5] >> 5) & 3;
90 frame_rate_ext_d = (buf[5] & 0x1f);
94 pc->
width = (pc->
width & 0xFFF) | (horiz_size_ext << 12);
95 pc->
height = (pc->
height& 0xFFF) | ( vert_size_ext << 12);
96 bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18);
106 if (bytes_left >= 5) {
107 top_field_first = buf[3] & (1 << 7);
108 repeat_first_field = buf[3] & (1 << 1);
109 progressive_frame = buf[4] & (1 << 7);
113 if (repeat_first_field) {
119 }
else if (progressive_frame) {
158 #if FF_API_AVCTX_TIMEBASE
166 const uint8_t **poutbuf,
int *poutbuf_size,
189 ff_dlog(
NULL,
"pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
193 *poutbuf_size = buf_size;
204 for(i=0; i<buf_size; i++){
205 state= (state<<8) | buf[i];
208 }
else if(found && state != 0x1B5 && state < 0x200 && state >= 0x100)
#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.
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.
enum AVFieldOrder field_order
#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 rational to double.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
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.
#define PARSER_FLAG_COMPLETE_FRAMES
int rc_max_rate
maximum bitrate
void ff_parse_close(AVCodecParserContext *s)
int bit_rate
the average bitrate
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 numerator/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.
static const uint8_t start_code[]
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)
common internal api header.
static int mpegvideo_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
int repeat_pict
This field is used for proper frame duration computation in lavf.
#define PICTURE_START_CODE
const AVRational ff_mpeg12_frame_rate_tab[16]