mpegvideo: don't pretend the first frame is always a key frame

Signed-off-by: Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>

Modify the parser initialization so that parsers can
set pict_type themselves.  Use this in the mpegvideo parser
so that initial frames are not unconditionally I frames.
I have had this in my tree for several years.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/3/merge
Wolfram Gloger 13 years ago committed by Michael Niedermayer
parent 6f9803e5e0
commit f8353d5fda
  1. 7
      libavcodec/mpegvideo_parser.c
  2. 4
      libavcodec/parser.c
  3. 6
      tests/ref/seek/lavf_mpg

@ -182,9 +182,16 @@ static int mpegvideo_split(AVCodecContext *avctx,
return 0;
}
static int mpegvideo_parse_init(AVCodecParserContext *s)
{
s->pict_type = AV_PICTURE_TYPE_NONE; // first frame might be partial
return 0;
}
AVCodecParser ff_mpegvideo_parser = {
.codec_ids = { CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO },
.priv_data_size = sizeof(struct MpvParseContext),
.parser_init = mpegvideo_parse_init,
.parser_parse = mpegvideo_parse,
.parser_close = ff_parse_close,
.split = mpegvideo_split,

@ -63,6 +63,8 @@ AVCodecParserContext *av_parser_init(int codec_id)
av_free(s);
return NULL;
}
s->fetch_timestamp=1;
s->pict_type = AV_PICTURE_TYPE_I;
if (parser->parser_init) {
ret = parser->parser_init(s);
if (ret != 0) {
@ -71,8 +73,6 @@ AVCodecParserContext *av_parser_init(int codec_id)
return NULL;
}
}
s->fetch_timestamp=1;
s->pict_type = AV_PICTURE_TYPE_I;
s->key_frame = -1;
s->convergence_duration = 0;
s->dts_sync_point = INT_MIN;

@ -16,7 +16,7 @@ ret: 0 st: 1 flags:1 dts: 1.000000 pts: 1.000000 pos: 2048 size: 208
ret: 0 st:-1 flags:1 ts:-0.740831
ret: 0 st: 1 flags:1 dts: 1.000000 pts: 1.000000 pos: 2048 size: 208
ret: 0 st: 0 flags:0 ts: 2.153333
ret: 0 st: 0 flags:1 dts: 1.920000 pts: 1.960000 pos: 339968 size: 681
ret: 0 st: 0 flags:0 dts: 1.920000 pts: 1.960000 pos: 339968 size: 681
ret: 0 st: 0 flags:1 ts: 1.047500
ret: 0 st: 0 flags:0 dts: 1.040000 pts: 1.080000 pos: 40960 size: 16073
ret: 0 st: 1 flags:0 ts:-0.058333
@ -30,7 +30,7 @@ ret: 0 st: 1 flags:1 dts: 1.000000 pts: 1.000000 pos: 2048 size: 208
ret: 0 st: 0 flags:0 ts:-0.481667
ret: 0 st: 1 flags:1 dts: 1.000000 pts: 1.000000 pos: 2048 size: 208
ret: 0 st: 0 flags:1 ts: 2.412500
ret: 0 st: 0 flags:1 dts: 1.920000 pts: 1.960000 pos: 339968 size: 681
ret: 0 st: 0 flags:0 dts: 1.920000 pts: 1.960000 pos: 339968 size: 681
ret: 0 st: 1 flags:0 ts: 1.306667
ret: 0 st: 1 flags:1 dts: 1.522444 pts: 1.522444 pos: 342028 size: 314
ret: 0 st: 1 flags:1 ts: 0.200844
@ -38,7 +38,7 @@ ret: 0 st: 1 flags:1 dts: 1.000000 pts: 1.000000 pos: 2048 size: 208
ret: 0 st:-1 flags:0 ts:-0.904994
ret: 0 st: 1 flags:1 dts: 1.000000 pts: 1.000000 pos: 2048 size: 208
ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st: 0 flags:1 dts: 1.920000 pts: 1.960000 pos: 339968 size: 681
ret: 0 st: 0 flags:0 dts: 1.920000 pts: 1.960000 pos: 339968 size: 681
ret: 0 st: 0 flags:0 ts: 0.883344
ret: 0 st: 1 flags:1 dts: 1.000000 pts: 1.000000 pos: 2048 size: 208
ret: 0 st: 0 flags:1 ts:-0.222489

Loading…
Cancel
Save