From patchwork Fri Oct 21 23:16:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Cadhalpun X-Patchwork-Id: 1108 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp1265162vsd; Fri, 21 Oct 2016 16:16:11 -0700 (PDT) X-Received: by 10.28.175.2 with SMTP id y2mr4967557wme.106.1477091771601; Fri, 21 Oct 2016 16:16:11 -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 q8si576596wme.18.2016.10.21.16.16.10; Fri, 21 Oct 2016 16:16:11 -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=@googlemail.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; dmarc=fail (p=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 92CD9689BFA; Sat, 22 Oct 2016 02:16:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33415689BE5 for ; Sat, 22 Oct 2016 02:15:59 +0300 (EEST) Received: by mail-wm0-f67.google.com with SMTP id o81so773727wma.2 for ; Fri, 21 Oct 2016 16:16:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to; bh=7nuJeS1/8Obg9x9tV2G47dZ0rp6B47nVOWzGZzG/dT0=; b=xKTqYjfgUscLaX4ZXcYfYvJRGNZ74thCQ0DjDQZgxQkW3HOOZVpipdFq9p7O6scsOd 2i4BBfOaxrD/yf5X+nycbszjqM8gy2WkMIJmqDF6KJgdwbR5uKo8j6Y7Q/udmSTngeuj QUpGgO0QccUsRqN50/PuAt5U7AEj2FpggDIVzZzyfsjfSbLbX1lt2u1+8N+0gd70Gc94 ZtY+Lc6adfJPspvFN+rbZKQrZj6JtCVZtj5KPsvsf2HUE33W+kiMGCQrEE5OnLuD0J3r ZsrKrEqzvfKVcK4IPWZCSXSGtxLmnva2AoNJaeIC6XGqGFnwHowOBqZMfyU4OlaQ01wq cmtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to; bh=7nuJeS1/8Obg9x9tV2G47dZ0rp6B47nVOWzGZzG/dT0=; b=iK6kWTD/XLKwLwDMz1/bdIr+pCYSr6D4lxjX5fGRNo4+tKPWBFB+Dk1VDk63QBXkVq ySLhhyIhWPgxX3NoEpMNdlul7ujQ3/54a9KdSqwcKBULlms07JyS4gaW1YdYVH7+Ur2k 3lKA5okyjHSTZ4MmLl2V9qPhsYN5jxpcn3HLbKietsmg7m8ejBcglk/snAPnPcgjj3fK Kj+qrBcwt1AOdtnO63h2MW5unk+dnadUbtnyzTd0Z5vjR93ObHJ1d45JEsPZKHmZoFbJ y+vmKzW7SfqwRuItvoL/HxDzamcWrsyMhBOFoaN4jyP9mrvsq6t4cJfz2YsFIh/R9wwH Taog== X-Gm-Message-State: ABUngvcPvGI1K06dQkl/k+bWV7IVXLXRxZrbdOeTxNcM5HOzRVMiQXk9fRSk24NJ7l7rJw== X-Received: by 10.194.20.231 with SMTP id q7mr2857725wje.57.1477091761676; Fri, 21 Oct 2016 16:16:01 -0700 (PDT) Received: from [192.168.2.21] (pD9E8E92D.dip0.t-ipconnect.de. [217.232.233.45]) by smtp.googlemail.com with ESMTPSA id kq7sm5235643wjb.0.2016.10.21.16.16.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Oct 2016 16:16:01 -0700 (PDT) From: Andreas Cadhalpun X-Google-Original-From: Andreas Cadhalpun To: ffmpeg-devel@ffmpeg.org References: <3f06de83-f054-4b7a-18e1-3ce1234c04d9@googlemail.com> <20161021221804.GL4602@nb4> Message-ID: <37e48e5d-d5bc-e321-ed93-b37759c472e8@googlemail.com> Date: Sat, 22 Oct 2016 01:16:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161021221804.GL4602@nb4> Subject: Re: [FFmpeg-devel] [PATCH] avformat: close parser if codec changed 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" On 22.10.2016 00:18, Michael Niedermayer wrote: > On Mon, Oct 17, 2016 at 08:49:23PM +0200, Andreas Cadhalpun wrote: >> The parser depends on the codec and thus must not be used with a different one. >> If it is, the 'avctx->codec_id == s->parser->codec_ids[0] ...' assert in >> av_parser_parse2 gets triggered. >> >> Signed-off-by: Andreas Cadhalpun >> --- >> libavformat/utils.c | 12 ++++++++++++ >> 1 file changed, 12 insertions(+) > > This changes the audio output from > http://samples.ffmpeg.org/MPEG2/vid_0x80.ts > > is that intended ? Nice catch: it shouldn't change, of course. While processing that sample only the codec_tag gets changed, which is no reason to close the parser. That is only necessary, when the codec_id changes. Fixed patch is attached. Best regards, Andreas From 9de87a4fb2c6c6311a11a2da5de8554a71adfa66 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Mon, 17 Oct 2016 20:26:51 +0200 Subject: [PATCH] avformat: close parser if codec changed The parser depends on the codec and thus must not be used with a different one. If it is, the 'avctx->codec_id == s->parser->codec_ids[0] ...' assert in av_parser_parse2 gets triggered. Signed-off-by: Andreas Cadhalpun --- libavformat/utils.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavformat/utils.c b/libavformat/utils.c index 70dbfa1..a8a78ed 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -480,6 +480,12 @@ static int update_stream_avctx(AVFormatContext *s) if (!st->internal->need_context_update) continue; + /* close parser, because it depends on the codec */ + if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) { + av_parser_close(st->parser); + st->parser = NULL; + } + /* update internal codec context, for the parser */ ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar); if (ret < 0) @@ -1515,6 +1521,12 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) st->info->found_decoder = 0; } + /* close parser, because it depends on the codec */ + if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) { + av_parser_close(st->parser); + st->parser = NULL; + } + ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar); if (ret < 0) return ret; -- 2.9.3