Path: blob/master/libs/mpg123/src/libmpg123/synth_mono.h
4394 views
/*1monosynth.h: generic mono related synth functions23copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.14see COPYING and AUTHORS files in distribution or http://mpg123.org5initially written by Michael Hipp, generalized by Thomas Orgis67This header is used multiple times to create different variants of these functions.8See decode.c and synth.h .9Hint: BLOCK, MONO_NAME, MONO2STEREO_NAME, SYNTH_NAME and SAMPLE_T do vary.1011Thomas looked closely at the decode_1to1, decode_2to1 and decode_4to1 contents, seeing that they are too similar to be separate files.12This is what resulted...1314Reason to separate this from synth.h:15There are decoders that have a special INT123_synth_1to1 but still can use these generic derivations for the mono stuff.16It generally makes a good deal of sense to set SYNTH_NAME to opt_synth_1to1(fr) (or opt_synth_2to1(fr), etc.).17*/1819/* Mono synth, wrapping over SYNTH_NAME */20int MONO_NAME(real *bandPtr, mpg123_handle *fr)21{22SAMPLE_T samples_tmp[BLOCK];23SAMPLE_T *tmp1 = samples_tmp;24int i,ret;2526/* save buffer stuff, trick samples_tmp into there, decode, restore */27unsigned char *samples = fr->buffer.data;28int pnt = fr->buffer.fill;29fr->buffer.data = (unsigned char*) samples_tmp;30fr->buffer.fill = 0;31ret = SYNTH_NAME(bandPtr, 0, fr, 0); /* decode into samples_tmp */32fr->buffer.data = samples; /* restore original value */3334/* now append samples from samples_tmp */35samples += pnt; /* just the next mem in frame buffer */36for(i=0;i<(BLOCK/2);i++)37{38*( (SAMPLE_T *)samples) = *tmp1;39samples += sizeof(SAMPLE_T);40tmp1 += 2;41}42fr->buffer.fill = pnt + (BLOCK/2)*sizeof(SAMPLE_T);4344return ret;45}4647/* Mono to stereo synth, wrapping over SYNTH_NAME */48int MONO2STEREO_NAME(real *bandPtr, mpg123_handle *fr)49{50int i,ret;51unsigned char *samples = fr->buffer.data;5253ret = SYNTH_NAME(bandPtr,0,fr,1);54samples += fr->buffer.fill - BLOCK*sizeof(SAMPLE_T);5556for(i=0;i<(BLOCK/2);i++)57{58((SAMPLE_T *)samples)[1] = ((SAMPLE_T *)samples)[0];59samples+=2*sizeof(SAMPLE_T);60}6162return ret;63}646566