From patchwork Wed Mar 8 12:40:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wm4 X-Patchwork-Id: 2834 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp1008272vsy; Wed, 8 Mar 2017 04:40:26 -0800 (PST) X-Received: by 10.28.69.194 with SMTP id l63mr5248461wmi.23.1488976826018; Wed, 08 Mar 2017 04:40:26 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 94si4236431wrf.7.2017.03.08.04.40.25; Wed, 08 Mar 2017 04:40:25 -0800 (PST) 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 sp=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 C181C68829C; Wed, 8 Mar 2017 14:40:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B44EF688269 for ; Wed, 8 Mar 2017 14:40:02 +0200 (EET) Received: by mail-wm0-f65.google.com with SMTP id u132so5848144wmg.1 for ; Wed, 08 Mar 2017 04:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Aona7yd3QaUwoCQDkLcap1ftA2PFcKRCHgKYJDOsrxg=; b=gqPmkmgAuynhXfD/LkOLQBjZDU0YdluzkmTFflT3Mv1WVVtHQw9aK9OVZPb3e5uOhp wXWHyTPmTurNGgDuPPAAhnBkM3OGCIjTAhwuRMeboqI0l5oELdRsvv+NnTjzF3ggHTgi 6PVPGMedC2Op3XyvrkapNBYyPHztGN1x572cVjK8r8Uq51JVdYsSSBnKDmkRY5+XvezE 3mwcsnrzDNHgCnh5H1F9lowRkdyDL/FCr+gZ1rPdWfSHFUXKZMbow48Sm/LTJ4aoE+nq oxP0xorHLTuBhdbk+K1P5oYPDFb7mirJKKbcYXVyfFfIgrwnVEjoNMZdYi5p7J6TOcZ+ 7YOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Aona7yd3QaUwoCQDkLcap1ftA2PFcKRCHgKYJDOsrxg=; b=JArYkzIQ3vA3f8nHT4FZnMs3WMC/Dq5eOngS4/SB5dw5FZ56vT110JoZFU79xUmkHk kuVex+Esd3EUHSr2RcMZv5izoz/ouLqZGW9Juira7+Jf/YGexpScqk2nKk7mr8hn5b9d ol0h9RMChzJSZ8NfyuXWjQWiPhztXgNhJtFKf+07XDcjITsmEvAlRiaJ71cXghTZrf2A DojdDcJWJ+XrzekW8JSiIX8MuvXCCfW7ayg6NRwFa7EJTIL9h5qFNHFp1OIhMxWPkP7Y da9i6MdHC3nMTwxffqirEqUoj5C6TIANT+awwZmtcSlOPaIHUGxsj3TdwM9ws83eW8KK nc8Q== X-Gm-Message-State: AMke39n6KelWpvSmNAodYFmdXMJllhxVQSN+wCOj/vYfmcpcN4GrIalZQSJV2hX+XebwsQ== X-Received: by 10.28.133.84 with SMTP id h81mr11543827wmd.23.1488976815836; Wed, 08 Mar 2017 04:40:15 -0800 (PST) Received: from localhost.localdomain (p4FF02688.dip0.t-ipconnect.de. [79.240.38.136]) by smtp.googlemail.com with ESMTPSA id 198sm4581948wmn.11.2017.03.08.04.40.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Mar 2017 04:40:15 -0800 (PST) From: wm4 To: ffmpeg-devel@ffmpeg.org Date: Wed, 8 Mar 2017 13:40:10 +0100 Message-Id: <20170308124012.27793-1-nfxjfg@googlemail.com> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH 1/3] aacdec: do not mutate input packet metadata 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: wm4 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Apparently the demuxer outputs the wrong padding for HE-AAC (based on the raw sample rate, or so). aacdec contains a hack to adjust the muxer padding accordingly before it's used to trim the decoder output. This modified the packet side data, which in combination with the old decoding API would change the packet the user passed to the decoder. This is clearly not allowed, and it breaks running some gapless fate tests with "-fflags +keepside" applied (without keepside, the packet metadata is typically newly allocated, essentially making a copy and not modifying the user's input packet). This should probably be fixed in the demuxer (and consequently also the muxer), but for now only fix the immediate problem. Regression since 946ed78f5f8 (2012). --- libavcodec/aacdec_template.c | 8 ++------ libavcodec/internal.h | 2 ++ libavcodec/utils.c | 4 +++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 4367e74cf7..98a3240597 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -3095,12 +3095,8 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, ac->oc[1].status = OC_LOCKED; } - if (multiplier) { - int side_size; - const uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); - if (side && side_size>=4) - AV_WL32(side, 2*AV_RL32(side)); - } + if (multiplier) + avctx->internal->skip_samples_multiplier = 2; if (!ac->frame->data[0] && samples) { av_log(avctx, AV_LOG_ERROR, "no frame data found\n"); diff --git a/libavcodec/internal.h b/libavcodec/internal.h index c92dba472a..e3286d2a58 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -174,6 +174,8 @@ typedef struct AVCodecInternal { AVFrame *buffer_frame; int draining_done; int showed_multi_packet_warning; + + int skip_samples_multiplier; } AVCodecInternal; struct AVCodecDefault { diff --git a/libavcodec/utils.c b/libavcodec/utils.c index db3adb18d4..3c8a9cc13e 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1305,6 +1305,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code goto free_and_end; } + avctx->internal->skip_samples_multiplier = 1; + if (codec->priv_data_size > 0) { if (!avctx->priv_data) { avctx->priv_data = av_mallocz(codec->priv_data_size); @@ -2387,7 +2389,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); if(side && side_size>=10) { - avctx->internal->skip_samples = AV_RL32(side); + avctx->internal->skip_samples = AV_RL32(side) * avctx->internal->skip_samples_multiplier; discard_padding = AV_RL32(side + 4); av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n", avctx->internal->skip_samples, (int)discard_padding);