[FFmpeg-devel] [PATCH] Document and validate AVFrame plane pointers.

Michael Niedermayer michael at niedermayer.cc
Sat Feb 27 02:21:18 CET 2016


On Fri, Feb 26, 2016 at 11:06:22PM +0100, Reimar Döffinger wrote:
> Check that the required plane pointers and only
> those are set up.
> 
> Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> ---
>  libavcodec/utils.c | 20 ++++++++++++++++++++
>  libavutil/frame.h  |  3 +++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index af21cdd..1b6397c 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -853,6 +853,24 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
>      return ff_init_buffer_info(avctx, frame);
>  }
>  
> +static void validate_avframe_allocation(const AVCodecContext *avctx, AVFrame *frame)
> +{
> +    if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
> +        int i;
> +        int num_planes = av_pix_fmt_count_planes(frame->format);
> +        for (i = 0; i < num_planes; i++) {
> +            av_assert0(frame->data[i]);
> +        }
> +        // for formats without data like hwaccel allow
> +        // pointers to be non-NULL.

> +        for (i = num_planes; num_planes > 0 && i < num_planes; i++) {

are both of i = num_planes and i < num_planes intended ?

some note in APIChanges or release notes or something might make sense
too


[...]
-- 
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: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160227/7f9ebfc1/attachment.sig>


More information about the ffmpeg-devel mailing list