[FFmpeg-devel] [PATCH 2/2] lavfi/vf_overlay: support NV12
Rodger Combs
rodger.combs at gmail.com
Wed May 25 04:42:58 CEST 2016
---
libavfilter/vf_overlay.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 71f4db7..e01b924 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -125,6 +125,7 @@ typedef struct OverlayContext {
int main_pix_step[4]; ///< steps per pixel for each plane of the main output
int overlay_pix_step[4]; ///< steps per pixel for each plane of the overlay
int hsub, vsub; ///< chroma subsampling values
+ const AVPixFmtDescriptor *main_desc;
double var_values[VAR_VARS_NB];
char *x_expr, *y_expr;
@@ -213,7 +214,7 @@ static int query_formats(AVFilterContext *ctx)
/* overlay formats contains alpha, for avoiding conversion with alpha information loss */
static const enum AVPixelFormat main_pix_fmts_yuv420[] = {
- AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
+ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NV12, AV_PIX_FMT_NONE
};
static const enum AVPixelFormat overlay_pix_fmts_yuv420[] = {
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
@@ -314,6 +315,8 @@ static int config_input_main(AVFilterLink *inlink)
s->hsub = pix_desc->log2_chroma_w;
s->vsub = pix_desc->log2_chroma_h;
+ s->main_desc = pix_desc;
+
s->main_is_packed_rgb =
ff_fill_rgba_map(s->main_rgba_map, inlink->format) >= 0;
s->main_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);
@@ -530,12 +533,14 @@ static void blend_image(AVFilterContext *ctx,
j = FFMAX(-yp, 0);
sp = src->data[i] + j * src->linesize[i];
- dp = dst->data[i] + (yp+j) * dst->linesize[i];
+ dp = dst->data[ol->main_desc->comp[i].plane]
+ + (yp+j) * dst->linesize[ol->main_desc->comp[i].plane]
+ + ol->main_desc->comp[i].offset;
ap = src->data[3] + (j<<vsub) * src->linesize[3];
for (jmax = FFMIN(-yp + dst_hp, src_hp); j < jmax; j++) {
k = FFMAX(-xp, 0);
- d = dp + xp+k;
+ d = dp + (xp+k) * ol->main_desc->comp[i].step;
s = sp + k;
a = ap + (k<<hsub);
@@ -574,10 +579,10 @@ static void blend_image(AVFilterContext *ctx,
}
*d = FAST_DIV255(*d * (255 - alpha) + *s * alpha);
s++;
- d++;
+ d += ol->main_desc->comp[i].step;
a += 1 << hsub;
}
- dp += dst->linesize[i];
+ dp += dst->linesize[ol->main_desc->comp[i].plane];
sp += src->linesize[i];
ap += (1 << vsub) * src->linesize[3];
}
--
2.8.2
More information about the ffmpeg-devel
mailing list