comparison imgconvert.c @ 1243:5d2376294fbf libavcodec

* fixing a bug in avpicture_layout (PAL8 wasn't handled properly) * adding regression tests for all pix_fmt conversions * making libavtest part of the default testsuite
author romansh
date Mon, 12 May 2003 02:53:43 +0000
parents b88dfc4bbf8c
children 8988af3ae1e8
comparison
equal deleted inserted replaced
1242:db903b6fd197 1243:5d2376294fbf
322 int size = avpicture_get_size(pix_fmt, width, height); 322 int size = avpicture_get_size(pix_fmt, width, height);
323 323
324 if (size > dest_size) 324 if (size > dest_size)
325 return -1; 325 return -1;
326 326
327 if (pf->pixel_type == FF_PIXEL_PACKED) { 327 if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {
328 if (pix_fmt == PIX_FMT_YUV422 || pix_fmt == PIX_FMT_RGB565 || 328 if (pix_fmt == PIX_FMT_YUV422 || pix_fmt == PIX_FMT_RGB565 ||
329 pix_fmt == PIX_FMT_RGB555) 329 pix_fmt == PIX_FMT_RGB555)
330 w = width * 2; 330 w = width * 2;
331 else if (pix_fmt == PIX_FMT_PAL8)
332 w = width;
331 else 333 else
332 w = width * (pf->depth * pf->nb_channels / 8); 334 w = width * (pf->depth * pf->nb_channels / 8);
335
333 data_planes = 1; 336 data_planes = 1;
334 h = height; 337 h = height;
335 } else { 338 } else {
336 data_planes = pf->nb_channels; 339 data_planes = pf->nb_channels;
337 w = width; 340 w = width;
348 memcpy(dest, s, w); 351 memcpy(dest, s, w);
349 dest += w; 352 dest += w;
350 s += src->linesize[i]; 353 s += src->linesize[i];
351 } 354 }
352 } 355 }
353 356
357 if (pf->pixel_type == FF_PIXEL_PALETTE)
358 memcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4);
359
354 return size; 360 return size;
355 } 361 }
356 362
357 int avpicture_get_size(int pix_fmt, int width, int height) 363 int avpicture_get_size(int pix_fmt, int width, int height)
358 { 364 {