summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/options.rst7
-rwxr-xr-xold-configure6
-rw-r--r--video/csputils.c33
-rw-r--r--video/csputils.h16
-rw-r--r--video/decode/vd_lavc.c1
-rw-r--r--video/image_writer.c8
-rw-r--r--video/image_writer.h1
-rw-r--r--video/mp_image.c11
-rw-r--r--video/mp_image.h1
-rw-r--r--video/out/gl_video.c17
-rw-r--r--wscript7
11 files changed, 21 insertions, 87 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 4c83b170e2..1018cf5f95 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2641,13 +2641,6 @@ Screenshot
:jpg: JPEG (default)
:jpeg: JPEG (same as jpg, but with .jpeg file ending)
-``--screenshot-tag-colorspace=<yes|no>``
- Tag screenshots with the appropriate colorspace.
-
- Note that not all formats are supported.
-
- Default: ``yes``.
-
``--screenshot-template=<template>``
Specify the filename template used to save screenshots. The template
specifies the filename without file extension, and can contain format
diff --git a/old-configure b/old-configure
index 6bdfc4413b..2558985b03 100755
--- a/old-configure
+++ b/old-configure
@@ -814,12 +814,6 @@ api_statement_check \
'av_frame_get_metadata(NULL)'
api_statement_check \
- "libavutil AVFrame colorspace information" \
- HAVE_AVFRAME_CSP \
- libavutil/frame.h \
- 'AVFrame frame; frame.color_primaries = frame.color_trc = 0;'
-
-api_statement_check \
"libavutil AVFrame skip samples metadata" \
HAVE_AVFRAME_SKIP_SAMPLES \
libavutil/frame.h \
diff --git a/video/csputils.c b/video/csputils.c
index cbd9734819..90eec39d36 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -65,13 +65,6 @@ const char *const mp_csp_prim_names[MP_CSP_PRIM_COUNT] = {
"BT.470 M",
};
-const char *const mp_csp_trc_names[MP_CSP_TRC_COUNT] = {
- "Autoselect",
- "BT.1886 (SD, HD, UHD)",
- "sRGB (IEC 61966-2-1)",
- "Linear light",
-};
-
const char *const mp_csp_equalizer_names[MP_CSP_EQ_COUNT] = {
"brightness",
"contrast",
@@ -149,21 +142,6 @@ enum mp_csp_prim avcol_pri_to_mp_csp_prim(int avpri)
}
}
-enum mp_csp_trc avcol_trc_to_mp_csp_trc(int avtrc)
-{
- switch (avtrc) {
- case AVCOL_TRC_BT709:
- case AVCOL_TRC_SMPTE170M:
- case AVCOL_TRC_SMPTE240M:
- case AVCOL_TRC_BT1361_ECG:
- case AVCOL_TRC_BT2020_10:
- case AVCOL_TRC_BT2020_12: return MP_CSP_TRC_BT_1886;
- case AVCOL_TRC_IEC61966_2_1: return MP_CSP_TRC_SRGB;
- case AVCOL_TRC_LINEAR: return MP_CSP_TRC_LINEAR;
- default: return MP_CSP_TRC_AUTO;
- }
-}
-
int mp_csp_to_avcol_spc(enum mp_csp colorspace)
{
switch (colorspace) {
@@ -203,17 +181,6 @@ int mp_csp_prim_to_avcol_pri(enum mp_csp_prim prim)
}
}
-int mp_csp_trc_to_avcol_trc(enum mp_csp_trc trc)
-{
- switch (trc) {
- // We just call it BT.1886 since we're decoding, but it's still BT.709
- case MP_CSP_TRC_BT_1886: return AVCOL_TRC_BT709;
- case MP_CSP_TRC_SRGB: return AVCOL_TRC_IEC61966_2_1;
- case MP_CSP_TRC_LINEAR: return AVCOL_TRC_LINEAR;
- default: return AVCOL_TRC_UNSPECIFIED;
- }
-}
-
enum mp_csp mp_csp_guess_colorspace(int width, int height)
{
return width >= 1280 || height > 576 ? MP_CSP_BT_709 : MP_CSP_BT_601;
diff --git a/video/csputils.h b/video/csputils.h
index a082682e43..b6d17c1815 100644
--- a/video/csputils.h
+++ b/video/csputils.h
@@ -68,19 +68,15 @@ enum mp_csp_prim {
MP_CSP_PRIM_COUNT
};
-// Any enum mp_csp_prim value is a valid index (except MP_CSP_PRIM_COUNT)
-extern const char *const mp_csp_prim_names[MP_CSP_PRIM_COUNT];
-
enum mp_csp_trc {
- MP_CSP_TRC_AUTO,
+ MP_CSP_TRC_NONE,
MP_CSP_TRC_BT_1886,
MP_CSP_TRC_SRGB,
- MP_CSP_TRC_LINEAR,
- MP_CSP_TRC_COUNT
+ MP_CSP_TRC_LINEAR
};
-// Any enum mp_csp_trc value is a valid index (except MP_CSP_TRC_COUNT)
-extern const char *const mp_csp_trc_names[MP_CSP_TRC_COUNT];
+// Any enum mp_csp_prim value is a valid index (except MP_CSP_PRIM_COUNT)
+extern const char *const mp_csp_prim_names[MP_CSP_PRIM_COUNT];
// These constants are based on the ICC specification (Table 23) and match
// up with the API of LittleCMS, which treats them as integers.
@@ -203,16 +199,12 @@ enum mp_csp_levels avcol_range_to_mp_csp_levels(int avrange);
enum mp_csp_prim avcol_pri_to_mp_csp_prim(int avpri);
-enum mp_csp_trc avcol_trc_to_mp_csp_trc(int avtrc);
-
int mp_csp_to_avcol_spc(enum mp_csp colorspace);
int mp_csp_levels_to_avcol_range(enum mp_csp_levels range);
int mp_csp_prim_to_avcol_pri(enum mp_csp_prim prim);
-int mp_csp_trc_to_avcol_trc(enum mp_csp_trc trc);
-
enum mp_csp mp_csp_guess_colorspace(int width, int height);
enum mp_csp_prim mp_csp_guess_primaries(int width, int height);
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index e32ff6b01e..9e0a778990 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -477,7 +477,6 @@ static void update_image_params(struct dec_video *vd, AVFrame *frame,
.colorspace = avcol_spc_to_mp_csp(ctx->avctx->colorspace),
.colorlevels = avcol_range_to_mp_csp_levels(ctx->avctx->color_range),
.primaries = avcol_pri_to_mp_csp_prim(ctx->avctx->color_primaries),
- .gamma = avcol_trc_to_mp_csp_trc(ctx->avctx->color_trc),
.chroma_location =
avchroma_location_to_mp(ctx->avctx->chroma_sample_location),
.rotate = vd->header->video->rotate,
diff --git a/video/image_writer.c b/video/image_writer.c
index 700e1c4284..ff321cfd1f 100644
--- a/video/image_writer.c
+++ b/video/image_writer.c
@@ -50,7 +50,6 @@ const struct image_writer_opts image_writer_opts_defaults = {
.jpeg_dpi = 72,
.jpeg_progressive = 0,
.jpeg_baseline = 1,
- .tag_csp = 1,
};
#define OPT_BASE_STRUCT struct image_writer_opts
@@ -66,7 +65,6 @@ const struct m_sub_options image_writer_conf = {
OPT_INTRANGE("png-compression", png_compression, 0, 0, 9),
OPT_INTRANGE("png-filter", png_filter, 0, 0, 5),
OPT_STRING("format", format, 0),
- OPT_FLAG("tag-colorspace", tag_csp, 0),
{0},
},
.size = sizeof(struct image_writer_opts),
@@ -133,12 +131,6 @@ static int write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp)
pic->format = avctx->pix_fmt;
pic->width = avctx->width;
pic->height = avctx->height;
-#if HAVE_AVFRAME_CSP
- if (ctx->opts->tag_csp) {
- pic->color_primaries = mp_csp_prim_to_avcol_pri(image->params.primaries);
- pic->color_trc = mp_csp_trc_to_avcol_trc(image->params.gamma);
- }
-#endif
int ret = avcodec_encode_video2(avctx, &pkt, pic, &got_output);
if (ret < 0)
goto error_exit;
diff --git a/video/image_writer.h b/video/image_writer.h
index 272af73b05..2fce63065e 100644
--- a/video/image_writer.h
+++ b/video/image_writer.h
@@ -28,7 +28,6 @@ struct image_writer_opts {
int jpeg_dpi;
int jpeg_progressive;
int jpeg_baseline;
- int tag_csp;
};
extern const struct image_writer_opts image_writer_opts_defaults;
diff --git a/video/mp_image.c b/video/mp_image.c
index fcf265f699..44f5ab903c 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -368,11 +368,10 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src)
dst->params.d_w = src->params.d_w;
dst->params.d_h = src->params.d_h;
}
- dst->params.primaries = src->params.primaries;
- dst->params.gamma = src->params.gamma;
if ((dst->flags & MP_IMGFLAG_YUV) == (src->flags & MP_IMGFLAG_YUV)) {
dst->params.colorspace = src->params.colorspace;
dst->params.colorlevels = src->params.colorlevels;
+ dst->params.primaries = src->params.primaries;
dst->params.chroma_location = src->params.chroma_location;
dst->params.outputlevels = src->params.outputlevels;
}
@@ -517,7 +516,6 @@ bool mp_image_params_equal(const struct mp_image_params *p1,
p1->colorlevels == p2->colorlevels &&
p1->outputlevels == p2->outputlevels &&
p1->primaries == p2->primaries &&
- p1->gamma == p2->gamma &&
p1->chroma_location == p2->chroma_location &&
p1->rotate == p2->rotate &&
p1->stereo_in == p2->stereo_in &&
@@ -580,8 +578,6 @@ void mp_image_params_guess_csp(struct mp_image_params *params)
params->primaries = mp_csp_guess_primaries(params->w, params->h);
}
}
- if (params->gamma == MP_CSP_TRC_AUTO)
- params->gamma = MP_CSP_TRC_BT_1886;
} else if (fmt.flags & MP_IMGFLAG_RGB) {
params->colorspace = MP_CSP_RGB;
params->colorlevels = MP_CSP_LEVELS_PC;
@@ -593,8 +589,6 @@ void mp_image_params_guess_csp(struct mp_image_params *params)
// Note: sRGB primaries = BT.709 primaries
if (params->primaries == MP_CSP_PRIM_AUTO)
params->primaries = MP_CSP_PRIM_BT_709;
- if (params->gamma == MP_CSP_TRC_AUTO)
- params->gamma = MP_CSP_TRC_SRGB;
} else if (fmt.flags & MP_IMGFLAG_XYZ) {
params->colorspace = MP_CSP_XYZ;
params->colorlevels = MP_CSP_LEVELS_PC;
@@ -609,14 +603,11 @@ void mp_image_params_guess_csp(struct mp_image_params *params)
// tagged with.
if (params->primaries == MP_CSP_PRIM_AUTO)
params->primaries = MP_CSP_PRIM_BT_709;
- if (params->gamma == MP_CSP_TRC_AUTO)
- params->gamma = MP_CSP_TRC_LINEAR;
} else {
// We have no clue.
params->colorspace = MP_CSP_AUTO;
params->colorlevels = MP_CSP_LEVELS_AUTO;
params->primaries = MP_CSP_PRIM_AUTO;
- params->gamma = MP_CSP_TRC_AUTO;
}
}
diff --git a/video/mp_image.h b/video/mp_image.h
index 3017ef46eb..5263249987 100644
--- a/video/mp_image.h
+++ b/video/mp_image.h
@@ -48,7 +48,6 @@ struct mp_image_params {
enum mp_csp colorspace;
enum mp_csp_levels colorlevels;
enum mp_csp_prim primaries;
- enum mp_csp_trc gamma;
enum mp_chroma_location chroma_location;
// The image should be converted to these levels. Unlike colorlevels, it
// does not describe the current state of the image. (Somewhat similar to
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 9c8a64365d..23b19b3125 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -937,7 +937,8 @@ static void compile_shaders(struct gl_video *p)
bool use_input_gamma = p->input_gamma != 1.0;
bool use_conv_gamma = p->conv_gamma != 1.0;
bool use_const_luma = p->image_params.colorspace == MP_CSP_BT_2020_C;
- enum mp_csp_trc gamma_fun = p->image_params.gamma;
+
+ enum mp_csp_trc gamma_fun = MP_CSP_TRC_NONE;
// If either color correction option (3dlut or srgb) is enabled, or if
// sigmoidal upscaling is requested, or if the source is linear XYZ, we
@@ -945,6 +946,20 @@ static void compile_shaders(struct gl_video *p)
bool use_linear_light = p->opts.linear_scaling || p->opts.sigmoid_upscaling
|| use_cms || is_xyz;
+ if (use_linear_light) {
+ // We use the color level range to distinguish between PC
+ // content like images, which are most likely sRGB, and TV content
+ // like movies, which are most likely BT.1886. XYZ input is always
+ // treated as linear.
+ if (is_xyz) {
+ gamma_fun = MP_CSP_TRC_LINEAR;
+ } else if (p->image_params.colorlevels == MP_CSP_LEVELS_PC) {
+ gamma_fun = MP_CSP_TRC_SRGB;
+ } else {
+ gamma_fun = MP_CSP_TRC_BT_1886;
+ }
+ }
+
// The inverse of the above transformation is normally handled by
// the CMS cases, but if CMS is disabled we need to go back manually
bool use_inv_bt1886 = false;
diff --git a/wscript b/wscript
index f273388305..d3086b9950 100644
--- a/wscript
+++ b/wscript
@@ -462,13 +462,6 @@ Libav libraries ({0}). Aborting.".format(" ".join(libav_pkg_config_checks))
'func': check_statement('libavutil/frame.h',
'enum AVFrameSideDataType type = AV_FRAME_DATA_SKIP_SAMPLES',
use='libav')
- }, {
- 'name': 'avframe-csp',
- 'desc': 'libavutil AVFrame colorspace information',
- 'func': check_statement('libavutil/frame.h',
- 'AVFrame frame;'
- 'frame.color_primaries = frame.color_trc = 0;',
- use='libav')
}
]