[FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h265: fix valid range of num_tile_{columns, rows}_minus1 in H265RawPPS
James Almer
jamrial at gmail.com
Thu Jun 20 20:45:24 EEST 2019
The spec states they can't be higher than the respective dimensions of the
stream in CTBs.
Signed-off-by: James Almer <jamrial at gmail.com>
---
I don't think it's wise further limiting the range to the maximum currently
defined for level 6.2 using those two HEVC_ defines, since a stream could in
theory go beyond them (New levels defined in the future?), but the alternative
is making the column_width_minus1 and row_height_minus1 arrays much bigger, or
dinamically allocated.
libavcodec/cbs_h265_syntax_template.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c
index f279d283d9..d2a20ddb35 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -1045,8 +1045,17 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext *rw,
flag(entropy_coding_sync_enabled_flag);
if (current->tiles_enabled_flag) {
- ue(num_tile_columns_minus1, 0, HEVC_MAX_TILE_COLUMNS);
- ue(num_tile_rows_minus1, 0, HEVC_MAX_TILE_ROWS);
+ unsigned int min_cb_log2_size_y = sps->log2_min_luma_coding_block_size_minus3 + 3;
+ unsigned int ctb_log2_size_y =
+ min_cb_log2_size_y + sps->log2_diff_max_min_luma_coding_block_size;
+ unsigned int ctb_size_y = 1 << ctb_log2_size_y;
+ unsigned int pic_width_in_ctbs_y =
+ (sps->pic_width_in_luma_samples + ctb_size_y - 1) / ctb_size_y;
+ unsigned int pic_height_in_ctbs_y =
+ (sps->pic_height_in_luma_samples + ctb_size_y - 1) / ctb_size_y;
+
+ ue(num_tile_columns_minus1, 0, FFMIN(pic_width_in_ctbs_y - 1, HEVC_MAX_TILE_COLUMNS - 1));
+ ue(num_tile_rows_minus1, 0, FFMIN(pic_height_in_ctbs_y - 1, HEVC_MAX_TILE_ROWS - 1));
flag(uniform_spacing_flag);
if (!current->uniform_spacing_flag) {
for (i = 0; i < current->num_tile_columns_minus1; i++)
--
2.22.0
More information about the ffmpeg-devel
mailing list