summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-07-30 18:40:46 +0200
committerwm4 <wm4@nowhere>2012-07-30 22:14:32 +0200
commit1fde09db6f4cee7347842261234082470dd3a2ca (patch)
treec05bf64b1b397a62e6f0b9cf295a6f9d0266eed2 /libmpcodecs
parent17b69493b70413326c95c3c552009626809b45ec (diff)
downloadmpv-1fde09db6f4cee7347842261234082470dd3a2ca.tar.bz2
mpv-1fde09db6f4cee7347842261234082470dd3a2ca.tar.xz
Remove some demuxers and decoders
Most of these demuxers and decoders are provided in better form by libav, while the mplayer builtin ones are essentially unmaintained. The only legimitate use case for not using the libav ones was working around libav bugs or bugs related to the way mplayer uses libav. Instead of trying to keep dead code alive, development effort should go into improving libav or the mplayer libav glue code. Note that the libav demuxer have been preferred over the mplayer builtin ones for a while in mplayer2. There were some exceptions: playing DVDs with dvdnav or playing network sources. (That's because some stream modules and network.c requested explicit file formats, such as DEMUXER_TYPE_MPEG_PS, which mapped to builtin demuxers.) With this commit, they are switched to use libav. One caveat is that the requested format is not passed to libavformat, instead we rely on the auto probing to select the correct libav demuxer (see code in demux_open_stream()).
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad.c16
-rw-r--r--libmpcodecs/ad_dk3adpcm.c262
-rw-r--r--libmpcodecs/ad_libvorbis.c350
-rw-r--r--libmpcodecs/ad_mpc.c231
-rw-r--r--libmpcodecs/ad_speex.c179
-rw-r--r--libmpcodecs/ad_twin.c523
-rw-r--r--libmpcodecs/dec_video.c1
-rw-r--r--libmpcodecs/vd.c12
-rw-r--r--libmpcodecs/vd_mpegpes.c84
-rw-r--r--libmpcodecs/vd_sgi.c343
-rw-r--r--libmpcodecs/vd_theora.c207
-rw-r--r--libmpcodecs/vd_xvid4.c393
12 files changed, 0 insertions, 2601 deletions
diff --git a/libmpcodecs/ad.c b/libmpcodecs/ad.c
index 0ab5d44971..dce8f9f710 100644
--- a/libmpcodecs/ad.c
+++ b/libmpcodecs/ad.c
@@ -41,20 +41,14 @@ extern const ad_functions_t mpcodecs_ad_dvdpcm;
extern const ad_functions_t mpcodecs_ad_alaw;
extern const ad_functions_t mpcodecs_ad_imaadpcm;
extern const ad_functions_t mpcodecs_ad_msadpcm;
-extern const ad_functions_t mpcodecs_ad_dk3adpcm;
-extern const ad_functions_t mpcodecs_ad_dk4adpcm;
extern const ad_functions_t mpcodecs_ad_dshow;
extern const ad_functions_t mpcodecs_ad_dmo;
extern const ad_functions_t mpcodecs_ad_acm;
extern const ad_functions_t mpcodecs_ad_faad;
-extern const ad_functions_t mpcodecs_ad_libvorbis;
-extern const ad_functions_t mpcodecs_ad_speex;
extern const ad_functions_t mpcodecs_ad_libmad;
extern const ad_functions_t mpcodecs_ad_realaud;
extern const ad_functions_t mpcodecs_ad_libdv;
extern const ad_functions_t mpcodecs_ad_qtaudio;
-extern const ad_functions_t mpcodecs_ad_twin;
-extern const ad_functions_t mpcodecs_ad_libmusepack;
extern const ad_functions_t mpcodecs_ad_libdca;
const ad_functions_t * const mpcodecs_ad_drivers[] =
@@ -73,7 +67,6 @@ const ad_functions_t * const mpcodecs_ad_drivers[] =
&mpcodecs_ad_alaw,
&mpcodecs_ad_imaadpcm,
&mpcodecs_ad_msadpcm,
- &mpcodecs_ad_dk3adpcm,
#ifdef CONFIG_WIN32DLL
&mpcodecs_ad_dshow,
&mpcodecs_ad_dmo,
@@ -86,12 +79,6 @@ const ad_functions_t * const mpcodecs_ad_drivers[] =
#ifdef CONFIG_FAAD
&mpcodecs_ad_faad,
#endif
-#ifdef CONFIG_OGGVORBIS
- &mpcodecs_ad_libvorbis,
-#endif
-#ifdef CONFIG_SPEEX
- &mpcodecs_ad_speex,
-#endif
#ifdef CONFIG_LIBMAD
&mpcodecs_ad_libmad,
#endif
@@ -101,9 +88,6 @@ const ad_functions_t * const mpcodecs_ad_drivers[] =
#ifdef CONFIG_LIBDV095
&mpcodecs_ad_libdv,
#endif
-#ifdef CONFIG_MUSEPACK
- &mpcodecs_ad_libmusepack,
-#endif
#ifdef CONFIG_LIBDCA
&mpcodecs_ad_libdca,
#endif
diff --git a/libmpcodecs/ad_dk3adpcm.c b/libmpcodecs/ad_dk3adpcm.c
deleted file mode 100644
index 15027f88b1..0000000000
--- a/libmpcodecs/ad_dk3adpcm.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * DK3 ADPCM decoder
- *
- * "This format number was used by Duck Corp. but not officially
- * registered with Microsoft"
- *
- * This file is responsible for decoding audio data encoded with
- * Duck Corp's DK3 ADPCM algorithm. Details about the data format
- * can be found here:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * Copyright (c) 2002 Mike Melanson
- *
- * This file is part of MPlayer.
- *
- * MPlayer 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.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <libavutil/intreadwrite.h>
-
-#include "config.h"
-#include "ad_internal.h"
-
-static const ad_info_t info =
-{
- "Duck Corp. DK3 ADPCM decoder",
- "dk3adpcm",
- "Nick Kurshev",
- "Mike Melanson",
- ""
-};
-
-LIBAD_EXTERN(dk3adpcm)
-
-#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;
-
-// pertinent tables
-static int 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 adpcm_index[16] =
-{
- -1, -1, -1, -1, 2, 4, 6, 8,
- -1, -1, -1, -1, 2, 4, 6, 8
-};
-
-static int preinit(sh_audio_t *sh_audio)
-{
- sh_audio->audio_out_minsize = sh_audio->wf->nBlockAlign * 6;
- sh_audio->ds->ss_div =
- (sh_audio->wf->nBlockAlign - DK3_ADPCM_PREAMBLE_SIZE) * 8 / 3;
- sh_audio->audio_in_minsize=
- sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign;
- return 1;
-}
-
-static int init(sh_audio_t *sh_audio)
-{
- sh_audio->channels = sh_audio->wf->nChannels;
- sh_audio->samplerate = sh_audio->wf->nSamplesPerSec;
- sh_audio->i_bps =
- (sh_audio->ds->ss_mul * sh_audio->samplerate) / sh_audio->ds->ss_div;
- sh_audio->samplesize=2;
- return 1;
-}
-
-static void uninit(sh_audio_t *sh_audio)
-{
-}
-
-static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...)
-{
- if(cmd==ADCTRL_SKIP_FRAME){
- demux_read_data(sh_audio->ds, sh_audio->a_in_buffer,sh_audio->ds->ss_mul);
- return CONTROL_TRUE;
- }
- return CONTROL_UNKNOWN;
-}
-
-#define DK3_GET_NEXT_NIBBLE() \
- if (decode_top_nibble_next) \
- { \
- nibble = (last_byte >> 4) & 0x0F; \
- decode_top_nibble_next = 0; \
- } \
- else \
- { \
- last_byte = input[in_ptr++]; \
- nibble = last_byte & 0x0F; \
- decode_top_nibble_next = 1; \
- }
-
-// note: This decoder assumes the format 0x62 data always comes in
-// stereo flavor
-static int dk3_adpcm_decode_block(unsigned short *output, unsigned char *input,
- int block_size)
-{
- int sum_pred;
- int diff_pred;
- int sum_index;
- int diff_index;
- int diff_channel;
- int in_ptr = 0x10;
- int out_ptr = 0;
-
- 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;
-
- sum_pred = AV_RL16(&input[10]);
- diff_pred = AV_RL16(&input[12]);
- SE_16BIT(sum_pred);
- SE_16BIT(diff_pred);
- diff_channel = diff_pred;
- sum_index = input[14];
- diff_index = input[15];
-
- while (in_ptr < block_size - !decode_top_nibble_next)
-// while (in_ptr < 2048)
- {
- // process the first predictor of the sum channel
- DK3_GET_NEXT_NIBBLE();
-
- step = 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 += adpcm_index[nibble];
- CLAMP_0_TO_88(sum_index);
-
- // process the diff channel predictor
- DK3_GET_NEXT_NIBBLE();
-
- step = 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 += adpcm_index[nibble];
- CLAMP_0_TO_88(diff_index);
-
- // output the first pair of stereo PCM samples
- diff_channel = (diff_channel + diff_pred) / 2;
- output[out_ptr++] = sum_pred + diff_channel;
- output[out_ptr++] = sum_pred - diff_channel;
-
- // process the second predictor of the sum channel
- DK3_GET_NEXT_NIBBLE();
-
- step = 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 += adpcm_index[nibble];
- CLAMP_0_TO_88(sum_index);
-
- // output the second pair of stereo PCM samples
- output[out_ptr++] = sum_pred + diff_channel;
- output[out_ptr++] = sum_pred - diff_channel;
- }
-
- return out_ptr;
-}
-
-static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
-{
- if (demux_read_data(sh_audio->ds, sh_audio->a_in_buffer,
- sh_audio->ds->ss_mul) !=
- sh_audio->ds->ss_mul)
- return -1; /* EOF */
-
- if (maxlen < 2 * 4 * sh_audio->wf->nBlockAlign * 2 / 3) {
- mp_msg(MSGT_DECAUDIO, MSGL_V, "dk3adpcm: maxlen too small in decode_audio\n");
- return -1;
- }
- return 2 * dk3_adpcm_decode_block(
- (unsigned short*)buf, sh_audio->a_in_buffer,
- sh_audio->ds->ss_mul);
-}
diff --git a/libmpcodecs/ad_libvorbis.c b/libmpcodecs/ad_libvorbis.c
deleted file mode 100644
index a768095187..0000000000
--- a/libmpcodecs/ad_libvorbis.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer 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.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <math.h>
-
-#include "config.h"
-#include "ad_internal.h"
-#include "libaf/reorder_ch.h"
-
-static const ad_info_t info =
-{
- "Ogg/Vorbis audio decoder",
-#ifdef CONFIG_TREMOR
- "tremor",
-#else
- "libvorbis",
-#endif
- "Felix Buenemann, A'rpi",
- "libvorbis",
- ""
-};
-
-LIBAD_EXTERN(libvorbis)
-
-#ifdef CONFIG_TREMOR
-#include <tremor/ivorbiscodec.h>
-#else
-#include <vorbis/codec.h>
-#endif
-
-// This struct is also defined in demux_ogg.c => common header ?
-typedef struct ov_struct_st {
- vorbis_info vi; /* struct that stores all the static vorbis bitstream
- settings */
- vorbis_comment vc; /* struct that stores all the bitstream user comments */
- vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
- vorbis_block vb; /* local working space for packet->PCM decode */
- float rg_scale; /* replaygain scale */
-#ifdef CONFIG_TREMOR
- int rg_scale_int;
-#endif
-} ov_struct_t;
-
-static int read_vorbis_comment( char* ptr, const char* comment, const char* format, ... ) {
- va_list va;
- int clen, ret;
-
- va_start( va, format );
- clen = strlen( comment );
- ret = strncasecmp( ptr, comment, clen) == 0 ? vsscanf( ptr+clen, format, va ) : 0;
- va_end( va );
-
- return ret;
-}
-
-static int preinit(sh_audio_t *sh)
-{
- sh->audio_out_minsize=1024*4; // 1024 samples/frame
- return 1;
-}
-
-static int init(sh_audio_t *sh)
-{
- unsigned int offset, i, length, hsizes[3];
- void *headers[3];
- unsigned char* extradata;
- ogg_packet op;
- vorbis_comment vc;
- struct ov_struct_st *ov;
-#define ERROR() { \
- vorbis_comment_clear(&vc); \
- vorbis_info_clear(&ov->vi); \
- free(ov); \
- return 0; \
- }
-
- /// Init the decoder with the 3 header packets
- ov = malloc(sizeof(struct ov_struct_st));
- vorbis_info_init(&ov->vi);
- vorbis_comment_init(&vc);
-
- if(! sh->wf) {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ad_vorbis, extradata seems to be absent! exit\n");
- ERROR();
- }
-
- if(! sh->wf->cbSize) {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ad_vorbis, extradata seems to be absent!, exit\n");
- ERROR();
- }
-
- mp_msg(MSGT_DECAUDIO,MSGL_V,"ad_vorbis, extradata seems is %d bytes long\n", sh->wf->cbSize);
- extradata = (char*) (sh->wf+1);
- if(!extradata) {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ad_vorbis, extradata seems to be NULL!, exit\n");
- ERROR();
- }
-
- if(*extradata != 2) {
- mp_msg (MSGT_DEMUX, MSGL_WARN, "ad_vorbis: Vorbis track does not contain valid headers.\n");
- ERROR();
- }
-
- offset = 1;
- for (i=0; i < 2; i++) {
- length = 0;
- while ((extradata[offset] == (unsigned char) 0xFF) && length < sh->wf->cbSize) {
- length += 255;
- offset++;
- }
- if(offset >= (sh->wf->cbSize - 1)) {
- mp_msg (MSGT_DEMUX, MSGL_WARN, "ad_vorbis: Vorbis track does not contain valid headers.\n");
- ERROR();
- }
- length += extradata[offset];
- offset++;
- mp_msg (MSGT_DEMUX, MSGL_V, "ad_vorbis, offset: %u, length: %u\n", offset, length);
- hsizes[i] = length;
- }
-
- headers[0] = &extradata[offset];
- headers[1] = &extradata[offset + hsizes[0]];
- headers[2] = &extradata[offset + hsizes[0] + hsizes[1]];
- hsizes[2] = sh->wf->cbSize - offset - hsizes[0] - hsizes[1];
- mp_msg (MSGT_DEMUX, MSGL_V, "ad_vorbis, header sizes: %d %d %d\n", hsizes[0], hsizes[1], hsizes[2]);
-
- for(i=0; i<3; i++) {
- op.bytes = hsizes[i];
- op.packet = headers[i];
- op.b_o_s = (i == 0);
- if(vorbis_synthesis_headerin(&ov->vi,&vc,&op) <0) {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"OggVorbis: header n. %d broken! len=%ld\n", i, op.bytes);
- ERROR();
- }
- if(i == 2) {
- float rg_gain=0.f, rg_peak=0.f;
- char **ptr=vc.user_comments;
- while(*ptr){
- mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbisComment: %s\n",*ptr);
- /* replaygain */
- read_vorbis_comment( *ptr, "replaygain_album_gain=", "%f", &rg_gain );
- read_vorbis_comment( *ptr, "rg_audiophile=", "%f", &rg_gain );
- if( !rg_gain ) {
- read_vorbis_comment( *ptr, "replaygain_track_gain=", "%f", &rg_gain );
- read_vorbis_comment( *ptr, "rg_radio=", "%f", &rg_gain );
- }
- read_vorbis_comment( *ptr, "replaygain_album_peak=", "%f", &rg_peak );
- if( !rg_peak ) {
- read_vorbis_comment( *ptr, "replaygain_track_peak=", "%f", &rg_peak );
- read_vorbis_comment( *ptr, "rg_peak=", "%f", &rg_peak );
- }
- ++ptr;
- }
- /* replaygain: scale */
- if(!rg_gain)
- ov->rg_scale = 1.f; /* just in case pow() isn't standard-conformant */
- else
- ov->rg_scale = pow(10.f, rg_gain/20);
- /* replaygain: anticlip */
- if(ov->rg_scale * rg_peak > 1.f)
- ov->rg_scale = 1.f / rg_peak;
- /* replaygain: security */
- if(ov->rg_scale > 15.)
- ov->rg_scale = 15.;
-#ifdef CONFIG_TREMOR
- ov->rg_scale_int = (int)(ov->rg_scale*64.f);
-#endif
- mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Bitstream is %d channel%s, %dHz, %dbit/s %cBR\n",(int)ov->vi.channels,ov->vi.channels>1?"s":"",(int)ov->vi.rate,(int)ov->vi.bitrate_nominal,
- (ov->vi.bitrate_lower!=ov->vi.bitrate_nominal)||(ov->vi.bitrate_upper!=ov->vi.bitrate_nominal)?'V':'C');
- if(rg_gain || rg_peak)
- mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Gain = %+.2f dB, Peak = %.4f, Scale = %.2f\n", rg_gain, rg_peak, ov->rg_scale);
- mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Encoded by: %s\n",vc.vendor);
- }
- }
-
- vorbis_comment_clear(&vc);
-
-// printf("lower=%d upper=%d \n",(int)ov->vi.bitrate_lower,(int)ov->vi.bitrate_upper);
-
- // Setup the decoder
- sh->channels=ov->vi.channels;
- sh->samplerate=ov->vi.rate;
- sh->samplesize=2;
- // assume 128kbit if bitrate not specified in the header
- sh->i_bps=((ov->vi.bitrate_nominal>0) ? ov->vi.bitrate_nominal : 128000)/8;
- sh->context = ov;
-
- /// Finish the decoder init
- vorbis_synthesis_init(&ov->vd,&ov->vi);
- vorbis_block_init(&ov->vd,&ov->vb);
- mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Init OK!\n");
-
- return 1;
-}
-
-static void uninit(sh_audio_t *sh)
-{
- struct ov_struct_st *ov = sh->context;
- vorbis_dsp_clear(&ov->vd);
- vorbis_block_clear(&ov->vb);
- vorbis_info_clear(&ov->vi);
- free(ov);
-}
-
-static int control(sh_audio_t *sh,int cmd,void* arg, ...)
-{
- switch(cmd)
- {
-#if 0
- case ADCTRL_RESYNC_STREAM:
- return CONTROL_TRUE;
- case ADCTRL_SKIP_FRAME:
- return CONTROL_TRUE;
-#endif
- }
- return CONTROL_UNKNOWN;
-}
-
-static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen)
-{
- int len = 0;
- int samples;
-#ifdef CONFIG_TREMOR
- ogg_int32_t **pcm;
-#else
- float scale;
- float **pcm;
-#endif
- struct ov_struct_st *ov = sh->context;
- while(len < minlen) {
- while((samples=vorbis_synthesis_pcmout(&ov->vd,&pcm))<=0){
- ogg_packet op;
- double pts;
- memset(&op,0,sizeof(op)); //op.b_o_s = op.e_o_s = 0;
- op.bytes = ds_get_packet_pts(sh->ds,&op.packet, &pts);
- if(op.bytes<=0) break;
- if (pts != MP_NOPTS_VALUE) {
- sh->pts = pts;
- sh->pts_bytes = 0;
- }
- if(vorbis_synthesis(&ov->vb,&op)==0) /* test for success! */
- vorbis_synthesis_blockin(&ov->vd,&ov->vb);
- }
- if(samples<=0) break; // error/EOF
- while(samples>0){
- int i,j;
- int clipflag=0;
- int convsize=(maxlen-len)/(2*ov->vi.channels); // max size!
- int bout=((samples<convsize)?samples:convsize);
-
- if(bout<=0) break; // no buffer space
-
- /* convert floats to 16 bit signed ints (host order) and
- interleave */
-#ifdef CONFIG_TREMOR
- if (ov->rg_scale_int == 64) {
- for(i=0;i<ov->vi.channels;i++){
- ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]);
- ogg_int16_t *ptr=convbuffer+i;
- ogg_int32_t *mono=pcm[i];
- for(j=0;j<bout;j++){
- int val=mono[j]>>9;
- /* might as well guard against clipping */
- if(val>32767){
- val=32767;
- clipflag=1;
- }
- if(val<-32768){
- val=-32768;
- clipflag=1;
- }
- *ptr=val;
- ptr+=ov->vi.channels;
- }
- }
- } else
-#endif /* CONFIG_TREMOR */
- {
-#ifndef CONFIG_TREMOR
- scale = 32767.f * ov->rg_scale;
-#endif
- for(i=0;i<ov->vi.channels;i++){
- ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]);
- ogg_int16_t *ptr=convbuffer+i;
-#ifdef CONFIG_TREMOR
- ogg_int32_t *mono=pcm[i];
- for(j=0;j<bout;j++){
- int val=(mono[j]*ov->rg_scale_int)>>(9+6);
-#else
- float *mono=pcm[i];
- for(j=0;j<bout;j++){
- int val=mono[j]*scale;
- /* might as well guard against clipping */
- if(val>32767){
- val=32767;
- clipflag=1;
- }
- if(val<-32768){
- val=-32768;
- clipflag=1;
- }
-#endif /* CONFIG_TREMOR */
- *ptr=val;
- ptr+=ov->vi.channels;
- }
- }
- }
-
- if(clipflag)
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"Clipping in frame %ld\n",(long)(ov->vd.sequence));
- len+=2*ov->vi.channels*bout;
- sh->pts_bytes += 2*ov->vi.channels*bout;
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"\n[decoded: %d / %d ]\n",bout,samples);
- samples-=bout;
- vorbis_synthesis_read(&ov->vd,bout); /* tell libvorbis how
- many samples we
- actually consumed */
- } //while(samples>0)
-// if (!samples) break; // why? how?
- }
-
- if (len > 0 && ov->vi.channels >= 5) {
- reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_VORBIS_DEFAULT,
- AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
- ov->vi.channels, len / sh->samplesize,
- sh->samplesize);
- }
-
-
- return len;
-}
diff --git a/libmpcodecs/ad_mpc.c b/libmpcodecs/ad_mpc.c
deleted file mode 100644
index 979dce6178..0000000000
--- a/libmpcodecs/ad_mpc.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Musepack audio files decoder for MPlayer
- * by Reza Jelveh <reza.jelveh@tuhh.de> and
- * Reimar Döffinger <Reimar.Doeffinger@stud.uni-karlsruhe.de>
- *
- * This code may be be relicensed under the terms of the GNU LGPL when it
- * becomes part of the FFmpeg project (ffmpeg.org)
- *
- * This file is part of MPlayer.
- *
- * MPlayer 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.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "config.h"
-#include "ad_internal.h"
-#include "libaf/af_format.h"
-#include "libvo/fastmemcpy.h"
-
-static const ad_info_t info =
-{
- "Musepack audio decoder",
- "mpcdec",
- "Reza Jelveh and Reimar Döffinger",
- "",
- ""
-};
-
-LIBAD_EXTERN(libmusepack)
-
-#include <mpcdec/mpcdec.h>
-
-// BUFFER_LENGTH is in MPC_SAMPLE_FORMAT units
-#define MAX_FRAMESIZE (4 * MPC_DECODER_BUFFER_LENGTH)
-//! this many frames should decode good after seeking
-#define MIN_SEEK_GOOD 5
-//! how many frames to discard at most after seeking
-#define MAX_SEEK_DISCARD 50
-
-typedef struct context_s {
- char *header;
- int header_len;
- sh_audio_t *sh;
- uint32_t pos;
- mpc_decoder decoder;
-} context_t;
-
-/**
- * \brief mpc_reader callback function for reading the header
- */
-static mpc_int32_t cb_read(void *data, void *buf, mpc_int32_t size) {
- context_t *d = (context_t *)data;
- char *p = (char *)buf;
- int s = size;
- if (d->pos < d->header_len) {
- if (s > d->header_len - d->pos)
- s = d->header_len - d->pos;
- fast_memcpy(p, &d->header[d->pos], s);
- } else
- s = 0;
- memset(&p[s], 0, size - s);
- d->pos += size;
- return size;
-}
-
-/**
- * \brief dummy mpc_reader callback function for seeking
- */
-static mpc_bool_t cb_seek(void *data, mpc_int32_t offset ) {
- context_t *d = (context_t *)data;
- d->pos = offset;
- return 1;
-}
-
-/**
- * \brief dummy mpc_reader callback function for getting stream position
- */
-static mpc_int32_t cb_tell(void *data) {
- context_t *d = (context_t *)data;
- return d->pos;
-}
-
-/**
- * \brief dummy mpc_reader callback function for getting stream length
- */
-static mpc_int32_t cb_get_size(void *data) {
- return 1 << 30;
-}
-
-/**
- * \brief mpc_reader callback function, we cannot seek.
- */
-static mpc_bool_t cb_canseek(void *data) {
- return 0;
-}
-
-
-mpc_reader header_reader = {
- .read = cb_read, .seek = cb_seek, .tell = cb_tell,
- .get_size = cb_get_size, .canseek = cb_canseek
-};
-
-static int preinit(sh_audio_t *sh) {
- sh->audio_out_minsize = MAX_FRAMESIZE;
- return 1;
-}
-
-static void uninit(sh_audio_t *sh) {
- free(sh->context);
- sh->context = NULL;
-}
-
-static int init(sh_audio_t *sh) {
- mpc_streaminfo info;
- context_t *cd = malloc(sizeof(context_t));
-
- if (!sh->wf || (sh->wf->cbSize < 6 * 4)) {
- mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Missing extradata!\n");
- return 0;
- }
- cd->header = (char *)(sh->wf + 1);
- cd->header_len = sh->wf->cbSize;
- cd->sh = sh;
- cd->pos = 0;
- sh->context = (char *)cd;
-
- /* read file's streaminfo data */
- mpc_streaminfo_init(&info);
- header_reader.data = cd;
- if (mpc_streaminfo_read(&info, &header_reader) != ERROR_CODE_OK) {
- mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Not a valid musepack file.\n");
- return 0;
- }
-// this value is nonsense, since it relies on the get_size function.
-// use the value from the demuxer instead.
-// sh->i_bps = info.average_bitrate / 8;
- sh->channels = info.channels;
- sh->samplerate = info.sample_freq;
- sh->samplesize = 4;
- sh->sample_format =
-#if MPC_SAMPLE_FORMAT == float
- AF_FORMAT_FLOAT_NE;
-#elif MPC_SAMPLE_FORMAT == mpc_int32_t
- AF_FORMAT_S32_NE;
-#else
- #error musepack lib must use either float or mpc_int32_t sample format
-#endif
-
- mpc_decoder_setup(&cd->decoder, NULL);
- mpc_decoder_set_streaminfo(&cd->decoder, &info);
- return 1;
-}
-
-// FIXME: minlen is currently ignored
-static int decode_audio(sh_audio_t *sh, unsigned char *buf,
- int minlen, int maxlen) {
- int status, len;
- MPC_SAMPLE_FORMAT *sample_buffer = (MPC_SAMPLE_FORMAT *)buf;
- mpc_uint32_t *packet = NULL;
-
- context_t *cd = (context_t *) sh->context;
- if (maxlen < MAX_FRAMESIZE) {
- mp_msg(MSGT_DECAUDIO, MSGL_V, "maxlen too small in decode_audio\n");
- return -1;
- }
- len = ds_get_packet(sh->ds, (unsigned char **)&packet);
- if (len <= 0) return -1;
- status = mpc_decoder_decode_frame(&cd->decoder, packet, len, sample_buffer);
- if (status == -1) // decode error
- mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Error decoding file.\n");
- if (status <= 0) // error or EOF
- return -1;
-
- status = MPC_FRAME_LENGTH * sh->channels; // one sample per channel
-#if MPC_SAMPLE_FORMAT == float || MPC_SAMPLE_FORMAT == mpc_int32_t
- status *= 4;
-#else
- // should not happen
- status *= 2;
-#endif
- return status;
-}
-
-/**
- * \brief check if the decoded values are in a sane range
- * \param buf decoded buffer
- * \param len length of buffer in bytes
- * \return 1 if all values are in (-1.01, 1.01) range, 0 otherwise
- */
-static int check_clip(void *buf, int len) {
-#if MPC_SAMPLE_FORMAT == float
- float *p = buf;
- if (len < 4) return 1;
- len = -len / 4;
- p = &p[-len];
- do {
- if (p[len] < -1 || p[len] > 1) return 0;
- } while (++len);
-#endif
- return 1;
-}
-
-static int control(sh_audio_t *sh, int cmd, void* arg, ...) {
- if (cmd == ADCTRL_RESYNC_STREAM) {
- unsigned char *buf = malloc(MAX_FRAMESIZE);
- int i;
- int nr_ok = 0;
- for (i = 0; i < MAX_SEEK_DISCARD; i++) {
- int len = decode_audio(sh, buf, 0, MAX_FRAMESIZE);
- if (check_clip(buf, len)) nr_ok++; else nr_ok = 0;
- if (nr_ok > MIN_SEEK_GOOD) break;
- }
- free(buf);
- }
- return CONTROL_UNKNOWN;
-}
diff --git a/libmpcodecs/ad_speex.c b/libmpcodecs/ad_speex.c
deleted file mode 100644
index c9ac1a42c6..0000000000
--- a/libmpcodecs/ad_speex.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Speex decoder by Reimar Döffinger <Reimar.Doeffinger@stud.uni-karlsruhe.de>
- *
- * This code may be be relicensed under the terms of the GNU LGPL when it
- * becomes part of the FFmpeg project (ffmpeg.org)
- *
- * This file is part of MPlayer.
- *
- * MPlayer 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.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <speex/speex.h>
-#include <speex/speex_stereo.h>
-#include <speex/speex_header.h>
-#include "ad_internal.h"
-
-static const ad_info_t info = {
- "Speex audio decoder",
- "speex",
- "Reimar Döffinger",
- "",
- ""
-};
-
-LIBAD_EXTERN(speex)
-
-typedef struct {
- SpeexBits bits;
- void *dec_context;
- SpeexStereoState stereo;
- SpeexHeader *hdr;
-} context_t;
-
-#define MAX_FRAMES_PER_PACKET 100
-
-static int preinit(sh_audio_t *sh) {
- sh->audio_out_minsize = 2 * 320 * MAX_FRAMES_PER_PACKET * 2 * sizeof(short);
- return 1;
-}
-
-static int read_le32(const uint8_t **src) {
- const uint8_t *p = *src;
- *src += 4;
- return p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24);
-}
-
-static int init(sh_audio_t *sh) {
- context_t *ctx = calloc(1, sizeof(context_t));