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

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
892 sao_filter_CTB(lc, s, pps, sps, x - ctb_size, y);892 sao_filter_CTB(lc, s, pps, sps, x - ctb_size, y);
893 if (y && x_end) {893 if (y && x_end) {
894 sao_filter_CTB(lc, s, pps, sps, x, y - ctb_size);894 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 )
896 ff_progress_frame_report(&s->cur_frame->tf, y);896 ff_progress_frame_report(&s->cur_frame->tf, y);
897 }897 }
898 if (x_end && y_end) {898 if (x_end && y_end) {
899 sao_filter_CTB(lc, s, pps, sps, x , y);899 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 )
901 ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size);901 ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size);
902 }902 }
903 } else if (s->threads_type & FF_THREAD_FRAME && x_end)903 } else if (s->avctx->active_thread_type & FF_THREAD_FRAME && x_end)
904 ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size - 4);904 ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size - 4);
905}905}
906 906
libavcodec/hevc/hevcdec.c+13−23
@@ -968,8 +968,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 967 unmodified lines
968 unsigned val = get_bits_long(gb, offset_len);968 unsigned val = get_bits_long(gb, offset_len);
969 sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size969 sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size
970 }970 }
971 if (s->threads_number > 1 && (pps->num_tile_rows > 1 || pps->num_tile_columns > 1))
972 s->threads_number = 1;
973 }971 }
974 }972 }
975 973
@@ -1870,7 +1868,7 @@ static void chroma_mc_bi(HEVCLocalContext *lc, · 894 unmodified lines
1870static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref,1868static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref,
1871 const Mv *mv, int y0, int height)1869 const Mv *mv, int y0, int height)
1872{1870{
1873 if (s->threads_type == FF_THREAD_FRAME ) {1871 if (s->avctx->active_thread_type == FF_THREAD_FRAME ) {
1874 int y = FFMAX(0, (mv->y >> 2) + y0 + height + 9);1872 int y = FFMAX(0, (mv->y >> 2) + y0 + height + 9);
1875 1873
1876 ff_progress_frame_await(&ref->tf, y);1874 ff_progress_frame_await(&ref->tf, y);
@@ -2631,7 +2629,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) · 754 unmodified lines
2631 return ctb_addr_ts;2629 return ctb_addr_ts;
2632}2630}
2633 2631
2634static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,2632static int hls_decode_entry_wpp(AVCodecContext *avctx, void *hevc_lclist,
2635 int job, int self_id)2633 int job, int self_id)
2636{2634{
2637 HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id];2635 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
2643 int ctb_row = job;2641 int ctb_row = job;
2644 int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((sps->width + ctb_size - 1) >> sps->log2_ctb_size);2642 int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((sps->width + ctb_size - 1) >> sps->log2_ctb_size);
2645 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs];2643 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;
2647 2645
2648 const uint8_t *data = s->data + s->sh.offset[ctb_row];2646 const uint8_t *data = s->data + s->sh.offset[ctb_row];
2649 const size_t data_size = s->sh.size[ctb_row];2647 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
2736 return AVERROR_INVALIDDATA;2734 return AVERROR_INVALIDDATA;
2737 }2735 }
2738 2736
2739 if (s->threads_number > s->nb_local_ctx) {2737 if (s->avctx->thread_count > s->nb_local_ctx) {
2740 HEVCLocalContext *tmp = av_malloc_array(s->threads_number, sizeof(*s->local_ctx));2738 HEVCLocalContext *tmp = av_malloc_array(s->avctx->thread_count, sizeof(*s->local_ctx));
2741 2739
2742 if (!tmp)2740 if (!tmp)
2743 return AVERROR(ENOMEM);2741 return AVERROR(ENOMEM);
@@ -2746,7 +2744,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 2 unmodified lines
2746 av_free(s->local_ctx);2744 av_free(s->local_ctx);
2747 s->local_ctx = tmp;2745 s->local_ctx = tmp;
2748 2746
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++) {
2750 tmp = &s->local_ctx[i];2748 tmp = &s->local_ctx[i];
2751 2749
2752 memset(tmp, 0, sizeof(*tmp));2750 memset(tmp, 0, sizeof(*tmp));
@@ -2756,7 +2754,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 3 unmodified lines
2756 tmp->common_cabac_state = &s->cabac;2754 tmp->common_cabac_state = &s->cabac;
2757 }2755 }
2758 2756
2759 s->nb_local_ctx = s->threads_number;2757 s->nb_local_ctx = s->avctx->thread_count;
2760 }2758 }
2761 2759
2762 offset = s->sh.data_offset;2760 offset = s->sh.data_offset;
@@ -2795,7 +2793,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 32 unmodified lines
2795 2793
2796 s->data = data;2794 s->data = data;
2797 2795
2798 for (i = 1; i < s->threads_number; i++) {2796 for (i = 1; i < s->nb_local_ctx; i++) {
2799 s->local_ctx[i].first_qp_group = 1;2797 s->local_ctx[i].first_qp_group = 1;
2800 s->local_ctx[i].qp_y = s->local_ctx[0].qp_y;2798 s->local_ctx[i].qp_y = s->local_ctx[0].qp_y;
2801 }2799 }
@@ -3157,7 +3155,9 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 355 unmodified lines
3157 goto fail;3155 goto fail;
3158 }3156 }
3159 3157
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)
3161 ctb_addr_ts = hls_slice_data_wpp(s, nal);3161 ctb_addr_ts = hls_slice_data_wpp(s, nal);
3162 else3162 else
3163 ctb_addr_ts = hls_decode_entry(s, &gb);3163 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
3282 }3282 }
3283 3283
3284fail:3284fail:
3285 if (s->cur_frame && s->threads_type == FF_THREAD_FRAME)3285 if (s->cur_frame && s->avctx->active_thread_type == FF_THREAD_FRAME)
3286 ff_progress_frame_report(&s->cur_frame->tf, INT_MAX);3286 ff_progress_frame_report(&s->cur_frame->tf, INT_MAX);
3287 3287
3288 return ret;3288 return ret;
@@ -3610,9 +3610,6 @@ static int hevc_update_thread_context(AVCodecContext *dst, · 321 unmodified lines
3610 s->is_nalff = s0->is_nalff;3610 s->is_nalff = s0->is_nalff;
3611 s->nal_length_size = s0->nal_length_size;3611 s->nal_length_size = s0->nal_length_size;
3612 3612
3613 s->threads_number = s0->threads_number;
3614 s->threads_type = s0->threads_type;
3615
3616 s->film_grain_warning_shown = s0->film_grain_warning_shown;3613 s->film_grain_warning_shown = s0->film_grain_warning_shown;
3617 3614
3618 if (s0->eos) {3615 if (s0->eos) {
@@ -3660,17 +3657,10 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx) · 41 unmodified lines
3660 int ret;3657 int ret;
3661 3658
3662 if (avctx->active_thread_type & FF_THREAD_SLICE) {3659 if (avctx->active_thread_type & FF_THREAD_SLICE) {
3663 s->threads_number = avctx->thread_count;
3664 ret = ff_slice_thread_init_progress(avctx);3660 ret = ff_slice_thread_init_progress(avctx);
3665 if (ret < 0)3661 if (ret < 0)
3666 return ret;3662 return ret;
3667 } else3663 }
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;
3674 3664
3675 ret = hevc_init_context(avctx);3665 ret = hevc_init_context(avctx);
3676 if (ret < 0)3666 if (ret < 0)
libavcodec/hevc/hevcdec.h+0−3
@@ -453,9 +453,6 @@ typedef struct HEVCContext { · 452 unmodified lines
453 HEVCLocalContext *local_ctx;453 HEVCLocalContext *local_ctx;
454 unsigned nb_local_ctx;454 unsigned nb_local_ctx;
455 455
456 uint8_t threads_type;
457 uint8_t threads_number;
458
459 /** 1 if the independent slice segment header was successfully parsed */456 /** 1 if the independent slice segment header was successfully parsed */
460 uint8_t slice_initialized;457 uint8_t slice_initialized;
461 458
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
248 x < sps->width) {248 x < sps->width) {
249 x &= ~15;249 x &= ~15;
250 y &= ~15;250 y &= ~15;
251 if (s->threads_type == FF_THREAD_FRAME)251 if (s->avctx->active_thread_type == FF_THREAD_FRAME)
252 ff_progress_frame_await(&ref->tf, y);252 ff_progress_frame_await(&ref->tf, y);
253 x_pu = x >> sps->log2_min_pu_size;253 x_pu = x >> sps->log2_min_pu_size;
254 y_pu = y >> sps->log2_min_pu_size;254 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
262 y = y0 + (nPbH >> 1);262 y = y0 + (nPbH >> 1);
263 x &= ~15;263 x &= ~15;
264 y &= ~15;264 y &= ~15;
265 if (s->threads_type == FF_THREAD_FRAME)265 if (s->avctx->active_thread_type == FF_THREAD_FRAME)
266 ff_progress_frame_await(&ref->tf, y);266 ff_progress_frame_await(&ref->tf, y);
267 x_pu = x >> sps->log2_min_pu_size;267 x_pu = x >> sps->log2_min_pu_size;
268 y_pu = y >> sps->log2_min_pu_size;268 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
435 frame->sequence = HEVC_SEQUENCE_COUNTER_INVALID;435 frame->sequence = HEVC_SEQUENCE_COUNTER_INVALID;
436 frame->flags = 0;436 frame->flags = 0;
437 437
438 if (s->threads_type == FF_THREAD_FRAME)438 if (s->avctx->active_thread_type == FF_THREAD_FRAME)
439 ff_progress_frame_report(&frame->tf, INT_MAX);439 ff_progress_frame_report(&frame->tf, INT_MAX);
440 440
441 return frame;441 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