History

lavc/hevcdec: move slice decoding dispatch to its own function

Also move there a sanity check from hls_decode_entry() that should also be performed when WPP is active (note that the check is not moved to hls_slice_header() because it requires the HEVCContext.tab_slice_address to be set up).

Anton Khirnov committed 2 years ago

Commit efc827b1 parent 7cce6121 file · +22 −14Browse files

Unified · Split

libavcodec/hevc/hevcdec.c+22−14
@@ -2578,14 +2578,6 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) · 2577 unmodified lines
2578 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];2578 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
2579 int ret;2579 int ret;
2580 2580
2581 if (s->sh.dependent_slice_segment_flag) {
2582 int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
2583 if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
2584 av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
2585 return AVERROR_INVALIDDATA;
2586 }
2587 }
2588
2589 while (more_data && ctb_addr_ts < sps->ctb_size) {2581 while (more_data && ctb_addr_ts < sps->ctb_size) {
2590 int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts];2582 int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2591 2583
@@ -2813,6 +2805,27 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 221 unmodified lines
2813 return res;2805 return res;
2814}2806}
2815 2807
2808static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext *gb)
2809{
2810 const HEVCPPS *pps = s->pps;
2811
2812 if (s->sh.dependent_slice_segment_flag) {
2813 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
2814 int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
2815 if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
2816 av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
2817 return AVERROR_INVALIDDATA;
2818 }
2819 }
2820
2821 if (s->avctx->active_thread_type == FF_THREAD_SLICE &&
2822 s->sh.num_entry_point_offsets > 0 &&
2823 pps->num_tile_rows == 1 && pps->num_tile_columns == 1)
2824 return hls_slice_data_wpp(s, nal);
2825
2826 return hls_decode_entry(s, gb);
2827}
2828
2816static int set_side_data(HEVCContext *s)2829static int set_side_data(HEVCContext *s)
2817{2830{
2818 AVFrame *out = s->cur_frame->f;2831 AVFrame *out = s->cur_frame->f;
@@ -3152,12 +3165,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 333 unmodified lines
3152 goto fail;3165 goto fail;
3153 }3166 }
3154 3167
3155 if (s->avctx->active_thread_type == FF_THREAD_SLICE &&3168 ctb_addr_ts = decode_slice_data(s, nal, &gb);
3156 s->sh.num_entry_point_offsets > 0 &&
3157 s->pps->num_tile_rows == 1 && s->pps->num_tile_columns == 1)
3158 ctb_addr_ts = hls_slice_data_wpp(s, nal);
3159 else
3160 ctb_addr_ts = hls_decode_entry(s, &gb);
3161 if (ctb_addr_ts >= s->cur_frame->ctb_count) {3169 if (ctb_addr_ts >= s->cur_frame->ctb_count) {
3162 ret = hevc_frame_end(s);3170 ret = hevc_frame_end(s);
3163 if (ret < 0)3171 if (ret < 0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t