From patchwork Thu May 9 20:45:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Roche X-Patchwork-Id: 13048 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 286AE4479D3 for ; Thu, 9 May 2019 23:46:23 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 091F7680924; Thu, 9 May 2019 23:46:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BA72468035F for ; Thu, 9 May 2019 23:46:15 +0300 (EEST) Received: by mail-qt1-f172.google.com with SMTP id a17so2923342qth.3 for ; Thu, 09 May 2019 13:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=giphy.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JfRycMnLr0OZO7Fht/nor2Ojr880+prC+NPgmh1HKd4=; b=bUsZcp2FI3mShYAWs8voqqfn4XQHrRXVXkbm8PbiEFOVvnrtmvJwTe2ksET5fFGePr ++yhtQtBS8uERNgNlT9gytevNqJUjVHy7+ruauaA+2mNT/kNclVMjVUHaDkc3t7kQLhw HQeOpBnjv4r/JyUt8SiuGhDCRNCU4bjjguXjM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JfRycMnLr0OZO7Fht/nor2Ojr880+prC+NPgmh1HKd4=; b=tfU0K/L7zOk7hG7qsy/XihQkNr4Gz7oJMG6qHxAntnQLQ8ddcraVJQD3jDWeiFs6H4 rT+TrXCdXN6qBoSUJQvVDu+6hU0AItfe/FPvekAIr5iTogvuUf3LRJFB0Ak8kxUda1+1 jwVYdyliLFRKmx32c0S0T1Nk8kvRrTU30XolhyYIW6yGEQ6Oo9aupkzc/g5Ujg/4BvKd QeTsEzsIa1//9kOTKsux1937vluDxLPPGHq6cK614HNBcltKRD7XwHjUI0bfkWWMtslS y0iGfsCgb63a4HoM/xtsuSRxWeQb8Gq4FxrlDeLa6h1qpyJ6LeYJkKt9GEJP950C9Bqg 5fRQ== X-Gm-Message-State: APjAAAWeDNXXeZDQ93msJWrnG3zArqnfJxvNHNnwnKHhQrDQbsHn3NOD RIMT2bfpqkQObqBYJjt8x67OGwHV/NY= X-Google-Smtp-Source: APXvYqzB3Iv/xli8zotWgNImyJ50mlfUFl46hauMKJ0pPpgm7pOXXb3VeOMF1da9stZC2Las6O6Uig== X-Received: by 2002:ac8:6bc8:: with SMTP id b8mr5606124qtt.21.1557434773373; Thu, 09 May 2019 13:46:13 -0700 (PDT) Received: from localhost.localdomain ([158.106.201.22]) by smtp.gmail.com with ESMTPSA id x7sm1627468qkc.22.2019.05.09.13.46.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 13:46:12 -0700 (PDT) From: Bjorn Roche To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 May 2019 16:45:56 -0400 Message-Id: <20190509204556.3097-1-bjorn@giphy.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] fix issues with transparent crop. (see https://trac.ffmpeg.org/ticket/7890) X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Jacob Graff Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Jacob Graff Resolves issues with some transparent gifs. see https://trac.ffmpeg.org/ticket/7890 contribution by Jacob Graff --- 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; }