From patchwork Sat Jan 13 21:57:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 7275 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp1099904jaa; Sat, 13 Jan 2018 13:57:51 -0800 (PST) X-Google-Smtp-Source: ACJfBotZL3Yiih2l9xvT3k+jgS7PcReFMntiFUInN7AAbP8cew0hQp/hQPTn8VnrQEscL4dAmk9+ X-Received: by 10.28.127.132 with SMTP id a126mr7015018wmd.37.1515880671641; Sat, 13 Jan 2018 13:57:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515880671; cv=none; d=google.com; s=arc-20160816; b=HNKkCzw80LUliO/sDx5+82nujwUoxm3QWOiAtpBnUfAyuQ5+MsbSEEwd2gnyvsEjr1 0OCrbUhQIITYpEiDnbYpfeSOQm25oBOTjs2ENg97UmD2UWBkPZKe1aPuf2N764LRFa0t vxpSdI6gHyRoVH0Rwo4ZN46rgxqzwGJ45rdDQGuLw9AtEkQjDQzovb8spSYeAMY2ddQ6 qqZEmj2jwr/4FV96WxLfINArdOkUoAw5geGJkQ/Rq6jp8hTqo6z3IrpiXxmQofm1GeLd dPXEsB5yMms0f+xhQYZ+kiF2+ZGBdnYU/2EbmRuN2EHGBXETj3S+NrJG4i9tr+GY82h4 6Trw== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=drimRiFA3VoPyiPvFDylVOBWGT4QMj0FgJGF6Kh7OTI=; b=oaY0NFTzAQsFW98odVxgH97/23sW5fnZ7JzrnicqqDsyMFk8z84XFiETfum9EzzYFW rfCRiD8CD9+uuEMV4TLjcBUP4J3wMfJnYiqF6UlQIVy9FCYLLsAWFRl3Gtsi9totAhUG VFwgpm9Na4wTMGDVHesTUBZHCFqZz05P4Ggl6SYe0ZPrk6Fmn4ZtxfiyguH0qL9DoKZt c6xtHOHrcD07PAl1KumI665JKkWWgum2Rm0olN+Ggqswq/px2rWf6hndaShkTgtXdQQ6 7L0tOzOE6oSFKRXoATz1jbX0Q48yvfCoAIyqwyjhyiDPq0rZYBeKG/RckZEtG5c45K9Z AWxw== ARC-Authentication-Results: i=1; mx.google.com; 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 10si4313229wrx.425.2018.01.13.13.57.50; Sat, 13 Jan 2018 13:57:51 -0800 (PST) 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; 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 939F0689EC3; Sat, 13 Jan 2018 23:57:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC6D668993B for ; Sat, 13 Jan 2018 23:57:42 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D54C3E1B2F; Sat, 13 Jan 2018 22:57:43 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bdc78D9BwqZX; Sat, 13 Jan 2018 22:57:42 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B9548E1B22; Sat, 13 Jan 2018 22:57:42 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Jan 2018 22:57:37 +0100 Message-Id: <20180113215739.29913-1-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 Subject: [FFmpeg-devel] [PATCH 1/3] avfilter/vf_framerate: unify luma and chroma blending 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The expressions were mathematically equvivalent... Signed-off-by: Marton Balint --- libavfilter/vf_framerate.c | 60 ++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 45 deletions(-) diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c index a5ae6ddb71..583c96e02c 100644 --- a/libavfilter/vf_framerate.c +++ b/libavfilter/vf_framerate.c @@ -196,32 +196,16 @@ static int filter_slice8(AVFilterContext *ctx, void *arg, int job, int nb_jobs) cpy_src2_data += start * cpy_src2_line_size; cpy_dst_data += start * cpy_dst_line_size; - if (plane <1 || plane >2) { - // luma or alpha - for (line = start; line < end; line++) { - for (pixel = 0; pixel < cpy_line_width; pixel++) { - // integer version of (src1 * src1_factor) + (src2 + src2_factor) + 0.5 - // 0.5 is for rounding - // 128 is the integer representation of 0.5 << 8 - cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + (cpy_src2_data[pixel] * src2_factor) + 128) >> 8; - } - cpy_src1_data += cpy_src1_line_size; - cpy_src2_data += cpy_src2_line_size; - cpy_dst_data += cpy_dst_line_size; - } - } else { - // chroma - for (line = start; line < end; line++) { - for (pixel = 0; pixel < cpy_line_width; pixel++) { - // as above - // because U and V are based around 128 we have to subtract 128 from the components. - // 32896 is the integer representation of 128.5 << 8 - cpy_dst_data[pixel] = (((cpy_src1_data[pixel] - 128) * src1_factor) + ((cpy_src2_data[pixel] - 128) * src2_factor) + 32896) >> 8; - } - cpy_src1_data += cpy_src1_line_size; - cpy_src2_data += cpy_src2_line_size; - cpy_dst_data += cpy_dst_line_size; + for (line = start; line < end; line++) { + for (pixel = 0; pixel < cpy_line_width; pixel++) { + // integer version of (src1 * src1_factor) + (src2 + src2_factor) + 0.5 + // 0.5 is for rounding + // 128 is the integer representation of 0.5 << 8 + cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + (cpy_src2_data[pixel] * src2_factor) + 128) >> 8; } + cpy_src1_data += cpy_src1_line_size; + cpy_src2_data += cpy_src2_line_size; + cpy_dst_data += cpy_dst_line_size; } } @@ -235,7 +219,6 @@ static int filter_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs) uint16_t src1_factor = td->src1_factor; uint16_t src2_factor = td->src2_factor; const int half = s->max / 2; - const int uv = (s->max + 1) * half; const int shift = s->bitdepth; int plane, line, pixel; @@ -254,25 +237,12 @@ static int filter_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs) cpy_src2_data += start * cpy_src2_line_size; cpy_dst_data += start * cpy_dst_line_size; - if (plane <1 || plane >2) { - // luma or alpha - for (line = start; line < end; line++) { - for (pixel = 0; pixel < cpy_line_width; pixel++) - cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + (cpy_src2_data[pixel] * src2_factor) + half) >> shift; - cpy_src1_data += cpy_src1_line_size; - cpy_src2_data += cpy_src2_line_size; - cpy_dst_data += cpy_dst_line_size; - } - } else { - // chroma - for (line = start; line < end; line++) { - for (pixel = 0; pixel < cpy_line_width; pixel++) { - cpy_dst_data[pixel] = (((cpy_src1_data[pixel] - half) * src1_factor) + ((cpy_src2_data[pixel] - half) * src2_factor) + uv) >> shift; - } - cpy_src1_data += cpy_src1_line_size; - cpy_src2_data += cpy_src2_line_size; - cpy_dst_data += cpy_dst_line_size; - } + for (line = start; line < end; line++) { + for (pixel = 0; pixel < cpy_line_width; pixel++) + cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + (cpy_src2_data[pixel] * src2_factor) + half) >> shift; + cpy_src1_data += cpy_src1_line_size; + cpy_src2_data += cpy_src2_line_size; + cpy_dst_data += cpy_dst_line_size; } }