From patchwork Thu Jan 18 00:03:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 7314 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp6223934jaa; Wed, 17 Jan 2018 16:03:41 -0800 (PST) X-Google-Smtp-Source: ACJfBovoKsICxM1HYoJlEazx4oq+8d6er4MfPVhaZ3/t5D3nGmB6GkpzPzoJyoJj1kTSH+Zba7Zu X-Received: by 10.223.129.227 with SMTP id 90mr4192941wra.148.1516233821064; Wed, 17 Jan 2018 16:03:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516233821; cv=none; d=google.com; s=arc-20160816; b=kBY45YfRUgNW1VqcWqZCwGI3o9kVkQnH6WNWmnWu+ay2bwrbcARkyNC6DM5xkyl0PQ ZnK3ij5TGUqJT5q5YEqLUWgBy357t4fGPKrSq4s+1Q+RDBRb897PYQ4Z280ts6SXBkUu SGRpfFHqJ61oEzDj6FgE5EYE7XjVvdHFXRvnLLpuhYlgQsyk92ZAdmOqzrKbi+ImfBup vwXNlfX5YUWaTh5xgRZysvB9UXlqaK+s6hvvFzSdWcZnGZwW1uefXWAxPn2e9kbA82dt z2ZQJEJeflasfyWMlkY1jyCJGHDvNw4l8beeAwQB09JY8+bKAkbBalLEtPhPUsjk3md3 M3mw== 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=REHpsfAumpa//0euhA/ciuDGHz6Tqhgw/tf26a5cqCDFXa7MoRvvyKZCYklYAT/NLY o1sx8sRy83oNiK2KURZFdET6Ha7bQBt60wFh5xd0Dw2tcEwMhD8glWT8rGCRQWC46B/w x2TCL26zDL+EHGWab45vSDEb5bn4y5wzw7qJISp6FpyUsIvxw7x8uDCPJBYBARZIMBWy wGw2HQGL74xPL16dJUfFKQIyW9qmlkJvRXVYAXz1Q/jQWeMgsGze8rnxDTCcMgv33ZCb rPeoFweGTxZrL13NyhtrRS4+IBshd2d9bJNX7A9Sv3j8M38bcKfzkZAwRlLc9/kSaZlT L/eQ== 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 q14si4639353wrc.14.2018.01.17.16.03.39; Wed, 17 Jan 2018 16:03:41 -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 B397E689C8B; Thu, 18 Jan 2018 02:03:38 +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 8FE24680159 for ; Thu, 18 Jan 2018 02:03:37 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 658EBE1B66; Thu, 18 Jan 2018 01:03:37 +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 3fCXkHA40uWV; Thu, 18 Jan 2018 01:03:36 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1697EE1AFF; Thu, 18 Jan 2018 01:03:36 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Jan 2018 01:03:29 +0100 Message-Id: <20180118000332.31119-1-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 Subject: [FFmpeg-devel] [PATCH 1/4] 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; } }