mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-12-24 11:52:06 +08:00
lavf/rkrga: add alpha_format options for overlay filter
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
@@ -1114,15 +1114,18 @@ av_cold int ff_rkrga_init(AVFilterContext *avctx, RKRGAParam *param)
|
||||
}
|
||||
}
|
||||
if (avctx->nb_inputs > 1) {
|
||||
const int premultiplied_alpha = r->in_rga_frame_infos[1].pix_desc->flags & AV_PIX_FMT_FLAG_ALPHA;
|
||||
int need_premultiply = 0;
|
||||
|
||||
if (r->in_rga_frame_infos[1].pix_desc->flags & AV_PIX_FMT_FLAG_ALPHA)
|
||||
need_premultiply = param->in_alpha_format == 0;
|
||||
|
||||
/* IM_ALPHA_BLEND_DST_OVER */
|
||||
if (param->in_global_alpha > 0 && param->in_global_alpha < 0xff) {
|
||||
r->in_rga_frame_infos[0].blend_mode = premultiplied_alpha ? (0x4 | (1 << 12)) : 0x4;
|
||||
r->in_rga_frame_infos[0].blend_mode = need_premultiply ? (0x4 | (1 << 12)) : 0x4;
|
||||
r->in_rga_frame_infos[0].blend_mode |= (param->in_global_alpha & 0xff) << 16; /* fg_global_alpha */
|
||||
r->in_rga_frame_infos[0].blend_mode |= 0xff << 24; /* bg_global_alpha */
|
||||
} else
|
||||
r->in_rga_frame_infos[0].blend_mode = premultiplied_alpha ? 0x504 : 0x501;
|
||||
r->in_rga_frame_infos[0].blend_mode = need_premultiply ? 0x504 : 0x501;
|
||||
|
||||
r->in_rga_frame_infos[1].overlay_x = FFMAX(param->overlay_x, 0);
|
||||
r->in_rga_frame_infos[1].overlay_y = FFMAX(param->overlay_y, 0);
|
||||
|
||||
@@ -110,6 +110,7 @@ typedef struct RKRGAParam {
|
||||
|
||||
int in_rotate_mode;
|
||||
int in_global_alpha;
|
||||
int in_alpha_format;
|
||||
|
||||
int in_crop;
|
||||
int in_crop_x;
|
||||
|
||||
@@ -52,6 +52,7 @@ typedef struct RGAOverlayContext {
|
||||
double var_values[VAR_VARS_NB];
|
||||
char *overlay_ox, *overlay_oy;
|
||||
int global_alpha;
|
||||
int alpha_format;
|
||||
enum AVPixelFormat format;
|
||||
} RGAOverlayContext;
|
||||
|
||||
@@ -195,6 +196,7 @@ static av_cold int rgaoverlay_config_props(AVFilterLink *outlink)
|
||||
param.filter_frame = NULL;
|
||||
param.out_sw_format = out_format;
|
||||
param.in_global_alpha = r->global_alpha;
|
||||
param.in_alpha_format = r->alpha_format;
|
||||
param.overlay_x = r->var_values[VAR_OX];
|
||||
param.overlay_y = r->var_values[VAR_OY];
|
||||
|
||||
@@ -312,6 +314,9 @@ static const AVOption rgaoverlay_options[] = {
|
||||
{ "x", "Overlay x position", OFFSET(overlay_ox), AV_OPT_TYPE_STRING, { .str = "0" }, 0, 0, .flags = FLAGS },
|
||||
{ "y", "Overlay y position", OFFSET(overlay_oy), AV_OPT_TYPE_STRING, { .str = "0" }, 0, 0, .flags = FLAGS },
|
||||
{ "alpha", "Overlay global alpha", OFFSET(global_alpha), AV_OPT_TYPE_INT, { .i64 = 255 }, 0, 255, .flags = FLAGS },
|
||||
{ "alpha_format", "alpha format", OFFSET(alpha_format), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "alpha_format" },
|
||||
{ "straight", "The overlay input is unpremultiplied", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = FLAGS, "alpha_format" },
|
||||
{ "premultiplied", "The overlay input is premultiplied", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = FLAGS, "alpha_format" },
|
||||
{ "format", "Output video pixel format", OFFSET(format), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, INT_MIN, INT_MAX, .flags = FLAGS },
|
||||
{ "eof_action", "Action to take when encountering EOF from secondary input ",
|
||||
OFFSET(fs.opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
|
||||
|
||||
Reference in New Issue
Block a user