Changeset 22d851e1d2c4aaf47a2f6ebf0de01b3a8e1d4cdd

Show
Ignore:
Timestamp:
25/01/03 17:58:35 (6 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1043513915 +0000
git-parent:

[25eea88d8bddd72976a76ce8ecf979a4033abf1d]

git-author:
Laurent Aimar <fenrir@videolan.org> 1043513915 +0000
Message:
  • all : fixed some memory leaks thanks valgrind.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/aac/demux.c

    r2f9b054 r22d851e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: demux.c,v 1.4 2003/01/20 13:03:03 fenrir Exp $ 
     5 * $Id: demux.c,v 1.5 2003/01/25 16:58:34 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    8  *  
     8 * 
    99 * This program is free software; you can redistribute it and/or modify 
    1010 * it under the terms of the GNU General Public License as published by 
    1111 * the Free Software Foundation; either version 2 of the License, or 
    1212 * (at your option) any later version. 
    13  *  
     13 * 
    1414 * This program is distributed in the hope that it will be useful, 
    1515 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     
    3636 * Local prototypes 
    3737 *****************************************************************************/ 
    38 static int  Activate ( vlc_object_t * ); 
    39 static int  Demux ( input_thread_t * ); 
    40  
     38static int  Activate    ( vlc_object_t * ); 
     39static int  Demux       ( input_thread_t * ); 
     40static void Deactivate  ( vlc_object_t * ); 
    4141 
    4242/***************************************************************************** 
     
    5151 
    5252/***************************************************************************** 
    53  * Definitions of structures  and functions used by this plugins  
    54  *****************************************************************************/ 
    55  
     53 * Definitions of structures  and functions used by this plugins 
     54 *****************************************************************************/ 
     55#define FREE( p ) if( p ) { free( p );  (p) = NULL; } 
    5656/* XXX set this to 0 to avoid problem with PS XXX */ 
    5757/* but with some file or web radio will failed to detect */ 
     
    8585    int i_no_raw_data_blocks_in_frame; 
    8686    int i_crc_check; 
    87                      
     87 
    8888} adts_header_t; 
    8989 
     
    9191typedef struct adif_header_s 
    9292{ 
    93     int b_copyright_id_present; 
    94     u8 i_copyright_id[10]; 
    95      
    96     int b_original_copy; 
    97  
    98     int i_home; 
    99     int i_bitstream_type; 
    100     int i_bitrate; 
    101     int i_num_program_config_elements; 
    102     int adif_buffer_fullness; 
     93    int     b_copyright_id_present; 
     94    uint8_t i_copyright_id[10]; 
     95 
     96    int     b_original_copy; 
     97 
     98    int     i_home; 
     99    int     i_bitstream_type; 
     100    int     i_bitrate; 
     101    int     i_num_program_config_elements; 
     102    int     adif_buffer_fullness; 
    103103 
    104104//    program_config_element 
     
    132132 **************************************************************************** 
    133133 * 
    134  ****************************************************************************/  
     134 ****************************************************************************/ 
    135135typedef struct bit_s 
    136136{ 
    137     u8 *p_buffer; 
     137    uint8_t *p_buffer; 
    138138    int i_buffer; 
    139139    int i_mask; 
     
    141141 
    142142static void bit_init( bit_t *p_bit, 
    143                       u8    *p_buffer, 
     143                      uint8_t    *p_buffer, 
    144144                      int   i_buffer ) 
    145145{ 
     
    149149} 
    150150 
    151 static u32 bit_get( bit_t *p_bit ) 
    152 { 
    153     u32 i_bit; 
     151static uint32_t bit_get( bit_t *p_bit ) 
     152{ 
     153    uint32_t i_bit; 
    154154    if( p_bit->i_buffer <= 0 ) 
    155155    { 
     
    157157    } 
    158158    i_bit = ( p_bit->p_buffer[0]&p_bit->i_mask ) ? 1 : 0; 
    159      
     159 
    160160    p_bit->i_mask >>= 1; 
    161161    if( !p_bit->i_mask ) 
     
    168168} 
    169169 
    170 static u32 bit_gets( bit_t *p_bit, int i_count ) 
    171 { 
    172     u32 i_bits; 
     170static uint32_t bit_gets( bit_t *p_bit, int i_count ) 
     171{ 
     172    uint32_t i_bits; 
    173173    i_bits = 0; 
    174174    for( ; i_count > 0; i_count-- ) 
     
    186186 * 
    187187 * ReadPes : read data and make a PES 
    188  *  
     188 * 
    189189 *****************************************************************************/ 
    190190static int SkipBytes( input_thread_t *p_input, int i_size ) 
     
    206206} 
    207207 
    208 static int ReadPES( input_thread_t *p_input,  
    209                     pes_packet_t **pp_pes,  
     208static int ReadPES( input_thread_t *p_input, 
     209                    pes_packet_t **pp_pes, 
    210210                    int i_size ) 
    211211{ 
     
    213213 
    214214    *pp_pes = NULL; 
    215          
     215 
    216216    if( !(p_pes = input_NewPES( p_input->p_method_data )) ) 
    217217    { 
     
    225225        int i_read; 
    226226 
    227         if( (i_read = input_SplitBuffer( p_input,  
    228                                          &p_data,  
     227        if( (i_read = input_SplitBuffer( p_input, 
     228                                         &p_data, 
    229229                                         __MIN( i_size, 1024 ) ) ) <= 0 ) 
    230230        { 
     
    257257                    adif_header_t  *p_adif ) 
    258258{ 
    259     u8  *p_peek; 
     259    uint8_t  *p_peek; 
    260260    int i_size; 
    261261 
     
    270270        return( 0 ); 
    271271    } 
    272      
     272 
    273273    /* we now that we have an adif header */ 
    274      
     274 
    275275//    return( 1 ); 
    276276    return( 0 ); /* need some work */ 
     
    286286                    int             *pi_skip ) 
    287287{ 
    288     u8  *p_peek; 
     288    uint8_t  *p_peek; 
    289289    int i_size; 
    290290    bit_t bit; 
     
    316316    bit_init( &bit, p_peek, i_size ); 
    317317    bit_gets( &bit, 12 ); /* synchro bits */ 
    318      
     318 
    319319    p_adts->i_id        = bit_get( &bit ); 
    320320    p_adts->i_layer     = bit_gets( &bit, 2); 
     
    355355        p_aac->i_object_type = p_aac->adts_header.i_profile; 
    356356        p_aac->i_samplerate  = i_aac_samplerate[p_aac->i_samplerate_index]; 
    357         p_aac->i_channels    = p_aac->adts_header.i_channel_configuration;        
     357        p_aac->i_channels    = p_aac->adts_header.i_channel_configuration; 
    358358        if( p_aac->i_channels > 6 ) 
    359359        { 
     
    382382static int CheckPS( input_thread_t *p_input ) 
    383383{ 
    384     u8 *p_peek; 
     384    uint8_t *p_peek; 
    385385    int i_size = input_Peek( p_input, &p_peek, 8196 ); 
    386386 
     
    407407    input_info_category_t * p_category; 
    408408    module_t * p_id3; 
    409      
     409 
    410410    int i_skip; 
    411411    int b_forced; 
     
    423423    b_forced = ( ( *p_input->psz_demux )&& 
    424424                 ( !strncmp( p_input->psz_demux, "aac", 10 ) ) ) ? 1 : 0; 
    425      
     425 
    426426    /* check if it can be a ps stream */ 
    427427    if( !b_forced && CheckPS(  p_input ) ) 
     
    430430    } 
    431431 
    432     /* skip possible id3 header */     
     432    /* skip possible id3 header */ 
    433433    p_id3 = module_Need( p_input, "id3", NULL ); 
    434434    if ( p_id3 ) { 
    435435        module_Unneed( p_input, p_id3 ); 
    436436    } 
    437      
     437 
    438438    /* allocate p_aac */ 
    439439    if( !( p_aac = malloc( sizeof( demux_sys_t ) ) ) ) 
     
    443443    } 
    444444    memset( p_aac, 0, sizeof( demux_sys_t ) ); 
    445      
     445 
    446446    /* Now check for adif/adts header */ 
    447447    i_skip = 0; 
     
    455455    } 
    456456    else 
    457     if( GetADTS( p_input,  
    458                  &p_aac->adts_header,  
     457    if( GetADTS( p_input, 
     458                 &p_aac->adts_header, 
    459459                 b_forced ? 8000 : 0, 
    460460                 &i_skip  ) ) 
     
    479479        msg_Err( p_input, "cannot init stream" ); 
    480480        return( -1 ); 
    481     }     
     481    } 
    482482    if( input_AddProgram( p_input, 0, 0) == NULL ) 
    483483    { 
     
    488488    p_input->stream.pp_programs[0]->b_is_ok = 0; 
    489489    p_input->stream.p_selected_program = p_input->stream.pp_programs[0]; 
    490      
    491     /* create our ES */  
    492     p_aac->p_es = input_AddES( p_input,  
     490 
     491    /* create our ES */ 
     492    p_aac->p_es = input_AddES( p_input, 
    493493                               p_input->stream.p_selected_program,  
    494494                               1, /* id */ 
     
    500500        return( -1 ); 
    501501    } 
    502      
     502 
    503503    p_aac->p_es->i_stream_id = 1; 
    504504    p_aac->p_es->i_fourcc = VLC_FOURCC( 'm', 'p', '4', 'a' ); 
     
    510510 
    511511 
    512      
     512 
    513513    vlc_mutex_lock( &p_input->stream.stream_lock ); 
    514514    if( p_aac->b_adif_header ) 
     
    548548        vlc_mutex_lock( &p_input->stream.stream_lock ); 
    549549        p_category = input_InfoCategory( p_input, "aac" ); 
    550      
     550 
    551551        input_AddInfo( p_category, "input type", "MPEG-%d AAC", 
    552552                       p_aac->adts_header.i_id == 1 ? 2 : 4 ); 
     
    563563 
    564564    p_input->p_demux_data = p_aac; 
    565      
     565 
    566566 
    567567    return( 0 ); 
     
    577577    int i_skip; 
    578578    int i_found; 
    579      
     579 
    580580    pes_packet_t    *p_pes; 
    581581    demux_sys_t *p_aac = p_input->p_demux_data; 
     
    590590    if( p_aac->b_adts_header ) 
    591591    { 
    592         i_found = GetADTS( p_input,  
     592        i_found = GetADTS( p_input, 
    593593                           &p_aac->adts_header, 
    594594                           8000, 
     
    600600    } 
    601601    ExtractConfiguration( p_aac ); 
    602     
     602 
    603603    /* skip garbage bytes */ 
    604604    if( i_skip > 0 ) 
     
    615615        return( 0 ); 
    616616    } 
    617      
     617 
    618618    input_ClockManageRef( p_input, 
    619619                          p_input->stream.p_selected_program, 
    620620                          p_aac->i_pts ); 
    621     
     621 
    622622    if( !ReadPES( p_input, &p_pes, p_aac->i_aac_frame_length ) ) 
    623623    { 
     
    643643 
    644644    /* Update date information */ 
    645     p_aac->i_pts += (mtime_t)90000 *  
     645    p_aac->i_pts += (mtime_t)90000 * 
    646646                    (mtime_t)p_aac->i_framelength / 
    647647                    (mtime_t)p_aac->i_samplerate; 
     
    650650} 
    651651 
     652static void Deactivate( vlc_object_t * p_this ) 
     653{ 
     654    input_thread_t *p_input = (input_thread_t*)p_this; 
     655//    demux_sys_t    *p_aac = p_input->p_demux_data; 
     656 
     657    FREE( p_input->p_demux_data ); 
     658} 
     659 
  • modules/demux/asf/asf.c

    r27ebd5c r22d851e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: asf.c,v 1.17 2003/01/23 15:07:20 fenrir Exp $ 
     5 * $Id: asf.c,v 1.18 2003/01/25 16:58:34 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 * 
     
    859859#undef p_stream 
    860860    } 
    861  
     861    FREE( p_input->p_demux_data ); 
    862862#undef FREE 
    863863} 
  • modules/demux/avi/avi.c

    r8a517cb r22d851e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: avi.c,v 1.30 2003/01/25 03:12:20 fenrir Exp $ 
     5 * $Id: avi.c,v 1.31 2003/01/25 16:58:34 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 * 
     
    5353 
    5454#define AVIEnd(a) __AVIEnd(VLC_OBJECT(a)) 
    55  
     55#define FREE( p ) if( p ) { free( p ); (p) = NULL; } 
    5656/***************************************************************************** 
    5757 * Module descriptor 
     
    794794#endif 
    795795    AVI_ChunkFreeRoot( p_input, &p_avi->ck_root ); 
     796 
     797    FREE( p_input->p_demux_data ); 
    796798} 
    797799 
  • modules/demux/avi/libavi.c

    r9a5b0b8 r22d851e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: libavi.c,v 1.14 2003/01/20 13:01:53 fenrir Exp $ 
     5 * $Id: libavi.c,v 1.15 2003/01/25 16:58:34 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 * 
     
    521521    { 
    522522        case( AVIFOURCC_auds ): 
     523            p_chk->strf.auds.i_cat = AUDIO_ES; 
    523524            p_chk->strf.auds.p_wf = malloc( p_chk->common.i_chunk_size ); 
    524525            AVI_READ2BYTES( p_chk->strf.auds.p_wf->wFormatTag ); 
     
    562563        case( AVIFOURCC_vids ): 
    563564            p_strh->strh.i_samplesize = 0; // XXX for ffmpeg avi file 
     565            p_chk->strf.vids.i_cat = VIDEO_ES; 
    564566            p_chk->strf.vids.p_bih = malloc( p_chk->common.i_chunk_size ); 
    565567            AVI_READ4BYTES( p_chk->strf.vids.p_bih->biSize ); 
     
    598600        default: 
    599601            msg_Warn( p_input, "unknown stream type" ); 
     602            p_chk->strf.common.i_cat = UNKNOWN_ES; 
    600603            break; 
    601604    } 
     
    605608                               avi_chunk_t *p_chk ) 
    606609{ 
    607  
     610    avi_chunk_strf_t *p_strf = (avi_chunk_strf_t*)p_chk; 
     611    switch( p_strf->common.i_cat ) 
     612    { 
     613        case AUDIO_ES: 
     614            FREE( p_strf->auds.p_wf ); 
     615            break; 
     616        case VIDEO_ES: 
     617            FREE( p_strf->vids.p_bih ); 
     618            break; 
     619        default: 
     620            break; 
     621    } 
    608622} 
    609623 
  • modules/demux/avi/libavi.h

    rade615b r22d851e  
    33 ****************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: libavi.h,v 1.6 2002/12/06 16:34:06 sam Exp $ 
     5 * $Id: libavi.h,v 1.7 2003/01/25 16:58:34 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 *  
     
    238238{ 
    239239    AVI_CHUNK_COMMON 
     240    int             i_cat; 
    240241    WAVEFORMATEX    *p_wf; 
    241242} avi_chunk_strf_auds_t; 
     
    244245{ 
    245246    AVI_CHUNK_COMMON 
     247    int              i_cat; 
    246248    BITMAPINFOHEADER *p_bih; 
    247249} avi_chunk_strf_vids_t; 
     
    251253    avi_chunk_strf_auds_t   auds; 
    252254    avi_chunk_strf_vids_t   vids; 
     255    struct 
     256    { 
     257        AVI_CHUNK_COMMON 
     258        int i_cat; 
     259    }                       common; 
    253260} avi_chunk_strf_t; 
    254261 
  • modules/demux/demuxdump.c

    rf22f4ef r22d851e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: demuxdump.c,v 1.2 2002/12/18 14:17:10 sam Exp $ 
     5 * $Id: demuxdump.c,v 1.3 2003/01/25 16:58:34 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    114114        p_demux->psz_name = psz_name; 
    115115    } 
    116      
     116 
    117117    p_demux->i_write = 0; 
    118118    p_demux->p_demux_data_sav = p_input->p_demux_data; 
     
    125125    else 
    126126    { 
    127      
     127 
    128128        if( input_InitStream( p_input, 0 ) == -1 ) 
    129129        { 
     
    134134        input_AddProgram( p_input, 0, 0 ); 
    135135        p_input->stream.p_selected_program = p_input->stream.pp_programs[0]; 
    136          
     136 
    137137        vlc_mutex_lock( &p_input->stream.stream_lock ); 
    138138        p_input->stream.p_selected_area->i_tell = 0; 
     
    156156    input_thread_t      *p_input = (input_thread_t *)p_this; 
    157157    demux_sys_t         *p_demux = (demux_sys_t*)p_input->p_demux_data; 
    158      
    159     msg_Info( p_input,  
    160               "closing %s ("I64Fd" Kbytes dumped)",  
     158 
     159    msg_Info( p_input, 
     160              "closing %s ("I64Fd" Kbytes dumped)", 
    161161              p_demux->psz_name, 
    162162              p_demux->i_write / 1024 ); 
    163     
     163 
    164164    if( p_demux->p_file ) 
    165165    { 
     
    169169    if( p_demux->psz_name ) 
    170170    { 
    171         free( p_demux->psz_name );     
     171        free( p_demux->psz_name ); 
    172172    } 
    173173    p_input->p_demux_data = p_demux->p_demux_data_sav; 
  • modules/demux/mp4/libmp4.c

    r4f21763 r22d851e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: libmp4.c,v 1.12 2003/01/13 02:30:11 fenrir Exp $ 
     5 * $Id: libmp4.c,v 1.13 2003/01/25 16:58:34 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    7  *  
     7 * 
    88 * This program is free software; you can redistribute it and/or modify 
    99 * it under the terms of the GNU General Public License as published by 
    1010 * the Free Software Foundation; either version 2 of the License, or 
    1111 * (at your option) any later version. 
    12  *  
     12 * 
    1313 * This program is distributed in the hope that it will be useful, 
    1414 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     
    3636 
    3737/***************************************************************************** 
    38  * Here are defined some macro to make life simpler but before using it  
    39  *  *look* at the code.  
     38 * Here are defined some macro to make life simpler but before using it 
     39 *  *look* at the code. 
    4040 * 
    4141 *  XXX: All macro are written in capital letters 
     
    4545  ( 8 + ( p_box->i_shortsize == 1 ? 8 : 0 ) \ 
    4646      + ( p_box->i_type == FOURCC_uuid ? 16 : 0 ) ) 
    47      
     47 
    4848#define MP4_BOX_DESCEND( p_box ) \ 
    4949    MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) ) 
     
    6060#define MP4_GET4BYTES( dst ) \ 
    6161    dst = GetDWBE( p_peek ); p_peek += 4; i_read -= 4 
    62      
     62 
    6363#define MP4_GETFOURCC( dst ) \ 
    6464    dst = VLC_FOURCC( p_peek[0], p_peek[1], p_peek[2], p_peek[3] ); \ 
     
    6767#define MP4_GET8BYTES( dst ) \ 
    6868    dst = GetQWBE( p_peek ); p_peek += 8; i_read -= 8 
    69          
     69 
    7070#define MP4_GETVERSIONFLAGS( p_void ) \ 
    7171    MP4_GET1BYTE( p_void->i_version ); \ 
    7272    MP4_GET3BYTES( p_void->i_flags ) 
    73      
     73 
    7474#define MP4_GETSTRINGZ( p_str ) \ 
    7575    if( ( i_read > 0 )&&(p_peek[0] ) ) \ 
     
    8585        p_str = NULL; \ 
    8686    } 
    87      
     87 
    8888 
    8989#define MP4_READBOX_ENTER( MP4_Box_data_TYPE_t ) \ 
     
    106106      free( p_buff ); \ 
    107107      return( 0 ); \ 
    108     }  
    109                  
     108    } 
     109 
    110110#define MP4_READBOX_EXIT( i_code ) \ 
    111111    free( p_buff ); \ 
     
    118118#define FREE( p ) \ 
    119119    if( p ) {free( p ); p = NULL; } 
    120     
    121  
    122      
     120 
     121 
     122 
    123123/* Some assumptions: 
    124         * The input method HAVE to be seekable  
    125   
     124        * The input method HAVE to be seekable 
     125 
    126126*/ 
    127127 
     
    188188    i_min  = ( i_date / 60 ) % 60; 
    189189    i_sec =  i_date % 60; 
    190     /* FIXME do it correctly, date begin at 1 jan 1904 */  
     190    /* FIXME do it correctly, date begin at 1 jan 1904 */ 
    191191    sprintf( psz, "%dd-%2.2dh:%2.2dm:%2.2ds", 
    192192                   i_day, i_hour, i_min, i_sec ); 
     
    199199 * 
    200200 * MP4_TellAbsolute get file position 
    201  *  
     201 * 
    202202 * MP4_SeekAbsolute seek in the file 
    203203 * 
     
    208208{ 
    209209    off_t i_pos; 
    210      
     210 
    211211    vlc_mutex_lock( &p_input->stream.stream_lock ); 
    212      
     212 
    213213    i_pos= p_input->stream.p_selected_area->i_tell; 
    214214//            ( p_input->p_last_data - p_input->p_current_data  ); 
     
    218218    return( i_pos ); 
    219219} 
    220   
     220 
    221221int MP4_SeekAbsolute( input_thread_t *p_input, 
    222222                       off_t i_pos) 
     
    228228        return( 0 ); 
    229229    } 
    230              
     230 
    231231    i_filepos = MP4_TellAbsolute( p_input ); 
    232232    if( i_pos != i_filepos ) 
     
    245245    int i_read; 
    246246 
    247                  
     247 
    248248    if( !i_size ) 
    249249    { 
     
    260260        memcpy( p_buff, p_data->p_payload_start, i_read ); 
    261261        input_DeletePacket( p_input->p_method_data, p_data ); 
    262          
     262 
    263263        p_buff += i_read; 
    264264        i_size -= i_read; 
    265                  
     265 
    266266    } while( i_size ); 
    267      
     267 
    268268    return( 1 ); 
    269269} 
     
    417417 
    418418/***************************************************************************** 
    419  * MP4_ReadBoxCommon : Load only common parameters for all boxes  
     419 * MP4_ReadBoxCommon : Load only common parameters for all boxes 
    420420 ***************************************************************************** 
    421  * p_box need to be an already allocated MP4_Box_t, and all data  
     421 * p_box need to be an already allocated MP4_Box_t, and all data 
    422422 *  will only be peek not read 
    423423 * 
     
    428428    int i_read; 
    429429    uint8_t  *p_peek; 
    430      
     430 
    431431    if( ( ( i_read = MP4_PeekStream( p_stream, &p_peek, 32 ) ) < 8 ) ) 
    432432    { 
     
    440440    p_box->p_last  = NULL; 
    441441    p_box->p_next   = NULL; 
    442      
     442 
    443443    MP4_GET4BYTES( p_box->i_shortsize ); 
    444444    MP4_GETFOURCC( p_box->i_type ); 
     
    456456        /* XXX size of 0 means that the box extends to end of file */ 
    457457    } 
    458      
     458 
    459459    if( p_box->i_type == FOURCC_uuid ) 
    460460    { 
     
    514514} 
    515515/***************************************************************************** 
    516  * MP4_MP4_GotoBox : Go to this particular box  
     516 * MP4_MP4_GotoBox : Go to this particular box 
    517517 ***************************************************************************** 
    518518 * RETURN : 0 if it fail, 1 otherwise 
     
    525525 
    526526/***************************************************************************** 
    527  * For all known box a loader is given,  
     527 * For all known box a loader is given, 
    528528 *  XXX: all common struct have to be already read by MP4_ReadBoxCommon 
    529529 *       after called one of theses functions, file position is unknown 
    530  *       you need to call MP4_GotoBox to go where you want  
     530 *       you need to call MP4_GotoBox to go where you want 
    531531 *****************************************************************************/ 
    532532int MP4_ReadBoxContainerRaw( MP4_Stream_t *p_stream, MP4_Box_t *p_container ) 
    533533{ 
    534534    MP4_Box_t *p_box; 
    535      
     535 
    536536    if( MP4_TellStream( p_stream ) + 8 >  
    537537                 (off_t)(p_container->i_pos + p_container->i_size) ) 
     
    540540        return( 0 ); 
    541541    } 
    542      
     542 
    543543    do 
    544544    { 
     
    564564            break; 
    565565        } 
    566          
     566 
    567567    }while( MP4_NextBox( p_stream, p_box ) == 1 ); 
    568      
     568 
    569569    return( 1 ); 
    570570} 
     
    573573int MP4_ReadBoxContainer( MP4_Stream_t *p_stream, MP4_Box_t *p_container ) 
    574574{ 
    575      
     575 
    576576    if( p_container->i_size <= (size_t)MP4_BOX_HEADERSIZE(p_container ) + 8 ) 
    577577    { 
     
    579579        return( 1 ); 
    580580    } 
    581      
     581 
    582582    /* enter box */ 
    583583    MP4_BOX_DESCEND( p_container ); 
     
    595595    /* Nothing to do */ 
    596596#ifdef MP4_VERBOSE 
    597     msg_Dbg( p_stream->p_input, "Skip box: \"%c%c%c%c\"",  
     597    msg_Dbg( p_stream->p_input, "Skip box: \"%c%c%c%c\"", 
    598598            (p_box->i_type)&0xff,  
    599599            (p_box->i_type>>8)&0xff, 
     
    607607{ 
    608608    MP4_READBOX_ENTER( MP4_Box_data_ftyp_t ); 
    609      
     609 
    610610    MP4_GETFOURCC( p_box->data.p_ftyp->i_major_brand ); 
    611611    MP4_GET4BYTES( p_box->data.p_ftyp->i_minor_version ); 
    612      
     612 
    613613    if( ( p_box->data.p_ftyp->i_compatible_brands_count = i_read / 4 ) ) 
    614614    { 
    615615        unsigned int i; 
    616         p_box->data.p_ftyp->i_compatible_brands =  
     616        p_box->data.p_ftyp->i_compatible_brands = 
    617617            calloc( p_box->data.p_ftyp->i_compatible_brands_count, sizeof(uint32_t)); 
    618618 
     
    11691169        MP4_READBOX_EXIT( 1 ); 
    11701170    } 
    1171     
     1171 
    11721172    i_len = MP4_ReadLengthDescriptor( &p_peek, &i_read ); 
    11731173    es_descriptor.p_decConfigDescr->i_decoder_specific_info_len = i_len; 
     
    11841184{ 
    11851185    FREE( p_box->data.p_esds->es_descriptor.psz_URL ); 
     1186    if( p_box->data.p_esds->es_descriptor.p_decConfigDescr ) 
     1187    { 
     1188        FREE( p_box->data.p_esds->es_descriptor.p_decConfigDescr->p_decoder_specific_info ); 
     1189    } 
    11861190    FREE( p_box->data.p_esds->es_descriptor.p_decConfigDescr ); 
    11871191} 
     
    11891193int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) 
    11901194{ 
    1191     unsigned int i;     
    1192      
     1195    unsigned int i; 
     1196 
    11931197    MP4_READBOX_ENTER( MP4_Box_data_sample_soun_t ); 
    11941198 
     
    11991203 
    12001204    MP4_GET2BYTES( p_box->data.p_sample_soun->i_data_reference_index ); 
    1201      
     1205 
    12021206    for( i = 0; i < 2 ; i++ ) 
    12031207    { 
    12041208        MP4_GET4BYTES( p_box->data.p_sample_soun->i_reserved2[i] ); 
    12051209    } 
    1206     
     1210 
    12071211    MP4_GET2BYTES( p_box->data.p_sample_soun->i_channelcount ); 
    12081212    MP4_GET2BYTES( p_box->data.p_sample_soun->i_samplesize ); 
     
    12111215    MP4_GET2BYTES( p_box->data.p_sample_soun->i_sampleratehi ); 
    12121216    MP4_GET2BYTES( p_box->data.p_sample_soun->i_sampleratelo ); 
    1213      
     1217 
    12141218    MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 28 ); 
    12151219    MP4_ReadBoxContainerRaw( p_stream, p_box ); /* esds */ 
    1216     
     1220 
    12171221#ifdef MP4_VERBOSE 
    12181222    msg_Dbg( p_stream->p_input, "Read Box: \"soun\" in stsd channel %d sample size %d sampl rate %f", 
     
    12321236 
    12331237    MP4_READBOX_ENTER( MP4_Box_data_sample_mp4a_t ); 
    1234      
     1238 
    12351239    for( i = 0; i < 6 ; i++ ) 
    12361240    { 
     
    12391243 
    12401244    MP4_GET2BYTES( p_box->data.p_sample_mp4a->i_data_reference_index ); 
    1241      
     1245 
    12421246    for( i = 0; i < 2 ; i++ ) 
    12431247    { 
    12441248        MP4_GET4BYTES( p_box->data.p_sample_mp4a->i_reserved2[i] ); 
    12451249    } 
    1246     
     1250 
    12471251    MP4_GET2BYTES( p_box->data.p_sample_mp4a->i_channelcount ); 
    12481252    MP4_GET2BYTES( p_box->data.p_sample_mp4a->i_samplesize ); 
  • modules/demux/mp4/mp4.c

    rfcfb04f r22d851e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: mp4.c,v 1.12 2003/01/08 10:46:30 fenrir Exp $ 
     5 * $Id: mp4.c,v 1.13 2003/01/25 16:58:34 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 * 
     
    442442            } 
    443443        } 
     444        FREE( p_demux->track[i_track].chunk ); 
    444445 
    445446        if( !p_demux->track[i_track].i_sample_size ) 
     
    449450    } 
    450451    FREE( p_demux->track ); 
     452 
     453    FREE( p_input->p_demux_data ); 
    451454#undef FREE 
    452455} 
     
    10581061            /* now create a bitmapinfoheader_t for decoder and  
    10591062               add information found in p_esds */ 
    1060             p_init = malloc( sizeof( BITMAPINFOHEADER ) + i_decoder_specific_info_len ); 
     1063            /* XXX XXX + 16 are for avoid segfault when ffmpeg access beyong the data */ 
     1064            p_init = malloc( sizeof( BITMAPINFOHEADER ) + i_decoder_specific_info_len + 16 ); 
    10611065            p_bih = (BITMAPINFOHEADER*)p_init; 
    10621066 
     
    11181122 
    11191123        case( AUDIO_ES ): 
    1120             p_init = malloc( sizeof( WAVEFORMATEX ) + i_decoder_specific_info_len); 
     1124            p_init = malloc( sizeof( WAVEFORMATEX ) + i_decoder_specific_info_len + 16 ); 
    11211125            p_wf = (WAVEFORMATEX*)p_init; 
    11221126 
  • modules/demux/wav/wav.c

    r81b7c54 r22d851e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: wav.c,v 1.9 2003/01/07 21:49:01 fenrir Exp $ 
     5 * $Id: wav.c,v 1.10 2003/01/25 16:58:35 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 *  
     
    6161 
    6262/* Some functions to manipulate memory */ 
    63 static u16 GetWLE( u8 *p_buff ) 
     63static uint16_t GetWLE( uint8_t *p_buff ) 
    6464{ 
    6565    return( (p_buff[0]) + ( p_buff[1] <<8 ) ); 
    6666} 
    6767 
    68 static u32 GetDWLE( u8 *p_buff ) 
     68static uint32_t GetDWLE( uint8_t *p_buff ) 
    6969{ 
    7070    return( p_buff[0] + ( p_buff[1] <<8 ) + 
     
    7272} 
    7373 
    74 static u32 CreateDWLE( int a, int b, int c, int d ) 
     74static uint32_t CreateDWLE( int a, int b, int c, int d ) 
    7575{ 
    7676    return( a + ( b << 8 ) + ( c << 16 ) + ( d << 24 ) ); 
     
    117117 
    118118/* return 1 if success, 0 if fail */ 
    119 static int ReadData( input_thread_t *p_input, u8 *p_buff, int i_size ) 
     119static int ReadData( input_thread_t *p_input, uint8_t *p_buff, int i_size ) 
    120120{ 
    121121    data_packet_t *p_data; 
     
    123123    int i_read; 
    124124 
    125                  
     125 
    126126    if( !i_size ) 
    127127    { 
     
    138138        memcpy( p_buff, p_data->p_payload_start, i_read ); 
    139139        input_DeletePacket( p_input->p_method_data, p_data ); 
    140          
     140 
    141141        p_buff += i_read; 
    142142        i_size -= i_read; 
    143                  
     143 
    144144    } while( i_size ); 
    145      
     145 
    146146    return( 1 ); 
    147147} 
     
    155155 
    156156    *pp_pes = NULL; 
    157          
     157 
    158158    if( !(p_pes = input_NewPES( p_input->p_method_data )) ) 
    159159    { 
     
    193193} 
    194194 
    195 static int FindTag( input_thread_t *p_input, u32 i_tag ) 
    196 { 
    197     u32   i_id; 
    198     u32   i_size; 
    199     u8    *p_peek; 
     195static int FindTag( input_thread_t *p_input, uint32_t i_tag ) 
     196{ 
     197    uint32_t   i_id; 
     198    uint32_t   i_size; 
     199    uint8_t    *p_peek; 
    200200 
    201201    for( ;; ) 
     
    227227                        demux_sys_t *p_demux ) 
    228228{ 
    229     u8  *p_peek; 
    230     u32 i_size; 
     229    uint8_t  *p_peek; 
     230    uint32_t i_size; 
    231231    WAVEFORMATEX *p_wf; 
    232              
     232 
    233233 
    234234    if( input_Peek( p_input, &p_peek , 8 ) < 8 ) 
     
    278278    /* read samples for 50ms of */ 
    279279    i_samples = __MAX( p_wf->nSamplesPerSec / 20, 1 ); 
    280          
    281      
     280