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

Andreas Rheinhardt git at videolan.org
Tue Apr 27 01:22:14 EEST 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Apr 26 20:47:03 2021 +0200| [ad184c8e363018044715cbe9ebc0b576e54a6438] | committer: Andreas Rheinhardt

avcodec/encode: Zero padding in ff_get_encode_buffer()

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.

Reviewed-by: James Almer <jamrial at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ad184c8e363018044715cbe9ebc0b576e54a6438
---

 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:



More information about the ffmpeg-cvslog mailing list