mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 14:50:07 +00:00
video/out: remove legacy colorspace stuff
Reduce most dependencies on struct mp_csp_details, which was a bad first attempt at dealing with colorspace stuff. Instead, consistently use mp_image_params. Code which retrieves colorspace matrices from csputils.c still uses this type, though.
This commit is contained in:
parent
fdeda359f7
commit
bd0618f01f
@ -1481,9 +1481,9 @@ static int mp_property_colormatrix(m_option_t *prop, int action, void *arg,
|
||||
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
|
||||
struct mp_csp_details vo_csp = {0};
|
||||
struct mp_image_params vo_csp = {0};
|
||||
if (mpctx->video_out)
|
||||
vo_control(mpctx->video_out, VOCTRL_GET_YUV_COLORSPACE, &vo_csp);
|
||||
vo_control(mpctx->video_out, VOCTRL_GET_COLORSPACE, &vo_csp);
|
||||
|
||||
struct mp_image_params vd_csp = {0};
|
||||
if (mpctx->d_video)
|
||||
@ -1492,7 +1492,7 @@ static int mp_property_colormatrix(m_option_t *prop, int action, void *arg,
|
||||
char *res = talloc_strdup(NULL, "");
|
||||
append_csp(&res, "*Requested", mp_csp_names, opts->requested_colorspace);
|
||||
append_csp(&res, "Video decoder", mp_csp_names, vd_csp.colorspace);
|
||||
append_csp(&res, "Video output", mp_csp_names, vo_csp.format);
|
||||
append_csp(&res, "Video output", mp_csp_names, vo_csp.colorspace);
|
||||
*(char **)arg = res;
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
@ -1505,9 +1505,9 @@ static int mp_property_colormatrix_input_range(m_option_t *prop, int action,
|
||||
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
|
||||
struct mp_csp_details vo_csp = {0};
|
||||
struct mp_image_params vo_csp = {0};
|
||||
if (mpctx->video_out)
|
||||
vo_control(mpctx->video_out, VOCTRL_GET_YUV_COLORSPACE, &vo_csp );
|
||||
vo_control(mpctx->video_out, VOCTRL_GET_COLORSPACE, &vo_csp);
|
||||
|
||||
struct mp_image_params vd_csp = {0};
|
||||
if (mpctx->d_video)
|
||||
@ -1517,7 +1517,7 @@ static int mp_property_colormatrix_input_range(m_option_t *prop, int action,
|
||||
append_csp(&res, "*Requested", mp_csp_levels_names,
|
||||
opts->requested_input_range);
|
||||
append_csp(&res, "Video decoder", mp_csp_levels_names, vd_csp.colorlevels);
|
||||
append_csp(&res, "Video output", mp_csp_levels_names, vo_csp.levels_in);
|
||||
append_csp(&res, "Video output", mp_csp_levels_names, vo_csp.colorlevels);
|
||||
*(char **)arg = res;
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
@ -1530,14 +1530,14 @@ static int mp_property_colormatrix_output_range(m_option_t *prop, int action,
|
||||
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
|
||||
struct mp_csp_details actual = {0};
|
||||
struct mp_image_params actual = {0};
|
||||
if (mpctx->video_out)
|
||||
vo_control(mpctx->video_out, VOCTRL_GET_YUV_COLORSPACE, &actual);
|
||||
vo_control(mpctx->video_out, VOCTRL_GET_COLORSPACE, &actual);
|
||||
|
||||
char *res = talloc_strdup(NULL, "");
|
||||
append_csp(&res, "*Requested", mp_csp_levels_names,
|
||||
opts->requested_output_range);
|
||||
append_csp(&res, "Video output", mp_csp_levels_names, actual.levels_out);
|
||||
append_csp(&res, "Video output", mp_csp_levels_names, actual.outputlevels);
|
||||
*(char **)arg = res;
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
|
@ -190,7 +190,6 @@ struct gl_video {
|
||||
// state for luma (0) and chroma (1) scalers
|
||||
struct scaler scalers[2];
|
||||
|
||||
struct mp_csp_details colorspace;
|
||||
struct mp_csp_equalizer video_eq;
|
||||
struct mp_image_params image_params;
|
||||
|
||||
@ -535,8 +534,13 @@ static void update_uniforms(struct gl_video *p, GLuint program)
|
||||
|
||||
gl->UseProgram(program);
|
||||
|
||||
struct mp_csp_details csp = MP_CSP_DETAILS_DEFAULTS;
|
||||
csp.levels_in = p->image_params.colorlevels;
|
||||
csp.levels_out = p->image_params.outputlevels;
|
||||
csp.format = p->image_params.colorspace;
|
||||
|
||||
struct mp_csp_params cparams = {
|
||||
.colorspace = p->colorspace,
|
||||
.colorspace = csp,
|
||||
.input_bits = p->plane_bits,
|
||||
.texture_bits = (p->plane_bits + 7) & ~7,
|
||||
};
|
||||
@ -1301,12 +1305,6 @@ static void init_video(struct gl_video *p, const struct mp_image_params *params)
|
||||
p->image_dh = params->d_h;
|
||||
p->image_params = *params;
|
||||
|
||||
struct mp_csp_details csp = MP_CSP_DETAILS_DEFAULTS;
|
||||
csp.levels_in = params->colorlevels;
|
||||
csp.levels_out = params->outputlevels;
|
||||
csp.format = params->colorspace;
|
||||
p->colorspace = csp;
|
||||
|
||||
if (p->is_rgb && (p->opts.srgb || p->use_lut_3d)) {
|
||||
// If we're opening an RGB source like a png file or similar,
|
||||
// we just sample it using GL_SRGB which treats it as an sRGB source
|
||||
@ -2215,10 +2213,9 @@ void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts)
|
||||
reinit_rendering(p);
|
||||
}
|
||||
|
||||
bool gl_video_get_csp_override(struct gl_video *p, struct mp_csp_details *csp)
|
||||
void gl_video_get_colorspace(struct gl_video *p, struct mp_image_params *params)
|
||||
{
|
||||
*csp = p->colorspace;
|
||||
return true;
|
||||
*params = p->image_params; // supports everything
|
||||
}
|
||||
|
||||
bool gl_video_set_equalizer(struct gl_video *p, const char *name, int val)
|
||||
|
@ -69,7 +69,7 @@ struct mp_image *gl_video_download_image(struct gl_video *p);
|
||||
void gl_video_resize(struct gl_video *p, struct mp_rect *window,
|
||||
struct mp_rect *src, struct mp_rect *dst,
|
||||
struct mp_osd_res *osd);
|
||||
bool gl_video_get_csp_override(struct gl_video *p, struct mp_csp_details *csp);
|
||||
void gl_video_get_colorspace(struct gl_video *p, struct mp_image_params *params);
|
||||
bool gl_video_set_equalizer(struct gl_video *p, const char *name, int val);
|
||||
bool gl_video_get_equalizer(struct gl_video *p, const char *name, int *val);
|
||||
|
||||
|
@ -450,16 +450,6 @@ int vo_reconfig(struct vo *vo, struct mp_image_params *params, int flags)
|
||||
vo->waiting_mpi = NULL;
|
||||
vo->redrawing = false;
|
||||
vo->hasframe = false;
|
||||
if (vo->config_ok) {
|
||||
// Legacy
|
||||
struct mp_csp_details csp;
|
||||
if (vo_control(vo, VOCTRL_GET_YUV_COLORSPACE, &csp) > 0) {
|
||||
csp.levels_in = params->colorlevels;
|
||||
csp.levels_out = params->outputlevels;
|
||||
csp.format = params->colorspace;
|
||||
vo_control(vo, VOCTRL_SET_YUV_COLORSPACE, &csp);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,10 @@ enum mp_voctrl {
|
||||
VOCTRL_GET_WINDOW_SIZE, // int[2] (w/h)
|
||||
VOCTRL_SET_WINDOW_SIZE, // int[2] (w/h)
|
||||
|
||||
VOCTRL_SET_YUV_COLORSPACE, // struct mp_csp_details*
|
||||
VOCTRL_GET_YUV_COLORSPACE, // struct mp_csp_details*
|
||||
// The VO is supposed to set "known" fields, and leave the others
|
||||
// untouched or set to 0.
|
||||
// imgfmt/w/h/d_w/d_h can be omitted for convenience.
|
||||
VOCTRL_GET_COLORSPACE, // struct mp_image_params*
|
||||
|
||||
VOCTRL_SCREENSHOT, // struct voctrl_screenshot_args*
|
||||
|
||||
|
@ -71,15 +71,13 @@ struct cv_functions {
|
||||
void (*bind_texture)(struct vo *vo);
|
||||
void (*unbind_texture)(struct vo *vo);
|
||||
mp_image_t *(*get_screenshot)(struct vo *vo);
|
||||
int (*get_yuv_colorspace)(struct vo *vo, struct mp_csp_details *csp);
|
||||
int (*set_yuv_colorspace)(struct vo *vo, struct mp_csp_details *csp);
|
||||
void (*get_colorspace)(struct vo *vo, struct mp_image_params *p);
|
||||
};
|
||||
|
||||
struct priv {
|
||||
MPGLContext *mpglctx;
|
||||
unsigned int image_width;
|
||||
unsigned int image_height;
|
||||
struct mp_csp_details colorspace;
|
||||
struct mp_rect src_rect;
|
||||
struct mp_rect dst_rect;
|
||||
struct mp_osd_res osd_res;
|
||||
@ -213,7 +211,6 @@ static int preinit(struct vo *vo)
|
||||
|
||||
*p = (struct priv) {
|
||||
.mpglctx = mpgl_init(vo, "cocoa"),
|
||||
.colorspace = MP_CSP_DETAILS_DEFAULTS,
|
||||
.quad = talloc_ptrtype(p, p->quad),
|
||||
};
|
||||
|
||||
@ -245,8 +242,11 @@ static CFStringRef get_cv_csp_matrix(enum mp_csp format)
|
||||
static void apply_csp(struct vo *vo, CVPixelBufferRef pbuf)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
CFStringRef matrix = get_cv_csp_matrix(p->colorspace.format);
|
||||
assert(matrix);
|
||||
if (!vo->params)
|
||||
return;
|
||||
CFStringRef matrix = get_cv_csp_matrix(vo->params->colorspace);
|
||||
if (!matrix)
|
||||
return;
|
||||
|
||||
CVPixelBufferLockBaseAddress(pbuf, 0);
|
||||
CVBufferSetAttachment(pbuf, kCVImageBufferYCbCrMatrixKey, matrix,
|
||||
@ -254,11 +254,11 @@ static void apply_csp(struct vo *vo, CVPixelBufferRef pbuf)
|
||||
CVPixelBufferUnlockBaseAddress(pbuf, 0);
|
||||
}
|
||||
|
||||
static int get_yuv_colorspace(struct vo *vo, struct mp_csp_details *csp)
|
||||
static void get_colorspace(struct vo *vo, struct mp_image_params *p)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
*(struct mp_csp_details *)csp = p->colorspace;
|
||||
return VO_TRUE;
|
||||
if (vo->params && get_cv_csp_matrix(vo->params->colorspace))
|
||||
p->colorspace = vo->params->colorspace;
|
||||
}
|
||||
|
||||
static int get_image_fmt(struct vo *vo, CVPixelBufferRef pbuf)
|
||||
@ -312,10 +312,9 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
case VOCTRL_REDRAW_FRAME:
|
||||
do_render(vo);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_SET_YUV_COLORSPACE:
|
||||
return p->fns.set_yuv_colorspace(vo, data);
|
||||
case VOCTRL_GET_YUV_COLORSPACE:
|
||||
return p->fns.get_yuv_colorspace(vo, data);
|
||||
case VOCTRL_GET_COLORSPACE:
|
||||
p->fns.get_colorspace(vo, data);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_SCREENSHOT: {
|
||||
struct voctrl_screenshot_args *args = data;
|
||||
if (args->full_window)
|
||||
@ -404,16 +403,7 @@ static mp_image_t *cv_get_screenshot(struct vo *vo)
|
||||
return get_screenshot(vo, p->cv.pbuf);
|
||||
}
|
||||
|
||||
static int cv_set_yuv_colorspace(struct vo *vo, struct mp_csp_details *csp)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
|
||||
if (get_cv_csp_matrix(csp->format)) {
|
||||
p->colorspace = *csp;
|
||||
return VO_TRUE;
|
||||
} else
|
||||
return VO_NOTIMPL;
|
||||
}
|
||||
|
||||
static struct cv_functions cv_functions = {
|
||||
.init = dummy_cb,
|
||||
@ -422,8 +412,7 @@ static struct cv_functions cv_functions = {
|
||||
.unbind_texture = cv_unbind_texture,
|
||||
.prepare_texture = upload_opengl_texture,
|
||||
.get_screenshot = cv_get_screenshot,
|
||||
.get_yuv_colorspace = get_yuv_colorspace,
|
||||
.set_yuv_colorspace = cv_set_yuv_colorspace,
|
||||
.get_colorspace = get_colorspace,
|
||||
};
|
||||
|
||||
#if HAVE_VDA_HWACCEL
|
||||
@ -506,14 +495,9 @@ static mp_image_t *iosurface_get_screenshot(struct vo *vo)
|
||||
return get_screenshot(vo, p->dr.pbuf);
|
||||
}
|
||||
|
||||
static int iosurface_set_yuv_csp(struct vo *vo, struct mp_csp_details *csp)
|
||||
static void iosurface_get_colorspace(struct vo *vo, struct mp_image_params *p)
|
||||
{
|
||||
if (csp->format == MP_CSP_BT_601) {
|
||||
struct priv *p = vo->priv;
|
||||
p->colorspace = *csp;
|
||||
return VO_TRUE;
|
||||
} else
|
||||
return VO_NOTIMPL;
|
||||
p->colorspace = MP_CSP_BT_601;
|
||||
}
|
||||
|
||||
static struct cv_functions iosurface_functions = {
|
||||
@ -523,8 +507,7 @@ static struct cv_functions iosurface_functions = {
|
||||
.unbind_texture = iosurface_unbind_texture,
|
||||
.prepare_texture = extract_texture_from_iosurface,
|
||||
.get_screenshot = iosurface_get_screenshot,
|
||||
.get_yuv_colorspace = get_yuv_colorspace,
|
||||
.set_yuv_colorspace = iosurface_set_yuv_csp,
|
||||
.get_colorspace = iosurface_get_colorspace,
|
||||
};
|
||||
#endif /* HAVE_VDA_HWACCEL */
|
||||
|
||||
|
@ -141,6 +141,7 @@ typedef struct d3d_priv {
|
||||
int src_height; /**< Source (movie) heigth */
|
||||
struct mp_osd_res osd_res;
|
||||
int image_format; /**< mplayer image format */
|
||||
struct mp_image_params params;
|
||||
bool use_textures; /**< use 3D texture rendering, instead of
|
||||
StretchRect */
|
||||
bool use_shaders; /**< use shader for YUV color conversion
|
||||
@ -180,7 +181,6 @@ typedef struct d3d_priv {
|
||||
int max_texture_height; /**< from the device capabilities */
|
||||
|
||||
D3DMATRIX d3d_colormatrix;
|
||||
struct mp_csp_details colorspace;
|
||||
struct mp_csp_equalizer video_eq;
|
||||
|
||||
struct osdpart *osd[MAX_OSD_PARTS];
|
||||
@ -1126,7 +1126,10 @@ static int query_format(struct vo *vo, uint32_t movie_fmt)
|
||||
static void update_colorspace(d3d_priv *priv)
|
||||
{
|
||||
float coeff[3][4];
|
||||
struct mp_csp_params csp = { .colorspace = priv->colorspace };
|
||||
struct mp_csp_params csp = MP_CSP_PARAMS_DEFAULTS;
|
||||
csp.colorspace.format = priv->params.colorspace;
|
||||
csp.colorspace.levels_in = priv->params.colorlevels;
|
||||
csp.colorspace.levels_out = priv->params.outputlevels;
|
||||
mp_csp_copy_equalizer_values(&csp, &priv->video_eq);
|
||||
|
||||
if (priv->use_shaders) {
|
||||
@ -1205,16 +1208,15 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
case VOCTRL_REDRAW_FRAME:
|
||||
d3d_draw_frame(priv);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_SET_YUV_COLORSPACE:
|
||||
priv->colorspace = *(struct mp_csp_details *)data;
|
||||
update_colorspace(priv);
|
||||
vo->want_redraw = true;
|
||||
return VO_TRUE;
|
||||
case VOCTRL_GET_YUV_COLORSPACE:
|
||||
if (!priv->use_shaders)
|
||||
break; // no idea what the heck D3D YUV uses
|
||||
*(struct mp_csp_details *)data = priv->colorspace;
|
||||
case VOCTRL_GET_COLORSPACE: {
|
||||
struct mp_image_params *p = data;
|
||||
if (priv->use_shaders) { // no idea what the heck D3D YUV uses
|
||||
p->colorspace = priv->params.colorspace;
|
||||
p->colorlevels = priv->params.colorlevels;
|
||||
p->outputlevels = priv->params.outputlevels;
|
||||
}
|
||||
return VO_TRUE;
|
||||
}
|
||||
case VOCTRL_SET_EQUALIZER: {
|
||||
if (!priv->use_shaders)
|
||||
break;
|
||||
@ -1282,6 +1284,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
|
||||
|
||||
priv->src_width = params->w;
|
||||
priv->src_height = params->h;
|
||||
priv->params = params;
|
||||
init_rendering_mode(priv, params->imgfmt, true);
|
||||
}
|
||||
|
||||
@ -1709,14 +1712,12 @@ static const struct m_option opts[] = {
|
||||
};
|
||||
|
||||
static const d3d_priv defaults_noshaders = {
|
||||
.colorspace = MP_CSP_DETAILS_DEFAULTS,
|
||||
.video_eq = { MP_CSP_EQ_CAPS_COLORMATRIX },
|
||||
.opt_disable_shaders = 1,
|
||||
.opt_disable_textures = 1,
|
||||
};
|
||||
|
||||
static const d3d_priv defaults = {
|
||||
.colorspace = MP_CSP_DETAILS_DEFAULTS,
|
||||
.video_eq = { MP_CSP_EQ_CAPS_COLORMATRIX },
|
||||
};
|
||||
|
||||
|
@ -56,7 +56,7 @@ struct priv {
|
||||
AVRational worst_time_base;
|
||||
int worst_time_base_is_stream;
|
||||
|
||||
struct mp_csp_details colorspace;
|
||||
struct mp_image_params real_colorspace;
|
||||
};
|
||||
|
||||
static int preinit(struct vo *vo)
|
||||
@ -69,7 +69,6 @@ static int preinit(struct vo *vo)
|
||||
vo->priv = talloc_zero(vo, struct priv);
|
||||
vc = vo->priv;
|
||||
vc->harddup = vo->encode_lavc_ctx->options->harddup;
|
||||
vc->colorspace = (struct mp_csp_details) MP_CSP_DETAILS_DEFAULTS;
|
||||
vo->untimed = true;
|
||||
return 0;
|
||||
}
|
||||
@ -153,14 +152,16 @@ static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
|
||||
vc->stream->codec->height = height;
|
||||
vc->stream->codec->pix_fmt = pix_fmt;
|
||||
|
||||
encode_lavc_set_csp(vo->encode_lavc_ctx, vc->stream, vc->colorspace.format);
|
||||
encode_lavc_set_csp_levels(vo->encode_lavc_ctx, vc->stream, vc->colorspace.levels_out);
|
||||
encode_lavc_set_csp(vo->encode_lavc_ctx, vc->stream, params->colorspace);
|
||||
encode_lavc_set_csp_levels(vo->encode_lavc_ctx, vc->stream, params->colorlevels);
|
||||
|
||||
if (encode_lavc_open_codec(vo->encode_lavc_ctx, vc->stream) < 0)
|
||||
goto error;
|
||||
|
||||
vc->colorspace.format = encode_lavc_get_csp(vo->encode_lavc_ctx, vc->stream);
|
||||
vc->colorspace.levels_out = encode_lavc_get_csp_levels(vo->encode_lavc_ctx, vc->stream);
|
||||
vc->real_colorspace.colorspace =
|
||||
encode_lavc_get_csp(vo->encode_lavc_ctx, vc->stream);
|
||||
vc->real_colorspace.colorlevels =
|
||||
encode_lavc_get_csp_levels(vo->encode_lavc_ctx, vc->stream);
|
||||
|
||||
vc->buffer_size = 6 * width * height + 200;
|
||||
if (vc->buffer_size < FF_MIN_BUFFER_SIZE)
|
||||
@ -502,8 +503,6 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
|
||||
if (vc->lastimg && vc->lastimg_wants_osd && vo->params) {
|
||||
struct mp_osd_res dim = osd_res_from_image_params(vo->params);
|
||||
|
||||
mp_image_set_colorspace_details(vc->lastimg, &vc->colorspace);
|
||||
|
||||
osd_draw_on_image(osd, dim, osd_get_vo_pts(osd), OSD_DRAW_SUB_ONLY,
|
||||
vc->lastimg);
|
||||
}
|
||||
@ -517,18 +516,8 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
int r = VO_NOTIMPL;
|
||||
pthread_mutex_lock(&vo->encode_lavc_ctx->lock);
|
||||
switch (request) {
|
||||
case VOCTRL_SET_YUV_COLORSPACE:
|
||||
vc->colorspace = *(struct mp_csp_details *)data;
|
||||
if (vc->stream) {
|
||||
encode_lavc_set_csp(vo->encode_lavc_ctx, vc->stream, vc->colorspace.format);
|
||||
encode_lavc_set_csp_levels(vo->encode_lavc_ctx, vc->stream, vc->colorspace.levels_out);
|
||||
vc->colorspace.format = encode_lavc_get_csp(vo->encode_lavc_ctx, vc->stream);
|
||||
vc->colorspace.levels_out = encode_lavc_get_csp_levels(vo->encode_lavc_ctx, vc->stream);
|
||||
}
|
||||
r = 1;
|
||||
break;
|
||||
case VOCTRL_GET_YUV_COLORSPACE:
|
||||
*(struct mp_csp_details *)data = vc->colorspace;
|
||||
case VOCTRL_GET_COLORSPACE:
|
||||
*(struct mp_image_params *)data = vc->real_colorspace;
|
||||
r = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -340,9 +340,9 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
vo->want_redraw = true;
|
||||
return r ? VO_TRUE : VO_NOTIMPL;
|
||||
}
|
||||
case VOCTRL_GET_YUV_COLORSPACE:
|
||||
case VOCTRL_GET_COLORSPACE:
|
||||
mpgl_lock(p->glctx);
|
||||
gl_video_get_csp_override(p->renderer, data);
|
||||
gl_video_get_colorspace(p->renderer, data);
|
||||
mpgl_unlock(p->glctx);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_SCREENSHOT: {
|
||||
|
@ -62,7 +62,6 @@ struct gl_priv {
|
||||
|
||||
int use_ycbcr;
|
||||
int use_yuv;
|
||||
struct mp_csp_details colorspace;
|
||||
int is_yuv;
|
||||
int lscale;
|
||||
int cscale;
|
||||
@ -1395,8 +1394,13 @@ static void update_yuvconv(struct vo *vo)
|
||||
{
|
||||
struct gl_priv *p = vo->priv;
|
||||
GL *gl = p->gl;
|
||||
if (!vo->params)
|
||||
return;
|
||||
|
||||
struct mp_csp_params cparams = { .colorspace = p->colorspace };
|
||||
struct mp_csp_params cparams = { .colorspace = MP_CSP_DETAILS_DEFAULTS };
|
||||
cparams.colorspace.format = vo->params->colorspace;
|
||||
cparams.colorspace.levels_in = vo->params->colorlevels;
|
||||
cparams.colorspace.levels_out = vo->params->outputlevels;
|
||||
mp_csp_copy_equalizer_values(&cparams, &p->video_eq);
|
||||
gl_conversion_params_t params = {
|
||||
p->target, p->yuvconvtype, cparams,
|
||||
@ -2121,18 +2125,16 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
return VO_TRUE;
|
||||
}
|
||||
break;
|
||||
case VOCTRL_SET_YUV_COLORSPACE: {
|
||||
case VOCTRL_GET_COLORSPACE: {
|
||||
struct mp_image_params *params = data;
|
||||
bool supports_csp = (1 << p->use_yuv) & MASK_NOT_COMBINERS;
|
||||
if (vo->config_count && supports_csp) {
|
||||
p->colorspace = *(struct mp_csp_details *)data;
|
||||
update_yuvconv(vo);
|
||||
vo->want_redraw = true;
|
||||
if (vo->params && supports_csp) {
|
||||
params->colorspace = vo->params->colorspace;
|
||||
params->colorlevels = vo->params->colorlevels;
|
||||
params->outputlevels = vo->params->outputlevels;
|
||||
}
|
||||
return VO_TRUE;
|
||||
}
|
||||
case VOCTRL_GET_YUV_COLORSPACE:
|
||||
*(struct mp_csp_details *)data = p->colorspace;
|
||||
return VO_TRUE;
|
||||
case VOCTRL_REDRAW_FRAME:
|
||||
do_render(vo);
|
||||
return true;
|
||||
@ -2173,7 +2175,6 @@ const struct vo_driver video_out_opengl_old = {
|
||||
.priv_defaults = &(const struct gl_priv) {
|
||||
.many_fmts = 1,
|
||||
.use_yuv = -1,
|
||||
.colorspace = MP_CSP_DETAILS_DEFAULTS,
|
||||
.filter_strength = 0.5,
|
||||
.use_rectangle = -1,
|
||||
.ati_hack = -1,
|
||||
|
@ -513,6 +513,12 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
arg->vaapi_ctx = p->mpvaapi;
|
||||
return true;
|
||||
}
|
||||
case VOCTRL_GET_COLORSPACE: {
|
||||
struct mp_image_params *params = data;
|
||||
if (va_get_colorspace_flag(p->image_params.colorspace))
|
||||
params->colorspace = p->image_params.colorspace;
|
||||
return true;
|
||||
}
|
||||
case VOCTRL_SET_EQUALIZER: {
|
||||
struct voctrl_set_equalizer_args *eq = data;
|
||||
return set_equalizer(p, eq->name, eq->value);
|
||||
|
@ -100,7 +100,6 @@ struct vdpctx {
|
||||
|
||||
int force_yuv;
|
||||
VdpVideoMixer video_mixer;
|
||||
struct mp_csp_details colorspace;
|
||||
int user_deint;
|
||||
int deint;
|
||||
int deint_type;
|
||||
@ -545,6 +544,8 @@ static int set_video_attribute(struct vo *vo, VdpVideoMixerAttribute attr,
|
||||
static void update_csc_matrix(struct vo *vo)
|
||||
{
|
||||
struct vdpctx *vc = vo->priv;
|
||||
if (!vo->params)
|
||||
return;
|
||||
|
||||
MP_VERBOSE(vo, "Updating CSC matrix\n");
|
||||
|
||||
@ -552,8 +553,10 @@ static void update_csc_matrix(struct vo *vo)
|
||||
// both are float[3][4]
|
||||
VdpCSCMatrix matrix;
|
||||
|
||||
struct mp_csp_params cparams = {
|
||||
.colorspace = vc->colorspace, .input_bits = 8, .texture_bits = 8 };
|
||||
struct mp_csp_params cparams = MP_CSP_PARAMS_DEFAULTS;
|
||||
cparams.colorspace.format = vo->params->colorspace;
|
||||
cparams.colorspace.levels_in = vo->params->colorlevels;
|
||||
cparams.colorspace.levels_out = vo->params->outputlevels;
|
||||
mp_csp_copy_equalizer_values(&cparams, &vc->video_eq);
|
||||
mp_get_yuv2rgb_coeffs(&cparams, matrix);
|
||||
|
||||
@ -1224,9 +1227,12 @@ static struct mp_image *read_output_surface(struct vo *vo,
|
||||
struct vdpctx *vc = vo->priv;
|
||||
VdpStatus vdp_st;
|
||||
struct vdp_functions *vdp = vc->vdp;
|
||||
if (!vo->params)
|
||||
return NULL;
|
||||
|
||||
struct mp_image *image = mp_image_alloc(IMGFMT_BGR32, width, height);
|
||||
image->colorspace = MP_CSP_RGB;
|
||||
image->levels = vc->colorspace.levels_out; // hardcoded with conv. matrix
|
||||
image->levels = vo->params->outputlevels; // hardcoded with conv. matrix
|
||||
|
||||
void *dst_planes[] = { image->planes[0] };
|
||||
uint32_t dst_pitches[] = { image->stride[0] };
|
||||
@ -1358,7 +1364,6 @@ static int preinit(struct vo *vo)
|
||||
vc->vdp_device = vc->mpvdp->vdp_device;
|
||||
vc->vdp = &vc->mpvdp->vdp;
|
||||
|
||||
vc->colorspace = (struct mp_csp_details) MP_CSP_DETAILS_DEFAULTS;
|
||||
vc->video_eq.capabilities = MP_CSP_EQ_CAPS_COLORMATRIX;
|
||||
|
||||
vc->deint_type = vc->deint ? FFABS(vc->deint) : 3;
|
||||
@ -1457,19 +1462,15 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
struct voctrl_get_equalizer_args *args = data;
|
||||
return get_equalizer(vo, args->name, args->valueptr);
|
||||
}
|
||||
case VOCTRL_SET_YUV_COLORSPACE:
|
||||
if (vc->rgb_mode)
|
||||
break;
|
||||
vc->colorspace = *(struct mp_csp_details *)data;
|
||||
if (status_ok(vo))
|
||||
update_csc_matrix(vo);
|
||||
vo->want_redraw = true;
|
||||
return true;
|
||||
case VOCTRL_GET_YUV_COLORSPACE:
|
||||
if (vc->rgb_mode)
|
||||
break;
|
||||
*(struct mp_csp_details *)data = vc->colorspace;
|
||||
case VOCTRL_GET_COLORSPACE: {
|
||||
struct mp_image_params *params = data;
|
||||
if (vo->params && !vc->rgb_mode) {
|
||||
params->colorspace = vo->params->colorspace;
|
||||
params->colorlevels = vo->params->colorlevels;
|
||||
params->outputlevels = vo->params->outputlevels;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case VOCTRL_NEWFRAME:
|
||||
vc->deint_queue_pos = next_deint_queue_pos(vo, true);
|
||||
if (status_ok(vo))
|
||||
|
@ -87,7 +87,7 @@ struct xvctx {
|
||||
uint32_t image_width;
|
||||
uint32_t image_height;
|
||||
uint32_t image_format;
|
||||
struct mp_csp_details cached_csp;
|
||||
int cached_csp;
|
||||
struct mp_rect src_rect;
|
||||
struct mp_rect dst_rect;
|
||||
uint32_t max_width, max_height; // zero means: not set
|
||||
@ -392,11 +392,10 @@ static void xv_draw_colorkey(struct vo *vo, const struct mp_rect *rc)
|
||||
static void read_xv_csp(struct vo *vo)
|
||||
{
|
||||
struct xvctx *ctx = vo->priv;
|
||||
struct mp_csp_details *cspc = &ctx->cached_csp;
|
||||
*cspc = (struct mp_csp_details) MP_CSP_DETAILS_DEFAULTS;
|
||||
ctx->cached_csp = 0;
|
||||
int bt709_enabled;
|
||||
if (xv_get_eq(vo, ctx->xv_port, "bt_709", &bt709_enabled))
|
||||
cspc->format = bt709_enabled == 100 ? MP_CSP_BT_709 : MP_CSP_BT_601;
|
||||
ctx->cached_csp = bt709_enabled == 100 ? MP_CSP_BT_709 : MP_CSP_BT_601;
|
||||
}
|
||||
|
||||
static void resize(struct vo *vo)
|
||||
@ -476,6 +475,9 @@ static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
|
||||
ctx->current_buf = 0;
|
||||
ctx->current_ip_buf = 0;
|
||||
|
||||
int is_709 = params->colorspace == MP_CSP_BT_709;
|
||||
xv_set_eq(vo, ctx->xv_port, "bt_709", is_709 * 200 - 100);
|
||||
read_xv_csp(vo);
|
||||
|
||||
resize(vo);
|
||||
|
||||
@ -603,7 +605,12 @@ static struct mp_image get_xv_buffer(struct vo *vo, int buf_index)
|
||||
img.stride[n] = xv_image->pitches[sn];
|
||||
}
|
||||
|
||||
mp_image_set_colorspace_details(&img, &ctx->cached_csp);
|
||||
if (vo->params) {
|
||||
struct mp_image_params params = *vo->params;
|
||||
if (ctx->cached_csp)
|
||||
params.colorspace = ctx->cached_csp;
|
||||
mp_image_set_attributes(&img, ¶ms);
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
@ -842,18 +849,12 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
struct voctrl_get_equalizer_args *args = data;
|
||||
return xv_get_eq(vo, ctx->xv_port, args->name, args->valueptr);
|
||||
}
|
||||
case VOCTRL_SET_YUV_COLORSPACE:;
|
||||
struct mp_csp_details* given_cspc = data;
|
||||
int is_709 = given_cspc->format == MP_CSP_BT_709;
|
||||
xv_set_eq(vo, ctx->xv_port, "bt_709", is_709 * 200 - 100);
|
||||
case VOCTRL_GET_COLORSPACE: {
|
||||
struct mp_image_params *params = data;
|
||||
read_xv_csp(vo);
|
||||
vo->want_redraw = true;
|
||||
return true;
|
||||
case VOCTRL_GET_YUV_COLORSPACE:;
|
||||
struct mp_csp_details* cspc = data;
|
||||
read_xv_csp(vo);
|
||||
*cspc = ctx->cached_csp;
|
||||
params->colorspace = ctx->cached_csp;
|
||||
return true;
|
||||
}
|
||||
case VOCTRL_REDRAW_FRAME:
|
||||
redraw_frame(vo);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user