diff mbox series

[FFmpeg-devel,24/34] avcodec/zmbvenc: Avoid copying packet data

Message ID HE1PR0301MB2154FF9EC1C0A8D74DB0728C8F439@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Superseded
Headers show
Series [FFmpeg-devel,01/34] avcodec/adpcmenc: Avoid copying packet data | expand

Checks

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

Commit Message

Andreas Rheinhardt April 25, 2021, 10:34 p.m. UTC
Here the packet size is known before allocating the packet because
the encoder itself works with an internal buffer, so one can pass
this information to ff_alloc_packet2() to avoid the implicit use
of another intermediate buffer for the packet data.

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

Comments

Tomas Härdin April 28, 2021, 8:01 a.m. UTC | #1
mån 2021-04-26 klockan 00:34 +0200 skrev Andreas Rheinhardt:
> Here the packet size is known before allocating the packet because
> the encoder itself works with an internal buffer, so one can pass
> this information to ff_alloc_packet2() to avoid the implicit use
> of another intermediate buffer for the packet data.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/zmbvenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
> index 4b3416219b..8933d06ede 100644
> --- a/libavcodec/zmbvenc.c
> +++ b/libavcodec/zmbvenc.c
> @@ -281,7 +281,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>      }
>  
>      pkt_size = c->zstream.total_out + 1 + 6*keyframe;
> -    if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0)
> +    if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, pkt_size)) <
> 0)

Looks correct

/Tomas
diff mbox series

Patch

diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
index 4b3416219b..8933d06ede 100644
--- a/libavcodec/zmbvenc.c
+++ b/libavcodec/zmbvenc.c
@@ -281,7 +281,7 @@  FF_ENABLE_DEPRECATION_WARNINGS
     }
 
     pkt_size = c->zstream.total_out + 1 + 6*keyframe;
-    if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0)
+    if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, pkt_size)) < 0)
         return ret;
     buf = pkt->data;