mirror of
https://github.com/librempeg/librempeg
synced 2024-11-23 03:28:27 +00:00
avfilter/vf_overlay: add yuv420p10 and yuv422p10 10bit format support
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
This commit is contained in:
parent
4d787c16e8
commit
dacae40a4b
@ -14342,9 +14342,15 @@ It accepts the following values:
|
||||
@item yuv420
|
||||
force YUV420 output
|
||||
|
||||
@item yuv420p10
|
||||
force YUV420p10 output
|
||||
|
||||
@item yuv422
|
||||
force YUV422 output
|
||||
|
||||
@item yuv422p10
|
||||
force YUV422p10 output
|
||||
|
||||
@item yuv444
|
||||
force YUV444 output
|
||||
|
||||
|
@ -154,6 +154,7 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar
|
||||
|
||||
static const enum AVPixelFormat alpha_pix_fmts[] = {
|
||||
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
|
||||
AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10,
|
||||
AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_RGBA,
|
||||
AV_PIX_FMT_BGRA, AV_PIX_FMT_GBRAP, AV_PIX_FMT_NONE
|
||||
};
|
||||
@ -172,6 +173,14 @@ static int query_formats(AVFilterContext *ctx)
|
||||
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
|
||||
};
|
||||
|
||||
static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = {
|
||||
AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUVA420P10,
|
||||
AV_PIX_FMT_NONE
|
||||
};
|
||||
static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
|
||||
AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_NONE
|
||||
};
|
||||
|
||||
static const enum AVPixelFormat main_pix_fmts_yuv422[] = {
|
||||
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_NONE
|
||||
};
|
||||
@ -179,6 +188,13 @@ static int query_formats(AVFilterContext *ctx)
|
||||
AV_PIX_FMT_YUVA422P, AV_PIX_FMT_NONE
|
||||
};
|
||||
|
||||
static const enum AVPixelFormat main_pix_fmts_yuv422p10[] = {
|
||||
AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_NONE
|
||||
};
|
||||
static const enum AVPixelFormat overlay_pix_fmts_yuv422p10[] = {
|
||||
AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_NONE
|
||||
};
|
||||
|
||||
static const enum AVPixelFormat main_pix_fmts_yuv444[] = {
|
||||
AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE
|
||||
};
|
||||
@ -217,6 +233,13 @@ static int query_formats(AVFilterContext *ctx)
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case OVERLAY_FORMAT_YUV420P10:
|
||||
if (!(main_formats = ff_make_format_list(main_pix_fmts_yuv420p10)) ||
|
||||
!(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv420p10))) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case OVERLAY_FORMAT_YUV422:
|
||||
if (!(main_formats = ff_make_format_list(main_pix_fmts_yuv422)) ||
|
||||
!(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv422))) {
|
||||
@ -224,6 +247,13 @@ static int query_formats(AVFilterContext *ctx)
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case OVERLAY_FORMAT_YUV422P10:
|
||||
if (!(main_formats = ff_make_format_list(main_pix_fmts_yuv422p10)) ||
|
||||
!(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv422p10))) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case OVERLAY_FORMAT_YUV444:
|
||||
if (!(main_formats = ff_make_format_list(main_pix_fmts_yuv444)) ||
|
||||
!(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv444))) {
|
||||
@ -566,6 +596,7 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext
|
||||
} \
|
||||
}
|
||||
DEFINE_BLEND_PLANE(8, 8);
|
||||
DEFINE_BLEND_PLANE(16, 10);
|
||||
|
||||
#define DEFINE_ALPHA_COMPOSITE(depth, nbits) \
|
||||
static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, const AVFrame *dst, \
|
||||
@ -617,6 +648,7 @@ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
|
||||
} \
|
||||
}
|
||||
DEFINE_ALPHA_COMPOSITE(8, 8);
|
||||
DEFINE_ALPHA_COMPOSITE(16, 10);
|
||||
|
||||
#define DEFINE_BLEND_SLICE_YUV(depth, nbits) \
|
||||
static av_always_inline void blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx, \
|
||||
@ -648,6 +680,7 @@ static av_always_inline void blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon
|
||||
jobnr, nb_jobs); \
|
||||
}
|
||||
DEFINE_BLEND_SLICE_YUV(8, 8);
|
||||
DEFINE_BLEND_SLICE_YUV(16, 10);
|
||||
|
||||
static av_always_inline void blend_slice_planar_rgb(AVFilterContext *ctx,
|
||||
AVFrame *dst, const AVFrame *src,
|
||||
@ -694,6 +727,38 @@ static int blend_slice_yuva420(AVFilterContext *ctx, void *arg, int jobnr, int n
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
|
||||
{
|
||||
OverlayContext *s = ctx->priv;
|
||||
ThreadData *td = arg;
|
||||
blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y, 1, jobnr, nb_jobs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
|
||||
{
|
||||
OverlayContext *s = ctx->priv;
|
||||
ThreadData *td = arg;
|
||||
blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y, 1, jobnr, nb_jobs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blend_slice_yuv422p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
|
||||
{
|
||||
OverlayContext *s = ctx->priv;
|
||||
ThreadData *td = arg;
|
||||
blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 0, 0, s->x, s->y, 1, jobnr, nb_jobs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blend_slice_yuva422p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
|
||||
{
|
||||
OverlayContext *s = ctx->priv;
|
||||
ThreadData *td = arg;
|
||||
blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 0, 1, s->x, s->y, 1, jobnr, nb_jobs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blend_slice_yuv422(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
|
||||
{
|
||||
OverlayContext *s = ctx->priv;
|
||||
@ -857,9 +922,15 @@ static int config_input_main(AVFilterLink *inlink)
|
||||
case OVERLAY_FORMAT_YUV420:
|
||||
s->blend_slice = s->main_has_alpha ? blend_slice_yuva420 : blend_slice_yuv420;
|
||||
break;
|
||||
case OVERLAY_FORMAT_YUV420P10:
|
||||
s->blend_slice = s->main_has_alpha ? blend_slice_yuva420p10 : blend_slice_yuv420p10;
|
||||
break;
|
||||
case OVERLAY_FORMAT_YUV422:
|
||||
s->blend_slice = s->main_has_alpha ? blend_slice_yuva422 : blend_slice_yuv422;
|
||||
break;
|
||||
case OVERLAY_FORMAT_YUV422P10:
|
||||
s->blend_slice = s->main_has_alpha ? blend_slice_yuva422p10 : blend_slice_yuv422p10;
|
||||
break;
|
||||
case OVERLAY_FORMAT_YUV444:
|
||||
s->blend_slice = s->main_has_alpha ? blend_slice_yuva444 : blend_slice_yuv444;
|
||||
break;
|
||||
@ -874,9 +945,15 @@ static int config_input_main(AVFilterLink *inlink)
|
||||
case AV_PIX_FMT_YUVA420P:
|
||||
s->blend_slice = blend_slice_yuva420;
|
||||
break;
|
||||
case AV_PIX_FMT_YUVA420P10:
|
||||
s->blend_slice = blend_slice_yuva420p10;
|
||||
break;
|
||||
case AV_PIX_FMT_YUVA422P:
|
||||
s->blend_slice = blend_slice_yuva422;
|
||||
break;
|
||||
case AV_PIX_FMT_YUVA422P10:
|
||||
s->blend_slice = blend_slice_yuva422p10;
|
||||
break;
|
||||
case AV_PIX_FMT_YUVA444P:
|
||||
s->blend_slice = blend_slice_yuva444;
|
||||
break;
|
||||
@ -1028,7 +1105,9 @@ static const AVOption overlay_options[] = {
|
||||
{ "shortest", "force termination when the shortest input terminates", OFFSET(fs.opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
|
||||
{ "format", "set output format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=OVERLAY_FORMAT_YUV420}, 0, OVERLAY_FORMAT_NB-1, FLAGS, "format" },
|
||||
{ "yuv420", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV420}, .flags = FLAGS, .unit = "format" },
|
||||
{ "yuv420p10", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV420P10}, .flags = FLAGS, .unit = "format" },
|
||||
{ "yuv422", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV422}, .flags = FLAGS, .unit = "format" },
|
||||
{ "yuv422p10", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV422P10}, .flags = FLAGS, .unit = "format" },
|
||||
{ "yuv444", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV444}, .flags = FLAGS, .unit = "format" },
|
||||
{ "rgb", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_RGB}, .flags = FLAGS, .unit = "format" },
|
||||
{ "gbrp", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_GBRP}, .flags = FLAGS, .unit = "format" },
|
||||
|
@ -41,7 +41,9 @@ enum var_name {
|
||||
|
||||
enum OverlayFormat {
|
||||
OVERLAY_FORMAT_YUV420,
|
||||
OVERLAY_FORMAT_YUV420P10,
|
||||
OVERLAY_FORMAT_YUV422,
|
||||
OVERLAY_FORMAT_YUV422P10,
|
||||
OVERLAY_FORMAT_YUV444,
|
||||
OVERLAY_FORMAT_RGB,
|
||||
OVERLAY_FORMAT_GBRP,
|
||||
|
Loading…
Reference in New Issue
Block a user