Skip to content

Commit

Permalink
a fix for colorspace=2020 in avformat consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Jan 19, 2025
1 parent 32abe16 commit b5890a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/framework/mlt_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* \brief video output definition
* \see mlt_profile_s
*
* Copyright (C) 2007-2018 Meltytech, LLC
* Copyright (C) 2007-2025 Meltytech, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -43,7 +43,7 @@ struct mlt_profile_s
int sample_aspect_den; /**< the denominator of the pixel aspect ratio */
int display_aspect_num; /**< the numerator of the image aspect ratio in case it can not be simply derived (e.g. ITU-R 601) */
int display_aspect_den; /**< the denominator of the image aspect ratio in case it can not be simply derived (e.g. ITU-R 601) */
int colorspace; /**< the Y'CbCr colorspace standard: =601 for ITU-R 601, =709 for ITU-R 709, or =240 for SMPTE240M */
int colorspace; /**< the Y'CbCr colorspace standard: `601` for ITU-R 601, `709` for ITU-R 709, `240` for SMPTE240M, `2020` for ITU-R BT.2020 non-constant luminance, `2021` for ITU-R BT.2020 constant luminance */
int is_explicit; /**< used internally to indicate if the profile was requested explicitly or computed or defaulted */
};

Expand Down
14 changes: 10 additions & 4 deletions src/modules/avformat/consumer_avformat.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* consumer_avformat.c -- an encoder based on avformat
* Copyright (C) 2003-2024 Meltytech, LLC
* Copyright (C) 2003-2025 Meltytech, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -330,7 +330,7 @@ static void recompute_aspect_ratio(mlt_properties properties)

static void color_trc_from_colorspace(mlt_properties properties)
{
// Default color transfer characteristic from colorspace.
// Default color transfer characteristic from MLT colorspace.
switch (mlt_properties_get_int(properties, "colorspace")) {
case 709:
mlt_properties_set_int(properties, "color_trc", AVCOL_TRC_BT709);
Expand Down Expand Up @@ -358,7 +358,7 @@ static void color_trc_from_colorspace(mlt_properties properties)

static void color_primaries_from_colorspace(mlt_properties properties)
{
// Default color transfer characteristic from colorspace.
// Default color_primaries from MLT colorspace.
switch (mlt_properties_get_int(properties, "colorspace")) {
case 0: // sRGB
case 709:
Expand Down Expand Up @@ -390,7 +390,7 @@ static void color_primaries_from_colorspace(mlt_properties properties)

static void av_colorspace_from_colorspace(mlt_properties properties, int colorspace)
{
// Default color_space from colorspace.
// Convert MLT colorspace to FFmpeg colorspace.
switch (colorspace) {
case 0: // sRGB
mlt_properties_set_int(properties, "colorspace", AVCOL_SPC_RGB);
Expand Down Expand Up @@ -1015,6 +1015,12 @@ static AVStream *add_video_stream(mlt_consumer consumer,
case 709:
c->colorspace = AVCOL_SPC_BT709;
break;
case 2020:
c->colorspace = AVCOL_SPC_BT2020_NCL;
break;
case 2021:
c->colorspace = AVCOL_SPC_BT2020_CL;
break;
}

if (mlt_properties_get(properties, "aspect")) {
Expand Down

0 comments on commit b5890a1

Please sign in to comment.