/src/mpg123/src/libmpg123/synth_mono.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | monosynth.h: generic mono related synth functions |
3 | | |
4 | | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 |
5 | | see COPYING and AUTHORS files in distribution or http://mpg123.org |
6 | | initially written by Michael Hipp, generalized by Thomas Orgis |
7 | | |
8 | | This header is used multiple times to create different variants of these functions. |
9 | | See decode.c and synth.h . |
10 | | Hint: BLOCK, MONO_NAME, MONO2STEREO_NAME, SYNTH_NAME and SAMPLE_T do vary. |
11 | | |
12 | | Thomas looked closely at the decode_1to1, decode_2to1 and decode_4to1 contents, seeing that they are too similar to be separate files. |
13 | | This is what resulted... |
14 | | |
15 | | Reason to separate this from synth.h: |
16 | | There are decoders that have a special INT123_synth_1to1 but still can use these generic derivations for the mono stuff. |
17 | | It generally makes a good deal of sense to set SYNTH_NAME to opt_synth_1to1(fr) (or opt_synth_2to1(fr), etc.). |
18 | | */ |
19 | | |
20 | | /* Mono synth, wrapping over SYNTH_NAME */ |
21 | | int MONO_NAME(real *bandPtr, mpg123_handle *fr) |
22 | 453k | { |
23 | 453k | SAMPLE_T samples_tmp[BLOCK]; |
24 | 453k | SAMPLE_T *tmp1 = samples_tmp; |
25 | 453k | int i,ret; |
26 | | |
27 | | /* save buffer stuff, trick samples_tmp into there, decode, restore */ |
28 | 453k | unsigned char *samples = fr->buffer.data; |
29 | 453k | int pnt = fr->buffer.fill; |
30 | 453k | fr->buffer.data = (unsigned char*) samples_tmp; |
31 | 453k | fr->buffer.fill = 0; |
32 | 453k | ret = SYNTH_NAME(bandPtr, 0, fr, 0); /* decode into samples_tmp */ |
33 | 453k | fr->buffer.data = samples; /* restore original value */ |
34 | | |
35 | | /* now append samples from samples_tmp */ |
36 | 453k | samples += pnt; /* just the next mem in frame buffer */ |
37 | 14.9M | for(i=0;i<(BLOCK/2);i++) |
38 | 14.5M | { |
39 | 14.5M | *( (SAMPLE_T *)samples) = *tmp1; |
40 | 14.5M | samples += sizeof(SAMPLE_T); |
41 | 14.5M | tmp1 += 2; |
42 | 14.5M | } |
43 | 453k | fr->buffer.fill = pnt + (BLOCK/2)*sizeof(SAMPLE_T); |
44 | | |
45 | 453k | return ret; |
46 | 453k | } Unexecuted instantiation: INT123_synth_1to1_8bit_mono Unexecuted instantiation: INT123_synth_2to1_8bit_mono Unexecuted instantiation: INT123_synth_4to1_8bit_mono Line | Count | Source | 22 | 453k | { | 23 | 453k | SAMPLE_T samples_tmp[BLOCK]; | 24 | 453k | SAMPLE_T *tmp1 = samples_tmp; | 25 | 453k | int i,ret; | 26 | | | 27 | | /* save buffer stuff, trick samples_tmp into there, decode, restore */ | 28 | 453k | unsigned char *samples = fr->buffer.data; | 29 | 453k | int pnt = fr->buffer.fill; | 30 | 453k | fr->buffer.data = (unsigned char*) samples_tmp; | 31 | 453k | fr->buffer.fill = 0; | 32 | 453k | ret = SYNTH_NAME(bandPtr, 0, fr, 0); /* decode into samples_tmp */ | 33 | 453k | fr->buffer.data = samples; /* restore original value */ | 34 | | | 35 | | /* now append samples from samples_tmp */ | 36 | 453k | samples += pnt; /* just the next mem in frame buffer */ | 37 | 14.9M | for(i=0;i<(BLOCK/2);i++) | 38 | 14.5M | { | 39 | 14.5M | *( (SAMPLE_T *)samples) = *tmp1; | 40 | 14.5M | samples += sizeof(SAMPLE_T); | 41 | 14.5M | tmp1 += 2; | 42 | 14.5M | } | 43 | 453k | fr->buffer.fill = pnt + (BLOCK/2)*sizeof(SAMPLE_T); | 44 | | | 45 | 453k | return ret; | 46 | 453k | } |
Unexecuted instantiation: INT123_synth_2to1_mono Unexecuted instantiation: INT123_synth_4to1_mono Unexecuted instantiation: INT123_synth_1to1_s32_mono Unexecuted instantiation: INT123_synth_2to1_s32_mono Unexecuted instantiation: INT123_synth_4to1_s32_mono Unexecuted instantiation: INT123_synth_1to1_real_mono Unexecuted instantiation: INT123_synth_2to1_real_mono Unexecuted instantiation: INT123_synth_4to1_real_mono |
47 | | |
48 | | /* Mono to stereo synth, wrapping over SYNTH_NAME */ |
49 | | int MONO2STEREO_NAME(real *bandPtr, mpg123_handle *fr) |
50 | 0 | { |
51 | 0 | int i,ret; |
52 | 0 | unsigned char *samples = fr->buffer.data; |
53 | |
|
54 | 0 | ret = SYNTH_NAME(bandPtr,0,fr,1); |
55 | 0 | samples += fr->buffer.fill - BLOCK*sizeof(SAMPLE_T); |
56 | |
|
57 | 0 | for(i=0;i<(BLOCK/2);i++) |
58 | 0 | { |
59 | 0 | ((SAMPLE_T *)samples)[1] = ((SAMPLE_T *)samples)[0]; |
60 | 0 | samples+=2*sizeof(SAMPLE_T); |
61 | 0 | } |
62 | |
|
63 | 0 | return ret; |
64 | 0 | } Unexecuted instantiation: INT123_synth_1to1_8bit_m2s Unexecuted instantiation: INT123_synth_2to1_8bit_m2s Unexecuted instantiation: INT123_synth_4to1_8bit_m2s Unexecuted instantiation: INT123_synth_1to1_m2s Unexecuted instantiation: INT123_synth_2to1_m2s Unexecuted instantiation: INT123_synth_4to1_m2s Unexecuted instantiation: INT123_synth_1to1_s32_m2s Unexecuted instantiation: INT123_synth_2to1_s32_m2s Unexecuted instantiation: INT123_synth_4to1_s32_m2s Unexecuted instantiation: INT123_synth_1to1_real_m2s Unexecuted instantiation: INT123_synth_2to1_real_m2s Unexecuted instantiation: INT123_synth_4to1_real_m2s |