[FFmpeg-devel] fix issues with transparent crop. (see https://trac.ffmpeg.org/ticket/7890)

Submitted by Bjorn Roche on May 9, 2019, 2:37 p.m.

Details

Message ID 20190509143701.20636-1-bjorn@giphy.com
State Accepted
Commit 0158dd14a35ff88c4837d4b463e1f393040884c9
Headers show

Commit Message

Bjorn Roche May 9, 2019, 2:37 p.m.
From: Bjorn Roche <bjorn@xowave.com>

---
 libavcodec/gif.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Bjorn Roche May 9, 2019, 4:23 p.m.
This patch should be attributed to Jacob Graff <Jacob@giphy.com>.

On Thu, May 9, 2019 at 10:37 AM Bjorn Roche <bjorn@giphy.com> wrote:

> From: Bjorn Roche <bjorn@xowave.com>
>
> ---
>  libavcodec/gif.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/gif.c b/libavcodec/gif.c
> index 94c8b1af49..d7768b4426 100644
> --- a/libavcodec/gif.c
> +++ b/libavcodec/gif.c
> @@ -136,7 +136,7 @@ static void gif_crop_translucent(AVCodecContext *avctx,
>          while (*y_start < y_end) {
>              int is_trans = 1;
>              for (int i = 0; i < w; i++) {
> -                if (buf[w * *y_start + i] != trans) {
> +                if (buf[linesize * *y_start + i] != trans) {
>                      is_trans = 0;
>                      break;
>                  }
> @@ -148,10 +148,10 @@ static void gif_crop_translucent(AVCodecContext
> *avctx,
>          }
>
>          // crop bottom
> -        while (y_end < h) {
> +        while (y_end > *y_start) {
>              int is_trans = 1;
>              for (int i = 0; i < w; i++) {
> -                if (buf[w * y_end + i] != trans) {
> +                if (buf[linesize * y_end + i] != trans) {
>                      is_trans = 0;
>                      break;
>                  }
> @@ -165,7 +165,7 @@ static void gif_crop_translucent(AVCodecContext *avctx,
>          while (*x_start < x_end) {
>              int is_trans = 1;
>              for (int i = *y_start; i < y_end; i++) {
> -                if (buf[w * i + *x_start] != trans) {
> +                if (buf[linesize * i + *x_start] != trans) {
>                      is_trans = 0;
>                      break;
>                  }
> @@ -176,10 +176,10 @@ static void gif_crop_translucent(AVCodecContext
> *avctx,
>          }
>
>          // crop right
> -        while (x_end < w) {
> +        while (x_end > *x_start) {
>              int is_trans = 1;
>              for (int i = *y_start; i < y_end; i++) {
> -                if (buf[w * i + x_end] != trans) {
> +                if (buf[linesize * i + x_end] != trans) {
>                      is_trans = 0;
>                      break;
>                  }
> --
> 2.19.1
>
>
Carl Eugen Hoyos May 9, 2019, 4:55 p.m.
> Am 09.05.2019 um 18:23 schrieb Bjorn Roche <bjorn@giphy.com>:
> 
> This patch should be attributed to Jacob Graff <Jacob@giphy.com>.

Then please resend with the correct attribution.

Carl Eugen

Patch hide | download patch | download mbox

diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index 94c8b1af49..d7768b4426 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -136,7 +136,7 @@  static void gif_crop_translucent(AVCodecContext *avctx,
         while (*y_start < y_end) {
             int is_trans = 1;
             for (int i = 0; i < w; i++) {
-                if (buf[w * *y_start + i] != trans) {
+                if (buf[linesize * *y_start + i] != trans) {
                     is_trans = 0;
                     break;
                 }
@@ -148,10 +148,10 @@  static void gif_crop_translucent(AVCodecContext *avctx,
         }
 
         // crop bottom
-        while (y_end < h) {
+        while (y_end > *y_start) {
             int is_trans = 1;
             for (int i = 0; i < w; i++) {
-                if (buf[w * y_end + i] != trans) {
+                if (buf[linesize * y_end + i] != trans) {
                     is_trans = 0;
                     break;
                 }
@@ -165,7 +165,7 @@  static void gif_crop_translucent(AVCodecContext *avctx,
         while (*x_start < x_end) {
             int is_trans = 1;
             for (int i = *y_start; i < y_end; i++) {
-                if (buf[w * i + *x_start] != trans) {
+                if (buf[linesize * i + *x_start] != trans) {
                     is_trans = 0;
                     break;
                 }
@@ -176,10 +176,10 @@  static void gif_crop_translucent(AVCodecContext *avctx,
         }
 
         // crop right
-        while (x_end < w) {
+        while (x_end > *x_start) {
             int is_trans = 1;
             for (int i = *y_start; i < y_end; i++) {
-                if (buf[w * i + x_end] != trans) {
+                if (buf[linesize * i + x_end] != trans) {
                     is_trans = 0;
                     break;
                 }