28 const uint8_t *buf,
int buf_size)
31 const uint8_t *buf_end = buf + buf_size;
34 int frame_rate_ext_n, frame_rate_ext_d;
36 int horiz_size_ext, vert_size_ext, bit_rate_ext;
41 while (buf < buf_end) {
44 bytes_left = buf_end - buf;
47 if (bytes_left >= 2) {
52 if (bytes_left >= 7) {
53 pc->
width = (buf[0] << 4) | (buf[1] >> 4);
54 pc->
height = ((buf[1] & 0x0f) << 8) | buf[2];
59 frame_rate_index = buf[3] & 0xf;
62 avctx->
bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400;
68 if (bytes_left >= 1) {
69 ext_type = (buf[0] >> 4);
72 if (bytes_left >= 6) {
73 horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7);
74 vert_size_ext = (buf[2] >> 5) & 3;
75 bit_rate_ext = ((buf[2] & 0x1F)<<7) | (buf[3]>>1);
76 frame_rate_ext_n = (buf[5] >> 5) & 3;
77 frame_rate_ext_d = (buf[5] & 0x1f);
81 pc->
width |=(horiz_size_ext << 12);
82 pc->
height |=( vert_size_ext << 12);
83 avctx->
bit_rate += (bit_rate_ext << 18) * 400;
93 if (bytes_left >= 5) {
94 top_field_first = buf[3] & (1 << 7);
95 repeat_first_field = buf[3] & (1 << 1);
96 progressive_frame = buf[4] & (1 << 7);
100 if (repeat_first_field) {
106 }
else if (progressive_frame) {
131 const uint8_t **poutbuf,
int *poutbuf_size,
132 const uint8_t *buf,
int buf_size)
154 av_dlog(
NULL,
"pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
158 *poutbuf_size = buf_size;
163 const uint8_t *buf,
int buf_size)
168 for(i=0; i<buf_size; i++){
169 state= (state<<8) | buf[i];
170 if(state != 0x1B3 && 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 if lowres enabled.
struct ParseContext1 ParseContext1
const AVRational avpriv_frame_rate_tab[16]
#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...
void ff_parse1_close(AVCodecParserContext *s)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int top_field_first
preferred ID for MPEG-1/2 video decoding
int has_b_frames
Size of the frame reordering buffer in the decoder.
int sub_id
Some codecs need additional format info.
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
int bit_rate
the average bitrate
int width
picture width / height.
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
const uint8_t * avpriv_mpv_find_start_code(const uint8_t *restrict p, const uint8_t *end, uint32_t *restrict state)
main external API structure.
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 void mpegvideo_extract_headers(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t *buf, int buf_size)
struct AVCodecContext * avctx
#define PARSER_FLAG_COMPLETE_FRAMES
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