Commit 0220726f authored by Jean-Paul Saman's avatar Jean-Paul Saman

- Updated configure to build fixed32tos16 and fixed32tofloat32.

  Desperately need a fixed32 mixer for testing the conversions.
- Uncommented unused functions in libmad.
parent ac4a6e1f
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -444,7 +444,7 @@ PLUGINS="${PLUGINS} demux/mpeg/es demux/mpeg/audio demux/mpeg/mpeg_system demux/ ...@@ -444,7 +444,7 @@ PLUGINS="${PLUGINS} demux/mpeg/es demux/mpeg/audio demux/mpeg/mpeg_system demux/
PLUGINS="${PLUGINS} codec/mpeg_video/idct/idct codec/mpeg_video/idct/idctclassic codec/mpeg_video/motion/motion codec/mpeg_video/mpeg_video codec/spudec/spudec codec/spdif" PLUGINS="${PLUGINS} codec/mpeg_video/idct/idct codec/mpeg_video/idct/idctclassic codec/mpeg_video/motion/motion codec/mpeg_video/mpeg_video codec/spudec/spudec codec/spdif"
#PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/mpeg_audio/mpeg_audio codec/a52old/a52old codec/lpcm/lpcm" #PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/mpeg_audio/mpeg_audio codec/a52old/a52old codec/lpcm/lpcm"
PLUGINS="${PLUGINS} video_filter/deinterlace/deinterlace video_filter/invert video_filter/wall video_filter/transform video_filter/distort video_filter/clone video_filter/crop" PLUGINS="${PLUGINS} video_filter/deinterlace/deinterlace video_filter/invert video_filter/wall video_filter/transform video_filter/distort video_filter/clone video_filter/crop"
PLUGINS="${PLUGINS} audio_filter/converter/float32tos16 audio_filter/converter/a52tospdif" PLUGINS="${PLUGINS} audio_filter/converter/float32tos16 audio_filter/converter/a52tospdif audio_filter/converter/fixed32tos16 audio_filter/converter/fixed32tofloat32"
PLUGINS="${PLUGINS} audio_filter/resampler/trivial" PLUGINS="${PLUGINS} audio_filter/resampler/trivial"
PLUGINS="${PLUGINS} audio_mixer/trivial audio_mixer/spdif" PLUGINS="${PLUGINS} audio_mixer/trivial audio_mixer/spdif"
PLUGINS="${PLUGINS} audio_output/file" PLUGINS="${PLUGINS} audio_output/file"
......
...@@ -44,7 +44,7 @@ static void PrintFrameInfo(struct mad_header *Header); ...@@ -44,7 +44,7 @@ static void PrintFrameInfo(struct mad_header *Header);
enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream) enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
{ {
mad_adec_thread_t *p_mad_adec = (mad_adec_thread_t *) data; mad_adec_thread_t *p_mad_adec = (mad_adec_thread_t *) data;
size_t ReadSize, Remaining; size_t ReadSize, Remaining;
unsigned char *ReadStart; unsigned char *ReadStart;
if ( p_mad_adec->p_fifo->b_die == 1 ) { if ( p_mad_adec->p_fifo->b_die == 1 ) {
...@@ -164,110 +164,110 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream) ...@@ -164,110 +164,110 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
* } * }
*/ */
/***************************************************************************** ///*****************************************************************************
* support routines borrowed from mpg321 (file: mad.c), which is distributed // * support routines borrowed from mpg321 (file: mad.c), which is distributed
* under GPL license // * under GPL license
* // *
* mpg321 was written by Joe Drew <drew@debian.org>, and based upon 'plaympeg' // * mpg321 was written by Joe Drew <drew@debian.org>, and based upon 'plaympeg'
* from the smpeg sources, which was written by various people from Loki Software // * from the smpeg sources, which was written by various people from Loki Software
* (http://www.lokigames.com). // * (http://www.lokigames.com).
* // *
* It also incorporates some source from mad, written by Robert Leslie // * It also incorporates some source from mad, written by Robert Leslie
*****************************************************************************/ // *****************************************************************************/
//
/* The following two routines and data structure are from the ever-brilliant ///* The following two routines and data structure are from the ever-brilliant
Rob Leslie. // Rob Leslie.
*/ //*/
//
struct audio_dither { //struct audio_dither {
mad_fixed_t error[3]; // mad_fixed_t error[3];
mad_fixed_t random; // mad_fixed_t random;
}; //};
//
/* ///*
* NAME: prng() //* NAME: prng()
* DESCRIPTION: 32-bit pseudo-random number generator //* DESCRIPTION: 32-bit pseudo-random number generator
*/ //*/
static inline unsigned long prng(unsigned long state) //static inline unsigned long prng(unsigned long state)
{ //{
return (state * 0x0019660dL + 0x3c6ef35fL) & 0xffffffffL; // return (state * 0x0019660dL + 0x3c6ef35fL) & 0xffffffffL;
} //}
//
/* ///*
* NAME: mpg321_s24_to_s16_pcm() //* NAME: mpg321_s24_to_s16_pcm()
* DESCRIPTION: generic linear sample quantize and dither routine //* DESCRIPTION: generic linear sample quantize and dither routine
*/ //*/
static inline signed int mpg321_s24_to_s16_pcm(unsigned int bits, mad_fixed_t sample, //static inline signed int mpg321_s24_to_s16_pcm(unsigned int bits, mad_fixed_t sample,
struct audio_dither *dither) // struct audio_dither *dither)
{ //{
unsigned int scalebits; // unsigned int scalebits;
mad_fixed_t output, mask, random; // mad_fixed_t output, mask, random;
//
enum { // enum {
MIN = -MAD_F_ONE, // MIN = -MAD_F_ONE,
MAX = MAD_F_ONE - 1 // MAX = MAD_F_ONE - 1
}; // };
//
/* noise shape */ // /* noise shape */
sample += dither->error[0] - dither->error[1] + dither->error[2]; // sample += dither->error[0] - dither->error[1] + dither->error[2];
//
dither->error[2] = dither->error[1]; // dither->error[2] = dither->error[1];
dither->error[1] = dither->error[0] / 2; // dither->error[1] = dither->error[0] / 2;
//
/* bias */ // /* bias */
output = sample + (1L << (MAD_F_FRACBITS + 1 - bits - 1)); // output = sample + (1L << (MAD_F_FRACBITS + 1 - bits - 1));
//
scalebits = MAD_F_FRACBITS + 1 - bits; // scalebits = MAD_F_FRACBITS + 1 - bits;
mask = (1L << scalebits) - 1; // mask = (1L << scalebits) - 1;
//
/* dither */ // /* dither */
random = prng(dither->random); // random = prng(dither->random);
output += (random & mask) - (dither->random & mask); // output += (random & mask) - (dither->random & mask);
//
dither->random = random; // dither->random = random;
//
/* clip */ // /* clip */
if (output > MAX) { // if (output > MAX) {
output = MAX; // output = MAX;
//
if (sample > MAX) // if (sample > MAX)
sample = MAX; // sample = MAX;
} // }
else if (output < MIN) { // else if (output < MIN) {
output = MIN; // output = MIN;
//
if (sample < MIN) // if (sample < MIN)
sample = MIN; // sample = MIN;
} // }
//
/* quantize */ // /* quantize */
output &= ~mask; // output &= ~mask;
//
/* error feedback */ // /* error feedback */
dither->error[0] = sample - output; // dither->error[0] = sample - output;
//
/* scale */ // /* scale */
return output >> scalebits; // return output >> scalebits;
} //}
//
/***************************************************************************** ///*****************************************************************************
* s24_to_s16_pcm: Scale a 24 bit pcm sample to a 16 bit pcm sample. // * s24_to_s16_pcm: Scale a 24 bit pcm sample to a 16 bit pcm sample.
*****************************************************************************/ // *****************************************************************************/
static inline mad_fixed_t s24_to_s16_pcm(mad_fixed_t sample) //static inline mad_fixed_t s24_to_s16_pcm(mad_fixed_t sample)
{ //{
/* round */ // /* round */
sample += (1L << (MAD_F_FRACBITS - 16)); // sample += (1L << (MAD_F_FRACBITS - 16));
//
/* clip */ // /* clip */
if (sample >= MAD_F_ONE) // if (sample >= MAD_F_ONE)
sample = MAD_F_ONE - 1; // sample = MAD_F_ONE - 1;
else if (sample < -MAD_F_ONE) // else if (sample < -MAD_F_ONE)
sample = -MAD_F_ONE; // sample = -MAD_F_ONE;
//
/* quantize */ // /* quantize */
return sample >> (MAD_F_FRACBITS + 1 - 16); // return sample >> (MAD_F_FRACBITS + 1 - 16);
} //}
//
/***************************************************************************** /*****************************************************************************
* libmad_ouput: this function is called just after the frame is decoded * libmad_ouput: this function is called just after the frame is decoded
*****************************************************************************/ *****************************************************************************/
...@@ -456,7 +456,7 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade ...@@ -456,7 +456,7 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade
} }
p_mad_adec->last_date += (mtime_t)(p_libmad_pcm->length*2) p_mad_adec->last_date += (mtime_t)(p_libmad_pcm->length*2)
/ p_mad_adec->output_format.i_rate; / p_mad_adec->output_format.i_rate;
p_buffer->end_date = p_mad_adec->i_next_pts; // last_date; p_buffer->end_date = p_mad_adec->last_date;
/* Interleave and keep buffers in mad_fixed_t format */ /* Interleave and keep buffers in mad_fixed_t format */
while (nsamples--) while (nsamples--)
...@@ -464,11 +464,12 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade ...@@ -464,11 +464,12 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade
/* left audio channel */ /* left audio channel */
sample = *left_ch++; sample = *left_ch++;
#ifndef WORDS_BIGENDIAN #ifndef WORDS_BIGENDIAN
*(p_buffer->p_buffer)++ = (byte_t) (sample >> 0); *(p_buffer->p_buffer)++ = (byte_t) (sample);
*(p_buffer->p_buffer)++ = (byte_t) (sample >> 8); // *(p_buffer->p_buffer)++ = (byte_t) (sample >> 0);
// *(p_buffer->p_buffer)++ = (byte_t) (sample >> 8);
#else #else
*(p_buffer->p_buffer)++ = (byte_t) (sample >> 8); // *(p_buffer->p_buffer)++ = (byte_t) (sample >> 8);
*(p_buffer->p_buffer)++ = (byte_t) (sample >> 0); // *(p_buffer->p_buffer)++ = (byte_t) (sample >> 0);
#endif #endif
/* right audio channel */ /* right audio channel */
if (p_libmad_pcm->channels == 2) if (p_libmad_pcm->channels == 2)
...@@ -476,11 +477,12 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade ...@@ -476,11 +477,12 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade
sample = *right_ch++; sample = *right_ch++;
} /* else reuse left audio channel */ } /* else reuse left audio channel */
#ifndef WORDS_BIGENDIAN #ifndef WORDS_BIGENDIAN
*(p_buffer->p_buffer)++ = (byte_t) (sample >> 0); *(p_buffer->p_buffer)++ = (byte_t) (sample);
*(p_buffer->p_buffer)++ = (byte_t) (sample >> 8); // *(p_buffer->p_buffer)++ = (byte_t) (sample >> 0);
// *(p_buffer->p_buffer)++ = (byte_t) (sample >> 8);
#else #else
*(p_buffer->p_buffer)++ = (byte_t) (sample >> 8); // *(p_buffer->p_buffer)++ = (byte_t) (sample >> 8);
*(p_buffer->p_buffer)++ = (byte_t) (sample >> 0); // *(p_buffer->p_buffer)++ = (byte_t) (sample >> 0);
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment