diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index adf8573a571dea38b71a11761dc71dd1a54bdfe8..fb582c47115a43a9ca6172c89a7d2d5b35d8337e 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -1221,7 +1221,7 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, } #ifndef DISABLE_FLOAT_API if (analysis->valid) - gain1 *= analysis->max_pitch_ratio; + gain1 = (opus_val16)(gain1 * analysis->max_pitch_ratio); #else (void)analysis; #endif diff --git a/silk/arm/LPC_inv_pred_gain_neon_intr.c b/silk/arm/LPC_inv_pred_gain_neon_intr.c index 27142f34cebe6946506c98c7c80ed706e60738be..ab426bcd66f8bd100317f2e2c19402dfc668e5d3 100644 --- a/silk/arm/LPC_inv_pred_gain_neon_intr.c +++ b/silk/arm/LPC_inv_pred_gain_neon_intr.c @@ -217,13 +217,13 @@ opus_int32 silk_LPC_inverse_pred_gain_neon( /* O Returns inverse predi { case 24: t0_s32x4 = vpadalq_s16( t0_s32x4, t2_s16x8 ); - /* Intend to fall through */ + /* FALLTHROUGH */ case 16: t0_s32x4 = vpadalq_s16( t0_s32x4, t1_s16x8 ); vst1q_s32( Atmp_QA + 16, vshll_n_s16( vget_low_s16 ( t2_s16x8 ), QA - 12 ) ); vst1q_s32( Atmp_QA + 20, vshll_n_s16( vget_high_s16( t2_s16x8 ), QA - 12 ) ); - /* Intend to fall through */ + /* FALLTHROUGH */ case 8: { @@ -246,17 +246,17 @@ opus_int32 silk_LPC_inverse_pred_gain_neon( /* O Returns inverse predi case 6: DC_resp += (opus_int32)A_Q12[ 5 ]; DC_resp += (opus_int32)A_Q12[ 4 ]; - /* Intend to fall through */ + /* FALLTHROUGH */ case 4: DC_resp += (opus_int32)A_Q12[ 3 ]; DC_resp += (opus_int32)A_Q12[ 2 ]; - /* Intend to fall through */ + /* FALLTHROUGH */ case 2: DC_resp += (opus_int32)A_Q12[ 1 ]; DC_resp += (opus_int32)A_Q12[ 0 ]; - /* Intend to fall through */ + /* FALLTHROUGH */ default: break; diff --git a/src/mapping_matrix.c b/src/mapping_matrix.c index 11a14ce19fc20b6d06a4fc9325a72f7055ad7c8b..f9821f7e61fd34eb04c766246cb8f316f5370145 100644 --- a/src/mapping_matrix.c +++ b/src/mapping_matrix.c @@ -58,7 +58,8 @@ opus_int32 mapping_matrix_get_size(int rows, int cols) opus_int16 *mapping_matrix_get_data(const MappingMatrix *matrix) { - return (opus_int16*)((char*)matrix + align(sizeof(MappingMatrix))); + /* void* cast avoids clang -Wcast-align warning */ + return (opus_int16*)(void*)((char*)matrix + align(sizeof(MappingMatrix))); } void mapping_matrix_init(MappingMatrix * const matrix, diff --git a/src/opus_projection_decoder.c b/src/opus_projection_decoder.c index c879ead7f36c310f2da05e144a108347942b2c00..1ccd8b720d30c6293c6acf1a2d407d3293901899 100644 --- a/src/opus_projection_decoder.c +++ b/src/opus_projection_decoder.c @@ -93,12 +93,16 @@ static void opus_projection_copy_channel_out_short( static MappingMatrix *get_demixing_matrix(OpusProjectionDecoder *st) { - return (MappingMatrix*)((char*)st + align(sizeof(OpusProjectionDecoder))); + /* void* cast avoids clang -Wcast-align warning */ + return (MappingMatrix*)(void*)((char*)st + + align(sizeof(OpusProjectionDecoder))); } static OpusMSDecoder *get_multistream_decoder(OpusProjectionDecoder *st) { - return (OpusMSDecoder*)((char*)st + align(sizeof(OpusProjectionDecoder) + + /* void* cast avoids clang -Wcast-align warning */ + return (OpusMSDecoder*)(void*)((char*)st + + align(sizeof(OpusProjectionDecoder) + st->demixing_matrix_size_in_bytes)); } diff --git a/src/opus_projection_encoder.c b/src/opus_projection_encoder.c index 1fbcf471f74ae0ab4af5cd7702b4972e492b43e2..8309e4b5ede0bb4a3ed1f5383b72ae415436a787 100644 --- a/src/opus_projection_encoder.c +++ b/src/opus_projection_encoder.c @@ -119,19 +119,26 @@ static int get_streams_from_channels(int channels, int mapping_family, static MappingMatrix *get_mixing_matrix(OpusProjectionEncoder *st) { - return (MappingMatrix *)((char*)st + align(sizeof(OpusProjectionEncoder))); + /* void* cast avoids clang -Wcast-align warning */ + return (MappingMatrix *)(void*)((char*)st + + align(sizeof(OpusProjectionEncoder))); } static MappingMatrix *get_demixing_matrix(OpusProjectionEncoder *st) { - return (MappingMatrix *)((char*)st + align(sizeof(OpusProjectionEncoder) + + /* void* cast avoids clang -Wcast-align warning */ + return (MappingMatrix *)(void*)((char*)st + + align(sizeof(OpusProjectionEncoder) + st->mixing_matrix_size_in_bytes)); } static OpusMSEncoder *get_multistream_encoder(OpusProjectionEncoder *st) { - return (OpusMSEncoder *)((char*)st + align(sizeof(OpusProjectionEncoder) + - st->mixing_matrix_size_in_bytes + st->demixing_matrix_size_in_bytes)); + /* void* cast avoids clang -Wcast-align warning */ + return (OpusMSEncoder *)(void*)((char*)st + + align(sizeof(OpusProjectionEncoder) + + st->mixing_matrix_size_in_bytes + + st->demixing_matrix_size_in_bytes)); } opus_int32 opus_projection_ambisonics_encoder_get_size(int channels, diff --git a/tests/test_opus_api.c b/tests/test_opus_api.c index 1d0095058f80a1213b015561984c3bcc7cf8e542..43c6d1437e8d59a27b3b8c22ca735ade9e67c8fb 100644 --- a/tests/test_opus_api.c +++ b/tests/test_opus_api.c @@ -78,6 +78,9 @@ void *malloc_hook(__attribute__((unused)) size_t size, } #endif +opus_int32 *null_int_ptr = (opus_int32 *)NULL; +opus_uint32 *null_uint_ptr = (opus_uint32 *)NULL; + static const opus_int32 opus_rates[5] = {48000,24000,16000,12000,8000}; opus_int32 test_dec_api(void) @@ -92,8 +95,6 @@ opus_int32 test_dec_api(void) #endif short sbuf[960*2]; int c,err; - opus_int32 *nullvalue; - nullvalue=0; cfgs=0; /*First test invalid configurations which should fail*/ @@ -147,7 +148,7 @@ opus_int32 test_dec_api(void) fprintf(stdout," opus_decoder_create() ........................ OK.\n"); fprintf(stdout," opus_decoder_init() .......................... OK.\n"); - err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE((opus_uint32 *)NULL)); + err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(null_uint_ptr)); if(err != OPUS_BAD_ARG)test_failed(); VG_UNDEF(&dec_final_range,sizeof(dec_final_range)); err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range)); @@ -161,7 +162,7 @@ opus_int32 test_dec_api(void) fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n"); cfgs++; - err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH((opus_int32 *)NULL)); + err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH(null_int_ptr)); if(err != OPUS_BAD_ARG)test_failed(); VG_UNDEF(&i,sizeof(i)); err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i)); @@ -169,7 +170,7 @@ opus_int32 test_dec_api(void) fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n"); cfgs++; - err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE((opus_int32 *)NULL)); + err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE(null_int_ptr)); if(err != OPUS_BAD_ARG)test_failed(); VG_UNDEF(&i,sizeof(i)); err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE(&i)); @@ -178,7 +179,7 @@ opus_int32 test_dec_api(void) cfgs++; /*GET_PITCH has different execution paths depending on the previously decoded frame.*/ - err=opus_decoder_ctl(dec, OPUS_GET_PITCH(nullvalue)); + err=opus_decoder_ctl(dec, OPUS_GET_PITCH(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; VG_UNDEF(&i,sizeof(i)); @@ -202,7 +203,7 @@ opus_int32 test_dec_api(void) cfgs++; fprintf(stdout," OPUS_GET_PITCH ............................... OK.\n"); - err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION((opus_int32 *)NULL)); + err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(null_int_ptr)); if(err != OPUS_BAD_ARG)test_failed(); VG_UNDEF(&i,sizeof(i)); err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&i)); @@ -215,7 +216,7 @@ opus_int32 test_dec_api(void) VG_CHECK(&i,sizeof(i)); if(err != OPUS_OK || i!=0)test_failed(); cfgs++; - err=opus_decoder_ctl(dec, OPUS_GET_GAIN(nullvalue)); + err=opus_decoder_ctl(dec, OPUS_GET_GAIN(null_int_ptr)); if(err != OPUS_BAD_ARG)test_failed(); cfgs++; err=opus_decoder_ctl(dec, OPUS_SET_GAIN(-32769)); @@ -352,11 +353,6 @@ opus_int32 test_msdec_api(void) #endif short sbuf[960*2]; int a,b,c,err; -#if 0 - /*Relevant test not enabled for multistream*/ - int *nullvalue; - nullvalue=0; -#endif mapping[0]=0; mapping[1]=1; @@ -610,7 +606,7 @@ opus_int32 test_msdec_api(void) #if 0 /*Currently unimplemented for multistream*/ /*GET_PITCH has different execution paths depending on the previously decoded frame.*/ - err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(nullvalue)); + err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; VG_UNDEF(&i,sizeof(i)); @@ -1166,7 +1162,7 @@ opus_int32 test_enc_api(void) err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); if(err!=OPUS_OK || i<0 || i>32766)test_failed(); cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; fprintf(stdout," OPUS_GET_LOOKAHEAD ........................... OK.\n"); @@ -1174,7 +1170,7 @@ opus_int32 test_enc_api(void) err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE(&i)); if(err!=OPUS_OK || i!=48000)test_failed(); cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; fprintf(stdout," OPUS_GET_SAMPLE_RATE ......................... OK.\n"); @@ -1183,7 +1179,7 @@ opus_int32 test_enc_api(void) fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n"); cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_APPLICATION((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_APPLICATION(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_APPLICATION(i),OPUS_GET_APPLICATION(&i),-1,OPUS_AUTO, @@ -1191,7 +1187,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_APPLICATION ......................... OK.\n", " OPUS_GET_APPLICATION ......................... OK.\n") - err=opus_encoder_ctl(enc,OPUS_GET_BITRATE((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_BITRATE(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; if(opus_encoder_ctl(enc,OPUS_SET_BITRATE(1073741832))!=OPUS_OK)test_failed(); @@ -1205,7 +1201,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_BITRATE ............................. OK.\n", " OPUS_GET_BITRATE ............................. OK.\n") - err=opus_encoder_ctl(enc,OPUS_GET_FORCE_CHANNELS((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_FORCE_CHANNELS(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_FORCE_CHANNELS(i),OPUS_GET_FORCE_CHANNELS(&i),-1,3, @@ -1243,7 +1239,7 @@ opus_int32 test_enc_api(void) cfgs++; if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(OPUS_AUTO))!=OPUS_OK)test_failed(); cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n"); @@ -1276,12 +1272,12 @@ opus_int32 test_enc_api(void) i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&& i!=OPUS_BANDWIDTH_FULLBAND))test_failed(); cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; fprintf(stdout," OPUS_GET_MAX_BANDWIDTH ....................... OK.\n"); - err=opus_encoder_ctl(enc,OPUS_GET_DTX((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_DTX(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_DTX(i),OPUS_GET_DTX(&i),-1,2, @@ -1289,7 +1285,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_DTX ................................. OK.\n", " OPUS_GET_DTX ................................. OK.\n") - err=opus_encoder_ctl(enc,OPUS_GET_COMPLEXITY((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_COMPLEXITY(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_COMPLEXITY(i),OPUS_GET_COMPLEXITY(&i),-1,11, @@ -1297,7 +1293,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_COMPLEXITY .......................... OK.\n", " OPUS_GET_COMPLEXITY .......................... OK.\n") - err=opus_encoder_ctl(enc,OPUS_GET_INBAND_FEC((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_INBAND_FEC(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_INBAND_FEC(i),OPUS_GET_INBAND_FEC(&i),-1,2, @@ -1305,7 +1301,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_INBAND_FEC .......................... OK.\n", " OPUS_GET_INBAND_FEC .......................... OK.\n") - err=opus_encoder_ctl(enc,OPUS_GET_PACKET_LOSS_PERC((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_PACKET_LOSS_PERC(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_PACKET_LOSS_PERC(i),OPUS_GET_PACKET_LOSS_PERC(&i),-1,101, @@ -1313,7 +1309,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_PACKET_LOSS_PERC .................... OK.\n", " OPUS_GET_PACKET_LOSS_PERC .................... OK.\n") - err=opus_encoder_ctl(enc,OPUS_GET_VBR((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_VBR(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_VBR(i),OPUS_GET_VBR(&i),-1,2, @@ -1321,7 +1317,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_VBR ................................. OK.\n", " OPUS_GET_VBR ................................. OK.\n") -/* err=opus_encoder_ctl(enc,OPUS_GET_VOICE_RATIO((opus_int32 *)NULL)); +/* err=opus_encoder_ctl(enc,OPUS_GET_VOICE_RATIO(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_VOICE_RATIO(i),OPUS_GET_VOICE_RATIO(&i),-2,101, @@ -1329,7 +1325,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_VOICE_RATIO ......................... OK.\n", " OPUS_GET_VOICE_RATIO ......................... OK.\n")*/ - err=opus_encoder_ctl(enc,OPUS_GET_VBR_CONSTRAINT((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_VBR_CONSTRAINT(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_VBR_CONSTRAINT(i),OPUS_GET_VBR_CONSTRAINT(&i),-1,2, @@ -1337,7 +1333,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_VBR_CONSTRAINT ...................... OK.\n", " OPUS_GET_VBR_CONSTRAINT ...................... OK.\n") - err=opus_encoder_ctl(enc,OPUS_GET_SIGNAL((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_SIGNAL(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_SIGNAL(i),OPUS_GET_SIGNAL(&i),-12345,0x7FFFFFFF, @@ -1345,7 +1341,7 @@ opus_int32 test_enc_api(void) " OPUS_SET_SIGNAL .............................. OK.\n", " OPUS_GET_SIGNAL .............................. OK.\n") - err=opus_encoder_ctl(enc,OPUS_GET_LSB_DEPTH((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_LSB_DEPTH(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_LSB_DEPTH(i),OPUS_GET_LSB_DEPTH(&i),7,25,16,24, @@ -1355,14 +1351,14 @@ opus_int32 test_enc_api(void) err=opus_encoder_ctl(enc,OPUS_GET_PREDICTION_DISABLED(&i)); if(i!=0)test_failed(); cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_PREDICTION_DISABLED((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_PREDICTION_DISABLED(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; CHECK_SETGET(OPUS_SET_PREDICTION_DISABLED(i),OPUS_GET_PREDICTION_DISABLED(&i),-1,2,1,0, " OPUS_SET_PREDICTION_DISABLED ................. OK.\n", " OPUS_GET_PREDICTION_DISABLED ................. OK.\n") - err=opus_encoder_ctl(enc,OPUS_GET_EXPERT_FRAME_DURATION((opus_int32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_EXPERT_FRAME_DURATION(null_int_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_2_5_MS)); @@ -1399,7 +1395,7 @@ opus_int32 test_enc_api(void) /*OPUS_SET_FORCE_MODE is not tested here because it's not a public API, however the encoder tests use it*/ - err=opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE((opus_uint32 *)NULL)); + err=opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE(null_uint_ptr)); if(err!=OPUS_BAD_ARG)test_failed(); cfgs++; if(opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test_failed();