~siretart/vlc/debian-packaging

« back to all changes in this revision

Viewing changes to modules/codec/adpcm.c

  • Committer: Sebastian Ramacher
  • Date: 2016-01-31 20:58:37 UTC
  • mfrom: (1.2.39)
  • Revision ID: git-v1:b7ac1de93ecf7cd3d86898544433974ce0af7086
Merge tag 'upstream/2.2.2'

Upstream version 2.2.2

# gpg: Signature made Sun 31 Jan 2016 21:57:53 CET using RSA key ID 6EA71993
# gpg: Good signature from "Sebastian Ramacher <sebastian@ramacher.at>"
# gpg:                 aka "Sebastian Ramacher <s.ramacher@gmail.com>"
# gpg:                 aka "Sebastian Ramacher <s.ramacher@gmx.at>"
# gpg:                 aka "Sebastian Ramacher <s.ramacher@student.tugraz.at>"
# gpg:                 aka "Sebastian Ramacher <sramacher@debian.org>"
# gpg:                 aka "Sebastian Ramacher <sebastian.ramacher@iaik.tugraz.at>"

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * adpcm.c : adpcm variant audio decoder
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2001, 2002 VLC authors and VideoLAN
5
 
 * $Id: b052965920a53a875464f6c86128a4f3eb6054fa $
 
5
 * $Id: e655c45ca990e3171f3d6f356754473b19d6af30 $
6
6
 *
7
7
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8
8
 *          Rémi Denis-Courmont <rem # videolan.org>
72
72
    size_t              i_samplesperblock;
73
73
 
74
74
    date_t              end_date;
 
75
    int16_t            *prev;
75
76
};
76
77
 
77
78
static void DecodeAdpcmMs    ( decoder_t *, int16_t *, uint8_t * );
164
165
    }
165
166
 
166
167
    /* Allocate the memory needed to store the decoder's structure */
167
 
    if( ( p_dec->p_sys = p_sys =
168
 
          (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
 
168
    p_sys = malloc(sizeof(*p_sys));
 
169
    if( unlikely(p_sys == NULL) )
169
170
        return VLC_ENOMEM;
170
171
 
 
172
    p_sys->prev = NULL;
 
173
 
171
174
    switch( p_dec->fmt_in.i_codec )
172
175
    {
173
176
        case VLC_FOURCC('i','m','a', '4'): /* IMA ADPCM */
187
190
            break;
188
191
        case VLC_FOURCC('X','A','J', 0): /* EA ADPCM */
189
192
            p_sys->codec = ADPCM_EA;
190
 
            p_dec->fmt_in.p_extra = calloc( 2 * p_dec->fmt_in.audio.i_channels,
191
 
                                            sizeof( int16_t ) );
192
 
            if( p_dec->fmt_in.p_extra == NULL )
 
193
            p_sys->prev = calloc( 2 * p_dec->fmt_in.audio.i_channels,
 
194
                                  sizeof( int16_t ) );
 
195
            if( unlikely(p_sys->prev == NULL) )
193
196
            {
194
197
                free( p_sys );
195
198
                return VLC_ENOMEM;
245
248
             p_dec->fmt_in.audio.i_bitspersample, p_sys->i_block,
246
249
             p_sys->i_samplesperblock );
247
250
 
 
251
    p_dec->p_sys = p_sys;
248
252
    p_dec->fmt_out.i_cat = AUDIO_ES;
249
253
    p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
250
254
    p_dec->fmt_out.audio.i_rate = p_dec->fmt_in.audio.i_rate;
349
353
    decoder_t *p_dec = (decoder_t *)p_this;
350
354
    decoder_sys_t *p_sys = p_dec->p_sys;
351
355
 
352
 
    if( p_sys->codec == ADPCM_EA )
353
 
        free( p_dec->fmt_in.p_extra );
 
356
    free( p_sys->prev );
354
357
    free( p_sys );
355
358
}
356
359
 
741
744
 
742
745
    unsigned chans = p_dec->fmt_in.audio.i_channels;
743
746
    const uint8_t *p_end = &p_buffer[p_sys->i_block];
744
 
    int16_t *prev = (int16_t *)p_dec->fmt_in.p_extra;
 
747
    int16_t *prev = p_sys->prev;
745
748
    int16_t *cur = prev + chans;
746
749
 
747
750
    for (unsigned c = 0; c < chans; c++)