From patchwork Fri Jun 2 21:10:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 3805 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.10.2 with SMTP id 2csp372716vsk; Fri, 2 Jun 2017 14:10:31 -0700 (PDT) X-Received: by 10.28.136.85 with SMTP id k82mr701707wmd.55.1496437831706; Fri, 02 Jun 2017 14:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496437831; cv=none; d=google.com; s=arc-20160816; b=hijCct8hwAL4zxy+3eOfkp/v2mCwC5z9em0nXdS/Wi+KgU1zoYmPsiOe6gRkABm1Li JqPmgEGAigLSgVP1l06sAhI04Cvr8+krh6yi+mXdH00GOfikCj5VenxbjdC87qOsWZaO NhRCfWRG60d5GciuXgQGTgyLPu0STI/+a4vy/gM70TTf1aEWbzgZvWzqzSKj3hHqf9N3 iT67L2pvtPBJbnSFZIgum55VdTLzue7ANgcEN7xvhuN+D9yY+5wqMWFV8czM+gUqRMCU pEZxeIwkPWP2qwrTBsgTa4x0YQe//uHj2qvgn2R5JkYqqjoumTzT7tDBnDOqYVtv8ji8 sLUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=MMqwPaHkniS77o/C6HvYAlxA2oVNsDxhs9P+xjDeR8k=; b=FLNIBkhjGbl7UZ4rCSFuWWeOQxRzntgSsoUs+MmYUf1DtHVrqizxst8RtPh0SveBSo cFX9eVYyqpfSyapsQxJA6hdXqg+VQf9LNUkA37ONjTb3H/VdXDdmb/Izdi/enJJxvPO1 NWOXruC6waTzukfI/VSlNEihYbEE0DGvljr0dWeWWHWKqEliIMUBTFXYD0ZU9fS2ydqH vDXk8mBdXTZux5JeXQF99mE9M+ZDi7ks1nDBwniNMVPfgy0NyK5uguvZdjQeAsxxaCbR dx4f95qwbi41GI8FupWukKtfQ3HNZ/bzqqm9DkjpN14xqGCwCIXAlb9RgsSDBN0uoeb5 fTOA== ARC-Authentication-Results: i=1; mx.google.com; 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 g198si3764669wme.43.2017.06.02.14.10.30; Fri, 02 Jun 2017 14:10:31 -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; 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 0607A688355; Sat, 3 Jun 2017 00:10:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 22A536804FA for ; Sat, 3 Jun 2017 00:10:15 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5B26E1031A7; Fri, 2 Jun 2017 23:10:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CgwlEadORFhm; Fri, 2 Jun 2017 23:10:18 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 928B4102EDA; Fri, 2 Jun 2017 23:10:18 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 2 Jun 2017 23:10:13 +0200 Message-Id: <20170602211014.4257-1-cus@passwd.hu> X-Mailer: git-send-email 2.12.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/utils: return impaired streams in av_find_best_stream if only those exist 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes ticket #6397. Signed-off-by: Marton Balint --- libavformat/utils.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index fbd8b58ac2..b544b6f9c5 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4097,7 +4097,9 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, AVCodec **decoder_ret, int flags) { int i, nb_streams = ic->nb_streams; - int ret = AVERROR_STREAM_NOT_FOUND, best_count = -1, best_bitrate = -1, best_multiframe = -1, count, bitrate, multiframe; + int ret = AVERROR_STREAM_NOT_FOUND; + int best_count = -1, best_bitrate = -1, best_multiframe = -1, best_disposition = -1; + int count, bitrate, multiframe, disposition; unsigned *program = NULL; const AVCodec *decoder = NULL, *best_decoder = NULL; @@ -4116,10 +4118,6 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, continue; if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb) continue; - if (wanted_stream_nb != real_stream_index && - st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED | - AV_DISPOSITION_VISUAL_IMPAIRED)) - continue; if (type == AVMEDIA_TYPE_AUDIO && !(par->channels && par->sample_rate)) continue; if (decoder_ret) { @@ -4130,13 +4128,16 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, continue; } } + disposition = !(st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED | AV_DISPOSITION_VISUAL_IMPAIRED)); count = st->codec_info_nb_frames; bitrate = par->bit_rate; multiframe = FFMIN(5, count); - if ((best_multiframe > multiframe) || - (best_multiframe == multiframe && best_bitrate > bitrate) || - (best_multiframe == multiframe && best_bitrate == bitrate && best_count >= count)) + if ((best_disposition > disposition) || + (best_disposition == disposition && best_multiframe > multiframe) || + (best_disposition == disposition && best_multiframe == multiframe && best_bitrate > bitrate) || + (best_disposition == disposition && best_multiframe == multiframe && best_bitrate == bitrate && best_count >= count)) continue; + best_disposition = disposition; best_count = count; best_bitrate = bitrate; best_multiframe = multiframe;