From patchwork Thu Sep 22 09:09:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 675 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp1314041vsd; Thu, 22 Sep 2016 02:09:23 -0700 (PDT) X-Received: by 10.194.140.77 with SMTP id re13mr1098355wjb.79.1474535363898; Thu, 22 Sep 2016 02:09:23 -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 ke3si830566wjb.240.2016.09.22.02.09.23; Thu, 22 Sep 2016 02:09:23 -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 31A7A689B5E; Thu, 22 Sep 2016 12:09: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 E2F30689898 for ; Thu, 22 Sep 2016 12:08:58 +0300 (EEST) Received: from localhost.localdomain (ip4d1666ad.dynamic.kabel-deutschland.de [77.22.102.173]) by btbn.de (Postfix) with ESMTPSA id 21202326CD0; Thu, 22 Sep 2016 11:09:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rothenpieler.org; s=mail; t=1474535354; bh=elwPyZ1bZ92itVzLZEBq+iq+vZX+RH0huC817Q/2d4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AkRsjMExE2/pw59RA3SGolcwPRw8sGqQd1wuF9TD7pm4eFv/EhYqDhMEPhLqG1V6P tMBjFoasbX7wu16Ao74g2gdDdh5Zi/ewDsD7bvhplvCHpM5luBRfyCdXuNeLq1y3XC Owd591xGqtGgYwp2sRMYiX8MoqORi2cKwtoWWNRs= From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Sep 2016 11:09:08 +0200 Message-Id: <20160922090908.13697-1-timo@rothenpieler.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160921210318.GG4975@nb4> References: <20160921210318.GG4975@nb4> Subject: [FFmpeg-devel] [PATCH] avformat/utils: force native h264 decoder 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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index a9bd034..05d2315 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -186,6 +186,18 @@ FF_ENABLE_DEPRECATION_WARNINGS return avcodec_find_decoder(codec_id); } +static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id) +{ +#if CONFIG_H264_DECODER + /* Other parts of the code assume this decoder to be used for h264, + * so force it if possible. */ + if (codec_id == AV_CODEC_ID_H264) + return avcodec_find_decoder_by_name("h264"); +#endif + + return find_decoder(s, st, codec_id); +} + int av_format_get_probe_score(const AVFormatContext *s) { return s->probe_score; @@ -2882,7 +2894,7 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt, (st->codecpar->codec_id != -st->info->found_decoder || !st->codecpar->codec_id)) { AVDictionary *thread_opt = NULL; - codec = find_decoder(s, st, st->codecpar->codec_id); + codec = find_probe_decoder(s, st, st->codecpar->codec_id); if (!codec) { st->info->found_decoder = -st->codecpar->codec_id; @@ -3379,7 +3391,7 @@ FF_ENABLE_DEPRECATION_WARNINGS if (st->request_probe <= 0) st->internal->avctx_inited = 1; - codec = find_decoder(ic, st, st->codecpar->codec_id); + codec = find_probe_decoder(ic, st, st->codecpar->codec_id); /* Force thread count to 1 since the H.264 decoder will not extract * SPS and PPS to extradata during multi-threaded decoding. */ @@ -3639,7 +3651,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st = ic->streams[stream_index]; avctx = st->internal->avctx; if (!has_codec_parameters(st, NULL)) { - const AVCodec *codec = find_decoder(ic, st, st->codecpar->codec_id); + const AVCodec *codec = find_probe_decoder(ic, st, st->codecpar->codec_id); if (codec && !avctx->codec) { if (avcodec_open2(avctx, codec, (options && stream_index < orig_nb_streams) ? &options[stream_index] : NULL) < 0) av_log(ic, AV_LOG_WARNING,