From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/hevcdec: Avoid redundant entry_point_offsets array Date: Wed, 5 Jan 2022 22:19:08 +0100 Message-ID: <AM7PR03MB66601467F893BCB1EF3B92258F4B9@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw) In-Reply-To: <AM7PR03MB6660B14C8ABBE0144FDFFB898F4B9@AM7PR03MB6660.eurprd03.prod.outlook.com> Instead modify the offsets in place. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/hevcdec.c | 19 +++++++++---------- libavcodec/hevcdec.h | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index fc0dc7a584..6aa14455d0 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -77,7 +77,6 @@ static void pic_arrays_free(HEVCContext *s) av_freep(&s->horizontal_bs); av_freep(&s->vertical_bs); - av_freep(&s->sh.entry_point_offset); av_freep(&s->sh.entry_points); av_buffer_pool_uninit(&s->tab_mvf_pool); @@ -913,18 +912,16 @@ static int hls_slice_header(HEVCContext *s) return AVERROR_INVALIDDATA; } - av_freep(&sh->entry_point_offset); av_freep(&sh->entry_points); - sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned)); FF_ALLOC_TYPED_ARRAY(sh->entry_points, sh->num_entry_point_offsets); - if (!sh->entry_point_offset || !sh->entry_points) { + if (!sh->entry_points) { sh->num_entry_point_offsets = 0; av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n"); return AVERROR(ENOMEM); } for (i = 0; i < sh->num_entry_point_offsets; i++) { unsigned val = get_bits_long(gb, offset_len); - sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size + sh->entry_points[i].offset = val + 1; // +1; // +1 to get the size } if (s->threads_number > 1 && (s->ps.pps->num_tile_rows > 1 || s->ps.pps->num_tile_columns > 1)) { s->enable_parallel_tiles = 0; // TODO: you can enable tiles in parallel here @@ -2657,29 +2654,31 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) offset = (lc->gb.index >> 3); - for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) { + for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_points[0].offset; j < nal->skipped_bytes; j++) { if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } } + /* Convert the entry_points offsets from being pre-0x03-escaping + * to post-0x03-escaping and set sizes. */ for (i = 1; i < s->sh.num_entry_point_offsets; i++) { - offset += (s->sh.entry_point_offset[i - 1] - cmpt); + offset += (s->sh.entry_points[i - 1].offset - cmpt); for (j = 0, cmpt = 0, startheader = offset - + s->sh.entry_point_offset[i]; j < nal->skipped_bytes; j++) { + + s->sh.entry_points[i].offset; j < nal->skipped_bytes; j++) { if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } } s->sh.entry_points[i - 1] = (EntryPoint){ - .size = s->sh.entry_point_offset[i] - cmpt, + .size = s->sh.entry_points[i].offset - cmpt, .offset = offset }; } if (s->sh.num_entry_point_offsets != 0) { - offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt; + offset += s->sh.entry_points[s->sh.num_entry_point_offsets - 1].offset - cmpt; if (length < offset) { av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n"); res = AVERROR_INVALIDDATA; diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 76ad262558..9ac04555f4 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -304,7 +304,6 @@ typedef struct SliceHeader { unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand - unsigned *entry_point_offset; EntryPoint *entry_points; int num_entry_point_offsets; -- 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".
next prev parent reply other threads:[~2022-01-05 21:19 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 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 ` Andreas Rheinhardt [this message] 2022-01-06 9:47 ` [FFmpeg-devel] [PATCH 4/4] avcodec/hevcdec: Avoid redundant entry_point_offsets array 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AM7PR03MB66601467F893BCB1EF3B92258F4B9@AM7PR03MB6660.eurprd03.prod.outlook.com \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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