History

lavc/hevcdec: drop redundant HEVCContext.threads_{type,number}

They are useless duplicates of corresponding AVCodecContext fields.

Anton Khirnov committed 2 years ago

Commit e4e9e1d1 parent b0c29a45 files · +19 −32Browse files

Showing the changes to libavcodec (5 of 5 files). Show all

Unified · Split

5 files
  1. libavcodec/hevc/filter.c +3 −3
  2. libavcodec/hevc/hevcdec.c +13 −23
  3. libavcodec/hevc/hevcdec.h +0 −3
  4. libavcodec/hevc/mvs.c +2 −2
  5. libavcodec/hevc/refs.c +1 −1
libavcodec/hevc/filter.c+3−3
@@ -892,15 +892,15 @@ void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCPPS *pps, · 891 unmodified lines
892892 sao_filter_CTB(lc, s, pps, sps, x - ctb_size, y);
893893 if (y && x_end) {
894894 sao_filter_CTB(lc, s, pps, sps, x, y - ctb_size);
895− if (s->threads_type & FF_THREAD_FRAME )
895+ if (s->avctx->active_thread_type & FF_THREAD_FRAME )
896896 ff_progress_frame_report(&s->cur_frame->tf, y);
897897 }
898898 if (x_end && y_end) {
899899 sao_filter_CTB(lc, s, pps, sps, x , y);
900− if (s->threads_type & FF_THREAD_FRAME )
900+ if (s->avctx->active_thread_type & FF_THREAD_FRAME )
901901 ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size);
902902 }
903− } else if (s->threads_type & FF_THREAD_FRAME && x_end)
903+ } else if (s->avctx->active_thread_type & FF_THREAD_FRAME && x_end)
904904 ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size - 4);
905905 }
906906
libavcodec/hevc/hevcdec.c+13−23
@@ -968,8 +968,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 967 unmodified lines
968968 unsigned val = get_bits_long(gb, offset_len);
969969 sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size
970970 }
971− if (s->threads_number > 1 && (pps->num_tile_rows > 1 || pps->num_tile_columns > 1))
972− s->threads_number = 1;
973971 }
974972 }
975973
@@ -1870,7 +1868,7 @@ static void chroma_mc_bi(HEVCLocalContext *lc, · 894 unmodified lines
18701868 static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref,
18711869 const Mv *mv, int y0, int height)
18721870 {
1873− if (s->threads_type == FF_THREAD_FRAME ) {
1871+ if (s->avctx->active_thread_type == FF_THREAD_FRAME ) {
18741872 int y = FFMAX(0, (mv->y >> 2) + y0 + height + 9);
18751873
18761874 ff_progress_frame_await(&ref->tf, y);
@@ -2631,7 +2629,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) · 754 unmodified lines
26312629 return ctb_addr_ts;
26322630 }
26332631
2634−static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
2632+static int hls_decode_entry_wpp(AVCodecContext *avctx, void *hevc_lclist,
26352633 int job, int self_id)
26362634 {
26372635 HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id];
@@ -2643,7 +2641,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 5 unmodified lines
26432641 int ctb_row = job;
26442642 int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((sps->width + ctb_size - 1) >> sps->log2_ctb_size);
26452643 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs];
2646− int thread = ctb_row % s->threads_number;
2644+ int thread = ctb_row % avctx->thread_count;
26472645
26482646 const uint8_t *data = s->data + s->sh.offset[ctb_row];
26492647 const size_t data_size = s->sh.size[ctb_row];
@@ -2736,8 +2734,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 86 unmodified lines
27362734 return AVERROR_INVALIDDATA;
27372735 }
27382736
2739− if (s->threads_number > s->nb_local_ctx) {
2740− HEVCLocalContext *tmp = av_malloc_array(s->threads_number, sizeof(*s->local_ctx));
2737+ if (s->avctx->thread_count > s->nb_local_ctx) {
2738+ HEVCLocalContext *tmp = av_malloc_array(s->avctx->thread_count, sizeof(*s->local_ctx));
27412739
27422740 if (!tmp)
27432741 return AVERROR(ENOMEM);
@@ -2746,7 +2744,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 2 unmodified lines
27462744 av_free(s->local_ctx);
27472745 s->local_ctx = tmp;
27482746
2749− for (unsigned i = s->nb_local_ctx; i < s->threads_number; i++) {
2747+ for (unsigned i = s->nb_local_ctx; i < s->avctx->thread_count; i++) {
27502748 tmp = &s->local_ctx[i];
27512749
27522750 memset(tmp, 0, sizeof(*tmp));
@@ -2756,7 +2754,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 3 unmodified lines
27562754 tmp->common_cabac_state = &s->cabac;
27572755 }
27582756
2759− s->nb_local_ctx = s->threads_number;
2757+ s->nb_local_ctx = s->avctx->thread_count;
27602758 }
27612759
27622760 offset = s->sh.data_offset;
@@ -2795,7 +2793,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 32 unmodified lines
27952793
27962794 s->data = data;
27972795
2798− for (i = 1; i < s->threads_number; i++) {
2796+ for (i = 1; i < s->nb_local_ctx; i++) {
27992797 s->local_ctx[i].first_qp_group = 1;
28002798 s->local_ctx[i].qp_y = s->local_ctx[0].qp_y;
28012799 }
@@ -3157,7 +3155,9 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 355 unmodified lines
31573155 goto fail;
31583156 }
31593157
3160− if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0)
3158+ if (s->avctx->active_thread_type == FF_THREAD_SLICE &&
3159+ s->sh.num_entry_point_offsets > 0 &&
3160+ s->pps->num_tile_rows == 1 && s->pps->num_tile_columns == 1)
31613161 ctb_addr_ts = hls_slice_data_wpp(s, nal);
31623162 else
31633163 ctb_addr_ts = hls_decode_entry(s, &gb);
@@ -3282,7 +3282,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) · 118 unmodified lines
32823282 }
32833283
32843284 fail:
3285− if (s->cur_frame && s->threads_type == FF_THREAD_FRAME)
3285+ if (s->cur_frame && s->avctx->active_thread_type == FF_THREAD_FRAME)
32863286 ff_progress_frame_report(&s->cur_frame->tf, INT_MAX);
32873287
32883288 return ret;
@@ -3610,9 +3610,6 @@ static int hevc_update_thread_context(AVCodecContext *dst, · 321 unmodified lines
36103610 s->is_nalff = s0->is_nalff;
36113611 s->nal_length_size = s0->nal_length_size;
36123612
3613− s->threads_number = s0->threads_number;
3614− s->threads_type = s0->threads_type;
3615−
36163613 s->film_grain_warning_shown = s0->film_grain_warning_shown;
36173614
36183615 if (s0->eos) {
@@ -3660,17 +3657,10 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx) · 41 unmodified lines
36603657 int ret;
36613658
36623659 if (avctx->active_thread_type & FF_THREAD_SLICE) {
3663− s->threads_number = avctx->thread_count;
36643660 ret = ff_slice_thread_init_progress(avctx);
36653661 if (ret < 0)
36663662 return ret;
3667− } else
3668− s->threads_number = 1;
3669−
3670− if((avctx->active_thread_type & FF_THREAD_FRAME) && avctx->thread_count > 1)
3671− s->threads_type = FF_THREAD_FRAME;
3672− else
3673− s->threads_type = FF_THREAD_SLICE;
3663+ }
36743664
36753665 ret = hevc_init_context(avctx);
36763666 if (ret < 0)
libavcodec/hevc/hevcdec.h+0−3
@@ -453,9 +453,6 @@ typedef struct HEVCContext { · 452 unmodified lines
453453 HEVCLocalContext *local_ctx;
454454 unsigned nb_local_ctx;
455455
456− uint8_t threads_type;
457− uint8_t threads_number;
458−
459456 /** 1 if the independent slice segment header was successfully parsed */
460457 uint8_t slice_initialized;
461458
libavcodec/hevc/mvs.c+2−2
@@ -248,7 +248,7 @@ static int temporal_luma_motion_vector(const HEVCContext *s, const HEVCSPS *sps, · 247 unmodified lines
248248 x < sps->width) {
249249 x &= ~15;
250250 y &= ~15;
251− if (s->threads_type == FF_THREAD_FRAME)
251+ if (s->avctx->active_thread_type == FF_THREAD_FRAME)
252252 ff_progress_frame_await(&ref->tf, y);
253253 x_pu = x >> sps->log2_min_pu_size;
254254 y_pu = y >> sps->log2_min_pu_size;
@@ -262,7 +262,7 @@ static int temporal_luma_motion_vector(const HEVCContext *s, const HEVCSPS *sps, · 7 unmodified lines
262262 y = y0 + (nPbH >> 1);
263263 x &= ~15;
264264 y &= ~15;
265− if (s->threads_type == FF_THREAD_FRAME)
265+ if (s->avctx->active_thread_type == FF_THREAD_FRAME)
266266 ff_progress_frame_await(&ref->tf, y);
267267 x_pu = x >> sps->log2_min_pu_size;
268268 y_pu = y >> sps->log2_min_pu_size;
libavcodec/hevc/refs.c+1−1
@@ -435,7 +435,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) · 434 unmodified lines
435435 frame->sequence = HEVC_SEQUENCE_COUNTER_INVALID;
436436 frame->flags = 0;
437437
438− if (s->threads_type == FF_THREAD_FRAME)
438+ if (s->avctx->active_thread_type == FF_THREAD_FRAME)
439439 ff_progress_frame_report(&frame->tf, INT_MAX);
440440
441441 return frame;

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