• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

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

変更サマリ

差分

--- a/test/loadsurface.h
+++ b/test/loadsurface.h
@@ -88,16 +88,22 @@ static int YUV_blend_with_pic(int width, int height,
8888 /* begin blend */
8989
9090 /* 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++) {
9699 *p = *p * (100 - alpha) / 100 + *q * alpha/100;
100+ p += Y_pixel_stride;
97101 }
102+ }
98103
99104 /* U/V plane */
100105 int U_pixel_stride, V_pixel_stride;
106+ int v_factor_to_nv12 = 1;
101107 switch (fourcc) {
102108 case VA_FOURCC_YV12:
103109 U_pixel_stride = V_pixel_stride = 1;
@@ -105,14 +111,18 @@ static int YUV_blend_with_pic(int width, int height,
105111 case VA_FOURCC_NV12:
106112 U_pixel_stride = V_pixel_stride = 2;
107113 break;
114+ case VA_FOURCC_YUY2:
115+ U_pixel_stride = V_pixel_stride = 4;
116+ v_factor_to_nv12 = 2;
117+ break;
108118 default:
109119 break;
110120 }
111- for (row=0; row<height/2; row++) {
121+ for (row=0; row<height/2*v_factor_to_nv12; row++) {
112122 unsigned char *pU = U_start + row * U_pitch;
113123 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;
116126
117127 for (col=0; col<width/2; col++, qU++, qV++) {
118128 *pU = *pU * (100 - alpha) / 100 + *qU * alpha/100;
@@ -141,8 +151,11 @@ static int yuvgen_planar(int width, int height,
141151 int field)
142152 {
143153 int row, alpha;
154+ unsigned char uv_value = 0x80;
144155
145156 /* copy Y plane */
157+ int y_factor = 1;
158+ if (fourcc == VA_FOURCC_YUY2) y_factor = 2;
146159 for (row=0;row<height;row++) {
147160 unsigned char *Y_row = Y_start + row * Y_pitch;
148161 int jj, xpos, ypos;
@@ -159,32 +172,38 @@ static int yuvgen_planar(int width, int height,
159172 for (jj=0; jj<width; jj++) {
160173 xpos = ((row_shift + jj) / box_width) & 0x1;
161174 if (xpos == ypos)
162- Y_row[jj] = 0xeb;
175+ Y_row[jj*y_factor] = 0xeb;
163176 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+ }
165182 }
166183 }
167184
168185 /* copy UV data */
169186 for( row =0; row < height/2; row++) {
170- unsigned short value = 0x80;
171187
172188 /* fill garbage data into the other field */
173189 if (((field == VA_TOP_FIELD) && (row &1))
174190 || ((field == VA_BOTTOM_FIELD) && ((row &1)==0))) {
175- value = 0xff;
191+ uv_value = 0xff;
176192 }
177193
178194 unsigned char *U_row = U_start + row * U_pitch;
179195 unsigned char *V_row = V_start + row * V_pitch;
180196 switch (fourcc) {
181197 case VA_FOURCC_NV12:
182- memset(U_row, value, width);
198+ memset(U_row, uv_value, width);
183199 break;
184200 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);
187203 break;
204+ case VA_FOURCC_YUY2:
205+ // see above. it is set with Y update.
206+ break;
188207 default:
189208 printf("unsupported fourcc in loadsurface.h\n");
190209 assert(0);
@@ -243,6 +262,12 @@ static int upload_surface(VADisplay va_dpy, VASurfaceID surface_id,
243262 pitches[1] = surface_image.pitches[2];
244263 pitches[2] = surface_image.pitches[1];
245264 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;
246271 default:
247272 assert(0);
248273 }