summaryrefslogtreecommitdiff
path: root/src/libxineadec
diff options
context:
space:
mode:
Diffstat (limited to 'src/libxineadec')
-rw-r--r--src/libxineadec/28k8.c555
-rw-r--r--src/libxineadec/Makefile.am27
-rw-r--r--src/libxineadec/adpcm.c1687
-rw-r--r--src/libxineadec/interplayaudio.c357
-rw-r--r--src/libxineadec/logpcm.c312
-rw-r--r--src/libxineadec/roqaudio.c242
6 files changed, 1 insertions, 3179 deletions
diff --git a/src/libxineadec/28k8.c b/src/libxineadec/28k8.c
deleted file mode 100644
index f8c51d59c..000000000
--- a/src/libxineadec/28k8.c
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Copyright (C) 2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * RealAudio 28k8 Decoder by Ewald Snel <ewald@rambo.its.tudelft.nl>
- *
- * Based on public domain source code from:
- * http://www.honeypot.net/audio/
- *
- * $Id: 28k8.c,v 1.7 2004/01/12 17:35:17 miguelfreitas Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <math.h>
-
-#include "xine_internal.h"
-#include "audio_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define SUBBLOCK 38
-#define BLOCKSIZE 2736
-
-typedef struct {
- audio_decoder_class_t decoder_class;
-} ra28k8_class_t;
-
-typedef struct ra28k8_decoder_s {
- audio_decoder_t audio_decoder;
-
- xine_stream_t *stream;
-
- int output_open;
- int decoder_ok;
-
- unsigned char buf[BLOCKSIZE];
- int size;
-
- float sb[41];
- float lhist[10];
- float output[40];
- float pr1[36];
- float st1a[111];
- float st1b[37];
- float st1[37];
- float pr2[10];
- float st2a[38];
- float st2b[11];
- float st2[11];
-
-} ra28k8_decoder_t;
-
-
-static const float ra28k8_amptable[8] = {
- 0.515625, 0.90234375, 1.57910156, 2.76342773,
- -0.515625,-0.90234375,-1.57910156,-2.76342773
-};
-
-static const float ra28k8_codetable[128][5] = {
- { 0.326171875, -1.4404296875, -0.6123046875, -0.8740234375, -1.24658203125 },
- { -2.45703125, -2.23486328125,-0.51025390625, 1.419921875, 1.6201171875 },
- { -1.37646484375,-1.30712890625,-0.462890625, -1.37939453125,-2.1728515625 },
- { -3.26123046875,-0.166015625, 0.7236328125, -0.623046875, 0.6162109375 },
- { -0.2744140625, -3.29931640625, 0.62548828125, 0.08740234375,-0.6220703125 },
- { -1.2265625, -3.4814453125, -2.40478515625, 3.37548828125, 1.17724609375 },
- { -1.2099609375, -0.076171875, 2.28662109375,-1.89111328125, 0 },
- { -4.0078125, 1.044921875, -0.2333984375, -1.35986328125, 0.26025390625 },
- { 0.92236328125, 1.34716796875, 0.67431640625,-3.39599609375,-2.88720703125 },
- { 2.4814453125, -1.201171875, -2.8212890625, 0.87744140625, 0.27734375 },
- { -1.078125, -1.61572265625,-2.20849609375,-3.044921875, -3.66455078125 },
- { -1.32763671875, 2.1279296875, -1.458984375, -0.56103515625, 1.30078125 },
- { 0.61474609375, 0.48583984375, 1.32373046875,-1.203125, -5.0732421875 },
- { 0.8408203125, -3.69580078125,-1.3388671875, 1.06005859375,-1.13720703125 },
- { 0.50390625, 0.36474609375,-0.4189453125, -3.8798828125, -6.27099609375 },
- { 1.5166015625, 2.37109375, -2.04736328125,-1.24072265625, 0.50537109375 },
- { 0.9091796875, -0.46875, -3.236328125, 0.2001953125, 2.8720703125 },
- { -1.21728515625,-1.283203125, -1.953125, -0.029296875, 3.5166015625 },
- { -1.3046875, 0.7060546875, 0.75, -1.87060546875, 0.60205078125 },
- { -2.5888671875, 3.375, 0.77587890625,-2.04443359375, 1.78955078125 },
- { -1.6875, -3.9892578125, -3.76416015625, 0.67578125, 2.2939453125 },
- { -2.29443359375,-3.03173828125,-5.45703125, 3.95703125, 8.2177734375 },
- { 0.4541015625, 3.419921875, 0.61962890625,-4.38330078125, 1.25341796875 },
- { 2.27001953125, 5.763671875, 1.68017578125,-2.76220703125, 0.58544921875 },
- { 1.2412109375, -0.08935546875,-4.32568359375,-3.89453125, 1.5771484375 },
- { -1.40234375, -0.98193359375,-4.74267578125,-4.09423828125, 6.33935546875 },
- { 1.5068359375, 1.044921875, -1.796875, -4.70849609375,-1.4140625 },
- { -3.71533203125, 3.18115234375,-1.11474609375,-1.2314453125, 3.091796875 },
- { -1.62744140625,-2.744140625, -4.4580078125, -5.43505859375, 2.70654296875 },
- { -0.19873046875,-3.28173828125,-8.5283203125, -1.41064453125, 5.6484375 },
- { 1.802734375, 3.318359375, -0.1279296875, -5.2958984375, -0.90625 },
- { 3.55224609375, 6.544921875, -1.45947265625,-5.17333984375, 2.41015625 },
- { 0.119140625, -1.08349609375, 1.296875, 1.84375, -2.642578125 },
- { -1.97412109375,-2.8974609375, 1.04052734375, 0.42138671875,-1.3994140625 },
- { -1.6123046875, 0.85107421875,-0.9794921875, -0.0625, -1.001953125 },
- { -3.10595703125, 1.6318359375, -0.77294921875,-0.01025390625, 0.5576171875 },
- { -1.87353515625,-0.89404296875, 3.12353515625, 1.24267578125,-1.390625 },
- { -4.556640625, -3.1875, 2.59228515625, 0.9697265625, -1.09619140625 },
- { -2.1923828125, 0.365234375, 0.94482421875,-1.47802734375,-0.24072265625 },
- { -4.51904296875, 2.6201171875, 1.55908203125,-2.19384765625, 0.87109375 },
- { 2.3359375, -0.1806640625, 0.9111328125, 0.51611328125,-0.92236328125 },
- { 3.5849609375, -1.3134765625, -1.25830078125, 0.330078125, -0.29833984375 },
- { -0.2451171875, 1.09130859375,-0.9033203125, -0.86767578125,-1.00048828125 },
- { 0.49365234375, 1.89453125, -1.20361328125, 1.07861328125,-0.07421875 },
- { 1.265625, 1.38134765625, 2.728515625, 1.38623046875,-3.5673828125 },
- { -1.48876953125,-2.4013671875, 2.90771484375, 4.49267578125,-2.17138671875 },
- { 0.34033203125, 1.908203125, 2.8310546875, -2.17333984375,-2.267578125 },
- { -1.03564453125, 2.658203125, -1.2548828125, 0.15673828125,-0.5869140625 },
- { 1.3896484375, -1.0185546875, 1.724609375, 0.2763671875, -0.345703125 },
- { -2.08935546875, 0.4638671875, 2.431640625, 1.83056640625, 0.220703125 },
- { -1.212890625, 1.7099609375, 0.83935546875,-0.0830078125, 0.1162109375 },
- { -1.67724609375, 0.12841796875, 1.0322265625, -0.97900390625, 1.15283203125 },
- { -3.5830078125, -0.58984375, 4.56396484375,-0.59375, -1.95947265625 },
- { -6.5908203125, -0.21435546875, 3.919921875, -2.06640625, 0.17626953125 },
- { -1.82080078125, 2.65283203125, 0.978515625, -2.30810546875,-0.61474609375 },
- { -1.9462890625, 3.78076171875, 4.11572265625,-1.80224609375,-0.48193359375 },
- { 2.5380859375, -0.20654296875, 0.5615234375, -0.62548828125, 0.3984375 },
- { 3.61767578125, 2.00634765625,-1.92822265625, 1.3134765625, 0.0146484384313 },
- { 0.6083984375, 1.49169921875,-0.01708984375,-0.6689453125, -0.1201171875 },
- { -0.72705078125, 2.75146484375,-0.3310546875, -1.28271484375, 1.5478515625 },
- { 2.3583984375, -2.23876953125, 0.98046875, -0.5185546875, 0.39013671875 },
- { -0.06298828125, 0.35009765625, 2.2431640625, 7.29345703125, 5.2275390625 },
- { 0.20361328125, 1.34716796875, 0.9033203125, -2.46923828125,-0.56298828125 },
- { -1.89794921875, 3.59423828125,-2.81640625, 2.09228515625, 0.3251953125 },
- { 0.70458984375,-0.4580078125, 0.009765625, -1.03466796875,-0.82861328125 },
- { -1.8125, -1.6611328125, -1.080078125, 0.0537109375, 1.04296875 },
- { -1.44140625, 0.005859375, -0.765625, -1.708984375, -0.90576171875 },
- { -0.64208984375,-0.84521484375, 0.56640625, -0.2724609375, 0.83447265625 },
- { 0.04296875, -2.23095703125, 0.0947265625, -0.2216796875, -1.44384765625 },
- { -1.38623046875,-0.8134765625, -0.13330078125, 1.017578125, -0.07568359375 },
- { -0.09228515625,-1.16015625, 0.81201171875,-0.5078125, -1.19580078125 },
- { -1.3876953125, -0.66845703125, 0.310546875, -0.12109375, -1.30712890625 },
- { 0.74072265625, 0.03857421875,-1.47119140625,-1.79150390625,-0.47509765625 },
- { 0.93408203125,-1.21728515625,-2.59375, -0.36572265625, 0.62060546875 },
- { -1.41748046875,-1.623046875, -1.833984375, -1.8017578125, -0.89306640625 },
- { -1.42236328125,-0.75537109375,-1.34765625, -0.6865234375, 0.548828125 },
- { 0.900390625, -0.8955078125, 0.22265625, 0.3447265625, -2.0859375 },
- { 0.22802734375,-2.078125, -0.93212890625, 0.74267578125, 0.5537109375 },
- { -0.06201171875,-0.4853515625, -0.31103515625,-0.72802734375,-3.1708984375 },
- { 0.42626953125,-0.99853515625,-1.869140625, -1.36328125, -0.2822265625 },
- { 1.12841796875,-0.88720703125, 1.28515625, -1.490234375, 0.9609375 },
- { 0.31298828125, 0.5830078125, 0.92431640625, 2.00537109375, 3.0966796875 },
- { -0.02197265625, 0.5849609375, 1.0546875, -0.70751953125, 1.07568359375 },
- { -0.978515625, 0.83642578125, 1.7177734375, 1.294921875, 2.07568359375 },
- { 1.43359375, -1.9375, 0.625, 0.06396484375,-0.720703125 },
- { 1.38037109375, 0.00390625, -0.94140625, 1.2978515625, 1.71533203125 },
- { 1.56201171875,-0.3984375, 1.31201171875,-0.85009765625,-0.68701171875 },
- { 1.439453125, 1.96728515625, 0.1923828125, -0.12353515625, 0.6337890625 },
- { 2.0927734375, 0.02490234375,-2.20068359375,-0.015625, -0.32177734375 },
- { 1.90576171875, 2.7568359375, -2.728515625, -1.265625, 2.78662109375 },
- { -0.2958984375, 0.6025390625, -0.78466796875,-2.53271484375, 0.32421875 },
- { -0.25634765625, 1.767578125, -1.0703125, -1.23388671875, 0.83349609375 },
- { 2.09814453125,-1.58740234375,-1.11474609375, 0.396484375, -1.10546875 },
- { 2.81494140625, 0.2578125, -1.60498046875, 0.66015625, 0.81640625 },
- { 1.33544921875, 0.60595703125,-0.53857421875,-1.59814453125,-1.66357421875 },
- { 1.96923828125, 0.8046875, -1.44775390625,-0.5732421875, 0.705078125 },
- { 0.0361328125, 0.4482421875, 0.97607421875, 0.44677734375,-0.5009765625 },
- { -1.21875, -0.78369140625, 0.9931640625, 1.4404296875, 0.11181640625 },
- { -1.05859375, 0.99462890625, 0.00732421921566,-0.6171875, -0.1015625 },
- { -1.734375, 0.7470703125, 0.28369140625, 0.72802734375, 0.4697265625 },
- { -1.27587890625,-1.1416015625, 1.76806640625,-0.7265625, -1.06689453125 },
- { -0.85302734375, 0.03955078125, 2.7041015625, 0.69921875, -1.10205078125 },
- { -0.49755859375, 0.42333984375, 0.1044921875, -1.115234375, -0.7373046875 },
- { -0.822265625, 1.375, -0.11181640625, 1.24560546875,-0.67822265625 },
- { 1.32177734375, 0.24609375, 0.23388671875, 1.35888671875,-0.49267578125 },
- { 1.22900390625,-0.72607421875,-0.779296875, 0.30322265625, 0.94189453125 },
- { -0.072265625, 1.0771484375, -2.09375, 0.630859375, -0.68408203125 },
- { -0.25732421875, 0.60693359375,-1.33349609375, 0.93212890625, 0.625 },
- { 1.04931640625,-0.73291015625, 1.80078125, 0.2978515625, -2.24169921875 },
- { 1.6142578125, -1.64501953125, 0.91552734375, 1.775390625, -0.59423828125 },
- { 1.2568359375, 1.22705078125, 0.70751953125,-1.5009765625, -2.43115234375 },
- { 0.3974609375, 0.8916015625, -1.21923828125, 2.0673828125, -1.99072265625 },
- { 0.8125, -0.107421875, 1.6689453125, 0.4892578125, 0.54443359375 },
- { 0.38134765625, 0.8095703125, 1.91357421875, 2.9931640625, 1.533203125 },
- { 0.560546875, 1.98486328125, 0.740234375, 0.39794921875, 0.09716796875 },
- { 0.58154296875, 1.21533203125, 1.25048828125, 1.18212890625, 1.19287109375 },
- { 0.3759765625, -2.88818359375, 2.69287109375,-0.1796875, -1.56201171875 },
- { 0.5810546875, 0.51123046875, 1.8271484375, 3.38232421875,-1.02001953125 },
- { 0.142578125, 1.51318359375, 2.103515625, -0.3701171875, -1.19873046875 },
- { 0.25537109375, 1.91455078125, 1.974609375, 0.6767578125, 0.04150390625 },
- { 2.13232421875, 0.4912109375, -0.611328125, -0.7158203125, -0.67529296875 },
- { 1.880859375, 0.77099609375,-0.03759765625, 1.0078125, 0.423828125 },
- { 2.49462890625, 1.42529296875,-0.0986328125, 0.17529296875,-0.24853515625 },
- { 1.7822265625, 1.5654296875, 1.12451171875, 0.82666015625, 0.6328125 },
- { 1.41845703125,-1.90771484375, 0.11181640625,-0.583984375, -1.138671875 },
- { 2.91845703125,-1.75048828125, 0.39306640625, 1.86767578125,-1.5322265625 },
- { 1.8291015625, -0.2958984375, 0.02587890625,-0.13134765625,-1.61181640625 },
- { 0.2958984375, 0.9853515625, -0.642578125, 1.984375, 0.1943359375 }
-};
-
-static const float ra28k8_table1[111] = {
- 0.576690972, 0.580838025, 0.585013986, 0.589219987, 0.59345597, 0.597723007,
- 0.602020264, 0.606384277, 0.610748291, 0.615142822, 0.619598389, 0.624084473,
- 0.628570557, 0.633117676, 0.637695313, 0.642272949, 0.646911621, 0.651580811,
- 0.656280518, 0.66104126, 0.665802002, 0.670593262, 0.675445557, 0.680328369,
- 0.685241699, 0.690185547, 0.695159912, 0.700164795, 0.705230713, 0.710327148,
- 0.715454102, 0.720611572, 0.725830078, 0.731048584, 0.736328125, 0.741638184,
- 0.747009277, 0.752380371, 0.7578125, 0.763305664, 0.768798828, 0.774353027,
- 0.779937744, 0.785583496, 0.791229248, 0.796936035, 0.802703857, 0.808502197,
- 0.814331055, 0.820220947, 0.826141357, 0.832092285, 0.838104248, 0.844146729,
- 0.850250244, 0.856384277, 0.862548828, 0.868774414, 0.875061035, 0.881378174,
- 0.88772583, 0.894134521, 0.900604248, 0.907104492, 0.913635254, 0.920227051,
- 0.926879883, 0.933563232, 0.940307617, 0.94708252, 0.953918457, 0.96081543,
- 0.96774292, 0.974731445, 0.981781006, 0.988861084, 0.994842529, 0.998565674,
- 0.999969482, 0.99911499, 0.996002197, 0.990600586, 0.982910156, 0.973022461,
- 0.960876465, 0.946533203, 0.930053711, 0.911437988, 0.89074707, 0.868041992,
- 0.843322754, 0.816680908, 0.788208008, 0.757904053, 0.725891113, 0.692199707,
- 0.656921387, 0.620178223, 0.582000732, 0.542480469, 0.501739502, 0.459838867,
- 0.416900635, 0.373016357, 0.328277588, 0.282775879, 0.236663818, 0.189971924,
- 0.142852783, 0.0954284668,0.0477600098
-};
-
-static const float ra28k8_table2[38] = {
- 0.505699992, 0.524200022, 0.54339999, 0.563300014, 0.583953857, 0.60534668,
- 0.627502441, 0.650482178, 0.674316406, 0.699005127, 0.724578857, 0.75112915,
- 0.778625488, 0.807128906, 0.836669922, 0.86730957, 0.899078369, 0.932006836,
- 0.961486816, 0.982757568, 0.995635986, 1, 0.995819092, 0.983154297,
- 0.96206665, 0.932769775, 0.895507813, 0.850585938, 0.798400879, 0.739379883,
- 0.674072266, 0.602996826, 0.526763916, 0.446014404, 0.361480713, 0.273834229,
- 0.183868408, 0.0923461914
-};
-
-static const float ra28k8_table1a[36] = {
- 0.654184103, 0.66194123, 0.669790328, 0.677732527, 0.685768902, 0.693900526,
- 0.702128589, 0.710454226, 0.718878567, 0.727402806, 0.736028135, 0.744755745,
- 0.753586829, 0.762522638, 0.771564424, 0.780713439, 0.789970934, 0.799338162,
- 0.808816493, 0.818407178, 0.828111589, 0.837931097, 0.847867012, 0.857920766,
- 0.868093729, 0.878387332, 0.888803005, 0.899342179, 0.910006344, 0.920796931,
- 0.931715488, 0.942763507, 0.953942537, 0.965254128, 0.976699829, 0.98828125
-};
-
-static const float ra28k8_table2a[10] = {
- 0.373657227, 0.41229248, 0.454956055, 0.50201416, 0.553955078,
- 0.61126709, 0.674499512, 0.74432373, 0.821289063, 0.90625
-};
-
-
-static inline float sum (float *p1, float *p2, int len) {
- float s = 0;
-
- while (len--) {
- s += (*(p1++)) * (*(p2++));
- }
-
- return s;
-}
-
-static inline void colmul (float *out, float *in, const float *table, int len) {
-
- while (len--) {
- *(out++) = (*(in++)) * (*(table++));
- }
-}
-
-static inline float clip (float a, float amin, float amax) {
- if (a < amin)
- return amin;
- else if (a > amax)
- return amax;
- else
- return a;
-}
-
-static inline int predict (float *in, float *tgt, int n) {
- int x, y;
- float f0, f1, f2, temp;
-
- if (in[n] == 0 || in[0] <= 0) {
- return 0;
- }
-
- f0 = in[0];
-
- for (x=n; (x > 0) && (f0 > 0); x--) {
- f1 = in[(n - x) + 1];
-
- for (y=1; y <= (n - x); y++) {
- f1 += in[y] * tgt[x + y];
- }
-
- f2 = -f1 / f0;
- f0 += f1 * f2;
-
- tgt[x] = f2;
-
- for (y=0; y < ((n - x) + 1)>>1; y++) {
- temp = tgt[n - y] + tgt[x + y + 1] * f2;
- tgt[x + y + 1] += tgt[n - y] * f2;
- tgt[n - y] = temp;
- }
- }
-
- return (f0 > 0);
-}
-
-static void decode_28k8_block (ra28k8_decoder_t *this, uint8_t *in, int16_t *out) {
- int i, j, x, z, phase, phasep, code;
- float buffer[5], work[111], temp1[37], temp2[11], d;
-
- for (x=0, z=0; x < 2304; x++) {
- phasep = 5*(phase = (x & 7));
-
- /* unpack */
- code = ((in[0] >> z) | (in[1] << (8 - z))) & (1023 >> (~x & 1));
-
- if (z == 7 && (x & 1)) {
- code |= (in[2] & 1) << 9;
- }
-
- z += (9 + (x & 1));
- in += (z >> 3);
- z &= 7;
-
- /* decode */
- memmove (this->sb, &this->sb[5], 36*sizeof(float));
-
- for (i=0; i < 5; i++) {
- this->sb[36 + i] = -sum (&this->sb[i], this->pr1, 36);
- }
-
- /* convert log and do rms */
- d = clip (32 - sum (this->pr2, this->lhist, 10), 0, 60);
- d = pow(10, d / 20) * ra28k8_amptable[code & 7];
-
- for (i=0; i < 5; i++) {
- buffer[i] = ra28k8_codetable[code >> 3][i] * d;
- }
-
- d = sum (buffer, buffer, 5) / 5;
- d = (d < 1) ? 0 : 10 * log10(d);
-
- /* shift and store */
- memmove (this->lhist, &this->lhist[1], 9*sizeof(float));
- this->lhist[9] = d - 32;
-
- for (i=1; i < 5; i++) {
- for(j=0; j < i; j++) {
- buffer[i] -= this->pr1[35 - j] * buffer[i - j - 1];
- }
- }
-
- /* output */
- for (i=0; i < 5; i++) {
- float f = clip (this->sb[36 + i] + buffer[i], -4095, 4095);
- this->output[phasep + i] = this->sb[36 + i] = f;
- *(out++) = (8 * f);
- }
-
- if (phase == 3) {
-
- /* rotate and multiply */
- memmove (this->st1a, &this->st1a[40], 71*sizeof(float));
- memcpy (&this->st1a[71], &this->output[20], 20*sizeof(float));
- memcpy (&this->st1a[91], this->output, 20*sizeof(float));
- memmove (this->st2a, &this->st2a[8], 30*sizeof(float));
- memcpy (&this->st2a[30], &this->lhist[2], 4*sizeof(float));
- memcpy (&this->st2a[34], &this->lhist[6], 4*sizeof(float));
-
- colmul (work, this->st1a, ra28k8_table1, 111);
-
- for (i=36; i >= 0; i--) {
- this->st1b[i] = this->st1b[i] * (0.5625) + sum (&work[36 - i], &work[36], 40);
- temp1[i] = this->st1b[i] + sum (&work[76 - i], &work[76], 35);
- }
-
- colmul (work, this->st2a, ra28k8_table2, 38);
-
- for (i=10; i >= 0; i--) {
- this->st2b[i] = this->st2b[i] * (0.5625) + sum (&work[10 - i], &work[10], 8);
- temp2[i] = this->st2b[i] + sum (&work[18 - i], &work[18], 20);
- }
-
- /* to prevent clipping */
- temp1[0] *= 1.00390625;
- temp2[0] *= 1.00390625;
-
- if (predict (temp1, this->st1, 36)) {
- colmul (this->pr1, &this->st1[1], ra28k8_table1a, 36);
- }
- if (predict (temp2, this->st2, 10)) {
- colmul (this->pr2, &this->st2[1], ra28k8_table2a, 10);
- }
- }
- }
-}
-
-static void ra28k8_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
- ra28k8_decoder_t *this = (ra28k8_decoder_t *) this_gen;
-
- if (buf->decoder_flags & BUF_FLAG_PREVIEW) {
-
- } else if (buf->decoder_flags & BUF_FLAG_HEADER) {
-
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC, "Real 28.8");
- this->decoder_ok = 1;
- if (!this->decoder_ok)
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
-
- } else if (this->decoder_ok ) {
- audio_buffer_t *audio_buffer;
- int i, j;
-
- if (!this->output_open) {
- this->output_open = this->stream->audio_out->open (this->stream->audio_out,
- this->stream, 16, 8000, AO_CAP_MODE_MONO);
- }
-
- /* copy and deinterleave sub-blocks */
- i = 0;
- j = this->size;
-
- while (i < buf->size || j == BLOCKSIZE) {
- if (j == BLOCKSIZE) {
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
-
- decode_28k8_block (this, this->buf, (int16_t *) audio_buffer->mem);
-
- audio_buffer->vpts = buf->pts;
- audio_buffer->num_frames = 11520;
-
- this->stream->audio_out->put_buffer (this->stream->audio_out,
- audio_buffer, this->stream);
-
- j = 0;
- } else if ((buf->size - i) >= SUBBLOCK) {
- memcpy (&this->buf[j], &buf->content[i], SUBBLOCK);
-
- if ((j += 12*SUBBLOCK) >= BLOCKSIZE) {
- if (j == (BLOCKSIZE + 11*SUBBLOCK))
- j = BLOCKSIZE;
- else
- j -= (BLOCKSIZE - SUBBLOCK);
- }
-
- i += SUBBLOCK;
- } else {
- memcpy (&this->buf[j], &buf->content[i], (buf->size - i));
-
- j += (buf->size - i);
- break;
- }
- }
-
- this->size = j;
- }
-}
-
-static void ra28k8_reset (audio_decoder_t *this_gen) {
- ra28k8_decoder_t *this = (ra28k8_decoder_t *) this_gen;
-
- this->size = 0;
-
- memset (this->sb, 0, sizeof(this->sb));
- memset (this->lhist, 0, sizeof(this->lhist));
- memset (this->output, 0, sizeof(this->lhist));
- memset (this->pr1, 0, sizeof(this->pr1));
- memset (this->st1a, 0, sizeof(this->st1a));
- memset (this->st1b, 0, sizeof(this->st1b));
- memset (this->st1, 0, sizeof(this->st1));
- memset (this->pr2, 0, sizeof(this->pr2));
- memset (this->st2a, 0, sizeof(this->st2a));
- memset (this->st2b, 0, sizeof(this->st2b));
- memset (this->st2, 0, sizeof(this->st2));
-}
-
-static void ra28k8_discontinuity (audio_decoder_t *this_gen) {
-}
-
-static void ra28k8_dispose (audio_decoder_t *this_gen) {
-
- ra28k8_decoder_t *this = (ra28k8_decoder_t *) this_gen;
-
- if (this->output_open)
- this->stream->audio_out->close (this->stream->audio_out, this->stream);
- this->output_open = 0;
-
- free (this_gen);
-}
-
-static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- ra28k8_decoder_t *this ;
-
- this = (ra28k8_decoder_t *) xine_xmalloc (sizeof (ra28k8_decoder_t));
-
- this->audio_decoder.decode_data = ra28k8_decode_data;
- this->audio_decoder.reset = ra28k8_reset;
- this->audio_decoder.discontinuity = ra28k8_discontinuity;
- this->audio_decoder.dispose = ra28k8_dispose;
-
- this->size = 0;
- this->stream = stream;
-
- return &this->audio_decoder;
-}
-
-static char *get_identifier (audio_decoder_class_t *this) {
- return "28k8";
-}
-
-static char *get_description (audio_decoder_class_t *this) {
- return "RealAudio 28k8 decoder plugin";
-}
-
-static void dispose_class (audio_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- ra28k8_class_t *this ;
-
- this = (ra28k8_class_t *) xine_xmalloc (sizeof (ra28k8_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-static uint32_t audio_types[] = {
- BUF_AUDIO_28_8, 0
-};
-
-static decoder_info_t dec_info_audio = {
- audio_types, /* supported types */
- 9 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_AUDIO_DECODER, 15, "28k8", XINE_VERSION_CODE, &dec_info_audio, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxineadec/Makefile.am b/src/libxineadec/Makefile.am
index f25dfe29d..4bad809de 100644
--- a/src/libxineadec/Makefile.am
+++ b/src/libxineadec/Makefile.am
@@ -9,25 +9,8 @@ AM_CFLAGS = -DNSF_PLAYER
SUBDIRS = gsm610 nosefart
lib_LTLIBRARIES = \
- xineplug_decode_adpcm.la \
- xineplug_decode_logpcm.la \
- xineplug_decode_roqaudio.la \
xineplug_decode_gsm610.la \
- xineplug_decode_interplayaudio.la \
- xineplug_decode_nsf.la \
- xineplug_decode_28k8.la
-
-xineplug_decode_roqaudio_la_SOURCES = roqaudio.c
-xineplug_decode_roqaudio_la_LIBADD = $(XINE_LIB)
-xineplug_decode_roqaudio_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_adpcm_la_SOURCES = adpcm.c
-xineplug_decode_adpcm_la_LIBADD = $(XINE_LIB)
-xineplug_decode_adpcm_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_logpcm_la_SOURCES = logpcm.c
-xineplug_decode_logpcm_la_LIBADD = $(XINE_LIB)
-xineplug_decode_logpcm_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
+ xineplug_decode_nsf.la
xineplug_decode_gsm610_la_SOURCES = gsm610.c
xineplug_decode_gsm610_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
@@ -35,10 +18,6 @@ xineplug_decode_gsm610_la_LIBADD = \
$(XINE_LIB) \
$(top_builddir)/src/libxineadec/gsm610/libgsm610.la
-xineplug_decode_interplayaudio_la_SOURCES = interplayaudio.c
-xineplug_decode_interplayaudio_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_decode_interplayaudio_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
xineplug_decode_nsf_la_SOURCES = nsf.c
#xineplug_decode_nsf_la_CFLAGS = -DNSF_PLAYER
xineplug_decode_nsf_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
@@ -46,8 +25,4 @@ xineplug_decode_nsf_la_LIBADD = \
$(XINE_LIB) \
$(top_builddir)/src/libxineadec/nosefart/libnosefart.la
-xineplug_decode_28k8_la_SOURCES = 28k8.c
-xineplug_decode_28k8_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_decode_28k8_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
# noinst_HEADERS =
diff --git a/src/libxineadec/adpcm.c b/src/libxineadec/adpcm.c
deleted file mode 100644
index 85d7804f1..000000000
--- a/src/libxineadec/adpcm.c
+++ /dev/null
@@ -1,1687 +0,0 @@
-/*
- * Copyright (C) 2000-2001 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * ADPCM Decoders by Mike Melanson (melanson@pcisys.net)
- *
- * This file is in charge of decoding all of the various ADPCM data
- * formats that various entities have created. Details about the data
- * formats can be found here:
- * http://www.pcisys.net/~melanson/codecs/
- * CD-ROM/XA ADPCM decoder by Stuart Caie (kyzer@4u.net)
- * - based on information in the USENET post by Jac Goudsmit (jac@codim.nl)
- * <01bbc34c$dbf64020$f9c8a8c0@cray.codim.nl>
- * - tested for correctness using Jon Atkins's CDXA software:
- * http://jonatkins.org/cdxa/
- * this is also useful for extracting streams from Playstation discs
- *
- *
- * $Id: adpcm.c,v 1.38 2004/01/12 17:35:18 miguelfreitas Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#define LOG_MODULE "adpcm_audio_decoder"
-#define LOG_VERBOSE
-/*
-#define LOG
-*/
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "audio_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-/* pertinent tables */
-static int ima_adpcm_step[89] = {
- 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
- 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
- 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
- 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
- 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
- 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
- 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
- 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
- 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
-};
-
-static int dialogic_ima_step[49] = {
- 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
- 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143,
- 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449,
- 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552
-};
-
-static int ima_adpcm_index[16] = {
- -1, -1, -1, -1, 2, 4, 6, 8,
- -1, -1, -1, -1, 2, 4, 6, 8
-};
-
-static int ms_adapt_table[] = {
- 230, 230, 230, 230, 307, 409, 512, 614,
- 768, 614, 512, 409, 307, 230, 230, 230
-};
-
-static int ms_adapt_coeff1[] = {
- 256, 512, 0, 192, 240, 460, 392
-};
-
-static int ms_adapt_coeff2[] = {
- 0, -256, 0, 64, 0, -208, -232
-};
-
-static int ea_adpcm_table[] = {
- 0, 240, 460, 392, 0, 0, -208, -220, 0, 1,
- 3, 4, 7, 8, 10, 11, 0, -1, -3, -4
-};
-
-static int xa_adpcm_table[] = {
- 0, 240, 460, 392, 0, 0, -208, -220
-};
-
-#define QT_IMA_ADPCM_PREAMBLE_SIZE 2
-#define QT_IMA_ADPCM_BLOCK_SIZE 0x22
-#define QT_IMA_ADPCM_SAMPLES_PER_BLOCK \
- ((QT_IMA_ADPCM_BLOCK_SIZE - QT_IMA_ADPCM_PREAMBLE_SIZE) * 2)
-
-#define MS_ADPCM_PREAMBLE_SIZE 7
-#define MS_IMA_ADPCM_PREAMBLE_SIZE 4
-#define DK4_ADPCM_PREAMBLE_SIZE 4
-#define DK3_ADPCM_PREAMBLE_SIZE 16
-
-/* useful macros */
-/* clamp a number between 0 and 88 */
-#define CLAMP_0_TO_88(x) if (x < 0) x = 0; else if (x > 88) x = 88;
-/* clamp a number within a signed 16-bit range */
-#define CLAMP_S16(x) if (x < -32768) x = -32768; \
- else if (x > 32767) x = 32767;
-/* clamp a number above 16 */
-#define CLAMP_ABOVE_16(x) if (x < 16) x = 16;
-/* sign extend a 16-bit value */
-#define SE_16BIT(x) if (x & 0x8000) x -= 0x10000;
-/* sign extend a 4-bit value */
-#define SE_4BIT(x) if (x & 0x8) x -= 0x10;
-
-#define AUDIOBUFSIZE 128*1024
-
-typedef struct {
- audio_decoder_class_t decoder_class;
-} adpcm_class_t;
-
-typedef struct adpcm_decoder_s {
- audio_decoder_t audio_decoder;
-
- xine_stream_t *stream;
-
- uint32_t rate;
- uint32_t bits_per_sample;
- uint32_t channels;
- uint32_t ao_cap_mode;
-
- unsigned int buf_type;
- int output_open;
-
- unsigned char *buf;
- int bufsize;
- int size;
-
- /* these fields are used for decoding ADPCM data transported in MS file */
- unsigned short *decode_buffer;
- unsigned int in_block_size;
- unsigned int out_block_size; /* size in samples (2 bytes/sample) */
-
- int xa_mode; /* 1 for mode A, 0 for mode B or mode C */
- int xa_p_l; /* previous sample, left/mono channel */
- int xa_p_r; /* previous sample, right channel */
- int xa_pp_l; /* 2nd-previous sample, left/mono channel */
- int xa_pp_r; /* 2nd-previous sample, right channel */
-
-} adpcm_decoder_t;
-
-/*
- * decode_ima_nibbles
- *
- * So many different audio encoding formats leverage off of the IMA
- * ADPCM algorithm that it makes sense to create a function that takes
- * care of handling the common decoding portion.
- *
- * This function takes a buffer of ADPCM nibbles that are stored in an
- * array of signed 16-bit numbers. The function then decodes the nibbles
- * in place so that the buffer contains the decoded audio when the function
- * is finished.
- *
- * The addresses of the initial predictor and index values are passed,
- * rather than their values, so that the function can return the final
- * predictor and index values after decoding. This is done in case the
- * calling function cares (in the case of IMA ADPCM from Westwood Studios'
- * VQA files, the values are initialized to 0 at the beginning of the file
- * and maintained throughout all of the IMA blocks).
- */
-static void decode_ima_nibbles(unsigned short *output,
- int output_size, int channels,
- int *predictor_l, int *index_l,
- int *predictor_r, int *index_r) {
-
- int step[2];
- int predictor[2];
- int index[2];
- int diff;
- int i;
- int sign;
- int delta;
- int channel_number = 0;
-
- /* take care of the left */
- step[0] = ima_adpcm_step[*index_l];
- predictor[0] = *predictor_l;
- index[0] = *index_l;
-
- /* only handle the right if non-NULL pointers */
- if (index_r) {
- step[1] = ima_adpcm_step[*index_r];
- predictor[1] = *predictor_r;
- index[1] = *index_r;
- }
-
- for (i = 0; i < output_size; i++) {
- delta = output[i];
-
- index[channel_number] += ima_adpcm_index[delta];
- CLAMP_0_TO_88(index[channel_number]);
-
- sign = delta & 8;
- delta = delta & 7;
-
- diff = step[channel_number] >> 3;
- if (delta & 4) diff += step[channel_number];
- if (delta & 2) diff += step[channel_number] >> 1;
- if (delta & 1) diff += step[channel_number] >> 2;
-
- if (sign)
- predictor[channel_number] -= diff;
- else
- predictor[channel_number] += diff;
-
- CLAMP_S16(predictor[channel_number]);
- output[i] = predictor[channel_number];
- step[channel_number] = ima_adpcm_step[index[channel_number]];
-
- /* toggle channel */
- channel_number ^= channels - 1;
- }
-
- /* save the index and predictor values in case the calling function cares */
- *predictor_l = predictor[0];
- *index_l = index[0];
-
- /* only save the right channel information if pointers are non-NULL */
- if (predictor_r) {
- *predictor_r = predictor[1];
- *index_r = index[1];
- }
-}
-
-#define DK3_GET_NEXT_NIBBLE() \
- if (decode_top_nibble_next) \
- { \
- nibble = (last_byte >> 4) & 0x0F; \
- decode_top_nibble_next = 0; \
- } \
- else \
- { \
- last_byte = this->buf[i + j++]; \
- if (j > this->in_block_size) break; \
- nibble = last_byte & 0x0F; \
- decode_top_nibble_next = 1; \
- }
-
-static void dk3_adpcm_decode_block(adpcm_decoder_t *this, buf_element_t *buf) {
-
- int i, j;
- audio_buffer_t *audio_buffer;
- int bytes_to_send;
-
- int sum_pred;
- int diff_pred;
- int sum_index;
- int diff_index;
- int diff_channel;
- int out_ptr;
-
- unsigned char last_byte = 0;
- unsigned char nibble;
- int decode_top_nibble_next = 0;
-
- /* ADPCM work variables */
- int sign;
- int delta;
- int step;
- int diff;
-
- /* make sure the input size checks out */
- if ((this->size % this->in_block_size) != 0) {
- lprintf ("received DK3 ADPCM block that does not line up\n");
- this->size = 0;
- return;
- }
-
- /* iterate through each block in the in buffer */
- for (i = 0; i < this->size; i += this->in_block_size) {
-
- sum_pred = LE_16(&this->buf[i + 10]);
- diff_pred = LE_16(&this->buf[i + 12]);
- SE_16BIT(sum_pred);
- SE_16BIT(diff_pred);
- diff_channel = diff_pred;
- sum_index = this->buf[i + 14];
- diff_index = this->buf[i + 15];
-
- j = DK3_ADPCM_PREAMBLE_SIZE; /* start past the preamble */
- out_ptr = 0;
- last_byte = 0;
- decode_top_nibble_next = 0;
- while (j < this->in_block_size) {
-
- /* process the first predictor of the sum channel */
- DK3_GET_NEXT_NIBBLE();
-
- step = ima_adpcm_step[sum_index];
-
- sign = nibble & 8;
- delta = nibble & 7;
-
- diff = step >> 3;
- if (delta & 4) diff += step;
- if (delta & 2) diff += step >> 1;
- if (delta & 1) diff += step >> 2;
-
- if (sign)
- sum_pred -= diff;
- else
- sum_pred += diff;
-
- CLAMP_S16(sum_pred);
-
- sum_index += ima_adpcm_index[nibble];
- CLAMP_0_TO_88(sum_index);
-
- /* process the diff channel predictor */
- DK3_GET_NEXT_NIBBLE();
-
- step = ima_adpcm_step[diff_index];
-
- sign = nibble & 8;
- delta = nibble & 7;
-
- diff = step >> 3;
- if (delta & 4) diff += step;
- if (delta & 2) diff += step >> 1;
- if (delta & 1) diff += step >> 2;
-
- if (sign)
- diff_pred -= diff;
- else
- diff_pred += diff;
-
- CLAMP_S16(diff_pred);
-
- diff_index += ima_adpcm_index[nibble];
- CLAMP_0_TO_88(diff_index);
-
- /* output the first pair of stereo PCM samples */
- diff_channel = (diff_channel + diff_pred) / 2;
- this->decode_buffer[out_ptr++] = sum_pred + diff_channel;
- this->decode_buffer[out_ptr++] = sum_pred - diff_channel;
-
- /* process the second predictor of the sum channel */
- DK3_GET_NEXT_NIBBLE();
-
- step = ima_adpcm_step[sum_index];
-
- sign = nibble & 8;
- delta = nibble & 7;
-
- diff = step >> 3;
- if (delta & 4) diff += step;
- if (delta & 2) diff += step >> 1;
- if (delta & 1) diff += step >> 2;
-
- if (sign)
- sum_pred -= diff;
- else
- sum_pred += diff;
-
- CLAMP_S16(sum_pred);
-
- sum_index += ima_adpcm_index[nibble];
- CLAMP_0_TO_88(sum_index);
-
- /* output the second pair of stereo PCM samples */
- this->decode_buffer[out_ptr++] = sum_pred + diff_channel;
- this->decode_buffer[out_ptr++] = sum_pred - diff_channel;
- }
-
- /* dispatch the decoded audio */
- j = 0;
- while (j < out_ptr) {
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- lprintf ("Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- /* out_ptr and j are sample counts, mem_size is a byte count */
- if (((out_ptr - j) * 2) > audio_buffer->mem_size)
- bytes_to_send = audio_buffer->mem_size;
- else
- bytes_to_send = (out_ptr - j) * 2;
-
- xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[j],
- bytes_to_send);
- /* byte count / 2 (bytes / sample) / channels */
- audio_buffer->num_frames = bytes_to_send / 2 / this->channels;
-
- audio_buffer->vpts = buf->pts;
- buf->pts = 0; /* only first buffer gets the real pts */
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
-
- j += bytes_to_send / 2; /* 2 bytes per sample */
- }
- }
-
- /* reset buffer */
- this->size = 0;
-}
-
-static void dk4_adpcm_decode_block(adpcm_decoder_t *this, buf_element_t *buf) {
-
- int predictor_l = 0;
- int predictor_r = 0;
- int index_l = 0;
- int index_r = 0;
-
- int i, j;
- unsigned int out_ptr = 0;
- audio_buffer_t *audio_buffer;
- int bytes_to_send;
-
- /* make sure the input size checks out */
- if ((this->size % this->in_block_size) != 0) {
- lprintf ("received DK4 ADPCM block that does not line up\n");
- this->size = 0;
- return;
- }
-
- /* iterate through each block in the in buffer */
- for (i = 0; i < this->size; i += this->in_block_size) {
-
- out_ptr = 0;
-
- /* the first predictor value goes straight to the output */
- predictor_l = this->decode_buffer[0] = LE_16(&this->buf[i + 0]);
- SE_16BIT(predictor_l);
- index_l = this->buf[i + 2];
- if (this->channels == 2) {
- predictor_r = this->decode_buffer[1] = LE_16(&this->buf[i + 4]);
- SE_16BIT(predictor_r);
- index_r = this->buf[i + 6];
- }
-
- /* break apart the ADPCM nibbles */
- out_ptr = this->channels;
- for (j = DK4_ADPCM_PREAMBLE_SIZE * this->channels;
- j < this->in_block_size; j++) {
- this->decode_buffer[out_ptr++] = this->buf[i + j] >> 4;
- this->decode_buffer[out_ptr++] = this->buf[i + j] & 0x0F;
- }
-
- /* process the nibbles */
- decode_ima_nibbles(&this->decode_buffer[this->channels],
- out_ptr - this->channels,
- this->channels,
- &predictor_l, &index_l,
- &predictor_r, &index_r);
-
- /* dispatch the decoded audio */
- j = 0;
- while (j < out_ptr) {
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- lprintf ("Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- /* out_ptr and j are sample counts, mem_size is a byte count */
- if (((out_ptr - j) * 2) > audio_buffer->mem_size)
- bytes_to_send = audio_buffer->mem_size;
- else
- bytes_to_send = (out_ptr - j) * 2;
-
- xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[j],
- bytes_to_send);
- /* byte count / 2 (bytes / sample) / channels */
- audio_buffer->num_frames = bytes_to_send / 2 / this->channels;
-
- audio_buffer->vpts = buf->pts;
- buf->pts = 0; /* only first buffer gets the real pts */
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
-
- j += bytes_to_send / 2; /* 2 bytes per sample */
- }
- }
-
- /* reset buffer */
- this->size = 0;
-}
-
-static void ms_ima_adpcm_decode_block(adpcm_decoder_t *this,
- buf_element_t *buf) {
-
- int predictor_l = 0;
- int predictor_r = 0;
- int index_l = 0;
- int index_r = 0;
- int channel_counter;
- int channel_index;
- int channel_index_l;
- int channel_index_r;
-
- int i, j;
- audio_buffer_t *audio_buffer;
- int bytes_to_send;
-
- /* check the size */
- if ((this->size % this->in_block_size) != 0) {
- lprintf ("received MS IMA block that does not line up\n");
- this->size = 0;
- return;
- }
-
- /* iterate through each block in the in buffer */
- for (i = 0; i < this->size; i += this->in_block_size) {
-
- /* initialize algorithm for this block */
- predictor_l = LE_16(&this->buf[i]);
- SE_16BIT(predictor_l);
- index_l = this->buf[i + 2];
- if (this->channels == 2) {
- predictor_r = LE_16(&this->buf[i + MS_IMA_ADPCM_PREAMBLE_SIZE]);
- SE_16BIT(predictor_r);
- index_r = this->buf[i + MS_IMA_ADPCM_PREAMBLE_SIZE + 2];
- }
-
- /* break apart all of the nibbles in the block */
- if (this->channels == 1) {
- for (j = 0;
- j < (this->in_block_size - MS_IMA_ADPCM_PREAMBLE_SIZE) / 2; j++) {
- this->decode_buffer[j * 2 + 0] =
- this->buf[i + MS_IMA_ADPCM_PREAMBLE_SIZE + j] & 0x0F;
- this->decode_buffer[j * 2 + 1] =
- this->buf[i + MS_IMA_ADPCM_PREAMBLE_SIZE + j] >> 4;
- }
- } else {
- /* encoded as 8 nibbles (4 bytes) per channel; switch channel every
- * 4th byte */
- channel_counter = 0;
- channel_index_l = 0;
- channel_index_r = 1;
- channel_index = channel_index_l;
- for (j = 0;
- j < (this->in_block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * 2); j++) {
- this->decode_buffer[channel_index + 0] =
- this->buf[i + MS_IMA_ADPCM_PREAMBLE_SIZE * 2 + j] & 0x0F;
- this->decode_buffer[channel_index + 2] =
- this->buf[i + MS_IMA_ADPCM_PREAMBLE_SIZE * 2 + j] >> 4;
- channel_index += 4;
- channel_counter++;
- if (channel_counter == 4) {
- channel_index_l = channel_index;
- channel_index = channel_index_r;
- } else if (channel_counter == 8) {
- channel_index_r = channel_index;
- channel_index = channel_index_l;
- channel_counter = 0;
- }
- }
- }
-
- /* process the nibbles */
- decode_ima_nibbles(this->decode_buffer,
- this->out_block_size,
- this->channels,
- &predictor_l, &index_l,
- &predictor_r, &index_r);
-
- /* dispatch the decoded audio */
- j = 0;
- while (j < this->out_block_size) {
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- lprintf ("Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- /* out_block_size and j are sample counts, mem_size is a byte count */
- if (((this->out_block_size - j) * 2) > audio_buffer->mem_size)
- bytes_to_send = audio_buffer->mem_size;
- else
- bytes_to_send = (this->out_block_size - j) * 2;
-
- xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[j],
- bytes_to_send);
- /* byte count / 2 (bytes / sample) / channels */
- audio_buffer->num_frames = bytes_to_send / 2 / this->channels;
-
- audio_buffer->vpts = buf->pts;
- buf->pts = 0; /* only first buffer gets the real pts */
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
-
- j += bytes_to_send / 2; /* 2 bytes per sample */
- }
- }
-
- /* reset buffer */
- this->size = 0;
-
-}
-
-static void qt_ima_adpcm_decode_block(adpcm_decoder_t *this,
- buf_element_t *buf) {
-
- int initial_predictor_l = 0;
- int initial_predictor_r = 0;
- int initial_index_l = 0;
- int initial_index_r = 0;
-
- int i, j;
- unsigned short *output;
- unsigned int out_ptr;
- audio_buffer_t *audio_buffer;
-
- /* check the size */
- if ((this->size % (QT_IMA_ADPCM_BLOCK_SIZE * this->channels) != 0)) {
- lprintf ("received QT IMA block that does not line up\n");
- this->size = 0;
- return;
- }
-
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- output = (unsigned short *)audio_buffer->mem;
- out_ptr = 0;
-
- /* iterate through the blocks (and there are 2 bytes/sample) */
- for (i = 0; i < this->size; i+=
- (QT_IMA_ADPCM_BLOCK_SIZE * this->channels)) {
-
- /* send the buffer if it gets full */
- if ((audio_buffer->mem_size / 2) <=
- out_ptr + (QT_IMA_ADPCM_SAMPLES_PER_BLOCK * this->channels)) {
-
- audio_buffer->vpts = buf->pts;
- buf->pts = 0;
- audio_buffer->num_frames = out_ptr / this->channels;
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
-
- /* get a new audio buffer */
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- output = (unsigned short *)audio_buffer->mem;
- out_ptr = 0;
- }
-
- /* get the left (or mono) channel preamble bytes */
- initial_predictor_l = BE_16(&this->buf[i]);
- initial_index_l = initial_predictor_l;
-
- /* mask, sign-extend, and clamp the predictor portion */
- initial_predictor_l &= 0xFF80;
- SE_16BIT(initial_predictor_l);
- CLAMP_S16(initial_predictor_l);
-
- /* mask and clamp the index portion */
- initial_index_l &= 0x7F;
- CLAMP_0_TO_88(initial_index_l);
-
- /* if stereo, handle the right channel too */
- if (this->channels > 1) {
- initial_predictor_r = BE_16(&this->buf[i + QT_IMA_ADPCM_BLOCK_SIZE]);
- initial_index_r = initial_predictor_r;
-
- /* mask, sign-extend, and clamp the predictor portion */
- initial_predictor_r &= 0xFF80;
- SE_16BIT(initial_predictor_r);
- CLAMP_S16(initial_predictor_r);
-
- /* mask and clamp the index portion */
- initial_index_r &= 0x7F;
- CLAMP_0_TO_88(initial_index_r);
- }
-
- /* break apart all of the nibbles in the block */
- if (this->channels == 1)
- for (j = 0; j < QT_IMA_ADPCM_SAMPLES_PER_BLOCK / 2; j++) {
- output[out_ptr + j * 2 + 0] = this->buf[i + 2 + j] & 0x0F;
- output[out_ptr + j * 2 + 1] = this->buf[i + 2 + j] >> 4;
- }
- else
- for (j = 0; j < QT_IMA_ADPCM_SAMPLES_PER_BLOCK / 2 * 2; j++) {
- output[out_ptr + j * 4 + 0] = this->buf[i + 2 + j] & 0x0F;
- output[out_ptr + j * 4 + 1] =
- this->buf[i + 2 + QT_IMA_ADPCM_BLOCK_SIZE + j] & 0x0F;
- output[out_ptr + j * 4 + 2] = this->buf[i + 2 + j] >> 4;
- output[out_ptr + j * 4 + 3] =
- this->buf[i + 2 + QT_IMA_ADPCM_BLOCK_SIZE + j] >> 4;
- }
-
- /* process the nibbles */
- decode_ima_nibbles(&output[out_ptr],
- QT_IMA_ADPCM_SAMPLES_PER_BLOCK * this->channels,
- this->channels,
- &initial_predictor_l, &initial_index_l,
- &initial_predictor_r, &initial_index_r);
-
- out_ptr += QT_IMA_ADPCM_SAMPLES_PER_BLOCK * this->channels;
- }
-
- audio_buffer->vpts = buf->pts;
- audio_buffer->num_frames = out_ptr / this->channels;
-
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
- this->size = 0;
-}
-
-static void ms_adpcm_decode_block(adpcm_decoder_t *this, buf_element_t *buf) {
-
- int i, j;
- unsigned int out_ptr = 0;
- audio_buffer_t *audio_buffer;
- int bytes_to_send;
-
- int current_channel = 0;
- int idelta[2];
- int sample1[2];
- int sample2[2];
- int coeff1[2];
- int coeff2[2];
- int upper_nibble = 1;
- int nibble;
- int snibble; /* signed nibble */
- int predictor;
-
- /* make sure the input size checks out */
- if ((this->size % this->in_block_size) != 0) {
- lprintf ("received MS ADPCM block that does not line up\n");
- this->size = 0;
- return;
- }
-
- /* iterate through each block in the in buffer */
- for (i = 0; i < this->size; i += this->in_block_size) {
-
- /* fetch the header information, in stereo if both channels are present */
- j = i;
- upper_nibble = 1;
- current_channel = 0;
- out_ptr = 0;
-#ifdef LOG
- if (this->buf[j] > 6)
- printf("MS ADPCM: coefficient (%d) out of range (should be [0..6])\n",
- this->buf[j]);
-#endif
- coeff1[0] = ms_adapt_coeff1[this->buf[j]];
- coeff2[0] = ms_adapt_coeff2[this->buf[j]];
- j++;
- if (this->channels == 2) {
- if (this->buf[j] > 6) {
- lprintf("MS ADPCM: coefficient (%d) out of range (should be [0..6])\n",
- this->buf[j]);
- }
- coeff1[1] = ms_adapt_coeff1[this->buf[j]];
- coeff2[1] = ms_adapt_coeff2[this->buf[j]];
- j++;
- }
-
- idelta[0] = LE_16(&this->buf[j]);
- j += 2;
- SE_16BIT(idelta[0]);
- if (this->channels == 2) {
- idelta[1] = LE_16(&this->buf[j]);
- j += 2;
- SE_16BIT(idelta[1]);
- }
-
- sample1[0] = LE_16(&this->buf[j]);
- j += 2;
- SE_16BIT(sample1[0]);
- if (this->channels == 2) {
- sample1[1] = LE_16(&this->buf[j]);
- j += 2;
- SE_16BIT(sample1[1]);
- }
-
- sample2[0] = LE_16(&this->buf[j]);
- j += 2;
- SE_16BIT(sample2[0]);
- if (this->channels == 2) {
- sample2[1] = LE_16(&this->buf[j]);
- j += 2;
- SE_16BIT(sample2[1]);
- }
-
- /* first 2 samples go directly to the output */
- if (this->channels == 1) {
- this->decode_buffer[out_ptr++] = sample2[0];
- this->decode_buffer[out_ptr++] = sample1[0];
- } else {
- this->decode_buffer[out_ptr++] = sample2[0];
- this->decode_buffer[out_ptr++] = sample2[1];
- this->decode_buffer[out_ptr++] = sample1[0];
- this->decode_buffer[out_ptr++] = sample1[1];
- }
-
- j = MS_ADPCM_PREAMBLE_SIZE * this->channels;
- while (j < this->in_block_size) {
- /* get the next nibble */
- if (upper_nibble)
- nibble = snibble = this->buf[i + j] >> 4;
- else
- nibble = snibble = this->buf[i + j++] & 0x0F;
- upper_nibble ^= 1;
- SE_4BIT(snibble);
-
- predictor = (
- ((sample1[current_channel] * coeff1[current_channel]) +
- (sample2[current_channel] * coeff2[current_channel])) / 256) +
- (snibble * idelta[current_channel]);
- CLAMP_S16(predictor);
- sample2[current_channel] = sample1[current_channel];
- sample1[current_channel] = predictor;
- this->decode_buffer[out_ptr++] = predictor;
-
- /* compute the next adaptive scale factor (a.k.a. the variable idelta) */
- idelta[current_channel] =
- (ms_adapt_table[nibble] * idelta[current_channel]) / 256;
- CLAMP_ABOVE_16(idelta[current_channel]);
-
- /* toggle the channel */
- current_channel ^= this->channels - 1;
- }
-
- /* dispatch the decoded audio */
- j = 0;
- while (j < out_ptr) {
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- lprintf ("Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- /* out_ptr and j are sample counts, mem_size is a byte count */
- if (((out_ptr - j) * 2) > audio_buffer->mem_size)
- bytes_to_send = audio_buffer->mem_size;
- else
- bytes_to_send = (out_ptr - j) * 2;
-
- xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[j],
- bytes_to_send);
- /* byte count / 2 (bytes / sample) / channels */
- audio_buffer->num_frames = bytes_to_send / 2 / this->channels;
-
- audio_buffer->vpts = buf->pts;
- buf->pts = 0; /* only first buffer gets the real pts */
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
-
- j += bytes_to_send / 2; /* 2 bytes per sample */
- }
- }
-
- /* reset buffer */
- this->size = 0;
-}
-
-static void smjpeg_adpcm_decode_block(adpcm_decoder_t *this, buf_element_t *buf) {
-
- unsigned int block_size;
- int predictor = 0;
- int index = 0;
-
- int i;
- unsigned int out_ptr = 0;
- audio_buffer_t *audio_buffer;
- int bytes_to_send;
-
- /* fetch the size for this block and check if the decode buffer needs
- * to increase */
- block_size = buf->size - 4; /* compensate for preamble */
- block_size *= 2; /* 2 samples / byte */
- if (block_size > this->out_block_size) {
- this->out_block_size = block_size;
- if (this->decode_buffer) {
- free(this->decode_buffer);
- }
- this->decode_buffer = xine_xmalloc(this->out_block_size * 2);
- }
-
- out_ptr = 0;
- predictor = BE_16(&this->buf[0]);
- index = this->buf[2];
-
- /* break apart the ADPCM nibbles (iterate through each byte in block) */
- for (i = 0; i < block_size / 2; i++) {
- this->decode_buffer[out_ptr++] = this->buf[i + 4] & 0x0F;
- this->decode_buffer[out_ptr++] = this->buf[i + 4] >> 4;
- }
-
- /* process the nibbles */
- decode_ima_nibbles(this->decode_buffer,
- out_ptr,
- 1,
- &predictor, &index,
- 0, 0);
-
- /* dispatch the decoded audio */
- i = 0;
- while (i < out_ptr) {
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- lprintf ("Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- /* out_ptr and i are sample counts, mem_size is a byte count */
- if (((out_ptr - i) * 2) > audio_buffer->mem_size)
- bytes_to_send = audio_buffer->mem_size;
- else
- bytes_to_send = (out_ptr - i) * 2;
-
- xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[i],
- bytes_to_send);
- /* byte count / 2 (bytes / sample) / channels */
- audio_buffer->num_frames = bytes_to_send / 2 / this->channels;
-
- audio_buffer->vpts = buf->pts;
- buf->pts = 0; /* only first buffer gets the real pts */
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
-
- i += bytes_to_send / 2; /* 2 bytes per sample */
- }
-
- /* reset buffer */
- this->size = 0;
-}
-
-static void vqa_adpcm_decode_block(adpcm_decoder_t *this, buf_element_t *buf) {
-
- /* VQA IMA blocks do not have a preamble with an initial index and
- * predictor; there is one master index and predictor pair per channel that
- * is initialized to 0 and maintained throughout all of the VQA IMA
- * blocks. (That is why the following variables are static.) */
- static int index_l = 0;
- static int index_r = 0;
- static int predictor_l = 0;
- static int predictor_r = 0;
-
- int out_ptr = 0;
- int i;
- audio_buffer_t *audio_buffer;
- int bytes_to_send;
-
- /* break apart the ADPCM nibbles */
- for (i = 0; i < this->size; i++) {
- if (this->channels == 1) {
- this->decode_buffer[out_ptr++] = this->buf[i] & 0x0F;
- this->decode_buffer[out_ptr++] = (this->buf[i] >> 4) & 0x0F;
- } else {
- if ((i & 0x1) == 0) {
- /* left channel */
- this->decode_buffer[out_ptr + 0] = this->buf[i] & 0x0F;
- this->decode_buffer[out_ptr + 2] = (this->buf[i] >> 4) & 0x0F;
- } else {
- /* right channel */
- this->decode_buffer[out_ptr + 1] = this->buf[i] & 0x0F;
- this->decode_buffer[out_ptr + 3] = (this->buf[i] >> 4) & 0x0F;
- out_ptr += 4;
- }
- }
- }
-
- /* process the nibbles */
- decode_ima_nibbles(this->decode_buffer,
- out_ptr,
- this->channels,
- &predictor_l, &index_l,
- &predictor_r, &index_r);
-
- /* dispatch the decoded audio */
- i = 0;
- while (i < out_ptr) {
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- lprintf ("Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- /* out_ptr and i are sample counts, mem_size is a byte count */
- if (((out_ptr - i) * 2) > audio_buffer->mem_size)
- bytes_to_send = audio_buffer->mem_size;
- else
- bytes_to_send = (out_ptr - i) * 2;
-
- xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[i],
- bytes_to_send);
- /* byte count / 2 (bytes / sample) / channels */
- audio_buffer->num_frames = bytes_to_send / 2 / this->channels;
-
- audio_buffer->vpts = buf->pts;
- buf->pts = 0; /* only first buffer gets the real pts */
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
-
- i += bytes_to_send / 2; /* 2 bytes per sample */
- }
-
- /* reset buffer */
- this->size = 0;
-}
-
-static void ea_adpcm_decode_block(adpcm_decoder_t *this, buf_element_t *buf) {
- uint32_t samples_in_chunk;
- int32_t previous_left_sample, previous_right_sample;
- int32_t current_left_sample, current_right_sample;
- int32_t next_left_sample, next_right_sample;
- int32_t coeff1l, coeff2l, coeff1r, coeff2r;
- uint8_t shift_left, shift_right;
-
- int count1, count2, i = 0, j = 0;
-
- samples_in_chunk = ALE_32(&this->buf[i]);
- i += 4;
- current_left_sample = (int16_t)ALE_16(&this->buf[i]);
- i += 2;
- previous_left_sample = (int16_t)ALE_16(&this->buf[i]);
- i += 2;
- current_right_sample = (int16_t)ALE_16(&this->buf[i]);
- i += 2;
- previous_right_sample = (int16_t)ALE_16(&this->buf[i]);
- i += 2;
-
- if (samples_in_chunk * 4 > this->out_block_size) {
- this->out_block_size = samples_in_chunk * 4;
- if (this->decode_buffer) {
- free(this->decode_buffer);
- }
- this->decode_buffer = xine_xmalloc(this->out_block_size);
- }
-
- for (count1 = 0; count1 < samples_in_chunk/28;count1++) {
- coeff1l = ea_adpcm_table[(this->buf[i] >> 4) & 0x0F];
- coeff2l = ea_adpcm_table[((this->buf[i] >> 4) & 0x0F) + 4];
- coeff1r = ea_adpcm_table[this->buf[i] & 0x0F];
- coeff2r = ea_adpcm_table[(this->buf[i] & 0x0F) + 4];
- i++;
-
- shift_left = ((this->buf[i] >> 4) & 0x0F) + 8;
- shift_right = (this->buf[i] & 0x0F) + 8;
- i++;
-
- for (count2 = 0; count2 < 28; count2++) {
- next_left_sample = (((this->buf[i] & 0xF0) << 24) >> shift_left);
- next_right_sample = (((this->buf[i] & 0x0F) << 28) >> shift_right);
- i++;
-
- next_left_sample = (next_left_sample + (current_left_sample * coeff1l) + (previous_left_sample * coeff2l) + 0x80) >> 8;
- next_right_sample = (next_right_sample + (current_right_sample * coeff1r) + (previous_right_sample * coeff2r) + 0x80) >> 8;
- CLAMP_S16(next_left_sample);
- CLAMP_S16(next_right_sample);
-
- previous_left_sample = current_left_sample;
- current_left_sample = next_left_sample;
- previous_right_sample = current_right_sample;
- current_right_sample = next_right_sample;
- this->decode_buffer[j] = (unsigned short)current_left_sample;
- j++;
- this->decode_buffer[j] = (unsigned short)current_right_sample;
- j++;
- }
- }
-
- i = 0;
- while (i < j) {
- audio_buffer_t *audio_buffer;
- int bytes_to_send;
-
- audio_buffer = this->stream->audio_out->get_buffer(this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- lprintf ("Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- if (((j - i) * 2) > audio_buffer->mem_size) {
- bytes_to_send = audio_buffer->mem_size;
- }
- else {
- bytes_to_send = (j - i) * 2;
- }
-
- xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[i], bytes_to_send);
-
- audio_buffer->num_frames = (bytes_to_send / 4);
- audio_buffer->vpts = buf->pts;
- buf->pts = 0;
- this->stream->audio_out->put_buffer(this->stream->audio_out, audio_buffer, this->stream);
-
- i += bytes_to_send / 2;
- }
-
- this->size = 0;
-}
-
-/* clamp a number between 0 and 48 */
-#define CLAMP_0_TO_48(x) if (x < 0) x = 0; else if (x > 48) x = 48;
-/* clamp a number within a signed 12-bit range */
-#define CLAMP_S12(x) if (x < -2048) x = -2048; \
- else if (x > 2048) x = 2048;
-static void dialogic_ima_decode_block(adpcm_decoder_t *this, buf_element_t *buf) {
-
- int i;
- unsigned int out_ptr = 0;
- audio_buffer_t *audio_buffer;
- unsigned int block_size;
-
- /* IMA ADPCM work variables */
- /* the predictor and index values are initialized to 0 and maintained
- * throughout the entire stream */
- static int predictor = 0;
- static int index = 16;
- int step = index;
- int diff;
- int sign;
- int delta;
-
- /* fetch the size for this block and check if the decode buffer needs
- * to increase */
- block_size = buf->size * 2; /* 2 samples / byte */
- if (block_size > this->out_block_size) {
- this->out_block_size = block_size;
- if (this->decode_buffer) {
- free(this->decode_buffer);
- }
- this->decode_buffer = xine_xmalloc(this->out_block_size * 2);
- }
-
- /* break apart the nibbles */
- for (i = 0; i < this->size; i++) {
- this->decode_buffer[out_ptr++] = this->buf[i] >> 4;
- this->decode_buffer[out_ptr++] = this->buf[i] & 0xF;
- }
-
- /* decode the nibbles in place using an alternate IMA step table */
- for (i = 0; i < out_ptr; i++) {
-
- delta = this->decode_buffer[i];
- index += ima_adpcm_index[delta];
- CLAMP_0_TO_48(index);
-
- sign = delta & 8;
- delta = delta & 7;
-
- diff = step >> 3;
- if (delta & 4) diff += step;
- if (delta & 2) diff += step >> 1;
- if (delta & 1) diff += step >> 2;
-
- if (sign)
- predictor -= diff;
- else
- predictor += diff;
-
- CLAMP_S12(predictor);
- this->decode_buffer[i] = predictor << 4;
- step = dialogic_ima_step[index];
- }
-
- /* dispatch the decoded audio */
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- audio_buffer->vpts = buf->pts;
- audio_buffer->num_frames = out_ptr;
- xine_fast_memcpy(audio_buffer->mem, this->decode_buffer, out_ptr * 2);
-
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
-
- /* reset buffer */
- this->size = 0;
-}
-
-
-static void xa_adpcm_decode_block(adpcm_decoder_t *this, buf_element_t *buf) {
- int32_t p_l, pp_l, coeff_p_l, coeff_pp_l, range_l;
- int32_t p_r, pp_r, coeff_p_r, coeff_pp_r, range_r;
- int32_t snd_group, snd_unit, snd_data, samp, i, j;
- uint8_t *inp;
-
- /* restore decoding history */
- p_l = this->xa_p_l; pp_l = this->xa_pp_l;
- p_r = this->xa_p_r; pp_r = this->xa_pp_r;
-
- inp = &this->buf[0];
- j = 0;
-
- if (this->xa_mode) {
- if (this->channels == 2) {
- /* mode A (8 bits per sample / 4 sound units) stereo
- * - sound units 0,2 are left channel, 1,3 are right channel
- * - sound data (8 bits) is shifted left to 16-bit border, then
- * shifted right by the range parameter, therefore it's shifted
- * (8-range) bits left.
- * - two coefficients tables (4 entries each) are merged into one
- * - coefficients are multiples of 1/256, so '>> 8' is applied
- * after multiplication to get correct answer.
- */
- for (snd_group = 0; snd_group < 18; snd_group++, inp += 128) {
- for (snd_unit = 0; snd_unit < 4; snd_unit += 2) {
- /* get left channel coeffs and range */
- coeff_p_l = xa_adpcm_table[((inp[snd_unit] >> 4) & 0x3)];
- coeff_pp_l = xa_adpcm_table[((inp[snd_unit] >> 4) & 0x3) + 4];
- range_l = 8 - (inp[snd_unit] & 0xF);
-
- /* get right channel coeffs and range */
- coeff_p_r = xa_adpcm_table[((inp[snd_unit+1] >> 4) & 0x3)];
- coeff_pp_r = xa_adpcm_table[((inp[snd_unit+1] >> 4) & 0x3) + 4];
- range_r = 8 - (inp[snd_unit+1] & 0xF);
-
- for (snd_data = 0; snd_data < 28; snd_data++) {
- /* left channel */
- samp = ((signed char *)inp)[16 + (snd_data << 2) + snd_unit];
- samp <<= range_l;
- samp += (coeff_p_l * p_l + coeff_pp_l * pp_l) >> 8;
- CLAMP_S16(samp);
- pp_l = p_l;
- p_l = samp;
- this->decode_buffer[j++] = (unsigned short) samp;
-
- /* right channel */
- samp = ((signed char *)inp)[16 + (snd_data << 2) + snd_unit+1];
- samp <<= range_r;
- samp += (coeff_p_r * p_r + coeff_pp_r * pp_r) >> 8;
- CLAMP_S16(samp);
- pp_r = p_r;
- p_r = samp;
- this->decode_buffer[j++] = (unsigned short) samp;
- }
- }
- }
- }
- else {
- /* mode A (8 bits per sample / 4 sound units) mono
- * - other details as before
- */
- for (snd_group = 0; snd_group < 18; snd_group++, inp += 128) {
- for (snd_unit = 0; snd_unit < 4; snd_unit++) {
- /* get coeffs and range */
- coeff_p_l = xa_adpcm_table[((inp[snd_unit] >> 4) & 0x3)];
- coeff_pp_l = xa_adpcm_table[((inp[snd_unit] >> 4) & 0x3) + 4];
- range_l = 8 - (inp[snd_unit] & 0xF);
-
- for (snd_data = 0; snd_data < 28; snd_data++) {
- samp = ((signed char *)inp)[16 + (snd_data << 2) + snd_unit];
- samp <<= range_l;
- samp += (coeff_p_l * p_l + coeff_pp_l * pp_l) >> 8;
- CLAMP_S16(samp);
- pp_l = p_l; p_l = samp;
- this->decode_buffer[j++] = (unsigned short) samp;
- }
- }
- }
- }
- }
- else {
- if (this->channels == 2) {
- /* mode B/C (4 bits per sample / 8 sound units) stereo
- * - sound units 0,2,4,6 are left channel, 1,3,5,7 are right channel
- * - sound parameters 0-7 are stored as 16 bytes in the order
- * "0123012345674567", so inp[x+4] gives sound parameter x while
- * inp[x] doesn't.
- * - sound data (4 bits) is shifted left to 16-bit border, then
- * shifted right by the range parameter, therefore it's shifted
- * (12-range) bits left.
- * - other details as before
- */
- for (snd_group = 0; snd_group < 18; snd_group++, inp += 128) {
- for (snd_unit = 0; snd_unit < 8; snd_unit += 2) {
- /* get left channel coeffs and range */
- coeff_p_l = xa_adpcm_table[((inp[snd_unit+4] >> 4) & 0x3)];
- coeff_pp_l = xa_adpcm_table[((inp[snd_unit+4] >> 4) & 0x3) + 4];
- range_l = 12 - (inp[snd_unit+4] & 0xF);
-
- /* get right channel coeffs and range */
- coeff_p_r = xa_adpcm_table[((inp[snd_unit+5] >> 4) & 0x3)];
- coeff_pp_r = xa_adpcm_table[((inp[snd_unit+5] >> 4) & 0x3) + 4];
- range_r = 12 - (inp[snd_unit+5] & 0xF);
-
- for (snd_data = 0; snd_data < 28; snd_data++) {
- /* left channel */
- samp = (inp[16 + (snd_data << 2) + (snd_unit >> 1)]) & 0xF;
- SE_4BIT(samp);
- samp <<= range_l;
- samp += (coeff_p_l * p_l + coeff_pp_l * pp_l) >> 8;
- CLAMP_S16(samp);
- pp_l = p_l;
- p_l = samp;
- this->decode_buffer[j++] = (unsigned short) samp;
-
- /* right channel */
- samp = (inp[16 + (snd_data << 2) + (snd_unit >> 1)] >> 4) & 0xF;
- SE_4BIT(samp);
- samp <<= range_r;
- samp += (coeff_p_r * p_r + coeff_pp_r * pp_r) >> 8;
- CLAMP_S16(samp);
- pp_r = p_r;
- p_r = samp;
- this->decode_buffer[j++] = (unsigned short) samp;
- }
- }
- }
- }
- else {
- /* mode B or C (4 bits per sample / 8 sound units) mono
- * - other details as before
- */
- for (snd_group = 0; snd_group < 18; snd_group++, inp += 128) {
- for (snd_unit = 0; snd_unit < 8; snd_unit++) {
- /* get coeffs and range */
- coeff_p_l = xa_adpcm_table[((inp[snd_unit+4] >> 4) & 0x3)];
- coeff_pp_l = xa_adpcm_table[((inp[snd_unit+4] >> 4) & 0x3) + 4];
- range_l = 12 - (inp[snd_unit+4] & 0xF);
-
- for (snd_data = 0; snd_data < 28; snd_data++) {
- samp = inp[16 + (snd_data << 2) + (snd_unit >> 1)];
- if (snd_unit & 1) samp >>= 4; samp &= 0xF;
- SE_4BIT(samp);
- samp <<= range_l;
- samp += (coeff_p_l * p_l + coeff_pp_l * pp_l) >> 8;
- CLAMP_S16(samp);
- pp_l = p_l;
- p_l = samp;
- this->decode_buffer[j++] = (unsigned short) samp;
- }
- }
- }
- }
- }
-
- /* store decoding history */
- this->xa_p_l = p_l; this->xa_pp_l = pp_l;
- this->xa_p_r = p_r; this->xa_pp_r = pp_r;
-
- /* despatch the decoded audio */
- i = 0;
- while (i < j) {
- audio_buffer_t *audio_buffer;
- int bytes_to_send;
-
- audio_buffer= this->stream->audio_out->get_buffer(this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- lprintf ("Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- if (((j - i) * 2) > audio_buffer->mem_size) {
- bytes_to_send = audio_buffer->mem_size;
- }
- else {
- bytes_to_send = (j - i) * 2;
- }
-
- xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[i],
- bytes_to_send);
-
- audio_buffer->num_frames = bytes_to_send / (2 * this->channels);
- audio_buffer->vpts = buf->pts;
- buf->pts = 0;
- this->stream->audio_out->put_buffer(this->stream->audio_out,
- audio_buffer, this->stream);
-
- i += bytes_to_send / 2;
- }
-
- /* reset input buffer */
- this->size = 0;
-}
-
-static void adpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
- adpcm_decoder_t *this = (adpcm_decoder_t *) this_gen;
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) {
- xine_waveformatex *audio_header;
-
- this->rate = buf->decoder_info[1];
- this->channels = buf->decoder_info[3];
- this->ao_cap_mode =
- (this->channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO;
-
- this->buf = xine_xmalloc(AUDIOBUFSIZE);
- this->bufsize = AUDIOBUFSIZE;
- this->size = 0;
-
- /* load the stream information */
- switch (buf->type & 0xFFFF0000) {
-
- case BUF_AUDIO_MSADPCM:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "Microsoft ADPCM");
- break;
-
- case BUF_AUDIO_MSIMAADPCM:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "Microsoft IMA ADPCM");
- break;
-
- case BUF_AUDIO_QTIMAADPCM:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "QT IMA ADPCM");
- break;
-
- case BUF_AUDIO_DK3ADPCM:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "Duck DK3 ADPCM");
- break;
-
- case BUF_AUDIO_DK4ADPCM:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "Duck DK4 ADPCM");
- break;
-
- case BUF_AUDIO_SMJPEG_IMA:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "SMJPEG IMA ADPCM");
- break;
-
- case BUF_AUDIO_VQA_IMA:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "VQA IMA ADPCM");
- break;
-
- case BUF_AUDIO_EA_ADPCM:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "EA ADPCM");
- break;
-
- case BUF_AUDIO_DIALOGIC_IMA:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "Dialogic IMA ADPCM");
- break;
-
- case BUF_AUDIO_XA_ADPCM:
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "CD-ROM/XA ADPCM");
- break;
-
- }
-
- /* if the data was transported in an MS-type file (packet size will be
- * non-0 indicating an audio header), create a decode buffer */
- if (buf->size) {
- audio_header = (xine_waveformatex *)buf->content;
- this->in_block_size = audio_header->nBlockAlign;
-
- switch(buf->type) {
- case BUF_AUDIO_MSADPCM:
- this->out_block_size =
- (this->in_block_size -
- ((MS_ADPCM_PREAMBLE_SIZE - 2) * this->channels)) * 2;
- break;
-
- case BUF_AUDIO_DK4ADPCM:
- /* A DK4 ADPCM block has 4 preamble bytes per channel and the
- * initial predictor is also the first output sample (hence
- * the +1) */
- this->out_block_size =
- (this->in_block_size - (4 * this->channels)) * 2 + this->channels;
- break;
-
- case BUF_AUDIO_DK3ADPCM:
- /* A DK3 ADPCM block as 16 preamble bytes. A set of 3 nibbles,
- * or 1.5 bytes, decodes to 4 PCM samples, so 6 nibbles, or 3
- * bytes, decode to 8 PCM samples. */
- this->out_block_size =
- (this->in_block_size - DK3_ADPCM_PREAMBLE_SIZE) * 8 / 3;
- break;
-
- case BUF_AUDIO_MSIMAADPCM:
- /* a block of IMA ADPCM stored in an MS-type file has 4
- * preamble bytes per channel. */
- this->out_block_size =
- (this->in_block_size -
- (MS_IMA_ADPCM_PREAMBLE_SIZE * this->channels)) * 2;
- break;
-
- default:
- this->out_block_size = 0;
- }
-
- /* allocate 2 bytes per sample */
- this->decode_buffer = xine_xmalloc(this->out_block_size * 2);
- }
-
- /* the decoder will not know the size of the output buffer until
- * an audio packet comes through */
- if ((buf->type == BUF_AUDIO_SMJPEG_IMA) ||
- (buf->type == BUF_AUDIO_EA_ADPCM) ||
- (buf->type == BUF_AUDIO_DIALOGIC_IMA)) {
- this->in_block_size = this->out_block_size = 0;
- this->decode_buffer = NULL;
- }
-
- /* make this decode buffer large enough to hold a second of decoded
- * audio */
- if (buf->type == BUF_AUDIO_VQA_IMA) {
- this->out_block_size = this->rate * this->channels;
- /* allocate 2 bytes per sample */
- this->decode_buffer = xine_xmalloc(this->out_block_size * 2);
- }
-
- /* XA blocks are always 2304 bytes of input data. For output, there
- * are 18 sound groups. These sound groups have 4 sound units (mode A)
- * or 8 sound units (mode B or mode C). The sound units have 28 sound
- * data samples. So, either 18*4*28=2016 or 18*8*28=4032 samples per
- * sector. 2 bytes per sample means 4032 or 8064 bytes per sector.
- */
- if ((buf->type & 0xFFFF0000) == BUF_AUDIO_XA_ADPCM) {
- /* initialise decoder state */
- this->xa_mode = buf->decoder_info[2];
- this->xa_p_l = this->xa_pp_l = this->xa_p_r = this->xa_pp_r = 0;
- /* allocate 2 bytes per sample */
- this->decode_buffer = xine_xmalloc((this->xa_mode) ? 4032 : 8064);
- }
-
- return;
- }
-
- if (!this->output_open) {
- lprintf ("opening audio output (%d Hz sampling rate, mode=%d)\n",
- this->rate, this->ao_cap_mode);
- this->output_open = this->stream->audio_out->open (this->stream->audio_out,
- this->stream, this->bits_per_sample, this->rate, this->ao_cap_mode);
- }
-
- /* if the audio still isn't open, bail */
- if (!this->output_open)
- return;
-
- /* accumulate compressed audio data */
- if( this->size + buf->size > this->bufsize ) {
- this->bufsize = this->size + 2 * buf->size;
- lprintf("increasing source buffer to %d to avoid overflow.\n",
- this->bufsize);
- this->buf = realloc( this->buf, this->bufsize );
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
- this->size += buf->size;
-
- /* time to decode a frame */
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- switch(buf->type & 0xFFFF0000) {
-
- case BUF_AUDIO_MSADPCM:
- ms_adpcm_decode_block(this, buf);
- break;
-
- case BUF_AUDIO_MSIMAADPCM:
- ms_ima_adpcm_decode_block(this, buf);
- break;
-
- case BUF_AUDIO_QTIMAADPCM:
- qt_ima_adpcm_decode_block(this, buf);
- break;
-
- case BUF_AUDIO_DK3ADPCM:
- dk3_adpcm_decode_block(this, buf);
- break;
-
- case BUF_AUDIO_DK4ADPCM:
- dk4_adpcm_decode_block(this, buf);
- break;
-
- case BUF_AUDIO_SMJPEG_IMA:
- smjpeg_adpcm_decode_block(this, buf);
- break;
-
- case BUF_AUDIO_VQA_IMA:
- vqa_adpcm_decode_block(this, buf);
- break;
-
- case BUF_AUDIO_EA_ADPCM:
- ea_adpcm_decode_block(this, buf);
- break;
-
- case BUF_AUDIO_DIALOGIC_IMA:
- dialogic_ima_decode_block(this, buf);
- break;
-
- case BUF_AUDIO_XA_ADPCM:
- xa_adpcm_decode_block(this, buf);
- break;
- }
- }
-}
-
-static void adpcm_reset (audio_decoder_t *this_gen) {
-
- /* adpcm_decoder_t *this = (adpcm_decoder_t *) this_gen; */
-
-}
-
-static void adpcm_discontinuity (audio_decoder_t *this_gen) {
-
- /* adpcm_decoder_t *this = (adpcm_decoder_t *) this_gen; */
-
-}
-
-static void adpcm_dispose (audio_decoder_t *this_gen) {
-
- adpcm_decoder_t *this = (adpcm_decoder_t *) this_gen;
-
- if (this->output_open)
- this->stream->audio_out->close (this->stream->audio_out, this->stream);
- this->output_open = 0;
-
- if (this->decode_buffer)
- free(this->decode_buffer);
- if (this->buf)
- free(this->buf);
-
- free (this_gen);
-}
-
-/*
- * ADPCM decoder class code
- */
-
-static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- adpcm_decoder_t *this ;
-
- this = (adpcm_decoder_t *) xine_xmalloc (sizeof (adpcm_decoder_t));
-
- this->audio_decoder.decode_data = adpcm_decode_data;
- this->audio_decoder.reset = adpcm_reset;
- this->audio_decoder.discontinuity = adpcm_discontinuity;
- this->audio_decoder.dispose = adpcm_dispose;
-
- this->output_open = 0;
- this->rate = 0;
- this->bits_per_sample = 16; /* these codecs always output 16-bit PCM */
- this->channels = 0;
- this->ao_cap_mode = 0;
- this->decode_buffer = NULL;
- this->stream = stream;
-
- return &this->audio_decoder;
-}
-
-static char *get_identifier (audio_decoder_class_t *this) {
- return "ADPCM";
-}
-
-static char *get_description (audio_decoder_class_t *this) {
- return "Multiple ADPCM audio format decoder plugin";
-}
-
-static void dispose_class (audio_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- adpcm_class_t *this ;
-
- this = (adpcm_class_t *) xine_xmalloc (sizeof (adpcm_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-static uint32_t audio_types[] = {
- BUF_AUDIO_MSADPCM, BUF_AUDIO_MSIMAADPCM,
- BUF_AUDIO_QTIMAADPCM, BUF_AUDIO_DK3ADPCM,
- BUF_AUDIO_DK4ADPCM, BUF_AUDIO_SMJPEG_IMA,
- BUF_AUDIO_VQA_IMA, BUF_AUDIO_EA_ADPCM,
- BUF_AUDIO_DIALOGIC_IMA, BUF_AUDIO_XA_ADPCM,
- 0
- };
-
-static decoder_info_t dec_info_audio = {
- audio_types, /* supported types */
- 9 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_AUDIO_DECODER, 15, "adpcm", XINE_VERSION_CODE, &dec_info_audio, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxineadec/interplayaudio.c b/src/libxineadec/interplayaudio.c
deleted file mode 100644
index 7d05f41ac..000000000
--- a/src/libxineadec/interplayaudio.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright (C) 2000-2001 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * Interplay DPCM Audio Decoder by Mike Melanson (melanson@pcisys.net)
- * For more information regarding the Interplay MVE file format, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: interplayaudio.c,v 1.8 2004/01/12 17:35:18 miguelfreitas Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "audio_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define AUDIOBUFSIZE 128*1024
-
-typedef struct {
- audio_decoder_class_t decoder_class;
-} interplay_class_t;
-
-typedef struct interplay_decoder_s {
- audio_decoder_t audio_decoder;
-
- xine_stream_t *stream;
-
- int sample_rate; /* audio sample rate */
- int bits_per_sample; /* bits/sample, usually 8 or 16 */
- int channels; /* 1 or 2, usually */
-
- int output_open; /* flag to indicate audio is ready */
-
- unsigned char *buf; /* data accumulation buffer */
- int bufsize; /* maximum size of buf */
- int size; /* size of accumulated data in buf */
-
- int last_left_delta;
- int last_right_delta;
-
-} interplay_decoder_t;
-
-/**************************************************************************
- * Interplay DPCM specific decode functions
- *************************************************************************/
-
-int interplay_delta_table[] = {
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 47, 51, 56, 61,
- 66, 72, 79, 86, 94, 102, 112, 122,
- 133, 145, 158, 173, 189, 206, 225, 245,
- 267, 292, 318, 348, 379, 414, 452, 493,
- 538, 587, 640, 699, 763, 832, 908, 991,
- 1081, 1180, 1288, 1405, 1534, 1673, 1826, 1993,
- 2175, 2373, 2590, 2826, 3084, 3365, 3672, 4008,
- 4373, 4772, 5208, 5683, 6202, 6767, 7385, 8059,
- 8794, 9597, 10472, 11428, 12471, 13609, 14851, 16206,
- 17685, 19298, 21060, 22981, 25078, 27367, 29864, 32589,
- -29973, -26728, -23186, -19322, -15105, -10503, -5481, -1,
- 1, 1, 5481, 10503, 15105, 19322, 23186, 26728,
- 29973, -32589, -29864, -27367, -25078, -22981, -21060, -19298,
- -17685, -16206, -14851, -13609, -12471, -11428, -10472, -9597,
- -8794, -8059, -7385, -6767, -6202, -5683, -5208, -4772,
- -4373, -4008, -3672, -3365, -3084, -2826, -2590, -2373,
- -2175, -1993, -1826, -1673, -1534, -1405, -1288, -1180,
- -1081, -991, -908, -832, -763, -699, -640, -587,
- -538, -493, -452, -414, -379, -348, -318, -292,
- -267, -245, -225, -206, -189, -173, -158, -145,
- -133, -122, -112, -102, -94, -86, -79, -72,
- -66, -61, -56, -51, -47, -43, -42, -41,
- -40, -39, -38, -37, -36, -35, -34, -33,
- -32, -31, -30, -29, -28, -27, -26, -25,
- -24, -23, -22, -21, -20, -19, -18, -17,
- -16, -15, -14, -13, -12, -11, -10, -9,
- -8, -7, -6, -5, -4, -3, -2, -1
-
-};
-
-/**************************************************************************
- * xine audio plugin functions
- *************************************************************************/
-
-/* clamp a number within a signed 16-bit range */
-#define CLAMP_S16(x) if (x < -32768) x = -32768; \
- else if (x > 32767) x = 32767;
-
-static void interplay_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
-
- interplay_decoder_t *this = (interplay_decoder_t *) this_gen;
- audio_buffer_t *audio_buffer;
- int i;
- int samples_to_send;
- int delta[2];
- int stream_ptr = 0;
- int sequence_number;
- int channel_number = 0;
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) {
-
- /* When the engine sends a BUF_FLAG_HEADER flag, it is time to initialize
- * the decoder. The buffer element type has 4 decoder_info fields,
- * 0..3. Field 1 is the sample rate. Field 2 is the bits/sample. Field
- * 3 is the number of channels. */
- this->sample_rate = buf->decoder_info[1];
- this->bits_per_sample = buf->decoder_info[2];
- this->channels = buf->decoder_info[3];
-
- /* initialize the data accumulation buffer */
- this->buf = xine_xmalloc(AUDIOBUFSIZE);
- this->bufsize = AUDIOBUFSIZE;
- this->size = 0;
-
- /* take this opportunity to initialize stream/meta information */
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "Interplay MVE DPCM");
-
- return;
- }
-
- /* if the audio output is not open yet, open the audio output */
- if (!this->output_open) {
- this->output_open = this->stream->audio_out->open(
- this->stream->audio_out,
- this->stream,
- 16,
- this->sample_rate,
- (this->channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO);
- }
-
- /* if the audio still isn't open, do not go any further with the decode */
- if (!this->output_open)
- return;
-
- /* accumulate the data passed through the buffer element type; increase
- * the accumulator buffer size as necessary */
- if( this->size + buf->size > this->bufsize ) {
- this->bufsize = this->size + 2 * buf->size;
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "interplayaudio: increasing source buffer to %d to avoid overflow.\n", this->bufsize);
- this->buf = realloc( this->buf, this->bufsize );
- }
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
- this->size += buf->size;
-
- /* When a buffer element type has the BUF_FLAG_FRAME_END flag set, it is
- * time to decode the data in the buffer. */
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- /* if this is the first frame, fetch the first deltas from the stream */
- sequence_number = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 6; /* skip over the stream mask and stream length */
- if (sequence_number == 1) {
- delta[0] = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- if (this->channels == 2) {
- delta[1] = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- }
- } else {
- delta[0] = this->last_left_delta;
- if (this->channels == 2)
- delta[1] = this->last_right_delta;
- }
-
- /* iterate through each 8-bit delta in the input buffer */
- while (stream_ptr < this->size) {
-
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "interplayaudio: Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- /* this->size and stream_ptr are sample counts, mem_size is a byte count */
- if ((this->size - stream_ptr) > (audio_buffer->mem_size / 2))
- samples_to_send = audio_buffer->mem_size / 2;
- else
- samples_to_send = this->size - stream_ptr;
-
- /* fill up this buffer */
- for (i = 0; i < samples_to_send; i++) {
- delta[channel_number] += interplay_delta_table[this->buf[stream_ptr++]];
- CLAMP_S16(delta[channel_number]);
- audio_buffer->mem[i] = delta[channel_number];
-
- /* toggle channel */
- channel_number ^= this->channels - 1;
- }
-
- audio_buffer->num_frames = samples_to_send / this->channels;
- audio_buffer->vpts = buf->pts;
- buf->pts = 0; /* only first buffer gets the real pts */
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
- }
-
- /* stash away the deltas for the next block */
- this->last_left_delta = delta[0];
- this->last_right_delta = delta[1];
-
- /* reset data accumulation buffer */
- this->size = 0;
- }
-}
-
-/* This function resets the state of the audio decoder. This usually
- * entails resetting the data accumulation buffer. */
-static void interplay_reset (audio_decoder_t *this_gen) {
-
- interplay_decoder_t *this = (interplay_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-/* This function resets the last pts value of the audio decoder. */
-static void interplay_discontinuity (audio_decoder_t *this_gen) {
-}
-
-/* This function closes the audio output and frees the private audio decoder
- * structure. */
-static void interplay_dispose (audio_decoder_t *this_gen) {
-
- interplay_decoder_t *this = (interplay_decoder_t *) this_gen;
-
- /* close the audio output */
- if (this->output_open)
- this->stream->audio_out->close (this->stream->audio_out, this->stream);
- this->output_open = 0;
-
- /* free anything that was allocated during operation */
- free(this->buf);
- free(this);
-}
-
-/* This function allocates, initializes, and returns a private audio
- * decoder structure. */
-static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- interplay_decoder_t *this ;
-
- this = (interplay_decoder_t *) xine_xmalloc (sizeof (interplay_decoder_t));
-
- /* connect the member functions */
- this->audio_decoder.decode_data = interplay_decode_data;
- this->audio_decoder.reset = interplay_reset;
- this->audio_decoder.discontinuity = interplay_discontinuity;
- this->audio_decoder.dispose = interplay_dispose;
-
- /* connect the stream */
- this->stream = stream;
-
- /* audio output is not open at the start */
- this->output_open = 0;
-
- /* initialize the basic audio parameters */
- this->channels = 0;
- this->sample_rate = 0;
- this->bits_per_sample = 0;
-
- /* initialize the data accumulation buffer */
- this->buf = NULL;
- this->bufsize = 0;
- this->size = 0;
-
- /* return the newly-initialized audio decoder */
- return &this->audio_decoder;
-}
-
-/* This function returns a brief string that describes (usually with the
- * decoder's most basic name) the audio decoder plugin. */
-static char *get_identifier (audio_decoder_class_t *this) {
- return "Interplay DPCM Audio";
-}
-
-/* This function returns a slightly longer string describing the audio
- * decoder plugin. */
-static char *get_description (audio_decoder_class_t *this) {
- return "Interplay DPCM audio decoder plugin";
-}
-
-/* This function frees the audio decoder class and any other memory that was
- * allocated. */
-static void dispose_class (audio_decoder_class_t *this_gen) {
-
- interplay_class_t *this = (interplay_class_t *)this_gen;
-
- free (this);
-}
-
-/* This function allocates a private audio decoder class and initializes
- * the class's member functions. */
-static void *init_plugin (xine_t *xine, void *data) {
-
- interplay_class_t *this ;
-
- this = (interplay_class_t *) xine_xmalloc (sizeof (interplay_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/* This is a list of all of the internal xine audio buffer types that
- * this decoder is able to handle. Check src/xine-engine/buffer.h for a
- * list of valid buffer types (and add a new one if the one you need does
- * not exist). Terminate the list with a 0. */
-static uint32_t audio_types[] = {
- BUF_AUDIO_INTERPLAY,
- 0
-};
-
-/* This data structure combines the list of supported xine buffer types and
- * the priority that the plugin should be given with respect to other
- * plugins that handle the same buffer type. A plugin with priority (n+1)
- * will be used instead of a plugin with priority (n). */
-static decoder_info_t dec_info_audio = {
- audio_types, /* supported types */
- 5 /* priority */
-};
-
-/* The plugin catalog entry. This is the only information that this plugin
- * will export to the public. */
-plugin_info_t xine_plugin_info[] = {
- /* { type, API version, "name", version, special_info, init_function }, */
- { PLUGIN_AUDIO_DECODER, 15, "interplayaudio", XINE_VERSION_CODE, &dec_info_audio, &init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
-
diff --git a/src/libxineadec/logpcm.c b/src/libxineadec/logpcm.c
deleted file mode 100644
index 3e2ea1a25..000000000
--- a/src/libxineadec/logpcm.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * Logarithmic PCM Decoder
- * This audio decoder handles the mu-law and A-law logarithmic coding
- * standards.
- *
- * mu-law -> PCM conversion routine found at this site:
- * http://www.speech.cs.cmu.edu/comp.speech/Section2/Q2.7.html
- * and credited to this person:
- * Craig Reese: IDA/Supercomputing Research Center
- *
- * A-law -> PCM conversion routine lifted from SoX Sound eXchange:
- * http://sox.sourceforge.net/
- * which listed the code as being lifted from Sun Microsystems.
- *
- * $Id: logpcm.c,v 1.19 2004/01/12 17:35:18 miguelfreitas Exp $
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "buffer.h"
-#include "xine_internal.h"
-#include "video_out.h"
-#include "audio_out.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define AUDIOBUFSIZE 128*1024
-#define LOGPCM_BITS_PER_SAMPLE 16
-
-typedef struct {
- audio_decoder_class_t decoder_class;
-} logpcm_class_t;
-
-typedef struct logpcm_decoder_s {
- audio_decoder_t audio_decoder;
-
- xine_stream_t *stream;
-
- int64_t pts;
-
- int output_open;
- int output_channels;
- int samplerate;
-
- unsigned char *buf;
- int bufsize;
- int size;
-
- short logtable[256];
-} logpcm_decoder_t;
-
-/*
-** This routine converts from ulaw to 16 bit linear.
-**
-** Craig Reese: IDA/Supercomputing Research Center
-** 29 September 1989
-**
-** References:
-** 1) CCITT Recommendation G.711 (very difficult to follow)
-** 2) MIL-STD-188-113,"Interoperability and Performance Standards
-** for Analog-to_Digital Conversion Techniques,"
-** 17 February 1987
-**
-** Input: 8 bit ulaw sample
-** Output: signed 16 bit linear sample
-*/
-
-static int mulaw2linear(unsigned char mulawbyte) {
-
- static int exp_lut[8] = {0,132,396,924,1980,4092,8316,16764};
- int sign, exponent, mantissa, sample;
-
- mulawbyte = ~mulawbyte;
- sign = (mulawbyte & 0x80);
- exponent = (mulawbyte >> 4) & 0x07;
- mantissa = mulawbyte & 0x0F;
- sample = exp_lut[exponent] + (mantissa << (exponent + 3));
- if (sign != 0) sample = -sample;
-
- return(sample);
-}
-
-/*
- * The following A-law -> PCM conversion function came from SoX which in
- * turn came from Sun Microsystems.
- */
-#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
-#define QUANT_MASK (0xf) /* Quantization field mask. */
-#define SEG_SHIFT (4) /* Left shift for segment number. */
-#define SEG_MASK (0x70) /* Segment field mask. */
-
-/*
- * alaw2linear() - Convert an A-law value to 16-bit signed linear PCM
- *
- */
-static int alaw2linear(unsigned char a_val) {
-
- int t;
- int seg;
-
- a_val ^= 0x55;
-
- t = (a_val & QUANT_MASK) << 4;
- seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
- switch (seg) {
- case 0:
- t += 8;
- break;
-
- case 1:
- t += 0x108;
- break;
-
- default:
- t += 0x108;
- t <<= seg - 1;
- }
- return ((a_val & SIGN_BIT) ? t : -t);
-}
-
-
-static void logpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
-
- logpcm_decoder_t *this = (logpcm_decoder_t *) this_gen;
- audio_buffer_t *audio_buffer;
- int in;
- int i;
- int bytes_to_send;
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) {
-
- this->samplerate = buf->decoder_info[1];
- this->output_channels = buf->decoder_info[3];
- this->buf = xine_xmalloc(AUDIOBUFSIZE);
- this->bufsize = AUDIOBUFSIZE;
- this->size = 0;
-
- /* stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- (buf->type == BUF_AUDIO_MULAW) ? "mu-law log PCM" :
- "A-law log PCM" );
-
- /* pre-calculate the possible log values */
- if (buf->type == BUF_AUDIO_MULAW)
- for (i = 0; i < 256; i++)
- this->logtable[i] = (short)mulaw2linear(i);
- else if (buf->type == BUF_AUDIO_ALAW)
- for (i = 0; i < 256; i++)
- this->logtable[i] = (short)alaw2linear(i);
-
- return;
- }
-
- if (!this->output_open) {
- this->output_open = this->stream->audio_out->open(this->stream->audio_out,
- this->stream, LOGPCM_BITS_PER_SAMPLE, this->samplerate,
- (this->output_channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO);
- }
-
- /* if the audio still isn't open, bail */
- if (!this->output_open)
- return;
-
- if( this->size + buf->size > this->bufsize ) {
- this->bufsize = this->size + 2 * buf->size;
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "logpcm: increasing source buffer to %d to avoid overflow.\n", this->bufsize);
- this->buf = realloc( this->buf, this->bufsize );
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) { /* time to decode a frame */
-
- /* iterate through each 8-bit sample in the input buffer */
- in = 0;
- while (in < this->size) {
-
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- if (audio_buffer->mem_size == 0) {
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "logpcm: Help! Allocated audio buffer with nothing in it!\n");
- return;
- }
-
- /* this->size and in are sample counts, mem_size is a byte count */
- if ((this->size - in) > (audio_buffer->mem_size / 2))
- bytes_to_send = audio_buffer->mem_size / 2;
- else
- bytes_to_send = this->size - in;
-
- /* fill up this buffer */
- for (i = 0; i < bytes_to_send; i++)
- audio_buffer->mem[i] = this->logtable[this->buf[in++]];
-
- audio_buffer->num_frames = bytes_to_send / this->output_channels;
- audio_buffer->vpts = buf->pts;
- buf->pts = 0; /* only first buffer gets the real pts */
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
- }
-
- /* reset internal accumulation buffer */
- this->size = 0;
- }
-}
-
-static void logpcm_reset (audio_decoder_t *this_gen) {
-}
-
-static void logpcm_discontinuity (audio_decoder_t *this_gen) {
- logpcm_decoder_t *this = (logpcm_decoder_t *) this_gen;
-
- this->pts = 0;
-}
-
-static void logpcm_dispose (audio_decoder_t *this_gen) {
-
- logpcm_decoder_t *this = (logpcm_decoder_t *) this_gen;
-
- if (this->output_open)
- this->stream->audio_out->close (this->stream->audio_out, this->stream);
- this->output_open = 0;
-
- if (this->buf)
- free(this->buf);
-
- free (this_gen);
-}
-
-static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- logpcm_decoder_t *this ;
-
- this = (logpcm_decoder_t *) xine_xmalloc (sizeof (logpcm_decoder_t));
-
- this->audio_decoder.decode_data = logpcm_decode_data;
- this->audio_decoder.reset = logpcm_reset;
- this->audio_decoder.discontinuity = logpcm_discontinuity;
- this->audio_decoder.dispose = logpcm_dispose;
-
- this->output_open = 0;
- this->output_channels = 0;
- this->stream = stream;
- this->buf = NULL;
- this->size = 0;
-
- return &this->audio_decoder;
-}
-
-static char *get_identifier (audio_decoder_class_t *this) {
- return "Log PCM";
-}
-
-static char *get_description (audio_decoder_class_t *this) {
- return "Logarithmic PCM audio format decoder plugin";
-}
-
-static void dispose_class (audio_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- logpcm_class_t *this ;
-
- this = (logpcm_class_t *) xine_xmalloc (sizeof (logpcm_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-static uint32_t audio_types[] = { BUF_AUDIO_MULAW, BUF_AUDIO_ALAW, 0 };
-
-static decoder_info_t dec_info_audio = {
- audio_types, /* supported types */
- 9 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_AUDIO_DECODER, 15, "logpcm", XINE_VERSION_CODE, &dec_info_audio, &init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxineadec/roqaudio.c b/src/libxineadec/roqaudio.c
deleted file mode 100644
index 6bc713a98..000000000
--- a/src/libxineadec/roqaudio.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * RoQ DPCM Audio Decoder by Mike Melanson (melanson@pcisys.net)
- * For more information regarding the RoQ file format, visit:
- * http://www.csse.monash.edu.au/~timf/
- *
- * $Id: roqaudio.c,v 1.22 2004/01/12 17:35:18 miguelfreitas Exp $
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "xine_internal.h"
-#include "audio_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define RoQ_AUDIO_SAMPLE_RATE 22050
-#define RoQ_AUDIO_BITS_PER_SAMPLE 16
-
-#define AUDIOBUFSIZE 128*1024
-
-#define CLAMP_S16(x) if (x < -32768) x = -32768; \
- else if (x > 32767) x = 32767;
-#define SE_16BIT(x) if (x & 0x8000) x -= 0x10000;
-
-typedef struct {
- audio_decoder_class_t decoder_class;
-} roqaudio_class_t;
-
-typedef struct roqaudio_decoder_s {
- audio_decoder_t audio_decoder;
-
- xine_stream_t *stream;
-
- int64_t pts;
-
- int output_open;
- int output_channels;
-
- unsigned char *buf;
- int bufsize;
- int size;
-
- short square_array[256];
-} roqaudio_decoder_t;
-
-static void roqaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
- roqaudio_decoder_t *this = (roqaudio_decoder_t *) this_gen;
- audio_buffer_t *audio_buffer;
- int in, out;
- int predictor[2];
- int channel_number = 0;
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) {
- this->output_channels = buf->decoder_info[3];
-
- this->buf = xine_xmalloc(AUDIOBUFSIZE);
- this->bufsize = AUDIOBUFSIZE;
- this->size = 0;
-
- /* stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
- "RoQ DPCM Audio");
-
- return;
- }
-
- if (!this->output_open) {
- this->output_open = this->stream->audio_out->open(this->stream->audio_out,
- this->stream, RoQ_AUDIO_BITS_PER_SAMPLE, RoQ_AUDIO_SAMPLE_RATE,
- (this->output_channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO);
- }
-
- /* if the audio still isn't open, bail */
- if (!this->output_open)
- return;
-
- if( this->size + buf->size > this->bufsize ) {
- this->bufsize = this->size + 2 * buf->size;
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "RoQ: increasing source buffer to %d to avoid overflow.\n", this->bufsize);
- this->buf = realloc( this->buf, this->bufsize );
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) { /* time to decode a frame */
- audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
-
- out = 0;
-
- /* prepare the initial predictors */
- if (this->output_channels == 1)
- predictor[0] = LE_16(&this->buf[6]);
- else
- {
- predictor[0] = this->buf[7] << 8;
- predictor[1] = this->buf[6] << 8;
- }
- SE_16BIT(predictor[0]);
- SE_16BIT(predictor[1]);
-
- /* decode the samples */
- for (in = 8; in < this->size; in++)
- {
- predictor[channel_number] += this->square_array[this->buf[in]];
- CLAMP_S16(predictor[channel_number]);
- audio_buffer->mem[out++] = predictor[channel_number];
-
- /* toggle channel */
- channel_number ^= this->output_channels - 1;
- }
-
- audio_buffer->vpts = buf->pts;
- audio_buffer->num_frames =
- (buf->size - 8) / this->output_channels;
-
- this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
-
- this->size = 0;
- }
-}
-
-static void roqaudio_reset (audio_decoder_t *this_gen) {
-}
-
-static void roqaudio_discontinuity (audio_decoder_t *this_gen) {
-
- roqaudio_decoder_t *this = (roqaudio_decoder_t *) this_gen;
-
- this->pts = 0;
-}
-
-static void roqaudio_dispose (audio_decoder_t *this_gen) {
-
- roqaudio_decoder_t *this = (roqaudio_decoder_t *) this_gen;
-
- if (this->output_open)
- this->stream->audio_out->close (this->stream->audio_out, this->stream);
- this->output_open = 0;
-
- if (this->buf)
- free(this->buf);
-
- free (this_gen);
-}
-
-static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- roqaudio_decoder_t *this;
- int i;
- short square;
-
- this = (roqaudio_decoder_t *) xine_xmalloc (sizeof (roqaudio_decoder_t));
-
- this->audio_decoder.decode_data = roqaudio_decode_data;
- this->audio_decoder.reset = roqaudio_reset;
- this->audio_decoder.discontinuity = roqaudio_discontinuity;
- this->audio_decoder.dispose = roqaudio_dispose;
- this->size = 0;
-
- this->stream = stream;
-
- this->buf = NULL;
- this->output_open = 0;
- this->output_channels = 0;
-
- /* initialize tables of squares */
- for (i = 0; i < 128; i++) {
- square = i * i;
- this->square_array[i] = square;
- this->square_array[i + 128] = -square;
- }
-
- return &this->audio_decoder;
-}
-
-static char *get_identifier (audio_decoder_class_t *this) {
- return "RoQ Audio";
-}
-
-static char *get_description (audio_decoder_class_t *this) {
- return "Id Roq audio decoder plugin";
-}
-
-static void dispose_class (audio_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- roqaudio_class_t *this;
-
- this = (roqaudio_class_t *) xine_xmalloc (sizeof (roqaudio_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-static uint32_t audio_types[] = {
- BUF_AUDIO_ROQ, 0
-};
-
-static decoder_info_t dec_info_audio = {
- audio_types, /* supported types */
- 5 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_AUDIO_DECODER, 15, "roqaudio", XINE_VERSION_CODE, &dec_info_audio, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};