return index;
}
+/**
+ *
+ * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
+ */
+int av_parser_change(AVCodecParserContext *s,
+ AVCodecContext *avctx,
+ uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size, int keyframe){
+
+ if(s && s->parser->split){
+ if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)){
+ int i= s->parser->split(avctx, buf, buf_size);
+ buf += i;
+ buf_size -= i;
+ }
+ }
+
+ *poutbuf= buf;
+ *poutbuf_size= buf_size;
+ if(avctx->extradata){
+ if( (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER))
+ /*||(s->pict_type != I_TYPE && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_NOKEY))*/
+ /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){
+ int size= buf_size + avctx->extradata_size;
+ *poutbuf_size= size;
+ *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
+
+ memcpy(*poutbuf, avctx->extradata, avctx->extradata_size);
+ memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
void av_parser_close(AVCodecParserContext *s)
{
if (s->parser->parser_close)
25025,
};
+//FIXME move into mpeg12.c
static void mpegvideo_extract_headers(AVCodecParserContext *s,
AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
int frame_rate_ext_n, frame_rate_ext_d;
int picture_structure, top_field_first, repeat_first_field, progressive_frame;
int horiz_size_ext, vert_size_ext, bit_rate_ext;
-
+//FIXME replace the crap with get_bits()
s->repeat_pict = 0;
buf_end = buf + buf_size;
while (buf < buf_end) {
pc->height = ((buf[1] & 0x0f) << 8) | buf[2];
avcodec_set_dimensions(avctx, pc->width, pc->height);
frame_rate_index = buf[3] & 0xf;
- pc->frame_rate = avctx->frame_rate = frame_rate_tab[frame_rate_index];
- avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE;
+ pc->frame_rate = avctx->time_base.den = frame_rate_tab[frame_rate_index];
+ avctx->time_base.num = MPEG1_FRAME_RATE_BASE;
avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400;
avctx->codec_id = CODEC_ID_MPEG1VIDEO;
avctx->sub_id = 1;
pc->height |=( vert_size_ext << 12);
avctx->bit_rate += (bit_rate_ext << 18) * 400;
avcodec_set_dimensions(avctx, pc->width, pc->height);
- avctx->frame_rate = pc->frame_rate * (frame_rate_ext_n + 1);
- avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1);
+ avctx->time_base.den = pc->frame_rate * (frame_rate_ext_n + 1);
+ avctx->time_base.num = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1);
avctx->codec_id = CODEC_ID_MPEG2VIDEO;
avctx->sub_id = 2; /* forces MPEG2 */
}
mpegvideo_extract_headers(s, avctx, buf, buf_size);
#if 0
printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
- s->pict_type, (double)avctx->frame_rate / avctx->frame_rate_base, s->repeat_pict);
+ s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict);
#endif
*poutbuf = (uint8_t *)buf;
return next;
}
+static int mpegvideo_split(AVCodecContext *avctx,
+ const uint8_t *buf, int buf_size)
+{
+ int i;
+ uint32_t state= -1;
+
+ for(i=0; i<buf_size; i++){
+ state= (state<<8) | buf[i];
+ if(state != 0x1B3 && state != 0x1B5 && state < 0x200 && state >= 0x100)
+ return i-3;
+ }
+ return 0;
+}
+
void ff_parse_close(AVCodecParserContext *s)
{
ParseContext *pc = s->priv_data;
return next;
}
+static int mpeg4video_split(AVCodecContext *avctx,
+ const uint8_t *buf, int buf_size)
+{
+ int i;
+ uint32_t state= -1;
+
+ for(i=0; i<buf_size; i++){
+ state= (state<<8) | buf[i];
+ if(state == 0x1B3 || state == 0x1B6)
+ return i-3;
+ }
+ return 0;
+}
+
/*************************/
typedef struct MpegAudioParseContext {
NULL,
mpegvideo_parse,
parse1_close,
+ mpegvideo_split,
};
AVCodecParser mpeg4video_parser = {
mpeg4video_parse_init,
mpeg4video_parse,
parse1_close,
+ mpeg4video_split,
};
AVCodecParser mpegaudio_parser = {