diff mbox

[FFmpeg-devel] avcodec/h2645_parse: simplify memset call

Message ID 20190907195551.23408-1-andriy.gelman@gmail.com
State Accepted
Commit 78b86c30d3860135042505dd4a9cbd95c4e6257d
Headers show

Commit Message

Andriy Gelman Sept. 7, 2019, 7:55 p.m. UTC
From: Andriy Gelman <andriy.gelman@gmail.com>

Removed (new_size - pkt->nals_allocated) because this value is always 1
during the call.
---
 libavcodec/h2645_parse.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Lance Wang Sept. 10, 2019, 1:24 a.m. UTC | #1
On Sat, Sep 07, 2019 at 03:55:51PM -0400, Andriy Gelman wrote:
> From: Andriy Gelman <andriy.gelman@gmail.com>
> 
> Removed (new_size - pkt->nals_allocated) because this value is always 1
> during the call.
> ---
>  libavcodec/h2645_parse.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
> index 307e8643e6..ef6a6b4b4f 100644
> --- a/libavcodec/h2645_parse.c
> +++ b/libavcodec/h2645_parse.c
> @@ -461,8 +461,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
>                  return AVERROR(ENOMEM);
>  
>              pkt->nals = tmp;
> -            memset(pkt->nals + pkt->nals_allocated, 0,
> -                   (new_size - pkt->nals_allocated) * sizeof(*pkt->nals));
> +            memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals));

instead, I think the new_size isn't set properly  please refer to my patch in the thread.


>  
>              nal = &pkt->nals[pkt->nb_nals];
>              nal->skipped_bytes_pos_size = 1024; // initial buffer size
> -- 
> 2.23.0
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Andriy Gelman Sept. 10, 2019, 9:35 a.m. UTC | #2
On Sat, 07. Sep 15:55, Andriy Gelman wrote:
> From: Andriy Gelman <andriy.gelman@gmail.com>
> 
> Removed (new_size - pkt->nals_allocated) because this value is always 1
> during the call.
> ---
>  libavcodec/h2645_parse.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
> index 307e8643e6..ef6a6b4b4f 100644
> --- a/libavcodec/h2645_parse.c
> +++ b/libavcodec/h2645_parse.c
> @@ -461,8 +461,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
>                  return AVERROR(ENOMEM);
>  
>              pkt->nals = tmp;
> -            memset(pkt->nals + pkt->nals_allocated, 0,
> -                   (new_size - pkt->nals_allocated) * sizeof(*pkt->nals));
> +            memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals));
>  
>              nal = &pkt->nals[pkt->nb_nals];
>              nal->skipped_bytes_pos_size = 1024; // initial buffer size
> -- 
> 2.23.0
> 

ping
James Almer Sept. 11, 2019, 1:28 p.m. UTC | #3
On 9/7/2019 4:55 PM, Andriy Gelman wrote:
> From: Andriy Gelman <andriy.gelman@gmail.com>
> 
> Removed (new_size - pkt->nals_allocated) because this value is always 1
> during the call.
> ---
>  libavcodec/h2645_parse.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
> index 307e8643e6..ef6a6b4b4f 100644
> --- a/libavcodec/h2645_parse.c
> +++ b/libavcodec/h2645_parse.c
> @@ -461,8 +461,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
>                  return AVERROR(ENOMEM);
>  
>              pkt->nals = tmp;
> -            memset(pkt->nals + pkt->nals_allocated, 0,
> -                   (new_size - pkt->nals_allocated) * sizeof(*pkt->nals));
> +            memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals));
>  
>              nal = &pkt->nals[pkt->nb_nals];
>              nal->skipped_bytes_pos_size = 1024; // initial buffer size

Pushed, thanks.
diff mbox

Patch

diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 307e8643e6..ef6a6b4b4f 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -461,8 +461,7 @@  int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
                 return AVERROR(ENOMEM);
 
             pkt->nals = tmp;
-            memset(pkt->nals + pkt->nals_allocated, 0,
-                   (new_size - pkt->nals_allocated) * sizeof(*pkt->nals));
+            memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals));
 
             nal = &pkt->nals[pkt->nb_nals];
             nal->skipped_bytes_pos_size = 1024; // initial buffer size