From patchwork Fri Jul 13 11:43:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Gorzel X-Patchwork-Id: 9713 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp657416jad; Fri, 13 Jul 2018 04:43:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpexFqd2IGX5GudvNdL5Z1MUC9tx4N3vFzwzSMhf+Z2MBBGjqLcT1smj0dFfPf6As+LRn6bI X-Received: by 2002:a5d:4acc:: with SMTP id y12-v6mr4378278wrs.132.1531482231494; Fri, 13 Jul 2018 04:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531482231; cv=none; d=google.com; s=arc-20160816; b=1FSSCK5F5M+rmk5teZ0jMvg5Xz4IfblKTFvtvmMLTgPgRYAJCk29YbDlqnsCsGnyTI dXpEcntMpdgBqCN3tsTC5FuEQF6vumYmff4B2l+ysxoqMcd0ff829EqH4y9M2hmMiO2a SdNkCKTE7mIr8QhmOTeD5F8s7oCB5Be5V+gc4qUUjZGghdbugc8/aBw5EAnqwxSl+K+d Dr7TD08XzAXvoF8khj8OEilV+Hm+WtjHqowFrni0YNk5vvBYIiRMAg2gKk55VlPnVPjp YqDSW8tut/o42wrWErkOa9zWpfNzc7EsFox3V6GzJeDpJHwwtdP2+9mrVN0gVEk9Cujv ECuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:from:references:message-id :in-reply-to:date:mime-version:dkim-signature:delivered-to :arc-authentication-results; bh=Dz7VDC8U36oA2IaoWjdOLvNiqqj29iW315Y/nXYJdSE=; b=j8yVDEZI66ZkUpVLF8HyB6S67y6xBu86S5FFUO+LvlGV0Y6X+UIO6ucQV1wgxBa3Vw 1lzDKvnqLgAuB/nmprHf51a7qXNobhm/o2Y6kRVvENzQL8l0ZylfBvrSik6Xcxiy2LX3 i5bh2b/tc54rpXCnYzQXGffMT7dpSjO1vJWw96TvDr+0PaJQGv58HsZ+RGWcH41mVgAP cy7dc5VSrXEtCtEyXLQdnl6Je3/zbSmSYJY8o/SmtfMxWmtiIgitpx68f1BiSGvPiN9h Vk1lM1CEdFyQfEdE2hyn/lx3A9QWH8nu7iQhUqnPHzALuksWxhk3WE8mjTDM7u7KN3Lj ml0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=IUp0U8yc; 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 15-v6si5856628wrt.437.2018.07.13.04.43.51; Fri, 13 Jul 2018 04:43:51 -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=@google.com header.s=20161025 header.b=IUp0U8yc; 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 4755568A59F; Fri, 13 Jul 2018 14:43:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f201.google.com (mail-io0-f201.google.com [209.85.223.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4F4A468A3D5 for ; Fri, 13 Jul 2018 14:43:34 +0300 (EEST) Received: by mail-io0-f201.google.com with SMTP id i18-v6so27450636iog.12 for ; Fri, 13 Jul 2018 04:43:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:in-reply-to:message-id:references:subject:from:to :cc:content-transfer-encoding; bh=fyoMCSA+mrO27vOwd8aR0cUXQRgIb4nkISjTzFVXass=; b=IUp0U8ycr5XEDBEk+UQ7SdvmnsEzYA+IAABPnMfkN9DXd3KLoER4AzfoUPBz+/XC2r NdUkdRTemCaKJUUnIvxwxkamfr+gVXgvN6exrE+0j+OkKjEo4KRKzXr6AUnknscWr30Q HYv4JrgBaBjfIIbUyNnbkRjcurcmwHtmdNBbh3A+J+/KzvqjtBNg5TLnl3SeZ+/Q+KtG UKzGO6Zyog9OB9WSV+M0Zp067VyZn9sD9OsCzPDClbIt9koQ1iULjkBmlqxL/NHDsFKG 7t5qOrb9l51435p4HrwrcayhB0vcPsSWJSpA9eW/qNQTGGxCQ3EuS6x74UpRcvWwbAxe ihkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc:content-transfer-encoding; bh=fyoMCSA+mrO27vOwd8aR0cUXQRgIb4nkISjTzFVXass=; b=QIlb2xJ17iqV8Bit0kkGa3IRxF9v/ueLRsMzxFRsvdhc+RQnD6GioJO4yj1ivlke31 +VAM7S8GMMsx4yhhfc7NU+ntfMw2JbXaV6F4dzwiDwIRsGGrKuvL/NxHTA/rITmQR3wt dyWmj6vbthvNhlVxf96cHXJi3IcblgUjCBSrOLfIxSydswtN7a+YzvojtsT6Mm5m9l6J VxTvrqTR66UyI+93WoUbEuZsqG4NGPBe5NWQdwsoRlcunIIGWaKmX568i53JFK435ohN jYVsoVCE9WdDtRIzCtlAGtVokPLhXBG2Sy6UT3b3YA85+C/dwA8//gIVX9Fntc8gJTmw 2Dqw== X-Gm-Message-State: AOUpUlGlAsjJxjKsXZ2azB6D5Xz21VNmdUprdrrXmNjArWxR9GNGK9T4 y1g2KC9UZRV6TSlrhzwA7gzKdrL93WWrLzgLlGdl1/b383AskJcgc2u+u+w2flUe/CewXnoFOok 2eYPWjsETTyDCX4myTbJRcI7txN0TDndHYab5HiTFsWoO96id6aE80nhpLm0dWMA= MIME-Version: 1.0 X-Received: by 2002:a6b:8864:: with SMTP id k97-v6mr2452846iod.129.1531482221482; Fri, 13 Jul 2018 04:43:41 -0700 (PDT) Date: Fri, 13 Jul 2018 12:43:36 +0100 In-Reply-To: Message-Id: <20180713114336.224847-1-gorzel@google.com> References: X-Mailer: git-send-email 2.18.0.203.gfac676dfb9-goog From: Marcin Gorzel To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] libswresample: Use channel count if channel layout is undefined 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: Marcin Gorzel Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Rematrixing supports up to 64 channels. However, there is only a limited number of channel layouts defined. Since the in/out channel count is obtained from the channel layout, for undefined layouts (e.g. for 9, 10, 11 channels etc.) the rematrixing fails. In ticket #6790 the problem has been partially addressed by applying a patch to swr_set_matrix() in rematrix.c:72. However, a similar change must be also applied to swri_rematrix_init() in rematrix.c:389 and swri_rematrix_init_x86() in rematrix_init.c:36. This patch adds the following check to the swri_rematrix_init() in rematrix.c:389 and swri_rematrix_init_x86() in rematrix_init.c:36: if channel layout is non-zero, obtain channel count from the channel layout, otherwise, use channel count instead. It also modifies the checks in swr_set_matrix() in rematrix.c:72 to match the above checks. (Since av_get_channel_layout_nb_channels(s->user_in_ch_layout) was originally used, there may be preference to rely on the channel layout first (if available) before falling back to the user channel count). --- libswresample/rematrix.c | 18 ++++++++++++------ libswresample/x86/rematrix_init.c | 8 ++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 8227730056..8c9fbf3804 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -69,10 +69,12 @@ int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride) return AVERROR(EINVAL); memset(s->matrix, 0, sizeof(s->matrix)); memset(s->matrix_flt, 0, sizeof(s->matrix_flt)); - nb_in = (s->user_in_ch_count > 0) ? s->user_in_ch_count : - av_get_channel_layout_nb_channels(s->user_in_ch_layout); - nb_out = (s->user_out_ch_count > 0) ? s->user_out_ch_count : - av_get_channel_layout_nb_channels(s->user_out_ch_layout); + nb_in = s->user_in_ch_layout != 0 + ? av_get_channel_layout_nb_channels(s->user_in_ch_layout) + : s->user_in_ch_count; + nb_out = s->user_out_ch_layout != 0 + ? av_get_channel_layout_nb_channels(s->user_out_ch_layout) + : s->user_out_ch_count; for (out = 0; out < nb_out; out++) { for (in = 0; in < nb_in; in++) s->matrix_flt[out][in] = s->matrix[out][in] = matrix[in]; @@ -384,8 +386,12 @@ av_cold static int auto_matrix(SwrContext *s) av_cold int swri_rematrix_init(SwrContext *s){ int i, j; - int nb_in = av_get_channel_layout_nb_channels(s->in_ch_layout); - int nb_out = av_get_channel_layout_nb_channels(s->out_ch_layout); + int nb_in = s->in_ch_layout != 0 + ? av_get_channel_layout_nb_channels(s->in_ch_layout) + : s->user_in_ch_count; + int nb_out = s->out_ch_layout != 0 + ? av_get_channel_layout_nb_channels(s->out_ch_layout) + : s->user_out_ch_count; s->mix_any_f = NULL; diff --git a/libswresample/x86/rematrix_init.c b/libswresample/x86/rematrix_init.c index d71b41a73e..a6ae074926 100644 --- a/libswresample/x86/rematrix_init.c +++ b/libswresample/x86/rematrix_init.c @@ -33,8 +33,12 @@ D(int16, sse2) av_cold int swri_rematrix_init_x86(struct SwrContext *s){ #if HAVE_X86ASM int mm_flags = av_get_cpu_flags(); - int nb_in = av_get_channel_layout_nb_channels(s->in_ch_layout); - int nb_out = av_get_channel_layout_nb_channels(s->out_ch_layout); + int nb_in = s->in_ch_layout != 0 + ? av_get_channel_layout_nb_channels(s->in_ch_layout) + : s->user_in_ch_count; + int nb_out = s->out_ch_layout != 0 + ? av_get_channel_layout_nb_channels(s->out_ch_layout) + : s->user_out_ch_count; int num = nb_in * nb_out; int i,j;