diff mbox series

[FFmpeg-devel,1/3] avcodec/extract_extradata: Consolidate zeroing extradata padding

Message ID 20200907131706.29060-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 16c916e4c90cc6fa6b53563c7d4db701d8001feb
Headers show
Series [FFmpeg-devel,1/3] avcodec/extract_extradata: Consolidate zeroing extradata padding | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 7, 2020, 1:17 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/extract_extradata_bsf.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

James Almer Sept. 9, 2020, 1:24 a.m. UTC | #1
On 9/7/2020 10:17 AM, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/extract_extradata_bsf.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
> index 1fead74b57..6e80076522 100644
> --- a/libavcodec/extract_extradata_bsf.c
> +++ b/libavcodec/extract_extradata_bsf.c
> @@ -103,7 +103,6 @@ static int extract_extradata_av1(AVBSFContext *ctx, AVPacket *pkt,
>              av_buffer_unref(&filtered_buf);
>              return AVERROR(ENOMEM);
>          }
> -        memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>  
>          *data = extradata;
>          *size = extradata_size;
> @@ -198,7 +197,6 @@ static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
>              av_buffer_unref(&filtered_buf);
>              return AVERROR(ENOMEM);
>          }
> -        memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>  
>          *data = extradata;
>          *size = extradata_size;
> @@ -254,7 +252,6 @@ static int extract_extradata_vc1(AVBSFContext *ctx, AVPacket *pkt,
>              return AVERROR(ENOMEM);
>  
>          memcpy(*data, pkt->data, extradata_size);
> -        memset(*data + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>          *size = extradata_size;
>  
>          if (s->remove) {
> @@ -285,7 +282,6 @@ static int extract_extradata_mpeg12(AVBSFContext *ctx, AVPacket *pkt,
>                      return AVERROR(ENOMEM);
>  
>                  memcpy(*data, pkt->data, *size);
> -                memset(*data + *size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>  
>                  if (s->remove) {
>                      pkt->data += *size;
> @@ -315,7 +311,6 @@ static int extract_extradata_mpeg4(AVBSFContext *ctx, AVPacket *pkt,
>                      return AVERROR(ENOMEM);
>  
>                  memcpy(*data, pkt->data, *size);
> -                memset(*data + *size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>  
>                  if (s->remove) {
>                      pkt->data += *size;
> @@ -377,6 +372,7 @@ static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *pkt)
>          goto fail;
>  
>      if (extradata) {
> +        memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>          ret = av_packet_add_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
>                                        extradata, extradata_size);
>          if (ret < 0) {

LGTM
diff mbox series

Patch

diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
index 1fead74b57..6e80076522 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -103,7 +103,6 @@  static int extract_extradata_av1(AVBSFContext *ctx, AVPacket *pkt,
             av_buffer_unref(&filtered_buf);
             return AVERROR(ENOMEM);
         }
-        memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
         *data = extradata;
         *size = extradata_size;
@@ -198,7 +197,6 @@  static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
             av_buffer_unref(&filtered_buf);
             return AVERROR(ENOMEM);
         }
-        memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
         *data = extradata;
         *size = extradata_size;
@@ -254,7 +252,6 @@  static int extract_extradata_vc1(AVBSFContext *ctx, AVPacket *pkt,
             return AVERROR(ENOMEM);
 
         memcpy(*data, pkt->data, extradata_size);
-        memset(*data + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
         *size = extradata_size;
 
         if (s->remove) {
@@ -285,7 +282,6 @@  static int extract_extradata_mpeg12(AVBSFContext *ctx, AVPacket *pkt,
                     return AVERROR(ENOMEM);
 
                 memcpy(*data, pkt->data, *size);
-                memset(*data + *size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
                 if (s->remove) {
                     pkt->data += *size;
@@ -315,7 +311,6 @@  static int extract_extradata_mpeg4(AVBSFContext *ctx, AVPacket *pkt,
                     return AVERROR(ENOMEM);
 
                 memcpy(*data, pkt->data, *size);
-                memset(*data + *size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
                 if (s->remove) {
                     pkt->data += *size;
@@ -377,6 +372,7 @@  static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *pkt)
         goto fail;
 
     if (extradata) {
+        memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
         ret = av_packet_add_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
                                       extradata, extradata_size);
         if (ret < 0) {