Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/4] avcodec/hevcdec: Combine multiple allocations
@ 2022-01-05 21:18 Andreas Rheinhardt
  2022-01-05 21:19 ` [FFmpeg-devel] [PATCH 2/4] avcodec/hevcdec: Remove redundant frees Andreas Rheinhardt
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2022-01-05 21:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Reduces the number of allocs and frees.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/hevcdec.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 8d7a4f7147..568bdb5ab7 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2621,17 +2621,15 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
     const uint8_t *data = nal->data;
     int length          = nal->size;
     HEVCLocalContext *lc = s->HEVClc;
-    int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
-    int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
+    int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, 2 * sizeof(int));
+    int *arg;
     int64_t offset;
     int64_t startheader, cmpt = 0;
     int i, j, res = 0;
 
-    if (!ret || !arg) {
-        av_free(ret);
-        av_free(arg);
+    if (!ret)
         return AVERROR(ENOMEM);
-    }
+    arg = ret + s->sh.num_entry_point_offsets + 1;
 
     if (s->sh.slice_ctb_addr_rs + s->sh.num_entry_point_offsets * s->ps.sps->ctb_width >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) {
         av_log(s->avctx, AV_LOG_ERROR, "WPP ctb addresses are wrong (%d %d %d %d)\n",
@@ -2716,7 +2714,6 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
         res += ret[i];
 error:
     av_free(ret);
-    av_free(arg);
     return res;
 }
 
-- 
2.32.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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-01-06 12:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 21:18 [FFmpeg-devel] [PATCH 1/4] avcodec/hevcdec: Combine multiple allocations Andreas Rheinhardt
2022-01-05 21:19 ` [FFmpeg-devel] [PATCH 2/4] avcodec/hevcdec: Remove redundant frees Andreas Rheinhardt
2022-01-05 21:19 ` [FFmpeg-devel] [PATCH 3/4] avcodec/hevcdec: Combine related data into structure Andreas Rheinhardt
2022-01-05 21:19 ` [FFmpeg-devel] [PATCH 4/4] avcodec/hevcdec: Avoid redundant entry_point_offsets array Andreas Rheinhardt
2022-01-06  9:47   ` Michael Niedermayer
2022-01-06  9:40 ` [FFmpeg-devel] [PATCH 1/4] avcodec/hevcdec: Combine multiple allocations Michael Niedermayer
2022-01-06  9:56   ` Andreas Rheinhardt
2022-01-06 12:00     ` Michael Niedermayer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git