Changeset 213


Ignore:
Timestamp:
02/13/07 12:13:51 (17 years ago)
Author:
r2d
Message:
  • mpcenc should now support encoding from pipe with unknow file length (fb2k), untested
File:
1 edited

Legend:

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

    r212 r213  
    15141514        PsyModel         m;
    15151515        mpc_encoder_t    e;
     1516        mpc_uint_t si_size;
    15161517
    15171518    // initialize tables which must be initialized once and only once
     
    16111612        writeStreamInfo ( &e, m.Max_Band, m.MS_Channelmode > 0, SamplesInWAVE,
    16121613                                           m.SampleFreq, Wave.Channels > 2 ? 2 : Wave.Channels, 0, 0, 0, 0);
    1613         writeBlock(&e, "SI", MPC_TRUE, 0);
     1614        si_size = writeBlock(&e, "SI", MPC_TRUE, 0);
    16141615        writeEncoderInfo(&e, m.FullQual, m.PNS > 0, MPPENC_MAJOR, MPPENC_MINOR,
    16151616                                          MPPENC_IMPLEMENT, MPPENC_BUILD);
     
    16421643    if ( myfeof (Wave.fp) ) {
    16431644        stderr_printf ( "WAVE file has incorrect header: header: %.3f s, contents: %.3f s    \n",
    1644                                                 (long double)(AllSamplesRead) / m.SampleFreq, (long double)(SamplesInWAVE) / m.SampleFreq );
    1645         SamplesInWAVE = AllSamplesRead;
     1645                                                (long double)(SamplesInWAVE) / m.SampleFreq, (long double)(AllSamplesRead) / m.SampleFreq);
    16461646    }
    16471647
     
    17121712        // adapt SamplesInWAV to the real number of contained samples
    17131713        if ( myfeof (Wave.fp) ) {
    1714             stderr_printf ( "WAVE file has incorrect header: header: %.3f s, contents: %.3f s    \n",
    1715                                                         (long double)(AllSamplesRead) / m.SampleFreq, (long double)(SamplesInWAVE) / m.SampleFreq );
    1716             SamplesInWAVE = AllSamplesRead;
     1714                        stderr_printf ( "WAVE file has incorrect header: header: %.3f s, contents: %.3f s    \n",
     1715                                                        (long double)(SamplesInWAVE) / m.SampleFreq, (long double)(AllSamplesRead) / m.SampleFreq);
    17171716        }
    17181717    }
     
    17301729        writeBlock(&e, "ST", MPC_FALSE, 0); // write seek table block
    17311730        writeBlock(&e, "SE", MPC_FALSE, 0); // write end of stream block
     1731
     1732        if (SamplesInWAVE != AllSamplesRead) {
     1733                SamplesInWAVE = AllSamplesRead;
     1734                fseek(e.outputFile, e.seek_ref + 4, SEEK_SET);
     1735                writeStreamInfo ( &e, m.Max_Band, m.MS_Channelmode > 0, SamplesInWAVE,
     1736                                                   m.SampleFreq, Wave.Channels > 2 ? 2 : Wave.Channels, 0, 0, 0, 0);
     1737                writeBlock(&e, "SI", MPC_TRUE, si_size);
     1738                fseek(e.outputFile, 0, SEEK_END);
     1739        }
     1740
    17321741    ShowProgress (&m, SamplesInWAVE, SamplesInWAVE, e.outputBits );
    17331742
Note: See TracChangeset for help on using the changeset viewer.