~ubuntu-branches/ubuntu/oneiric/libav/oneiric

« back to all changes in this revision

Viewing changes to libavcodec/imc.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2011-04-30 14:27:42 UTC
  • mfrom: (1.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110430142742-quvblxk1tj6adlh5
Tags: 4:0.7~b1-1ubuntu1
* Merge from debian. Remaining changes:
  - don't build against libfaad, libdirac, librtmp and libopenjpeg
    (all in universe)
  - explicitly --enable-pic on powerpc, cf. LP #654666
  - different arm configure bits that should probably better be
    merged into debian
* Cherry-picked from git: 
  - install doc/APIChanges and refer to them in NEWS.Debian (Closes: #623682)
  - don't try to install non-existing documentation, fixes FTBFS on powerpc

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Copyright (c) 2006 Benjamin Larsson
5
5
 * Copyright (c) 2006 Konstantin Shishkov
6
6
 *
7
 
 * This file is part of FFmpeg.
 
7
 * This file is part of Libav.
8
8
 *
9
 
 * FFmpeg is free software; you can redistribute it and/or
 
9
 * Libav is free software; you can redistribute it and/or
10
10
 * modify it under the terms of the GNU Lesser General Public
11
11
 * License as published by the Free Software Foundation; either
12
12
 * version 2.1 of the License, or (at your option) any later version.
13
13
 *
14
 
 * FFmpeg is distributed in the hope that it will be useful,
 
14
 * Libav is distributed in the hope that it will be useful,
15
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
17
 * Lesser General Public License for more details.
18
18
 *
19
19
 * You should have received a copy of the GNU Lesser General Public
20
 
 * License along with FFmpeg; if not, write to the Free Software
 
20
 * License along with Libav; if not, write to the Free Software
21
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
22
 */
23
23
 
40
40
#include "get_bits.h"
41
41
#include "dsputil.h"
42
42
#include "fft.h"
 
43
#include "libavutil/audioconvert.h"
 
44
#include "sinewin.h"
43
45
 
44
46
#include "imcdata.h"
45
47
 
87
89
    DSPContext dsp;
88
90
    FFTContext fft;
89
91
    DECLARE_ALIGNED(16, FFTComplex, samples)[COEFFS/2];
90
 
    DECLARE_ALIGNED(16, float, out_samples)[COEFFS];
 
92
    float *out_samples;
91
93
} IMCContext;
92
94
 
93
95
static VLC huffman_vlc[4][4];
116
118
    for(i = 0; i < COEFFS; i++)
117
119
        q->mdct_sine_window[i] *= sqrt(2.0);
118
120
    for(i = 0; i < COEFFS/2; i++){
119
 
        q->post_cos[i] = cos(i / 256.0 * M_PI);
120
 
        q->post_sin[i] = sin(i / 256.0 * M_PI);
 
121
        q->post_cos[i] = (1.0f / 32768) * cos(i / 256.0 * M_PI);
 
122
        q->post_sin[i] = (1.0f / 32768) * sin(i / 256.0 * M_PI);
121
123
 
122
124
        r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI);
123
125
        r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI);
156
158
 
157
159
    ff_fft_init(&q->fft, 7, 1);
158
160
    dsputil_init(&q->dsp, avctx);
159
 
    avctx->sample_fmt = SAMPLE_FMT_S16;
160
 
    avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
 
161
    avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
 
162
    avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
161
163
    return 0;
162
164
}
163
165
 
362
364
        iacc = 0;
363
365
 
364
366
        for(j = (stream_format_code & 0x2)?4:0; j < BANDS; j++) {
365
 
            cwlen = av_clip((int)((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
 
367
            cwlen = av_clipf(((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
366
368
 
367
369
            q->bitsBandT[j] = cwlen;
368
370
            summer += q->bandWidthT[j] * cwlen;
563
565
    }
564
566
 
565
567
    /* FFT */
566
 
    ff_fft_permute(&q->fft, q->samples);
567
 
    ff_fft_calc (&q->fft, q->samples);
 
568
    q->fft.fft_permute(&q->fft, q->samples);
 
569
    q->fft.fft_calc   (&q->fft, q->samples);
568
570
 
569
571
    /* postrotation, window and reorder */
570
572
    for(i = 0; i < COEFFS/2; i++){
660
662
        return -1;
661
663
    }
662
664
    for(i = 0; i < IMC_BLOCK_SIZE / 2; i++)
663
 
        buf16[i] = bswap_16(((const uint16_t*)buf)[i]);
 
665
        buf16[i] = av_bswap16(((const uint16_t*)buf)[i]);
664
666
 
 
667
    q->out_samples = data;
665
668
    init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);
666
669
 
667
670
    /* Check the frame header */
805
808
 
806
809
    imc_imdct256(q);
807
810
 
808
 
    q->dsp.float_to_int16(data, q->out_samples, COEFFS);
809
 
 
810
 
    *data_size = COEFFS * sizeof(int16_t);
 
811
    *data_size = COEFFS * sizeof(float);
811
812
 
812
813
    return IMC_BLOCK_SIZE;
813
814
}
822
823
}
823
824
 
824
825
 
825
 
AVCodec imc_decoder = {
 
826
AVCodec ff_imc_decoder = {
826
827
    .name = "imc",
827
828
    .type = AVMEDIA_TYPE_AUDIO,
828
829
    .id = CODEC_ID_IMC,