From patchwork Wed Mar 22 15:41:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 3065 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp368072vsy; Wed, 22 Mar 2017 08:42:24 -0700 (PDT) X-Received: by 10.223.135.245 with SMTP id c50mr4600097wrc.41.1490197344473; Wed, 22 Mar 2017 08:42:24 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c14si2737469wrd.188.2017.03.22.08.42.23; Wed, 22 Mar 2017 08:42:24 -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=@gmail.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0A875689760; Wed, 22 Mar 2017 17:41:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D0A868972D for ; Wed, 22 Mar 2017 17:41:49 +0200 (EET) Received: by mail-qt0-f193.google.com with SMTP id n37so25813073qtb.3 for ; Wed, 22 Mar 2017 08:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=4Ghbr40W6kypZsEGQwGto4/NA680zqrgwnACJOrlGvM=; b=kIFnVz5Kmdj6dLISGJW62J9N1SFF0mXcPBAfvxpThzCihhWe69tyDlJlDMNxk2ibbB aol1KxUAfY5eZ5zLYluHeUA4Dd1aeTqinfkV1ZOuW7MSKkBB0wQ0qhFsFpRBpaE0GnEy elvLRwCQamAQr8+ORwW8LGoyl+zWB079BEBh6Sda1bSb52I/Nfsk7tR2QkHP1P4kvQpv 1HosH07X/0FwVt0bmfM6+S8Rj/zlrj4wn4uKlj3WJChYqOmsTUlK1qsm2kG3dvCiFFyd cQbTkNaJ0GJZgzMFcgpznOLZuPwsIAg56iXxw4TM56fUtdoqxJwLuTyN/VZ6f66U010c h8LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=4Ghbr40W6kypZsEGQwGto4/NA680zqrgwnACJOrlGvM=; b=fQ6Vz0b9LLY8Fe+jIUPs+t4MY5OIjy+DnenpjlteHtUqrBiW18Z6ig45lKyODizoc/ CTSy8fRdY2xDkBvbe1lmvHuLuVybG1UrSAywmAp8ewkR0Wcy1/Cn1/FAbL4yX06soF05 nYLzrD1GdAy6SzDBxq5PzhA4ZrBXySfXpqRHI9Xwks2A6rox5kwVwYDAJCT8Yb0f1As5 txl/o1po67DZ34ohZbNO1GNx5R/7soYlBOcyZz/lLDcj3Xc5OcHM/b6JxjZ29GWSqZMB b/SPJImKxClBk+jkXiTkClSmK9HeDiibdgycUXCIcpXikD/lKEMFQJ7mE4afZlX7uxxs b0ag== X-Gm-Message-State: AFeK/H1u4UYi3YuiJKenYfKmX9oUWgBUjH6nSo4TGepiWxRGs9FLrlN+GkJ+F+BlQtWVTw== X-Received: by 10.237.40.2 with SMTP id r2mr42762053qtd.74.1490197326918; Wed, 22 Mar 2017 08:42:06 -0700 (PDT) Received: from localhost.localdomain ([181.231.62.139]) by smtp.gmail.com with ESMTPSA id v4sm1217887qtg.0.2017.03.22.08.42.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Mar 2017 08:42:06 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Mar 2017 12:41:26 -0300 Message-Id: <20170322154126.7424-2-jamrial@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170322154126.7424-1-jamrial@gmail.com> References: <20170322154126.7424-1-jamrial@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/ac3dsp: add special-case handling for the C downmix_fixed function 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- libavcodec/ac3dsp.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c index 74f9e3caae..43438da131 100644 --- a/libavcodec/ac3dsp.c +++ b/libavcodec/ac3dsp.c @@ -279,6 +279,49 @@ static void ac3_downmix_c(float **samples, float **matrix, } } +static void ac3_downmix_5_to_2_symmetric_c_fixed(int32_t **samples, int16_t **matrix, + int len) +{ + int i; + int64_t v0, v1; + int16_t front_mix = matrix[0][0]; + int16_t center_mix = matrix[0][1]; + int16_t surround_mix = matrix[0][3]; + + for (i = 0; i < len; i++) { + v0 = (int64_t)samples[0][i] * front_mix + + (int64_t)samples[1][i] * center_mix + + (int64_t)samples[3][i] * surround_mix; + + v1 = (int64_t)samples[1][i] * center_mix + + (int64_t)samples[2][i] * front_mix + + (int64_t)samples[4][i] * surround_mix; + + samples[0][i] = (v0+2048)>>12; + samples[1][i] = (v1+2048)>>12; + } +} + +static void ac3_downmix_5_to_1_symmetric_c_fixed(int32_t **samples, int16_t **matrix, + int len) +{ + int i; + int64_t v0; + int16_t front_mix = matrix[0][0]; + int16_t center_mix = matrix[0][1]; + int16_t surround_mix = matrix[0][3]; + + for (i = 0; i < len; i++) { + v0 = (int64_t)samples[0][i] * front_mix + + (int64_t)samples[1][i] * center_mix + + (int64_t)samples[2][i] * front_mix + + (int64_t)samples[3][i] * surround_mix + + (int64_t)samples[4][i] * surround_mix; + + samples[0][i] = (v0+2048)>>12; + } +} + static void ac3_downmix_c_fixed(int32_t **samples, int16_t **matrix, int out_ch, int in_ch, int len) { @@ -307,6 +350,24 @@ static void ac3_downmix_c_fixed(int32_t **samples, int16_t **matrix, void ff_ac3dsp_downmix_fixed(AC3DSPContext *c, int32_t **samples, int16_t **matrix, int out_ch, int in_ch, int len) { + if (c->in_channels != in_ch || c->out_channels != out_ch) { + c->in_channels = in_ch; + c->out_channels = out_ch; + c->downmix_fixed = NULL; + + if (in_ch == 5 && out_ch == 2 && + !(matrix[1][0] | matrix[0][2] | + matrix[1][3] | matrix[0][4] | + (matrix[0][1] ^ matrix[1][1]) | + (matrix[0][0] ^ matrix[1][2]))) { + c->downmix_fixed = ac3_downmix_5_to_2_symmetric_c_fixed; + } else if (in_ch == 5 && out_ch == 1 && + matrix[0][0] == matrix[0][2] && + matrix[0][3] == matrix[0][4]) { + c->downmix_fixed = ac3_downmix_5_to_1_symmetric_c_fixed; + } + } + if (c->downmix_fixed) c->downmix_fixed(samples, matrix, len); else