1 /*
2 * Copyright(c) 2019 Intel Corporation
3 * SPDX - License - Identifier: BSD - 2 - Clause - Patent
4 */
5
6 #include "EbAvcStyleMcp.h"
7 #include "EbPictureOperators.h"
8
unpack_uni_pred_ref10_bit(EbPictureBufferDesc * ref_frame_pic_list0,uint32_t pos_x,uint32_t pos_y,uint32_t pu_width,uint32_t pu_height,EbPictureBufferDesc * dst,uint32_t dst_luma_index,uint32_t dst_chroma_index,uint32_t component_mask,EbByte temp_buf)9 void unpack_uni_pred_ref10_bit(
10 EbPictureBufferDesc *ref_frame_pic_list0,
11 uint32_t pos_x,
12 uint32_t pos_y,
13 uint32_t pu_width,
14 uint32_t pu_height,
15 EbPictureBufferDesc *dst,
16 uint32_t dst_luma_index,
17 uint32_t dst_chroma_index, //input parameter, please refer to the detailed explanation above.
18 uint32_t component_mask,
19 EbByte temp_buf)
20 {
21 uint32_t chroma_pu_width = pu_width >> 1;
22 uint32_t chroma_pu_height = pu_height >> 1;
23
24 //doing the luma interpolation
25 if (component_mask & PICTURE_BUFFER_DESC_LUMA_MASK)
26 {
27 (void) temp_buf;
28 uint32_t in_posx = (pos_x >> 2);
29 uint32_t in_posy = (pos_y >> 2);
30 uint16_t *ptr16 = (uint16_t *)ref_frame_pic_list0->buffer_y + in_posx + in_posy*ref_frame_pic_list0->stride_y;
31
32 eb_vp9_extract8_bitdata_safe_sub(
33 ptr16,
34 ref_frame_pic_list0->stride_y,
35 dst->buffer_y + dst_luma_index,
36 dst->stride_y,
37 pu_width,
38 pu_height
39 );
40
41 }
42
43 //chroma
44 if (component_mask & PICTURE_BUFFER_DESC_CHROMA_MASK) {
45
46 {
47 uint32_t in_posx = (pos_x >> 3);
48 uint32_t in_posy = (pos_y >> 3);
49 uint16_t *ptr16 = (uint16_t *)ref_frame_pic_list0->buffer_cb + in_posx + in_posy*ref_frame_pic_list0->stride_cb;
50
51 eb_vp9_extract_8bit_data(
52 ptr16,
53 ref_frame_pic_list0->stride_cb,
54 dst->buffer_cb + dst_chroma_index,
55 dst->stride_cb,
56 chroma_pu_width,
57 chroma_pu_height
58 );
59
60 ptr16 = (uint16_t *)ref_frame_pic_list0->buffer_cr + in_posx + in_posy*ref_frame_pic_list0->stride_cr;
61
62 eb_vp9_extract_8bit_data(
63 ptr16,
64 ref_frame_pic_list0->stride_cr,
65 dst->buffer_cr + dst_chroma_index,
66 dst->stride_cr,
67 chroma_pu_width,
68 chroma_pu_height
69 );
70
71 }
72 }
73
74 }
75
unpack_bi_pred_ref10_bit(EbPictureBufferDesc * ref_frame_pic_list0,EbPictureBufferDesc * ref_frame_pic_list1,uint32_t ref_list0_pos_x,uint32_t ref_list0_pos_y,uint32_t ref_list1_pos_x,uint32_t ref_list1_pos_y,uint32_t pu_width,uint32_t pu_height,EbPictureBufferDesc * bi_dst,uint32_t dst_luma_index,uint32_t dst_chroma_index,uint32_t component_mask,EbByte ref_list0_temp_dst,EbByte ref_list1_temp_dst,EbByte first_pass_if_temp_dst)76 void unpack_bi_pred_ref10_bit(
77 EbPictureBufferDesc *ref_frame_pic_list0,
78 EbPictureBufferDesc *ref_frame_pic_list1,
79 uint32_t ref_list0_pos_x,
80 uint32_t ref_list0_pos_y,
81 uint32_t ref_list1_pos_x,
82 uint32_t ref_list1_pos_y,
83 uint32_t pu_width,
84 uint32_t pu_height,
85 EbPictureBufferDesc *bi_dst,
86 uint32_t dst_luma_index,
87 uint32_t dst_chroma_index,
88 uint32_t component_mask,
89 EbByte ref_list0_temp_dst,
90 EbByte ref_list1_temp_dst,
91 EbByte first_pass_if_temp_dst)
92 {
93 uint32_t chroma_pu_width = pu_width >> 1;
94 uint32_t chroma_pu_height = pu_height >> 1;
95
96 //Luma
97 if (component_mask & PICTURE_BUFFER_DESC_LUMA_MASK) {
98
99 (void) first_pass_if_temp_dst;
100 (void) ref_list0_temp_dst;
101 (void) ref_list1_temp_dst;
102 eb_vp9_unpack_l0l1_avg_safe_sub(
103 (uint16_t *)ref_frame_pic_list0->buffer_y + (ref_list0_pos_x >> 2) + (ref_list0_pos_y >> 2)*ref_frame_pic_list0->stride_y,
104 ref_frame_pic_list0->stride_y,
105 (uint16_t *)ref_frame_pic_list1->buffer_y + (ref_list1_pos_x >> 2) + (ref_list1_pos_y >> 2)*ref_frame_pic_list1->stride_y,
106 ref_frame_pic_list1->stride_y,
107 bi_dst->buffer_y + dst_luma_index,
108 bi_dst->stride_y,
109 pu_width,
110 pu_height
111 );
112
113 }
114
115 //uni-prediction List0 chroma
116 if (component_mask & PICTURE_BUFFER_DESC_CHROMA_MASK) {
117
118 eb_vp9_unpack_l0l1_avg(
119 (uint16_t *)ref_frame_pic_list0->buffer_cb + (ref_list0_pos_x >> 3) + (ref_list0_pos_y >> 3)*ref_frame_pic_list0->stride_cb,
120 ref_frame_pic_list0->stride_cb,
121 (uint16_t *)ref_frame_pic_list1->buffer_cb + (ref_list1_pos_x >> 3) + (ref_list1_pos_y >> 3)*ref_frame_pic_list1->stride_cb,
122 ref_frame_pic_list1->stride_cb,
123 bi_dst->buffer_cb + dst_chroma_index,
124 bi_dst->stride_cb ,
125 chroma_pu_width,
126 chroma_pu_height
127 );
128
129 eb_vp9_unpack_l0l1_avg(
130 (uint16_t *)ref_frame_pic_list0->buffer_cr + (ref_list0_pos_x >> 3) + (ref_list0_pos_y >> 3)*ref_frame_pic_list0->stride_cr,
131 ref_frame_pic_list0->stride_cr,
132 (uint16_t *)ref_frame_pic_list1->buffer_cr + (ref_list1_pos_x >> 3) + (ref_list1_pos_y >> 3)*ref_frame_pic_list1->stride_cr,
133 ref_frame_pic_list1->stride_cr,
134 bi_dst->buffer_cr + dst_chroma_index,
135 bi_dst->stride_cr,
136 chroma_pu_width,
137 chroma_pu_height
138 );
139
140 }
141 }
142
bi_pred_average_kernel_c(EbByte src0,uint32_t src0_stride,EbByte src1,uint32_t src1_stride,EbByte dst,uint32_t dst_stride,uint32_t area_width,uint32_t area_height)143 void bi_pred_average_kernel_c(
144 EbByte src0,
145 uint32_t src0_stride,
146 EbByte src1,
147 uint32_t src1_stride,
148 EbByte dst,
149 uint32_t dst_stride,
150 uint32_t area_width,
151 uint32_t area_height
152 )
153 {
154
155 uint32_t i, j;
156
157 for (j = 0; j < area_height; j++)
158 {
159 for (i = 0; i < area_width; i++)
160 {
161 dst[i + j * dst_stride] = (src0[i + j * src0_stride] + src1[i + j * src1_stride] + 1) / 2;
162 }
163 }
164
165 }
166