From patchwork Wed Apr 26 10:16:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Faiz X-Patchwork-Id: 3496 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp251081vsd; Wed, 26 Apr 2017 03:22:36 -0700 (PDT) X-Received: by 10.28.63.148 with SMTP id m142mr5182464wma.98.1493202156555; Wed, 26 Apr 2017 03:22:36 -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 s18si12662906wrc.28.2017.04.26.03.22.35; Wed, 26 Apr 2017 03:22:36 -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=@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 A60266882D1; Wed, 26 Apr 2017 13:22:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 31B0C68066D for ; Wed, 26 Apr 2017 13:22:25 +0300 (EEST) Received: by mail-pf0-f196.google.com with SMTP id g23so15877532pfj.1 for ; Wed, 26 Apr 2017 03:22:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Pxl6HIJRDfJG6FHMxPnclZMbDMJ6z8ELXPx40jqnWDc=; b=N5hC+XvPDxa6fT+aXpPTMn4CcG8pW78AyjidFovNGeG3EFDA6wav9HbZJh5yCCV4NO HKcwqokLF16YqbSTZzEk544nQ56j7dDlhTiQK04A7vaACQXJY8ZUEhNExNWA/gXl1ydN De18pWLahp4mMalHbJm1z/styq819haUnapKgQT0PIeKet5R/8wcpJVep+eUVWYmzBZa 9dk5P/OS1UGcmrfmq+slDqrinKlC+L698/6R/LbqUBtnPHKs/DIjDnJeChocwgs2lA6u yMWQn2D0cGVfSTIHSGg38ePW8A5FddttohjhvNtUdOHWePA2WKrJMsJuBbWWEqdqIAGr fWdA== 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=Pxl6HIJRDfJG6FHMxPnclZMbDMJ6z8ELXPx40jqnWDc=; b=iYnMB3He/ffVmG+YZ9V77a6xWlai0LcjSTq0VlX8dXOm+cS1pWSQnaB6SqMSN8WUxk Ihv/PIvtyOoveZtAWGOcSR29ZYRC1ayNnB09D3TW+4OI/Rm94c4/V/rTHqNjFxC6cCMw gugCqMxVdLb43TsxKuzlAaetH3HuQSCrFsgnn67NypaJaK/Jz8TyjE5SHG+yrzPWqQu/ xoXPJaU5tZi6VCorRTsoY90Z5oeCXJaDUi09ebh13FrlTfofYWObfelZPWtPkJUrLPQV gjra06HECZsLx/fkfB8FMPJiIz3zIqhvBVWaSt/a7UZS4yMr4XRU/8kvTcTYkgFP6YI/ QedQ== X-Gm-Message-State: AN3rC/7efaGuG2FhRKTARS9R6IUIp/ZcZj5/swz+Cp0S/EJx7hfuZjT7 Binls/qfCGu7Hw== X-Received: by 10.98.89.213 with SMTP id k82mr31943441pfj.196.1493201782644; Wed, 26 Apr 2017 03:16:22 -0700 (PDT) Received: from localhost.localdomain ([114.124.148.0]) by smtp.gmail.com with ESMTPSA id n85sm41435473pfi.101.2017.04.26.03.16.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Apr 2017 03:16:22 -0700 (PDT) From: Muhammad Faiz To: ffmpeg-devel@ffmpeg.org Date: Wed, 26 Apr 2017 17:16:05 +0700 Message-Id: <20170426101605.7014-1-mfcc64@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH] avcodec/libmp3lame: properly handle unaligned frame data 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: Muhammad Faiz MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This should fix Ticket6349 Since 383057f8e744efeaaa3648a59bc577b25b055835, framequeue may generate unaligned frame data. Signed-off-by: Muhammad Faiz --- libavcodec/libmp3lame.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 5e26743..cd505bb 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -203,15 +203,20 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ENCODE_BUFFER(lame_encode_buffer_int, int32_t, frame->data); break; case AV_SAMPLE_FMT_FLTP: - if (frame->linesize[0] < 4 * FFALIGN(frame->nb_samples, 8)) { - av_log(avctx, AV_LOG_ERROR, "inadequate AVFrame plane padding\n"); - return AVERROR(EINVAL); - } for (ch = 0; ch < avctx->channels; ch++) { + if (frame->linesize[0] < 4 * FFALIGN(frame->nb_samples, 8) || 0x1F & (intptr_t)(frame->data[ch])) { + float *src = (float *) frame->data[ch]; + float *dst = s->samples_flt[ch]; + int k; + + for (k = 0; k < frame->nb_samples; k++) + dst[k] = src[k] * 32768.0f; + } else { s->fdsp->vector_fmul_scalar(s->samples_flt[ch], (const float *)frame->data[ch], 32768.0f, FFALIGN(frame->nb_samples, 8)); + } } ENCODE_BUFFER(lame_encode_buffer_float, float, s->samples_flt); break;