[FFmpeg-devel] [PATCH] avcodec/libvpxenc: return quantizer parameter for an encoded frame
Anton Khirnov
anton at khirnov.net
Tue Apr 5 13:03:09 EEST 2022
Quoting Danil Chapovalov (2022-03-24 18:25:24)
> ---
> libavcodec/libvpxenc.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index dff1d06b0e..5db31db5dc 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -1250,6 +1250,7 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
> int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0);
> uint8_t *side_data;
> int pict_type;
> + int quality;
>
> if (ret < 0)
> return ret;
> @@ -1264,7 +1265,13 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
> pict_type = AV_PICTURE_TYPE_P;
> }
>
> - ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1,
> + ret = vpx_codec_control(&((VPxContext *)avctx->priv_data)->encoder,
The cast is really ugly, just add a local variable for priv_data.
> + VP8E_GET_LAST_QUANTIZER_64, &quality);
> + if (ret != VPX_CODEC_OK) {
> + quality = 0;
> + }
> +
> + ff_side_data_set_encoder_stats(pkt, quality, cx_frame->sse + 1,
other encoders multiply the quantizer by FF_QP2LAMBDA
--
Anton Khirnov
More information about the ffmpeg-devel
mailing list