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 | #define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)]) | 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 | const HEVCPPS *pps, const HEVCSPS *sps, | 269 | const HEVCPPS *pps, const HEVCSPS *sps, |
| 269 | int x, int y) | 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 | int y_ctb = y >> sps->log2_ctb_size; | 276 | int y_ctb = y >> sps->log2_ctb_size; |
| 276 | int ctb_addr_rs = y_ctb * sps->ctb_width + x_ctb; | 277 | int ctb_addr_rs = y_ctb * sps->ctb_width + x_ctb; |
| 277 | int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs]; | 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 | // flags indicating unfilterable edges | 280 | // flags indicating unfilterable edges |
| 280 | uint8_t vert_edge[] = { 0, 0 }; | 281 | uint8_t vert_edge[] = { 0, 0 }; |
| 281 | uint8_t horiz_edge[] = { 0, 0 }; | 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 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb - 1) * w + x0 - left) << sh); | 386 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb - 1) * w + x0 - left) << sh); |
| 386 | pos = 0; | 387 | pos = 0; |
| 387 | if (left) { | 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 | SAO_APPLIED); | 390 | SAO_APPLIED); |
| 390 | copy_pixel(dst1, src1[src_idx], sh); | 391 | copy_pixel(dst1, src1[src_idx], sh); |
| 391 | pos += (1 << sh); | 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 | SAO_APPLIED); | 395 | SAO_APPLIED); |
| 395 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | 396 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); |
| 396 | if (right) { | 397 | if (right) { |
| 397 | pos += width << sh; | 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 | SAO_APPLIED); | 400 | SAO_APPLIED); |
| 400 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | 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 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) * w + x0 - left) << sh); | 413 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) * w + x0 - left) << sh); |
| 413 | pos = 0; | 414 | pos = 0; |
| 414 | if (left) { | 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 | SAO_APPLIED); | 417 | SAO_APPLIED); |
| 417 | copy_pixel(dst1, src1[src_idx], sh); | 418 | copy_pixel(dst1, src1[src_idx], sh); |
| 418 | pos += (1 << sh); | 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 | SAO_APPLIED); | 422 | SAO_APPLIED); |
| 422 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | 423 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); |
| 423 | if (right) { | 424 | if (right) { |
| 424 | pos += width << sh; | 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 | SAO_APPLIED); | 427 | SAO_APPLIED); |
| 427 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | 428 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); |
| 428 | } | 429 | } |
| 429 | } | 430 | } |
| 430 | left_pixels = 0; | 431 | left_pixels = 0; |
| 431 | if (!left_edge) { | 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 | copy_vert(dst - (1 << sh), | 434 | copy_vert(dst - (1 << sh), |
| 434 | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) * h + y0) << sh), | 435 | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) * h + y0) << sh), |
| 435 | sh, height, stride_dst, 1 << sh); | 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 | right_pixels = 0; | 441 | right_pixels = 0; |
| 441 | if (!right_edge) { | 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 | copy_vert(dst + (width << sh), | 444 | copy_vert(dst + (width << sh), |
| 444 | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 2) * h + y0) << sh), | 445 | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 2) * h + y0) << sh), |
| 445 | sh, height, stride_dst, 1 << sh); | 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 | if (sps->sao_enabled && !skip) { | 890 | if (sps->sao_enabled && !skip) { |
| 890 | int y_end = y >= sps->height - ctb_size; | 891 | int y_end = y >= sps->height - ctb_size; |
| 891 | if (y && x) | 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 | if (x && y_end) | 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 | if (y && x_end) { | 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 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) | 898 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) |
| 898 | ff_progress_frame_report(&s->cur_frame->tf, y); | 899 | ff_progress_frame_report(&s->cur_frame->tf, y); |
| 899 | } | 900 | } |
| 900 | if (x_end && y_end) { | 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 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) | 903 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) |
| 903 | ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size); | 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 | /* free everything allocated by pic_arrays_init() */ | 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 | av_freep(&s->deblock); | 72 | av_freep(&s->deblock); |
| 73 | 73 | ||
| 74 | av_freep(&s->skip_flag); | 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 | l->bs_width = (width >> 2) + 1; | 103 | l->bs_width = (width >> 2) + 1; |
| 104 | l->bs_height = (height >> 2) + 1; | 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 | s->deblock = av_calloc(ctb_count, sizeof(*s->deblock)); | 107 | s->deblock = av_calloc(ctb_count, sizeof(*s->deblock)); |
| 108 | if (!s->sao || !s->deblock) | 108 | if (!l->sao || !s->deblock) |
| 109 | goto fail; | 109 | goto fail; |
| 110 | 110 | ||
| 111 | s->skip_flag = av_malloc_array(sps->min_cb_height, sps->min_cb_width); | 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 | return 0; | 140 | return 0; |
| 141 | 141 | ||
| 142 | fail: | 142 | fail: |
| 143 | pic_arrays_free(s); | 143 | pic_arrays_free(s, l); |
| 144 | return AVERROR(ENOMEM); | 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 | int ret, i; | 532 | int ret, i; |
| 533 | 533 | ||
| 534 | pic_arrays_free(s); | 534 | pic_arrays_free(s, l); |
| 535 | s->ps.sps = NULL; | 535 | s->ps.sps = NULL; |
| 536 | ff_refstruct_unref(&s->vps); | 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 | return 0; | 576 | return 0; |
| 577 | 577 | ||
| 578 | fail: | 578 | fail: |
| 579 | pic_arrays_free(s); | 579 | pic_arrays_free(s, l); |
| 580 | for (i = 0; i < 3; i++) { | 580 | for (i = 0; i < 3; i++) { |
| 581 | av_freep(&s->sao_pixel_buffer_h[i]); | 581 | av_freep(&s->sao_pixel_buffer_h[i]); |
| 582 | av_freep(&s->sao_pixel_buffer_v[i]); | 582 | av_freep(&s->sao_pixel_buffer_v[i]); |
| @@ -990,21 +990,21 @@ do { \ · 407 unmodified lines | |||
| 990 | if (!sao_merge_up_flag && !sao_merge_left_flag) \ | 990 | if (!sao_merge_up_flag && !sao_merge_left_flag) \ |
| 991 | sao->elem = value; \ | 991 | sao->elem = value; \ |
| 992 | else if (sao_merge_left_flag) \ | 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 | else if (sao_merge_up_flag) \ | 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 | else \ | 996 | else \ |
| 997 | sao->elem = 0; \ | 997 | sao->elem = 0; \ |
| 998 | } while (0) | 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 | const HEVCPPS *pps, const HEVCSPS *sps, | 1001 | const HEVCPPS *pps, const HEVCSPS *sps, |
| 1002 | int rx, int ry) | 1002 | int rx, int ry) |
| 1003 | { | 1003 | { |
| 1004 | const HEVCContext *const s = lc->parent; | 1004 | const HEVCContext *const s = lc->parent; |
| 1005 | int sao_merge_left_flag = 0; | 1005 | int sao_merge_left_flag = 0; |
| 1006 | int sao_merge_up_flag = 0; | 1006 | int sao_merge_up_flag = 0; |
| 1007 | SAOParams *sao = &CTB(s->sao, rx, ry); | 1007 | SAOParams *sao = &CTB(l->sao, rx, ry); |
| 1008 | int c_idx, i; | 1008 | int c_idx, i; |
| 1009 | 1009 | ||
| 1010 | if (s->sh.slice_sample_adaptive_offset_flag[0] || | 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 | return ret; | 2556 | return ret; |
| 2557 | } | 2557 | } |
| 2558 | 2558 | ||
| 2559 | hls_sao_param(lc, pps, sps, | 2559 | hls_sao_param(lc, l, pps, sps, |
| 2560 | x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size); | 2560 | x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size); |
| 2561 | 2561 | ||
| 2562 | s->deblock[ctb_addr_rs].beta_offset = s->sh.beta_offset; | 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 | ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, data, data_size, 1); | 2624 | ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, data, data_size, 1); |
| 2625 | if (ret < 0) | 2625 | if (ret < 0) |
| 2626 | goto error; | 2626 | goto error; |
| 2627 | hls_sao_param(lc, pps, sps, | 2627 | hls_sao_param(lc, l, pps, sps, |
| 2628 | x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size); | 2628 | x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size); |
| 2629 | more_data = hls_coding_quadtree(lc, l, pps, sps, x_ctb, y_ctb, sps->log2_ctb_size, 0); | 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 | HEVCContext *s = avctx->priv_data; | 3518 | HEVCContext *s = avctx->priv_data; |
| 3519 | int i; | 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 | ff_refstruct_unref(&s->vps); | 3524 | ff_refstruct_unref(&s->vps); |
| 3524 | ff_refstruct_unref(&s->pps); | 3525 | ff_refstruct_unref(&s->pps); |
| @@ -443,6 +443,8 @@ typedef struct HEVCLayerContext { · 442 unmodified lines | |||
| 443 | 443 | ||
| 444 | int bs_width; | 444 | int bs_width; |
| 445 | int bs_height; | 445 | int bs_height; |
| 446 | |||
| 447 | SAOParams *sao; | ||
| 446 | } HEVCLayerContext; | 448 | } HEVCLayerContext; |
| 447 | 449 | ||
| 448 | typedef struct HEVCContext { | 450 | typedef struct HEVCContext { |
| @@ -476,7 +478,6 @@ typedef struct HEVCContext { · 27 unmodified lines | |||
| 476 | const HEVCVPS *vps; ///< RefStruct reference | 478 | const HEVCVPS *vps; ///< RefStruct reference |
| 477 | const HEVCPPS *pps; ///< RefStruct reference | 479 | const HEVCPPS *pps; ///< RefStruct reference |
| 478 | SliceHeader sh; | 480 | SliceHeader sh; |
| 479 | SAOParams *sao; | ||
| 480 | DBParams *deblock; | 481 | DBParams *deblock; |
| 481 | enum HEVCNALUnitType nal_unit_type; | 482 | enum HEVCNALUnitType nal_unit_type; |
| 482 | int temporal_id; ///< temporal_id_plus1 - 1 | 483 | int temporal_id; ///< temporal_id_plus1 - 1 |