From patchwork Thu May 30 14:03:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 13344 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6162F4468A0 for ; Thu, 30 May 2019 17:05:28 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 49AAD68A791; Thu, 30 May 2019 17:05:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-3.mx.upcmail.net (vie01a-dmta-pe06-3.mx.upcmail.net [84.116.36.16]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A03B68A701 for ; Thu, 30 May 2019 17:05:18 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.91) (envelope-from ) id 1hWLgD-0002Qn-2t for ffmpeg-devel@ffmpeg.org; Thu, 30 May 2019 16:05:17 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id WLfEhW9fF5D5NWLfEh9yNj; Thu, 30 May 2019 16:04:16 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.41.20 X-CNFS-Analysis: v=2.3 cv=bu8y+3Si c=1 sm=1 tr=0 a=I1eytVlZLDX1BM2VTtTtSw==:117 a=I1eytVlZLDX1BM2VTtTtSw==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=gwKL8U396iXolCuaGSAA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 30 May 2019 16:03:57 +0200 Message-Id: <20190530140400.6205-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CMAE-Envelope: MS4wfE1vfttvujNH/ZU3vosoa23vKHLxBlay+2ogU/hTf9+uKHEQdqB15Sj3cVyfPb9BkhxsjiH0u2heDAiGyxx/IrmVaIV+3LZUedPfO29GbFyrjwrsrKrn GInG17ohKTk2SVQO1ViQ8BN/5OTuLOrpQxRe7nNSioyQ2l0zZPr8ZnuC Subject: [FFmpeg-devel] [PATCH 1/4] swresample/swresample: Support unspecified sample rate when it is not needed 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" Signed-off-by: Michael Niedermayer --- libswresample/swresample.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 1ac5ef9a30..f1decb600a 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -164,6 +164,11 @@ av_cold int swr_init(struct SwrContext *s){ return AVERROR(EINVAL); } + if (s->in_sample_rate == 0 && s->out_sample_rate == 0) + s->in_sample_rate = 1; + if (s->in_sample_rate == 0 || s->out_sample_rate == 0) + s->in_sample_rate = s->out_sample_rate = s->in_sample_rate + s->out_sample_rate; + if(s-> in_sample_rate <= 0){ av_log(s, AV_LOG_ERROR, "Requested input sample rate %d is invalid\n", s->in_sample_rate); return AVERROR(EINVAL);