1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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>
This commit is contained in:
Michael Niedermayer 2013-01-04 20:28:45 +01:00
parent cf369d4449
commit fa11f36876
3 changed files with 33 additions and 33 deletions

View File

@ -1062,13 +1062,13 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt)
dts= pkt->dts; dts= pkt->dts;
if (s->last_scr == AV_NOPTS_VALUE) { 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) if (dts != AV_NOPTS_VALUE)
s->preload += av_rescale(-dts, AV_TIME_BASE, 90000); s->preload += av_rescale(-dts, AV_TIME_BASE, 90000);
s->last_scr = 0; s->last_scr = 0;
} else { } else {
s->last_scr = dts + preload; s->last_scr = dts - preload;
s->preload *= 2; s->preload = 0;
} }
preload = av_rescale(s->preload, 90000, AV_TIME_BASE); 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); av_log(ctx, AV_LOG_DEBUG, "First SCR: %"PRId64" First DTS: %"PRId64"\n", s->last_scr, dts + preload);

View File

@ -1,9 +1,9 @@
bba1d30df5e8309c8eac70722014ad92 *./tests/data/lavf/lavf.mpg ddc5cd5469eb8a0500f8a725baead5e5 *./tests/data/lavf/lavf.mpg
372736 ./tests/data/lavf/lavf.mpg 372736 ./tests/data/lavf/lavf.mpg
./tests/data/lavf/lavf.mpg CRC=0x5b136bb1 ./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 399360 ./tests/data/lavf/lavf.mpg
./tests/data/lavf/lavf.mpg CRC=0xd21e5631 ./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 372736 ./tests/data/lavf/lavf.mpg
./tests/data/lavf/lavf.mpg CRC=0x5b136bb1 ./tests/data/lavf/lavf.mpg CRC=0x5b136bb1

View File

@ -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: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:-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: 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: 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: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 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: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 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: 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: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: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 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:-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 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: 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: 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: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 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: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 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: 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: 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: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 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: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 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