Ignore:
Timestamp:
12/19/06 02:08:32 (19 years ago)
Author:
zorg
Message:

Fix mpcdec compilation for latest libmpcdec
Fix and update cmake build system (static libs only currently)
Use mpc booleans in mppenc

Location:
libmpc/branches/r2d/mpcdec
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/branches/r2d/mpcdec/mpcdec.c

    r85 r162  
    6363main(int argc, char **argv)
    6464{
    65     mpc_reader reader; mpc_streaminfo si; mpc_decoder* decoder; mpc_status err;
     65    mpc_reader reader; mpc_demux* demux; mpc_streaminfo si; mpc_decoder* decoder; mpc_status err;
    6666    MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
    6767    clock_t begin, end, sum; int total_samples; t_wav_output_file wav_output;
    6868    mpc_bool_t is_wav_output;
    6969
     70    printf("mpcdec - musepack (mpc) decoder sample application\n");
    7071    if(3 < argc && argc < 2)
    7172    {
     
    7778    if(err < 0) return !MPC_STATUS_OK;
    7879
    79     err = mpc_streaminfo_init(&si, &reader);
    80     if(err < 0) return !MPC_STATUS_OK;
    81 
    82     err = mpc_decoder_init(&decoder, &reader, &si);
    83     if(err < 0) return !MPC_STATUS_OK;
     80    demux = mpc_demux_init(&reader);
     81    if(!demux) return !MPC_STATUS_OK;
     82    mpc_demux_get_info(demux,  &si);
     83    decoder = mpc_decoder_init(&si);
    8484
    8585    is_wav_output = argc > 2;
     
    9292        wavo_fc.m_user_data = fopen(argv[2], "wb");
    9393        if(!wavo_fc.m_user_data) return !MPC_STATUS_OK;
    94         err = waveformat_output_open(&wav_output, wavo_fc, si.channels, 16, 0, si.sample_freq, (t_wav_uint32) si.pcm_samples * 2);
     94        err = waveformat_output_open(&wav_output, wavo_fc, si.channels, 16, 0, si.sample_freq, (t_wav_uint32) si.samples * 2);
    9595        if(!err) return !MPC_STATUS_OK;
    9696    }
     
    9999    while(MPC_TRUE)
    100100    {
    101         mpc_uint32_t samples;
     101        mpc_frame_info frame; mpc_uint32_t samples;
    102102
    103         begin   = clock();
    104         samples = mpc_decoder_decode(decoder, sample_buffer, 0, 0);
    105         end     = clock();
     103        frame.buffer = sample_buffer;
     104        begin        = clock();
     105        mpc_demux_decode(demux, &frame);
     106        end          = clock();
     107        if(frame.bits == -1) break;
    106108
    107         if(samples <= 0) break;
    108         if(!samples)     break;
    109         total_samples += samples;
     109        total_samples += frame.samples;
    110110        sum           += end - begin;
    111111
    112112        if(is_wav_output)
    113             if(waveformat_output_process_float32(&wav_output, sample_buffer, samples*2) < 0)
     113            if(waveformat_output_process_float32(&wav_output, sample_buffer, frame.samples*2) < 0)
    114114                break;
    115115    }
     
    124124
    125125    mpc_decoder_exit(decoder);
     126    mpc_demux_exit(demux);
    126127    mpc_reader_exit_stdio(&reader);
    127128    if(is_wav_output)
Note: See TracChangeset for help on using the changeset viewer.