When using the interleaved functions (such as lame_encode_buffer_interleaved) for encoding a mono stream, bad output is coming out.
Further investigation lead to a problem in lame_encode_buffer_template. When cfg->channels_in == 1, it calls lame_copy_inbuffer(gfc, buffer_l, buffer_r, nsamples, pcm_type, aa, norm); The value of aa is set to 2 when called from the interleaved functions. The aa parameter is passed on to lame_copy_inbuffer and define the jump value when copying the buffer. Jump value of 2 for mono stream result in skipping each second sample and accessing data beyond the buffer boundaries.