From patchwork Thu Sep 22 16:44:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 680 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp107726vsd; Thu, 22 Sep 2016 09:44:25 -0700 (PDT) X-Received: by 10.28.139.145 with SMTP id n139mr9501330wmd.125.1474562665542; Thu, 22 Sep 2016 09:44:25 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t9si2813246wjf.106.2016.09.22.09.44.23; Thu, 22 Sep 2016 09:44:25 -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=@rothenpieler.org; 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 2D9D5689D0F; Thu, 22 Sep 2016 19:44:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from btbn.de (btbn.de [5.9.118.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A87AE689A44 for ; Thu, 22 Sep 2016 19:43:59 +0300 (EEST) Received: from localhost.localdomain (ip4d1666ad.dynamic.kabel-deutschland.de [77.22.102.173]) by btbn.de (Postfix) with ESMTPSA id 835EA32646F; Thu, 22 Sep 2016 18:44:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rothenpieler.org; s=mail; t=1474562655; bh=yzBGUtZSBmaia1uxeEJVvgYgKkGBL2ixWKfwDWDqOAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tkAuSV2dKvBGNekiTnLBD8JcFz48TkYKJ8hGNrYto/K8XigQqRvoLRjcD4v/kqv9c jchXZzPAgJMqap1IXXpPO8fsKNEurJlNMa/5JOdedq0VrEgB/5MUF7yQoHS1yiVGQs Fg6oGoU+S+zU6UH2+F5o/Ovh5yffDggDMyP+2wpg= From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Sep 2016 18:44:09 +0200 Message-Id: <20160922164409.5860-1-timo@rothenpieler.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160922144806.GM4975@nb4> References: <20160922144806.GM4975@nb4> Subject: [FFmpeg-devel] [PATCH] avformat/utils: avoid using marked decoders for probing 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: Timo Rothenpieler MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/utils.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 05d2315..93ea6ff 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -188,6 +188,8 @@ FF_ENABLE_DEPRECATION_WARNINGS static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id) { + const AVCodec *codec; + #if CONFIG_H264_DECODER /* Other parts of the code assume this decoder to be used for h264, * so force it if possible. */ @@ -195,7 +197,22 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, return avcodec_find_decoder_by_name("h264"); #endif - return find_decoder(s, st, codec_id); + codec = find_decoder(s, st, codec_id); + if (!codec) + return NULL; + + if (codec->capabilities & AV_CODEC_CAP_AVOID_PROBING) { + const AVCodec *probe_codec = NULL; + while (probe_codec = av_codec_next(probe_codec)) { + if (probe_codec->id == codec_id && + av_codec_is_decoder(probe_codec) && + !(probe_codec->capabilities & (AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_EXPERIMENTAL))) { + return probe_codec; + } + } + } + + return codec; } int av_format_get_probe_score(const AVFormatContext *s)