| @@ -91,7 +91,6 @@ typedef struct ATRAC3Context { · 90 unmodified lines |
| 91 | 91 | //@{ |
| 92 | 92 | /** stream data */ |
| 93 | 93 | int coding_mode; |
| 94 | | − int sample_rate; |
| 95 | 94 | |
| 96 | 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 | 178 | static av_cold void init_atrac3_window(void) |
| 180 | 179 | { |
| 181 | | − float enc_window[256]; |
| 182 | | − int i; |
| 180 | + int i, j; |
| 183 | 181 | |
| 184 | 182 | /* generate the mdct window, for details see |
| 185 | 183 | * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */ |
| 186 | | − for (i = 0; i < 256; i++) |
| 187 | | − enc_window[i] = (sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0) * 0.5; |
| 188 | | − |
| 189 | | − for (i = 0; i < 256; i++) { |
| 190 | | − mdct_window[i] = enc_window[i] / |
| 191 | | − (enc_window[ i] * enc_window[ i] + |
| 192 | | − enc_window[255 - i] * enc_window[255 - i]); |
| 193 | | − mdct_window[511 - i] = mdct_window[i]; |
| 184 | + for (i = 0, j = 255; i < 128; i++, j--) { |
| 185 | + float wi = sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0; |
| 186 | + float wj = sin(((j + 0.5) / 256.0 - 0.5) * M_PI) + 1.0; |
| 187 | + float w = 0.5 * (wi * wi + wj * wj); |
| 188 | + mdct_window[i] = mdct_window[511 - i] = wi / w; |
| 189 | + mdct_window[j] = mdct_window[511 - j] = wj / w; |
| 194 | 190 | } |
| 195 | 191 | } |
| 196 | 192 | |
| @@ -315,13 +311,13 @@ static int decode_spectrum(GetBitContext *gb, float *output) · 118 unmodified lines |
| 315 | 311 | output[first] = mantissas[j] * scale_factor; |
| 316 | 312 | } else { |
| 317 | 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 | 318 | /* clear the subbands that were not coded */ |
| 323 | 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 | 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 | 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 | 684 | if (band <= num_bands) |
| 689 | 685 | imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1); |
| 690 | 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 | 689 | /* gain compensation and overlapping */ |
| 694 | 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 | 742 | init_get_bits(&q->gb, ptr1, avctx->block_align * 8); |
| 747 | 743 | |
| 748 | 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 | 747 | q->weighting_delay[4] = get_bits1(&q->gb); |
| 751 | 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 | 869 | const uint8_t *edata_ptr = avctx->extradata; |
| 873 | 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 | 872 | if (avctx->channels <= 0 || avctx->channels > 2) { |
| 879 | 873 | av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n"); |
| 880 | 874 | return AVERROR(EINVAL); |
| @@ -954,8 +948,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 73 unmodified lines |
| 954 | 948 | if (avctx->block_align >= UINT_MAX / 2) |
| 955 | 949 | return AVERROR(EINVAL); |
| 956 | 950 | |
| 957 | | − q->decoded_bytes_buffer = av_mallocz(avctx->block_align + |
| 958 | | − (4 - avctx->block_align % 4) + |
| 951 | + q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) + |
| 959 | 952 | FF_INPUT_BUFFER_PADDING_SIZE); |
| 960 | 953 | if (q->decoded_bytes_buffer == NULL) |
| 961 | 954 | return AVERROR(ENOMEM); |
| @@ -986,7 +979,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 24 unmodified lines |
| 986 | 979 | avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); |
| 987 | 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 | 983 | if (!q->units) { |
| 991 | 984 | atrac3_decode_close(avctx); |
| 992 | 985 | return AVERROR(ENOMEM); |