diff mbox series

[FFmpeg-devel] avcodec/encode: Zero padding in ff_get_encode_buffer()

Message ID VI1PR0301MB21592644F100236E28D6B2028F429@VI1PR0301MB2159.eurprd03.prod.outlook.com
State Accepted
Commit ad184c8e363018044715cbe9ebc0b576e54a6438
Headers show
Series [FFmpeg-devel] avcodec/encode: Zero padding in ff_get_encode_buffer() | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 26, 2021, 6:52 p.m. UTC
The documentation of the get_encode_buffer() callback does not require
to zero the padding; therefore we do it in ff_get_encode_buffer().
This also constitutes an implicit check for whether the buffer is
actually allocated with padding.

The memset in avcodec_default_get_encode_buffer() is now redundant and
has been removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/encode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Almer April 26, 2021, 9:40 p.m. UTC | #1
On 4/26/2021 3:52 PM, Andreas Rheinhardt wrote:
> The documentation of the get_encode_buffer() callback does not require
> to zero the padding; therefore we do it in ff_get_encode_buffer().
> This also constitutes an implicit check for whether the buffer is
> actually allocated with padding.
> 
> The memset in avcodec_default_get_encode_buffer() is now redundant and
> has been removed.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>   libavcodec/encode.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/encode.c b/libavcodec/encode.c
> index 9a4140f91a..75129c8646 100644
> --- a/libavcodec/encode.c
> +++ b/libavcodec/encode.c
> @@ -74,7 +74,6 @@ int avcodec_default_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, in
>           return ret;
>       }
>       avpkt->data = avpkt->buf->data;
> -    memset(avpkt->data + avpkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>   
>       return 0;
>   }
> @@ -98,6 +97,7 @@ int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, i
>           ret = AVERROR(EINVAL);
>           goto fail;
>       }
> +    memset(avpkt->data + avpkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>   
>       ret = 0;
>   fail:

LGTM.
diff mbox series

Patch

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 9a4140f91a..75129c8646 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -74,7 +74,6 @@  int avcodec_default_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, in
         return ret;
     }
     avpkt->data = avpkt->buf->data;
-    memset(avpkt->data + avpkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
     return 0;
 }
@@ -98,6 +97,7 @@  int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, i
         ret = AVERROR(EINVAL);
         goto fail;
     }
+    memset(avpkt->data + avpkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
     ret = 0;
 fail: