[FFmpeg-devel] [PATCH] Only using st->parser->pos when doing repacking in the parser.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Apr 24 18:55:54 CEST 2011


---
 libavformat/utils.c      |    7 ++++++-
 tests/ref/seek/h261_avi  |   40 ++++++++++++++++++++--------------------
 tests/ref/seek/h263_avi  |   40 ++++++++++++++++++++--------------------
 tests/ref/seek/h263p_avi |   40 ++++++++++++++++++++--------------------
 4 files changed, 66 insertions(+), 61 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index e7ce911..810856f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1069,7 +1069,12 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
                     pkt->stream_index = st->index;
                     pkt->pts = st->parser->pts;
                     pkt->dts = st->parser->dts;
-                    pkt->pos = st->parser->pos;
+                    pkt->pos = st->cur_pkt.pos;
+                    // When not repacking, using parser pos can at best break
+                    // things since parsers are not designed to handle the
+                    // case where current packet pos + size < next packet pos
+                    if (st->need_parsing == AVSTREAM_PARSE_FULL)
+                        pkt->pos = st->parser->pos;
                     if(pkt->data == st->cur_pkt.data && pkt->size == st->cur_pkt.size){
                         s->cur_st = NULL;
                         pkt->destruct= st->cur_pkt.destruct;
diff --git a/tests/ref/seek/h261_avi b/tests/ref/seek/h261_avi
index d31364f..b60a1ca 100644
--- a/tests/ref/seek/h261_avi
+++ b/tests/ref/seek/h261_avi
@@ -1,46 +1,46 @@
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size:  9645
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  15314 size:  9645
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size:  9645
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  15314 size:  9645
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 126514 size: 11377
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 137900 size: 11377
 ret: 0         st: 0 flags:0  ts: 0.800000
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  82072 size: 10322
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  92402 size: 10322
 ret:-1         st: 0 flags:1  ts:-0.320000
 ret:-1         st:-1 flags:0  ts: 2.576668
 ret: 0         st:-1 flags:1  ts: 1.470835
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 126514 size: 11377
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 137900 size: 11377
 ret: 0         st: 0 flags:0  ts: 0.360000
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  44678 size:  9404
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  54090 size:  9404
 ret:-1         st: 0 flags:1  ts:-0.760000
 ret:-1         st:-1 flags:0  ts: 2.153336
 ret: 0         st:-1 flags:1  ts: 1.047503
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  82072 size: 10322
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  92402 size: 10322
 ret: 0         st: 0 flags:0  ts:-0.040000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size:  9645
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  15314 size:  9645
 ret: 0         st: 0 flags:1  ts: 2.840000
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 175882 size: 11707
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 187598 size: 11707
 ret: 0         st:-1 flags:0  ts: 1.730004
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 175882 size: 11707
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 187598 size: 11707
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  44678 size:  9404
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  54090 size:  9404
 ret: 0         st: 0 flags:0  ts:-0.480000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size:  9645
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  15314 size:  9645
 ret: 0         st: 0 flags:1  ts: 2.400000
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 175882 size: 11707
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 187598 size: 11707
 ret: 0         st:-1 flags:0  ts: 1.306672
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 126514 size: 11377
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 137900 size: 11377
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size:  9645
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  15314 size:  9645
 ret: 0         st: 0 flags:0  ts:-0.920000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size:  9645
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  15314 size:  9645
 ret: 0         st: 0 flags:1  ts: 2.000000
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 175882 size: 11707
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 187598 size: 11707
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  82072 size: 10322
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  92402 size: 10322
 ret:-1         st:-1 flags:1  ts:-0.222493
 ret:-1         st: 0 flags:0  ts: 2.680000
 ret: 0         st: 0 flags:1  ts: 1.560000
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 126514 size: 11377
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 137900 size: 11377
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  44678 size:  9404
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  54090 size:  9404
 ret:-1         st:-1 flags:1  ts:-0.645825
diff --git a/tests/ref/seek/h263_avi b/tests/ref/seek/h263_avi
index 8b1795c..4b2aeea 100644
--- a/tests/ref/seek/h263_avi
+++ b/tests/ref/seek/h263_avi
@@ -1,46 +1,46 @@
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 10381
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  16050 size: 10381
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 10381
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  16050 size: 10381
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 103714 size: 12296
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 116018 size: 12296
 ret: 0         st: 0 flags:0  ts: 0.800000
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  66804 size: 11128
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  77940 size: 11128
 ret:-1         st: 0 flags:1  ts:-0.320000
 ret:-1         st:-1 flags:0  ts: 2.576668
 ret: 0         st:-1 flags:1  ts: 1.470835
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 103714 size: 12296
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 116018 size: 12296
 ret: 0         st: 0 flags:0  ts: 0.360000
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  36450 size: 10090
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  46548 size: 10090
 ret:-1         st: 0 flags:1  ts:-0.760000
 ret:-1         st:-1 flags:0  ts: 2.153336
 ret: 0         st:-1 flags:1  ts: 1.047503
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  66804 size: 11128
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  77940 size: 11128
 ret: 0         st: 0 flags:0  ts:-0.040000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 10381
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  16050 size: 10381
 ret: 0         st: 0 flags:1  ts: 2.840000
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 144558 size: 12731
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 157298 size: 12731
 ret: 0         st:-1 flags:0  ts: 1.730004
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 144558 size: 12731
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 157298 size: 12731
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  36450 size: 10090
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  46548 size: 10090
 ret: 0         st: 0 flags:0  ts:-0.480000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 10381
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  16050 size: 10381
 ret: 0         st: 0 flags:1  ts: 2.400000
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 144558 size: 12731
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 157298 size: 12731
 ret: 0         st:-1 flags:0  ts: 1.306672
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 103714 size: 12296
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 116018 size: 12296
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 10381
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  16050 size: 10381
 ret: 0         st: 0 flags:0  ts:-0.920000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 10381
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  16050 size: 10381
 ret: 0         st: 0 flags:1  ts: 2.000000
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 144558 size: 12731
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 157298 size: 12731
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  66804 size: 11128
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  77940 size: 11128
 ret:-1         st:-1 flags:1  ts:-0.222493
 ret:-1         st: 0 flags:0  ts: 2.680000
 ret: 0         st: 0 flags:1  ts: 1.560000
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 103714 size: 12296
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 116018 size: 12296
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  36450 size: 10090
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  46548 size: 10090
 ret:-1         st:-1 flags:1  ts:-0.645825
diff --git a/tests/ref/seek/h263p_avi b/tests/ref/seek/h263p_avi
index 51e6952..32060b0 100644
--- a/tests/ref/seek/h263p_avi
+++ b/tests/ref/seek/h263p_avi
@@ -1,46 +1,46 @@
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 36208
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  41876 size: 36208
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 36208
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  41876 size: 36208
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 569938 size: 45151
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 615098 size: 45151
 ret: 0         st: 0 flags:0  ts: 0.800000
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 355988 size: 40907
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 396904 size: 40907
 ret:-1         st: 0 flags:1  ts:-0.320000
 ret:-1         st:-1 flags:0  ts: 2.576668
 ret: 0         st:-1 flags:1  ts: 1.470835
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 569938 size: 45151
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 615098 size: 45151
 ret: 0         st: 0 flags:0  ts: 0.360000
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 171054 size: 36515
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 207578 size: 36515
 ret:-1         st: 0 flags:1  ts:-0.760000
 ret:-1         st:-1 flags:0  ts: 2.153336
 ret: 0         st:-1 flags:1  ts: 1.047503
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 355988 size: 40907
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 396904 size: 40907
 ret: 0         st: 0 flags:0  ts:-0.040000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 36208
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  41876 size: 36208
 ret: 0         st: 0 flags:1  ts: 2.840000
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 804378 size: 46411
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 850798 size: 46411
 ret: 0         st:-1 flags:0  ts: 1.730004
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 804378 size: 46411
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 850798 size: 46411
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 171054 size: 36515
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 207578 size: 36515
 ret: 0         st: 0 flags:0  ts:-0.480000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 36208
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  41876 size: 36208
 ret: 0         st: 0 flags:1  ts: 2.400000
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 804378 size: 46411
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 850798 size: 46411
 ret: 0         st:-1 flags:0  ts: 1.306672
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 569938 size: 45151
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 615098 size: 45151
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 36208
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  41876 size: 36208
 ret: 0         st: 0 flags:0  ts:-0.920000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5660 size: 36208
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:  41876 size: 36208
 ret: 0         st: 0 flags:1  ts: 2.000000
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 804378 size: 46411
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos: 850798 size: 46411
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 355988 size: 40907
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 396904 size: 40907
 ret:-1         st:-1 flags:1  ts:-0.222493
 ret:-1         st: 0 flags:0  ts: 2.680000
 ret: 0         st: 0 flags:1  ts: 1.560000
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 569938 size: 45151
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos: 615098 size: 45151
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 171054 size: 36515
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 207578 size: 36515
 ret:-1         st:-1 flags:1  ts:-0.645825
-- 
1.7.4.4



More information about the ffmpeg-devel mailing list