aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale/utils.c
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-11-28 13:43:48 +0100
committerNiklas Haas <git@haasn.dev>2024-12-23 12:33:43 +0100
commita8d01dff9a24520f80b1d4243a9787925d57539f (patch)
tree76b8cf066435c4f28a37709a620a0f1a7df54cbc /libswscale/utils.c
parentb9dfe8138eb2df49c85a085b73c20d652ecf579a (diff)
downloadffmpeg-a8d01dff9a24520f80b1d4243a9787925d57539f.tar.gz
swscale/utils: add HDR metadata to SwsFormat
Only add the condensed values that we actually care about. Group them into a new struct to make it easier to discard or replace this metadata. Define a special comparison function that does not choke on undefined/unknown metadata.
Diffstat (limited to 'libswscale/utils.c')
-rw-r--r--libswscale/utils.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c
index dc0f30aa3a..f8ad093631 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -2659,11 +2659,13 @@ SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field)
.height = frame->height,
.format = frame->format,
.range = frame->color_range,
- .prim = frame->color_primaries,
- .trc = frame->color_trc,
.csp = frame->colorspace,
.loc = frame->chroma_location,
.desc = desc,
+ .color = {
+ .prim = frame->color_primaries,
+ .trc = frame->color_trc,
+ },
};
av_assert1(fmt.width > 0);
@@ -2676,12 +2678,14 @@ SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field)
fmt.range = AVCOL_RANGE_JPEG;
} else if (desc->flags & AV_PIX_FMT_FLAG_XYZ) {
fmt.csp = AVCOL_SPC_UNSPECIFIED;
- fmt.prim = AVCOL_PRI_SMPTE428;
- fmt.trc = AVCOL_TRC_SMPTE428;
+ fmt.color = (SwsColor) {
+ .prim = AVCOL_PRI_SMPTE428,
+ .trc = AVCOL_TRC_SMPTE428,
+ };
} else if (desc->nb_components < 3) {
/* Grayscale formats */
- fmt.prim = AVCOL_PRI_UNSPECIFIED;
- fmt.csp = AVCOL_SPC_UNSPECIFIED;
+ fmt.color.prim = AVCOL_PRI_UNSPECIFIED;
+ fmt.csp = AVCOL_SPC_UNSPECIFIED;
if (desc->flags & AV_PIX_FMT_FLAG_FLOAT)
fmt.range = AVCOL_RANGE_UNSPECIFIED;
else
@@ -2756,12 +2760,12 @@ static int test_loc(enum AVChromaLocation loc)
int ff_test_fmt(const SwsFormat *fmt, int output)
{
- return fmt->width > 0 && fmt->height > 0 &&
- sws_test_format (fmt->format, output) &&
- sws_test_colorspace(fmt->csp, output) &&
- sws_test_primaries (fmt->prim, output) &&
- sws_test_transfer (fmt->trc, output) &&
- test_range (fmt->range) &&
+ return fmt->width > 0 && fmt->height > 0 &&
+ sws_test_format (fmt->format, output) &&
+ sws_test_colorspace(fmt->csp, output) &&
+ sws_test_primaries (fmt->color.prim, output) &&
+ sws_test_transfer (fmt->color.trc, output) &&
+ test_range (fmt->range) &&
test_loc (fmt->loc);
}