[FFmpeg-devel] [PATCH 08/34] avcodec/fitsenc: Avoid copying packet data
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Mon Apr 26 01:34:22 EEST 2021
When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/fitsenc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c
index b44507e436..201604aa59 100644
--- a/libavcodec/fitsenc.c
+++ b/libavcodec/fitsenc.c
@@ -80,7 +80,8 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
data_size = (bitpix >> 3) * avctx->height * avctx->width * naxis3;
padded_data_size = ((data_size + 2879) / 2880 ) * 2880;
- if ((ret = ff_alloc_packet2(avctx, pkt, padded_data_size, 0)) < 0)
+ if ((ret = ff_alloc_packet2(avctx, pkt, padded_data_size,
+ padded_data_size)) < 0)
return ret;
bytestream_start =
@@ -104,9 +105,7 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytes_left = padded_data_size - data_size;
memset(bytestream, 0, bytes_left);
- bytestream += bytes_left;
- pkt->size = bytestream - bytestream_start;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
--
2.27.0
More information about the ffmpeg-devel
mailing list