[FFmpeg-devel] [PATCH 23/30] lavc/ffv1enc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Wed Jan 4 19:27:04 EET 2023
Anton Khirnov:
> ---
> libavcodec/ffv1enc.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
> index 0237ac48eb..553abb558f 100644
> --- a/libavcodec/ffv1enc.c
> +++ b/libavcodec/ffv1enc.c
> @@ -1233,7 +1233,20 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
> pkt->size = buf_p - pkt->data;
> pkt->pts =
> pkt->dts = pict->pts;
> + pkt->duration = pict->duration;
> pkt->flags |= AV_PKT_FLAG_KEY * f->key_frame;
> +
> + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
> + pkt->opaque = pict->opaque;
> + if (pict->opaque_ref) {
> + pkt->opaque_ref = av_buffer_ref(pict->opaque_ref);
> + if (!pkt->opaque_ref)
> + return AVERROR(ENOMEM);
> + }
> + }
> +
> + avctx->reordered_opaque = pict->reordered_opaque;
> +
> *got_packet = 1;
>
> return 0;
> @@ -1272,7 +1285,8 @@ const FFCodec ff_ffv1_encoder = {
> .p.type = AVMEDIA_TYPE_VIDEO,
> .p.id = AV_CODEC_ID_FFV1,
> .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
> - AV_CODEC_CAP_SLICE_THREADS,
> + AV_CODEC_CAP_SLICE_THREADS |
> + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
> .priv_data_size = sizeof(FFV1Context),
> .init = encode_init,
> FF_CODEC_ENCODE_CB(encode_frame),
FFV1's does not have frame reordering (no AV_CODEC_PROP_REORDER for the
codec descriptor); the encoder just has the AV_CODEC_CAP_DELAY set to
write stats in case this was the first pass of a two-pass encoding (this
could actually be moved . Otherwise the encoder is a simple
one-in-one-out encoder with no delay at all. Something similar is true
for the FLAC encoder (it has the DELAY cap so that it can output a
side-data only packet with updated extradata when flushing) and adxenc.
Maybe we should have an internal capability to allow to set these
properties generically for these codecs, too?
- Andreas
More information about the ffmpeg-devel
mailing list