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
pull/126/head
Michael Niedermayer 20 years ago
parent 30bc6613fe
commit 7cbaa7bafa
  1. 7
      libavcodec/avcodec.h
  2. 10
      libavcodec/parser.c
  3. 2
      libavformat/avformat.h
  4. 1
      libavformat/avidec.c
  5. 5
      libavformat/utils.c

@ -21,8 +21,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s) #define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s #define AV_TOSTRING(s) #s
#define LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+1) #define LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+2)
#define LIBAVCODEC_VERSION 49.0.1 #define LIBAVCODEC_VERSION 49.0.2
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) #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_offset[AV_PARSER_PTS_NB];
int64_t cur_frame_pts[AV_PARSER_PTS_NB]; int64_t cur_frame_pts[AV_PARSER_PTS_NB];
int64_t cur_frame_dts[AV_PARSER_PTS_NB]; int64_t cur_frame_dts[AV_PARSER_PTS_NB];
int flags;
#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
} AVCodecParserContext; } AVCodecParserContext;
typedef struct AVCodecParser { typedef struct AVCodecParser {

@ -430,6 +430,9 @@ static int mpegvideo_parse(AVCodecParserContext *s,
ParseContext *pc= &pc1->pc; ParseContext *pc= &pc1->pc;
int next; int next;
if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
next= buf_size;
}else{
next= ff_mpeg1_find_frame_end(pc, buf, buf_size); next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) { if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
@ -437,6 +440,8 @@ static int mpegvideo_parse(AVCodecParserContext *s,
*poutbuf_size = 0; *poutbuf_size = 0;
return buf_size; return buf_size;
} }
}
/* we have a full frame : we just parse the first few MPEG headers /* we have a full frame : we just parse the first few MPEG headers
to have the full timing information. The time take by this to have the full timing information. The time take by this
function should be negligible for uncorrupted streams */ function should be negligible for uncorrupted streams */
@ -506,6 +511,7 @@ static int av_mpeg4_decode_header(AVCodecParserContext *s1,
if (s->width) { if (s->width) {
avcodec_set_dimensions(avctx, s->width, s->height); avcodec_set_dimensions(avctx, s->width, s->height);
} }
s1->pict_type= s->pict_type;
pc->first_picture = 0; pc->first_picture = 0;
return ret; return ret;
} }
@ -529,6 +535,9 @@ static int mpeg4video_parse(AVCodecParserContext *s,
ParseContext *pc = s->priv_data; ParseContext *pc = s->priv_data;
int next; int next;
if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
next= buf_size;
}else{
next= ff_mpeg4_find_frame_end(pc, buf, buf_size); next= ff_mpeg4_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) { if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
@ -536,6 +545,7 @@ static int mpeg4video_parse(AVCodecParserContext *s,
*poutbuf_size = 0; *poutbuf_size = 0;
return buf_size; return buf_size;
} }
}
av_mpeg4_decode_header(s, avctx, buf, buf_size); av_mpeg4_decode_header(s, avctx, buf, buf_size);
*poutbuf = (uint8_t *)buf; *poutbuf = (uint8_t *)buf;

@ -248,7 +248,7 @@ typedef struct AVStream {
char language[4]; /* ISO 639 3-letter language code (empty string if undefined) */ char language[4]; /* ISO 639 3-letter language code (empty string if undefined) */
/* av_read_frame() support */ /* av_read_frame() support */
int need_parsing; int need_parsing; ///< 1->full parsing needed, 2->only parse headers dont repack
struct AVCodecParserContext *parser; struct AVCodecParserContext *parser;
int64_t cur_dts; 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); st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
if (st->codec->codec_id == CODEC_ID_XAN_WC4) if (st->codec->codec_id == CODEC_ID_XAN_WC4)
xan_video = 1; 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); // url_fskip(pb, size - 5 * 4);
break; break;
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:

@ -927,6 +927,8 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
if (!st->parser) { if (!st->parser) {
/* no parser available : just output the raw packets */ /* no parser available : just output the raw packets */
st->need_parsing = 0; 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 //only for the split stuff
if (!st->parser) { if (!st->parser) {
st->parser = av_parser_init(st->codec->codec_id); st->parser = av_parser_init(st->codec->codec_id);
if(st->need_parsing == 2 && st->parser){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
} }
} }

Loading…
Cancel
Save