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
159159 AVFrame *const p = data;
160160 uint8_t *ptr[AV_NUM_DATA_POINTERS];
161161 uint32_t header_version, version = 0;
162− char creator[101];
163− char input_device[33];
162+ char creator[101] = { 0 };
163+ char input_device[33] = { 0 };
164164
165165 unsigned int offset;
166166 int magic_num, endian;
@@ -327,6 +327,10 @@ static int decode_frame(AVCodecContext *avctx, · 160 unmodified lines
327327 }
328328
329329 switch (descriptor) {
330+ case 1: // R
331+ case 2: // G
332+ case 3: // B
333+ case 4: // A
330334 case 6: // Y
331335 elements = 1;
332336 yuv = 1;
@@ -385,8 +389,10 @@ static int decode_frame(AVCodecContext *avctx, · 52 unmodified lines
385389 case 16:
386390 stride = 2 * avctx->width * elements;
387391 break;
388− case 1:
389392 case 32:
393+ stride = 4 * avctx->width * elements;
394+ break;
395+ case 1:
390396 case 64:
391397 avpriv_report_missing_feature(avctx, "Depth %d", bits_per_color);
392398 return AVERROR_PATCHWELCOME;
@@ -499,6 +505,20 @@ static int decode_frame(AVCodecContext *avctx, · 106 unmodified lines
499505 case 6120:
500506 avctx->pix_fmt = AV_PIX_FMT_GRAY12;
501507 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;
502522 case 50081:
503523 case 50080:
504524 avctx->pix_fmt = AV_PIX_FMT_RGB24;
@@ -549,6 +569,18 @@ static int decode_frame(AVCodecContext *avctx, · 44 unmodified lines
549569 case 51160:
550570 avctx->pix_fmt = AV_PIX_FMT_RGBA64LE;
551571 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;
552584 case 100081:
553585 avctx->pix_fmt = AV_PIX_FMT_UYVY422;
554586 break;
@@ -559,7 +591,8 @@ static int decode_frame(AVCodecContext *avctx, · 4 unmodified lines
559591 avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
560592 break;
561593 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);
563596 return AVERROR_PATCHWELCOME;
564597 }
565598
@@ -657,6 +690,36 @@ static int decode_frame(AVCodecContext *avctx, · 91 unmodified lines
657690 buf += need_align;
658691 }
659692 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;
660723 case 16:
661724 elements *= 2;
662725 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