hardware/intel/libva
リビジョン | 8a8ce8ba45a2ab4877623959d957593cc40bc9cd (tree) |
---|---|
日時 | 2013-05-28 17:46:48 |
作者 | Zhao Halley <halley.zhao@inte...> |
コミッター | Xiang, Haihao |
test: add YUY2 support in loadsurface.h
@@ -88,16 +88,22 @@ static int YUV_blend_with_pic(int width, int height, | ||
88 | 88 | /* begin blend */ |
89 | 89 | |
90 | 90 | /* Y plane */ |
91 | - for (row=0; row<height; row++) | |
92 | - for (col=0; col<width; col++) { | |
93 | - unsigned char *p = Y_start + row * Y_pitch + col; | |
94 | - unsigned char *q = pic_y + row * width + col; | |
95 | - | |
91 | + int Y_pixel_stride = 1; | |
92 | + if (fourcc == VA_FOURCC_YUY2) | |
93 | + Y_pixel_stride = 2; | |
94 | + | |
95 | + for (row=0; row<height; row++) { | |
96 | + unsigned char *p = Y_start + row * Y_pitch; | |
97 | + unsigned char *q = pic_y + row * width; | |
98 | + for (col=0; col<width; col++, q++) { | |
96 | 99 | *p = *p * (100 - alpha) / 100 + *q * alpha/100; |
100 | + p += Y_pixel_stride; | |
97 | 101 | } |
102 | + } | |
98 | 103 | |
99 | 104 | /* U/V plane */ |
100 | 105 | int U_pixel_stride, V_pixel_stride; |
106 | + int v_factor_to_nv12 = 1; | |
101 | 107 | switch (fourcc) { |
102 | 108 | case VA_FOURCC_YV12: |
103 | 109 | U_pixel_stride = V_pixel_stride = 1; |
@@ -105,14 +111,18 @@ static int YUV_blend_with_pic(int width, int height, | ||
105 | 111 | case VA_FOURCC_NV12: |
106 | 112 | U_pixel_stride = V_pixel_stride = 2; |
107 | 113 | break; |
114 | + case VA_FOURCC_YUY2: | |
115 | + U_pixel_stride = V_pixel_stride = 4; | |
116 | + v_factor_to_nv12 = 2; | |
117 | + break; | |
108 | 118 | default: |
109 | 119 | break; |
110 | 120 | } |
111 | - for (row=0; row<height/2; row++) { | |
121 | + for (row=0; row<height/2*v_factor_to_nv12; row++) { | |
112 | 122 | unsigned char *pU = U_start + row * U_pitch; |
113 | 123 | unsigned char *pV = V_start + row * V_pitch; |
114 | - unsigned char *qU = pic_u + row * width/2; | |
115 | - unsigned char *qV = pic_v + row * width/2; | |
124 | + unsigned char *qU = pic_u + row/v_factor_to_nv12 * width/2; | |
125 | + unsigned char *qV = pic_v + row/v_factor_to_nv12 * width/2; | |
116 | 126 | |
117 | 127 | for (col=0; col<width/2; col++, qU++, qV++) { |
118 | 128 | *pU = *pU * (100 - alpha) / 100 + *qU * alpha/100; |
@@ -141,8 +151,11 @@ static int yuvgen_planar(int width, int height, | ||
141 | 151 | int field) |
142 | 152 | { |
143 | 153 | int row, alpha; |
154 | + unsigned char uv_value = 0x80; | |
144 | 155 | |
145 | 156 | /* copy Y plane */ |
157 | + int y_factor = 1; | |
158 | + if (fourcc == VA_FOURCC_YUY2) y_factor = 2; | |
146 | 159 | for (row=0;row<height;row++) { |
147 | 160 | unsigned char *Y_row = Y_start + row * Y_pitch; |
148 | 161 | int jj, xpos, ypos; |
@@ -159,32 +172,38 @@ static int yuvgen_planar(int width, int height, | ||
159 | 172 | for (jj=0; jj<width; jj++) { |
160 | 173 | xpos = ((row_shift + jj) / box_width) & 0x1; |
161 | 174 | if (xpos == ypos) |
162 | - Y_row[jj] = 0xeb; | |
175 | + Y_row[jj*y_factor] = 0xeb; | |
163 | 176 | else |
164 | - Y_row[jj] = 0x10; | |
177 | + Y_row[jj*y_factor] = 0x10; | |
178 | + | |
179 | + if (fourcc == VA_FOURCC_YUY2) { | |
180 | + Y_row[jj*y_factor+1] = uv_value; // it is for UV | |
181 | + } | |
165 | 182 | } |
166 | 183 | } |
167 | 184 | |
168 | 185 | /* copy UV data */ |
169 | 186 | for( row =0; row < height/2; row++) { |
170 | - unsigned short value = 0x80; | |
171 | 187 | |
172 | 188 | /* fill garbage data into the other field */ |
173 | 189 | if (((field == VA_TOP_FIELD) && (row &1)) |
174 | 190 | || ((field == VA_BOTTOM_FIELD) && ((row &1)==0))) { |
175 | - value = 0xff; | |
191 | + uv_value = 0xff; | |
176 | 192 | } |
177 | 193 | |
178 | 194 | unsigned char *U_row = U_start + row * U_pitch; |
179 | 195 | unsigned char *V_row = V_start + row * V_pitch; |
180 | 196 | switch (fourcc) { |
181 | 197 | case VA_FOURCC_NV12: |
182 | - memset(U_row, value, width); | |
198 | + memset(U_row, uv_value, width); | |
183 | 199 | break; |
184 | 200 | case VA_FOURCC_YV12: |
185 | - memset (U_row,value,width/2); | |
186 | - memset (V_row,value,width/2); | |
201 | + memset (U_row,uv_value,width/2); | |
202 | + memset (V_row,uv_value,width/2); | |
187 | 203 | break; |
204 | + case VA_FOURCC_YUY2: | |
205 | + // see above. it is set with Y update. | |
206 | + break; | |
188 | 207 | default: |
189 | 208 | printf("unsupported fourcc in loadsurface.h\n"); |
190 | 209 | assert(0); |
@@ -243,6 +262,12 @@ static int upload_surface(VADisplay va_dpy, VASurfaceID surface_id, | ||
243 | 262 | pitches[1] = surface_image.pitches[2]; |
244 | 263 | pitches[2] = surface_image.pitches[1]; |
245 | 264 | break; |
265 | + case VA_FOURCC_YUY2: | |
266 | + U_start = surface_p + 1; | |
267 | + V_start = surface_p + 3; | |
268 | + pitches[1] = surface_image.pitches[0]; | |
269 | + pitches[2] = surface_image.pitches[0]; | |
270 | + break; | |
246 | 271 | default: |
247 | 272 | assert(0); |
248 | 273 | } |