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 <stdint.h>
+#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] = {
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel