[FFmpeg-devel] [PATCH v2] hw_base_enc: inject side data to crop output for AV1

Anton Khirnov anton at khirnov.net
Mon Sep 23 07:50:32 EEST 2024


Quoting Lynne via ffmpeg-devel (2024-09-14 08:58:46)
> @@ -551,6 +552,30 @@ int ff_hw_base_encode_set_output_property(FFHWBaseEncodeContext *ctx,
>                                  (3 * ctx->output_delay + ctx->async_depth)];
>      }
>  
> +    if ((avctx->codec_id == AV_CODEC_ID_AV1) &&
> +        ((avctx->coded_width != avctx->width) ||
> +         (avctx->coded_height != avctx->height))) {
> +        int err;
> +        size_t crop_data_size = 4*4;
> +
> +        uint8_t *crop_data = av_mallocz(crop_data_size);
> +        if (!crop_data) {
> +            av_buffer_unref(&pkt->buf);
> +            return AVERROR(ENOMEM);
> +        }
> +
> +        AV_WL32(&crop_data[2], ctx->surface_width - avctx->width);
> +        AV_WL32(&crop_data[3], ctx->surface_height - avctx->height);
> +
> +        err = av_packet_add_side_data(pkt, AV_PKT_DATA_FRAME_CROPPING,
> +                                      crop_data, crop_data_size);
> +        if (err < 0) {
> +            av_buffer_unref(&pkt->buf);

Not av_packet_unref()?

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list