| @@ -593,9 +593,8 @@ fail: · 592 unmodified lines |
| 593 | return ret; | 593 | return ret; |
| 594 | } | 594 | } |
| 595 | | 595 | |
| 596 | static int hls_slice_header(HEVCContext *s) | 596 | static int hls_slice_header(HEVCContext *s, GetBitContext *gb) |
| 597 | { | 597 | { |
| 598 | GetBitContext *gb = &s->HEVClc->gb; | | |
| 599 | SliceHeader *sh = &s->sh; | 598 | SliceHeader *sh = &s->sh; |
| 600 | int i, ret; | 599 | int i, ret; |
| 601 | | 600 | |
| @@ -2533,9 +2532,11 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, int x_ctb, int y_ctb, · 1931 unmodified lines |
| 2533 | lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->ps.sps->ctb_width]])); | 2532 | lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->ps.sps->ctb_width]])); |
| 2534 | } | 2533 | } |
| 2535 | | 2534 | |
| 2536 | static int hls_decode_entry(HEVCContext *s) | 2535 | static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) |
| 2537 | { | 2536 | { |
| 2538 | HEVCLocalContext *const lc = s->HEVClc; | 2537 | HEVCLocalContext *const lc = s->HEVClc; |
| | 2538 | const uint8_t *slice_data = gb->buffer + s->sh.data_offset; |
| | 2539 | const size_t slice_size = gb->buffer_end - gb->buffer - s->sh.data_offset; |
| 2539 | int ctb_size = 1 << s->ps.sps->log2_ctb_size; | 2540 | int ctb_size = 1 << s->ps.sps->log2_ctb_size; |
| 2540 | int more_data = 1; | 2541 | int more_data = 1; |
| 2541 | int x_ctb = 0; | 2542 | int x_ctb = 0; |
| @@ -2563,7 +2564,7 @@ static int hls_decode_entry(HEVCContext *s) · 21 unmodified lines |
| 2563 | y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size; | 2564 | y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size; |
| 2564 | hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts); | 2565 | hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts); |
| 2565 | | 2566 | |
| 2566 | ret = ff_hevc_cabac_init(lc, ctb_addr_ts); | 2567 | ret = ff_hevc_cabac_init(lc, ctb_addr_ts, slice_data, slice_size); |
| 2567 | if (ret < 0) { | 2568 | if (ret < 0) { |
| 2568 | s->tab_slice_address[ctb_addr_rs] = -1; | 2569 | s->tab_slice_address[ctb_addr_rs] = -1; |
| 2569 | return ret; | 2570 | return ret; |
| @@ -2605,14 +2606,14 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 35 unmodified lines |
| 2605 | int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size); | 2606 | int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size); |
| 2606 | int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; | 2607 | int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; |
| 2607 | int thread = ctb_row % s->threads_number; | 2608 | int thread = ctb_row % s->threads_number; |
| | 2609 | |
| | 2610 | const uint8_t *data = s->data + s->sh.offset[ctb_row]; |
| | 2611 | const size_t data_size = s->sh.size[ctb_row]; |
| | 2612 | |
| 2608 | int ret; | 2613 | int ret; |
| 2609 | | 2614 | |
| 2610 | if(ctb_row) { | 2615 | if (ctb_row) |
| 2611 | ret = init_get_bits8(&lc->gb, s->data + s->sh.offset[ctb_row], s->sh.size[ctb_row]); | 2616 | ff_init_cabac_decoder(&lc->cc, data, data_size); |
| 2612 | if (ret < 0) | | |
| 2613 | goto error; | | |
| 2614 | ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[ctb_row], s->sh.size[ctb_row]); | | |
| 2615 | } | | |
| 2616 | | 2617 | |
| 2617 | while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) { | 2618 | while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) { |
| 2618 | int x_ctb = (ctb_addr_rs % s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size; | 2619 | int x_ctb = (ctb_addr_rs % s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size; |
| @@ -2630,7 +2631,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 11 unmodified lines |
| 2630 | return 0; | 2631 | return 0; |
| 2631 | } | 2632 | } |
| 2632 | | 2633 | |
| 2633 | ret = ff_hevc_cabac_init(lc, ctb_addr_ts); | 2634 | ret = ff_hevc_cabac_init(lc, ctb_addr_ts, data, data_size); |
| 2634 | if (ret < 0) | 2635 | if (ret < 0) |
| 2635 | goto error; | 2636 | goto error; |
| 2636 | hls_sao_param(lc, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); | 2637 | hls_sao_param(lc, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); |
| @@ -2681,7 +2682,6 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 44 unmodified lines |
| 2681 | { | 2682 | { |
| 2682 | const uint8_t *data = nal->data; | 2683 | const uint8_t *data = nal->data; |
| 2683 | int length = nal->size; | 2684 | int length = nal->size; |
| 2684 | HEVCLocalContext *lc; | | |
| 2685 | int *ret; | 2685 | int *ret; |
| 2686 | int64_t offset; | 2686 | int64_t offset; |
| 2687 | int64_t startheader, cmpt = 0; | 2687 | int64_t startheader, cmpt = 0; |
| @@ -2719,8 +2719,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 31 unmodified lines |
| 2719 | s->nb_local_ctx = s->threads_number; | 2719 | s->nb_local_ctx = s->threads_number; |
| 2720 | } | 2720 | } |
| 2721 | | 2721 | |
| 2722 | lc = &s->local_ctx[0]; | 2722 | offset = s->sh.data_offset; |
| 2723 | offset = (lc->gb.index >> 3); | | |
| 2724 | | 2723 | |
| 2725 | for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) { | 2724 | for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) { |
| 2726 | if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { | 2725 | if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { |
| @@ -2981,11 +2980,9 @@ static int hevc_frame_end(HEVCContext *s) · 254 unmodified lines |
| 2981 | | 2980 | |
| 2982 | static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) | 2981 | static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) |
| 2983 | { | 2982 | { |
| 2984 | HEVCLocalContext *lc = s->HEVClc; | 2983 | GetBitContext gb = nal->gb; |
| 2985 | GetBitContext *gb = &lc->gb; | | |
| 2986 | int ctb_addr_ts, ret; | 2984 | int ctb_addr_ts, ret; |
| 2987 | | 2985 | |
| 2988 | *gb = nal->gb; | | |
| 2989 | s->nal_unit_type = nal->type; | 2986 | s->nal_unit_type = nal->type; |
| 2990 | s->temporal_id = nal->temporal_id; | 2987 | s->temporal_id = nal->temporal_id; |
| 2991 | | 2988 | |
| @@ -2997,7 +2994,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 5 unmodified lines |
| 2997 | if (ret < 0) | 2994 | if (ret < 0) |
| 2998 | goto fail; | 2995 | goto fail; |
| 2999 | } | 2996 | } |
| 3000 | ret = ff_hevc_decode_nal_vps(gb, s->avctx, &s->ps); | 2997 | ret = ff_hevc_decode_nal_vps(&gb, s->avctx, &s->ps); |
| 3001 | if (ret < 0) | 2998 | if (ret < 0) |
| 3002 | goto fail; | 2999 | goto fail; |
| 3003 | break; | 3000 | break; |
| @@ -3008,7 +3005,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 4 unmodified lines |
| 3008 | if (ret < 0) | 3005 | if (ret < 0) |
| 3009 | goto fail; | 3006 | goto fail; |
| 3010 | } | 3007 | } |
| 3011 | ret = ff_hevc_decode_nal_sps(gb, s->avctx, &s->ps, | 3008 | ret = ff_hevc_decode_nal_sps(&gb, s->avctx, &s->ps, |
| 3012 | s->apply_defdispwin); | 3009 | s->apply_defdispwin); |
| 3013 | if (ret < 0) | 3010 | if (ret < 0) |
| 3014 | goto fail; | 3011 | goto fail; |
| @@ -3020,7 +3017,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 5 unmodified lines |
| 3020 | if (ret < 0) | 3017 | if (ret < 0) |
| 3021 | goto fail; | 3018 | goto fail; |
| 3022 | } | 3019 | } |
| 3023 | ret = ff_hevc_decode_nal_pps(gb, s->avctx, &s->ps); | 3020 | ret = ff_hevc_decode_nal_pps(&gb, s->avctx, &s->ps); |
| 3024 | if (ret < 0) | 3021 | if (ret < 0) |
| 3025 | goto fail; | 3022 | goto fail; |
| 3026 | break; | 3023 | break; |
| @@ -3032,7 +3029,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 5 unmodified lines |
| 3032 | if (ret < 0) | 3029 | if (ret < 0) |
| 3033 | goto fail; | 3030 | goto fail; |
| 3034 | } | 3031 | } |
| 3035 | ret = ff_hevc_decode_nal_sei(gb, s->avctx, &s->sei, &s->ps, s->nal_unit_type); | 3032 | ret = ff_hevc_decode_nal_sei(&gb, s->avctx, &s->sei, &s->ps, s->nal_unit_type); |
| 3036 | if (ret < 0) | 3033 | if (ret < 0) |
| 3037 | goto fail; | 3034 | goto fail; |
| 3038 | break; | 3035 | break; |
| @@ -3052,7 +3049,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 13 unmodified lines |
| 3052 | case HEVC_NAL_RADL_R: | 3049 | case HEVC_NAL_RADL_R: |
| 3053 | case HEVC_NAL_RASL_N: | 3050 | case HEVC_NAL_RASL_N: |
| 3054 | case HEVC_NAL_RASL_R: | 3051 | case HEVC_NAL_RASL_R: |
| 3055 | ret = hls_slice_header(s); | 3052 | ret = hls_slice_header(s, &gb); |
| 3056 | if (ret < 0) | 3053 | if (ret < 0) |
| 3057 | return ret; | 3054 | return ret; |
| 3058 | if (ret == 1) { | 3055 | if (ret == 1) { |
| @@ -3134,7 +3131,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) · 75 unmodified lines |
| 3134 | if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0) | 3131 | if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0) |
| 3135 | ctb_addr_ts = hls_slice_data_wpp(s, nal); | 3132 | ctb_addr_ts = hls_slice_data_wpp(s, nal); |
| 3136 | else | 3133 | else |
| 3137 | ctb_addr_ts = hls_decode_entry(s); | 3134 | ctb_addr_ts = hls_decode_entry(s, &gb); |
| 3138 | if (ctb_addr_ts >= (s->ps.sps->ctb_width * s->ps.sps->ctb_height)) { | 3135 | if (ctb_addr_ts >= (s->ps.sps->ctb_width * s->ps.sps->ctb_height)) { |
| 3139 | ret = hevc_frame_end(s); | 3136 | ret = hevc_frame_end(s); |
| 3140 | if (ret < 0) | 3137 | if (ret < 0) |