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
25782578 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
25792579 int ret;
25802580
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−
25892581 while (more_data && ctb_addr_ts < sps->ctb_size) {
25902582 int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts];
25912583
@@ -2813,6 +2805,27 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 221 unmodified lines
28132805 return res;
28142806 }
28152807
2808+static 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+
28162829 static int set_side_data(HEVCContext *s)
28172830 {
28182831 AVFrame *out = s->cur_frame->f;
@@ -3152,12 +3165,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 333 unmodified lines
31523165 goto fail;
31533166 }
31543167
3155− if (s->avctx->active_thread_type == FF_THREAD_SLICE &&
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);
3168+ ctb_addr_ts = decode_slice_data(s, nal, &gb);
31613169 if (ctb_addr_ts >= s->cur_frame->ctb_count) {
31623170 ret = hevc_frame_end(s);
31633171 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