From patchwork Tue Feb 21 09:59:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 2625 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.149 with SMTP id x21csp312171vsf; Tue, 21 Feb 2017 01:59:26 -0800 (PST) X-Received: by 10.223.139.220 with SMTP id w28mr19751600wra.172.1487671165907; Tue, 21 Feb 2017 01:59:25 -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 l74si15790125wmg.126.2017.02.21.01.59.25; Tue, 21 Feb 2017 01:59: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=@gmail.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=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2C5456882DC; Tue, 21 Feb 2017 11:59:14 +0200 (EET) 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 0310868829A for ; Tue, 21 Feb 2017 11:59:08 +0200 (EET) Received: by mail-wm0-f67.google.com with SMTP id r18so18733265wmd.3 for ; Tue, 21 Feb 2017 01:59:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=dkP47dnaJ3elBFElZm7HGMih3kkodvvkgwHDcxCytrc=; b=oRuEHKd6CKOV4r2ol2sVZiu7nhMslCVbYW9I9PluvDs2uPSzZKiwEXFTQl8CFQgL2j lrIlaGNgAfhVm+WMHyqxNHf83yAUVumTFzmSuJWR77ToRjF+WjwZfe9Hiw5socPxc1Pi YV4pb7D/5tUlUbZhHVQL2PJFhMBEkNsSVvwpCkxyCuheGsZUgkeOXfBXeidzLYyiJo7/ 4vV0SDUbIXLAf2y5pzYABeRREM2ZCSswodqv2Lx4goEoNpKG2D4vVz8VZMJSdDnlzjYF 6k9y48bXJuOZDu3w9Dy3GWBOyzcvXvcImZsSKbTbOZdy0oo1xUO8VtsTAc8c5+nmJDFa FDHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=dkP47dnaJ3elBFElZm7HGMih3kkodvvkgwHDcxCytrc=; b=Y3p6yiDmINeI5oI0ylHZpA52E1+KqxmFbvBGAKkbFbn4OQmK+p1mF33sE3NneFxl75 Ha9PP1FH8Fr367FqzmdEraS3hJJ/jW7HlBOzmlFu78+85WPdMkZvrORpgXZHmvRXwGT5 z6Dw6gh7kgUuD/Q1nwg6yW5VUtnCdPFsA35cwKaER3GT/zupAq+UyW68AJNt/OtuRrTf A1VKEStXmDAsV/YUocNNrI6LGXoEYm9M6nYQxnmaT77lLuLd5KGq+T+K7b70bUzB5nMq 9uwh2uS/3siGJZtKjuJNJCSBJHgkDsJaPmtFdlptPnKcfJ8l6xgcNqws3C+dK38KmKUw RAsA== X-Gm-Message-State: AMke39nmqHTOIDvSq0sPSAvx0KF8dpDdT2ZEIlr9JJzxFWeft3kJYwSvyi3dUHOmB2Ou1g== X-Received: by 10.28.130.212 with SMTP id e203mr12892445wmd.104.1487671155463; Tue, 21 Feb 2017 01:59:15 -0800 (PST) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id d1sm28276923wrb.62.2017.02.21.01.59.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 01:59:13 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Feb 2017 10:59:00 +0100 Message-Id: <20170221095900.2635-1-onemda@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH] avcodec/amrnbdec: fix handling of NO_DATA frames 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes #1849. Signed-off-by: Paul B Mahol --- libavcodec/amrnbdec.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index ea299ac..e75df23 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -101,6 +101,7 @@ typedef struct AMRContext { AMRNBFrame frame; ///< decoded AMR parameters (lsf coefficients, codebook indexes, etc) uint8_t bad_frame_indicator; ///< bad frame ? 1 : 0 enum Mode cur_frame_mode; + enum Mode prev_frame_mode; int16_t prev_lsf_r[LP_FILTER_ORDER]; ///< residual LSF vector from previous subframe double lsp[4][LP_FILTER_ORDER]; ///< lsp vectors from current frame @@ -188,6 +189,7 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx) ff_acelp_vectors_init(&p->acelpv_ctx); ff_celp_filter_init(&p->celpf_ctx); ff_celp_math_init(&p->celpm_ctx); + p->prev_frame_mode = NO_DATA; return 0; } @@ -960,6 +962,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, float spare_vector[AMR_SUBFRAME_SIZE]; // extra stack space to hold result from anti-sparseness processing float synth_fixed_gain; // the fixed gain that synthesis should use const float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use + int consumed; /* get output buffer */ frame->nb_samples = AMR_BLOCK_SIZE; @@ -969,8 +972,14 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, p->cur_frame_mode = unpack_bitstream(p, buf, buf_size); if (p->cur_frame_mode == NO_DATA) { - av_log(avctx, AV_LOG_ERROR, "Corrupt bitstream\n"); - return AVERROR_INVALIDDATA; + p->cur_frame_mode = p->prev_frame_mode; + if (p->cur_frame_mode == NO_DATA) { + av_log(avctx, AV_LOG_ERROR, "Corrupt bitstream\n"); + return AVERROR_INVALIDDATA; + } + consumed = 1; + } else { + consumed = frame_sizes_nb[p->cur_frame_mode] + 1; // +7 for rounding and +8 for TOC } if (p->cur_frame_mode == MODE_DTX) { avpriv_report_missing_feature(avctx, "dtx mode"); @@ -1075,8 +1084,10 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, *got_frame_ptr = 1; + p->prev_frame_mode = p->cur_frame_mode; + /* return the amount of bytes consumed if everything was OK */ - return frame_sizes_nb[p->cur_frame_mode] + 1; // +7 for rounding and +8 for TOC + return consumed; }