Commit 7cbaa7ba authored by Michael Niedermayer's avatar Michael Niedermayer

parse pict_type for streams in avi

fix mpeg4 parser so it outputs te pict_type
support header only parseing without repacking

Originally committed as revision 4527 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 30bc6613
......@@ -21,8 +21,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
#define LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+1)
#define LIBAVCODEC_VERSION 49.0.1
#define LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+2)
#define LIBAVCODEC_VERSION 49.0.2
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
......@@ -2324,6 +2324,9 @@ typedef struct AVCodecParserContext {
int64_t cur_frame_offset[AV_PARSER_PTS_NB];
int64_t cur_frame_pts[AV_PARSER_PTS_NB];
int64_t cur_frame_dts[AV_PARSER_PTS_NB];
int flags;
#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
} AVCodecParserContext;
typedef struct AVCodecParser {
......
......@@ -429,13 +429,18 @@ static int mpegvideo_parse(AVCodecParserContext *s,
ParseContext1 *pc1 = s->priv_data;
ParseContext *pc= &pc1->pc;
int next;
next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
next= buf_size;
}else{
next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
}
/* we have a full frame : we just parse the first few MPEG headers
to have the full timing information. The time take by this
......@@ -506,6 +511,7 @@ static int av_mpeg4_decode_header(AVCodecParserContext *s1,
if (s->width) {
avcodec_set_dimensions(avctx, s->width, s->height);
}
s1->pict_type= s->pict_type;
pc->first_picture = 0;
return ret;
}
......@@ -529,12 +535,16 @@ static int mpeg4video_parse(AVCodecParserContext *s,
ParseContext *pc = s->priv_data;
int next;
next= ff_mpeg4_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
next= buf_size;
}else{
next= ff_mpeg4_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
}
av_mpeg4_decode_header(s, avctx, buf, buf_size);
......
......@@ -248,7 +248,7 @@ typedef struct AVStream {
char language[4]; /* ISO 639 3-letter language code (empty string if undefined) */
/* av_read_frame() support */
int need_parsing;
int need_parsing; ///< 1->full parsing needed, 2->only parse headers dont repack
struct AVCodecParserContext *parser;
int64_t cur_dts;
......
......@@ -302,6 +302,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
if (st->codec->codec_id == CODEC_ID_XAN_WC4)
xan_video = 1;
st->need_parsing = 2; //only parse headers dont do slower repacketization, this is needed to get the pict type which is needed for generating correct pts
// url_fskip(pb, size - 5 * 4);
break;
case CODEC_TYPE_AUDIO:
......
......@@ -927,6 +927,8 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
if (!st->parser) {
/* no parser available : just output the raw packets */
st->need_parsing = 0;
}else if(st->need_parsing == 2){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
}
}
......@@ -1846,6 +1848,9 @@ int av_find_stream_info(AVFormatContext *ic)
//only for the split stuff
if (!st->parser) {
st->parser = av_parser_init(st->codec->codec_id);
if(st->need_parsing == 2 && st->parser){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment