summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOzkan Sezer <sezero@users.noreply.github.com>2022-10-17 18:54:53 +0300
committerGitHub <noreply@github.com>2022-10-17 17:54:53 +0200
commit92928f2868d35d4c9c0f4341ce126b36e44b95ec (patch)
treef1a669634f989a4cf9a8a5a243066f0500cb8516
parent5a9ffda85271e406c1dfb2872005b9abd83438c3 (diff)
downloadflac-92928f2868d35d4c9c0f4341ce126b36e44b95ec.tar.gz
fix errors: 'for' loop initial declarations are only allowed in C99 mode
-rw-r--r--src/flac/decode.c7
-rw-r--r--src/flac/foreign_metadata.c3
-rw-r--r--src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c11
-rw-r--r--src/libFLAC/fixed.c15
-rw-r--r--src/libFLAC/lpc.c3
-rw-r--r--src/libFLAC/metadata_object.c6
-rw-r--r--src/libFLAC/stream_decoder.c13
-rw-r--r--src/libFLAC/stream_encoder.c6
-rw-r--r--src/test_libFLAC/metadata_object.c3
9 files changed, 42 insertions, 25 deletions
diff --git a/src/flac/decode.c b/src/flac/decode.c
index 1acc66aa..c0dd446b 100644
--- a/src/flac/decode.c
+++ b/src/flac/decode.c
@@ -334,11 +334,12 @@ FLAC__bool DecoderSession_init_decoder(DecoderSession *decoder_session, const ch
if (decoder_session->replaygain.spec.apply || !decoder_session->channel_map_none)
FLAC__stream_decoder_set_metadata_respond(decoder_session->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
- if(!decoder_session->analysis_mode && !decoder_session->test_only && decoder_session->foreign_metadata == NULL)
+ if(!decoder_session->analysis_mode && !decoder_session->test_only && decoder_session->foreign_metadata == NULL) {
/* Warn user if foreign metadata is found */
- for(uint32_t i = 0; i < FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS; i++)
+ uint32_t i;
+ for(i = 0; i < FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS; i++)
FLAC__stream_decoder_set_metadata_respond_application(decoder_session->decoder, (FLAC__byte *)FLAC__FOREIGN_METADATA_APPLICATION_ID[i]);
-
+ }
#if FLAC__HAS_OGG
if(decoder_session->is_ogg) {
diff --git a/src/flac/foreign_metadata.c b/src/flac/foreign_metadata.c
index c86dff42..8d89a473 100644
--- a/src/flac/foreign_metadata.c
+++ b/src/flac/foreign_metadata.c
@@ -489,7 +489,8 @@ static FLAC__bool read_from_flac_(foreign_metadata_t *fm, FILE *f, FLAC__Metadat
/* The found application metadata block is not of the right type, check
* whether it is of another recognized type so we can tell the user it
* is decoding to the wrong file format */
- for(uint32_t i = 0; i < FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS; i++)
+ uint32_t i;
+ for(i = 0; i < FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS; i++)
if(memcmp(id, FLAC__FOREIGN_METADATA_APPLICATION_ID[i], sizeof(id)) == 0) {
foreign_metadata_found = true;
foreign_metadata_found_type = i;
diff --git a/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c b/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c
index 5843b000..76419db0 100644
--- a/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c
+++ b/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c
@@ -1,13 +1,14 @@
+ int i, j;
(void) lag;
FLAC__ASSERT(lag <= MAX_LAG);
- for(int i = 0; i < MAX_LAG; i++)
+ for(i = 0; i < MAX_LAG; i++)
autoc[i] = 0.0;
- for(int i = 0; i < MAX_LAG; i++)
- for(int j = 0; j <= i; j++)
+ for(i = 0; i < MAX_LAG; i++)
+ for(j = 0; j <= i; j++)
autoc[j] += (double)data[i] * (double)data[i-j];
- for(int i = MAX_LAG; i < (int)data_len; i++)
- for(int j = 0; j < MAX_LAG; j++)
+ for(i = MAX_LAG; i < (int)data_len; i++)
+ for(j = 0; j < MAX_LAG; j++)
autoc[j] += (double)data[i] * (double)data[i-j];
diff --git a/src/libFLAC/fixed.c b/src/libFLAC/fixed.c
index 7d826f10..da5c7dac 100644
--- a/src/libFLAC/fixed.c
+++ b/src/libFLAC/fixed.c
@@ -236,11 +236,12 @@ uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t d
FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]);
FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
FLAC__int32 error, save;
+ uint32_t i;
/* total_error_* are 64-bits to avoid overflow when encoding
* erratic signals when the bits-per-sample and blocksize are
* large.
*/
- for(uint32_t i = 0; i < data_len; i++) {
+ for(i = 0; i < data_len; i++) {
error = data[i] ; total_error_0 += local_abs(error); save = error;
error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error;
error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error;
@@ -248,7 +249,8 @@ uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t d
error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save;
}
#else
- for(int i = 0; i < (int)data_len; i++) {
+ int i;
+ for(i = 0; i < (int)data_len; i++) {
total_error_0 += local_abs(data[i]);
total_error_1 += local_abs(data[i] - data[i-1]);
total_error_2 += local_abs(data[i] - 2 * data[i-1] + data[i-2]);
@@ -303,8 +305,9 @@ uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint3
{
FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
uint32_t order;
+ int i;
- for(int i = 0; i < (int)data_len; i++) {
+ for(i = 0; i < (int)data_len; i++) {
total_error_0 += local_abs(data[i]);
total_error_1 += local_abs(data[i] - data[i-1]);
total_error_2 += local_abs(data[i] - 2 * data[i-1] + data[i-2]);
@@ -380,8 +383,9 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual(const FLAC__int32 dat
FLAC__uint64 error_0, error_1, error_2, error_3, error_4;
FLAC__bool order_0_is_valid = true, order_1_is_valid = true, order_2_is_valid = true, order_3_is_valid = true, order_4_is_valid = true;
uint32_t order = 0;
+ int i;
- for(int i = 0; i < (int)data_len; i++) {
+ for(i = 0; i < (int)data_len; i++) {
error_0 = local_abs64((FLAC__int64)data[i]);
error_1 = (i > 0) ? local_abs64((FLAC__int64)data[i] - data[i-1]) : 0 ;
error_2 = (i > 1) ? local_abs64((FLAC__int64)data[i] - 2 * (FLAC__int64)data[i-1] + data[i-2]) : 0;
@@ -426,8 +430,9 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_33bit(const FLAC__int
FLAC__uint64 error_0, error_1, error_2, error_3, error_4;
FLAC__bool order_0_is_valid = true, order_1_is_valid = true, order_2_is_valid = true, order_3_is_valid = true, order_4_is_valid = true;
uint32_t order = 0;
+ int i;
- for(int i = 0; i < (int)data_len; i++) {
+ for(i = 0; i < (int)data_len; i++) {
error_0 = local_abs64(data[i]);
error_1 = (i > 0) ? local_abs64(data[i] - data[i-1]) : 0 ;
error_2 = (i > 1) ? local_abs64(data[i] - 2 * data[i-1] + data[i-2]) : 0;
diff --git a/src/libFLAC/lpc.c b/src/libFLAC/lpc.c
index a760b121..9d9c7e3b 100644
--- a/src/libFLAC/lpc.c
+++ b/src/libFLAC/lpc.c
@@ -946,7 +946,8 @@ uint32_t FLAC__lpc_max_prediction_before_shift_bps(uint32_t subframe_bps, const
* predictor is known however, so taking the log2 of the sum of the absolute values
* of all coefficients is a more accurate representation of the predictor */
FLAC__int32 abs_sum_of_qlp_coeff = 0;
- for(uint32_t i = 0; i < order; i++)
+ uint32_t i;
+ for(i = 0; i < order; i++)
abs_sum_of_qlp_coeff += abs(qlp_coeff[i]);
if(abs_sum_of_qlp_coeff == 0)
abs_sum_of_qlp_coeff = 1;
diff --git a/src/libFLAC/metadata_object.c b/src/libFLAC/metadata_object.c
index c1e54ab2..3f56b0ef 100644
--- a/src/libFLAC/metadata_object.c
+++ b/src/libFLAC/metadata_object.c
@@ -1179,9 +1179,10 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__St
if (new_num_comments == 0)
return true;
else {
+ uint32_t i;
if ((object->data.vorbis_comment.comments = vorbiscomment_entry_array_new_(new_num_comments)) == NULL)
return false;
- for (uint32_t i = 0; i < new_num_comments; i++) {
+ for (i = 0; i < new_num_comments; i++) {
object->data.vorbis_comment.comments[i].length = 0;
if ((object->data.vorbis_comment.comments[i].entry = safe_malloc_(1)) == NULL) {
object->data.vorbis_comment.num_comments = i+1;
@@ -1223,7 +1224,8 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__St
/* if growing, zero all the length/pointers of new elements */
if (new_size > old_size) {
- for (uint32_t i = object->data.vorbis_comment.num_comments; i < new_num_comments; i++) {
+ uint32_t i;
+ for (i = object->data.vorbis_comment.num_comments; i < new_num_comments; i++) {
object->data.vorbis_comment.comments[i].length = 0;
if ((object->data.vorbis_comment.comments[i].entry = safe_malloc_(1)) == NULL) {
object->data.vorbis_comment.num_comments = i+1;
diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c
index 83409ed7..09bdadaa 100644
--- a/src/libFLAC/stream_decoder.c
+++ b/src/libFLAC/stream_decoder.c
@@ -2747,7 +2747,8 @@ FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel,
/* decode the subframe */
if(do_full_decode) {
if(bps < 33){
- for(uint32_t i = 0; i < order; i++)
+ uint32_t i;
+ for(i = 0; i < order; i++)
decoder->private_->output[channel][i] = subframe->warmup[i];
if(bps+order <= 32)
FLAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->output[channel]+order);
@@ -2849,7 +2850,8 @@ FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, ui
/* decode the subframe */
if(do_full_decode) {
if(bps <= 32) {
- for(uint32_t i = 0; i < order; i++)
+ uint32_t i;
+ for(i = 0; i < order; i++)
decoder->private_->output[channel][i] = subframe->warmup[i];
if(FLAC__lpc_max_residual_bps(bps, subframe->qlp_coeff, order, subframe->quantization_level) <= 32 &&
FLAC__lpc_max_prediction_before_shift_bps(bps, subframe->qlp_coeff, order) <= 32)
@@ -3072,6 +3074,7 @@ FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data)
__attribute__((no_sanitize("signed-integer-overflow")))
#endif
void undo_channel_coding(FLAC__StreamDecoder *decoder) {
+ uint32_t i;
switch(decoder->private_->frame.header.channel_assignment) {
case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
/* do nothing */
@@ -3079,7 +3082,7 @@ void undo_channel_coding(FLAC__StreamDecoder *decoder) {
case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32));
- for(uint32_t i = 0; i < decoder->private_->frame.header.blocksize; i++)
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
if(decoder->private_->side_subframe_in_use)
decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->side_subframe[i];
else
@@ -3088,7 +3091,7 @@ void undo_channel_coding(FLAC__StreamDecoder *decoder) {
case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32));
- for(uint32_t i = 0; i < decoder->private_->frame.header.blocksize; i++)
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
if(decoder->private_->side_subframe_in_use)
decoder->private_->output[0][i] = decoder->private_->output[1][i] + decoder->private_->side_subframe[i];
else
@@ -3097,7 +3100,7 @@ void undo_channel_coding(FLAC__StreamDecoder *decoder) {
case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32));
- for(uint32_t i = 0; i < decoder->private_->frame.header.blocksize; i++) {
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++) {
if(!decoder->private_->side_subframe_in_use){
FLAC__int32 mid, side;
mid = decoder->private_->output[0][i];
diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c
index 2f0b1e31..c54d7902 100644
--- a/src/libFLAC/stream_encoder.c
+++ b/src/libFLAC/stream_encoder.c
@@ -3722,7 +3722,8 @@ FLAC__bool process_subframe_(
FLAC__lpc_window_data_wide(integer_signal, encoder->private_->window[a], encoder->private_->windowed_signal, frame_header->blocksize);
encoder->private_->local_lpc_compute_autocorrelation(encoder->private_->windowed_signal, frame_header->blocksize, max_lpc_order_this_apodization+1, autoc);
if(encoder->protected_->apodizations[a].type == FLAC__APODIZATION_SUBDIVIDE_TUKEY){
- for(uint32_t i = 0; i < max_lpc_order_this_apodization; i++)
+ uint32_t i;
+ for(i = 0; i < max_lpc_order_this_apodization; i++)
autoc_root[i] = autoc[i];
b++;
}else{
@@ -3750,7 +3751,8 @@ FLAC__bool process_subframe_(
}else{
/* on uneven c, evaluate the root window (over the whole block) minus the previous partial window
* similar to tukey_punchout apodization but more efficient */
- for(uint32_t i = 0; i < max_lpc_order_this_apodization; i++)
+ uint32_t i;
+ for(i = 0; i < max_lpc_order_this_apodization; i++)
autoc[i] = autoc_root[i] - autoc[i];
}
/* Next function sets a, b and c appropriate for next iteration */
diff --git a/src/test_libFLAC/metadata_object.c b/src/test_libFLAC/metadata_object.c
index 0f2e4aae..b0db732c 100644
--- a/src/test_libFLAC/metadata_object.c
+++ b/src/test_libFLAC/metadata_object.c
@@ -199,9 +199,10 @@ static void vc_resize_(FLAC__StreamMetadata *block, uint32_t num)
}
}
else {
+ uint32_t i;
vc->comments = realloc(vc->comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*num);
FLAC__ASSERT(0 != vc->comments);
- for(uint32_t i = vc->num_comments; i < num; i++) {
+ for(i = vc->num_comments; i < num; i++) {
vc->comments[i].length = 0;
vc->comments[i].entry = malloc(1);
vc->comments[i].entry[0] = '\0';