Showing the changes to libavcodec (3 of 3 files). Show all
Unified · Split
| @@ -264,7 +264,8 @@ static void restore_tqb_pixels(const HEVCContext *s, · 263 unmodified lines | ||
| 264 | 264 | |
| 265 | 265 | #define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)]) |
| 266 | 266 | |
| 267 | −static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, | |
| 267 | +static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCLayerContext *l, | |
| 268 | + const HEVCContext *s, | |
| 268 | 269 | const HEVCPPS *pps, const HEVCSPS *sps, |
| 269 | 270 | int x, int y) |
| 270 | 271 | { |
| @@ -275,7 +276,7 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, · 4 unmodified lines | ||
| 275 | 276 | int y_ctb = y >> sps->log2_ctb_size; |
| 276 | 277 | int ctb_addr_rs = y_ctb * sps->ctb_width + x_ctb; |
| 277 | 278 | int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs]; |
| 278 | − SAOParams *sao = &CTB(s->sao, x_ctb, y_ctb); | |
| 279 | + SAOParams *sao = &CTB(l->sao, x_ctb, y_ctb); | |
| 279 | 280 | // flags indicating unfilterable edges |
| 280 | 281 | uint8_t vert_edge[] = { 0, 0 }; |
| 281 | 282 | uint8_t horiz_edge[] = { 0, 0 }; |
| @@ -385,17 +386,17 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, · 103 unmodified lines | ||
| 385 | 386 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb - 1) * w + x0 - left) << sh); |
| 386 | 387 | pos = 0; |
| 387 | 388 | if (left) { |
| 388 | − src_idx = (CTB(s->sao, x_ctb-1, y_ctb-1).type_idx[c_idx] == | |
| 389 | + src_idx = (CTB(l->sao, x_ctb-1, y_ctb-1).type_idx[c_idx] == | |
| 389 | 390 | SAO_APPLIED); |
| 390 | 391 | copy_pixel(dst1, src1[src_idx], sh); |
| 391 | 392 | pos += (1 << sh); |
| 392 | 393 | } |
| 393 | − src_idx = (CTB(s->sao, x_ctb, y_ctb-1).type_idx[c_idx] == | |
| 394 | + src_idx = (CTB(l->sao, x_ctb, y_ctb-1).type_idx[c_idx] == | |
| 394 | 395 | SAO_APPLIED); |
| 395 | 396 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); |
| 396 | 397 | if (right) { |
| 397 | 398 | pos += width << sh; |
| 398 | − src_idx = (CTB(s->sao, x_ctb+1, y_ctb-1).type_idx[c_idx] == | |
| 399 | + src_idx = (CTB(l->sao, x_ctb+1, y_ctb-1).type_idx[c_idx] == | |
| 399 | 400 | SAO_APPLIED); |
| 400 | 401 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); |
| 401 | 402 | } |
| @@ -412,24 +413,24 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, · 10 unmodified lines | ||
| 412 | 413 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) * w + x0 - left) << sh); |
| 413 | 414 | pos = 0; |
| 414 | 415 | if (left) { |
| 415 | − src_idx = (CTB(s->sao, x_ctb-1, y_ctb+1).type_idx[c_idx] == | |
| 416 | + src_idx = (CTB(l->sao, x_ctb-1, y_ctb+1).type_idx[c_idx] == | |
| 416 | 417 | SAO_APPLIED); |
| 417 | 418 | copy_pixel(dst1, src1[src_idx], sh); |
| 418 | 419 | pos += (1 << sh); |
| 419 | 420 | } |
| 420 | − src_idx = (CTB(s->sao, x_ctb, y_ctb+1).type_idx[c_idx] == | |
| 421 | + src_idx = (CTB(l->sao, x_ctb, y_ctb+1).type_idx[c_idx] == | |
| 421 | 422 | SAO_APPLIED); |
| 422 | 423 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); |
| 423 | 424 | if (right) { |
| 424 | 425 | pos += width << sh; |
| 425 | − src_idx = (CTB(s->sao, x_ctb+1, y_ctb+1).type_idx[c_idx] == | |
| 426 | + src_idx = (CTB(l->sao, x_ctb+1, y_ctb+1).type_idx[c_idx] == | |
| 426 | 427 | SAO_APPLIED); |
| 427 | 428 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); |
| 428 | 429 | } |
| 429 | 430 | } |
| 430 | 431 | left_pixels = 0; |
| 431 | 432 | if (!left_edge) { |
| 432 | − if (CTB(s->sao, x_ctb-1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { | |
| 433 | + if (CTB(l->sao, x_ctb-1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { | |
| 433 | 434 | copy_vert(dst - (1 << sh), |
| 434 | 435 | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) * h + y0) << sh), |
| 435 | 436 | sh, height, stride_dst, 1 << sh); |
| @@ -439,7 +440,7 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, · 3 unmodified lines | ||
| 439 | 440 | } |
| 440 | 441 | right_pixels = 0; |
| 441 | 442 | if (!right_edge) { |
| 442 | − if (CTB(s->sao, x_ctb+1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { | |
| 443 | + if (CTB(l->sao, x_ctb+1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { | |
| 443 | 444 | copy_vert(dst + (width << sh), |
| 444 | 445 | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 2) * h + y0) << sh), |
| 445 | 446 | sh, height, stride_dst, 1 << sh); |
| @@ -889,16 +890,16 @@ void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCLayerContext *l, · 443 unmodified lines | ||
| 889 | 890 | if (sps->sao_enabled && !skip) { |
| 890 | 891 | int y_end = y >= sps->height - ctb_size; |
| 891 | 892 | if (y && x) |
| 892 | − sao_filter_CTB(lc, s, pps, sps, x - ctb_size, y - ctb_size); | |
| 893 | + sao_filter_CTB(lc, l, s, pps, sps, x - ctb_size, y - ctb_size); | |
| 893 | 894 | if (x && y_end) |
| 894 | − sao_filter_CTB(lc, s, pps, sps, x - ctb_size, y); | |
| 895 | + sao_filter_CTB(lc, l, s, pps, sps, x - ctb_size, y); | |
| 895 | 896 | if (y && x_end) { |
| 896 | − sao_filter_CTB(lc, s, pps, sps, x, y - ctb_size); | |
| 897 | + sao_filter_CTB(lc, l, s, pps, sps, x, y - ctb_size); | |
| 897 | 898 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) |
| 898 | 899 | ff_progress_frame_report(&s->cur_frame->tf, y); |
| 899 | 900 | } |
| 900 | 901 | if (x_end && y_end) { |
| 901 | − sao_filter_CTB(lc, s, pps, sps, x , y); | |
| 902 | + sao_filter_CTB(lc, l, s, pps, sps, x , y); | |
| 902 | 903 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) |
| 903 | 904 | ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size); |
| 904 | 905 | } |
| @@ -66,9 +66,9 @@ static const uint8_t hevc_pel_weight[65] = { [2] = 0, [4] = 1, [6] = 2, [8] = 3, · 65 unmodified lines | ||
| 66 | 66 | */ |
| 67 | 67 | |
| 68 | 68 | /* free everything allocated by pic_arrays_init() */ |
| 69 | −static void pic_arrays_free(HEVCContext *s) | |
| 69 | +static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) | |
| 70 | 70 | { |
| 71 | − av_freep(&s->sao); | |
| 71 | + av_freep(&l->sao); | |
| 72 | 72 | av_freep(&s->deblock); |
| 73 | 73 | |
| 74 | 74 | av_freep(&s->skip_flag); |
| @@ -103,9 +103,9 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s · 28 unmodified lines | ||
| 103 | 103 | l->bs_width = (width >> 2) + 1; |
| 104 | 104 | l->bs_height = (height >> 2) + 1; |
| 105 | 105 | |
| 106 | − s->sao = av_calloc(ctb_count, sizeof(*s->sao)); | |
| 106 | + l->sao = av_calloc(ctb_count, sizeof(*l->sao)); | |
| 107 | 107 | s->deblock = av_calloc(ctb_count, sizeof(*s->deblock)); |
| 108 | − if (!s->sao || !s->deblock) | |
| 108 | + if (!l->sao || !s->deblock) | |
| 109 | 109 | goto fail; |
| 110 | 110 | |
| 111 | 111 | s->skip_flag = av_malloc_array(sps->min_cb_height, sps->min_cb_width); |
| @@ -140,7 +140,7 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s · 28 unmodified lines | ||
| 140 | 140 | return 0; |
| 141 | 141 | |
| 142 | 142 | fail: |
| 143 | − pic_arrays_free(s); | |
| 143 | + pic_arrays_free(s, l); | |
| 144 | 144 | return AVERROR(ENOMEM); |
| 145 | 145 | } |
| 146 | 146 | |
| @@ -531,7 +531,7 @@ static int set_sps(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps) · 384 unmodified lines | ||
| 531 | 531 | { |
| 532 | 532 | int ret, i; |
| 533 | 533 | |
| 534 | − pic_arrays_free(s); | |
| 534 | + pic_arrays_free(s, l); | |
| 535 | 535 | s->ps.sps = NULL; |
| 536 | 536 | ff_refstruct_unref(&s->vps); |
| 537 | 537 | |
| @@ -576,7 +576,7 @@ static int set_sps(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps) · 38 unmodified lines | ||
| 576 | 576 | return 0; |
| 577 | 577 | |
| 578 | 578 | fail: |
| 579 | − pic_arrays_free(s); | |
| 579 | + pic_arrays_free(s, l); | |
| 580 | 580 | for (i = 0; i < 3; i++) { |
| 581 | 581 | av_freep(&s->sao_pixel_buffer_h[i]); |
| 582 | 582 | av_freep(&s->sao_pixel_buffer_v[i]); |
| @@ -990,21 +990,21 @@ do { \ · 407 unmodified lines | ||
| 990 | 990 | if (!sao_merge_up_flag && !sao_merge_left_flag) \ |
| 991 | 991 | sao->elem = value; \ |
| 992 | 992 | else if (sao_merge_left_flag) \ |
| 993 | − sao->elem = CTB(s->sao, rx-1, ry).elem; \ | |
| 993 | + sao->elem = CTB(l->sao, rx-1, ry).elem; \ | |
| 994 | 994 | else if (sao_merge_up_flag) \ |
| 995 | − sao->elem = CTB(s->sao, rx, ry-1).elem; \ | |
| 995 | + sao->elem = CTB(l->sao, rx, ry-1).elem; \ | |
| 996 | 996 | else \ |
| 997 | 997 | sao->elem = 0; \ |
| 998 | 998 | } while (0) |
| 999 | 999 | |
| 1000 | −static void hls_sao_param(HEVCLocalContext *lc, | |
| 1000 | +static void hls_sao_param(HEVCLocalContext *lc, const HEVCLayerContext *l, | |
| 1001 | 1001 | const HEVCPPS *pps, const HEVCSPS *sps, |
| 1002 | 1002 | int rx, int ry) |
| 1003 | 1003 | { |
| 1004 | 1004 | const HEVCContext *const s = lc->parent; |
| 1005 | 1005 | int sao_merge_left_flag = 0; |
| 1006 | 1006 | int sao_merge_up_flag = 0; |
| 1007 | − SAOParams *sao = &CTB(s->sao, rx, ry); | |
| 1007 | + SAOParams *sao = &CTB(l->sao, rx, ry); | |
| 1008 | 1008 | int c_idx, i; |
| 1009 | 1009 | |
| 1010 | 1010 | if (s->sh.slice_sample_adaptive_offset_flag[0] || |
| @@ -2556,7 +2556,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) · 1545 unmodified lines | ||
| 2556 | 2556 | return ret; |
| 2557 | 2557 | } |
| 2558 | 2558 | |
| 2559 | − hls_sao_param(lc, pps, sps, | |
| 2559 | + hls_sao_param(lc, l, pps, sps, | |
| 2560 | 2560 | x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size); |
| 2561 | 2561 | |
| 2562 | 2562 | s->deblock[ctb_addr_rs].beta_offset = s->sh.beta_offset; |
| @@ -2624,7 +2624,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctx, void *hevc_lclist, · 61 unmodified lines | ||
| 2624 | 2624 | ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, data, data_size, 1); |
| 2625 | 2625 | if (ret < 0) |
| 2626 | 2626 | goto error; |
| 2627 | − hls_sao_param(lc, pps, sps, | |
| 2627 | + hls_sao_param(lc, l, pps, sps, | |
| 2628 | 2628 | x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size); |
| 2629 | 2629 | more_data = hls_coding_quadtree(lc, l, pps, sps, x_ctb, y_ctb, sps->log2_ctb_size, 0); |
| 2630 | 2630 | |
| @@ -3518,7 +3518,8 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) · 887 unmodified lines | ||
| 3518 | 3518 | HEVCContext *s = avctx->priv_data; |
| 3519 | 3519 | int i; |
| 3520 | 3520 | |
| 3521 | − pic_arrays_free(s); | |
| 3521 | + for (int i = 0; i < FF_ARRAY_ELEMS(s->layers); i++) | |
| 3522 | + pic_arrays_free(s, &s->layers[i]); | |
| 3522 | 3523 | |
| 3523 | 3524 | ff_refstruct_unref(&s->vps); |
| 3524 | 3525 | ff_refstruct_unref(&s->pps); |
| @@ -443,6 +443,8 @@ typedef struct HEVCLayerContext { · 442 unmodified lines | ||
| 443 | 443 | |
| 444 | 444 | int bs_width; |
| 445 | 445 | int bs_height; |
| 446 | + | |
| 447 | + SAOParams *sao; | |
| 446 | 448 | } HEVCLayerContext; |
| 447 | 449 | |
| 448 | 450 | typedef struct HEVCContext { |
| @@ -476,7 +478,6 @@ typedef struct HEVCContext { · 27 unmodified lines | ||
| 476 | 478 | const HEVCVPS *vps; ///< RefStruct reference |
| 477 | 479 | const HEVCPPS *pps; ///< RefStruct reference |
| 478 | 480 | SliceHeader sh; |
| 479 | − SAOParams *sao; | |
| 480 | 481 | DBParams *deblock; |
| 481 | 482 | enum HEVCNALUnitType nal_unit_type; |
| 482 | 483 | int temporal_id; ///< temporal_id_plus1 - 1 |