[FFmpeg-cvslog] vf_fade: Support slice threaded alpha
Michael Niedermayer
git at videolan.org
Fri May 24 20:21:48 CEST 2013
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri May 24 20:02:34 2013 +0200| [0cbfbdef4a0701c162569808b8a50ff462e788d8] | committer: Michael Niedermayer
vf_fade: Support slice threaded alpha
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0cbfbdef4a0701c162569808b8a50ff462e788d8
---
libavfilter/vf_fade.c | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index 44170fd..b899dc1 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -208,6 +208,31 @@ static int filter_slice_chroma(AVFilterContext *ctx, void *arg, int jobnr,
return 0;
}
+static int filter_slice_alpha(AVFilterContext *ctx, void *arg, int jobnr,
+ int nb_jobs)
+{
+ FadeContext *s = ctx->priv;
+ AVFrame *frame = arg;
+ int plane = s->is_packed_rgb ? 0 : A;
+ int slice_start = (frame->height * jobnr ) / nb_jobs;
+ int slice_end = (frame->height * (jobnr+1)) / nb_jobs;
+ int i, j;
+
+ for (i = slice_start; i < slice_end; i++) {
+ uint8_t *p = frame->data[plane] + i * frame->linesize[plane] + s->is_packed_rgb*s->rgba_map[A];
+ int step = s->is_packed_rgb ? 4 : 1;
+ for (j = 0; j < frame->width; j++) {
+ /* s->factor is using 16 lower-order bits for decimal
+ * places. 32768 = 1 << 15, it is an integer representation
+ * of 0.5 and is for rounding. */
+ *p = ((*p - s->black_level) * s->factor + s->black_level_scaled) >> 16;
+ p += step;
+ }
+ }
+
+ return 0;
+}
+
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
AVFilterContext *ctx = inlink->dst;
@@ -264,14 +289,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
if (s->factor < UINT16_MAX) {
if (s->alpha) {
- // alpha only
- int plane = s->is_packed_rgb ? 0 : A; // alpha is on plane 0 for packed formats
- // or plane 3 for planar formats
- fade_plane(0, frame->height, inlink->w,
- s->factor, s->black_level, s->black_level_scaled,
- s->is_packed_rgb ? s->rgba_map[A] : 0, // alpha offset for packed formats
- s->is_packed_rgb ? 4 : 1, // pixstep for 8 bit packed formats
- 1, frame->data[plane], frame->linesize[plane]);
+ ctx->internal->execute(ctx, filter_slice_alpha, frame, NULL,
+ FFMIN(frame->height, ctx->graph->nb_threads));
} else {
/* luma or rgb plane */
ctx->internal->execute(ctx, filter_slice_luma, frame, NULL,
More information about the ffmpeg-cvslog
mailing list