| @@ -91,7 +91,6 @@ typedef struct ATRAC3Context { · 90 unmodified lines |
| 91 | //@{ | 91 | //@{ |
| 92 | /** stream data */ | 92 | /** stream data */ |
| 93 | int coding_mode; | 93 | int coding_mode; |
| 94 | int sample_rate; | | |
| 95 | | 94 | |
| 96 | ChannelUnit *units; | 95 | ChannelUnit *units; |
| 97 | //@} | 96 | //@} |
| @@ -178,19 +177,16 @@ static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes) · 80 unmodified lines |
| 178 | | 177 | |
| 179 | static av_cold void init_atrac3_window(void) | 178 | static av_cold void init_atrac3_window(void) |
| 180 | { | 179 | { |
| 181 | float enc_window[256]; | 180 | int i, j; |
| 182 | int i; | | |
| 183 | | 181 | |
| 184 | /* generate the mdct window, for details see | 182 | /* generate the mdct window, for details see |
| 185 | * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */ | 183 | * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */ |
| 186 | for (i = 0; i < 256; i++) | 184 | for (i = 0, j = 255; i < 128; i++, j--) { |
| 187 | enc_window[i] = (sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0) * 0.5; | 185 | float wi = sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0; |
| 188 | | 186 | float wj = sin(((j + 0.5) / 256.0 - 0.5) * M_PI) + 1.0; |
| 189 | for (i = 0; i < 256; i++) { | 187 | float w = 0.5 * (wi * wi + wj * wj); |
| 190 | mdct_window[i] = enc_window[i] / | 188 | mdct_window[i] = mdct_window[511 - i] = wi / w; |
| 191 | (enc_window[ i] * enc_window[ i] + | 189 | mdct_window[j] = mdct_window[511 - j] = wj / w; |
| 192 | enc_window[255 - i] * enc_window[255 - i]); | | |
| 193 | mdct_window[511 - i] = mdct_window[i]; | | |
| 194 | } | 190 | } |
| 195 | } | 191 | } |
| 196 | | 192 | |
| @@ -315,13 +311,13 @@ static int decode_spectrum(GetBitContext *gb, float *output) · 118 unmodified lines |
| 315 | output[first] = mantissas[j] * scale_factor; | 311 | output[first] = mantissas[j] * scale_factor; |
| 316 | } else { | 312 | } else { |
| 317 | /* this subband was not coded, so zero the entire subband */ | 313 | /* this subband was not coded, so zero the entire subband */ |
| 318 | memset(output + first, 0, subband_size * sizeof(float)); | 314 | memset(output + first, 0, subband_size * sizeof(*output)); |
| 319 | } | 315 | } |
| 320 | } | 316 | } |
| 321 | | 317 | |
| 322 | /* clear the subbands that were not coded */ | 318 | /* clear the subbands that were not coded */ |
| 323 | first = subband_tab[i]; | 319 | first = subband_tab[i]; |
| 324 | memset(output + first, 0, (SAMPLES_PER_FRAME - first) * sizeof(float)); | 320 | memset(output + first, 0, (SAMPLES_PER_FRAME - first) * sizeof(*output)); |
| 325 | return num_subbands; | 321 | return num_subbands; |
| 326 | } | 322 | } |
| 327 | | 323 | |
| @@ -498,7 +494,7 @@ static void gain_compensate_and_overlap(float *input, float *prev, · 170 unmodified lines |
| 498 | } | 494 | } |
| 499 | | 495 | |
| 500 | /* Delay for the overlapping part. */ | 496 | /* Delay for the overlapping part. */ |
| 501 | memcpy(prev, &input[256], 256 * sizeof(float)); | 497 | memcpy(prev, &input[256], 256 * sizeof(*prev)); |
| 502 | } | 498 | } |
| 503 | | 499 | |
| 504 | /* | 500 | /* |
| @@ -688,7 +684,7 @@ static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb, · 183 unmodified lines |
| 688 | if (band <= num_bands) | 684 | if (band <= num_bands) |
| 689 | imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1); | 685 | imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1); |
| 690 | else | 686 | else |
| 691 | memset(snd->imdct_buf, 0, 512 * sizeof(float)); | 687 | memset(snd->imdct_buf, 0, 512 * sizeof(*snd->imdct_buf)); |
| 692 | | 688 | |
| 693 | /* gain compensation and overlapping */ | 689 | /* gain compensation and overlapping */ |
| 694 | gain_compensate_and_overlap(snd->imdct_buf, | 690 | gain_compensate_and_overlap(snd->imdct_buf, |
| @@ -746,7 +742,8 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, · 51 unmodified lines |
| 746 | init_get_bits(&q->gb, ptr1, avctx->block_align * 8); | 742 | init_get_bits(&q->gb, ptr1, avctx->block_align * 8); |
| 747 | | 743 | |
| 748 | /* Fill the Weighting coeffs delay buffer */ | 744 | /* Fill the Weighting coeffs delay buffer */ |
| 749 | memmove(q->weighting_delay, &q->weighting_delay[2], 4 * sizeof(int)); | 745 | memmove(q->weighting_delay, &q->weighting_delay[2], |
| | 746 | 4 * sizeof(*q->weighting_delay)); |
| 750 | q->weighting_delay[4] = get_bits1(&q->gb); | 747 | q->weighting_delay[4] = get_bits1(&q->gb); |
| 751 | q->weighting_delay[5] = get_bits(&q->gb, 3); | 748 | q->weighting_delay[5] = get_bits(&q->gb, 3); |
| 752 | | 749 | |
| @@ -872,9 +869,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 119 unmodified lines |
| 872 | const uint8_t *edata_ptr = avctx->extradata; | 869 | const uint8_t *edata_ptr = avctx->extradata; |
| 873 | ATRAC3Context *q = avctx->priv_data; | 870 | ATRAC3Context *q = avctx->priv_data; |
| 874 | | 871 | |
| 875 | /* Take data from the AVCodecContext (RM container). */ | | |
| 876 | q->sample_rate = avctx->sample_rate; | | |
| 877 | | | |
| 878 | if (avctx->channels <= 0 || avctx->channels > 2) { | 872 | if (avctx->channels <= 0 || avctx->channels > 2) { |
| 879 | av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n"); | 873 | av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n"); |
| 880 | return AVERROR(EINVAL); | 874 | return AVERROR(EINVAL); |
| @@ -954,8 +948,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 73 unmodified lines |
| 954 | if (avctx->block_align >= UINT_MAX / 2) | 948 | if (avctx->block_align >= UINT_MAX / 2) |
| 955 | return AVERROR(EINVAL); | 949 | return AVERROR(EINVAL); |
| 956 | | 950 | |
| 957 | q->decoded_bytes_buffer = av_mallocz(avctx->block_align + | 951 | q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) + |
| 958 | (4 - avctx->block_align % 4) + | | |
| 959 | FF_INPUT_BUFFER_PADDING_SIZE); | 952 | FF_INPUT_BUFFER_PADDING_SIZE); |
| 960 | if (q->decoded_bytes_buffer == NULL) | 953 | if (q->decoded_bytes_buffer == NULL) |
| 961 | return AVERROR(ENOMEM); | 954 | return AVERROR(ENOMEM); |
| @@ -986,7 +979,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 24 unmodified lines |
| 986 | avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); | 979 | avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); |
| 987 | ff_fmt_convert_init(&q->fmt_conv, avctx); | 980 | ff_fmt_convert_init(&q->fmt_conv, avctx); |
| 988 | | 981 | |
| 989 | q->units = av_mallocz(sizeof(ChannelUnit) * avctx->channels); | 982 | q->units = av_mallocz(sizeof(*q->units) * avctx->channels); |
| 990 | if (!q->units) { | 983 | if (!q->units) { |
| 991 | atrac3_decode_close(avctx); | 984 | atrac3_decode_close(avctx); |
| 992 | return AVERROR(ENOMEM); | 985 | return AVERROR(ENOMEM); |