1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 17:42:17 +00:00

encode: simplify colorspace setting

This was also refactored at some point, and is now unnecessarily
roundabout.
This commit is contained in:
wm4 2018-04-19 20:29:17 +02:00
parent 20a1f250c6
commit 78227706ad
3 changed files with 2 additions and 38 deletions

View File

@ -1196,34 +1196,4 @@ void encode_lavc_fail(struct encode_lavc_context *ctx, const char *format, ...)
encode_lavc_finish(ctx);
}
bool encode_lavc_set_csp(struct encode_lavc_context *ctx,
AVCodecContext *codec, enum mp_csp csp)
{
CHECK_FAIL(ctx, NULL);
if (ctx->header_written) {
if (codec->colorspace != mp_csp_to_avcol_spc(csp))
MP_WARN(ctx, "can not change color space during encoding\n");
return false;
}
codec->colorspace = mp_csp_to_avcol_spc(csp);
return true;
}
bool encode_lavc_set_csp_levels(struct encode_lavc_context *ctx,
AVCodecContext *codec, enum mp_csp_levels lev)
{
CHECK_FAIL(ctx, NULL);
if (ctx->header_written) {
if (codec->color_range != mp_csp_levels_to_avcol_range(lev))
MP_WARN(ctx, "can not change color space during encoding\n");
return false;
}
codec->color_range = mp_csp_levels_to_avcol_range(lev);
return true;
}
// vim: ts=4 sw=4 et

View File

@ -113,9 +113,4 @@ double encode_lavc_getoffset(struct encode_lavc_context *ctx,
AVCodecContext *codec);
void encode_lavc_fail(struct encode_lavc_context *ctx, const char *format, ...); // report failure of encoding
bool encode_lavc_set_csp(struct encode_lavc_context *ctx,
AVCodecContext *codec, enum mp_csp csp);
bool encode_lavc_set_csp_levels(struct encode_lavc_context *ctx,
AVCodecContext *codec, enum mp_csp_levels lev);
#endif

View File

@ -148,9 +148,8 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
vc->codec->width = width;
vc->codec->height = height;
vc->codec->pix_fmt = pix_fmt;
encode_lavc_set_csp(vo->encode_lavc_ctx, vc->codec, params->color.space);
encode_lavc_set_csp_levels(vo->encode_lavc_ctx, vc->codec, params->color.levels);
vc->codec->colorspace = mp_csp_to_avcol_spc(params->color.space);
vc->codec->color_range = mp_csp_levels_to_avcol_range(params->color.levels);
if (encode_lavc_open_codec(vo->encode_lavc_ctx, vc->codec) < 0)
goto error;