Changeset e4f4f59ee368c4dc1c7ed6e344945fae36e63ef2

Show
Ignore:
Timestamp:
07/03/05 14:05:06 (4 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1110200706 +0000
git-parent:

[509b4b9d1dcc4f8ee2c3fafb7fc226245ad54e79]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1110200706 +0000
Message:

- XA file demux
- EA ADPCM decoder (Maxis games)
(- corner case memleak in adpcm decoder)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac

    r509b4b9 re4f4f59  
    984984VLC_ADD_PLUGINS([id3 playlist export sgimb m3u xtag]) 
    985985VLC_ADD_PLUGINS([i420_rgb rawvideo blend scale image logo]) 
    986 VLC_ADD_PLUGINS([wav araw subtitle vobsub adpcm a52sys dtssys au]) 
     986VLC_ADD_PLUGINS([wav araw subtitle vobsub adpcm a52sys dtssys au xa]) 
    987987VLC_ADD_PLUGINS([access_directory access_file access_udp access_tcp]) 
    988988VLC_ADD_PLUGINS([access_http access_mms access_ftp ipv4]) 
  • modules/codec/adpcm.c

    ra90a19a re4f4f59  
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     8 *          Remi Denis-Courmont <courmisch # via.ecp.fr> 
    89 * 
    910 * This program is free software; you can redistribute it and/or modify 
     
    5556    ADPCM_MS, 
    5657    ADPCM_DK3, 
    57     ADPCM_DK4 
     58    ADPCM_DK4, 
     59    ADPCM_EA 
    5860}; 
    5961 
     
    7375static void DecodeAdpcmDk4   ( decoder_t *, int16_t *, uint8_t * ); 
    7476static void DecodeAdpcmDk3   ( decoder_t *, int16_t *, uint8_t * ); 
     77static void DecodeAdpcmEA    ( decoder_t *, int16_t *, uint8_t * ); 
    7578 
    7679static int pi_channels_maps[6] = 
     
    136139        case VLC_FOURCC('m','s',0x00,0x61): /* Duck DK4 ADPCM */ 
    137140        case VLC_FOURCC('m','s',0x00,0x62): /* Duck DK3 ADPCM */ 
     141        case VLC_FOURCC('X','A','J', 0): /* EA ADPCM */ 
    138142            break; 
    139143        default: 
    140144            return VLC_EGENERIC; 
     145    } 
     146 
     147    if( p_dec->fmt_in.audio.i_channels <= 0 || 
     148        p_dec->fmt_in.audio.i_channels > 5 ) 
     149    { 
     150        msg_Err( p_dec, "bad channels count(1-5)" ); 
     151        return VLC_EGENERIC; 
     152    } 
     153 
     154    if( p_dec->fmt_in.audio.i_rate <= 0 ) 
     155    { 
     156        msg_Err( p_dec, "bad samplerate" ); 
     157        return VLC_EGENERIC; 
    141158    } 
    142159 
     
    146163    { 
    147164        msg_Err( p_dec, "out of memory" ); 
    148         return VLC_EGENERIC; 
    149     } 
    150  
    151     if( p_dec->fmt_in.audio.i_channels <= 0 || 
    152         p_dec->fmt_in.audio.i_channels > 5 ) 
    153     { 
    154         msg_Err( p_dec, "bad channels count(1-5)" ); 
    155         return VLC_EGENERIC; 
    156     } 
    157  
    158     if( p_dec->fmt_in.audio.i_rate <= 0 ) 
    159     { 
    160         msg_Err( p_dec, "bad samplerate" ); 
    161         return VLC_EGENERIC; 
     165        return VLC_ENOMEM; 
    162166    } 
    163167 
     
    178182        case VLC_FOURCC('m','s',0x00,0x62): /* Duck DK3 ADPCM */ 
    179183            p_sys->codec = ADPCM_DK3; 
     184            break; 
     185        case VLC_FOURCC('X','A','J', 0): /* EA ADPCM */ 
     186            p_sys->codec = ADPCM_EA; 
     187            p_dec->fmt_in.p_extra = calloc( 2 * p_dec->fmt_in.audio.i_channels, 
     188                                            sizeof( int16_t ) ); 
     189            if( p_dec->fmt_in.p_extra == NULL ) 
     190            { 
     191                free( p_sys ); 
     192                return VLC_ENOMEM; 
     193            } 
    180194            break; 
    181195    } 
     
    217231        p_sys->i_samplesperblock = ( 4 * ( p_sys->i_block - 16 ) + 2 )/ 3; 
    218232        break; 
     233    case ADPCM_EA: 
     234        p_sys->i_samplesperblock = 
     235            2 * (p_sys->i_block - p_dec->fmt_in.audio.i_channels) / 
     236            p_dec->fmt_in.audio.i_channels; 
    219237    } 
    220238 
     
    304322                            p_block->p_buffer ); 
    305323            break; 
     324        case ADPCM_EA: 
     325            DecodeAdpcmEA( p_dec, (int16_t*)p_out->p_buffer, 
     326                           p_block->p_buffer ); 
    306327        default: 
    307328            break; 
     
    325346    decoder_sys_t *p_sys = p_dec->p_sys; 
    326347 
     348    if( p_sys->codec == ADPCM_EA ) 
     349        free( p_dec->fmt_in.p_extra ); 
    327350    free( p_sys ); 
    328351} 
     
    694717    } 
    695718} 
     719 
     720 
     721/* 
     722 * EA ADPCM 
     723 */ 
     724#define MAX_CHAN 5 
     725static void DecodeAdpcmEA( decoder_t *p_dec, int16_t *p_sample, 
     726                           uint8_t *p_buffer ) 
     727{ 
     728    static const uint32_t EATable[]= 
     729    { 
     730        0x00000000, 0x000000F0, 0x000001CC, 0x00000188, 
     731        0x00000000, 0x00000000, 0xFFFFFF30, 0xFFFFFF24, 
     732        0x00000000, 0x00000001, 0x00000003, 0x00000004, 
     733        0x00000007, 0x00000008, 0x0000000A, 0x0000000B, 
     734        0x00000000, 0xFFFFFFFF, 0xFFFFFFFD, 0xFFFFFFFC 
     735    }; 
     736    decoder_sys_t *p_sys  = p_dec->p_sys; 
     737    uint8_t *p_end; 
     738    unsigned i_channels, c; 
     739    int16_t *prev, *cur; 
     740    int32_t c1[MAX_CHAN], c2[MAX_CHAN]; 
     741    int8_t d[MAX_CHAN]; 
     742 
     743    i_channels = p_dec->fmt_in.audio.i_channels; 
     744    p_end = &p_buffer[p_sys->i_block]; 
     745 
     746    prev = (int16_t *)p_dec->fmt_in.p_extra; 
     747    cur = prev + i_channels; 
     748 
     749    for (c = 0; c < i_channels; c++) 
     750    { 
     751        uint8_t input; 
     752 
     753        input = p_buffer[c]; 
     754        c1[c] = EATable[input >> 4]; 
     755        c2[c] = EATable[(input >> 4) + 4]; 
     756        d[c] = (input & 0xf) + 8; 
     757    } 
     758 
     759    for( p_buffer += i_channels; p_buffer < p_end ; p_buffer += i_channels) 
     760    { 
     761        for (c = 0; c < i_channels; c++) 
     762        { 
     763            int32_t spl; 
     764 
     765            spl = (p_buffer[c] >> 4) & 0xf; 
     766            spl = (spl << 0x1c) >> d[c]; 
     767            spl = (spl + cur[c] * c1[c] + prev[c] * c2[c] + 0x80) >> 8; 
     768            CLAMP( spl, -32768, 32767 ); 
     769            prev[c] = cur[c]; 
     770            cur[c] = spl; 
     771 
     772            *(p_sample++) = spl; 
     773        } 
     774 
     775        for (c = 0; c < i_channels; c++) 
     776        { 
     777            int32_t spl; 
     778 
     779            spl = p_buffer[c] & 0xf; 
     780            spl = (spl << 0x1c) >> d[c]; 
     781            spl = (spl + cur[c] * c1[c] + prev[c] * c2[c] + 0x80) >> 8; 
     782            CLAMP( spl, -32768, 32767 ); 
     783            prev[c] = cur[c]; 
     784            cur[c] = spl; 
     785 
     786            *(p_sample++) = spl; 
     787        } 
     788    } 
     789} 
  • modules/demux/Modules.am

    r0acb799 re4f4f59  
    2222SOURCES_subtitle = subtitle.c 
    2323SOURCES_vobsub = vobsub.c 
     24SOURCES_xa = xa.c