summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-18 11:17:35 +0200
committerwm4 <wm4@nowhere>2012-08-20 15:36:04 +0200
commit6a26b4a66504f701baf35e58467e55aea28c0ad5 (patch)
tree8b09b91d63926543eaa8ec95c90a2532bde71dd6 /libmpcodecs
parent6f7ba66817b5cd3761b802930dc7ba62464e3c6a (diff)
downloadmpv-6a26b4a66504f701baf35e58467e55aea28c0ad5.tar.bz2
mpv-6a26b4a66504f701baf35e58467e55aea28c0ad5.tar.xz
libmpcodecs: remove redundant audio and video decoders
Probably all of these are supported by libavcodec. Missing things can be added back. Also remove qtpalette.h. It was used by demux_mov.c, and should have been deleted with commit 1fde09db6f4ce.
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad.c28
-rw-r--r--libmpcodecs/ad_alaw.c93
-rw-r--r--libmpcodecs/ad_dvdpcm.c162
-rw-r--r--libmpcodecs/ad_faad.c324
-rw-r--r--libmpcodecs/ad_hwac3.c577
-rw-r--r--libmpcodecs/ad_hwmpa.c166
-rw-r--r--libmpcodecs/ad_imaadpcm.c340
-rw-r--r--libmpcodecs/ad_liba52.c339
-rw-r--r--libmpcodecs/ad_libdca.c353
-rw-r--r--libmpcodecs/ad_libmad.c187
-rw-r--r--libmpcodecs/ad_msadpcm.c237
-rw-r--r--libmpcodecs/ad_pcm.c214
-rw-r--r--libmpcodecs/ad_sample.c145
-rw-r--r--libmpcodecs/native/alaw.h76
-rw-r--r--libmpcodecs/vd.c20
-rw-r--r--libmpcodecs/vd_hmblck.c151
-rw-r--r--libmpcodecs/vd_ijpg.c197
-rw-r--r--libmpcodecs/vd_lzo.c166
-rw-r--r--libmpcodecs/vd_mpng.c182
-rw-r--r--libmpcodecs/vd_mtga.c252
-rw-r--r--libmpcodecs/vd_raw.c142
21 files changed, 0 insertions, 4351 deletions
diff --git a/libmpcodecs/ad.c b/libmpcodecs/ad.c
index 0c56f0d546..aea9badadf 100644
--- a/libmpcodecs/ad.c
+++ b/libmpcodecs/ad.c
@@ -33,42 +33,14 @@
extern const ad_functions_t mpcodecs_ad_mpg123;
extern const ad_functions_t mpcodecs_ad_ffmpeg;
-extern const ad_functions_t mpcodecs_ad_liba52;
-extern const ad_functions_t mpcodecs_ad_hwac3;
-extern const ad_functions_t mpcodecs_ad_hwmpa;
-extern const ad_functions_t mpcodecs_ad_pcm;
-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_faad;
-extern const ad_functions_t mpcodecs_ad_libmad;
extern const ad_functions_t mpcodecs_ad_spdif;
-extern const ad_functions_t mpcodecs_ad_libdca;
const ad_functions_t * const mpcodecs_ad_drivers[] =
{
#ifdef CONFIG_MPG123
&mpcodecs_ad_mpg123,
#endif
-#ifdef CONFIG_LIBA52
- &mpcodecs_ad_liba52,
-#endif
- &mpcodecs_ad_hwac3,
- &mpcodecs_ad_hwmpa,
&mpcodecs_ad_ffmpeg,
&mpcodecs_ad_spdif,
- &mpcodecs_ad_pcm,
- &mpcodecs_ad_dvdpcm,
- &mpcodecs_ad_alaw,
- &mpcodecs_ad_imaadpcm,
-#ifdef CONFIG_FAAD
- &mpcodecs_ad_faad,
-#endif
-#ifdef CONFIG_LIBMAD
- &mpcodecs_ad_libmad,
-#endif
-#ifdef CONFIG_LIBDCA
- &mpcodecs_ad_libdca,
-#endif
NULL
};
diff --git a/libmpcodecs/ad_alaw.c b/libmpcodecs/ad_alaw.c
deleted file mode 100644
index 4a8f3849cf..0000000000
--- a/libmpcodecs/ad_alaw.c
+++ /dev/null
@@ -1,93 +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 "config.h"
-#include "ad_internal.h"
-
-static const ad_info_t info =
-{
- "aLaw/uLaw audio decoder",
- "alaw",
- "Nick Kurshev",
- "A'rpi",
- ""
-};
-
-LIBAD_EXTERN(alaw)
-
-#include "native/alaw.h"
-
-static int init(sh_audio_t *sh_audio)
-{
- /* aLaw audio codec:*/
- if(!sh_audio->wf) return 0;
- sh_audio->channels=sh_audio->wf->nChannels;
- sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
- sh_audio->i_bps=sh_audio->channels*sh_audio->samplerate;
- sh_audio->samplesize=2;
- return 1;
-}
-
-static int preinit(sh_audio_t *sh)
-{
- sh->audio_out_minsize=2048;
- sh->ds->ss_div = 1; // 1 samples/packet
- sh->ds->ss_mul = sh->wf->nChannels; // bytes/packet
- return 1;
-}
-
-static void uninit(sh_audio_t *sh)
-{
-}
-
-static int control(sh_audio_t *sh,int cmd,void* arg, ...)
-{
- int skip;
- switch(cmd)
- {
- case ADCTRL_SKIP_FRAME:
- skip=sh->i_bps/16;
- skip=skip&(~3);
- demux_read_data(sh->ds,NULL,skip);
- return CONTROL_TRUE;
- default:
- return CONTROL_UNKNOWN;
- }
- return CONTROL_UNKNOWN;
-}
-
-static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
-{
- int len;
- int l=demux_read_data(sh_audio->ds,buf,minlen/2);
- unsigned short *d=(unsigned short *) buf;
- unsigned char *s=buf;
- len=2*l;
- if(sh_audio->format==6 || sh_audio->format==0x77616C61){
- /* aLaw */
- while(l>0){ --l; d[l]=alaw2short[s[l]]; }
- } else {
- /* uLaw */
- while(l>0){ --l; d[l]=ulaw2short[s[l]]; }
- }
- return len;
-}
diff --git a/libmpcodecs/ad_dvdpcm.c b/libmpcodecs/ad_dvdpcm.c
deleted file mode 100644
index 41f6a1426d..0000000000
--- a/libmpcodecs/ad_dvdpcm.c
+++ /dev/null
@@ -1,162 +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 "config.h"
-#include "mp_msg.h"
-#include "ad_internal.h"
-
-static const ad_info_t info =
-{
- "Uncompressed DVD/VOB LPCM audio decoder",
- "dvdpcm",
- "Nick Kurshev",
- "A'rpi",
- ""
-};
-
-LIBAD_EXTERN(dvdpcm)
-
-static int init(sh_audio_t *sh)
-{
-/* DVD PCM Audio:*/
- sh->i_bps = 0;
- if(sh->codecdata_len==3){
- // we have LPCM header:
- unsigned char h=sh->codecdata[1];
- sh->channels=1+(h&7);
- switch((h>>4)&3){
- case 0: sh->samplerate=48000;break;
- case 1: sh->samplerate=96000;break;
- case 2: sh->samplerate=44100;break;
- case 3: sh->samplerate=32000;break;
- }
- switch ((h >> 6) & 3) {
- case 0:
- sh->sample_format = AF_FORMAT_S16_BE;
- sh->samplesize = 2;
- break;
- case 1:
- mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Samples of this format are needed to improve support. Please contact the developers.\n");
- sh->i_bps = sh->channels * sh->samplerate * 5 / 2;
- case 2:
- sh->sample_format = AF_FORMAT_S24_BE;
- sh->samplesize = 3;
- break;
- default:
- sh->sample_format = AF_FORMAT_S16_BE;
- sh->samplesize = 2;
- }
- } else {
- // use defaults:
- sh->channels=2;
- sh->samplerate=48000;
- sh->sample_format = AF_FORMAT_S16_BE;
- sh->samplesize = 2;
- }
- if (!sh->i_bps)
- sh->i_bps = sh->samplesize * sh->channels * sh->samplerate;
- return 1;
-}
-
-static int preinit(sh_audio_t *sh)
-{
- sh->audio_out_minsize=2048;
- return 1;
-}
-
-static void uninit(sh_audio_t *sh)
-{
-}
-
-static int control(sh_audio_t *sh,int cmd,void* arg, ...)
-{
- int skip;
- switch(cmd)
- {
- case ADCTRL_SKIP_FRAME:
- skip=sh->i_bps/16;
- skip=skip&(~3);
- demux_read_data(sh->ds,NULL,skip);
- return CONTROL_TRUE;
- }
- return CONTROL_UNKNOWN;
-}
-
-static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
-{
- int j,len;
- if (sh_audio->samplesize == 3) {
- if (((sh_audio->codecdata[1] >> 6) & 3) == 1) {
- // 20 bit
- // not sure if the "& 0xf0" and "<< 4" are the right way around
- // can somebody clarify?
- for (j = 0; j < minlen; j += 12) {
- char tmp[10];
- len = demux_read_data(sh_audio->ds, tmp, 10);
- if (len < 10) break;
- // first sample
- buf[j + 0] = tmp[0];
- buf[j + 1] = tmp[1];
- buf[j + 2] = tmp[8] & 0xf0;
- // second sample
- buf[j + 3] = tmp[2];
- buf[j + 4] = tmp[3];
- buf[j + 5] = tmp[8] << 4;
- // third sample
- buf[j + 6] = tmp[4];
- buf[j + 7] = tmp[5];
- buf[j + 8] = tmp[9] & 0xf0;
- // fourth sample
- buf[j + 9] = tmp[6];
- buf[j + 10] = tmp[7];
- buf[j + 11] = tmp[9] << 4;
- }
- len = j;
- } else {
- // 24 bit
- for (j = 0; j < minlen; j += 12) {
- char tmp[12];
- len = demux_read_data(sh_audio->ds, tmp, 12);
- if (len < 12) break;
- // first sample
- buf[j + 0] = tmp[0];
- buf[j + 1] = tmp[1];
- buf[j + 2] = tmp[8];
- // second sample
- buf[j + 3] = tmp[2];
- buf[j + 4] = tmp[3];
- buf[j + 5] = tmp[9];
- // third sample
- buf[j + 6] = tmp[4];
- buf[j + 7] = tmp[5];
- buf[j + 8] = tmp[10];
- // fourth sample
- buf[j + 9] = tmp[6];
- buf[j + 10] = tmp[7];
- buf[j + 11] = tmp[11];
- }
- len = j;
- }
- } else
- len=demux_read_data(sh_audio->ds,buf,(minlen+3)&(~3));
- return len;
-}
diff --git a/libmpcodecs/ad_faad.c b/libmpcodecs/ad_faad.c
deleted file mode 100644
index d750f2ff30..0000000000
--- a/libmpcodecs/ad_faad.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * MPlayer AAC decoder using libfaad2
- *
- * Copyright (C) 2002 Felix Buenemann <atmosfear at users.sourceforge.net>
- *
- * 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 <neaacdec.h>
-
-#include "config.h"
-#include "options.h"
-#include "ad_internal.h"
-#include "libaf/reorder_ch.h"
-
-static const ad_info_t info =
-{
- "AAC (MPEG2/4 Advanced Audio Coding)",
- "faad",
- "Felix Buenemann",
- "faad2",
- "uses libfaad2"
-};
-
-LIBAD_EXTERN(faad)
-
-/* configure maximum supported channels, *
- * this is theoretically max. 64 chans */
-#define FAAD_MAX_CHANNELS 8
-#define FAAD_BUFFLEN (FAAD_MIN_STREAMSIZE*FAAD_MAX_CHANNELS)
-
-//#define AAC_DUMP_COMPRESSED
-
-static faacDecHandle faac_hdec;
-static faacDecFrameInfo faac_finfo;
-
-static int preinit(sh_audio_t *sh)
-{
- sh->audio_out_minsize=8192*FAAD_MAX_CHANNELS;
- sh->audio_in_minsize=FAAD_BUFFLEN;
- return 1;
-}
-
-static int aac_probe(unsigned char *buffer, int len)
-{
- int i = 0, pos = 0;
- mp_msg(MSGT_DECAUDIO,MSGL_V, "\nAAC_PROBE: %d bytes\n", len);
- while(i <= len-4) {
- if(
- ((buffer[i] == 0xff) && ((buffer[i+1] & 0xf6) == 0xf0)) ||
- (buffer[i] == 'A' && buffer[i+1] == 'D' && buffer[i+2] == 'I' && buffer[i+3] == 'F')
- ) {
- pos = i;
- break;
- }
- mp_msg(MSGT_DECAUDIO,MSGL_V, "AUDIO PAYLOAD: %x %x %x %x\n", buffer[i], buffer[i+1], buffer[i+2], buffer[i+3]);
- i++;
- }
- mp_msg(MSGT_DECAUDIO,MSGL_V, "\nAAC_PROBE: ret %d\n", pos);
- return pos;
-}
-
-static int init(sh_audio_t *sh)
-{
- struct MPOpts *opts = sh->opts;
- unsigned long faac_samplerate;
- unsigned char faac_channels;
- int faac_init, pos = 0;
- faac_hdec = faacDecOpen();
-
- // If we don't get the ES descriptor, try manual config
- if(!sh->codecdata_len && sh->wf) {
- sh->codecdata_len = sh->wf->cbSize;
- sh->codecdata = malloc(sh->codecdata_len);
- memcpy(sh->codecdata, sh->wf+1, sh->codecdata_len);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FAAD: codecdata extracted from WAVEFORMATEX\n");
- }
- if(!sh->codecdata_len || sh->format == mmioFOURCC('M', 'P', '4', 'L')) {
- faacDecConfigurationPtr faac_conf;
- /* Set the default object type and samplerate */
- /* This is useful for RAW AAC files */
- faac_conf = faacDecGetCurrentConfiguration(faac_hdec);
- if(sh->samplerate)
- faac_conf->defSampleRate = sh->samplerate;
- /* XXX: FAAD support FLOAT output, how do we handle
- * that (FAAD_FMT_FLOAT)? ::atmos
- */
- if (opts->audio_output_channels <= 2)
- faac_conf->downMatrix = 1;
- switch(sh->samplesize){
- case 1: // 8Bit
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: 8Bit samplesize not supported by FAAD, assuming 16Bit!\n");
- default:
- sh->samplesize=2;
- case 2: // 16Bit
- faac_conf->outputFormat = FAAD_FMT_16BIT;
- break;
- case 3: // 24Bit
- faac_conf->outputFormat = FAAD_FMT_24BIT;
- break;
- case 4: // 32Bit
- faac_conf->outputFormat = FAAD_FMT_32BIT;
- break;
- }
- //faac_conf->defObjectType = LTP; // => MAIN, LC, SSR, LTP available.
-
- faacDecSetConfiguration(faac_hdec, faac_conf);
-
- sh->a_in_buffer_len = demux_read_data(sh->ds, sh->a_in_buffer, sh->a_in_buffer_size);
- if (!sh->a_in_buffer_len) {
- // faad init will crash with 0 buffer length
- mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Could not get audio data!\n");
- return 0;
- }
- /* external faad does not have latm lookup support */
- faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
- sh->a_in_buffer_len, &faac_samplerate, &faac_channels);
-
- if (faac_init < 0) {
- pos = aac_probe(sh->a_in_buffer, sh->a_in_buffer_len);
- if(pos) {
- sh->a_in_buffer_len -= pos;
- memmove(sh->a_in_buffer, &(sh->a_in_buffer[pos]), sh->a_in_buffer_len);
- sh->a_in_buffer_len +=
- demux_read_data(sh->ds,&(sh->a_in_buffer[sh->a_in_buffer_len]),
- sh->a_in_buffer_size - sh->a_in_buffer_len);
- pos = 0;
- }
-
- /* init the codec */
- faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
- sh->a_in_buffer_len, &faac_samplerate, &faac_channels);
- }
-
- sh->a_in_buffer_len -= (faac_init > 0)?faac_init:0; // how many bytes init consumed
- // XXX FIXME: shouldn't we memcpy() here in a_in_buffer ?? --A'rpi
-
- } else { // We have ES DS in codecdata
- faacDecConfigurationPtr faac_conf = faacDecGetCurrentConfiguration(faac_hdec);
- if (opts->audio_output_channels <= 2) {
- faac_conf->downMatrix = 1;
- faacDecSetConfiguration(faac_hdec, faac_conf);
- }
-
- /*int i;
- for(i = 0; i < sh_audio->codecdata_len; i++)
- printf("codecdata_dump %d: 0x%02X\n", i, sh_audio->codecdata[i]);*/
-
- faac_init = faacDecInit2(faac_hdec, sh->codecdata,
- sh->codecdata_len, &faac_samplerate, &faac_channels);
- }
- if(faac_init < 0) {
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: Failed to initialize the decoder!\n"); // XXX: deal with cleanup!
- faacDecClose(faac_hdec);
- // XXX: free a_in_buffer here or in uninit?
- return 0;
- } else {
- mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Decoder init done (%dBytes)!\n", sh->a_in_buffer_len); // XXX: remove or move to debug!
- mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Negotiated samplerate: %ldHz channels: %d\n", faac_samplerate, faac_channels);
- // 8 channels is aac channel order #7.
- sh->channels = faac_channels == 7 ? 8 : faac_channels;
- if (opts->audio_output_channels <= 2)
- sh->channels = faac_channels > 1 ? 2 : 1;
- sh->samplerate = faac_samplerate;
- sh->samplesize=2;
- //sh->o_bps = sh->samplesize*faac_channels*faac_samplerate;
- if(!sh->i_bps) {
- mp_msg(MSGT_DECAUDIO, MSGL_V, "FAAD: compressed input bitrate missing, assuming 128kbit/s!\n");
- sh->i_bps = 128*1000/8; // XXX: HACK!!! ::atmos
- } else
- mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: got %dkbit/s bitrate from MP4 header!\n",sh->i_bps*8/1000);
- }
- return 1;
-}
-
-static void uninit(sh_audio_t *sh)
-{
- mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Closing decoder!\n");
- faacDecClose(faac_hdec);
-}
-
-static int aac_sync(sh_audio_t *sh)
-{
- int pos = 0;
- // do not probe LATM, faad does that
- if(!sh->codecdata_len && sh->format != mmioFOURCC('M', 'P', '4', 'L')) {
- if(sh->a_in_buffer_len < sh->a_in_buffer_size){
- sh->a_in_buffer_len +=
- demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len],
- sh->a_in_buffer_size - sh->a_in_buffer_len);
- }
- pos = aac_probe(sh->a_in_buffer, sh->a_in_buffer_len);
- if(pos) {
- sh->a_in_buffer_len -= pos;
- memmove(sh->a_in_buffer, &(sh->a_in_buffer[pos]), sh->a_in_buffer_len);
- mp_msg(MSGT_DECAUDIO,MSGL_V, "\nAAC SYNC AFTER %d bytes\n", pos);
- }
- }
- return pos;
-}
-
-static int control(sh_audio_t *sh,int cmd,void* arg, ...)
-{
- switch(cmd)
- {
- case ADCTRL_RESYNC_STREAM:
- aac_sync(sh);
- return CONTROL_TRUE;
-#if 0
- case ADCTRL_SKIP_FRAME:
- return CONTROL_TRUE;
-#endif
- }
- return CONTROL_UNKNOWN;
-}
-
-#define MAX_FAAD_ERRORS 10
-static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen)
-{
- int len = 0, last_dec_len = 1, errors = 0;
- // int j = 0;
- void *faac_sample_buffer;
-
- while(len < minlen && last_dec_len > 0 && errors < MAX_FAAD_ERRORS) {
-
- /* update buffer for raw aac streams: */
- if(!sh->codecdata_len)
- if(sh->a_in_buffer_len < sh->a_in_buffer_size){
- sh->a_in_buffer_len +=
- demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len],
- sh->a_in_buffer_size - sh->a_in_buffer_len);
- }
-
-#ifdef DUMP_AAC_COMPRESSED
- {int i;
- for (i = 0; i < 16; i++)
- printf ("%02X ", sh->a_in_buffer[i]);
- printf ("\n");}
-#endif
-
- if(!sh->codecdata_len){
- // raw aac stream:
- do {
- faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, sh->a_in_buffer, sh->a_in_buffer_len);
-
- /* update buffer index after faacDecDecode */
- if(faac_finfo.bytesconsumed >= sh->a_in_buffer_len) {
- sh->a_in_buffer_len=0;
- } else {
- sh->a_in_buffer_len-=faac_finfo.bytesconsumed;
- memmove(sh->a_in_buffer,&sh->a_in_buffer[faac_finfo.bytesconsumed],sh->a_in_buffer_len);
- }
-
- if(faac_finfo.error > 0) {
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: error: %s, trying to resync!\n",
- faacDecGetErrorMessage(faac_finfo.error));
- if (sh->a_in_buffer_len <= 0) {
- errors = MAX_FAAD_ERRORS;
- break;
- }
- sh->a_in_buffer_len--;
- memmove(sh->a_in_buffer,&sh->a_in_buffer[1],sh->a_in_buffer_len);
- aac_sync(sh);
- errors++;
- } else
- break;
- } while(errors < MAX_FAAD_ERRORS);
- } else {
- // packetized (.mp4) aac stream:
- unsigned char* bufptr=NULL;
- double pts;
- int buflen=ds_get_packet_pts(sh->ds, &bufptr, &pts);
- if(buflen<=0) break;
- if (pts != MP_NOPTS_VALUE) {
- sh->pts = pts;
- sh->pts_bytes = 0;
- }
- faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, bufptr, buflen);
- }
- //for (j=0;j<faac_finfo.channels;j++) printf("%d:%d\n", j, faac_finfo.channel_position[j]);
-
- if(faac_finfo.error > 0) {
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: Failed to decode frame: %s \n",
- faacDecGetErrorMessage(faac_finfo.error));
- } else if (faac_finfo.samples == 0) {
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FAAD: Decoded zero samples!\n");
- } else {
- /* XXX: samples already multiplied by channels! */
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FAAD: Successfully decoded frame (%ld Bytes)!\n",
- sh->samplesize*faac_finfo.samples);
-
- if (sh->channels >= 5)
- reorder_channel_copy_nch(faac_sample_buffer,
- AF_CHANNEL_LAYOUT_AAC_DEFAULT,
- buf+len, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
- sh->channels,
- faac_finfo.samples, sh->samplesize);
- else
- memcpy(buf+len,faac_sample_buffer, sh->samplesize*faac_finfo.samples);
- last_dec_len = sh->samplesize*faac_finfo.samples;
- len += last_dec_len;
- sh->pts_bytes += last_dec_len;
- //printf("FAAD: buffer: %d bytes consumed: %d \n", k, faac_finfo.bytesconsumed);
- }
- }
- return len;
-}
diff --git a/libmpcodecs/ad_hwac3.c b/libmpcodecs/ad_hwac3.c
deleted file mode 100644
index 44e7657107..0000000000
--- a/libmpcodecs/ad_hwac3.c
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * DTS code based on "ac3/decode_dts.c" and "ac3/conversion.c" from "ogle 0.9"
- * (see http://www.dtek.chalmers.se/~dvd/)
- * Reference: DOCS/tech/hwac3.txt !!!!!
- *
- * 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.
- */
-
-#define _GNU_SOURCE
-#define _XOPEN_SOURCE 600
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <libavutil/intreadwrite.h>
-#include <libavutil/common.h>
-
-#include "config.h"
-#include "mp_msg.h"
-#include "mpbswap.h"
-
-#include "ad_internal.h"
-
-
-static int isdts = -1;
-
-static const ad_info_t info =
-{
- "AC3/DTS pass-through S/PDIF",
- "hwac3",
- "Nick Kurshev/Peter Schüller",
- "???",
- ""
-};
-
-LIBAD_EXTERN(hwac3)
-
-
-static int dts_syncinfo(uint8_t *indata_ptr, int *flags, int *sample_rate, int *bit_rate);
-static int decode_audio_dts(unsigned char *indata_ptr, int len, unsigned char *buf);
-
-
-static int a52_syncinfo (uint8_t *buf, int *sample_rate, int *bit_rate)
-{
- static const uint16_t rate[] = { 32, 40, 48, 56, 64, 80, 96, 112,
- 128, 160, 192, 224, 256, 320, 384, 448,
- 512, 576, 640};
- int frmsizecod;
- int bitrate;
- int half;
-
- if (buf[0] != 0x0b || buf[1] != 0x77) /* syncword */
- return 0;
-
- if (buf[5] >= 0x60) /* bsid >= 12 */
- return 0;
- half = buf[5] >> 3;
- half = FFMAX(half - 8, 0);
-
- frmsizecod = buf[4] & 63;
- if (frmsizecod >= 38)
- return 0;
- bitrate = rate[frmsizecod >> 1];
- *bit_rate = (bitrate * 1000) >> half;
-
- switch (buf[4] & 0xc0) {
- case 0:
- *sample_rate = 48000 >> half;
- return 4 * bitrate;
- case 0x40:
- *sample_rate = 44100 >> half;
- return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
- case 0x80:
- *sample_rate = 32000 >> half;
- return 6 * bitrate;
- default:
- return 0;
- }
-}
-
-static int ac3dts_fillbuff(sh_audio_t *sh_audio)
-{
- int length = 0;
- int flags = 0;
- int sample_rate = 0;
- int bit_rate = 0;
-
- sh_audio->a_in_buffer_len = 0;
- /* sync frame:*/
- while(1)
- {
- // Original code DTS has a 10 bytes header.
- // Now max 12 bytes for 14 bits DTS header.
- while(sh_audio->a_in_buffer_len < 12)
- {
- int c = demux_getc(sh_audio->ds);
- if(c<0)
- return -1; /* EOF*/
- sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++] = c;
- }
-
- if (sh_audio->format == 0x2001)
- {
- length = dts_syncinfo(sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate);
- if(length >= 12)
- {
- if(isdts != 1)
- {
- mp_msg(MSGT_DECAUDIO, MSGL_STATUS, "hwac3: switched to DTS, %d bps, %d Hz\n", bit_rate, sample_rate);
- isdts = 1;
- }
- break;
- }
- }
- else
- {
- length = a52_syncinfo(sh_audio->a_in_buffer, &sample_rate, &bit_rate);
- if(length >= 7 && length <= 3840)
- {
- if(isdts != 0)
- {
- mp_msg(MSGT_DECAUDIO, MSGL_STATUS, "hwac3: switched to AC3, %d bps, %d Hz\n", bit_rate, sample_rate);
- isdts = 0;
- }
- break; /* we're done.*/
- }
- }
- /* bad file => resync*/
- memcpy(sh_audio->a_in_buffer, sh_audio->a_in_buffer + 1, 11);
- --sh_audio->a_in_buffer_len;
- }
- mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "ac3dts: %s len=%d flags=0x%X %d Hz %d bit/s\n", isdts == 1 ? "DTS" : isdts == 0 ? "AC3" : "unknown", length, flags, sample_rate, bit_rate);
-
- sh_audio->samplerate = sample_rate;
- sh_audio->i_bps = bit_rate / 8;
- demux_read_data(sh_audio->ds, sh_audio->a_in_buffer + 12, length - 12);
- sh_audio->a_in_buffer_len = length;
-
- return length;
-}
-
-
-static int preinit(sh_audio_t *sh)
-{
- /* Dolby AC3 audio: */
- sh->audio_out_minsize = 128 * 32 * 2 * 2; // DTS seems to need more than AC3
- sh->audio_in_minsize = 8192;
- sh->channels = 2;
- sh->samplesize = 2;
- sh->sample_format = AF_FORMAT_AC3_BE;
- // HACK for DTS where useless swapping can't easily be removed
- if (sh->format == 0x2001)
- sh->sample_format = AF_FORMAT_AC3_NE;
- return 1;
-}
-
-static int init(sh_audio_t *sh_audio)
-{
- /* Dolby AC3 passthrough:*/
- if(ac3dts_fillbuff(sh_audio) < 0)
- {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, "AC3/DTS sync failed\n");
- return 0;
- }
- return 1;
-}
-
-static void uninit(sh_audio_t *sh)
-{
-}
-
-static int control(sh_audio_t *sh,int cmd,void* arg, ...)
-{
- switch(cmd)
- {
- case ADCTRL_RESYNC_STREAM:
- case ADCTRL_SKIP_FRAME:
- ac3dts_fillbuff(sh);
- return CONTROL_TRUE;
- }
- return CONTROL_UNKNOWN;
-}
-
-
-static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
-{
- int len = sh_audio->a_in_buffer_len;
-
- if(len <= 0)
- if((len = ac3dts_fillbuff(sh_audio)) <= 0)
- return len; /*EOF*/
- sh_audio->a_in_buffer_len = 0;
-
- if(isdts == 1)
- {
- return decode_audio_dts(sh_audio->a_in_buffer, len, buf);
- }
- else if(isdts == 0)
- {
- AV_WB16(buf, 0xF872); // iec 61937 syncword 1
- AV_WB16(buf + 2, 0x4E1F); // iec 61937 syncword 2
- buf[4] = sh_audio->a_in_buffer[5] & 0x7; // bsmod
- buf[5] = 0x01; // data-type ac3
- AV_WB16(buf + 6, len << 3); // number of bits in payload
- memcpy(buf + 8, sh_audio->a_in_buffer, len);
- memset(buf + 8 + len, 0, 6144 - 8 - len);
-
- return 6144;
- }
- else
- return -1;
-}
-
-
-static const int DTS_SAMPLEFREQS[16] =
-{
- 0,
- 8000,
- 16000,
- 32000,
- 64000,
- 128000,
- 11025,
- 22050,
- 44100,
- 88200,
- 176400,
- 12000,
- 24000,
- 48000,
- 96000,
- 192000
-};
-
-static const int DTS_BITRATES[30] =
-{
- 32000,
- 56000,
- 64000,
- 96000,
- 112000,
- 128000,
- 192000,
- 224000,
- 256000,
- 320000,
- 384000,
- 448000,
- 512000,
- 576000,
- 640000,
- 768000,
- 896000,
- 1024000,
- 1152000,
- 1280000,
- 1344000,
- 1408000,
- 1411200,
- 1472000,
- 1536000,
- 1920000,
- 2048000,
- 3072000,
- 3840000,
- 4096000
-};
-
-static int dts_decode_header(uint8_t *indata_ptr, int *rate, int *nblks, int *sfreq)
-{
- int ftype;
- int surp;
- int unknown_bit av_unused;
- int fsize;
- int amode av_unused;
-
- int word_mode;
- int le_mode;
-
- unsigned int first4bytes = indata_ptr[0] << 24 | indata_ptr[1] << 16
-