History

avcodec/dpx: add float support for single components and rgb(a)

Paul B Mahol committed 5 years ago

Commit 68fa2941 parent 48a0eb21 file · +67 −4Browse files

Unified · Split

libavcodec/dpx.c+67−4
@@ -159,8 +159,8 @@ static int decode_frame(AVCodecContext *avctx, · 158 unmodified lines
159 AVFrame *const p = data;159 AVFrame *const p = data;
160 uint8_t *ptr[AV_NUM_DATA_POINTERS];160 uint8_t *ptr[AV_NUM_DATA_POINTERS];
161 uint32_t header_version, version = 0;161 uint32_t header_version, version = 0;
162 char creator[101];162 char creator[101] = { 0 };
163 char input_device[33];163 char input_device[33] = { 0 };
164 164
165 unsigned int offset;165 unsigned int offset;
166 int magic_num, endian;166 int magic_num, endian;
@@ -327,6 +327,10 @@ static int decode_frame(AVCodecContext *avctx, · 160 unmodified lines
327 }327 }
328 328
329 switch (descriptor) {329 switch (descriptor) {
330 case 1: // R
331 case 2: // G
332 case 3: // B
333 case 4: // A
330 case 6: // Y334 case 6: // Y
331 elements = 1;335 elements = 1;
332 yuv = 1;336 yuv = 1;
@@ -385,8 +389,10 @@ static int decode_frame(AVCodecContext *avctx, · 52 unmodified lines
385 case 16:389 case 16:
386 stride = 2 * avctx->width * elements;390 stride = 2 * avctx->width * elements;
387 break;391 break;
388 case 1:
389 case 32:392 case 32:
393 stride = 4 * avctx->width * elements;
394 break;
395 case 1:
390 case 64:396 case 64:
391 avpriv_report_missing_feature(avctx, "Depth %d", bits_per_color);397 avpriv_report_missing_feature(avctx, "Depth %d", bits_per_color);
392 return AVERROR_PATCHWELCOME;398 return AVERROR_PATCHWELCOME;
@@ -499,6 +505,20 @@ static int decode_frame(AVCodecContext *avctx, · 106 unmodified lines
499 case 6120:505 case 6120:
500 avctx->pix_fmt = AV_PIX_FMT_GRAY12;506 avctx->pix_fmt = AV_PIX_FMT_GRAY12;
501 break;507 break;
508 case 1320:
509 case 2320:
510 case 3320:
511 case 4320:
512 case 6320:
513 avctx->pix_fmt = AV_PIX_FMT_GRAYF32LE;
514 break;
515 case 1321:
516 case 2321:
517 case 3321:
518 case 4321:
519 case 6321:
520 avctx->pix_fmt = AV_PIX_FMT_GRAYF32BE;
521 break;
502 case 50081:522 case 50081:
503 case 50080:523 case 50080:
504 avctx->pix_fmt = AV_PIX_FMT_RGB24;524 avctx->pix_fmt = AV_PIX_FMT_RGB24;
@@ -549,6 +569,18 @@ static int decode_frame(AVCodecContext *avctx, · 44 unmodified lines
549 case 51160:569 case 51160:
550 avctx->pix_fmt = AV_PIX_FMT_RGBA64LE;570 avctx->pix_fmt = AV_PIX_FMT_RGBA64LE;
551 break;571 break;
572 case 50320:
573 avctx->pix_fmt = AV_PIX_FMT_GBRPF32LE;
574 break;
575 case 50321:
576 avctx->pix_fmt = AV_PIX_FMT_GBRPF32BE;
577 break;
578 case 51320:
579 avctx->pix_fmt = AV_PIX_FMT_GBRAPF32LE;
580 break;
581 case 51321:
582 avctx->pix_fmt = AV_PIX_FMT_GBRAPF32BE;
583 break;
552 case 100081:584 case 100081:
553 avctx->pix_fmt = AV_PIX_FMT_UYVY422;585 avctx->pix_fmt = AV_PIX_FMT_UYVY422;
554 break;586 break;
@@ -559,7 +591,8 @@ static int decode_frame(AVCodecContext *avctx, · 4 unmodified lines
559 avctx->pix_fmt = AV_PIX_FMT_YUVA444P;591 avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
560 break;592 break;
561 default:593 default:
562 av_log(avctx, AV_LOG_ERROR, "Unsupported format\n");594 av_log(avctx, AV_LOG_ERROR, "Unsupported format %d\n",
595 1000 * descriptor + 10 * bits_per_color + endian);
563 return AVERROR_PATCHWELCOME;596 return AVERROR_PATCHWELCOME;
564 }597 }
565 598
@@ -657,6 +690,36 @@ static int decode_frame(AVCodecContext *avctx, · 91 unmodified lines
657 buf += need_align;690 buf += need_align;
658 }691 }
659 break;692 break;
693 case 32:
694 if (elements == 1) {
695 av_image_copy_plane(ptr[0], p->linesize[0],
696 buf, stride,
697 elements * avctx->width * 4, avctx->height);
698 } else {
699 for (y = 0; y < avctx->height; y++) {
700 ptr[0] = p->data[0] + y * p->linesize[0];
701 ptr[1] = p->data[1] + y * p->linesize[1];
702 ptr[2] = p->data[2] + y * p->linesize[2];
703 ptr[3] = p->data[3] + y * p->linesize[3];
704 for (x = 0; x < avctx->width; x++) {
705 AV_WN32(ptr[2], AV_RN32(buf));
706 AV_WN32(ptr[0], AV_RN32(buf + 4));
707 AV_WN32(ptr[1], AV_RN32(buf + 8));
708 if (avctx->pix_fmt == AV_PIX_FMT_GBRAPF32BE ||
709 avctx->pix_fmt == AV_PIX_FMT_GBRAPF32LE) {
710 AV_WN32(ptr[3], AV_RN32(buf + 12));
711 buf += 4;
712 ptr[3] += 4;
713 }
714
715 buf += 12;
716 ptr[2] += 4;
717 ptr[0] += 4;
718 ptr[1] += 4;
719 }
720 }
721 }
722 break;
660 case 16:723 case 16:
661 elements *= 2;724 elements *= 2;
662 case 8:725 case 8:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t