Tested-by: Michael on x86-32/64 linux, mingw, mips/arm qemu linux
Rodger Combs authored on 2016/10/25 15:28:43... | ... |
@@ -125,6 +125,7 @@ typedef struct OverlayContext { |
125 | 125 |
int main_pix_step[4]; ///< steps per pixel for each plane of the main output |
126 | 126 |
int overlay_pix_step[4]; ///< steps per pixel for each plane of the overlay |
127 | 127 |
int hsub, vsub; ///< chroma subsampling values |
128 |
+ const AVPixFmtDescriptor *main_desc; ///< format descriptor for main input |
|
128 | 129 |
|
129 | 130 |
double var_values[VAR_VARS_NB]; |
130 | 131 |
char *x_expr, *y_expr; |
... | ... |
@@ -215,7 +216,9 @@ static int query_formats(AVFilterContext *ctx) |
215 | 215 |
|
216 | 216 |
/* overlay formats contains alpha, for avoiding conversion with alpha information loss */ |
217 | 217 |
static const enum AVPixelFormat main_pix_fmts_yuv420[] = { |
218 |
- AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE |
|
218 |
+ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVA420P, |
|
219 |
+ AV_PIX_FMT_NV12, AV_PIX_FMT_NV21, |
|
220 |
+ AV_PIX_FMT_NONE |
|
219 | 221 |
}; |
220 | 222 |
static const enum AVPixelFormat overlay_pix_fmts_yuv420[] = { |
221 | 223 |
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE |
... | ... |
@@ -470,6 +473,7 @@ static av_always_inline void blend_plane(AVFilterContext *ctx, |
470 | 470 |
int x, int y, |
471 | 471 |
int main_has_alpha) |
472 | 472 |
{ |
473 |
+ OverlayContext *ol = ctx->priv; |
|
473 | 474 |
int src_wp = AV_CEIL_RSHIFT(src_w, hsub); |
474 | 475 |
int src_hp = AV_CEIL_RSHIFT(src_h, vsub); |
475 | 476 |
int dst_wp = AV_CEIL_RSHIFT(dst_w, hsub); |
... | ... |
@@ -479,14 +483,20 @@ static av_always_inline void blend_plane(AVFilterContext *ctx, |
479 | 479 |
uint8_t *s, *sp, *d, *dp, *a, *ap; |
480 | 480 |
int jmax, j, k, kmax; |
481 | 481 |
|
482 |
+ int dst_plane = ol->main_desc->comp[i].plane; |
|
483 |
+ int dst_offset = ol->main_desc->comp[i].offset; |
|
484 |
+ int dst_step = ol->main_desc->comp[i].step; |
|
485 |
+ |
|
482 | 486 |
j = FFMAX(-yp, 0); |
483 | 487 |
sp = src->data[i] + j * src->linesize[i]; |
484 |
- dp = dst->data[i] + (yp+j) * dst->linesize[i]; |
|
488 |
+ dp = dst->data[dst_plane] |
|
489 |
+ + (yp+j) * dst->linesize[dst_plane] |
|
490 |
+ + dst_offset; |
|
485 | 491 |
ap = src->data[3] + (j<<vsub) * src->linesize[3]; |
486 | 492 |
|
487 | 493 |
for (jmax = FFMIN(-yp + dst_hp, src_hp); j < jmax; j++) { |
488 | 494 |
k = FFMAX(-xp, 0); |
489 |
- d = dp + xp+k; |
|
495 |
+ d = dp + (xp+k) * dst_step; |
|
490 | 496 |
s = sp + k; |
491 | 497 |
a = ap + (k<<hsub); |
492 | 498 |
|
... | ... |
@@ -525,10 +535,10 @@ static av_always_inline void blend_plane(AVFilterContext *ctx, |
525 | 525 |
} |
526 | 526 |
*d = FAST_DIV255(*d * (255 - alpha) + *s * alpha); |
527 | 527 |
s++; |
528 |
- d++; |
|
528 |
+ d += dst_step; |
|
529 | 529 |
a += 1 << hsub; |
530 | 530 |
} |
531 |
- dp += dst->linesize[i]; |
|
531 |
+ dp += dst->linesize[dst_plane]; |
|
532 | 532 |
sp += src->linesize[i]; |
533 | 533 |
ap += (1 << vsub) * src->linesize[3]; |
534 | 534 |
} |
... | ... |
@@ -626,6 +636,8 @@ static int config_input_main(AVFilterLink *inlink) |
626 | 626 |
s->hsub = pix_desc->log2_chroma_w; |
627 | 627 |
s->vsub = pix_desc->log2_chroma_h; |
628 | 628 |
|
629 |
+ s->main_desc = pix_desc; |
|
630 |
+ |
|
629 | 631 |
s->main_is_packed_rgb = |
630 | 632 |
ff_fill_rgba_map(s->main_rgba_map, inlink->format) >= 0; |
631 | 633 |
s->main_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts); |
... | ... |
@@ -172,6 +172,16 @@ FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_F |
172 | 172 |
fate-filter-overlay_yuv420: tests/data/filtergraphs/overlay_yuv420 |
173 | 173 |
fate-filter-overlay_yuv420: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv420 |
174 | 174 |
|
175 |
+FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_nv12 |
|
176 |
+fate-filter-overlay_nv12: tests/data/filtergraphs/overlay_nv12 |
|
177 |
+fate-filter-overlay_nv12: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_nv12 |
|
178 |
+fate-filter-overlay_nv12: REF = $(SRC_PATH)/tests/ref/fate/filter-overlay_yuv420 |
|
179 |
+ |
|
180 |
+FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_nv21 |
|
181 |
+fate-filter-overlay_nv21: tests/data/filtergraphs/overlay_nv21 |
|
182 |
+fate-filter-overlay_nv21: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_nv21 |
|
183 |
+fate-filter-overlay_nv21: REF = $(SRC_PATH)/tests/ref/fate/filter-overlay_yuv420 |
|
184 |
+ |
|
175 | 185 |
FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_yuv422 |
176 | 186 |
fate-filter-overlay_yuv422: tests/data/filtergraphs/overlay_yuv422 |
177 | 187 |
fate-filter-overlay_yuv422: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv422 |