0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

encode: fix PTS unit mismatch

This used MP_NOPTS_VALUE to compare with ffmpeg-style int64_t PTS
values. This probably happened to work, because both constants use the
same value.
This commit is contained in:
wm4 2014-05-10 10:32:23 +02:00
parent bc9a86c392
commit fc385baf02
2 changed files with 11 additions and 11 deletions

View File

@ -166,8 +166,8 @@ static int init(struct ao *ao)
// but at least one!
ac->framecount = FFMAX(ac->framecount, 1);
ac->savepts = MP_NOPTS_VALUE;
ac->lastpts = MP_NOPTS_VALUE;
ac->savepts = AV_NOPTS_VALUE;
ac->lastpts = AV_NOPTS_VALUE;
ao->untimed = true;
@ -251,7 +251,7 @@ static int encode(struct ao *ao, double apts, void **data)
}
int64_t frame_pts = av_rescale_q(frame->pts, ac->stream->codec->time_base, ac->worst_time_base);
if (ac->lastpts != MP_NOPTS_VALUE && frame_pts <= ac->lastpts) {
if (ac->lastpts != AV_NOPTS_VALUE && frame_pts <= ac->lastpts) {
// this indicates broken video
// (video pts failing to increase fast enough to match audio)
MP_WARN(ao, "audio frame pts went backwards (%d <- %d), autofixed\n",
@ -265,7 +265,7 @@ static int encode(struct ao *ao, double apts, void **data)
status = avcodec_encode_audio2(ac->stream->codec, &packet, frame, &gotpacket);
if (!status) {
if (ac->savepts == MP_NOPTS_VALUE)
if (ac->savepts == AV_NOPTS_VALUE)
ac->savepts = frame->pts;
}
@ -310,7 +310,7 @@ static int encode(struct ao *ao, double apts, void **data)
packet.duration = av_rescale_q(packet.duration, ac->stream->codec->time_base,
ac->stream->time_base);
ac->savepts = MP_NOPTS_VALUE;
ac->savepts = AV_NOPTS_VALUE;
if (encode_lavc_write_frame(ao->encode_lavc_ctx, &packet) < 0) {
MP_ERR(ao, "error writing at %f %f/%f\n",

View File

@ -134,9 +134,9 @@ static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
goto error;
}
vc->lastipts = MP_NOPTS_VALUE;
vc->lastframeipts = MP_NOPTS_VALUE;
vc->lastencodedipts = MP_NOPTS_VALUE;
vc->lastipts = AV_NOPTS_VALUE;
vc->lastframeipts = AV_NOPTS_VALUE;
vc->lastencodedipts = AV_NOPTS_VALUE;
if (pix_fmt == AV_PIX_FMT_NONE) {
MP_FATAL(vo, "Format %s not supported by lavc.\n",
@ -407,7 +407,7 @@ static void draw_image_unlocked(struct vo *vo, mp_image_t *mpi)
}
}
if (vc->lastipts != MP_NOPTS_VALUE) {
if (vc->lastipts != AV_NOPTS_VALUE) {
// we have a valid image in lastimg
while (vc->lastipts < frameipts) {
@ -417,7 +417,7 @@ static void draw_image_unlocked(struct vo *vo, mp_image_t *mpi)
// we will ONLY encode this frame if it can be encoded at at least
// vc->mindeltapts after the last encoded frame!
int64_t skipframes =
(vc->lastencodedipts == MP_NOPTS_VALUE)
(vc->lastencodedipts == AV_NOPTS_VALUE)
? 0
: vc->lastencodedipts + vc->mindeltapts - vc->lastipts;
if (skipframes < 0)
@ -464,7 +464,7 @@ static void draw_image_unlocked(struct vo *vo, mp_image_t *mpi)
} while (size > 0);
} else {
if (frameipts >= vc->lastframeipts) {
if (vc->lastframeipts != MP_NOPTS_VALUE && vc->lastdisplaycount != 1)
if (vc->lastframeipts != AV_NOPTS_VALUE && vc->lastdisplaycount != 1)
MP_INFO(vo, "Frame at pts %d got displayed %d times\n",
(int) vc->lastframeipts, vc->lastdisplaycount);
mp_image_setrefp(&vc->lastimg, mpi);