From patchwork Wed Nov 22 13:32:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pkv.stream" X-Patchwork-Id: 6269 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp178933jah; Wed, 22 Nov 2017 05:37:48 -0800 (PST) X-Google-Smtp-Source: AGs4zMakzeTD4DKimMyfjuVr2ZvzR5uZK5I7hhNMsixcEByDxlu3YpngD8AZwlB1TzRE78Pl2KY/ X-Received: by 10.223.169.68 with SMTP id u62mr16900779wrc.30.1511357868696; Wed, 22 Nov 2017 05:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511357868; cv=none; d=google.com; s=arc-20160816; b=EpESaUy164MxPh9JmmN/ftl4eEgQjD7TnDF0Pvls10ulXSQZJ/wC4RsCV7nV+N/QVt dIu/dDWprLSquc4QDHM1v3tVKGg78r/JaqtT4xh0QxU9npq90fpRHQpM+55+oMtAcGdE xCBH0nGnaOmBB7iqU8X3lKuo5e2/jRtXsfDF5p95oEGNfqixdSDZwZ18hedHg3C7Keji Td/UVFlabg5qgnsrHxVzc5raKLimnBXLhS0FYSaUrvg9UU+qKsF8wDe50rvdYicWc7Dg 5GUjmoBN45bYvZsZCVslzN93zeBxo+65knabNsHTEdhqXCTj5p5W95uAtjjSBpwDSk7h Zhdg== 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:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:dkim-signature:delivered-to :arc-authentication-results; bh=b309ro5YUuw84OUSOKU4dj7ZeR7PECMNKIRZzRlCBko=; b=AdRcxqTOfTExKNT6mJPDv/DwZO5yC2IuXBNQEcgeotD5KpyNQU92+VgSBgAszAkx6Z pgx/EfA+GRUXqLrEXF2aE+ITUSZOIAkIuMTAN5C6guHCkp81c6XMr6eOzW8CO+9ty8qD fLOmsgFCso1x3DqzaJGqGh2BD1R7A+53CtB3ILjYJkwISFs1PVyp7Xuog1XNBjhC/y/2 iXDOkcBbst05e+h2tsA3cSnIF5LR8d2dYIuE5BYLbsku98JGMSo+3FnW0ByD6YsIcp2I J7JSPO4SMZKQ3VNdUO/jNLxnt2T2eWUU/StIk83HSctP/Pj8rzyujfQRAUwlihXfzzBM 1Q1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=LnjvpSIX; 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 d41si13610724wrd.251.2017.11.22.05.37.48; Wed, 22 Nov 2017 05:37:48 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=LnjvpSIX; 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 03D0E68A15C; Wed, 22 Nov 2017 15:37:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A77F68A0FD for ; Wed, 22 Nov 2017 15:37:41 +0200 (EET) Received: by mail-lf0-f47.google.com with SMTP id x76so13644951lfb.6 for ; Wed, 22 Nov 2017 05:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=tDIx47OYYJqpU7IxtYoF6ZZAZLBccZ6pGOnLh56Qmcw=; b=LnjvpSIXLV3heo8IsOtxRk761bujQRSmiXgnXkmABvlmCkAxBcxRLCIKRoq06kal6A 8OEzNceJhcXWzJlVNDofLfDYEItN0TU+lRDEmyNygth6KZNlpIFDjExbmKopItcaVNWz 5YPrcbu/aZcGR1FGLh77kYlFDJKc450Dwgfzp2P+a3OurDS4GHm8q66kJ3MazlNcatSY bjiIFwlSbzOAE/sFvXWWK1KVthtvyWYaNnWiHoVhlPDAHG+By4Ivz4FiiRXJxHgh+rBx qOm0r1LnYEqNJPwsSSzXp+nGQ0ES7eVZMCv6HJxrQNtqCiU5hZoVAQhizCAxVtrwIiEy 8uZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=tDIx47OYYJqpU7IxtYoF6ZZAZLBccZ6pGOnLh56Qmcw=; b=Vt9jZXQwA6Zs8AoUvhDgY1rINaYrsNPbOiohYLDzZsNZwG0uxPfUV4+FVB+MN4SuBz 4vjgwnVs2fb6VjiNPttTs7e1MmP51M91S7fL1q1wfjgosFWPEjLxt4jSN4KB2nb4owl2 9ueTWOT0zzf78VJ7Ca29ya27e01EMvM2TbXx8MOGTLHWt6La9UNvdISMFm7y+VMWFlZn J+CaK0RcX2mZdEr2CvfeMnSrpqxKz1naafmjuvb6U1NL7V+wTFNyeBTeE1YanOLCx62s ebmmdWl8jHtmGd58DhrjrVSAyH6TOid5fvkH8bOtJz9Na6MM+8MqtApZjye8ZLTHA+qY NW9A== X-Gm-Message-State: AJaThX44nImOVkak0R1OCo9WoYm6bbSbl8w3KmWUhsOMPUb0BAlaC+T0 ytltJ2xiNDzlmY4Bqkh05Y8x7g== X-Received: by 10.25.178.139 with SMTP id t11mr1028116lfk.13.1511357540049; Wed, 22 Nov 2017 05:32:20 -0800 (PST) Received: from [192.168.0.100] ([176.159.7.188]) by smtp.googlemail.com with ESMTPSA id f99sm2832864lfi.77.2017.11.22.05.32.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Nov 2017 05:32:19 -0800 (PST) To: ffmpeg-devel@ffmpeg.org References: <20171112160048.GQ6009@nb4> <20171112163827.GT6009@nb4> <19c44254-1279-b685-3f46-0f03b2fa7a07@gmail.com> <20171114121355.GB6009@nb4> <16cfbba9-053d-0958-0042-6487d93301e9@gmail.com> <20171116014847.GT6009@nb4> <148ce8f6-476b-a8b1-a7ae-d44cd2e44316@gmail.com> <20171118202649.GC4903@nb4> <425f2195-fc3d-9325-df02-796dae5289e3@gmail.com> <20171119192842.GB4645@nb4> From: "pkv.stream" Message-ID: Date: Wed, 22 Nov 2017 14:32:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171119192842.GB4645@nb4> Content-Language: fr Subject: [FFmpeg-devel] [DEVEL][PATCH 2/2] ffmpeg: fix ticket 6706 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" From 532b13fb2a174af0b91a0b08984cbdb8d5027392 Mon Sep 17 00:00:00 2001 From: pkviet Date: Sat, 18 Nov 2017 00:26:50 +0100 Subject: [PATCH 2/2] ffmpeg: fix ticket 6706 Fix regression with channel_layout option which is not passed correctly from output streams to filters when the channel layout is not a default one. Signed-off-by: pkviet --- fftools/ffmpeg.h | 3 +++ fftools/ffmpeg_opt.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index e0977e1..5c45df4 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -121,6 +121,8 @@ typedef struct OptionsContext { int nb_frame_sizes; SpecifierOpt *frame_pix_fmts; int nb_frame_pix_fmts; + SpecifierOpt *channel_layouts; + int nb_channel_layouts; /* input options */ int64_t input_ts_offset; @@ -624,6 +626,7 @@ extern int vstats_version; extern const AVIOInterruptCB int_cb; extern const OptionDef options[]; +extern const OptionDef channel_layout_option[]; extern const HWAccel hwaccels[]; extern AVBufferRef *hw_device_ctx; #if CONFIG_QSV diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index f66f672..6da53aa 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1818,6 +1818,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in char *sample_fmt = NULL; MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st); + MATCH_PER_STREAM_OPT(channel_layouts, ui64, audio_enc->channel_layout, oc, st); MATCH_PER_STREAM_OPT(sample_fmts, str, sample_fmt, oc, st); if (sample_fmt && @@ -2542,7 +2543,11 @@ 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]) @@ -3119,7 +3124,7 @@ static int opt_channel_layout(void *optctx, const char *opt, const char *arg) char layout_str[32]; char *stream_str; char *ac_str; - int ret, channels, ac_str_size; + int ret, channels, ac_str_size, stream_str_size; uint64_t layout; layout = av_get_channel_layout(arg); @@ -3131,12 +3136,30 @@ static int opt_channel_layout(void *optctx, const char *opt, const char *arg) ret = opt_default_new(o, opt, layout_str); if (ret < 0) return ret; + stream_str = strchr(opt, ':'); + stream_str_size = (stream_str ? strlen(stream_str) : 0); + /* set duplicate 'channel_layout' option in SpecifierOpt, + * enabling access to channel layout through MATCH_PER_STREAM_OPT + */ + ac_str_size = 22 + stream_str_size; + ac_str = av_mallocz(ac_str_size); + if (!ac_str) { + return AVERROR(ENOMEM); + } + av_strlcpy(ac_str, "channel_layout", 22); + if (stream_str) { + av_strlcat(ac_str, stream_str, ac_str_size); + } + ret = parse_duplicate_option(o, ac_str, layout_str, options); + av_free(ac_str); + if (ret < 0) { + return ret; + } /* set 'ac' option based on channel layout */ channels = av_get_channel_layout_nb_channels(layout); snprintf(layout_str, sizeof(layout_str), "%d", channels); - stream_str = strchr(opt, ':'); - ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0); + ac_str_size = 3 + stream_str_size; ac_str = av_mallocz(ac_str_size); if (!ac_str) return AVERROR(ENOMEM); @@ -3689,6 +3712,9 @@ const OptionDef options[] = { { "channel_layout", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_channel_layout }, "set channel layout", "layout" }, + { "channel_layout", OPT_AUDIO | HAS_ARG | OPT_INT64 | OPT_SPEC | + OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(channel_layouts) }, + "set channel layout with uint64", "layout_uint64" }, // allows storage of option in SpecifierOpt { "af", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_filters }, "set audio filters", "filter_graph" }, { "guess_layout_max", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(guess_layout_max) },