comparison imgconvert.c @ 576:9aa5f0d0124e libavcodec

YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
author michaelni
date Sun, 21 Jul 2002 07:54:53 +0000
parents 000aeeac27a2
children d6955d0d7d27
comparison
equal deleted inserted replaced
575:23eee7d73c4b 576:9aa5f0d0124e
239 s1 += 2; 239 s1 += 2;
240 s2 += 2; 240 s2 += 2;
241 d++; 241 d++;
242 } 242 }
243 src += 2 * src_wrap; 243 src += 2 * src_wrap;
244 dst += dst_wrap;
245 }
246 }
247
248 /* 1x1 -> 2x2 */
249 static void grow22(UINT8 *dst, int dst_wrap,
250 UINT8 *src, int src_wrap,
251 int width, int height)
252 {
253 int w;
254 UINT8 *s1, *d;
255
256 for(;height > 0; height--) {
257 s1 = src;
258 d = dst;
259 for(w = width;w >= 4; w-=4) {
260 d[1] = d[0] = s1[0];
261 d[3] = d[2] = s1[1];
262 s1 += 2;
263 d += 4;
264 }
265 for(;w > 0; w--) {
266 d[0] = s1[0];
267 s1 ++;
268 d++;
269 }
270 if (height%2)
271 src += src_wrap;
244 dst += dst_wrap; 272 dst += dst_wrap;
245 } 273 }
246 } 274 }
247 275
248 static void img_copy(UINT8 *dst, int dst_wrap, 276 static void img_copy(UINT8 *dst, int dst_wrap,
380 return -1; 408 return -1;
381 } 409 }
382 } else if (dst_pix_fmt == PIX_FMT_YUV420P) { 410 } else if (dst_pix_fmt == PIX_FMT_YUV420P) {
383 411
384 switch(pix_fmt) { 412 switch(pix_fmt) {
413 case PIX_FMT_YUV410P:
414 img_copy(dst->data[0], dst->linesize[0],
415 src->data[0], src->linesize[0],
416 width, height);
417 grow22(dst->data[1], dst->linesize[1],
418 src->data[1], src->linesize[1],
419 width/2, height/2);
420 grow22(dst->data[2], dst->linesize[2],
421 src->data[2], src->linesize[2],
422 width/2, height/2);
423 break;
385 case PIX_FMT_YUV420P: 424 case PIX_FMT_YUV420P:
386 for(i=0;i<3;i++) { 425 for(i=0;i<3;i++) {
387 img_copy(dst->data[i], dst->linesize[i], 426 img_copy(dst->data[i], dst->linesize[i],
388 src->data[i], src->linesize[i], 427 src->data[i], src->linesize[i],
389 width, height); 428 width, height);