Hello, LAME developers.

This is the first time for me to post the message to this community. So
please let me allow introduce myself. My name is Osamu Shigematsu, and now
porting LAME to Macintosh. My work had done and now optimizing the code for
Macintosh.

I'm newbie, though, I uploaded both binary and compleate source code with
codewarrior pro 5 (macintosh c/c++ popular IDE from metroworks) to hope
being someone's help. I know patent problem, so I wrote an e-mail to IIS and
Thomson multimedia that I upladed the stuffs.

BTW, I wonder if why the buffer for mp3 encorder is buffer[2][1152].
So we have to copy from insamp to buffer and the order is deffernt from
both, I can not use memcpy to copy the memory block. (of course, this is
terrible waste of the time, just pass buffer pointer to the read_samples
subroutine)

Does anyone know the reason? TIA.

/* this code from get_audio.c but modified to my style */
int
get_audio( short buffer[2][1152], int stereo, layer* info )
{
    int j;
    short insamp[1152][2];
    
    int samples_read;
    int framesize, samples_to_read;
    static unsigned long num_samples_read;
    unsigned long remaining;

    if ( frameNum == 0 ) {
        num_samples_read = 0;
        num_samples = GetSndSamples();
    }

    remaining = num_samples - num_samples_read;
    framesize = ( info->version == 0 ) ? 576 : 1152;
    samples_to_read = ( remaining > framesize ) ? framesize : remaining;
    
    if ( samples_to_read < 0 )
        samples_to_read = 0;

    if ( input_format == sf_mp3 ) {
        DebugStr( "\psf_mp3 is not supported!" ); /* call debugger to draw
string (macintosh only!!) */
    }
    else
    {
        /* MPEG 1 */
        if ( stereo == 2 )
        {
            samples_read = read_samples( (short*)insamp, 2*framesize,
2*samples_to_read );
            samples_read /= 2;
            for( j = 0; j < framesize; j++ )
            {
                buffer[0][j] = insamp[j][0];
                buffer[1][j] = insamp[j][1];
            }
        }
        else
        {
            if ( autoconvert != FALSE ) /* autoconvert == TRUE */
            {
                /* downconvert from a stereo file into a mono buffer */
                samples_read = read_samples( (short*)insamp, 2*framesize,
2*samples_to_read );
                samples_read /=2;
                for( j = 0; j < framesize; j++ )
                {
                    /* dont overflow the short int */
                    buffer[0][j] = ((long)insamp[j][0] +
(long)insamp[j][1])/2;
                    buffer[1][j] = 0;
                }
            }
            else
            {
                samples_read = read_samples( (short*)insamp, framesize,
samples_to_read );
                for( j = 0; j < framesize; j++ )
                {
                    buffer[0][j] = insamp[j][0];
                    buffer[1][j] = 0;
                }
            }
        }
    }

    /* dont count things in this case to avoid overflows */
    if ( num_samples != ULONG_MAX /* MAX_U_32_NUM */ ) /* limits.h */
        num_samples_read += samples_read;
    
    return( samples_read );
}

-- 
Osamu Shigematsu
http://www.ravi.ne.jp/


--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

Reply via email to