From patchwork Sun Oct 1 01:17:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pkv.stream" X-Patchwork-Id: 5355 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.61.8 with SMTP id n8csp65359jan; Sat, 30 Sep 2017 18:24:15 -0700 (PDT) X-Received: by 10.28.29.71 with SMTP id d68mr8286326wmd.114.1506821055336; Sat, 30 Sep 2017 18:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506821055; cv=none; d=google.com; s=arc-20160816; b=At8cZMBqBYpFVa1jLLI5a17fWOP7v1cjbbnOgwmaH5ZwiS3jhkQ2eJq8iEd8h05ZKU CL2h5htcGR83w1VRzmG4jbsXD0nBpC3Pvw2vNU5LBtGaA46+AnjdFBCiKhH9onTbw0U7 QEeZHcmcLLooj0JTPkrKZNv0411nVLJKPuJQwUyG+n2cxnul4sZLb8UPTCLsgOzBiDNr ru/zLOR+GsUNFQlOrUZff8SlOXlHt24o0ad6d1xoQM3BSDteLexZ7ajUPmm2Gbf09RS8 r0ToEpu09SV6aDPKG9rci//P6d1TzV9QMAg9D8BlNj0oaKKj8vlqFmNsyUeUejWhC4uI C5CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:mime-version:user-agent:date:message-id:from:to :dkim-signature:delivered-to:arc-authentication-results; bh=NIr2r8e9+2CfWEsZWiy3z6dMr5oNMJL25TWTNdt8IQY=; b=B1LJmCuNr75WsEe5iFLsq2yxipPYssqBjkKP/55DuWET3IK6p3G05aUCujJnY+kXW6 RiEIgD8hSJDVb94Ko6nZroxw2G2siHh4to1JICNkwB6hPZO9KM41gsUsLDS6cwgo2rUP cl21q5tkpyDgo2Drpmwewg8S7TASuEWlXoCjnweI4DDlCi4O1Et70+RyuVBWkKHqm40Q ZgJ7BQ3dKQlDI0spYO8+zQ9FCPddxf/YFe8CKo2fcgu+A0azRcKyosnnAtRj4y98xGjA ZJKXjKK2Q2ym7m22sDI26ANkreRo3k7L5FIY4a0FOHpG996Lj01Fa45CCg4TYKbmjLeV XEIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=rUG79uwH; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a66si5203335wma.270.2017.09.30.18.24.14; Sat, 30 Sep 2017 18:24:15 -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 header.s=20161025 header.b=rUG79uwH; 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 ADC2E689CE6; Sun, 1 Oct 2017 04:23:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 90EDF689D29 for ; Sun, 1 Oct 2017 04:23:53 +0300 (EEST) Received: by mail-wm0-f42.google.com with SMTP id q132so4878514wmd.2 for ; Sat, 30 Sep 2017 18:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=Yr/5wC0/BB+bEuM6dgMA0rJy/kSrztXymYbI1ObtyYA=; b=rUG79uwHoefZTJiPgG77I/LHPr0e3ozjTBAAgxgb9iGANikpmCwwfWI5wqpEbBm0lF ZJwOj8/SWZ8DiKNKEprXX39RIomywwHdK9ZMvqFoMaFT6RLR0ugZFB5ffiS5w8P2TDpB eaXmDkPonJsVAdjpZVinJj6L4HSvppDS6F0t1i7FKd0vBeWjoXTEjUXUvRtGcDu148MJ cCS6Tafghoc6cFrfke4HVpYbAPN2AwZy4qxNOBkygiEaeZcJvGCiUdVQYD6jTZnnQJvx Dlf96SJQij1xrROA6TrrZjGxho6gPnPHXAw8F2tgTjMj6/qxSlMCmwvTUCTgX9QxigJd dP5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=Yr/5wC0/BB+bEuM6dgMA0rJy/kSrztXymYbI1ObtyYA=; b=EfDIfez2nZaA9gVz/gIy+8xmKV0vv+KSBtLvCk5R5V7eXojELx0AsFnsycTSrtDy/6 3PlnfMDV4BlQSitJ+Qjovr2CgbsHlnFLOzgEE1PjGKrjZIZIkqe5jh/ZsDIPsPpBboku 4dfsA6Ayed5cM/JQV1X/raWVEqA3xOQJ6Besl8a1BzX5YS3aVMdK658I4PzVnBxRuaCK tpwY+2HVZttiz3JjQqCjO2oXGSbGRLEVbrqJ2vjXnxGZklZlNTznaj9pCG83TLAlyQgD APlzSUsL+I8LDRDvR6t6S4F6RECCgwuqmKvQfufcRGfqx7gOfIBzynZjkij8Hectk6qy t4og== X-Gm-Message-State: AHPjjUiRVkXoRpLGYaoyeI32wRMouvqpktJ4wMS5M5HetCB3wT1z3EZA F3dxu0SYaAQ/GxaJSOBJHAw8nQ== X-Google-Smtp-Source: AOwi7QDUj3wBG8GFFmq4k4BftTHAUGEvNSTIx19vVokohNCULRFlfEzBTAvd4QpHRbamhOcsvCvmxw== X-Received: by 10.80.174.168 with SMTP id e37mr14697873edd.297.1506820655221; Sat, 30 Sep 2017 18:17:35 -0700 (PDT) Received: from [192.168.0.2] ([176.159.7.188]) by smtp.googlemail.com with ESMTPSA id m1sm7550398edd.56.2017.09.30.18.17.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Sep 2017 18:17:34 -0700 (PDT) To: ffmpeg-devel@ffmpeg.org From: "pkv.stream" Message-ID: <8058ec17-1a5c-62e3-f07b-d3fabe18f8ed@gmail.com> Date: Sun, 1 Oct 2017 03:17:30 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Language: fr X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [DEVEL][PATCH] ffmpeg: fix channel_layout bug on non-default layout 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hello the submitted patch addresses the regression discussed in ticket #6706. The -channel_layout option is not working when the channel layout is not a default one (ex: for 4 channels, quad is interpreted as 4.0 which is the default layout for 4 channels; or octagonal interpreted as 7.1). This leads to the spurious auto-insertion of an auto-resampler filter remapping the channels even if input and output have identical channel layouts. Thanks for any comments. Regards From e8216768be2323659081fab7b391fed132d1c2d9 Mon Sep 17 00:00:00 2001 From: pkviet Date: Sat, 30 Sep 2017 01:29:48 +0200 Subject: [PATCH] ffmpeg: fix channel_layout bug on non-default layout Fix for ticket 6706. The -channel_layout option was not working when the channel layout was not a default one (ex: for 4 channels, quad was interpreted as 4.0 which is the default layout for 4 channels; or octagonal interpreted as 7.1). This led to the spurious auto-insertion of an auto-resampler filter remapping the channels even if input and output had identical channel layouts. The fix operates by directly calling the channel layout if defined in options. If the layout is undefined, the default layout is selected as before the fix. --- ffmpeg_opt.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 100fa76..c8dcf4d 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -1800,11 +1800,16 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); if (!ost->stream_copy) { - char *sample_fmt = NULL; + + char *sample_fmt = NULL; MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st); - MATCH_PER_STREAM_OPT(sample_fmts, str, sample_fmt, oc, st); + AVDictionaryEntry *output_layout = av_dict_get(o->g->codec_opts, "channel_layout",NULL, AV_DICT_MATCH_CASE); + if (output_layout) + ost->enc_ctx->channel_layout = _strtoui64(output_layout->value, NULL, 10); + + MATCH_PER_STREAM_OPT(sample_fmts, str, sample_fmt, oc, st); if (sample_fmt && (audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) == AV_SAMPLE_FMT_NONE) { av_log(NULL, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt); @@ -2524,7 +2529,10 @@ loop_end: (count + 1) * sizeof(*f->sample_rates)); } if (ost->enc_ctx->channels) { - f->channel_layout = av_get_default_channel_layout(ost->enc_ctx->channels); + if (ost->enc_ctx->channel_layout) + f->channel_layout = ost->enc_ctx->channel_layout; + else + f->channel_layout = av_get_default_channel_layout(ost->enc_ctx->channels); } else if (ost->enc->channel_layouts) { count = 0; while (ost->enc->channel_layouts[count])