mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-03-13 09:00:40 +08:00
libavcodec/dpxenc: map AVCodecContext color transfer and color primaries fields
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "codec_internal.h"
|
||||
#include "encode.h"
|
||||
#include "version.h"
|
||||
#include "dpx.h"
|
||||
|
||||
typedef struct DPXContext {
|
||||
int big_endian;
|
||||
@@ -178,6 +179,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
DPXContext *s = avctx->priv_data;
|
||||
int size, ret, need_align, len;
|
||||
uint8_t *buf;
|
||||
int color_trc, color_spec;
|
||||
|
||||
#define HEADER_SIZE 1664 /* DPX Generic header */
|
||||
if (s->bits_per_component == 10)
|
||||
@@ -217,8 +219,46 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
write32(buf + 772, avctx->width);
|
||||
write32(buf + 776, avctx->height);
|
||||
buf[800] = s->descriptor;
|
||||
buf[801] = 2; /* linear transfer */
|
||||
buf[802] = 2; /* linear colorimetric */
|
||||
|
||||
switch (avctx->color_trc) {
|
||||
case AVCOL_TRC_BT709:
|
||||
color_trc = DPX_TRC_ITU_R_709_4;
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_WARNING, "unsupported color transfer\n");
|
||||
case AVCOL_TRC_UNSPECIFIED:
|
||||
color_trc = DPX_TRC_UNSPECIFIED_VIDEO;
|
||||
break;
|
||||
case AVCOL_TRC_GAMMA28:
|
||||
color_trc = DPX_TRC_ITU_R_624_4_PAL;
|
||||
break;
|
||||
case AVCOL_TRC_SMPTE170M:
|
||||
color_trc = DPX_TRC_SMPTE_170;
|
||||
break;
|
||||
case AVCOL_TRC_LINEAR:
|
||||
color_trc = DPX_TRC_LINEAR;
|
||||
break;
|
||||
}
|
||||
buf[801] = color_trc;
|
||||
|
||||
switch (avctx->color_primaries) {
|
||||
case AVCOL_PRI_BT709:
|
||||
color_spec = DPX_COL_SPEC_ITU_R_709_4;
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_WARNING, "unsupported colorimetric specification\n");
|
||||
case AVCOL_PRI_UNSPECIFIED:
|
||||
color_spec = DPX_COL_SPEC_UNSPECIFIED_VIDEO;
|
||||
break;
|
||||
case AVCOL_PRI_BT470BG:
|
||||
color_spec = DPX_COL_SPEC_ITU_R_624_4_PAL;
|
||||
break;
|
||||
case AVCOL_PRI_SMPTE170M:
|
||||
color_spec = DPX_COL_SPEC_SMPTE_170;
|
||||
break;
|
||||
}
|
||||
buf[802] = color_spec;
|
||||
|
||||
buf[803] = s->bits_per_component;
|
||||
write16(buf + 804, (s->bits_per_component == 10 || s->bits_per_component == 12) ?
|
||||
1 : 0); /* packing method */
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
4c8880d5835ffb5fe37c1ed8c8d404de *tests/data/images/dpx/02.dpx
|
||||
1ac8708e2d140b63915f0abfbdeb953f *tests/data/images/dpx/02.dpx
|
||||
305792 tests/data/images/dpx/02.dpx
|
||||
tests/data/images/dpx/%02d.dpx CRC=0x6da01946
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
7ca935d5d5e00c54acbc85565d3039b6 *tests/data/images/gbrp10le.dpx/02.gbrp10le.dpx
|
||||
79aa69bb78c4422a883a7d2323f6b066 *tests/data/images/gbrp10le.dpx/02.gbrp10le.dpx
|
||||
407168 tests/data/images/gbrp10le.dpx/02.gbrp10le.dpx
|
||||
tests/data/images/gbrp10le.dpx/%02d.gbrp10le.dpx CRC=0xe6663fba
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
a4cfea1797c928f2eff73573e559675d *tests/data/images/gbrp12le.dpx/02.gbrp12le.dpx
|
||||
6969191e30f9f8b0d895784dc4d07f96 *tests/data/images/gbrp12le.dpx/02.gbrp12le.dpx
|
||||
609920 tests/data/images/gbrp12le.dpx/02.gbrp12le.dpx
|
||||
tests/data/images/gbrp12le.dpx/%02d.gbrp12le.dpx CRC=0x1c755633
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
075963c3c08978b6a20555ba09161434 *tests/data/images/rgb48le.dpx/02.rgb48le.dpx
|
||||
35376cc1ff5f1b934cdfc1bf0776cf48 *tests/data/images/rgb48le.dpx/02.rgb48le.dpx
|
||||
609920 tests/data/images/rgb48le.dpx/02.rgb48le.dpx
|
||||
tests/data/images/rgb48le.dpx/%02d.rgb48le.dpx CRC=0xe5b9c023
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
b9f22728f8ff393bf30cf6cbd624fa95 *tests/data/images/rgb48le_10.dpx/02.rgb48le_10.dpx
|
||||
46533558d2f7ff875756dcd9227b9907 *tests/data/images/rgb48le_10.dpx/02.rgb48le_10.dpx
|
||||
407168 tests/data/images/rgb48le_10.dpx/02.rgb48le_10.dpx
|
||||
tests/data/images/rgb48le_10.dpx/%02d.rgb48le_10.dpx CRC=0xf38d5830
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
545603630f30dec2768c8ae8d12eb8ea *tests/data/images/rgba64le.dpx/02.rgba64le.dpx
|
||||
89f545002e21044b01378aeccc437dcd *tests/data/images/rgba64le.dpx/02.rgba64le.dpx
|
||||
812672 tests/data/images/rgba64le.dpx/02.rgba64le.dpx
|
||||
tests/data/images/rgba64le.dpx/%02d.rgba64le.dpx CRC=0xe72ce131
|
||||
|
||||
Reference in New Issue
Block a user