Mercurial > libavcodec.hg
comparison imgconvert.c @ 3646:e324e5ce41a1 libavcodec
Minimal support for the new pixel formats in libavcodec
author | lucabe |
---|---|
date | Mon, 28 Aug 2006 14:56:47 +0000 |
parents | 19c437d6aba5 |
children | c8c591fe26f8 |
comparison
equal
deleted
inserted
replaced
3645:47821be55b6c | 3646:e324e5ce41a1 |
---|---|
232 .nb_channels = 1, | 232 .nb_channels = 1, |
233 .color_type = FF_COLOR_YUV, | 233 .color_type = FF_COLOR_YUV, |
234 .pixel_type = FF_PIXEL_PACKED, | 234 .pixel_type = FF_PIXEL_PACKED, |
235 .depth = 8, | 235 .depth = 8, |
236 .x_chroma_shift = 2, .y_chroma_shift = 0, | 236 .x_chroma_shift = 2, .y_chroma_shift = 0, |
237 }, | |
238 [PIX_FMT_BGR32] = { | |
239 .name = "bgr32", | |
240 .nb_channels = 4, .is_alpha = 1, | |
241 .color_type = FF_COLOR_RGB, | |
242 .pixel_type = FF_PIXEL_PACKED, | |
243 .depth = 8, | |
244 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
245 }, | |
246 [PIX_FMT_BGR565] = { | |
247 .name = "bgr565", | |
248 .nb_channels = 3, | |
249 .color_type = FF_COLOR_RGB, | |
250 .pixel_type = FF_PIXEL_PACKED, | |
251 .depth = 5, | |
252 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
253 }, | |
254 [PIX_FMT_BGR555] = { | |
255 .name = "bgr555", | |
256 .nb_channels = 4, .is_alpha = 1, | |
257 .color_type = FF_COLOR_RGB, | |
258 .pixel_type = FF_PIXEL_PACKED, | |
259 .depth = 5, | |
260 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
261 }, | |
262 [PIX_FMT_RGB8] = { | |
263 .name = "rgb8", | |
264 .nb_channels = 1, | |
265 .color_type = FF_COLOR_RGB, | |
266 .pixel_type = FF_PIXEL_PACKED, | |
267 .depth = 8, | |
268 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
269 }, | |
270 [PIX_FMT_RGB4] = { | |
271 .name = "rgb4", | |
272 .nb_channels = 1, | |
273 .color_type = FF_COLOR_RGB, | |
274 .pixel_type = FF_PIXEL_PACKED, | |
275 .depth = 4, | |
276 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
277 }, | |
278 [PIX_FMT_RGB4_BYTE] = { | |
279 .name = "rgb4_byte", | |
280 .nb_channels = 1, | |
281 .color_type = FF_COLOR_RGB, | |
282 .pixel_type = FF_PIXEL_PACKED, | |
283 .depth = 8, | |
284 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
285 }, | |
286 [PIX_FMT_BGR8] = { | |
287 .name = "bgr8", | |
288 .nb_channels = 1, | |
289 .color_type = FF_COLOR_RGB, | |
290 .pixel_type = FF_PIXEL_PACKED, | |
291 .depth = 8, | |
292 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
293 }, | |
294 [PIX_FMT_BGR4] = { | |
295 .name = "bgr4", | |
296 .nb_channels = 1, | |
297 .color_type = FF_COLOR_RGB, | |
298 .pixel_type = FF_PIXEL_PACKED, | |
299 .depth = 4, | |
300 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
301 }, | |
302 [PIX_FMT_BGR4_BYTE] = { | |
303 .name = "bgr4_byte", | |
304 .nb_channels = 1, | |
305 .color_type = FF_COLOR_RGB, | |
306 .pixel_type = FF_PIXEL_PACKED, | |
307 .depth = 8, | |
308 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
309 }, | |
310 [PIX_FMT_NV12] = { | |
311 .name = "nv12", | |
312 .nb_channels = 2, | |
313 .color_type = FF_COLOR_YUV, | |
314 .pixel_type = FF_PIXEL_PLANAR, | |
315 .depth = 8, | |
316 .x_chroma_shift = 1, .y_chroma_shift = 1, | |
317 }, | |
318 [PIX_FMT_NV21] = { | |
319 .name = "nv12", | |
320 .nb_channels = 2, | |
321 .color_type = FF_COLOR_YUV, | |
322 .pixel_type = FF_PIXEL_PLANAR, | |
323 .depth = 8, | |
324 .x_chroma_shift = 1, .y_chroma_shift = 1, | |
325 }, | |
326 | |
327 [PIX_FMT_BGR32_1] = { | |
328 .name = "bgr32_1", | |
329 .nb_channels = 4, .is_alpha = 1, | |
330 .color_type = FF_COLOR_RGB, | |
331 .pixel_type = FF_PIXEL_PACKED, | |
332 .depth = 8, | |
333 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
334 }, | |
335 [PIX_FMT_RGB32_1] = { | |
336 .name = "rgb32_1", | |
337 .nb_channels = 4, .is_alpha = 1, | |
338 .color_type = FF_COLOR_RGB, | |
339 .pixel_type = FF_PIXEL_PACKED, | |
340 .depth = 8, | |
341 .x_chroma_shift = 0, .y_chroma_shift = 0, | |
237 }, | 342 }, |
238 }; | 343 }; |
239 | 344 |
240 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift) | 345 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift) |
241 { | 346 { |
290 picture->data[2] = picture->data[1] + size2; | 395 picture->data[2] = picture->data[1] + size2; |
291 picture->linesize[0] = width; | 396 picture->linesize[0] = width; |
292 picture->linesize[1] = w2; | 397 picture->linesize[1] = w2; |
293 picture->linesize[2] = w2; | 398 picture->linesize[2] = w2; |
294 return size + 2 * size2; | 399 return size + 2 * size2; |
400 case PIX_FMT_NV12: | |
401 case PIX_FMT_NV21: | |
402 w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift; | |
403 h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift; | |
404 size2 = w2 * h2 * 2; | |
405 picture->data[0] = ptr; | |
406 picture->data[1] = picture->data[0] + size; | |
407 picture->data[2] = NULL; | |
408 picture->linesize[0] = width; | |
409 picture->linesize[1] = w2; | |
410 picture->linesize[2] = 0; | |
411 return size + 2 * size2; | |
295 case PIX_FMT_RGB24: | 412 case PIX_FMT_RGB24: |
296 case PIX_FMT_BGR24: | 413 case PIX_FMT_BGR24: |
297 picture->data[0] = ptr; | 414 picture->data[0] = ptr; |
298 picture->data[1] = NULL; | 415 picture->data[1] = NULL; |
299 picture->data[2] = NULL; | 416 picture->data[2] = NULL; |
300 picture->linesize[0] = width * 3; | 417 picture->linesize[0] = width * 3; |
301 return size * 3; | 418 return size * 3; |
302 case PIX_FMT_RGBA32: | 419 case PIX_FMT_RGBA32: |
420 case PIX_FMT_BGR32: | |
421 case PIX_FMT_RGB32_1: | |
422 case PIX_FMT_BGR32_1: | |
303 picture->data[0] = ptr; | 423 picture->data[0] = ptr; |
304 picture->data[1] = NULL; | 424 picture->data[1] = NULL; |
305 picture->data[2] = NULL; | 425 picture->data[2] = NULL; |
306 picture->linesize[0] = width * 4; | 426 picture->linesize[0] = width * 4; |
307 return size * 4; | 427 return size * 4; |
428 case PIX_FMT_BGR555: | |
429 case PIX_FMT_BGR565: | |
308 case PIX_FMT_RGB555: | 430 case PIX_FMT_RGB555: |
309 case PIX_FMT_RGB565: | 431 case PIX_FMT_RGB565: |
310 case PIX_FMT_YUV422: | 432 case PIX_FMT_YUV422: |
311 picture->data[0] = ptr; | 433 picture->data[0] = ptr; |
312 picture->data[1] = NULL; | 434 picture->data[1] = NULL; |
323 picture->data[0] = ptr; | 445 picture->data[0] = ptr; |
324 picture->data[1] = NULL; | 446 picture->data[1] = NULL; |
325 picture->data[2] = NULL; | 447 picture->data[2] = NULL; |
326 picture->linesize[0] = width + width/2; | 448 picture->linesize[0] = width + width/2; |
327 return size + size/2; | 449 return size + size/2; |
450 case PIX_FMT_RGB8: | |
451 case PIX_FMT_BGR8: | |
452 case PIX_FMT_RGB4_BYTE: | |
453 case PIX_FMT_BGR4_BYTE: | |
328 case PIX_FMT_GRAY8: | 454 case PIX_FMT_GRAY8: |
329 picture->data[0] = ptr; | 455 picture->data[0] = ptr; |
330 picture->data[1] = NULL; | 456 picture->data[1] = NULL; |
331 picture->data[2] = NULL; | 457 picture->data[2] = NULL; |
332 picture->linesize[0] = width; | 458 picture->linesize[0] = width; |
333 return size; | 459 return size; |
460 case PIX_FMT_RGB4: | |
461 case PIX_FMT_BGR4: | |
462 picture->data[0] = ptr; | |
463 picture->data[1] = NULL; | |
464 picture->data[2] = NULL; | |
465 picture->linesize[0] = width / 2; | |
466 return size / 2; | |
334 case PIX_FMT_MONOWHITE: | 467 case PIX_FMT_MONOWHITE: |
335 case PIX_FMT_MONOBLACK: | 468 case PIX_FMT_MONOBLACK: |
336 picture->data[0] = ptr; | 469 picture->data[0] = ptr; |
337 picture->data[1] = NULL; | 470 picture->data[1] = NULL; |
338 picture->data[2] = NULL; | 471 picture->data[2] = NULL; |
368 return -1; | 501 return -1; |
369 | 502 |
370 if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) { | 503 if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) { |
371 if (pix_fmt == PIX_FMT_YUV422 || | 504 if (pix_fmt == PIX_FMT_YUV422 || |
372 pix_fmt == PIX_FMT_UYVY422 || | 505 pix_fmt == PIX_FMT_UYVY422 || |
506 pix_fmt == PIX_FMT_BGR565 || | |
507 pix_fmt == PIX_FMT_BGR565 || | |
373 pix_fmt == PIX_FMT_RGB565 || | 508 pix_fmt == PIX_FMT_RGB565 || |
374 pix_fmt == PIX_FMT_RGB555) | 509 pix_fmt == PIX_FMT_RGB555) |
375 w = width * 2; | 510 w = width * 2; |
376 else if (pix_fmt == PIX_FMT_UYVY411) | 511 else if (pix_fmt == PIX_FMT_UYVY411) |
377 w = width + width/2; | 512 w = width + width/2; |
482 switch(pix_fmt) { | 617 switch(pix_fmt) { |
483 case PIX_FMT_YUV422: | 618 case PIX_FMT_YUV422: |
484 case PIX_FMT_UYVY422: | 619 case PIX_FMT_UYVY422: |
485 case PIX_FMT_RGB565: | 620 case PIX_FMT_RGB565: |
486 case PIX_FMT_RGB555: | 621 case PIX_FMT_RGB555: |
622 case PIX_FMT_BGR565: | |
623 case PIX_FMT_BGR555: | |
487 bits = 16; | 624 bits = 16; |
488 break; | 625 break; |
489 case PIX_FMT_UYVY411: | 626 case PIX_FMT_UYVY411: |
490 bits = 12; | 627 bits = 12; |
491 break; | 628 break; |
600 switch(pix_fmt) { | 737 switch(pix_fmt) { |
601 case PIX_FMT_YUV422: | 738 case PIX_FMT_YUV422: |
602 case PIX_FMT_UYVY422: | 739 case PIX_FMT_UYVY422: |
603 case PIX_FMT_RGB565: | 740 case PIX_FMT_RGB565: |
604 case PIX_FMT_RGB555: | 741 case PIX_FMT_RGB555: |
742 case PIX_FMT_BGR565: | |
743 case PIX_FMT_BGR555: | |
605 bits = 16; | 744 bits = 16; |
606 break; | 745 break; |
607 case PIX_FMT_UYVY411: | 746 case PIX_FMT_UYVY411: |
608 bits = 12; | 747 bits = 12; |
609 break; | 748 break; |