* [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h266: store SubpicIdVal in the context @ 2023-07-01 1:36 James Almer 2023-07-01 1:36 ` [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h266: store RowHeightVal " James Almer 2023-07-01 14:51 ` [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h266: store SubpicIdVal " Nuo Mi 0 siblings, 2 replies; 7+ messages in thread From: James Almer @ 2023-07-01 1:36 UTC (permalink / raw) To: ffmpeg-devel And use it to derive CurrSubpicIdx Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/cbs_h266.h | 2 ++ libavcodec/cbs_h266_syntax_template.c | 34 +++++++++++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h index be3c744426..edcb5ad0e3 100644 --- a/libavcodec/cbs_h266.h +++ b/libavcodec/cbs_h266.h @@ -552,6 +552,8 @@ typedef struct H266RawPPS { uint16_t num_tiles_in_pic; uint16_t slice_height_in_ctus[VVC_MAX_SLICES]; uint16_t num_slices_in_subpic[VVC_MAX_SLICES]; + uint16_t sub_pic_id_val[VVC_MAX_SLICES]; + uint16_t row_height_val[VVC_MAX_TILE_ROWS]; } H266RawPPS; typedef struct H266RawAUD { diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c index 863fecdefa..ec2bb1ccc3 100644 --- a/libavcodec/cbs_h266_syntax_template.c +++ b/libavcodec/cbs_h266_syntax_template.c @@ -1706,6 +1706,15 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, } } + for (i = 0; i <= sps->sps_num_subpics_minus1; i++) { + if (sps->sps_subpic_id_mapping_explicitly_signalled_flag) + current->sub_pic_id_val[i] = current->pps_subpic_id_mapping_present_flag + ? current->pps_subpic_id[i] + : sps->sps_subpic_id[i]; + else + current->sub_pic_id_val[i] = i; + } + pic_width_in_ctbs_y = AV_CEIL_RSHIFT (current->pps_pic_width_in_luma_samples, (sps->sps_log2_ctu_size_minus5 + 5)); pic_height_in_ctbs_y = AV_CEIL_RSHIFT( @@ -2697,25 +2706,16 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw, if (sps->sps_subpic_info_present_flag) { ub(sps->sps_subpic_id_len_minus1 + 1, sh_subpic_id); - if (sps->sps_subpic_id_mapping_explicitly_signalled_flag) { - for (i = 0; i <= sps->sps_num_subpics_minus1; i++) { - uint16_t subpic_id_val = - pps->pps_subpic_id_mapping_present_flag ? - pps->pps_subpic_id[i] : sps->sps_subpic_id[i]; - if (subpic_id_val == current->sh_subpic_id) { - curr_subpic_idx = i; - break; - } - } - } else { - curr_subpic_idx = current->sh_subpic_id; - if (curr_subpic_idx > sps->sps_num_subpics_minus1) { - av_log(ctx->log_ctx, AV_LOG_ERROR, - "sh_subpic_id(%d) should in range [0, %d]\n", - curr_subpic_idx, sps->sps_num_subpics_minus1); - return AVERROR_INVALIDDATA; + for (i = 0; i <= sps->sps_num_subpics_minus1; i++) { + if (pps->sub_pic_id_val[i] == current->sh_subpic_id) { + curr_subpic_idx = i; + break; } } + if (i > sps->sps_num_subpics_minus1) { + av_log(ctx->log_ctx, AV_LOG_ERROR, "invalid CurrSubpicIdx %d\n", i); + return AVERROR_INVALIDDATA; + } } else { curr_subpic_idx = 0; } -- 2.41.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] 7+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h266: store RowHeightVal in the context 2023-07-01 1:36 [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h266: store SubpicIdVal in the context James Almer @ 2023-07-01 1:36 ` James Almer 2023-07-01 15:10 ` Nuo Mi 2023-07-01 23:39 ` [FFmpeg-devel] [PATCH v2] avcodec/cbs_h266: store RowHeightVal and ColWidthVal " James Almer 2023-07-01 14:51 ` [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h266: store SubpicIdVal " Nuo Mi 1 sibling, 2 replies; 7+ messages in thread From: James Almer @ 2023-07-01 1:36 UTC (permalink / raw) To: ffmpeg-devel Stop overwriting values from the bitstream array pps_tile_row_height_minus1. Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/cbs_h266_syntax_template.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c index ec2bb1ccc3..625995a2bd 100644 --- a/libavcodec/cbs_h266_syntax_template.c +++ b/libavcodec/cbs_h266_syntax_template.c @@ -1779,14 +1779,14 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, "Tile row height(%d) exceeds picture height\n",i); return AVERROR_INVALIDDATA; } + current->row_height_val[i] = current->pps_tile_row_height_minus1[i] + 1; remaining_size -= (current->pps_tile_row_height_minus1[i] + 1); } - unified_size = (i == 0 ? pic_height_in_ctbs_y : - (current->pps_tile_row_height_minus1[i - 1] + 1)); + unified_size = current->pps_tile_row_height_minus1[i - 1] + 1; while (remaining_size > 0) { unified_size = FFMIN(remaining_size, unified_size); - current->pps_tile_row_height_minus1[i] = unified_size - 1; + current->row_height_val[i] = unified_size; remaining_size -= unified_size; i++; } @@ -1855,17 +1855,17 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, ctu_x += current->pps_tile_column_width_minus1[j] + 1; } for (j = 0; j < tile_y; j++) { - ctu_y += current->pps_tile_row_height_minus1[j] + 1; + ctu_y += current->row_height_val[j]; } if (current->pps_slice_width_in_tiles_minus1[i] == 0 && current->pps_slice_height_in_tiles_minus1[i] == 0 && - current->pps_tile_row_height_minus1[tile_y] > 0) { + current->row_height_val[tile_y] > 1) { int num_slices_in_tile, uniform_slice_height, remaining_height_in_ctbs_y; remaining_height_in_ctbs_y = - current->pps_tile_row_height_minus1[tile_y] + 1; + current->row_height_val[tile_y]; ues(pps_num_exp_slices_in_tile[i], - 0, current->pps_tile_row_height_minus1[tile_y], 1, i); + 0, current->row_height_val[tile_y] - 1, 1, i); if (current->pps_num_exp_slices_in_tile[i] == 0) { num_slices_in_tile = 1; slice_top_left_ctu_x[i] = ctu_x; @@ -1875,7 +1875,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, for (j = 0; j < current->pps_num_exp_slices_in_tile[i]; j++) { ues(pps_exp_slice_height_in_ctus_minus1[i][j], 0, - current->pps_tile_row_height_minus1[tile_y], 2, + current->row_height_val[tile_y] - 1, 2, i, j); slice_height_in_ctus = current-> @@ -1890,7 +1890,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, remaining_height_in_ctbs_y -= slice_height_in_ctus; } uniform_slice_height = 1 + - (j == 0 ? current->pps_tile_row_height_minus1[tile_y] : + (j == 0 ? current->row_height_val[tile_y] - 1: current->pps_exp_slice_height_in_ctus_minus1[i][j-1]); while (remaining_height_in_ctbs_y > uniform_slice_height) { current->slice_height_in_ctus[i + j] = @@ -1919,7 +1919,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, j <= current->pps_slice_height_in_tiles_minus1[i]; j++) { height += - current->pps_tile_row_height_minus1[tile_y + j] + 1; + current->row_height_val[tile_y + j]; } current->slice_height_in_ctus[i] = height; @@ -1959,7 +1959,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, ctu_x += current->pps_tile_column_width_minus1[j] + 1; } for (j = 0; j < tile_y; j++) { - ctu_y += current->pps_tile_row_height_minus1[j] + 1; + ctu_y += current->row_height_val[j]; } slice_top_left_ctu_x[i] = ctu_x; slice_top_left_ctu_y[i] = ctu_y; @@ -1972,7 +1972,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, for (j = 0; j <= current->pps_slice_height_in_tiles_minus1[i]; j++) { height += - current->pps_tile_row_height_minus1[tile_y + j] + 1; + current->row_height_val[tile_y + j]; } current->slice_height_in_ctus[i] = height; @@ -2015,6 +2015,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, infer(pps_tile_column_width_minus1[0], pic_width_in_ctbs_y - 1); infer(pps_num_exp_tile_rows_minus1, 0); infer(pps_tile_row_height_minus1[0], pic_height_in_ctbs_y - 1); + infer(row_height_val[0], pic_height_in_ctbs_y); infer(num_tile_columns, 1); infer(num_tile_rows, 1); infer(num_tiles_in_pic, 1); @@ -3037,7 +3038,7 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw, current->sh_slice_address + current->sh_num_tiles_in_slice_minus1; tile_idx++) { tile_y = tile_idx / pps->num_tile_rows; - height = pps->pps_tile_row_height_minus1[tile_y] + 1; + height = pps->row_height_val[tile_y]; num_entry_points += (entropy_sync ? height : 1); } } -- 2.41.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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h266: store RowHeightVal in the context 2023-07-01 1:36 ` [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h266: store RowHeightVal " James Almer @ 2023-07-01 15:10 ` Nuo Mi 2023-07-01 22:33 ` James Almer 2023-07-01 23:39 ` [FFmpeg-devel] [PATCH v2] avcodec/cbs_h266: store RowHeightVal and ColWidthVal " James Almer 1 sibling, 1 reply; 7+ messages in thread From: Nuo Mi @ 2023-07-01 15:10 UTC (permalink / raw) To: FFmpeg development discussions and patches On Sat, Jul 1, 2023 at 9:37 AM James Almer <jamrial@gmail.com> wrote: > Stop overwriting values from the bitstream array > pps_tile_row_height_minus1. > > Signed-off-by: James Almer <jamrial@gmail.com> > --- > libavcodec/cbs_h266_syntax_template.c | 27 ++++++++++++++------------- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/libavcodec/cbs_h266_syntax_template.c > b/libavcodec/cbs_h266_syntax_template.c > index ec2bb1ccc3..625995a2bd 100644 > --- a/libavcodec/cbs_h266_syntax_template.c > +++ b/libavcodec/cbs_h266_syntax_template.c > @@ -1779,14 +1779,14 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, > RWContext *rw, > "Tile row height(%d) exceeds picture height\n",i); > return AVERROR_INVALIDDATA; > } > + current->row_height_val[i] = > current->pps_tile_row_height_minus1[i] + 1; > remaining_size -= (current->pps_tile_row_height_minus1[i] + 1); > } > - unified_size = (i == 0 ? pic_height_in_ctbs_y : > - (current->pps_tile_row_height_minus1[i - 1] + 1)); > + unified_size = current->pps_tile_row_height_minus1[i - 1] + 1; > > while (remaining_size > 0) { > unified_size = FFMIN(remaining_size, unified_size); > - current->pps_tile_row_height_minus1[i] = unified_size - 1; > + current->row_height_val[i] = unified_size; > remaining_size -= unified_size; > i++; > } > @@ -1855,17 +1855,17 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, > RWContext *rw, > ctu_x += current->pps_tile_column_width_minus1[j] + 1; > } > for (j = 0; j < tile_y; j++) { > - ctu_y += current->pps_tile_row_height_minus1[j] + 1; > + ctu_y += current->row_height_val[j]; > } > if (current->pps_slice_width_in_tiles_minus1[i] == 0 && > current->pps_slice_height_in_tiles_minus1[i] == 0 && > - current->pps_tile_row_height_minus1[tile_y] > 0) { > + current->row_height_val[tile_y] > 1) { > int num_slices_in_tile, > uniform_slice_height, remaining_height_in_ctbs_y; > remaining_height_in_ctbs_y = > - current->pps_tile_row_height_minus1[tile_y] + 1; > + current->row_height_val[tile_y]; > ues(pps_num_exp_slices_in_tile[i], > - 0, current->pps_tile_row_height_minus1[tile_y], > 1, i); > + 0, current->row_height_val[tile_y] - 1, 1, i); > if (current->pps_num_exp_slices_in_tile[i] == 0) { > num_slices_in_tile = 1; > slice_top_left_ctu_x[i] = ctu_x; > @@ -1875,7 +1875,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, > RWContext *rw, > for (j = 0; j < > current->pps_num_exp_slices_in_tile[i]; > j++) { > > ues(pps_exp_slice_height_in_ctus_minus1[i][j], 0, > - > current->pps_tile_row_height_minus1[tile_y], 2, > + current->row_height_val[tile_y] - 1, 2, > The benefit is not so obvious when we need to -1 in multiple places. > i, j); > slice_height_in_ctus = > current-> > @@ -1890,7 +1890,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, > RWContext *rw, > remaining_height_in_ctbs_y -= > slice_height_in_ctus; > } > uniform_slice_height = 1 + > - (j == 0 ? > current->pps_tile_row_height_minus1[tile_y] : > + (j == 0 ? current->row_height_val[tile_y] - 1: > > current->pps_exp_slice_height_in_ctus_minus1[i][j-1]); > while (remaining_height_in_ctbs_y > > uniform_slice_height) { > current->slice_height_in_ctus[i + j] = > @@ -1919,7 +1919,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, > RWContext *rw, > j <= > current->pps_slice_height_in_tiles_minus1[i]; > j++) { > height += > - current->pps_tile_row_height_minus1[tile_y + > j] + 1; > + current->row_height_val[tile_y + j]; > } > current->slice_height_in_ctus[i] = height; > > @@ -1959,7 +1959,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, > RWContext *rw, > ctu_x += current->pps_tile_column_width_minus1[j] + 1; > } > for (j = 0; j < tile_y; j++) { > - ctu_y += current->pps_tile_row_height_minus1[j] + 1; > + ctu_y += current->row_height_val[j]; > } > slice_top_left_ctu_x[i] = ctu_x; > slice_top_left_ctu_y[i] = ctu_y; > @@ -1972,7 +1972,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, > RWContext *rw, > for (j = 0; j <= > current->pps_slice_height_in_tiles_minus1[i]; > j++) { > height += > - current->pps_tile_row_height_minus1[tile_y + j] + > 1; > + current->row_height_val[tile_y + j]; > } > current->slice_height_in_ctus[i] = height; > > @@ -2015,6 +2015,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, > RWContext *rw, > infer(pps_tile_column_width_minus1[0], pic_width_in_ctbs_y - 1); > infer(pps_num_exp_tile_rows_minus1, 0); > infer(pps_tile_row_height_minus1[0], pic_height_in_ctbs_y - 1); > + infer(row_height_val[0], pic_height_in_ctbs_y); > infer(num_tile_columns, 1); > infer(num_tile_rows, 1); > infer(num_tiles_in_pic, 1); > @@ -3037,7 +3038,7 @@ static int FUNC(slice_header) (CodedBitstreamContext > *ctx, RWContext *rw, > current->sh_slice_address + > current->sh_num_tiles_in_slice_minus1; tile_idx++) { > tile_y = tile_idx / pps->num_tile_rows; > - height = pps->pps_tile_row_height_minus1[tile_y] + 1; > + height = pps->row_height_val[tile_y]; > num_entry_points += (entropy_sync ? height : 1); > } > } > -- > 2.41.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". > _______________________________________________ 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h266: store RowHeightVal in the context 2023-07-01 15:10 ` Nuo Mi @ 2023-07-01 22:33 ` James Almer 2023-07-01 23:40 ` James Almer 0 siblings, 1 reply; 7+ messages in thread From: James Almer @ 2023-07-01 22:33 UTC (permalink / raw) To: ffmpeg-devel On 7/1/2023 12:10 PM, Nuo Mi wrote: > On Sat, Jul 1, 2023 at 9:37 AM James Almer <jamrial@gmail.com> wrote: > >> Stop overwriting values from the bitstream array >> pps_tile_row_height_minus1. >> >> Signed-off-by: James Almer <jamrial@gmail.com> >> --- >> libavcodec/cbs_h266_syntax_template.c | 27 ++++++++++++++------------- >> 1 file changed, 14 insertions(+), 13 deletions(-) >> >> diff --git a/libavcodec/cbs_h266_syntax_template.c >> b/libavcodec/cbs_h266_syntax_template.c >> index ec2bb1ccc3..625995a2bd 100644 >> --- a/libavcodec/cbs_h266_syntax_template.c >> +++ b/libavcodec/cbs_h266_syntax_template.c >> @@ -1779,14 +1779,14 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, >> RWContext *rw, >> "Tile row height(%d) exceeds picture height\n",i); >> return AVERROR_INVALIDDATA; >> } >> + current->row_height_val[i] = >> current->pps_tile_row_height_minus1[i] + 1; >> remaining_size -= (current->pps_tile_row_height_minus1[i] + 1); >> } >> - unified_size = (i == 0 ? pic_height_in_ctbs_y : >> - (current->pps_tile_row_height_minus1[i - 1] + 1)); >> + unified_size = current->pps_tile_row_height_minus1[i - 1] + 1; >> >> while (remaining_size > 0) { >> unified_size = FFMIN(remaining_size, unified_size); >> - current->pps_tile_row_height_minus1[i] = unified_size - 1; >> + current->row_height_val[i] = unified_size; >> remaining_size -= unified_size; >> i++; >> } >> @@ -1855,17 +1855,17 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, >> RWContext *rw, >> ctu_x += current->pps_tile_column_width_minus1[j] + 1; >> } >> for (j = 0; j < tile_y; j++) { >> - ctu_y += current->pps_tile_row_height_minus1[j] + 1; >> + ctu_y += current->row_height_val[j]; >> } >> if (current->pps_slice_width_in_tiles_minus1[i] == 0 && >> current->pps_slice_height_in_tiles_minus1[i] == 0 && >> - current->pps_tile_row_height_minus1[tile_y] > 0) { >> + current->row_height_val[tile_y] > 1) { >> int num_slices_in_tile, >> uniform_slice_height, remaining_height_in_ctbs_y; >> remaining_height_in_ctbs_y = >> - current->pps_tile_row_height_minus1[tile_y] + 1; >> + current->row_height_val[tile_y]; >> ues(pps_num_exp_slices_in_tile[i], >> - 0, current->pps_tile_row_height_minus1[tile_y], >> 1, i); >> + 0, current->row_height_val[tile_y] - 1, 1, i); >> if (current->pps_num_exp_slices_in_tile[i] == 0) { >> num_slices_in_tile = 1; >> slice_top_left_ctu_x[i] = ctu_x; >> @@ -1875,7 +1875,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, >> RWContext *rw, >> for (j = 0; j < >> current->pps_num_exp_slices_in_tile[i]; >> j++) { >> >> ues(pps_exp_slice_height_in_ctus_minus1[i][j], 0, >> - >> current->pps_tile_row_height_minus1[tile_y], 2, >> + current->row_height_val[tile_y] - 1, 2, >> > The benefit is not so obvious when we need to -1 in multiple places. It's not about having a benefit, but to stop writing derived values to a raw bitstream struct field. And in the end, i also remove a bunch of +1. What i did not carefully look in the spec is which of these uses actually needs pps_tile_row_height_minus1 and which RowHeightVal. I assumed all wanted the latter since it's calculated almost immediately after the former is read from the bitstream, but maybe you know better. I'll send an updated patch to do the same for ColWidthVal, now that i notice the same happens with it. > >> i, j); >> slice_height_in_ctus = >> current-> >> @@ -1890,7 +1890,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, >> RWContext *rw, >> remaining_height_in_ctbs_y -= >> slice_height_in_ctus; >> } >> uniform_slice_height = 1 + >> - (j == 0 ? >> current->pps_tile_row_height_minus1[tile_y] : >> + (j == 0 ? current->row_height_val[tile_y] - 1: >> >> current->pps_exp_slice_height_in_ctus_minus1[i][j-1]); >> while (remaining_height_in_ctbs_y > >> uniform_slice_height) { >> current->slice_height_in_ctus[i + j] = >> @@ -1919,7 +1919,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, >> RWContext *rw, >> j <= >> current->pps_slice_height_in_tiles_minus1[i]; >> j++) { >> height += >> - current->pps_tile_row_height_minus1[tile_y + >> j] + 1; >> + current->row_height_val[tile_y + j]; >> } >> current->slice_height_in_ctus[i] = height; >> >> @@ -1959,7 +1959,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, >> RWContext *rw, >> ctu_x += current->pps_tile_column_width_minus1[j] + 1; >> } >> for (j = 0; j < tile_y; j++) { >> - ctu_y += current->pps_tile_row_height_minus1[j] + 1; >> + ctu_y += current->row_height_val[j]; >> } >> slice_top_left_ctu_x[i] = ctu_x; >> slice_top_left_ctu_y[i] = ctu_y; >> @@ -1972,7 +1972,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, >> RWContext *rw, >> for (j = 0; j <= >> current->pps_slice_height_in_tiles_minus1[i]; >> j++) { >> height += >> - current->pps_tile_row_height_minus1[tile_y + j] + >> 1; >> + current->row_height_val[tile_y + j]; >> } >> current->slice_height_in_ctus[i] = height; >> >> @@ -2015,6 +2015,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, >> RWContext *rw, >> infer(pps_tile_column_width_minus1[0], pic_width_in_ctbs_y - 1); >> infer(pps_num_exp_tile_rows_minus1, 0); >> infer(pps_tile_row_height_minus1[0], pic_height_in_ctbs_y - 1); >> + infer(row_height_val[0], pic_height_in_ctbs_y); >> infer(num_tile_columns, 1); >> infer(num_tile_rows, 1); >> infer(num_tiles_in_pic, 1); >> @@ -3037,7 +3038,7 @@ static int FUNC(slice_header) (CodedBitstreamContext >> *ctx, RWContext *rw, >> current->sh_slice_address + >> current->sh_num_tiles_in_slice_minus1; tile_idx++) { >> tile_y = tile_idx / pps->num_tile_rows; >> - height = pps->pps_tile_row_height_minus1[tile_y] + 1; >> + height = pps->row_height_val[tile_y]; >> num_entry_points += (entropy_sync ? height : 1); >> } >> } >> -- >> 2.41.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". >> > _______________________________________________ > 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". _______________________________________________ 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h266: store RowHeightVal in the context 2023-07-01 22:33 ` James Almer @ 2023-07-01 23:40 ` James Almer 0 siblings, 0 replies; 7+ messages in thread From: James Almer @ 2023-07-01 23:40 UTC (permalink / raw) To: ffmpeg-devel On 7/1/2023 7:33 PM, James Almer wrote: > On 7/1/2023 12:10 PM, Nuo Mi wrote: >> On Sat, Jul 1, 2023 at 9:37 AM James Almer <jamrial@gmail.com> wrote: >> >>> Stop overwriting values from the bitstream array >>> pps_tile_row_height_minus1. >>> >>> Signed-off-by: James Almer <jamrial@gmail.com> >>> --- >>> libavcodec/cbs_h266_syntax_template.c | 27 ++++++++++++++------------- >>> 1 file changed, 14 insertions(+), 13 deletions(-) >>> >>> diff --git a/libavcodec/cbs_h266_syntax_template.c >>> b/libavcodec/cbs_h266_syntax_template.c >>> index ec2bb1ccc3..625995a2bd 100644 >>> --- a/libavcodec/cbs_h266_syntax_template.c >>> +++ b/libavcodec/cbs_h266_syntax_template.c >>> @@ -1779,14 +1779,14 @@ static int FUNC(pps) (CodedBitstreamContext >>> *ctx, >>> RWContext *rw, >>> "Tile row height(%d) exceeds picture >>> height\n",i); >>> return AVERROR_INVALIDDATA; >>> } >>> + current->row_height_val[i] = >>> current->pps_tile_row_height_minus1[i] + 1; >>> remaining_size -= (current->pps_tile_row_height_minus1[i] >>> + 1); >>> } >>> - unified_size = (i == 0 ? pic_height_in_ctbs_y : >>> - (current->pps_tile_row_height_minus1[i - 1] >>> + 1)); >>> + unified_size = current->pps_tile_row_height_minus1[i - 1] + 1; >>> >>> while (remaining_size > 0) { >>> unified_size = FFMIN(remaining_size, unified_size); >>> - current->pps_tile_row_height_minus1[i] = unified_size - 1; >>> + current->row_height_val[i] = unified_size; >>> remaining_size -= unified_size; >>> i++; >>> } >>> @@ -1855,17 +1855,17 @@ static int FUNC(pps) (CodedBitstreamContext >>> *ctx, >>> RWContext *rw, >>> ctu_x += >>> current->pps_tile_column_width_minus1[j] + 1; >>> } >>> for (j = 0; j < tile_y; j++) { >>> - ctu_y += current->pps_tile_row_height_minus1[j] >>> + 1; >>> + ctu_y += current->row_height_val[j]; >>> } >>> if (current->pps_slice_width_in_tiles_minus1[i] == >>> 0 && >>> current->pps_slice_height_in_tiles_minus1[i] == >>> 0 && >>> - current->pps_tile_row_height_minus1[tile_y] > 0) { >>> + current->row_height_val[tile_y] > 1) { >>> int num_slices_in_tile, >>> uniform_slice_height, >>> remaining_height_in_ctbs_y; >>> remaining_height_in_ctbs_y = >>> - current->pps_tile_row_height_minus1[tile_y] >>> + 1; >>> + current->row_height_val[tile_y]; >>> ues(pps_num_exp_slices_in_tile[i], >>> - 0, current->pps_tile_row_height_minus1[tile_y], >>> 1, i); >>> + 0, current->row_height_val[tile_y] - 1, 1, i); >>> if (current->pps_num_exp_slices_in_tile[i] == 0) { >>> num_slices_in_tile = 1; >>> slice_top_left_ctu_x[i] = ctu_x; >>> @@ -1875,7 +1875,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, >>> RWContext *rw, >>> for (j = 0; j < >>> current->pps_num_exp_slices_in_tile[i]; >>> j++) { >>> >>> ues(pps_exp_slice_height_in_ctus_minus1[i][j], 0, >>> - >>> current->pps_tile_row_height_minus1[tile_y], 2, >>> + current->row_height_val[tile_y] - 1, 2, >>> >> The benefit is not so obvious when we need to -1 in multiple places. > > It's not about having a benefit, but to stop writing derived values to a > raw bitstream struct field. And in the end, i also remove a bunch of +1. > > What i did not carefully look in the spec is which of these uses > actually needs pps_tile_row_height_minus1 and which RowHeightVal. I > assumed all wanted the latter since it's calculated almost immediately > after the former is read from the bitstream, but maybe you know better. Looking at the spec, it's indeed RowHeightVal and ColWidthVal what's used everywhere, including the couple - 1 where i added them. > > I'll send an updated patch to do the same for ColWidthVal, now that i > notice the same happens with it. _______________________________________________ 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] 7+ messages in thread
* [FFmpeg-devel] [PATCH v2] avcodec/cbs_h266: store RowHeightVal and ColWidthVal in the context 2023-07-01 1:36 ` [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h266: store RowHeightVal " James Almer 2023-07-01 15:10 ` Nuo Mi @ 2023-07-01 23:39 ` James Almer 1 sibling, 0 replies; 7+ messages in thread From: James Almer @ 2023-07-01 23:39 UTC (permalink / raw) To: ffmpeg-devel Stop overwriting values from the bitstream arrays pps_tile_column_width_minus1 and pps_tile_row_height_minus1. Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/cbs_h266.h | 2 ++ libavcodec/cbs_h266_syntax_template.c | 37 ++++++++++++++------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h index 9e823919af..dc7406f084 100644 --- a/libavcodec/cbs_h266.h +++ b/libavcodec/cbs_h266.h @@ -553,6 +553,8 @@ typedef struct H266RawPPS { uint16_t slice_height_in_ctus[VVC_MAX_SLICES]; uint16_t num_slices_in_subpic[VVC_MAX_SLICES]; uint16_t sub_pic_id_val[VVC_MAX_SLICES]; + uint16_t col_width_val[VVC_MAX_TILE_COLUMNS]; + uint16_t row_height_val[VVC_MAX_TILE_ROWS]; } H266RawPPS; typedef struct H266RawAUD { diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c index f1cd45f815..f8d0fc8f1b 100644 --- a/libavcodec/cbs_h266_syntax_template.c +++ b/libavcodec/cbs_h266_syntax_template.c @@ -1748,10 +1748,10 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, "Tile column width(%d) exceeds picture width\n",i); return AVERROR_INVALIDDATA; } + current->col_width_val[i] = current->pps_tile_column_width_minus1[i] + 1; remaining_size -= (current->pps_tile_column_width_minus1[i] + 1); } - unified_size = (i == 0 ? pic_width_in_ctbs_y : - (current->pps_tile_column_width_minus1[i - 1] + 1)); + unified_size = current->pps_tile_column_width_minus1[i - 1] + 1; while (remaining_size > 0) { if (current->num_tile_columns > VVC_MAX_TILE_COLUMNS) { av_log(ctx->log_ctx, AV_LOG_ERROR, @@ -1760,7 +1760,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, return AVERROR_INVALIDDATA; } unified_size = FFMIN(remaining_size, unified_size); - current->pps_tile_column_width_minus1[i] = unified_size - 1; + current->col_width_val[i] = unified_size; remaining_size -= unified_size; i++; } @@ -1779,14 +1779,14 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, "Tile row height(%d) exceeds picture height\n",i); return AVERROR_INVALIDDATA; } + current->row_height_val[i] = current->pps_tile_row_height_minus1[i] + 1; remaining_size -= (current->pps_tile_row_height_minus1[i] + 1); } - unified_size = (i == 0 ? pic_height_in_ctbs_y : - (current->pps_tile_row_height_minus1[i - 1] + 1)); + unified_size = current->pps_tile_row_height_minus1[i - 1] + 1; while (remaining_size > 0) { unified_size = FFMIN(remaining_size, unified_size); - current->pps_tile_row_height_minus1[i] = unified_size - 1; + current->row_height_val[i] = unified_size; remaining_size -= unified_size; i++; } @@ -1852,20 +1852,20 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, ctu_x = ctu_y = 0; for (j = 0; j < tile_x; j++) { - ctu_x += current->pps_tile_column_width_minus1[j] + 1; + ctu_x += current->col_width_val[j]; } for (j = 0; j < tile_y; j++) { - ctu_y += current->pps_tile_row_height_minus1[j] + 1; + ctu_y += current->row_height_val[j]; } if (current->pps_slice_width_in_tiles_minus1[i] == 0 && current->pps_slice_height_in_tiles_minus1[i] == 0 && - current->pps_tile_row_height_minus1[tile_y] > 0) { + current->row_height_val[tile_y] > 1) { int num_slices_in_tile, uniform_slice_height, remaining_height_in_ctbs_y; remaining_height_in_ctbs_y = - current->pps_tile_row_height_minus1[tile_y] + 1; + current->row_height_val[tile_y]; ues(pps_num_exp_slices_in_tile[i], - 0, current->pps_tile_row_height_minus1[tile_y], 1, i); + 0, current->row_height_val[tile_y] - 1, 1, i); if (current->pps_num_exp_slices_in_tile[i] == 0) { num_slices_in_tile = 1; slice_top_left_ctu_x[i] = ctu_x; @@ -1875,7 +1875,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, for (j = 0; j < current->pps_num_exp_slices_in_tile[i]; j++) { ues(pps_exp_slice_height_in_ctus_minus1[i][j], 0, - current->pps_tile_row_height_minus1[tile_y], 2, + current->row_height_val[tile_y] - 1, 2, i, j); slice_height_in_ctus = current-> @@ -1890,7 +1890,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, remaining_height_in_ctbs_y -= slice_height_in_ctus; } uniform_slice_height = 1 + - (j == 0 ? current->pps_tile_row_height_minus1[tile_y] : + (j == 0 ? current->row_height_val[tile_y] - 1: current->pps_exp_slice_height_in_ctus_minus1[i][j-1]); while (remaining_height_in_ctbs_y > uniform_slice_height) { current->slice_height_in_ctus[i + j] = @@ -1919,7 +1919,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, j <= current->pps_slice_height_in_tiles_minus1[i]; j++) { height += - current->pps_tile_row_height_minus1[tile_y + j] + 1; + current->row_height_val[tile_y + j]; } current->slice_height_in_ctus[i] = height; @@ -1956,10 +1956,10 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, ctu_x = 0, ctu_y = 0; for (j = 0; j < tile_x; j++) { - ctu_x += current->pps_tile_column_width_minus1[j] + 1; + ctu_x += current->col_width_val[j]; } for (j = 0; j < tile_y; j++) { - ctu_y += current->pps_tile_row_height_minus1[j] + 1; + ctu_y += current->row_height_val[j]; } slice_top_left_ctu_x[i] = ctu_x; slice_top_left_ctu_y[i] = ctu_y; @@ -1972,7 +1972,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, for (j = 0; j <= current->pps_slice_height_in_tiles_minus1[i]; j++) { height += - current->pps_tile_row_height_minus1[tile_y + j] + 1; + current->row_height_val[tile_y + j]; } current->slice_height_in_ctus[i] = height; @@ -2015,6 +2015,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, infer(pps_tile_column_width_minus1[0], pic_width_in_ctbs_y - 1); infer(pps_num_exp_tile_rows_minus1, 0); infer(pps_tile_row_height_minus1[0], pic_height_in_ctbs_y - 1); + infer(row_height_val[0], pic_height_in_ctbs_y); infer(num_tile_columns, 1); infer(num_tile_rows, 1); infer(num_tiles_in_pic, 1); @@ -3037,7 +3038,7 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw, current->sh_slice_address + current->sh_num_tiles_in_slice_minus1; tile_idx++) { tile_y = tile_idx / pps->num_tile_rows; - height = pps->pps_tile_row_height_minus1[tile_y] + 1; + height = pps->row_height_val[tile_y]; num_entry_points += (entropy_sync ? height : 1); } } -- 2.41.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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h266: store SubpicIdVal in the context 2023-07-01 1:36 [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h266: store SubpicIdVal in the context James Almer 2023-07-01 1:36 ` [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h266: store RowHeightVal " James Almer @ 2023-07-01 14:51 ` Nuo Mi 1 sibling, 0 replies; 7+ messages in thread From: Nuo Mi @ 2023-07-01 14:51 UTC (permalink / raw) To: FFmpeg development discussions and patches On Sat, Jul 1, 2023 at 9:37 AM James Almer <jamrial@gmail.com> wrote: > And use it to derive CurrSubpicIdx > > Signed-off-by: James Almer <jamrial@gmail.com> > --- > libavcodec/cbs_h266.h | 2 ++ > libavcodec/cbs_h266_syntax_template.c | 34 +++++++++++++-------------- > 2 files changed, 19 insertions(+), 17 deletions(-) > > diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h > index be3c744426..edcb5ad0e3 100644 > --- a/libavcodec/cbs_h266.h > +++ b/libavcodec/cbs_h266.h > @@ -552,6 +552,8 @@ typedef struct H266RawPPS { > uint16_t num_tiles_in_pic; > uint16_t slice_height_in_ctus[VVC_MAX_SLICES]; > uint16_t num_slices_in_subpic[VVC_MAX_SLICES]; > + uint16_t sub_pic_id_val[VVC_MAX_SLICES]; > + uint16_t row_height_val[VVC_MAX_TILE_ROWS]; > row_height_val is not related to this patch. Other things are ok. > } H266RawPPS; > > typedef struct H266RawAUD { > diff --git a/libavcodec/cbs_h266_syntax_template.c > b/libavcodec/cbs_h266_syntax_template.c > index 863fecdefa..ec2bb1ccc3 100644 > --- a/libavcodec/cbs_h266_syntax_template.c > +++ b/libavcodec/cbs_h266_syntax_template.c > @@ -1706,6 +1706,15 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, > RWContext *rw, > } > } > > + for (i = 0; i <= sps->sps_num_subpics_minus1; i++) { > + if (sps->sps_subpic_id_mapping_explicitly_signalled_flag) > + current->sub_pic_id_val[i] = > current->pps_subpic_id_mapping_present_flag > + ? current->pps_subpic_id[i] > + : sps->sps_subpic_id[i]; > + else > + current->sub_pic_id_val[i] = i; > + } > + > pic_width_in_ctbs_y = AV_CEIL_RSHIFT > (current->pps_pic_width_in_luma_samples, > (sps->sps_log2_ctu_size_minus5 + 5)); > pic_height_in_ctbs_y = AV_CEIL_RSHIFT( > @@ -2697,25 +2706,16 @@ static int FUNC(slice_header) > (CodedBitstreamContext *ctx, RWContext *rw, > > if (sps->sps_subpic_info_present_flag) { > ub(sps->sps_subpic_id_len_minus1 + 1, sh_subpic_id); > - if (sps->sps_subpic_id_mapping_explicitly_signalled_flag) { > - for (i = 0; i <= sps->sps_num_subpics_minus1; i++) { > - uint16_t subpic_id_val = > - pps->pps_subpic_id_mapping_present_flag ? > - pps->pps_subpic_id[i] : sps->sps_subpic_id[i]; > - if (subpic_id_val == current->sh_subpic_id) { > - curr_subpic_idx = i; > - break; > - } > - } > - } else { > - curr_subpic_idx = current->sh_subpic_id; > - if (curr_subpic_idx > sps->sps_num_subpics_minus1) { > - av_log(ctx->log_ctx, AV_LOG_ERROR, > - "sh_subpic_id(%d) should in range [0, %d]\n", > - curr_subpic_idx, sps->sps_num_subpics_minus1); > - return AVERROR_INVALIDDATA; > + for (i = 0; i <= sps->sps_num_subpics_minus1; i++) { > + if (pps->sub_pic_id_val[i] == current->sh_subpic_id) { > + curr_subpic_idx = i; > + break; > } > } > + if (i > sps->sps_num_subpics_minus1) { > + av_log(ctx->log_ctx, AV_LOG_ERROR, "invalid CurrSubpicIdx > %d\n", i); > + return AVERROR_INVALIDDATA; > + } > } else { > curr_subpic_idx = 0; > } > -- > 2.41.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". > _______________________________________________ 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] 7+ messages in thread
end of thread, other threads:[~2023-07-01 23:40 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-07-01 1:36 [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h266: store SubpicIdVal in the context James Almer 2023-07-01 1:36 ` [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h266: store RowHeightVal " James Almer 2023-07-01 15:10 ` Nuo Mi 2023-07-01 22:33 ` James Almer 2023-07-01 23:40 ` James Almer 2023-07-01 23:39 ` [FFmpeg-devel] [PATCH v2] avcodec/cbs_h266: store RowHeightVal and ColWidthVal " James Almer 2023-07-01 14:51 ` [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h266: store SubpicIdVal " Nuo Mi
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