vd_lavc: slightly improve codec_timebase hack

The mp_set_av_packet()/mp_pts_from_av() functions check whether the
timebase is set at all (i.e. AVRational.num!=0), so there's no need to
fiddle with pointers.
This commit is contained in:
wm4 2016-03-24 16:38:14 +01:00
parent 30e94fa711
commit b34befbab8
1 changed files with 3 additions and 4 deletions

View File

@ -646,7 +646,6 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
vd_ffmpeg_ctx *ctx = vd->priv;
AVCodecContext *avctx = ctx->avctx;
struct vd_lavc_params *opts = ctx->opts->vd_lavc_params;
AVRational *tb = ctx->codec_timebase.num ? &ctx->codec_timebase : NULL;
AVPacket pkt;
if (!avctx)
@ -660,7 +659,7 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
avctx->skip_frame = ctx->skip_frame;
}
mp_set_av_packet(&pkt, packet, tb);
mp_set_av_packet(&pkt, packet, &ctx->codec_timebase);
ctx->flushing |= !pkt.data;
// Reset decoder if hw state got reset, or new data comes during flushing.
@ -723,8 +722,8 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
return;
}
assert(mpi->planes[0] || mpi->planes[3]);
mpi->pts = mp_pts_from_av(ctx->pic->pkt_pts, tb);
mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, tb);
mpi->pts = mp_pts_from_av(ctx->pic->pkt_pts, &ctx->codec_timebase);
mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, &ctx->codec_timebase);
struct mp_image_params params;
update_image_params(vd, ctx->pic, &params);