diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-01-04 20:28:45 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-01-04 20:58:59 +0100 |
commit | fa11f368764f0e4a562d4d8e45da01132c9abf74 (patch) | |
tree | e74188c91b8a344f0c00fbeb5b5bda6eb6105488 | |
parent | cf369d4449857b094e4ec91e29eaeaa7e7334bad (diff) | |
download | ffmpeg-fa11f368764f0e4a562d4d8e45da01132c9abf74.tar.gz |
mpegpsenc: avoid shifting dts/pts
Only shift if needed to avoid negative scr when requested
or for dvd.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/mpegenc.c | 6 | ||||
-rw-r--r-- | tests/ref/lavf/mpg | 6 | ||||
-rw-r--r-- | tests/ref/seek/lavf-mpg | 54 |
3 files changed, 33 insertions, 33 deletions
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 23ba8edd67..b467bb5de5 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -1062,13 +1062,13 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt) dts= pkt->dts; if (s->last_scr == AV_NOPTS_VALUE) { - if (dts == AV_NOPTS_VALUE || s->is_dvd) { + if (dts == AV_NOPTS_VALUE || (dts < preload && ctx->avoid_negative_ts) || s->is_dvd) { if (dts != AV_NOPTS_VALUE) s->preload += av_rescale(-dts, AV_TIME_BASE, 90000); s->last_scr = 0; } else { - s->last_scr = dts + preload; - s->preload *= 2; + s->last_scr = dts - preload; + s->preload = 0; } preload = av_rescale(s->preload, 90000, AV_TIME_BASE); av_log(ctx, AV_LOG_DEBUG, "First SCR: %"PRId64" First DTS: %"PRId64"\n", s->last_scr, dts + preload); diff --git a/tests/ref/lavf/mpg b/tests/ref/lavf/mpg index c880fe680c..35465ed127 100644 --- a/tests/ref/lavf/mpg +++ b/tests/ref/lavf/mpg @@ -1,9 +1,9 @@ -bba1d30df5e8309c8eac70722014ad92 *./tests/data/lavf/lavf.mpg +ddc5cd5469eb8a0500f8a725baead5e5 *./tests/data/lavf/lavf.mpg 372736 ./tests/data/lavf/lavf.mpg ./tests/data/lavf/lavf.mpg CRC=0x5b136bb1 -f716380af800eb85112ba87c99845ac0 *./tests/data/lavf/lavf.mpg +c4e9026e5f57777a71762d68994fc3a9 *./tests/data/lavf/lavf.mpg 399360 ./tests/data/lavf/lavf.mpg ./tests/data/lavf/lavf.mpg CRC=0xd21e5631 -e396acf92df0c0b8753f54a15b5770ae *./tests/data/lavf/lavf.mpg +bb22933de60193bce9032f67ce6fcc23 *./tests/data/lavf/lavf.mpg 372736 ./tests/data/lavf/lavf.mpg ./tests/data/lavf/lavf.mpg CRC=0x5b136bb1 diff --git a/tests/ref/seek/lavf-mpg b/tests/ref/seek/lavf-mpg index 935eae1f60..e804b84739 100644 --- a/tests/ref/seek/lavf-mpg +++ b/tests/ref/seek/lavf-mpg @@ -1,53 +1,53 @@ -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:0 dts: 1.880000 pts: 1.920000 pos: 327680 size: 12629 +ret: 0 st: 1 flags:1 dts: 1.051544 pts: 1.051544 pos: 342028 size: 314 ret: 0 st: 0 flags:0 ts: 0.788333 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 0 flags:0 dts: 0.820000 pts: 0.860000 pos: 118784 size: 14717 ret: 0 st: 0 flags:1 ts:-0.317500 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st: 1 flags:0 ts: 2.576667 -ret: 0 st: 1 flags:1 dts: 1.772767 pts: 1.772767 pos: 368652 size: 379 +ret: 0 st: 1 flags:1 dts: 1.312767 pts: 1.312767 pos: 368652 size: 379 ret: 0 st: 1 flags:1 ts: 1.470833 -ret: 0 st: 1 flags:1 dts: 1.250322 pts: 1.250322 pos: 145408 size: 261 +ret: 0 st: 1 flags:1 dts: 1.312767 pts: 1.312767 pos: 368652 size: 379 ret: 0 st:-1 flags:0 ts: 0.365002 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st:-1 flags:1 ts:-0.740831 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st: 0 flags:0 ts: 2.153333 -ret: 0 st: 1 flags:1 dts: 1.511544 pts: 1.511544 pos: 342028 size: 314 +ret: 0 st: 1 flags:1 dts: 1.051544 pts: 1.051544 pos: 342028 size: 314 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: 0 flags:0 dts: 1.020000 pts: 1.060000 pos: 196608 size: 17639 ret: 0 st: 1 flags:0 ts:-0.058333 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st: 1 flags:1 ts: 2.835833 -ret: 0 st: 1 flags:1 dts: 1.772767 pts: 1.772767 pos: 368652 size: 379 +ret: 0 st: 1 flags:1 dts: 1.312767 pts: 1.312767 pos: 368652 size: 379 ret: 0 st:-1 flags:0 ts: 1.730004 -ret: 0 st: 0 flags:0 dts: 1.760000 pts: 1.800000 pos: 292864 size: 12894 +ret: 0 st: 1 flags:1 dts: 1.051544 pts: 1.051544 pos: 342028 size: 314 ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 0 flags:0 dts: 0.620000 pts: 0.660000 pos: 55296 size: 14239 ret: 0 st: 0 flags:0 ts:-0.481667 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st: 0 flags:1 ts: 2.412500 -ret: 0 st: 1 flags:1 dts: 1.511544 pts: 1.511544 pos: 342028 size: 314 +ret: 0 st: 1 flags:1 dts: 1.051544 pts: 1.051544 pos: 342028 size: 314 ret: 0 st: 1 flags:0 ts: 1.306667 -ret: 0 st: 1 flags:1 dts: 1.511544 pts: 1.511544 pos: 342028 size: 314 +ret: 0 st: 1 flags:1 dts: 1.312767 pts: 1.312767 pos: 368652 size: 379 ret: 0 st: 1 flags:1 ts: 0.200844 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st:-1 flags:0 ts:-0.904994 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st:-1 flags:1 ts: 1.989173 -ret: 0 st: 1 flags:1 dts: 1.511544 pts: 1.511544 pos: 342028 size: 314 +ret: 0 st: 1 flags:1 dts: 1.051544 pts: 1.051544 pos: 342028 size: 314 ret: 0 st: 0 flags:0 ts: 0.883344 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 0 flags:0 dts: 0.900000 pts: 0.940000 pos: 147456 size: 12755 ret: 0 st: 0 flags:1 ts:-0.222489 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st: 1 flags:0 ts: 2.671678 -ret: 0 st: 1 flags:1 dts: 1.772767 pts: 1.772767 pos: 368652 size: 379 +ret: 0 st: 1 flags:1 dts: 1.312767 pts: 1.312767 pos: 368652 size: 379 ret: 0 st: 1 flags:1 ts: 1.565844 -ret: 0 st: 1 flags:1 dts: 1.511544 pts: 1.511544 pos: 342028 size: 314 +ret: 0 st: 1 flags:1 dts: 1.312767 pts: 1.312767 pos: 368652 size: 379 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 1 flags:1 dts: 0.989089 pts: 0.989089 pos: 2048 size: 208 +ret: 0 st: 1 flags:1 dts: 0.529089 pts: 0.529089 pos: 2048 size: 208 |