From: Peter Ross via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: Peter Ross <code@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] dpxenc: map AVCodecContext color transfer and color primaries fields (PR #20365) Message-ID: <175645426431.25.964419051948033752@463a07221176> (raw) PR #20365 opened by Peter Ross (pross) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20365 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20365.patch Fixes issue #20341 >From cbac28e3292bc8240a8b3aca371ffc611b8cdcf7 Mon Sep 17 00:00:00 2001 From: Peter Ross <pross@xvid.org> Date: Fri, 29 Aug 2025 17:51:06 +1000 Subject: [PATCH 1/2] avcodec/dpx: move enum DPX_TRC and DPX_COL_SPEC to dpx.h --- libavcodec/dpx.c | 33 +--------------------------- libavcodec/dpx.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 32 deletions(-) create mode 100644 libavcodec/dpx.h diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 80616d98a2..1b1ada316a 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -27,38 +27,7 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" - -enum DPX_TRC { - DPX_TRC_USER_DEFINED = 0, - DPX_TRC_PRINTING_DENSITY = 1, - DPX_TRC_LINEAR = 2, - DPX_TRC_LOGARITHMIC = 3, - DPX_TRC_UNSPECIFIED_VIDEO = 4, - DPX_TRC_SMPTE_274 = 5, - DPX_TRC_ITU_R_709_4 = 6, - DPX_TRC_ITU_R_601_625 = 7, - DPX_TRC_ITU_R_601_525 = 8, - DPX_TRC_SMPTE_170 = 9, - DPX_TRC_ITU_R_624_4_PAL = 10, - DPX_TRC_Z_LINEAR = 11, - DPX_TRC_Z_HOMOGENEOUS = 12, -}; - -enum DPX_COL_SPEC { - DPX_COL_SPEC_USER_DEFINED = 0, - DPX_COL_SPEC_PRINTING_DENSITY = 1, - /* 2 = N/A */ - /* 3 = N/A */ - DPX_COL_SPEC_UNSPECIFIED_VIDEO = 4, - DPX_COL_SPEC_SMPTE_274 = 5, - DPX_COL_SPEC_ITU_R_709_4 = 6, - DPX_COL_SPEC_ITU_R_601_625 = 7, - DPX_COL_SPEC_ITU_R_601_525 = 8, - DPX_COL_SPEC_SMPTE_170 = 9, - DPX_COL_SPEC_ITU_R_624_4_PAL = 10, - /* 11 = N/A */ - /* 12 = N/A */ -}; +#include "dpx.h" static unsigned int read16(const uint8_t **ptr, int is_big) { diff --git a/libavcodec/dpx.h b/libavcodec/dpx.h new file mode 100644 index 0000000000..800c651e5a --- /dev/null +++ b/libavcodec/dpx.h @@ -0,0 +1,57 @@ +/* + * DPX (.dpx) image decoder + * Copyright (c) 2009 Jimmy Christensen + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_DPX_H +#define AVCODEC_DPX_H + +enum DPX_TRC { + DPX_TRC_USER_DEFINED = 0, + DPX_TRC_PRINTING_DENSITY = 1, + DPX_TRC_LINEAR = 2, + DPX_TRC_LOGARITHMIC = 3, + DPX_TRC_UNSPECIFIED_VIDEO = 4, + DPX_TRC_SMPTE_274 = 5, + DPX_TRC_ITU_R_709_4 = 6, + DPX_TRC_ITU_R_601_625 = 7, + DPX_TRC_ITU_R_601_525 = 8, + DPX_TRC_SMPTE_170 = 9, + DPX_TRC_ITU_R_624_4_PAL = 10, + DPX_TRC_Z_LINEAR = 11, + DPX_TRC_Z_HOMOGENEOUS = 12, +}; + +enum DPX_COL_SPEC { + DPX_COL_SPEC_USER_DEFINED = 0, + DPX_COL_SPEC_PRINTING_DENSITY = 1, + /* 2 = N/A */ + /* 3 = N/A */ + DPX_COL_SPEC_UNSPECIFIED_VIDEO = 4, + DPX_COL_SPEC_SMPTE_274 = 5, + DPX_COL_SPEC_ITU_R_709_4 = 6, + DPX_COL_SPEC_ITU_R_601_625 = 7, + DPX_COL_SPEC_ITU_R_601_525 = 8, + DPX_COL_SPEC_SMPTE_170 = 9, + DPX_COL_SPEC_ITU_R_624_4_PAL = 10, + /* 11 = N/A */ + /* 12 = N/A */ +}; + +#endif /* AVCODEC_DPX_H */ -- 2.49.1 >From f10e4902c9c64119ca3f030c44ad3b97c6db1e70 Mon Sep 17 00:00:00 2001 From: Peter Ross <pross@xvid.org> Date: Fri, 29 Aug 2025 17:51:46 +1000 Subject: [PATCH 2/2] libavcodec/dpxenc: map AVCodecContext color transfer and color primaries fields --- libavcodec/dpxenc.c | 44 +++++++++++++++++++++++++++++++++-- tests/ref/lavf/dpx | 2 +- tests/ref/lavf/gbrp10le.dpx | 2 +- tests/ref/lavf/gbrp12le.dpx | 2 +- tests/ref/lavf/rgb48le.dpx | 2 +- tests/ref/lavf/rgb48le_10.dpx | 2 +- tests/ref/lavf/rgba64le.dpx | 2 +- 7 files changed, 48 insertions(+), 8 deletions(-) diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c index 400ff98395..e136c7a249 100644 --- a/libavcodec/dpxenc.c +++ b/libavcodec/dpxenc.c @@ -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 */ diff --git a/tests/ref/lavf/dpx b/tests/ref/lavf/dpx index 736fe39cff..9ac74196d0 100644 --- a/tests/ref/lavf/dpx +++ b/tests/ref/lavf/dpx @@ -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 diff --git a/tests/ref/lavf/gbrp10le.dpx b/tests/ref/lavf/gbrp10le.dpx index 35e34d0859..54c01ea2fa 100644 --- a/tests/ref/lavf/gbrp10le.dpx +++ b/tests/ref/lavf/gbrp10le.dpx @@ -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 diff --git a/tests/ref/lavf/gbrp12le.dpx b/tests/ref/lavf/gbrp12le.dpx index 2758982d5a..ed15abe056 100644 --- a/tests/ref/lavf/gbrp12le.dpx +++ b/tests/ref/lavf/gbrp12le.dpx @@ -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 diff --git a/tests/ref/lavf/rgb48le.dpx b/tests/ref/lavf/rgb48le.dpx index b808ff4bdc..7d818d9d0f 100644 --- a/tests/ref/lavf/rgb48le.dpx +++ b/tests/ref/lavf/rgb48le.dpx @@ -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 diff --git a/tests/ref/lavf/rgb48le_10.dpx b/tests/ref/lavf/rgb48le_10.dpx index a49d929f7f..2a5d82dff5 100644 --- a/tests/ref/lavf/rgb48le_10.dpx +++ b/tests/ref/lavf/rgb48le_10.dpx @@ -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 diff --git a/tests/ref/lavf/rgba64le.dpx b/tests/ref/lavf/rgba64le.dpx index 5ccde8975b..66ea06d33b 100644 --- a/tests/ref/lavf/rgba64le.dpx +++ b/tests/ref/lavf/rgba64le.dpx @@ -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 -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-08-29 7:59 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=175645426431.25.964419051948033752@463a07221176 \ --to=ffmpeg-devel@ffmpeg.org \ --cc=code@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git