From 22fa498bf9968e622e7d6326006c3f321a3bf2e4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 26 Oct 2017 19:44:26 +0200 Subject: vd_lavc: more aggressive frame dropping for intra only codecs Should speed up seeks. (Unfortunately it's useless for backstepping. Backstepping is like precise seeking, except we're unable to drop frames, as we can't know the previous frame if we drop it.) --- video/decode/lavc.h | 1 + video/decode/vd_lavc.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'video') diff --git a/video/decode/lavc.h b/video/decode/lavc.h index ff819d751b..8383c0a67f 100644 --- a/video/decode/lavc.h +++ b/video/decode/lavc.h @@ -37,6 +37,7 @@ typedef struct lavc_ctx { bool hwdec_failed; bool hwdec_notified; + bool intra_only; int framedrop_flags; // For HDR side-data caching diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index bf610e83e4..64b6249fd8 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -537,6 +537,9 @@ static void init_avctx(struct dec_video *vd, const char *decoder, if (!lavc_codec) return; + const AVCodecDescriptor *desc = avcodec_descriptor_get(lavc_codec->id); + ctx->intra_only = desc && (desc->props & AV_CODEC_PROP_INTRA_ONLY); + ctx->codec_timebase = mp_get_codec_timebase(vd->codec); // This decoder does not read pkt_timebase correctly yet. @@ -1059,12 +1062,15 @@ static bool prepare_decoding(struct dec_video *vd) return false; int drop = ctx->framedrop_flags; - if (drop) { - // hr-seek framedrop vs. normal framedrop - avctx->skip_frame = drop == 2 ? AVDISCARD_NONREF : opts->framedrop; + if (drop == 1) { + avctx->skip_frame = opts->framedrop; // normal framedrop + } else if (drop == 2) { + avctx->skip_frame = AVDISCARD_NONREF; // hr-seek framedrop + // Can be much more aggressive for true intra codecs. + if (ctx->intra_only) + avctx->skip_frame = AVDISCARD_ALL; } else { - // normal playback - avctx->skip_frame = ctx->skip_frame; + avctx->skip_frame = ctx->skip_frame; // normal playback } if (ctx->hwdec_request_reinit) @@ -1095,6 +1101,9 @@ static bool do_send_packet(struct dec_video *vd, struct demux_packet *pkt) if (!prepare_decoding(vd)) return false; + if (avctx->skip_frame == AVDISCARD_ALL) + return true; + AVPacket avpkt; mp_set_av_packet(&avpkt, pkt, &ctx->codec_timebase); -- cgit v1.2.3