@@ -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;
@@ -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;
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(-)