From patchwork Mon Oct 2 17:24:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Roche X-Patchwork-Id: 5381 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.61.8 with SMTP id n8csp1752723jan; Mon, 2 Oct 2017 10:25:36 -0700 (PDT) X-Received: by 10.28.6.149 with SMTP id 143mr11553400wmg.114.1506965136577; Mon, 02 Oct 2017 10:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506965136; cv=none; d=google.com; s=arc-20160816; b=KptREXVnIe3+VvsceUUqvnW6Pu2OkqC9bKnezkrNyhndI6Sn0Ii6j8XY8SvIJ9izae Xbu+4F1p+FOTbes/PnFwdEgbrwCFBVlXouG5mNgLlZAdxZ4b/EX4GdROwdY+qrXsl7h7 Mt6VbuptVFP8xrWpZ+Cmo2ZMhiFRvyTkqpBlbQiisZ+59RIdAnFwYn2r63P45gHPJz5K a6A5YGBWDwllVkpIiRoZ4uoUH9lo89q+3uWdvU5IVv1gdHuRjooXVGtKzy1BdvrF/5sz G6ugXpuFdGAgCnUyaYZUb0ehCDNHF8BUxFQN8uZYa/UBxcWy9pnJARkILTDsG0tS/abU QtrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=MW0yosF4DSOVLjvHPDY6FI7oPj4rRTJ2f0wOwF3JyKI=; b=JaW0QUmesVU7CTy4kIZTVAxbtmOkzIV22r98T4xdct0VQVZcplxJRCxwrq8ykHdBnP +pAiPh8hvYqZo38CyVxQ8UUI9agoDRbBNIPqQ/WhPQtUnXzEMQEERFlPPulTVgyO88iY krN+f/OHxYbWxOu8YsrI84G9djwqdo64/8LbURW4EGFc+RZ0ow79CyHG+lcHciljQ3Uh XkqZgIBKXB2UtmdKBe8PNnQEP0uvaC/5gjR3wgL4JHLSWEfqvsmhPgJfggO3CdzlZdnv iFT2Ks9pvO3jyhax0OVg0JDXX95qW/IB8V0O/DoFjs1WtoPMGKGr1BEz6z76pAe+04zf ndmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@giphy.com header.s=google header.b=XiFmCYWG; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h2si6867310wre.269.2017.10.02.10.25.35; Mon, 02 Oct 2017 10:25:36 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@giphy.com header.s=google header.b=XiFmCYWG; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8F80E689F0F; Mon, 2 Oct 2017 20:24:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f179.google.com (mail-qk0-f179.google.com [209.85.220.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF798689F09 for ; Mon, 2 Oct 2017 20:24:51 +0300 (EEST) Received: by mail-qk0-f179.google.com with SMTP id k123so2417484qke.3 for ; Mon, 02 Oct 2017 10:25:06 -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:in-reply-to:references; bh=YDrp+LPeV0IYSl3vNnnnY1ct0EL/7GoKsPc9rEYwmWo=; b=XiFmCYWGUdKhSfwIGv4glSJUhbMAwPDk+haLQBS+/6BdwM0C/nBrZQ7HojHb9VpWFV TMkU9cSUhRqeuvyA5PyAj2jAmj8l5uJga/Ij3gfl9Ip1PMYcMj9Abj2EjaKNOxM0dDBm S8c1qyrbeBy+8b/0N4Nr3QTyvaLcrhXXoZzuA= 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:in-reply-to :references; bh=YDrp+LPeV0IYSl3vNnnnY1ct0EL/7GoKsPc9rEYwmWo=; b=r3kCZFD2Q7rZ0edhjFFfjDguIfEIysNdRr5tRwOuE8Y5REIK9iOLcOl8eqtRMR9qer iaZe5PPWWDzqwIqohYZ1AEZHdK8B/E9AYxbaLgYyZ3IgeRaUvqW1o+iKesmWc/NtBXLS HimrrXc4M8dKM8MIRTSgzKK4GoGkCVJWGOOF5uLJKf7R7y+B1Jyf5/gBsiycwqYgAXdK t/7hCgj449xtI1kvIE/7uzfd8yqDBCUEDAlxo0cK+pWwkbp3248zYCM6Hq9oOg3RL/1F 3O8vdqEwm/dy95p8oc0dSCwk1zwtcE8/J4tBx2CDDQDLYUrUK+giNW9w2Zp2iD59u3fa J/cg== X-Gm-Message-State: AMCzsaVnt8GyGeUNSIqmpcerUkGZ/CjQSieFD7OwJvkZ+lEXUyxeBadX RfjDGdfKFepGRngR5Fqpm8zs7JXYEWQ= X-Google-Smtp-Source: AOwi7QDvoOaWgwLOADP0t9PxIZ5oeDebFsYwodK8g7sqQg8kCve0vscvJll3QaXn/emhxAWuh63Zbg== X-Received: by 10.55.65.68 with SMTP id o65mr15620986qka.349.1506965104930; Mon, 02 Oct 2017 10:25:04 -0700 (PDT) Received: from localhost.localdomain ([208.184.100.82]) by smtp.gmail.com with ESMTPSA id p25sm7339001qte.28.2017.10.02.10.25.04 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Oct 2017 10:25:04 -0700 (PDT) From: Bjorn Roche To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Oct 2017 13:24:37 -0400 Message-Id: <20171002172439.65628-6-bjorn@giphy.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171002172439.65628-1-bjorn@giphy.com> References: <20171002172439.65628-1-bjorn@giphy.com> Subject: [FFmpeg-devel] [PATCH 5/7] Reimplement optimization for transparency 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: Bjorn Roche MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Bjorn Roche --- libavcodec/gif.c | 131 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 53 deletions(-) diff --git a/libavcodec/gif.c b/libavcodec/gif.c index db2193a718..3838aa7592 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -80,7 +80,7 @@ static int is_image_translucent(AVCodecContext *avctx, const uint8_t *buf, const int linesize) { GIFContext *s = avctx->priv_data; - int trans = s->transparent_index; + uint8_t trans = s->transparent_index; int p; const int m = avctx->width * avctx->height ; @@ -88,7 +88,6 @@ static int is_image_translucent(AVCodecContext *avctx, return 0; } - // FIXME: this might be faster with strchr for( p=0; ppriv_data; - int len = 0, height = avctx->height, width = avctx->width, x, y; + int len = 0, height = avctx->height, width = avctx->width, y; int x_start = 0, y_start = 0, trans = s->transparent_index; - int honor_transparency = (s->flags & GF_TRANSDIFF) && s->last_frame && !palette; + //int honor_transparency = (s->flags & GF_TRANSDIFF) && s->last_frame && !palette; const uint8_t *ptr; - // /* Crop image */ - // if ((s->flags & GF_OFFSETTING) && s->last_frame && !palette) { - // const uint8_t *ref = s->last_frame->data[0]; - // const int ref_linesize = s->last_frame->linesize[0]; - // int x_end = avctx->width - 1, - // y_end = avctx->height - 1; - - // /* skip common lines */ - // while (y_start < y_end) { - // if (memcmp(ref + y_start*ref_linesize, buf + y_start*linesize, width)) - // break; - // y_start++; - // } - // while (y_end > y_start) { - // if (memcmp(ref + y_end*ref_linesize, buf + y_end*linesize, width)) - // break; - // y_end--; - // } - // height = y_end + 1 - y_start; - - // /* skip common columns */ - // while (x_start < x_end) { - // int same_column = 1; - // for (y = y_start; y <= y_end; y++) { - // if (ref[y*ref_linesize + x_start] != buf[y*linesize + x_start]) { - // same_column = 0; - // break; - // } - // } - // if (!same_column) - // break; - // x_start++; - // } - // while (x_end > x_start) { - // int same_column = 1; - // for (y = y_start; y <= y_end; y++) { - // if (ref[y*ref_linesize + x_end] != buf[y*linesize + x_end]) { - // same_column = 0; - // break; - // } - // } - // if (!same_column) - // break; - // x_end--; - // } - // width = x_end + 1 - x_start; - - // av_log(avctx, AV_LOG_DEBUG,"%dx%d image at pos (%d;%d) [area:%dx%d]\n", - // width, height, x_start, y_start, avctx->width, avctx->height); + /* Crop Image */ + if ( (s->flags & GF_OFFSETTING) && trans >=0 ) { + const int w = avctx->width; + const int h = avctx->height; + int x_end = w - 1, + y_end = h - 1; + + // top + while (y_start < y_end) { + int i; + int is_trans = 1; + for( i=0; iwidth, avctx->height); + } + + // for( int i=0; iwidth*avctx->height; ++i ) { + // ((uint8_t *)buf)[i] = 120; // }