From patchwork Sat Mar 10 14:02:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Bramini X-Patchwork-Id: 7888 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.181.170 with SMTP id m39csp2114854jaj; Sat, 10 Mar 2018 06:03:08 -0800 (PST) X-Google-Smtp-Source: AG47ELu6JDjCH/4fS0ovpNyRNevhkA3CIlE2IcjGnEYfsMygodGuAzzP8lucDNREGHnHwi9RMzJs X-Received: by 10.28.22.208 with SMTP id 199mr1302045wmw.79.1520690588207; Sat, 10 Mar 2018 06:03:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520690587; cv=none; d=google.com; s=arc-20160816; b=Rh2BTcVmsCAwOQVTA37ojER/HcRw/GqbYrGvLHPFDan1T+vYuRXN8Z0pA0mVJ2/Ilw FF9b8LevEA87inLhfl6Tn9eT34BoyaeRxe+RWsT5viuiED/m+RekJ+J29+6X9M+TNRIn wtO9vS+5gLE4M57v8LPURNlaN4fRX+pwNw9TMLLNIKfobyhOwbx8fIVu4WAaA9Zafs4q zOg3U47m3pTBhCm0bxzkreGx8BHr62n8bl+8XxjEW0mxS0vY0titlrsgPPp0o/DltUog L3nXgkY4CjjSHhVaEbFPobwj8saUOSnd3JEPPuOXV6rtQ02nGYWhN0ROhgSUVEb+fWJB lKlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:importance :mime-version:message-id:to:from:date:dkim-signature:delivered-to :arc-authentication-results; bh=4IHyxVf55PI6WfMc6kwYuKVxlXAoKRk6OdQzqrNPEdU=; b=Sr3OJpuWjJ+IP4OqjnT7rbUCXVBByKhwKfw+OLRogaF0PNPOhUj7eQWelyjvpFqF7P soj8bnsNotuyhH1w8z8F2duGDZKsmTr6cBSufLAb9qr6Fnb95oWhEV0vwXwObjM5I1QK FQeRO9law96dXO1c2a0l55zqGYDlZYJAdJYlF1DDxRwwU+jsjQRx9c1Sv9hzdG1rNsEB 04TNX++D1LgMRWekJuwcJNq6yTEmmn1Q2AHPRAyQrDALnnFw6xJxBss4TwIHJhF7nZZ0 rYhxYS+ulR6HiQjs8pErUeLsnYDmH004QEcrYY6xrTBWMiOsCRD4M8cIiR4VxBksGth4 Ul8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@libero.it header.s=s2014 header.b=qC58SEqR; 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=libero.it Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p1si2587248wrg.398.2018.03.10.06.03.05; Sat, 10 Mar 2018 06:03:07 -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=@libero.it header.s=s2014 header.b=qC58SEqR; 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=libero.it Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AA77668A518; Sat, 10 Mar 2018 16:02:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from libero.it (smtp-32-i2.italiaonline.it [213.209.12.32]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9661F68A258 for ; Sat, 10 Mar 2018 16:02:48 +0200 (EET) Received: from oxapps-16-093.iol.local ([10.101.8.103]) by smtp-32.iol.local with SMTP id uf5MeqKajhHnYuf5MesrBG; Sat, 10 Mar 2018 15:02:56 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2014; t=1520690576; bh=eCoEfTGgXQaNdxeBGy4ow4JNCNoREuV3YcPnjT131e4=; h=Date:From:To:Subject; b=qC58SEqRGOxXrypP/Rzi2fq9RH8bnsF0IZTSjHyjn1MrpMlUppftBA1NoiwtQQKcK VlOyYgkBBzZyW4bh1rndHPzwycOS78oZyK0FWowVT7tsx85kCqYVQlptaPMnOyUcAF W560u2MuBjwjo2i+UHnrg/DyjIQaS+Di1ak0FiIfFpavqcugV51ftbVzmnJ41+WS3g rft2m+AOv4xF3wmu4sD6ZlYwNZRk0cCsPGUT2PvyvWzrujVA3KfpmIDFJuFVAHMHak AsJBAivZ7UndjQhEVLNbA2PHZKivdMT+ERSMDjRtb4PXCyLMx4RaUr4U883mAqlvwc J+t36AXWZzsUQ== X-CNFS-Analysis: v=2.2 cv=c//beV1l c=1 sm=1 tr=0 a=JW4PBAGGOXeSOokdiexgQA==:117 a=TqXGDx2a5VIA:10 a=NEAV23lmAAAA:8 a=M3BvdcjAsrv0Dja5qOoA:9 a=QEXdDO2ut3YA:10 a=UeoUs6IMxrDbLK3_k6cA:9 a=wPNLvfGTeEIA:10 a=Ld372NDzu18A:10 Date: Sat, 10 Mar 2018 15:02:56 +0100 (CET) From: Carlo Bramini To: ffmpeg-devel@ffmpeg.org Message-ID: <1994689946.824459.1520690576097@mail.libero.it> MIME-Version: 1.0 X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.3-Rev40 X-Originating-IP: 87.15.200.92 X-Originating-Client: open-xchange-appsuite x-libjamsun: T90NyIYTROoJvI0GyPUSCGGD04cNTl65 x-libjamv: n4gGnMwdlGw= X-CMAE-Envelope: MS4wfGnWDQr+dWJGDX31RtJbbo2Eu4fRrg9SavO67aBYc8MQ9tgqGHOdpHDCInCOsbZBZZecK/hwZndfBfvA/Ls4KKHzgOiPFRtKzcfS9cv9t4M76nPGlRQo wZFCAoaEIVLdWHPtW7bzhpRgc5zhcdsr/rWpSPal1Gh3g9V2JzJodlh8HekBC7p8RpoNB6F6Q0HQaw== Subject: [FFmpeg-devel] Type mismatch in ADPCM 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" Hello, while working with ADPCM source code, I noticed that there is a type mismatch in ff_adpcm_afc_coeffs[2][16]. Inside libavcodec/adpcm_data.c it is declared as uint16_t: https://github.com/FFmpeg/FFmpeg/blob/d168e78effd170377ec57f67bca05c9f0de91bca/libavcodec/adpcm_data.c#L109 but into libavcodec/adpcm_data.h it is declared as int16_t: https://github.com/FFmpeg/FFmpeg/blob/d168e78effd170377ec57f67bca05c9f0de91bca/libavcodec/adpcm_data.h#L43 Those values are used as signed integer elsewhere. So, I would like to suggest to fix this declaration with attached patch. I noticed this thing because I compiled those sources with a more robust syntax check, by using C++ rather that plain C. At pratical level, nothing changed, except for the .h files that required to use the extern "C" keyword. I was wondering if you could evaulate the chance to add this feature to the include files. It could be done directly by using some #ifdef/#endif, or perhaps by doing something like this, somewhere in a common file: #ifdef __cplusplus #define FFMPEG_EXTERN_C_BEGIN extern "C" { #define FFMPEG_EXTERN_C_END } #else #define FFMPEG_EXTERN_C_BEGIN #define FFMPEG_EXTERN_C_END #endif and just add FFMPEG_EXTERN_C_BEGIN and FFMPEG_EXTERN_C_END to the top and to the bottom of each include file. You could take it as a suggestion, allowing compilation with both GCC and G++ may show you some defects you cannot see normally and give room to some improvements. Sincerely. diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index cd3bbd33c2..2753bd852d 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -1254,7 +1254,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int coeff1, coeff2; int shift; unsigned int channel; - uint16_t *samplesC; + int16_t *samplesC; int count = 0; int offsets[6]; diff --git a/libavcodec/adpcm_data.c b/libavcodec/adpcm_data.c index 4cce0a5857..e7ca5bc697 100644 --- a/libavcodec/adpcm_data.c +++ b/libavcodec/adpcm_data.c @@ -25,6 +25,8 @@ #include +#include "adpcm_data.h" + /* ff_adpcm_step_table[] and ff_adpcm_index_table[] are from the ADPCM reference source */ static const int8_t adpcm_index_table2[4] = { @@ -106,9 +108,9 @@ const int8_t ff_adpcm_yamaha_difflookup[] = { -1, -3, -5, -7, -9, -11, -13, -15 }; -const uint16_t ff_adpcm_afc_coeffs[2][16] = { - { 0, 2048, 0, 1024, 4096, 3584, 3072, 4608, 4200, 4800, 5120, 2048, 1024, 64512, 64512, 63488 }, - { 0, 0, 2048, 1024, 63488, 64000, 64512, 62976, 63288, 63236, 62464, 63488, 64512, 1024, 0, 0 } +const int16_t ff_adpcm_afc_coeffs[2][16] = { + { 0, 2048, 0, 1024, 4096, 3584, 3072, 4608, 4200, 4800, 5120, 2048, 1024, -1024, -1024, -2048, }, + { 0, 0, 2048, 1024, -2048, -1536, -1024, -2560, -2248, -2300, -3072, -2048, -1024, 1024, 0, 0, } }; const int16_t ff_adpcm_mtaf_stepsize[32][16] = {