[FFmpeg-devel] [PATCH 1/2] lavc/decode: re-allocate surface in ff_decode_get_hw_frames_ctx
Hendrik Leppkes
h.leppkes at gmail.com
Fri Dec 27 12:24:31 EET 2019
On Fri, Dec 27, 2019 at 9:59 AM Linjie Fu <linjie.fu at intel.com> wrote:
>
> Allow hw_frames_ctx to be recreated instead of just return if it exists.
>
> Move hw_frames_ctx check outside ff_decode_get_hw_frames_ctx, and check
> in relevant code.
>
> Signed-off-by: Linjie Fu <linjie.fu at intel.com>
> ---
> libavcodec/decode.c | 2 +-
> libavcodec/dxva2.c | 8 +++++---
> libavcodec/vdpau.c | 9 +++++----
> 3 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index cd275ba..ad046d9 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1229,7 +1229,7 @@ int ff_decode_get_hw_frames_ctx(AVCodecContext *avctx,
> return AVERROR(ENOSYS);
>
> if (avctx->hw_frames_ctx)
> - return 0;
> + av_buffer_unref(&avctx->hw_frames_ctx);
> if (!avctx->hw_device_ctx) {
> av_log(avctx, AV_LOG_ERROR, "A hardware frames or device context is "
> "required for hardware accelerated decoding.\n");
As mentioned in the other mail, this is not safe. An externally
provided hw_frames_ctx could be allocated with special requirements,
and shared with a renderer. If a user provides an external
hw_frames_ctx, then avcodec cannot just re-allocate it, instead we
would have to ask the user to do so.
- Hendrik
More information about the ffmpeg-devel
mailing list