diff mbox

[FFmpeg-devel] vf_thumbnail: support alpha

Message ID CALdTkGEc9Vw=Hu+pLXH_u+irsNiefkJ=7Vu2M=KXNMXTi0tM2A@mail.gmail.com
State New
Headers show

Commit Message

Robert Nagy May 11, 2019, 10:19 a.m. UTC
---
 libavfilter/vf_thumbnail.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

     // keep a reference of each frame
     s->frames[s->n].buf = frame;
@@ -143,9 +144,9 @@ static int filter_frame(AVFilterLink *inlink,
AVFrame *frame)
     // update current frame RGB histogram
     for (j = 0; j < inlink->h; j++) {
         for (i = 0; i < inlink->w; i++) {
-            hist[0*256 + p[i*3    ]]++;
-            hist[1*256 + p[i*3 + 1]]++;
-            hist[2*256 + p[i*3 + 2]]++;
+            hist[0*256 + p[i*stride    ]]++;
+            hist[1*256 + p[i*stride + 1]]++;
+            hist[2*256 + p[i*stride + 2]]++;
         }
         p += frame->linesize[0];
     }
@@ -197,6 +198,7 @@ static int query_formats(AVFilterContext *ctx)
 {
     static const enum AVPixelFormat pix_fmts[] = {
         AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
+        AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA,
         AV_PIX_FMT_NONE
     };
     AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);

Comments

Michael Niedermayer May 11, 2019, 11:40 p.m. UTC | #1
On Sat, May 11, 2019 at 12:19:22PM +0200, Robert Nagy wrote:
> ---
>  libavfilter/vf_thumbnail.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/vf_thumbnail.c b/libavfilter/vf_thumbnail.c
> index 0effdc91e9..30bb0dfdb8 100644
> --- a/libavfilter/vf_thumbnail.c
> +++ b/libavfilter/vf_thumbnail.c
> @@ -136,6 +136,7 @@ static int filter_frame(AVFilterLink *inlink,
> AVFrame *frame)
>      AVFilterLink *outlink = ctx->outputs[0];
>      int *hist = s->frames[s->n].histogram;
>      const uint8_t *p = frame->data[0];
> +    int stride = frame->format == AV_PIX_FMT_BGRA || frame->format ==
> AV_PIX_FMT_RGBA ? 4 : 3;

Applying: vf_thumbnail: support alpha
error: corrupt patch at line 10
error: could not build fake ancestor
Patch failed at 0001 vf_thumbnail: support alpha
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".


[...]
diff mbox

Patch

diff --git a/libavfilter/vf_thumbnail.c b/libavfilter/vf_thumbnail.c
index 0effdc91e9..30bb0dfdb8 100644
--- a/libavfilter/vf_thumbnail.c
+++ b/libavfilter/vf_thumbnail.c
@@ -136,6 +136,7 @@  static int filter_frame(AVFilterLink *inlink,
AVFrame *frame)
     AVFilterLink *outlink = ctx->outputs[0];
     int *hist = s->frames[s->n].histogram;
     const uint8_t *p = frame->data[0];
+    int stride = frame->format == AV_PIX_FMT_BGRA || frame->format ==
AV_PIX_FMT_RGBA ? 4 : 3;