From patchwork Fri Jul 6 14:15:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Gorzel X-Patchwork-Id: 9635 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp3069908jad; Fri, 6 Jul 2018 07:17:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeyIMwQDsVWyApsigQj88FGAQQW1KzjodKgTpETdqdenJbm32h8w3KI7n6+RqpBy4vJEd6U X-Received: by 2002:adf:ecc6:: with SMTP id s6-v6mr8214243wro.160.1530886674225; Fri, 06 Jul 2018 07:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530886674; cv=none; d=google.com; s=arc-20160816; b=UpPcO/aeQBo0Z74CCiOUHF5CclTgITqkhYRLJ7c6ZLdcOxXdFqxVhb534GnLNcINvK LKidOeFPPseUuqvWFPmNnj2gvNDXXUX6UOOk63SPEbBon2UchdFB/ZuMq135AAunU1WX xWgWvo4dWMseybdIU7oDM/ApmSRyLgX4105y1J4q3jv68GmjuWYKgExIvmgGhm8MCNYU lsUmeEkfXOYJpP0YEJYrOrV0mVIHGCoGUlYDsQGfuUdxlJZhyhhgjOd1jzX+AQobVkYr E4Yz6/EteJToFCnL6ATbq2ox+hjdPV9iDAMTyl/EabV6xH/p6Nhk7XhAnVy5RX9/ry5O 9kHQ== 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:message-id:date:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=6KmMI+9P4AWAd2BHS2OtpA4hu1PDAR3OEthjrcM7S74=; b=ejBYsAx0iEVcSgy02wlU2mpIeTfMfmBMrPpaepBTET3pdmq8RsQrIrwuUzvCZxwLEh mC7Pr88eK2jnmnhhhVjlVcQiXy7APISfIcw0ZkqdWyGl0K92Vh/5zzWUtJczyOwpqg9g w6ap9m7/Goqghwzq87duaL809Ay0Ibv0dvw/jBeKyw86s8+XU6LROOKx0oi6ZWACmrjG U9WDmC+x9sSdSzLupEpu5LBdO4rlrmFrBVGsjWMSiMzuXnmozRo02jD0/I6QvB/sU7bK V7gV3afq62BXCnAxL9Dvfont+JKUXAxnpX+lSDo8+tXzDCsrd16zbaGTdzYcbcKcJMHh OsoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=V9JE0tu9; 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 m17-v6si7040844wro.325.2018.07.06.07.17.53; Fri, 06 Jul 2018 07:17:54 -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=V9JE0tu9; 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 1F2B368A507; Fri, 6 Jul 2018 17:17:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f202.google.com (mail-io0-f202.google.com [209.85.223.202]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D520368976F for ; Fri, 6 Jul 2018 17:17:39 +0300 (EEST) Received: by mail-io0-f202.google.com with SMTP id s19-v6so9831868iog.0 for ; Fri, 06 Jul 2018 07:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:message-id:subject:from:to:cc :content-transfer-encoding; bh=jAn0r07LIdqabdbKzGAkmAiiJTjUjo+popr8WCm65XE=; b=V9JE0tu9YoxqRC7IBVbcDiQ1RKTbBGSeRFb8Xwecfl7yuYemVIbnJ4ivVlWT9gJL6t 2Q1jcYivmuUFEoOSSi9PZtPrJDKRJzqoW99yeRMFuyLC5jB+bEaOO2xuQfMbQzBpLhl+ 6uoa4MV0hp6bX0N7fZLEv6W91eMqwOXLFGfq3KI/1sJV3KoaLIfVyVMBnFvHMh+IkT93 Nxv4CeiQBWfd9HEEMqv7SwbwwEPQ2TjPZ9D6CurSkG4QbjOvusCQPifysbZNgCdhnXTP R5nMrJLedrPRt4fnaZUze8GXSxRfTskBW9MWQutxvsRluKMmv4u8zRi0/go7y4zirIZN iSoQ== 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:message-id:subject:from:to:cc :content-transfer-encoding; bh=jAn0r07LIdqabdbKzGAkmAiiJTjUjo+popr8WCm65XE=; b=Fs7euK0CKJVSsaUOdG44pl6Bt+1oKmYaZrePkWhv1T4W6q+TcW/AagHRe3ChTtlID5 HlFWAGHfJuGPSbrNTh0uJahxZLdHx16OWFbZ+D0dFHpcTDQoEvaV5i6ZjDC0m68UCpCg NhvgzzvkBaJYie4yuNgJDTARTUq1JKMtvKfKAHs6Hdtvok5Pbs5vPeL2/oBcCkZl/0tP iqvYxD6IRjuktlnUjv8QaYQe61utAF0FclYjdf1LU2zOvJXu6UdHnuyZh6xTmaKSq2NL Ej7ld+MEqc5xQbW3aOZfPmtUtzEZST9Il6BRSpaSjpWZWicDvlwZjf6za9EsirBVkFkw GIMg== X-Gm-Message-State: APt69E2YdTXZVTPZLktCERVII/y3JyZnRmmTpE4p7W0zYzgIyRBPCWhI 3CdrUWxVKDzpK0ypW9jffVlnWQt3EwZ5W73kBboJMY+aDlG52xmdBhfgEL+hAhi88z6ShS0HOP0 uHmrAgW1gW4Tpm+TPZ/EfLVIbQoOcX1y01GWg8sH1ChpR6HJNZhSUrrlmoJ90t/8= MIME-Version: 1.0 X-Received: by 2002:a24:2f05:: with SMTP id j5-v6mr4376393itj.37.1530886662860; Fri, 06 Jul 2018 07:17:42 -0700 (PDT) Date: Fri, 6 Jul 2018 15:15:58 +0100 Message-Id: <20180706141557.95983-1-gorzel@google.com> X-Mailer: git-send-email 2.18.0.399.gad0ab374a1-goog From: Marcin Gorzel To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] 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 but there is only a limited number of channel layouts defined. Currently, in/out channel count is obtained from the channel layout so if the channel layout is undefined (e.g. for 9, 10, 11 channels etc.) the in/out channel count will be 0 and the rematrixing will fail. This change adds a check if the channel layout is non-zero, and if not, prefers to use the in|out_ch_count instead. This seems to be related to ticket #6790. --- 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..45e84eb2df 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) + : FFMIN(s->user_in_ch_count, SWR_CH_MAX); + nb_out = s->user_out_ch_layout != 0 + ? av_get_channel_layout_nb_channels(s->user_out_ch_layout) + : FFMIN(s->user_out_ch_count, SWR_CH_MAX); 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) + : FFMIN(s->user_in_ch_count, SWR_CH_MAX); + int nb_out = s->out_ch_layout != 0 + ? av_get_channel_layout_nb_channels(s->out_ch_layout) + : FFMIN(s->user_out_ch_count, SWR_CH_MAX); s->mix_any_f = NULL; diff --git a/libswresample/x86/rematrix_init.c b/libswresample/x86/rematrix_init.c index d71b41a73e..f3363567cd 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) + : FFMIN(s->user_in_ch_count, SWR_CH_MAX); + int nb_out = s->out_ch_layout != 0 + ? av_get_channel_layout_nb_channels(s->out_ch_layout) + : FFMIN(s->user_out_ch_count, SWR_CH_MAX); int num = nb_in * nb_out; int i,j;