[FFmpeg-devel] [PATCH] avcodec/decode: add a parameter to ff_reget_buffer() to request a writable buffer

Michael Niedermayer michael at niedermayer.cc
Sat Aug 31 17:22:51 EEST 2019


On Fri, Aug 30, 2019 at 04:26:57PM -0300, James Almer wrote:
> Some decoders may not need a writable buffer in some specific cases, but only
> a reference to the existing buffer with updated frame properties instead, for
> the purpose of returning duplicate frames.
> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
[...]
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index 5f964148fd..d12040f47e 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -321,10 +321,10 @@ static av_always_inline float ff_exp2fi(int x) {
>  int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags);
>  
>  /**
> - * Identical in function to av_frame_make_writable(), except it uses
> - * ff_get_buffer() to allocate the buffer when needed.
> + * Identical in function to ff_get_buffer(), except it reuses the existing buffer
> + * if available and ensures it's writable when requested.
>   */
> -int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame);
> +int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int writable);

I suggest using named constants instead of 0 and 1
#define BUF_TYPE_WRITEABLE 1
#define BUF_TYPE_READONLY  0

This makes the code easier to understand

patch LGTM either way

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190831/8780305c/attachment.sig>


More information about the ffmpeg-devel mailing list