[FFmpeg-devel] [PATCH] vf_fade: fade alpha

Stefano Sabatini stefasab at gmail.com
Sun Nov 6 01:40:13 CET 2011


On date Saturday 2011-11-05 21:53:35 +0000, Mark Himsley encoded:
> On 05/11/2011 14:26, Stefano Sabatini wrote:
> >On date Saturday 2011-11-05 02:01:02 +0000, Mark Himsley encoded:
> >>add alpha fading
[...]
> >slightly more readable:
> >          plane = fade->is_packed_rgb ? 0 : 3;
> >          fade_luma(y, h, inlink->w, fade->factor, fade->black_level, fade->black_level_scaled,
> >                    fade->is_packed_rgb ? fade->rgba_map[3] : 0, // offset
> >                    fade->is_packed_rgb ? 4 : 1,                 // pixstep
> >                    1, outpic->data[plane], outpic->linesize[plane]);
> 
> Ok.
> 
> One question. Should fade->bpp be used for the alpha plane?

With the supported formats bpp is always 1, I thought you wanted that
parameter for future extensions, but in that case maybe the function
may need to be reworked anyway, so it's up to you.

> >maybe you can define R G B A Y macros and use them in place of 0 1 2 3 0.
> >
> >>+        } else {
> >>          /* luma or rgb plane */
> >>-        for (i = 0; i<  h; i++) {
> >>-            p = outpic->data[0] + (y+i) * outpic->linesize[0];
> >>-            for (j = 0; j<  inlink->w * fade->bpp; j++) {
> >>-                /* fade->factor is using 16 lower-order bits for decimal places. */
> >>-                *p = ((*p - fade->black_level) * fade->factor + fade->black_level_scaled)>>  16;
> >>-                p++;
> >>-            }
> >>-        }
> >>-
> >>+        fade_luma( y, h, inlink->w, fade->factor, fade->black_level, fade->black_level_scaled,
> >>+                0, 1, fade->bpp, outpic->data[0], outpic->linesize[0]);
> >>          if (outpic->data[1]&&  outpic->data[2]) {
> >>              /* chroma planes */
> >>              for (plane = 1; plane<  3; plane++) {
> >>@@ -223,6 +260,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
> >>                  }
> >>              }
> >>          }
> >>+        }
> >>      }
> 
> Thanks for the review.

Thanks for the patch ;-).

> 
> I'll send updated patches.
-- 
FFmpeg = Fundamental & Fundamental Multipurpose Patchable Ecstatic Gadget


More information about the ffmpeg-devel mailing list