1
mirror of https://github.com/mpv-player/mpv synced 2024-08-24 07:21:49 +02:00

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 1fde09db6f.
This commit is contained in:
wm4 2012-08-18 11:17:35 +02:00
parent 6f7ba66817
commit 6a26b4a665
27 changed files with 1 additions and 7822 deletions

View File

@ -34,8 +34,6 @@ SRCS_COMMON-$(DVBIN) += stream/dvb_tune.c \
SRCS_COMMON-$(DVDREAD) += stream/stream_dvd.c \
stream/stream_dvd_common.c
SRCS_COMMON-$(FAAD) += libmpcodecs/ad_faad.c
# These filters use private headers and do not work with shared libavcodec.
SRCS_COMMON-$(FFMPEG_INTERNALS) += libmpcodecs/vf_mcdeint.c \
libmpcodecs/vf_spp.c \
@ -44,18 +42,13 @@ SRCS_COMMON-$(FTP) += stream/stream_ftp.c
SRCS_COMMON-$(GIF) += libmpdemux/demux_gif.c
SRCS_COMMON-$(HAVE_POSIX_SELECT) += libmpcodecs/vf_bmovl.c
SRCS_COMMON-$(HAVE_SYS_MMAN_H) += libaf/af_export.c osdep/mmap_anon.c
SRCS_COMMON-$(JPEG) += libmpcodecs/vd_ijpg.c
SRCS_COMMON-$(LADSPA) += libaf/af_ladspa.c
SRCS_COMMON-$(LIBA52) += libmpcodecs/ad_liba52.c
SRCS_COMMON-$(LIBASS) += libmpcodecs/vf_ass.c \
sub/ass_mp.c \
sub/sd_ass.c \
SRCS_COMMON-$(LIBBLURAY) += stream/stream_bluray.c
SRCS_COMMON-$(LIBBS2B) += libaf/af_bs2b.c
SRCS_COMMON-$(LIBDCA) += libmpcodecs/ad_libdca.c
SRCS_COMMON-$(LIBMAD) += libmpcodecs/ad_libmad.c
SRCS_COMMON-$(LIBPOSTPROC) += libmpcodecs/vf_pp.c
SRCS_COMMON-$(LIBSMBCLIENT) += stream/stream_smb.c
@ -83,7 +76,6 @@ SRCS_COMMON-$(NETWORKING) += stream/stream_netstream.c \
stream/tcp.c \
stream/stream_udp.c \
SRCS_COMMON-$(PNG) += libmpcodecs/vd_mpng.c
SRCS_COMMON-$(PRIORITY) += osdep/priority.c
SRCS_COMMON-$(PVR) += stream/stream_pvr.c
SRCS_COMMON-$(RADIO) += stream/stream_radio.c
@ -147,15 +139,8 @@ SRCS_COMMON = asxparser.c \
libaf/reorder_ch.c \
libaf/window.c \
libmpcodecs/ad.c \
libmpcodecs/ad_alaw.c \
libmpcodecs/ad_dvdpcm.c \
libmpcodecs/ad_ffmpeg.c \
libmpcodecs/ad_spdif.c \
libmpcodecs/ad_hwac3.c \
libmpcodecs/ad_hwmpa.c \
libmpcodecs/ad_imaadpcm.c \
libmpcodecs/ad_msadpcm.c \
libmpcodecs/ad_pcm.c \
libmpcodecs/dec_audio.c \
libmpcodecs/dec_video.c \
libmpcodecs/img_format.c \
@ -163,11 +148,6 @@ SRCS_COMMON = asxparser.c \
libmpcodecs/pullup.c \
libmpcodecs/vd.c \
libmpcodecs/vd_ffmpeg.c \
libmpcodecs/vd_hmblck.c \
libmpcodecs/vd_lzo.c \
libmpcodecs/vd_mtga.c \
libmpcodecs/vd_null.c \
libmpcodecs/vd_raw.c \
libmpcodecs/vf.c \
libmpcodecs/vf_1bpp.c \
libmpcodecs/vf_2xsai.c \
@ -257,7 +237,6 @@ SRCS_COMMON = asxparser.c \
libmpdemux/ebml.c \
libmpdemux/extension.c \
libmpdemux/mf.c \
libmpdemux/mp3_hdr.c \
libmpdemux/mp_taglists.c \
libmpdemux/video.c \
libvo/osd.c \
@ -359,7 +338,6 @@ DIRS = . \
libaf \
libao2 \
libmpcodecs \
libmpcodecs/native \
libmpdemux \
libvo \
osdep \

101
configure vendored
View File

@ -347,13 +347,9 @@ Codecs:
--enable-jpeg enable JPEG input/output support [autodetect]
--enable-libcdio enable libcdio support [autodetect]
--enable-libav skip Libav autodetection [autodetect]
--enable-faad enable FAAD2 (AAC) [autodetect]
--disable-ladspa disable LADSPA plugin support [autodetect]
--disable-libbs2b disable libbs2b audio filter support [autodetect]
--disable-mpg123 disable libmpg123 MP3 decoding support [autodetect]
--disable-mad disable libmad (MPEG audio) support [autodetect]
--enable-libdca enable libdca support [autodetect]
--disable-liba52 disable liba52 [autodetect]
Video output:
--enable-gl enable OpenGL video output [autodetect]
@ -461,11 +457,7 @@ _portaudio=auto
_jack=auto
_openal=no
_libcdio=auto
_mad=auto
_mpg123=auto
_liba52=auto
_libdca=auto
_faad=auto
_ladspa=auto
_libbs2b=auto
_vcd=auto
@ -664,18 +656,10 @@ for ac_option do
--disable-jack) _jack=no ;;
--enable-openal) _openal=yes ;;
--disable-openal) _openal=no ;;
--enable-mad) _mad=yes ;;
--disable-mad) _mad=no ;;
--enable-libcdio) _libcdio=yes ;;
--disable-libcdio) _libcdio=no ;;
--enable-mpg123) _mpg123=yes ;;
--disable-mpg123) _mpg123=no ;;
--enable-liba52) _liba52=yes ;;
--disable-liba52) _liba52=no ;;
--enable-libdca) _libdca=yes ;;
--disable-libdca) _libdca=no ;;
--enable-faad) _faad=yes ;;
--disable-faad) _faad=no ;;
--enable-ladspa) _ladspa=yes ;;
--disable-ladspa) _ladspa=no ;;
--enable-libbs2b) _libbs2b=yes ;;
@ -2856,22 +2840,6 @@ fi
echores "$_zlib"
echocheck "mad support"
if test "$_mad" = auto ; then
_mad=no
statement_check mad.h 'mad_synth_init(0)' -lmad && _mad=yes
fi
if test "$_mad" = yes ; then
def_mad='#define CONFIG_LIBMAD 1'
extra_ldflags="$extra_ldflags -lmad"
codecmodules="libmad $codecmodules"
else
def_mad='#undef CONFIG_LIBMAD'
nocodecmodules="libmad $nocodecmodules"
fi
echores "$_mad"
# Any version of libmpg123 that knows MPG123_RESYNC_LIMIT shall be fine.
# That is, 1.2.0 onwards. Recommened is 1.14 onwards, though.
echocheck "mpg123 support"
@ -2888,67 +2856,6 @@ else
fi
echores "$_mpg123"
echocheck "liba52 support"
def_liba52='#undef CONFIG_LIBA52'
if test "$_liba52" = auto ; then
_liba52=no
cat > $TMPC << EOF
#include <inttypes.h>
#include <a52dec/a52.h>
int main(void) { a52_state_t *testHand; testHand=a52_init(0); return 0; }
EOF
cc_check -la52 && _liba52=yes && extra_ldflags="$extra_ldflags -la52"
fi
if test "$_liba52" = yes ; then
def_liba52='#define CONFIG_LIBA52 1'
codecmodules="liba52 $codecmodules"
else
nocodecmodules="liba52 $nocodecmodules"
fi
echores "$_liba52"
echocheck "libdca support"
if test "$_libdca" = auto ; then
_libdca=no
for _ld_dca in -ldca -ldts ; do
statement_check_broken stdint.h dts.h 'dts_init(0)' $_ld_dca $_ld_lm &&
extra_ldflags="$extra_ldflags $_ld_dca" && _libdca=yes && break
done
fi
if test "$_libdca" = yes ; then
def_libdca='#define CONFIG_LIBDCA 1'
codecmodules="libdca $codecmodules"
else
def_libdca='#undef CONFIG_LIBDCA'
nocodecmodules="libdca $nocodecmodules"
fi
echores "$_libdca"
echocheck "FAAD2 support"
if test "$_faad" = auto ; then
_faad=no
cat > $TMPC << EOF
#include <neaacdec.h>
#ifndef FAAD_MIN_STREAMSIZE
#error Too old version
#endif
int main(void) { faacDecHandle testhand; faacDecFrameInfo testinfo;
testhand = faacDecOpen(); faacDecInit(0, 0, 0, 0, 0); return 0; }
EOF
cc_check -lfaad $_ld_lm && _faad=yes
fi
def_faad='#undef CONFIG_FAAD'
if test "$_faad" = yes ; then
def_faad='#define CONFIG_FAAD 1'
extra_ldflags="$extra_ldflags -lfaad"
codecmodules="faad2 $codecmodules"
else
nocodecmodules="faad2 $nocodecmodules"
fi
echores "$_faad"
echocheck "LADSPA plugin support"
if test "$_ladspa" = auto ; then
@ -3426,7 +3333,6 @@ DIRECT3D = $_direct3d
DVBIN = $_dvbin
DVDREAD = $_dvdread
DXR3 = $_dxr3
FAAD = $_faad
FTP = $_ftp
GIF = $_gif
GL = $_gl
@ -3439,14 +3345,11 @@ JACK = $_jack
JOYSTICK = $_joystick
JPEG = $_jpeg
LADSPA = $_ladspa
LIBA52 = $_liba52
LIBASS = $_ass
LIBASS_OSD = $_libass_osd
DUMMY_OSD = $_dummy_osd
LIBBLURAY = $_bluray
LIBBS2B = $_libbs2b
LIBDCA = $_libdca
LIBMAD = $_mad
LCMS2 = $_lcms2
LIBPOSTPROC = $libpostproc
LIBSMBCLIENT = $_smb
@ -3616,10 +3519,6 @@ $def_vcd
/* codec libraries */
$def_faad
$def_liba52
$def_libdca
$def_mad
$def_mpg123
$def_zlib

File diff suppressed because it is too large Load Diff

View File

@ -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
};

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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
| indata_ptr[2] << 8 | indata_ptr[3];
switch(first4bytes)
{
/* 14 bits LE */
case 0xff1f00e8:
/* Also make sure frame type is 1. */
if ((indata_ptr[4]&0xf0) != 0xf0 || indata_ptr[5] != 0x07)
return -1;
word_mode = 0;
le_mode = 1;
break;
/* 14 bits BE */
case 0x1fffe800:
/* Also make sure frame type is 1. */
if (indata_ptr[4] != 0x07 || (indata_ptr[5]&0xf0) != 0xf0)
return -1;
word_mode = 0;
le_mode = 0;
break;
/* 16 bits LE */
case 0xfe7f0180:
word_mode = 1;
le_mode = 1;
break;
/* 16 bits BE */
case 0x7ffe8001:
word_mode = 1;
le_mode = 0;
break;
default:
return -1;
}
if(word_mode)
{
/* First bit after first 32 bits:
Frame type ( 1: Normal frame; 0: Termination frame ) */
ftype = indata_ptr[4+le_mode] >> 7;
if(ftype != 1)
{
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: Termination frames not handled, REPORT BUG\n");
return -1;
}
/* Next 5 bits: Surplus Sample Count V SURP 5 bits */
surp = indata_ptr[4+le_mode] >> 2 & 0x1f;
/* Number of surplus samples */
surp = (surp + 1) % 32;
/* One unknown bit, crc? */
unknown_bit = indata_ptr[4+le_mode] >> 1 & 0x01;
/* NBLKS 7 bits: Valid Range=5-127, Invalid Range=0-4 */
*nblks = (indata_ptr[4+le_mode] & 0x01) << 6 | indata_ptr[5-le_mode] >> 2;
/* NBLKS+1 indicates the number of 32 sample PCM audio blocks per channel
encoded in the current frame per channel. */
++(*nblks);
/* Frame Byte Size V FSIZE 14 bits: 0-94=Invalid, 95-8191=Valid range-1
(ie. 96 bytes to 8192 bytes), 8192-16383=Invalid
FSIZE defines the byte size of the current audio frame. */
fsize = (indata_ptr[5-le_mode] & 0x03) << 12 | indata_ptr[6+le_mode] << 4
| indata_ptr[7-le_mode] >> 4;
++fsize;
/* Audio Channel Arrangement ACC AMODE 6 bits */
amode = (indata_ptr[7-le_mode] & 0x0f) << 2 | indata_ptr[8+le_mode] >> 6;
/* Source Sampling rate ACC SFREQ 4 bits */
*sfreq = indata_ptr[8+le_mode] >> 2 & 0x0f;
/* Transmission Bit Rate ACC RATE 5 bits */
*rate = (indata_ptr[8+le_mode] & 0x03) << 3
| (indata_ptr[9-le_mode] >> 5 & 0x07);
}
else
{
/* in the case judgement, we assure this */
ftype = 1;
surp = 0;
/* 14 bits support, every 2 bytes, & 0x3fff, got used 14 bits */
/* Bits usage:
32 bits: Sync code (28 + 4) 1th and 2th word, 4 bits in 3th word
1 bits: Frame type 1 bits in 3th word
5 bits: SURP 5 bits in 3th word
1 bits: crc? 1 bits in 3th word
7 bits: NBLKS 3 bits in 3th word, 4 bits in 4th word
14 bits: FSIZE 10 bits in 4th word, 4 bits in 5th word
in 14 bits mode, FSIZE = FSIZE*8/14*2
6 bits: AMODE 6 bits in 5th word
4 bits: SFREQ 4 bits in 5th word
5 bits: RATE 5 bits in 6th word
total bits: 75 bits */
/* NBLKS 7 bits: Valid Range=5-127, Invalid Range=0-4 */
*nblks = (indata_ptr[5-le_mode] & 0x07) << 4
| (indata_ptr[6+le_mode] & 0x3f) >> 2;
/* NBLKS+1 indicates the number of 32 sample PCM audio blocks per channel
encoded in the current frame per channel. */
++(*nblks);
/* Frame Byte Size V FSIZE 14 bits: 0-94=Invalid, 95-8191=Valid range-1
(ie. 96 bytes to 8192 bytes), 8192-16383=Invalid
FSIZE defines the byte size of the current audio frame. */
fsize = (indata_ptr[6+le_mode] & 0x03) << 12 | indata_ptr[7-le_mode] << 4
| (indata_ptr[8+le_mode] & 0x3f) >> 2;
++fsize;
fsize = fsize * 8 / 14 * 2;
/* Audio Channel Arrangement ACC AMODE 6 bits */
amode = (indata_ptr[8+le_mode] & 0x03) << 4
| (indata_ptr[9-le_mode] & 0xf0) >> 4;
/* Source Sampling rate ACC SFREQ 4 bits */
*sfreq = indata_ptr[9-le_mode] & 0x0f;
/* Transmission Bit Rate ACC RATE 5 bits */
*rate = (indata_ptr[10+le_mode] & 0x3f) >> 1;
}
#if 0
if(*sfreq != 13)
{
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: Only 48kHz supported, REPORT BUG\n");
return -1;
}
#endif
if((fsize > 8192) || (fsize < 96))
{
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: fsize: %d invalid, REPORT BUG\n", fsize);
return -1;
}
if(*nblks != 8 &&
*nblks != 16 &&
*nblks != 32 &&
*nblks != 64 &&
*nblks != 128 &&
ftype == 1)
{
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: nblks %d not valid for normal frame, REPORT BUG\n", *nblks);
return -1;
}
return fsize;
}
static int dts_syncinfo(uint8_t *indata_ptr, int *flags, int *sample_rate, int *bit_rate)
{
int nblks;
int fsize;
int rate;
int sfreq;
fsize = dts_decode_header(indata_ptr, &rate, &nblks, &sfreq);
if(fsize >= 0)
{
if(rate >= 0 && rate <= 29)
*bit_rate = DTS_BITRATES[rate];
else
*bit_rate = 0;
if(sfreq >= 1 && sfreq <= 15)
*sample_rate = DTS_SAMPLEFREQS[sfreq];
else
*sample_rate = 0;
}
return fsize;
}
static int convert_14bits_to_16bits(const unsigned char *src,
unsigned char *dest,
int len,
int is_le)
{
uint16_t *p = (uint16_t *)dest;
uint16_t buf = 0;
int spacebits = 16;
if (len <= 0) return 0;
while (len > 0) {
uint16_t v;
if (len == 1)
v = is_le ? src[0] : src[0] << 8;
else
v = is_le ? src[1] << 8 | src[0] : src[0] << 8 | src[1];
v <<= 2;
src += 2;
len -= 2;
buf |= v >> (16 - spacebits);
spacebits -= 14;
if (spacebits < 0) {
*p++ = buf;
spacebits += 16;
buf = v << (spacebits - 2);
}
}
*p++ = buf;
return (unsigned char *)p - dest;
}
static int decode_audio_dts(unsigned char *indata_ptr, int len, unsigned char *buf)
{
int nblks;
int fsize;
int rate;
int sfreq;
int nr_samples;
int convert_16bits = 0;
uint16_t *buf16 = (uint16_t *)buf;
fsize = dts_decode_header(indata_ptr, &rate, &nblks, &sfreq);
if(fsize < 0)
return -1;
nr_samples = nblks * 32;
buf16[0] = 0xf872; /* iec 61937 */
buf16[1] = 0x4e1f; /* syncword */
switch(nr_samples)
{
case 512:
buf16[2] = 0x000b; /* DTS-1 (512-sample bursts) */
break;
case 1024:
buf16[2] = 0x000c; /* DTS-2 (1024-sample bursts) */
break;
case 2048:
buf16[2] = 0x000d; /* DTS-3 (2048-sample bursts) */
break;
default:
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: %d-sample bursts not supported\n", nr_samples);
buf16[2] = 0x0000;
break;
}
if(fsize + 8 > nr_samples * 2 * 2)
{
// dts wav (14bits LE) match this condition, one way to passthrough
// is not add iec 61937 header, decoders will notice the dts header
// and identify the dts stream. Another way here is convert
// the stream from 14 bits to 16 bits.
if ((indata_ptr[0] == 0xff || indata_ptr[0] == 0x1f)
&& fsize * 14 / 16 + 8 <= nr_samples * 2 * 2) {
// The input stream is 14 bits, we can shrink it to 16 bits
// to save space for add the 61937 header
fsize = convert_14bits_to_16bits(indata_ptr,
&buf[8],
fsize,
indata_ptr[0] == 0xff /* is LE */
);
mp_msg(MSGT_DECAUDIO, MSGL_DBG3, "DTS: shrink 14 bits stream to "
"16 bits %02x%02x%02x%02x => %02x%02x%02x%02x, new size %d.\n",
indata_ptr[0], indata_ptr[1], indata_ptr[2], indata_ptr[3],
buf[8], buf[9], buf[10], buf[11], fsize);
convert_16bits = 1;
}
else
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: more data than fits\n");
}
buf16[3] = fsize << 3;
if (!convert_16bits) {
#ifdef BIG_ENDIAN
/* BE stream */
if (indata_ptr[0] == 0x1f || indata_ptr[0] == 0x7f)
#else
/* LE stream */
if (indata_ptr[0] == 0xff || indata_ptr[0] == 0xfe)
#endif
memcpy(&buf[8], indata_ptr, fsize);
else
{
swab(indata_ptr, &buf[8], fsize);
if (fsize & 1) {
buf[8+fsize-1] = 0;
buf[8+fsize] = indata_ptr[fsize-1];
fsize++;
}
}
}
memset(&buf[fsize + 8], 0, nr_samples * 2 * 2 - (fsize + 8));
return nr_samples * 2 * 2;
}

View File

@ -1,166 +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 <string.h>
#include <unistd.h>
#include "config.h"
#include "mp_msg.h"
#include "libaf/af_format.h"
#include "ad_internal.h"
#include "libmpdemux/mp3_hdr.h"
//based on ad_hwac3.c and ad_libmad.c
static const ad_info_t info =
{
"MPEG audio pass-through (fake decoder)",
"hwmpa",
"NicoDVB",
"NicoDVB",
"For hardware decoders"
};
LIBAD_EXTERN(hwmpa)
static int mpa_sync(sh_audio_t *sh, int no_frames, int *n, int *chans, int *srate, int *spf, int *mpa_layer, int *br)
{
int cnt = 0, x = 0, len, frames_count;
frames_count = 0;
do
{
while(cnt + 4 < sh->a_in_buffer_len)
{
x = mp_get_mp3_header(&(sh->a_in_buffer[cnt]), chans, srate, spf, mpa_layer, br);
if(x > 0)
{
frames_count++;
if(frames_count == no_frames)
{
*n = x;
return cnt;
}
}
cnt++;
}
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);
if(len > 0)
sh->a_in_buffer_len += len;
} while(len > 0);
mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Cannot sync MPA frame: %d\r\n", len);
return -1;
}
static int preinit(sh_audio_t *sh)
{
sh->audio_out_minsize = 4608;//check
sh->audio_in_minsize = 4608;//check
sh->sample_format = AF_FORMAT_MPEG2;
return 1;
}
static int init(sh_audio_t *sh)
{
int cnt, chans, srate, spf, mpa_layer, br, len;
if((cnt = mpa_sync(sh, 1, &len, &chans, &srate, &spf, &mpa_layer, &br)) < 0)
return 0;
sh->channels = chans;
sh->samplerate = srate;
sh->i_bps = br * 125;
sh->samplesize = 2;
mp_msg(MSGT_DECAUDIO,MSGL_V,"AC_HWMPA initialized, bitrate: %d kb/s\r\n", len);
return 1;
}
static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen)
{
int len, start, tot;
int chans, srate, spf, mpa_layer, br;
int tot2;
tot = tot2 = 0;
while(tot2 < maxlen)
{
start = mpa_sync(sh, 1, &len, &chans, &srate, &spf, &mpa_layer, &br);
if(start < 0 || tot2 + spf * 2 * chans > maxlen)
break;
if(start + len > sh->a_in_buffer_len)
{
int l;
l = FFMIN(sh->a_in_buffer_size - sh->a_in_buffer_len, start + len);
l = demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], l);
if(! l)
break;
sh->a_in_buffer_len += l;
continue;
}
memcpy(&buf[tot], &(sh->a_in_buffer[start]), len);
tot += len;
sh->a_in_buffer_len -= start + len;
memmove(sh->a_in_buffer, &(sh->a_in_buffer[start + len]), sh->a_in_buffer_len);
tot2 += spf * 2 * chans;
/* HACK: seems to fix most A/V sync issues */
break;
}
memset(&buf[tot], 0, tot2-tot);
return tot2;
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
{
int start, len;
switch(cmd)
{
case ADCTRL_RESYNC_STREAM:
if(mpa_sync(sh, 1, &len, NULL, NULL, NULL, NULL, NULL) >= 0)
return CONTROL_TRUE;
else
return CONTROL_FALSE;
case ADCTRL_SKIP_FRAME:
start = mpa_sync(sh, 2, &len, NULL, NULL, NULL, NULL, NULL);
if(start < 0)
return CONTROL_FALSE;
sh->a_in_buffer_len -= start;
memmove(sh->a_in_buffer, &(sh->a_in_buffer[start]), sh->a_in_buffer_len);
return CONTROL_TRUE;
}
return CONTROL_UNKNOWN;
}
static void uninit(sh_audio_t *sh)
{
}

View File

@ -1,340 +0,0 @@
/*
* IMA ADPCM decoder
*
* This file is in charge of decoding all of the various IMA ADPCM data
* formats that various entities have created. Details about the data
* formats can be found here:
* http://www.pcisys.net/~melanson/codecs/
*
* So far, this file handles these formats:
* 'ima4': IMA ADPCM found in QT files
* 0x11: IMA ADPCM found in MS AVI/ASF/WAV files
* 0x61: DK4 ADPCM found in certain AVI files on Sega Saturn CD-ROMs;
* note that this is a 'rogue' format number in that it was
* never officially registered with Microsoft
* 0x1100736d: IMA ADPCM coded like in MS AVI/ASF/WAV found in QT files
*
* 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 <inttypes.h>
#include <libavutil/intreadwrite.h>
#include "config.h"
#include "mpbswap.h"
#include "ad_internal.h"
#define MS_IMA_ADPCM_PREAMBLE_SIZE 4
#define QT_IMA_ADPCM_PREAMBLE_SIZE 2
#define QT_IMA_ADPCM_BLOCK_SIZE 0x22
#define QT_IMA_ADPCM_SAMPLES_PER_BLOCK 64
// pertinent tables for IMA ADPCM
static const int16_t 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 const int8_t adpcm_index[8] =
{
-1, -1, -1, -1, 2, 4, 6, 8,
};
// useful macros
// clamp a number between 0 and 88
#define CLAMP_0_TO_88(x) x = av_clip(x, 0, 88);
// clamp a number within a signed 16-bit range
#define CLAMP_S16(x) x = av_clip_int16(x);
// clamp a number above 16
#define CLAMP_ABOVE_16(x) if (x < 16) x = 16;
static const ad_info_t info =
{
"IMA ADPCM audio decoder",
"imaadpcm",
"Nick Kurshev",
"Mike Melanson",
""
};
LIBAD_EXTERN(imaadpcm)
static int preinit(sh_audio_t *sh_audio)
{
// not exactly sure what this field is for
sh_audio->audio_out_minsize = 8192;
// if format is "ima4", assume the audio is coming from a QT file which
// indicates constant block size, whereas an AVI/ASF/WAV file will fill
// in this field with 0x11
if ((sh_audio->format == 0x11) || (sh_audio->format == 0x61) ||
(sh_audio->format == 0x1100736d))
{
sh_audio->ds->ss_div = (sh_audio->wf->nBlockAlign -
(MS_IMA_ADPCM_PREAMBLE_SIZE * sh_audio->wf->nChannels)) * 2;
sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign;
}
else
{
sh_audio->ds->ss_div = QT_IMA_ADPCM_SAMPLES_PER_BLOCK;
sh_audio->ds->ss_mul = QT_IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels;
}
sh_audio->audio_in_minsize=sh_audio->ds->ss_mul;
return 1;
}
static int init(sh_audio_t *sh_audio)
{
/* IMA-ADPCM 4:1 audio codec:*/
sh_audio->channels=sh_audio->wf->nChannels;
sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
/* decodes 34 byte -> 64 short*/
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;
}
static void decode_nibbles(unsigned short *output,
int output_size, int channels,
int predictor[2], int index[2])
{
int step[2];
int i;
int sign;
int delta;
int channel_number = 0;
step[0] = adpcm_step[index[0]];
step[1] = adpcm_step[index[1]];
for (i = 0; i < output_size; i++)
{
delta = output[i];
sign = delta & 8;
delta = delta & 7;
index[channel_number] += adpcm_index[delta];
CLAMP_0_TO_88(index[channel_number]);
delta = 2 * delta + 1;
if (sign) delta = -delta;
predictor[channel_number] += (delta * step[channel_number]) >> 3;
CLAMP_S16(predictor[channel_number]);
output[i] = predictor[channel_number];
step[channel_number] = adpcm_step[index[channel_number]];
// toggle channel
channel_number ^= channels - 1;
}
}
static int qt_ima_adpcm_decode_block(unsigned short *output,
unsigned char *input, int channels, int block_size)
{
int initial_predictor[2] = {0};
int initial_index[2] = {0};
int i;
if (channels != 1) channels = 2;
if (block_size < channels * QT_IMA_ADPCM_BLOCK_SIZE)
return -1;
for (i = 0; i < channels; i++) {
initial_index[i] = initial_predictor[i] = (int16_t)AV_RB16(&input[i * QT_IMA_ADPCM_BLOCK_SIZE]);
// mask, sign-extend, and clamp the predictor portion
initial_predictor[i] &= ~0x7F;
CLAMP_S16(initial_predictor[i]);
// mask and clamp the index portion
initial_index[i] &= 0x7F;
CLAMP_0_TO_88(initial_index[i]);
}
// break apart all of the nibbles in the block
if (channels == 1)
for (i = 0; i < QT_IMA_ADPCM_SAMPLES_PER_BLOCK / 2; i++)
{
output[i * 2 + 0] = input[2 + i] & 0x0F;
output[i * 2 + 1] = input[2 + i] >> 4;
}
else
for (i = 0; i < QT_IMA_ADPCM_SAMPLES_PER_BLOCK / 2; i++)
{
output[i * 4 + 0] = input[2 + i] & 0x0F;
output[i * 4 + 1] = input[2 + QT_IMA_ADPCM_BLOCK_SIZE + i] & 0x0F;
output[i * 4 + 2] = input[2 + i] >> 4;
output[i * 4 + 3] = input[2 + QT_IMA_ADPCM_BLOCK_SIZE + i] >> 4;
}
decode_nibbles(output,
QT_IMA_ADPCM_SAMPLES_PER_BLOCK * channels, channels,
initial_predictor, initial_index);
return QT_IMA_ADPCM_SAMPLES_PER_BLOCK * channels;
}
static int ms_ima_adpcm_decode_block(unsigned short *output,
unsigned char *input, int channels, int block_size)
{
int predictor[2];
int index[2];
int i;
int channel_counter;
int channel_index;
int channel_index_l;
int channel_index_r;
if (channels != 1) channels = 2;
if (block_size < MS_IMA_ADPCM_PREAMBLE_SIZE * channels)
return -1;
for (i = 0; i < channels; i++) {
predictor[i] = (int16_t)AV_RL16(&input[i * 4]);
index[i] = input[i * 4 + 2];
}
if (channels == 1)
for (i = 0;
i < (block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels); i++)
{
output[i * 2 + 0] = input[MS_IMA_ADPCM_PREAMBLE_SIZE + i] & 0x0F;
output[i * 2 + 1] = input[MS_IMA_ADPCM_PREAMBLE_SIZE + i] >> 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 (i = 0;
i < (block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels); i++)
{
output[channel_index + 0] =
input[MS_IMA_ADPCM_PREAMBLE_SIZE * 2 + i] & 0x0F;
output[channel_index + 2] =
input[MS_IMA_ADPCM_PREAMBLE_SIZE * 2 + i] >> 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;
}
}
}
decode_nibbles(output,
(block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels) * 2,
channels,
predictor, index);
return (block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels) * 2;
}
static int dk4_ima_adpcm_decode_block(unsigned short *output,
unsigned char *input, int channels, int block_size)
{
int i;
int output_ptr;
int predictor[2];
int index[2];
if (channels != 1) channels = 2;
if (block_size < MS_IMA_ADPCM_PREAMBLE_SIZE * channels)
return -1;
for (i = 0; i < channels; i++) {
// the first predictor value goes straight to the output
predictor[i] = output[i] = (int16_t)AV_RL16(&input[i * 4]);
index[i] = input[i * 4 + 2];
}
output_ptr = channels;
for (i = MS_IMA_ADPCM_PREAMBLE_SIZE * channels; i < block_size; i++)
{
output[output_ptr++] = input[i] >> 4;
output[output_ptr++] = input[i] & 0x0F;
}
decode_nibbles(&output[channels],
(block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels) * 2 - channels,
channels,
predictor, index);
return (block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels) * 2 - channels;
}
static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
{
int res = -1;
int (*decode_func)(unsigned short *output, unsigned char *input, int channels, int block_size) = qt_ima_adpcm_decode_block;
if (demux_read_data(sh_audio->ds, sh_audio->a_in_buffer,
sh_audio->ds->ss_mul) !=
sh_audio->ds->ss_mul)
return -1;
if ((sh_audio->format == 0x11) || (sh_audio->format == 0x1100736d))
decode_func = ms_ima_adpcm_decode_block;
else if (sh_audio->format == 0x61)
decode_func = dk4_ima_adpcm_decode_block;
res = decode_func((unsigned short*)buf, sh_audio->a_in_buffer,
sh_audio->wf->nChannels, sh_audio->ds->ss_mul);
return res < 0 ? res : 2 * res;
}

View File

@ -1,339 +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.
*/
#define _GNU_SOURCE
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <assert.h>
#include "config.h"
#include "options.h"
#include "mp_msg.h"
#include "mpbswap.h"
#include "ad_internal.h"
#include "cpudetect.h"
#include "libaf/af_format.h"
#include <a52dec/a52.h>
#include <a52dec/mm_accel.h>
int (* a52_resample) (float * _f, int16_t * s16);
static a52_state_t *a52_state;
static uint32_t a52_flags=0;
/** Used by a52_resample_float, it defines the mapping between liba52
* channels and output channels. The ith nibble from the right in the
* hex representation of channel_map is the index of the source
* channel corresponding to the ith output channel. Source channels are
* indexed 1-6. Silent output channels are marked by 0xf. */
static uint32_t channel_map;
#define DRC_NO_ACTION 0
#define DRC_NO_COMPRESSION 1
#define DRC_CALLBACK 2
/** The output is multiplied by this var. Used for volume control */
static sample_t a52_level = 1;
static int a52_drc_action = DRC_NO_ACTION;
static const ad_info_t info =
{
"AC3 decoding with liba52",
"liba52",
"Nick Kurshev",
"Michel LESPINASSE",
""
};
LIBAD_EXTERN(liba52)
static int a52_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){
while(sh_audio->a_in_buffer_len<8){
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==MKTAG('d','n','e','t')) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8);
length = a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate);
if(length>=7 && length<=3840) break; /* we're done.*/
/* bad file => resync*/
if(sh_audio->format==MKTAG('d','n','e','t')) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8);
memmove(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,7);
--sh_audio->a_in_buffer_len;
}
mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"a52: len=%d flags=0x%X %d Hz %d bit/s\n",length,flags,sample_rate,bit_rate);
sh_audio->samplerate=sample_rate;
sh_audio->i_bps=bit_rate/8;
sh_audio->samplesize=sh_audio->sample_format==AF_FORMAT_FLOAT_NE ? 4 : 2;
demux_read_data(sh_audio->ds,sh_audio->a_in_buffer+8,length-8);
if(sh_audio->format==MKTAG('d','n','e','t'))
swab(sh_audio->a_in_buffer+8,sh_audio->a_in_buffer+8,length-8);
#ifdef CONFIG_LIBA52_INTERNAL
if(crc16_block(sh_audio->a_in_buffer+2,length-2)!=0)
mp_msg(MSGT_DECAUDIO,MSGL_STATUS,"a52: CRC check failed! \n");
#endif
return length;
}
/* returns: number of available channels*/
static int a52_printinfo(sh_audio_t *sh_audio){
int flags, sample_rate, bit_rate;
char* mode="unknown";
int channels=0;
a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate);
switch(flags&A52_CHANNEL_MASK){
case A52_CHANNEL: mode="channel"; channels=2; break;
case A52_MONO: mode="mono"; channels=1; break;
case A52_STEREO: mode="stereo"; channels=2; break;
case A52_3F: mode="3f";channels=3;break;
case A52_2F1R: mode="2f+1r";channels=3;break;
case A52_3F1R: mode="3f+1r";channels=4;break;
case A52_2F2R: mode="2f+2r";channels=4;break;
case A52_3F2R: mode="3f+2r";channels=5;break;
case A52_CHANNEL1: mode="channel1"; channels=2; break;
case A52_CHANNEL2: mode="channel2"; channels=2; break;
case A52_DOLBY: mode="dolby"; channels=2; break;
}
mp_msg(MSGT_DECAUDIO,MSGL_V,"AC3: %d.%d (%s%s) %d Hz %3.1f kbit/s\n",
channels, (flags&A52_LFE)?1:0,
mode, (flags&A52_LFE)?"+lfe":"",
sample_rate, bit_rate*0.001f);
return (flags&A52_LFE) ? (channels+1) : channels;
}
static sample_t dynrng_call (sample_t c, void *data)
{
struct MPOpts *opts = data;
//fprintf(stderr, "(%f, %f): %f\n", (double)c, (double)drc_level, (double)pow((double)c, drc_level));
//fprintf(stderr, "(%lf, %lf): %lf\n", (double)c, opts->drc_level, pow(c, opts->drc_level));
return pow(c, opts->drc_level);
}
static int preinit(sh_audio_t *sh)
{
struct MPOpts *opts = sh->opts;
/* Dolby AC3 audio: */
/* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */
if (sh->samplesize < 4) sh->samplesize = 4;
sh->audio_out_minsize=opts->audio_output_channels*sh->samplesize*256*6;
sh->audio_in_minsize=3840;
a52_level = 1.0;
return 1;
}
/**
* \brief Function to convert the "planar" float format used by liba52
* into the interleaved float format used by libaf/libao2.
* \param in the input buffer containing the planar samples.
* \param out the output buffer where the interleaved result is stored.
*/
static int a52_resample_float(float *in, int16_t *out)
{
unsigned long i;
float *p = (float*) out;
for (i = 0; i != 256; i++) {
unsigned long map = channel_map;
do {
unsigned long ch = map & 15;
if (ch == 15)
*p = 0;
else
*p = in[i + ((ch-1)<<8)];
p++;
} while ((map >>= 4));
}
return (int16_t*) p - out;
}
static int init(sh_audio_t *sh_audio)
{
struct MPOpts *opts = sh_audio->opts;
uint32_t a52_accel=0;
sample_t level=a52_level, bias=384;
int flags=0;
/* Dolby AC3 audio:*/
#ifdef MM_ACCEL_X86_SSE
if(gCpuCaps.hasSSE) a52_accel|=MM_ACCEL_X86_SSE;
#endif
if(gCpuCaps.hasMMX) a52_accel|=MM_ACCEL_X86_MMX;
if(gCpuCaps.hasMMX2) a52_accel|=MM_ACCEL_X86_MMXEXT;
a52_state=a52_init (a52_accel);
if (a52_state == NULL) {
mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n");
return 0;
}
sh_audio->sample_format = AF_FORMAT_FLOAT_NE;
if(a52_fillbuff(sh_audio)<0){
mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n");
return 0;
}
/* Init a52 dynrng */
if (opts->drc_level < 0.001) {
/* level == 0 --> no compression, init library without callback */
a52_drc_action = DRC_NO_COMPRESSION;
} else if (opts->drc_level > 0.999 && opts->drc_level < 1.001) {
/* level == 1 --> full compression, do nothing at all (library default = full compression) */
a52_drc_action = DRC_NO_ACTION;
} else {
a52_drc_action = DRC_CALLBACK;
}
/* Library init for dynrng has to be done for each frame, see decode_audio() */
/* 'a52 cannot upmix' hotfix:*/
a52_printinfo(sh_audio);
sh_audio->channels=opts->audio_output_channels;
while(sh_audio->channels>0){
switch(sh_audio->channels){
case 1: a52_flags=A52_MONO; break;
/* case 2: a52_flags=A52_STEREO; break;*/
case 2: a52_flags=A52_DOLBY; break;
/* case 3: a52_flags=A52_3F; break;*/
case 3: a52_flags=A52_2F1R; break;
case 4: a52_flags=A52_2F2R; break; /* 2+2*/
case 5: a52_flags=A52_3F2R; break;
case 6: a52_flags=A52_3F2R|A52_LFE; break; /* 5.1*/
}
/* test:*/
flags=a52_flags|A52_ADJUST_LEVEL;
mp_msg(MSGT_DECAUDIO,MSGL_V,"A52 flags before a52_frame: 0x%X\n",flags);
if (a52_frame (a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){
mp_msg(MSGT_DECAUDIO,MSGL_ERR,"a52: error decoding frame -> nosound\n");
return 0;
}
mp_msg(MSGT_DECAUDIO,MSGL_V,"A52 flags after a52_frame: 0x%X\n",flags);
/* frame decoded, let's init resampler:*/
channel_map = 0;
if (sh_audio->sample_format == AF_FORMAT_FLOAT_NE) {
if (!(flags & A52_LFE)) {
switch ((flags<<3) | sh_audio->channels) {
case (A52_MONO << 3) | 1: channel_map = 0x1; break;
case (A52_CHANNEL << 3) | 2:
case (A52_STEREO << 3) | 2:
case (A52_DOLBY << 3) | 2: channel_map = 0x21; break;
case (A52_2F1R << 3) | 3: channel_map = 0x321; break;
case (A52_2F2R << 3) | 4: channel_map = 0x4321; break;
case (A52_3F << 3) | 5: channel_map = 0x2ff31; break;
case (A52_3F2R << 3) | 5: channel_map = 0x25431; break;
}
} else if (sh_audio->channels == 6) {
switch (flags & ~A52_LFE) {
case A52_MONO : channel_map = 0x12ffff; break;
case A52_CHANNEL:
case A52_STEREO :
case A52_DOLBY : channel_map = 0x1fff32; break;
case A52_3F : channel_map = 0x13ff42; break;
case A52_2F1R : channel_map = 0x1f4432; break;
case A52_2F2R : channel_map = 0x1f5432; break;
case A52_3F2R : channel_map = 0x136542; break;
}
}
if (channel_map) {
a52_resample = a52_resample_float;
break;
}
} else
break;
}
if(sh_audio->channels<=0){
mp_msg(MSGT_DECAUDIO,MSGL_ERR,"a52: no resampler. try different channel setup!\n");
return 0;
}
return 1;
}
static void uninit(sh_audio_t *sh)
{
a52_free(a52_state);
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
{
switch(cmd)
{
case ADCTRL_RESYNC_STREAM:
case ADCTRL_SKIP_FRAME:
a52_fillbuff(sh);
return CONTROL_TRUE;
case ADCTRL_SET_VOLUME: {
float vol = *(float*)arg;
if (vol > 60.0) vol = 60.0;
a52_level = vol <= -200.0 ? 0 : pow(10.0,vol/20.0);
return CONTROL_TRUE;
}
case ADCTRL_QUERY_FORMAT:
if (*(int*)arg == AF_FORMAT_S16_NE ||
*(int*)arg == AF_FORMAT_FLOAT_NE)
return CONTROL_TRUE;
return CONTROL_FALSE;
}
return CONTROL_UNKNOWN;
}
static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
{
sample_t level=a52_level, bias=384;
int flags=a52_flags|A52_ADJUST_LEVEL;
int i,len=-1;
if (sh_audio->sample_format == AF_FORMAT_FLOAT_NE)
bias = 0;
if(!sh_audio->a_in_buffer_len)
if(a52_fillbuff(sh_audio)<0) return len; /* EOF */
sh_audio->a_in_buffer_len=0;
if (a52_frame (a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){
mp_msg(MSGT_DECAUDIO,MSGL_WARN,"a52: error decoding frame\n");
return len;
}
/* handle dynrng */
if (a52_drc_action != DRC_NO_ACTION) {
if (a52_drc_action == DRC_NO_COMPRESSION)
a52_dynrng(a52_state, NULL, NULL);
else
a52_dynrng(a52_state, dynrng_call, sh_audio->opts);
}
len=0;
for (i = 0; i < 6; i++) {
if (a52_block (a52_state)){
mp_msg(MSGT_DECAUDIO,MSGL_WARN,"a52: error at resampling\n");
break;
}
len+=2*a52_resample(a52_samples(a52_state),(int16_t *)&buf[len]);
}
assert(len <= maxlen);
return len;
}

View File

@ -1,353 +0,0 @@
/*
* DTS Coherent Acoustics stream decoder using libdca
* This file is partially based on dtsdec.c r9036 from FFmpeg and ad_liba52.c
*
* Copyright (C) 2007 Roberto Togni
*
* 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 <assert.h>
#include "config.h"
#include "options.h"
#include "mp_msg.h"
#include "ad_internal.h"
#include <dts.h>
static const ad_info_t info =
{
"DTS decoding with libdca",
"libdca",
"Roberto Togni",
"",
""
};
LIBAD_EXTERN(libdca)
#define DTSBUFFER_SIZE 18726
#define HEADER_SIZE 14
#define CONVERT_LEVEL 1
#define CONVERT_BIAS 0
static const char ch2flags[6] = {
DTS_MONO,
DTS_STEREO,
DTS_3F,
DTS_2F2R,
DTS_3F2R,
DTS_3F2R | DTS_LFE
};
static inline int16_t convert(sample_t s)
{
int i = s * 0x7fff;
return (i > 32767) ? 32767 : ((i < -32768) ? -32768 : i);
}
static void convert2s16_multi(sample_t *f, int16_t *s16, int flags, int ch_out)
{
int i;
switch(flags & (DTS_CHANNEL_MASK | DTS_LFE)){
case DTS_MONO:
if (ch_out == 1)
for(i = 0; i < 256; i++)
s16[i] = convert(f[i]);
else
for(i = 0; i < 256; i++){
s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0;
s16[5*i+4] = convert(f[i]);
}
break;
case DTS_CHANNEL:
case DTS_STEREO:
case DTS_DOLBY:
for(i = 0; i < 256; i++){
s16[2*i] = convert(f[i]);
s16[2*i+1] = convert(f[i+256]);
}
break;
case DTS_3F:
for(i = 0; i < 256; i++){
s16[3*i] = convert(f[i+256]);
s16[3*i+1] = convert(f[i+512]);
s16[3*i+2] = convert(f[i]);
}
break;
case DTS_2F2R:
for(i = 0; i < 256; i++){
s16[4*i] = convert(f[i]);
s16[4*i+1] = convert(f[i+256]);
s16[4*i+2] = convert(f[i+512]);
s16[4*i+3] = convert(f[i+768]);
}
break;
case DTS_3F2R:
for(i = 0; i < 256; i++){
s16[5*i] = convert(f[i+256]);
s16[5*i+1] = convert(f[i+512]);
s16[5*i+2] = convert(f[i+768]);
s16[5*i+3] = convert(f[i+1024]);
s16[5*i+4] = convert(f[i]);
}
break;
case DTS_MONO | DTS_LFE:
for(i = 0; i < 256; i++){
s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0;
s16[6*i+4] = convert(f[i]);
s16[6*i+5] = convert(f[i+256]);
}
break;
case DTS_CHANNEL | DTS_LFE:
case DTS_STEREO | DTS_LFE:
case DTS_DOLBY | DTS_LFE:
for(i = 0; i < 256; i++){
s16[6*i] = convert(f[i]);
s16[6*i+1] = convert(f[i+256]);
s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0;
s16[6*i+5] = convert(f[i+512]);
}
break;
case DTS_3F | DTS_LFE:
for(i = 0; i < 256; i++){
s16[6*i] = convert(f[i+256]);
s16[6*i+1] = convert(f[i+512]);
s16[6*i+2] = s16[6*i+3] = 0;
s16[6*i+4] = convert(f[i]);
s16[6*i+5] = convert(f[i+768]);
}
break;
case DTS_2F2R | DTS_LFE:
for(i = 0; i < 256; i++){
s16[6*i] = convert(f[i]);
s16[6*i+1] = convert(f[i+256]);
s16[6*i+2] = convert(f[i+512]);
s16[6*i+3] = convert(f[i+768]);
s16[6*i+4] = 0;
s16[6*i+5] = convert(f[1024]);
}
break;
case DTS_3F2R | DTS_LFE:
for(i = 0; i < 256; i++){
s16[6*i] = convert(f[i+256]);
s16[6*i+1] = convert(f[i+512]);
s16[6*i+2] = convert(f[i+768]);
s16[6*i+3] = convert(f[i+1024]);
s16[6*i+4] = convert(f[i]);
s16[6*i+5] = convert(f[i+1280]);
}
break;
}
}
static void channels_info(int flags)
{
int lfe = 0;
char lfestr[5] = "";
if (flags & DTS_LFE) {
lfe = 1;
strcpy(lfestr, "+lfe");
}
mp_msg(MSGT_DECAUDIO, MSGL_V, "DTS: ");
switch(flags & DTS_CHANNEL_MASK){
case DTS_MONO:
mp_msg(MSGT_DECAUDIO, MSGL_V, "1.%d (mono%s)", lfe, lfestr);
break;
case DTS_CHANNEL:
mp_msg(MSGT_DECAUDIO, MSGL_V, "2.%d (channel%s)", lfe, lfestr);
break;
case DTS_STEREO:
mp_msg(MSGT_DECAUDIO, MSGL_V, "2.%d (stereo%s)", lfe, lfestr);
break;
case DTS_3F:
mp_msg(MSGT_DECAUDIO, MSGL_V, "3.%d (3f%s)", lfe, lfestr);
break;
case DTS_2F2R:
mp_msg(MSGT_DECAUDIO, MSGL_V, "4.%d (2f+2r%s)", lfe, lfestr);
break;
case DTS_3F2R:
mp_msg(MSGT_DECAUDIO, MSGL_V, "5.%d (3f+2r%s)", lfe, lfestr);
break;
default:
mp_msg(MSGT_DECAUDIO, MSGL_V, "x.%d (unknown%s)", lfe, lfestr);
}
mp_msg(MSGT_DECAUDIO, MSGL_V, "\n");
}
static int dts_sync(sh_audio_t *sh, int *flags)
{
dts_state_t *s = sh->context;
int length;
int sample_rate;
int frame_length;
int bit_rate;
sh->a_in_buffer_len=0;
while(1) {
while(sh->a_in_buffer_len < HEADER_SIZE) {
int c = demux_getc(sh->ds);
if(c < 0)
return -1;
sh->a_in_buffer[sh->a_in_buffer_len++] = c;
}
length = dts_syncinfo(s, sh->a_in_buffer, flags, &sample_rate,
&bit_rate, &frame_length);
if(length >= HEADER_SIZE)
break;
// mp_msg(MSGT_DECAUDIO, MSGL_V, "skip\n");
memmove(sh->a_in_buffer, sh->a_in_buffer+1, HEADER_SIZE-1);
--sh->a_in_buffer_len;
}
demux_read_data(sh->ds, sh->a_in_buffer + HEADER_SIZE, length - HEADER_SIZE);
sh->samplerate = sample_rate;
sh->i_bps = bit_rate/8;
return length;
}
static int decode_audio(sh_audio_t *sh, unsigned char *buf, int minlen, int maxlen)
{
dts_state_t *s = sh->context;
int16_t *out_samples = (int16_t*)buf;
int flags;
level_t level;
sample_t bias;
int nblocks;
int i;
int data_size = 0;
if(!sh->a_in_buffer_len)
if(dts_sync(sh, &flags) < 0) return -1; /* EOF */
sh->a_in_buffer_len=0;
flags &= ~(DTS_CHANNEL_MASK | DTS_LFE);
flags |= ch2flags[sh->channels - 1];
level = CONVERT_LEVEL;
bias = CONVERT_BIAS;
flags |= DTS_ADJUST_LEVEL;
if(dts_frame(s, sh->a_in_buffer, &flags, &level, bias)) {
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "dts_frame() failed\n");
goto end;
}
nblocks = dts_blocks_num(s);
for(i = 0; i < nblocks; i++) {
if(dts_block(s)) {
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "dts_block() failed\n");
goto end;
}
convert2s16_multi(dts_samples(s), out_samples, flags, sh->channels);
out_samples += 256 * sh->channels;
data_size += 256 * sizeof(int16_t) * sh->channels;
}
end:
return data_size;
}
static int preinit(sh_audio_t *sh)
{
struct MPOpts *opts = sh->opts;
/* 256 = samples per block, 16 = max number of blocks */
int channels = opts->audio_output_channels;
if (channels > 6)
channels = 6;
sh->audio_out_minsize = channels * sizeof(int16_t) * 256 * 16;
sh->audio_in_minsize = DTSBUFFER_SIZE;
sh->samplesize=2;
return 1;
}
static int init(sh_audio_t *sh)
{
struct MPOpts *opts = sh->opts;
dts_state_t *s;
int flags;
int decoded_bytes;
s = dts_init(0);
if(s == NULL) {
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "dts_init() failed\n");
return 0;
}
sh->context = s;
if(dts_sync(sh, &flags) < 0) {
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "dts sync failed\n");
dts_free(s);
return 0;
}
channels_info(flags);
int channels = opts->audio_output_channels;
if (channels > 6)
channels = 6;
assert(channels >= 1 && channels <= 6);
sh->channels = channels;
decoded_bytes = decode_audio(sh, sh->a_buffer, 1, sh->a_buffer_size);
if(decoded_bytes > 0)
sh->a_buffer_len = decoded_bytes;
else {
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "dts decode failed on first frame (up/downmix problem?)\n");
dts_free(s);
return 0;
}
return 1;
}
static void uninit(sh_audio_t *sh)
{
dts_state_t *s = sh->context;
dts_free(s);
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
{
int flags;
switch(cmd){
case ADCTRL_RESYNC_STREAM:
dts_sync(sh, &flags);
return CONTROL_TRUE;
}
return CONTROL_UNKNOWN;
}

View File

@ -1,187 +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 = {
"libmad mpeg audio decoder",
"libmad",
"A'rpi",
"libmad...",
"based on Xine's libmad/xine_decoder.c"
};
LIBAD_EXTERN(libmad)
#include <mad.h>
typedef struct mad_decoder_s {
struct mad_synth synth;
struct mad_stream stream;
struct mad_frame frame;
int have_frame;
int output_sampling_rate;
int output_open;
int output_mode;
} mad_decoder_t;
static int preinit(sh_audio_t *sh){
mad_decoder_t *this = calloc(1, sizeof(mad_decoder_t));
sh->context = this;
mad_synth_init (&this->synth);
mad_stream_init (&this->stream);
mad_frame_init (&this->frame);
sh->audio_out_minsize=2*4608;
sh->audio_in_minsize=4096;
return 1;
}
static int read_frame(sh_audio_t *sh){
mad_decoder_t *this = sh->context;
int len;
while((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))>0){
sh->a_in_buffer_len+=len;
while(1){
int ret;
mad_stream_buffer (&this->stream, sh->a_in_buffer, sh->a_in_buffer_len);
ret=mad_frame_decode (&this->frame, &this->stream);
if (this->stream.next_frame) {
int num_bytes =
(char*)sh->a_in_buffer+sh->a_in_buffer_len - (char*)this->stream.next_frame;
memmove(sh->a_in_buffer, this->stream.next_frame, num_bytes);
mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"libmad: %d bytes processed\n",sh->a_in_buffer_len-num_bytes);
sh->a_in_buffer_len = num_bytes;
}
if (ret == 0) return 1; // OK!!!
// error! try to resync!
if(this->stream.error==MAD_ERROR_BUFLEN) break;
}
}
mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Cannot sync MAD frame\n");
return 0;
}
static int init(sh_audio_t *sh){
mad_decoder_t *this = sh->context;
this->have_frame=read_frame(sh);
if(!this->have_frame) return 0; // failed to sync...
sh->channels=(this->frame.header.mode == MAD_MODE_SINGLE_CHANNEL) ? 1 : 2;
sh->samplerate=this->frame.header.samplerate;
if (sh->i_bps < 1)
sh->i_bps=this->frame.header.bitrate/8;
sh->samplesize=2;
return 1;
}
static void uninit(sh_audio_t *sh){
mad_decoder_t *this = sh->context;
mad_synth_finish (&this->synth);
mad_frame_finish (&this->frame);
mad_stream_finish(&this->stream);
free(sh->context);
}
/* utility to scale and round samples to 16 bits */
static inline signed int scale(mad_fixed_t sample) {
/* round */
sample += (1L << (MAD_F_FRACBITS - 16));
/* clip */
if (sample >= MAD_F_ONE)
sample = MAD_F_ONE - 1;
else if (sample < -MAD_F_ONE)
sample = -MAD_F_ONE;
/* quantize */
return sample >> (MAD_F_FRACBITS + 1 - 16);
}
static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){
mad_decoder_t *this = sh->context;
int len=0;
while(len<minlen && len+4608<=maxlen){
if(!this->have_frame) this->have_frame=read_frame(sh);
if(!this->have_frame) break; // failed to sync... or EOF
this->have_frame=0;
mad_synth_frame (&this->synth, &this->frame);
{ unsigned int nchannels, nsamples;
mad_fixed_t const *left_ch, *right_ch;
struct mad_pcm *pcm = &this->synth.pcm;
uint16_t *output = (uint16_t*) buf;
nchannels = pcm->channels;
nsamples = pcm->length;
left_ch = pcm->samples[0];
right_ch = pcm->samples[1];
len+=2*nchannels*nsamples;
buf+=2*nchannels*nsamples;
while (nsamples--) {
/* output sample(s) in 16-bit signed little-endian PCM */
*output++ = scale(*left_ch++);
if (nchannels == 2)
*output++ = scale(*right_ch++);
}
}
}
return len?len:-1;
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...){
mad_decoder_t *this = sh->context;
// various optional functions you MAY implement:
switch(cmd){
case ADCTRL_RESYNC_STREAM:
this->have_frame=0;
mad_synth_init (&this->synth);
mad_stream_init (&this->stream);
mad_frame_init (&this->frame);
return CONTROL_TRUE;
case ADCTRL_SKIP_FRAME:
this->have_frame=read_frame(sh);
return CONTROL_TRUE;
}
return CONTROL_UNKNOWN;
}

View File

@ -1,237 +0,0 @@
/*
* MS ADPCM decoder
*
* This file is responsible for decoding Microsoft ADPCM data.
* 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/common.h>
#include <libavutil/intreadwrite.h>
#include "config.h"
#include "mpbswap.h"
#include "ad_internal.h"
static const ad_info_t info =
{
"MS ADPCM audio decoder",
"msadpcm",
"Nick Kurshev",
"Mike Melanson",
""
};
LIBAD_EXTERN(msadpcm)
static const int ms_adapt_table[] =
{
230, 230, 230, 230, 307, 409, 512, 614,
768, 614, 512, 409, 307, 230, 230, 230
};
static const uint8_t ms_adapt_coeff1[] =
{
64, 128, 0, 48, 60, 115, 98
};
static const int8_t ms_adapt_coeff2[] =
{
0, -64, 0, 16, 0, -52, -58
};
#define MS_ADPCM_PREAMBLE_SIZE 6
#define LE_16(x) ((int16_t)AV_RL16(x))
// clamp a number between 0 and 88
#define CLAMP_0_TO_88(x) x = av_clip(x, 0, 88);
// clamp a number within a signed 16-bit range
#define CLAMP_S16(x) x = av_clip_int16(x);
// clamp a number above 16
#define CLAMP_ABOVE_16(x) if (x < 16) x = 16;
// sign extend a 4-bit value
#define SE_4BIT(x) if (x & 0x8) x -= 0x10;
static int preinit(sh_audio_t *sh_audio)
{
sh_audio->audio_out_minsize = sh_audio->wf->nBlockAlign * 4;
sh_audio->ds->ss_div =
(sh_audio->wf->nBlockAlign - MS_ADPCM_PREAMBLE_SIZE) * 2;
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->wf->nBlockAlign *
(sh_audio->channels*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;
}
static inline int check_coeff(uint8_t c) {
if (c > 6) {
mp_msg(MSGT_DECAUDIO, MSGL_WARN,
"MS ADPCM: coefficient (%d) out of range (should be [0..6])\n",
c);
c = 6;
}
return c;
}
static int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
int channels, int block_size)
{
int current_channel = 0;
int coeff_idx;
int idelta[2];
int sample1[2];
int sample2[2];
int coeff1[2];
int coeff2[2];
int stream_ptr = 0;
int out_ptr = 0;
int upper_nibble = 1;
int nibble;
int snibble; // signed nibble
int predictor;
if (channels != 1) channels = 2;
if (block_size < 7 * channels)
return -1;
// fetch the header information, in stereo if both channels are present
coeff_idx = check_coeff(input[stream_ptr]);
coeff1[0] = ms_adapt_coeff1[coeff_idx];
coeff2[0] = ms_adapt_coeff2[coeff_idx];
stream_ptr++;
if (channels == 2)
{
coeff_idx = check_coeff(input[stream_ptr]);
coeff1[1] = ms_adapt_coeff1[coeff_idx];
coeff2[1] = ms_adapt_coeff2[coeff_idx];
stream_ptr++;
}
idelta[0] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
if (channels == 2)
{
idelta[1] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
}
sample1[0] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
if (channels == 2)
{
sample1[1] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
}
sample2[0] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
if (channels == 2)
{
sample2[1] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
}
if (channels == 1)
{
output[out_ptr++] = sample2[0];
output[out_ptr++] = sample1[0];
} else {
output[out_ptr++] = sample2[0];
output[out_ptr++] = sample2[1];
output[out_ptr++] = sample1[0];
output[out_ptr++] = sample1[1];
}
while (stream_ptr < block_size)
{
// get the next nibble
if (upper_nibble)
nibble = snibble = input[stream_ptr] >> 4;
else
nibble = snibble = input[stream_ptr++] & 0x0F;
upper_nibble ^= 1;
SE_4BIT(snibble);
// should this really be a division and not a shift?
// coefficients were originally scaled by for, which might have
// been an optimization for 8-bit CPUs _if_ a shift is correct
predictor = (
((sample1[current_channel] * coeff1[current_channel]) +
(sample2[current_channel] * coeff2[current_channel])) / 64) +
(snibble * idelta[current_channel]);
CLAMP_S16(predictor);
sample2[current_channel] = sample1[current_channel];
sample1[current_channel] = predictor;
output[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 ^= channels - 1;
}
return (block_size - (MS_ADPCM_PREAMBLE_SIZE * channels)) * 2;
}
static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
{
int res;
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 */
res = ms_adpcm_decode_block(
(unsigned short*)buf, sh_audio->a_in_buffer,
sh_audio->wf->nChannels, sh_audio->wf->nBlockAlign);
return res < 0 ? res : 2 * res;
}

View File

@ -1,214 +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 <stdbool.h>
#include "talloc.h"
#include "config.h"
#include "ad_internal.h"
#include "libaf/af_format.h"
#include "libaf/reorder_ch.h"
static const ad_info_t info = {
"Uncompressed PCM audio decoder",
"pcm",
"Nick Kurshev",
"A'rpi",
""
};
struct ad_pcm_context {
unsigned char *buffer;
int buffer_pos;
int buffer_len;
int buffer_size;
};
LIBAD_EXTERN(pcm)
static int init(sh_audio_t * sh_audio)
{
WAVEFORMATEX *h = sh_audio->wf;
if (!h)
return 0;
sh_audio->i_bps = h->nAvgBytesPerSec;
sh_audio->channels = h->nChannels;
sh_audio->samplerate = h->nSamplesPerSec;
sh_audio->samplesize = (h->wBitsPerSample + 7) / 8;
sh_audio->sample_format = AF_FORMAT_S16_LE; // default
switch (sh_audio->format) { /* hardware formats: */
case 0x0:
case 0x1: // Microsoft PCM
case 0xfffe: // Extended
switch (sh_audio->samplesize) {
case 1: sh_audio->sample_format = AF_FORMAT_U8; break;
case 2: sh_audio->sample_format = AF_FORMAT_S16_LE; break;
case 3: sh_audio->sample_format = AF_FORMAT_S24_LE; break;
case 4: sh_audio->sample_format = AF_FORMAT_S32_LE; break;
}
break;
case 0x3: // IEEE float
sh_audio->sample_format = AF_FORMAT_FLOAT_LE;
break;
case 0x6: sh_audio->sample_format = AF_FORMAT_A_LAW; break;
case 0x7: sh_audio->sample_format = AF_FORMAT_MU_LAW; break;
case 0x11: sh_audio->sample_format = AF_FORMAT_IMA_ADPCM; break;
case 0x50: sh_audio->sample_format = AF_FORMAT_MPEG2; break;
/* case 0x2000: sh_audio->sample_format=AFMT_AC3; */
case 0x20776172: // 'raw '
sh_audio->sample_format = AF_FORMAT_S16_BE;
if (sh_audio->samplesize == 1)
sh_audio->sample_format = AF_FORMAT_U8;
break;
case 0x736F7774: // 'twos'
sh_audio->sample_format = AF_FORMAT_S16_BE;
// intended fall-through
case 0x74776F73: // 'sowt'
if (sh_audio->samplesize == 1)
sh_audio->sample_format = AF_FORMAT_S8;
break;
case 0x32336c66: // 'fl32', bigendian float32
case 0x32334C46: // 'FL32', bigendian float32 in aiff
sh_audio->sample_format = AF_FORMAT_FLOAT_BE;
sh_audio->samplesize = 4;
break;
case 0x666c3332: // '23lf', little endian float32, MPlayer internal fourCC
case 0x6D63706C: // 'lpcm'
sh_audio->sample_format = AF_FORMAT_FLOAT_LE;
sh_audio->samplesize = 4;
break;
/* case 0x34366c66: // 'fl64', bigendian float64
sh_audio->sample_format=AF_FORMAT_FLOAT_BE;
sh_audio->samplesize=8;
break;
case 0x666c3634: // '46lf', little endian float64, MPlayer internal fourCC
sh_audio->sample_format=AF_FORMAT_FLOAT_LE;
sh_audio->samplesize=8;
break;*/
case 0x34326e69: // 'in24', bigendian int24
sh_audio->sample_format = AF_FORMAT_S24_BE;
sh_audio->samplesize = 3;
break;
case 0x696e3234: // '42ni', little endian int24, MPlayer internal fourCC
sh_audio->sample_format = AF_FORMAT_S24_LE;
sh_audio->samplesize = 3;
break;
case 0x32336e69: // 'in32', bigendian int32
sh_audio->sample_format = AF_FORMAT_S32_BE;
sh_audio->samplesize = 4;
break;
case 0x696e3332: // '23ni', little endian int32, MPlayer internal fourCC
sh_audio->sample_format = AF_FORMAT_S32_LE;
sh_audio->samplesize = 4;
break;
default:
if (sh_audio->samplesize != 2)
sh_audio->sample_format = AF_FORMAT_U8;
}
if (!sh_audio->samplesize) // this would cause MPlayer to hang later
sh_audio->samplesize = 2;
sh_audio->context = talloc_zero(NULL, struct ad_pcm_context);
return 1;
}
static int preinit(sh_audio_t *sh)
{
sh->audio_out_minsize = 2048;
return 1;
}
static void uninit(sh_audio_t *sh)
{
talloc_free(sh->context);
}
static int control(sh_audio_t *sh, int cmd, void *arg, ...)
{
struct ad_pcm_context *ctx = sh->context;
int skip;
switch (cmd) {
case ADCTRL_RESYNC_STREAM:
ctx->buffer_len = 0;
return true;
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 unitsize = sh_audio->channels * sh_audio->samplesize;
minlen = (minlen + unitsize - 1) / unitsize * unitsize;
if (minlen > maxlen)
// if someone needs hundreds of channels adjust audio_out_minsize
// based on channels in preinit()
return -1;
int len = 0;
struct ad_pcm_context *ctx = sh_audio->context;
while (len < minlen) {
if (ctx->buffer_len - ctx->buffer_pos <= 0) {
double pts;
unsigned char *ptr;
int plen = ds_get_packet_pts(sh_audio->ds, &ptr, &pts);
if (plen < 0)
break;
if (ctx->buffer_size < plen) {
talloc_free(ctx->buffer);
ctx->buffer = talloc_size(ctx, plen);
ctx->buffer_size = plen;
}
memcpy(ctx->buffer, ptr, plen);
ctx->buffer_len = plen;
ctx->buffer_pos = 0;
if (pts != MP_NOPTS_VALUE) {
sh_audio->pts = pts;
sh_audio->pts_bytes = 0;
}
}
int from_stored = ctx->buffer_len - ctx->buffer_pos;
if (from_stored > minlen - len)
from_stored = minlen - len;
memcpy(buf + len, ctx->buffer + ctx->buffer_pos, from_stored);
ctx->buffer_pos += from_stored;
sh_audio->pts_bytes += from_stored;
len += from_stored;
}
if (len % unitsize) {
mp_msg(MSGT_DECAUDIO, MSGL_WARN, "[ad_pcm] discarding partial sample "
"at end\n");
len -= len % unitsize;
}
if (len == 0)
len = -1; // The loop above only exits at error/EOF
if (len > 0 && sh_audio->channels >= 5) {
reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT,
AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
sh_audio->channels, len / sh_audio->samplesize,
sh_audio->samplesize);
}
return len;
}

View File

@ -1,145 +0,0 @@
// SAMPLE audio decoder - you can use this file as template when creating new codec!
/*
* 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 = {
"Sample audio decoder", // name of the driver
"sample", // driver name. should be the same as filename without ad_
"A'rpi", // writer/maintainer of _this_ file
"", // writer/maintainer/site of the _codec_
"" // comments
};
LIBAD_EXTERN(sample)
#include "libsample/sample.h" // include your codec's .h files here
static int preinit(sh_audio_t *sh){
// let's check if the driver is available, return 0 if not.
// (you should do that if you use external lib(s) which is optional)
...
// there are default values set for buffering, but you can override them:
// minimum output buffer size (should be the uncompressed max. frame size)
sh->audio_out_minsize=4*2*1024; // in this sample, we assume max 4 channels,
// 2 bytes/sample and 1024 samples/frame
// Default: 8192
// minimum input buffer size (set only if you need input buffering)
// (should be the max compressed frame size)
sh->audio_in_minsize=2048; // Default: 0 (no input buffer)
// if you set audio_in_minsize non-zero, the buffer will be allocated
// before the init() call by the core, and you can access it via
// pointer: sh->audio_in_buffer
// it will free'd after uninit(), so you don't have to use malloc/free here!
// the next few parameters define the audio format (channels, sample type,
// in/out bitrate etc.). it's OK to move these to init() if you can set
// them only after some initialization:
sh->samplesize=2; // bytes (not bits!) per sample per channel
sh->channels=2; // number of channels
sh->samplerate=44100; // samplerate
sh->sample_format=AF_FORMAT_S16_LE; // sample format, see libao2/afmt.h
sh->i_bps=64000/8; // input data rate (compressed bytes per second)
// Note: if you have VBR or unknown input rate, set it to some common or
// average value, instead of zero. it's used to predict time delay of
// buffered compressed bytes, so it must be more-or-less real!
//sh->o_bps=... // output data rate (uncompressed bytes per second)
// Note: you DON'T need to set o_bps in most cases, as it defaults to:
// sh->samplesize*sh->channels*sh->samplerate;
// for constant rate compressed QuickTime (.mov files) codecs you MUST
// set the compressed and uncompressed packet size (used by the demuxer):
sh->ds->ss_mul = 34; // compressed packet size
sh->ds->ss_div = 64; // samples per packet
return 1; // return values: 1=OK 0=ERROR
}
static int init(sh_audio_t *sh_audio){
// initialize the decoder, set tables etc...
// you can store HANDLE or private struct pointer at sh->context
// you can access WAVEFORMATEX header at sh->wf
// set sample format/rate parameters if you didn't do it in preinit() yet.
return 1; // return values: 1=OK 0=ERROR
}
static void uninit(sh_audio_t *sh){
// uninit the decoder etc...
// again: you don't have to free() a_in_buffer here! it's done by the core.
}
static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
// audio decoding. the most important thing :)
// parameters you get:
// buf = pointer to the output buffer, you have to store uncompressed
// samples there
// minlen = requested minimum size (in bytes!) of output. it's just a
// _recommendation_, you can decode more or less, it just tell you that
// the caller process needs 'minlen' bytes. if it gets less, it will
// call decode_audio() again.
// maxlen = maximum size (bytes) of output. you MUST NOT write more to the
// buffer, it's the upper-most limit!
// note: maxlen will be always greater or equal to sh->audio_out_minsize
// now, let's decode...
// you can read the compressed stream using the demux stream functions:
// demux_read_data(sh->ds, buffer, length) - read 'length' bytes to 'buffer'
// ds_get_packet(sh->ds, &buffer) - set ptr buffer to next data packet
// (both func return number of bytes or 0 for error)
return len; // return value: number of _bytes_ written to output buffer,
// or -1 for EOF (or uncorrectable error)
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...){
// various optional functions you MAY implement:
switch(cmd){
case ADCTRL_RESYNC_STREAM:
// it is called once after seeking, to resync.
// Note: sh_audio->a_in_buffer_len=0; is done _before_ this call!
...
return CONTROL_TRUE;
case ADCTRL_SKIP_FRAME:
// it is called to skip (jump over) small amount (1/10 sec or 1 frame)
// of audio data - used to sync audio to video after seeking
// if you don't return CONTROL_TRUE, it will defaults to:
// ds_fill_buffer(sh_audio->ds); // skip 1 demux packet
...
return CONTROL_TRUE;
}
return CONTROL_UNKNOWN;
}

View File

@ -1,76 +0,0 @@
// Generated by TOOLS/alaw-gen.c
#ifndef MPLAYER_ALAW_H
#define MPLAYER_ALAW_H
const short alaw2short[]={
-5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
-7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
-2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
-3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
-22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944,
-30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136,
-11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472,
-15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568,
-344, -328, -376, -360, -280, -264, -312, -296,
-472, -456, -504, -488, -408, -392, -440, -424,
-88, -72, -120, -104, -24, -8, -56, -40,
-216, -200, -248, -232, -152, -136, -184, -168,
-1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
-1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
-688, -656, -752, -720, -560, -528, -624, -592,
-944, -912, -1008, -976, -816, -784, -880, -848,
5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
344, 328, 376, 360, 280, 264, 312, 296,
472, 456, 504, 488, 408, 392, 440, 424,
88, 72, 120, 104, 24, 8, 56, 40,
216, 200, 248, 232, 152, 136, 184, 168,
1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
688, 656, 752, 720, 560, 528, 624, 592,
944, 912, 1008, 976, 816, 784, 880, 848
};
const short ulaw2short[]={
-32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956,
-23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764,
-15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412,
-11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316,
-7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140,
-5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092,
-3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004,
-2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980,
-1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436,
-1372, -1308, -1244, -1180, -1116, -1052, -988, -924,
-876, -844, -812, -780, -748, -716, -684, -652,
-620, -588, -556, -524, -492, -460, -428, -396,
-372, -356, -340, -324, -308, -292, -276, -260,
-244, -228, -212, -196, -180, -164, -148, -132,
-120, -112, -104, -96, -88, -80, -72, -64,
-56, -48, -40, -32, -24, -16, -8, 0,
32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956,
23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764,
15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412,
11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316,
7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140,
5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092,
3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004,
2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980,
1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436,
1372, 1308, 1244, 1180, 1116, 1052, 988, 924,
876, 844, 812, 780, 748, 716, 684, 652,
620, 588, 556, 524, 492, 460, 428, 396,
372, 356, 340, 324, 308, 292, 276, 260,
244, 228, 212, 196, 180, 164, 148, 132,
120, 112, 104, 96, 88, 80, 72, 64,
56, 48, 40, 32, 24, 16, 8, 0
};
#endif /* MPLAYER_ALAW_H */

View File

@ -37,34 +37,14 @@
#include "vf.h"
#include "libvo/video_out.h"
extern const vd_functions_t mpcodecs_vd_null;
extern const vd_functions_t mpcodecs_vd_ffmpeg;
extern const vd_functions_t mpcodecs_vd_raw;
extern const vd_functions_t mpcodecs_vd_hmblck;
extern const vd_functions_t mpcodecs_vd_mpng;
extern const vd_functions_t mpcodecs_vd_ijpg;
extern const vd_functions_t mpcodecs_vd_mtga;
extern const vd_functions_t mpcodecs_vd_realvid;
extern const vd_functions_t mpcodecs_vd_lzo;
extern const vd_functions_t mpcodecs_vd_qtvideo;
/* Please do not add any new decoders here. If you want to implement a new
* decoder, add it to libavcodec, except for wrappers around external
* libraries and decoders requiring binary support. */
const vd_functions_t * const mpcodecs_vd_drivers[] = {
&mpcodecs_vd_null,
&mpcodecs_vd_ffmpeg,
&mpcodecs_vd_lzo,
&mpcodecs_vd_raw,
&mpcodecs_vd_hmblck,
#ifdef CONFIG_PNG
&mpcodecs_vd_mpng,
#endif
#ifdef CONFIG_JPEG
&mpcodecs_vd_ijpg,
#endif
&mpcodecs_vd_mtga,
/* Please do not add any new decoders here. If you want to implement a new
* decoder, add it to libavcodec, except for wrappers around external
* libraries and decoders requiring binary support. */

View File

@ -1,151 +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 "config.h"
#include "mp_msg.h"
#include "vd_internal.h"
static const vd_info_t info = {
"Hauppauge Macroblock/NV12/NV21 Decoder",
"hmblck",
"Alex <d18c7db@hotmail.com>, A'rpi, Alex Beregszaszi",
"Alex <d18c7db@hotmail.com>",
"uncompressed"
};
LIBVD_EXTERN(hmblck)
static void de_macro_y(unsigned char* dst,unsigned char* src,int dstride,int w,int h){
unsigned int y;
// descramble Y plane
for (y=0; y<h; y+=16) {
unsigned int x;
for (x=0; x<w; x+=16) {
unsigned int i;
for (i=0; i<16; i++) {
memcpy(dst + x + (y+i)*dstride, src, 16);
src+=16;
}
}
}
}
static void de_macro_uv(unsigned char* dstu,unsigned char* dstv,unsigned char* src,int dstride,int w,int h){
unsigned int y;
// descramble U/V plane
for (y=0; y<h; y+=16) {
unsigned int x;
for (x=0; x<w; x+=8) {
unsigned int i;
for (i=0; i<16; i++) {
int idx=x + (y+i)*dstride;
dstu[idx+0]=src[0]; dstv[idx+0]=src[1];
dstu[idx+1]=src[2]; dstv[idx+1]=src[3];
dstu[idx+2]=src[4]; dstv[idx+2]=src[5];
dstu[idx+3]=src[6]; dstv[idx+3]=src[7];
dstu[idx+4]=src[8]; dstv[idx+4]=src[9];
dstu[idx+5]=src[10]; dstv[idx+5]=src[11];
dstu[idx+6]=src[12]; dstv[idx+6]=src[13];
dstu[idx+7]=src[14]; dstv[idx+7]=src[15];
src+=16;
}
}
}
}
/*************************************************************************
* convert a nv12 buffer to yv12
*/
static int nv12_to_yv12(unsigned char *data, int len, mp_image_t* mpi, int swapped) {
unsigned int Y_size = mpi->width * mpi->height;
unsigned int UV_size = mpi->chroma_width * mpi->chroma_height;
unsigned int idx;
unsigned char *dst_Y = mpi->planes[0];
unsigned char *dst_U = mpi->planes[1];
unsigned char *dst_V = mpi->planes[2];
unsigned char *src = data + Y_size;
// sanity check raw stream
if ( (len != (Y_size + (UV_size<<1))) ) {
mp_msg(MSGT_DECVIDEO, MSGL_ERR,
"hmblck: Image size inconsistent with data size.\n");
return 0;
}
if (mpi->num_planes != 3) {
mp_msg(MSGT_DECVIDEO,MSGL_ERR,
"hmblck: Incorrect number of image planes.\n");
return 0;
}
// luma data is easy, just copy it
memcpy(dst_Y, data, Y_size);
// chroma data is interlaced UVUV... so deinterlace it
for(idx=0; idx<UV_size; idx++ ) {
*(dst_U + idx) = *(src + (idx<<1) + (swapped ? 1 : 0));
*(dst_V + idx) = *(src + (idx<<1) + (swapped ? 0 : 1));
}
return 1;
}
/*************************************************************************
* set/get/query special features/parameters
*/
static int control(sh_video_t *sh,int cmd, void *arg,...){
return CONTROL_UNKNOWN;
}
/*************************************************************************
* init driver
*/
static int init(sh_video_t *sh){
return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->format);
}
/*************************************************************************
* uninit driver
*/
static void uninit(sh_video_t *sh){
}
/*************************************************************************
* decode a frame
*/
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
mp_image_t* mpi;
if(len<=0) return NULL; // skipped frame
mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
sh->disp_w, sh->disp_h);
if(!mpi) return NULL;
if(sh->format == IMGFMT_HM12) {
//if(!de_macro(sh, data, len, flags, mpi)) return NULL;
de_macro_y(mpi->planes[0],data,mpi->stride[0],mpi->w,mpi->h);
de_macro_uv(mpi->planes[1],mpi->planes[2],
(unsigned char *)data+mpi->w*mpi->h,mpi->stride[1],
mpi->w/2,mpi->h/2);
} else {
if(!nv12_to_yv12(data, len, mpi,(sh->format == IMGFMT_NV21))) return NULL;
}
return mpi;
}
/*************************************************************************/

View File

@ -1,197 +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 <string.h>
#include "config.h"
#include "mp_msg.h"
#include <jpeglib.h>
#define UINT16 IJPG_UINT16
#define INT16 IJPG_INT16
#include <setjmp.h>
#include "mpbswap.h"
#include "vd_internal.h"
static const vd_info_t info = {
"JPEG Images decoder",
"ijpg",
"Pontscho",
"based on vd_mpng.c",
"uses Independent JPEG Group's jpeglib"
};
LIBVD_EXTERN(ijpg)
static int last_w=-1;
static int last_h=-1;
static int last_depth=-1;
// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
if (cmd == VDCTRL_QUERY_FORMAT) {
int format = *(int *)arg;
if ((last_depth == 24 && format == IMGFMT_RGB24) ||
(last_depth == 8 && format == IMGFMT_Y8 ))
return CONTROL_TRUE;
return CONTROL_FALSE;
}
return CONTROL_UNKNOWN;
}
// init driver
static int init(sh_video_t *sh){
last_w=-1;
return 1;
}
// uninit driver
static void uninit(sh_video_t *sh){
}
//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
typedef struct
{
struct jpeg_source_mgr pub;
unsigned char * inbuf;
int bufsize;
} my_source_mgr;
typedef my_source_mgr * my_src_ptr;
METHODDEF(void) init_source (j_decompress_ptr cinfo)
{
}
METHODDEF(boolean) fill_input_buffer (j_decompress_ptr cinfo)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
src->pub.next_input_byte = src->inbuf;
src->pub.bytes_in_buffer = src->bufsize;
return TRUE;
}
METHODDEF(void) skip_input_data (j_decompress_ptr cinfo, long num_bytes)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
if (num_bytes > 0)
{
while (num_bytes > (long) src->pub.bytes_in_buffer)
{
num_bytes -= (long) src->pub.bytes_in_buffer;
(void) fill_input_buffer(cinfo);
}
src->pub.next_input_byte += (size_t) num_bytes;
src->pub.bytes_in_buffer -= (size_t) num_bytes;
}
}
METHODDEF(void) term_source (j_decompress_ptr cinfo) { }
static void jpeg_buf_src (j_decompress_ptr cinfo, char * inbuf, int bufsize)
{
my_src_ptr src;
if (cinfo->src == NULL) cinfo->src=malloc( sizeof( my_source_mgr ) );
src = (my_src_ptr) cinfo->src;
src->pub.init_source = init_source;
src->pub.fill_input_buffer = fill_input_buffer;
src->pub.skip_input_data = skip_input_data;
src->pub.resync_to_restart = jpeg_resync_to_restart;
src->pub.term_source = term_source;
src->inbuf = inbuf;
src->bufsize=bufsize;
src->pub.bytes_in_buffer = 0;
src->pub.next_input_byte = NULL;
}
struct my_error_mgr
{
struct jpeg_error_mgr pub;
jmp_buf setjmp_buffer;
};
typedef struct my_error_mgr * my_error_ptr;
METHODDEF(void) my_error_exit (j_common_ptr cinfo)
{
my_error_ptr myerr=(my_error_ptr) cinfo->err;
(*cinfo->err->output_message) (cinfo);
longjmp(myerr->setjmp_buffer, 1);
}
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
mp_image_t * mpi = NULL;
int width,height,depth,i;
if ( len <= 0 ) return NULL; // skipped frame
memset(&cinfo, 0, sizeof(cinfo));
memset(&jerr, 0, sizeof(jerr));
cinfo.err=jpeg_std_error( &jerr.pub );
jerr.pub.error_exit=my_error_exit;
if( setjmp( jerr.setjmp_buffer ) )
{
mp_msg( MSGT_DECVIDEO,MSGL_ERR,"[ijpg] setjmp error ...\n" );
return NULL;
}
jpeg_create_decompress( &cinfo );
jpeg_buf_src( &cinfo,data,len );
jpeg_read_header( &cinfo,TRUE );
sh->disp_w=width=cinfo.image_width;
sh->disp_h=height=cinfo.image_height;
jpeg_start_decompress( &cinfo );
depth=cinfo.output_components * 8;
switch( depth ) {
case 8:
case 24: break;
default: mp_msg( MSGT_DECVIDEO,MSGL_ERR,"Sorry, unsupported JPEG colorspace: %d.\n",depth ); return NULL;
}
if ( last_w!=width || last_h!=height || last_depth != depth )
{
last_depth = depth;
if(!mpcodecs_config_vo( sh,width,height, depth == 8 ? IMGFMT_Y8 : IMGFMT_RGB24 )) return NULL;
last_w=width; last_h=height;
}
mpi=mpcodecs_get_image( sh,MP_IMGTYPE_TEMP,MP_IMGFLAG_ACCEPT_STRIDE,width,height );
if ( !mpi ) return NULL;
for ( i=0;i < height;i++ )
{
unsigned char * drow = mpi->planes[0] + mpi->stride[0] * i;
jpeg_read_scanlines( &cinfo,(JSAMPLE**)&drow,1 );
}
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
return mpi;
}

View File

@ -1,166 +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 "config.h"
#include "mp_msg.h"
#include "vd_internal.h"
#include "libavutil/lzo.h"
#define MOD_NAME "DecLZO"
static const vd_info_t info = {
"LZO compressed Video",
"lzo",
"Tilmann Bitterberg",
"Transcode development team <http://www.theorie.physik.uni-goettingen.de/~ostreich/transcode/>",
"based on liblzo: http://www.oberhumer.com/opensource/lzo/"
};
LIBVD_EXTERN(lzo)
typedef struct {
uint8_t *buffer;
int bufsz;
int codec;
} lzo_context_t;
// to set/get/query special features/parameters
static int control (sh_video_t *sh, int cmd, void* arg, ...)
{
lzo_context_t *priv = sh->context;
switch(cmd){
case VDCTRL_QUERY_FORMAT:
if (*(int *)arg == priv->codec) return CONTROL_TRUE;
return CONTROL_FALSE;
}
return CONTROL_UNKNOWN;
}
// init driver
static int init(sh_video_t *sh)
{
lzo_context_t *priv;
if (sh->bih->biSizeImage <= 0) {
mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] Invalid frame size\n", MOD_NAME);
return 0;
}
priv = malloc(sizeof(lzo_context_t));
if (!priv)
{
mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] memory allocation failed\n", MOD_NAME);
return 0;
}
priv->bufsz = sh->bih->biSizeImage;
priv->buffer = malloc(priv->bufsz + AV_LZO_OUTPUT_PADDING);
priv->codec = -1;
sh->context = priv;
return 1;
}
// uninit driver
static void uninit(sh_video_t *sh)
{
lzo_context_t *priv = sh->context;
if (priv)
{
free(priv->buffer);
free(priv);
}
sh->context = NULL;
}
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
{
int r;
mp_image_t* mpi;
lzo_context_t *priv = sh->context;
int w = priv->bufsz;
if (len <= 0) {
return NULL; // skipped frame
}
r = av_lzo1x_decode(priv->buffer, &w, data, &len);
if (r) {
/* this should NEVER happen */
mp_msg (MSGT_DECVIDEO, MSGL_ERR,
"[%s] internal error - decompression failed: %d\n", MOD_NAME, r);
return NULL;
}
if (priv->codec == -1) {
// detect RGB24 vs. YV12 via decoded size
mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] 2 depth %d, format %d data %p len (%d) (%d)\n",
MOD_NAME, sh->bih->biBitCount, sh->format, data, len, sh->bih->biSizeImage
);
if (w == 0) {
priv->codec = IMGFMT_BGR24;
mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] codec chosen is BGR24\n", MOD_NAME);
} else if (w == (sh->bih->biSizeImage)/2) {
priv->codec = IMGFMT_YV12;
mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] codec chosen is YV12\n", MOD_NAME);
} else {
priv->codec = -1;
mp_msg(MSGT_DECVIDEO,MSGL_ERR,"[%s] Unsupported out_fmt\n", MOD_NAME);
return NULL;
}
if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,priv->codec)) {
priv->codec = -1;
return NULL;
}
}
mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,
sh->disp_w, sh->disp_h);
if (!mpi) {
mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] mpcodecs_get_image failed\n", MOD_NAME);
return NULL;
}
mpi->planes[0] = priv->buffer;
if (priv->codec == IMGFMT_BGR24)
mpi->stride[0] = 3 * sh->disp_w;
else {
mpi->stride[0] = sh->disp_w;
mpi->planes[2] = priv->buffer + sh->disp_w*sh->disp_h;
mpi->stride[2] = sh->disp_w / 2;
mpi->planes[1] = priv->buffer + sh->disp_w*sh->disp_h*5/4;
mpi->stride[1] = sh->disp_w / 2;
}
mp_msg (MSGT_DECVIDEO, MSGL_DBG2,
"[%s] decompressed %lu bytes into %lu bytes\n", MOD_NAME,
(long) len, (long)w);
return mpi;
}

View File

@ -1,182 +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 "config.h"
#include "mp_msg.h"
#include <png.h>
#include "libavutil/common.h"
#include "mpbswap.h"
#include "libvo/fastmemcpy.h"
#include "vd_internal.h"
static const vd_info_t info = {
"PNG Images decoder",
"mpng",
"A'rpi",
".so, based on mpng.c",
"uses libpng, 8bpp modes not supported yet"
};
LIBVD_EXTERN(mpng)
static unsigned int out_fmt=0;
static int last_w=-1;
static int last_h=-1;
static int last_c=-1;
// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
switch (cmd)
{
case VDCTRL_QUERY_FORMAT:
if (*((int *) arg) == out_fmt) return CONTROL_TRUE;
return CONTROL_FALSE;
}
return CONTROL_UNKNOWN;
}
// init driver
static int init(sh_video_t *sh){
last_w=-1;
return 1;
}
// uninit driver
static void uninit(sh_video_t *sh){
}
//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
static int pngPointer;
static int pngLength;
static void pngReadFN( png_structp pngstr,png_bytep buffer,png_size_t size )
{
char * p = png_get_io_ptr(pngstr);
if(size>pngLength-pngPointer && pngLength>=pngPointer) size=pngLength-pngPointer;
fast_memcpy( buffer,(char *)&p[pngPointer],size );
pngPointer+=size;
}
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
png_structp png;
png_infop info;
png_infop endinfo;
// png_bytep data;
png_bytep * row_p;
png_uint_32 png_width=0,png_height=0;
int depth,color;
png_uint_32 i;
png_byte color_type;
mp_image_t* mpi;
int cols;
png_colorp pal;
unsigned char *p;
if(len<=0) return NULL; // skipped frame
png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
info=png_create_info_struct( png );
endinfo=png_create_info_struct( png );
pngPointer=8;
pngLength=len;
png_set_read_fn( png,data,pngReadFN );
png_set_strip_16( png );
png_set_sig_bytes( png,8 );
png_read_info( png,info );
png_get_IHDR( png,info,&png_width,&png_height,&depth,&color,NULL,NULL,NULL );
png_set_bgr( png );
color_type=png_get_color_type(png, info);
switch( color_type ) {
case PNG_COLOR_TYPE_GRAY_ALPHA:
mp_msg( MSGT_DECVIDEO,MSGL_INFO,"Sorry gray scaled png with alpha channel not supported at moment.\n" );
break;
case PNG_COLOR_TYPE_GRAY:
out_fmt=IMGFMT_Y800;
break;
case PNG_COLOR_TYPE_PALETTE:
out_fmt=IMGFMT_BGR8;
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
out_fmt=IMGFMT_BGR32;
break;
case PNG_COLOR_TYPE_RGB:
out_fmt=IMGFMT_BGR24;
break;
default:
mp_msg( MSGT_DECVIDEO,MSGL_INFO,"Sorry, unsupported PNG colorspace: %d.\n" ,color_type);
}
// (re)init libvo if image parameters changed (width/height/colorspace)
if(last_w!=png_width || last_h!=png_height || last_c!=out_fmt){
last_w=png_width; last_h=png_height; last_c=out_fmt;
if(!out_fmt) return NULL;
if(!mpcodecs_config_vo(sh,png_width,png_height,out_fmt)) return NULL;
}
#if 0
switch( info->color_type )
{
case PNG_COLOR_TYPE_GRAY_ALPHA: printf( "[png] used GrayA -> stripping alpha channel\n" ); break;
case PNG_COLOR_TYPE_GRAY: printf( "[png] used Gray -> rgb\n" ); break;
case PNG_COLOR_TYPE_PALETTE: printf( "[png] used palette -> rgb\n" ); break;
case PNG_COLOR_TYPE_RGB_ALPHA: printf( "[png] used RGBA -> stripping alpha channel\n" ); break;
case PNG_COLOR_TYPE_RGB: printf( "[png] read rgb datas.\n" ); break;
}
#endif
mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
png_width,png_height);
if(!mpi) return NULL;
// Let's DECODE!
row_p=malloc( sizeof( png_bytep ) * png_height );
//png_get_rowbytes( png,info )
for ( i=0; i < png_height; i++ ) row_p[i]=mpi->planes[0] + mpi->stride[0]*i;
png_read_image( png,row_p );
free( row_p );
if (out_fmt==IMGFMT_BGR8) {
png_get_PLTE( png,info,&pal,&cols );
mpi->planes[1] = realloc(mpi->planes[1], 4*cols);
p = mpi->planes[1];
for (i = 0; i < cols; i++) {
*p++ = pal[i].blue;
*p++ = pal[i].green;
*p++ = pal[i].red;
*p++ = 0;
}
}
png_read_end( png,endinfo );
png_destroy_read_struct( &png,&info,&endinfo );
return mpi;
}

View File

@ -1,252 +0,0 @@
/*
* based on: XreaL's x_r_img_tga.* (http://www.sourceforge.net/projects/xreal/)
* libtarga.*
* xli's tga.*
*
* Copyright (c) 2002 Tilman Sauerbeck <tsauerbeck@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 <string.h>
#include <libavutil/intreadwrite.h>
#include "config.h"
#include "mp_msg.h"
#include "libvo/fastmemcpy.h"
#include "vd_internal.h"
static const vd_info_t info =
{
"TGA Images decoder",
"mtga",
"Tilman Sauerbeck, A'rpi",
"Tilman Sauerbeck",
"only 24bpp and 32bpp RGB targa files support so far"
};
LIBVD_EXTERN(mtga)
typedef enum
{
TGA_NO_DATA,
TGA_UNCOMP_PALETTED,
TGA_UNCOMP_TRUECOLOR,
TGA_UNCOMP_GRAYSCALE,
TGA_RLE_PALETTED = 9,
TGA_RLE_TRUECOLOR,
TGA_RLE_GRAYSCALE
} TGAImageType;
typedef struct
{
unsigned char id_len;
unsigned short img_type;
unsigned short width;
unsigned short height;
unsigned char bpp;
unsigned char origin; /* 0 = lower left, 1 = upper left */
unsigned short start_row;
short increment;
} TGAInfo;
static unsigned int out_fmt = 0;
static int last_w = -1;
static int last_h = -1;
static int last_c = -1;
/* to set/get/query special features/parameters */
static int control(sh_video_t *sh, int cmd, void *arg, ...)
{
switch (cmd)
{
case VDCTRL_QUERY_FORMAT:
if (*((int *) arg) == out_fmt) return CONTROL_TRUE;
return CONTROL_FALSE;
}
return CONTROL_UNKNOWN;
}
/* init driver */
static int init(sh_video_t *sh)
{
sh->context = calloc(1, sizeof(TGAInfo));
last_w = -1;
return 1;
}
/* uninit driver */
static void uninit(sh_video_t *sh)
{
TGAInfo *info = sh->context;
free(info);
return;
}
/* decode a runlength-encoded tga */
static void decode_rle_tga(TGAInfo *info, unsigned char *data, mp_image_t *mpi)
{
int row, col, replen, i, num_bytes = info->bpp / 8;
unsigned char repetitions, packet_header, *final;
/* see line 207 to see why this loop is set up like this */
for (row = info->start_row; (!info->origin && row) || (info->origin && row < info->height); row += info->increment)
{
final = mpi->planes[0] + mpi->stride[0] * row;
for (col = 0; col < info->width; col += repetitions)
{
packet_header = *data++;
repetitions = (1 + (packet_header & 0x7f));
replen = repetitions * num_bytes;
if (packet_header & 0x80) /* runlength encoded packet */
{
memcpy(final, data, num_bytes);
// Note: this will be slow when DR to vram!
i=num_bytes;
while(2*i<=replen){
memcpy(final+i,final,i);
i*=2;
}
memcpy(final+i,final,replen-i);
data += num_bytes;
}
else /* raw packet */
{
fast_memcpy(final, data, replen);
data += replen;
}
final += replen;
}
}
return;
}
static void decode_uncompressed_tga(TGAInfo *info, unsigned char *data, mp_image_t *mpi)
{
unsigned char *final;
int row, num_bytes = info->bpp / 8;
/* see line 207 to see why this loop is set up like this */
for (row = info->start_row; (!info->origin && row) || (info->origin && row < info->height); row += info->increment)
{
final = mpi->planes[0] + mpi->stride[0] * row;
fast_memcpy(final, data, info->width * num_bytes);
data += info->width * num_bytes;
}
return;
}
static short read_tga_header(unsigned char *buf, TGAInfo *info)
{
info->id_len = buf[0];
info->img_type = buf[2];
/* targa data is always stored in little endian byte order */
info->width = AV_RL16(&buf[12]);
info->height = AV_RL16(&buf[14]);
info->bpp = buf[16];
info->origin = (buf[17] & 0x20) >> 5;
/* FIXME check for valid targa data */
return 0;
}
/* decode a frame */
static mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags)
{
TGAInfo *info = sh->context;
unsigned char *data = raw;
mp_image_t *mpi;
if (len <= 0)
return NULL; /* skip frame */
read_tga_header(data, info); /* read information about the file */
if (info->bpp == 24)
out_fmt = IMGFMT_BGR24;
else if (info->bpp == 32)
out_fmt = IMGFMT_BGR32;
else
{
mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Unsupported TGA type! depth=%d\n",info->bpp);
return NULL;
}
if (info->img_type != TGA_UNCOMP_TRUECOLOR && info->img_type != TGA_RLE_TRUECOLOR) /* not a true color image */
{
mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Unsupported TGA type: %i!\n", info->img_type);
return NULL;
}
/* if img.origin is 0, we decode from bottom to top. if it's 1, we decode from top to bottom */
info->start_row = (info->origin) ? 0 : info->height - 1;
info->increment = (info->origin) ? 1 : -1;
/* set data to the beginning of the image data */
data += 18 + info->id_len;
/* (re)init libvo if image parameters changed (width/height/colorspace) */
if (last_w != info->width || last_h != info->height || last_c != out_fmt)
{
last_w = info->width;
last_h = info->height;
last_c = out_fmt;
if (!out_fmt || !mpcodecs_config_vo(sh, info->width, info->height, out_fmt))
return NULL;
}
if (!(mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, info->width, info->height)))
return NULL;
/* finally decode the image */
if (info->img_type == TGA_UNCOMP_TRUECOLOR)
decode_uncompressed_tga(info, data, mpi);
else if (info->img_type == TGA_RLE_TRUECOLOR)
decode_rle_tga(info, data, mpi);
// else
// mpi = NULL;
return mpi;
}

View File

@ -1,142 +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 "config.h"
#include "mp_msg.h"
#include "vd_internal.h"
static const vd_info_t info = {
"RAW Uncompressed Video",
"raw",
"A'rpi",
"A'rpi & Alex",
"uncompressed"
};
LIBVD_EXTERN(raw)
// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
int format = sh->bih ? sh->bih->biCompression : sh->format;
switch(cmd){
case VDCTRL_QUERY_FORMAT:
if (*(int *)arg == format) return CONTROL_TRUE;
if (*(int *)arg == IMGFMT_YUY2 && format == MKTAG('y', 'u', 'v', '2')) return CONTROL_TRUE;
return CONTROL_FALSE;
}
return CONTROL_UNKNOWN;
}
// init driver
static int init(sh_video_t *sh){
// set format fourcc for raw RGB:
if(sh->bih && sh->bih->biCompression==0){ // set based on bit depth
switch(sh->bih->biBitCount){
case 1: sh->bih->biCompression=IMGFMT_BGR1; break;
case 4: sh->bih->biCompression=IMGFMT_BGR4; break;
case 8: sh->bih->biCompression=IMGFMT_BGR8; break;
case 15: sh->bih->biCompression=IMGFMT_BGR15; break;
// workaround bitcount==16 => bgr15 case for avi files:
case 16: sh->bih->biCompression=(sh->format)?IMGFMT_BGR16:IMGFMT_BGR15; break;
case 24: sh->bih->biCompression=IMGFMT_BGR24; break;
case 32: sh->bih->biCompression=IMGFMT_BGR32; break;
default:
mp_msg(MSGT_DECVIDEO,MSGL_WARN,"RAW: depth %d not supported\n",sh->bih->biBitCount);
}
}
return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih ? sh->bih->biCompression : sh->format);
}
// uninit driver
static void uninit(sh_video_t *sh){
}
//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
mp_image_t* mpi;
int frame_size;
int format = sh->bih ? sh->bih->biCompression : sh->format;
if(len<=0) return NULL; // skipped frame
mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,
sh->disp_w, sh->disp_h);
if(!mpi) return NULL;
if(mpi->flags&MP_IMGFLAG_PLANAR){
// TODO !!!
mpi->planes[0]=data;
mpi->stride[0]=mpi->width;
frame_size=mpi->stride[0]*mpi->h;
if((mpi->imgfmt == IMGFMT_NV12) || (mpi->imgfmt == IMGFMT_NV21))
{
mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height;
mpi->stride[1]=mpi->chroma_width;
frame_size+=mpi->chroma_width*mpi->chroma_height;
} else if(mpi->flags&MP_IMGFLAG_YUV) {
int cb=2, cr=1;
if(mpi->flags&MP_IMGFLAG_SWAPPED) {
cb=1; cr=2;
}
// Support for some common Planar YUV formats
/* YV12,I420,IYUV */
mpi->planes[cb]=mpi->planes[0]+mpi->width*mpi->height;
mpi->stride[cb]=mpi->chroma_width;
mpi->planes[cr]=mpi->planes[cb]+mpi->chroma_width*mpi->chroma_height;
mpi->stride[cr]=mpi->chroma_width;
frame_size+=2*mpi->chroma_width*mpi->chroma_height;
}
} else {
mpi->planes[0]=data;
mpi->stride[0]=mpi->width*(mpi->bpp/8);
// .AVI files has uncompressed lines 4-byte aligned:
if(sh->format==0 || sh->format==3) mpi->stride[0]=(mpi->stride[0]+3)&(~3);
if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){
// export palette:
mpi->planes[1]=sh->bih ? (unsigned char*)(sh->bih+1) : NULL;
#if 0
printf("Exporting palette: %p !!\n",mpi->planes[1]);
{ unsigned char* p=mpi->planes[1];
int i;
for(i=0;i<64;i++) printf("%3d: %02X %02X %02X (%02X)\n",i,p[4*i],p[4*i+1],p[4*i+2],p[4*i+3]);
}
#endif
}
frame_size=mpi->stride[0]*mpi->h;
if (len >= frame_size && format == MKTAG('y', 'u', 'v', '2')) {
int i;
for (i = 1; i < frame_size; i += 2)
mpi->planes[0][i] ^= 128;
}
if(mpi->bpp<8) frame_size=frame_size*mpi->bpp/8;
}
if(len<frame_size){
mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Frame too small! (%d<%d) Wrong format?\n",
len,frame_size);
return NULL;
}
return mpi;
}

View File

@ -1,122 +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 <stdint.h>
#include "config.h"
#include "mp3_hdr.h"
#include "mp_msg.h"
//----------------------- mp3 audio frame header parser -----------------------
static const uint16_t tabsel_123[2][3][16] = {
{ {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0},
{0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,0},
{0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,0} },
{ {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,0},
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0},
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0} }
};
static const int freqs[9] = { 44100, 48000, 32000, // MPEG 1.0
22050, 24000, 16000, // MPEG 2.0
11025, 12000, 8000}; // MPEG 2.5
/*
* return frame size or -1 (bad frame)
*/
int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* srate, int* spf, int* mpa_layer, int* br){
int stereo,lsf,framesize,padding,bitrate_index,sampling_frequency, divisor;
int bitrate;
int layer;
static const int mult[3] = { 12000, 144000, 144000 };
uint32_t newhead =
hbuf[0] << 24 |
hbuf[1] << 16 |
hbuf[2] << 8 |
hbuf[3];
// head_check:
if( (newhead & 0xffe00000) != 0xffe00000 ){
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"head_check failed\n");
return -1;
}
layer = 4-((newhead>>17)&3);
if(layer==4){
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"not layer-1/2/3\n");
return -1;
}
sampling_frequency = (newhead>>10)&0x3; // valid: 0..2
if(sampling_frequency==3){
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid sampling_frequency\n");
return -1;
}
if( newhead & (1<<20) ) {
// MPEG 1.0 (lsf==0) or MPEG 2.0 (lsf==1)
lsf = !(newhead & (1<<19));
sampling_frequency += lsf*3;
} else {
// MPEG 2.5
lsf = 1;
sampling_frequency += 6;
}
bitrate_index = (newhead>>12)&0xf; // valid: 1..14
padding = (newhead>>9)&0x1;
stereo = ( ((newhead>>6)&0x3) == 3) ? 1 : 2;
bitrate = tabsel_123[lsf][layer-1][bitrate_index];
framesize = bitrate * mult[layer-1];
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"FRAMESIZE: %d, layer: %d, bitrate: %d, mult: %d\n",
framesize, layer, tabsel_123[lsf][layer-1][bitrate_index], mult[layer-1]);
if(!framesize){
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid framesize/bitrate_index\n");
return -1;
}
divisor = layer == 3 ? (freqs[sampling_frequency] << lsf) : freqs[sampling_frequency];
framesize /= divisor;
framesize += padding;
if(layer==1)
framesize *= 4;
if(srate)
*srate = freqs[sampling_frequency];
if(spf) {
if(layer == 1)
*spf = 384;
else if(layer == 2)
*spf = 1152;
else if(sampling_frequency > 2) // not 1.0
*spf = 576;
else
*spf = 1152;
}
if(mpa_layer) *mpa_layer = layer;
if(chans) *chans = stereo;
if(br) *br = bitrate;
return framesize;
}

View File

@ -1,36 +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.
*/
#ifndef MPLAYER_MP3_HDR_H
#define MPLAYER_MP3_HDR_H
#include <stddef.h>
int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* freq, int* spf, int* mpa_layer, int* br);
#define mp_decode_mp3_header(hbuf) mp_get_mp3_header(hbuf,NULL,NULL,NULL,NULL,NULL)
static inline int mp_check_mp3_header(unsigned int head){
unsigned char tmp[4] = {head >> 24, head >> 16, head >> 8, head};
if( (head & 0xffe00000) != 0xffe00000 ||
(head & 0x00000c00) == 0x00000c00) return 0;
if(mp_decode_mp3_header(tmp)<=0) return 0;
return 1;
}
#endif /* MPLAYER_MP3_HDR_H */

View File

@ -1,589 +0,0 @@
/*
* default palettes for QuickTime files
* Automatically generated from a utility derived from XAnim:
* http://xanim.va.pubnix.com/home.html
*
* 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.
*/
#ifndef MPLAYER_QTPALETTE_H
#define MPLAYER_QTPALETTE_H
static const unsigned char qt_default_palette_4[4 * 4] = {
0x5E, 0x65, 0x93, 0x00,
0xFF, 0xFF, 0xFF, 0x00,
0xAB, 0xD0, 0xDF, 0x00,
0x00, 0x00, 0x00, 0x00
};
static const unsigned char qt_default_palette_16[16 * 4] = {
0xFF, 0xFB, 0xFF, 0x00,
0xBB, 0xD9, 0xEF, 0x00,
0xB1, 0xC9, 0xE8, 0x00,
0x5E, 0x65, 0x93, 0x00,
0xE8, 0xDE, 0xFC, 0x00,
0x91, 0x88, 0x9D, 0x00,
0xFF, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0xFF, 0x00,
0x37, 0x48, 0x47, 0x00,
0x55, 0x5E, 0x7A, 0x00,
0xAB, 0xD0, 0xDF, 0x00,
0xF9, 0xFB, 0xFF, 0x00,
0xC5, 0xCA, 0xE8, 0x00,
0x77, 0x7C, 0x8A, 0x00,
0x00, 0x00, 0x00, 0x00
};
static const unsigned char qt_default_palette_256[256 * 4] = {
/* 0, 0x00 */ 0xFF, 0xFF, 0xFF, 0x00,
/* 1, 0x01 */ 0xCC, 0xFF, 0xFF, 0x00,
/* 2, 0x02 */ 0x99, 0xFF, 0xFF, 0x00,
/* 3, 0x03 */ 0x66, 0xFF, 0xFF, 0x00,
/* 4, 0x04 */ 0x33, 0xFF, 0xFF, 0x00,
/* 5, 0x05 */ 0x00, 0xFF, 0xFF, 0x00,
/* 6, 0x06 */ 0xFF, 0xCC, 0xFF, 0x00,
/* 7, 0x07 */ 0xCC, 0xCC, 0xFF, 0x00,
/* 8, 0x08 */ 0x99, 0xCC, 0xFF, 0x00,
/* 9, 0x09 */ 0x66, 0xCC, 0xFF, 0x00,
/* 10, 0x0A */ 0x33, 0xCC, 0xFF, 0x00,
/* 11, 0x0B */ 0x00, 0xCC, 0xFF, 0x00,
/* 12, 0x0C */ 0xFF, 0x99, 0xFF, 0x00,
/* 13, 0x0D */ 0xCC, 0x99, 0xFF, 0x00,
/* 14, 0x0E */ 0x99, 0x99, 0xFF, 0x00,
/* 15, 0x0F */ 0x66, 0x99, 0xFF, 0x00,
/* 16, 0x10 */ 0x33, 0x99, 0xFF, 0x00,
/* 17, 0x11 */ 0x00, 0x99, 0xFF, 0x00,
/* 18, 0x12 */ 0xFF, 0x66, 0xFF, 0x00,
/* 19, 0x13 */ 0xCC, 0x66, 0xFF, 0x00,
/* 20, 0x14 */ 0x99, 0x66, 0xFF, 0x00,
/* 21, 0x15 */ 0x66, 0x66, 0xFF, 0x00,
/* 22, 0x16 */ 0x33, 0x66, 0xFF, 0x00,
/* 23, 0x17 */ 0x00, 0x66, 0xFF, 0x00,
/* 24, 0x18 */ 0xFF, 0x33, 0xFF, 0x00,
/* 25, 0x19 */ 0xCC, 0x33, 0xFF, 0x00,
/* 26, 0x1A */ 0x99, 0x33, 0xFF, 0x00,
/* 27, 0x1B */ 0x66, 0x33, 0xFF, 0x00,
/* 28, 0x1C */ 0x33, 0x33, 0xFF, 0x00,
/* 29, 0x1D */ 0x00, 0x33, 0xFF, 0x00,
/* 30, 0x1E */ 0xFF, 0x00, 0xFF, 0x00,
/* 31, 0x1F */ 0xCC, 0x00, 0xFF, 0x00,
/* 32, 0x20 */ 0x99, 0x00, 0xFF, 0x00,
/* 33, 0x21 */ 0x66, 0x00, 0xFF, 0x00,
/* 34, 0x22 */ 0x33, 0x00, 0xFF, 0x00,
/* 35, 0x23 */ 0x00, 0x00, 0xFF, 0x00,
/* 36, 0x24 */ 0xFF, 0xFF, 0xCC, 0x00,
/* 37, 0x25 */ 0xCC, 0xFF, 0xCC, 0x00,
/* 38, 0x26 */ 0x99, 0xFF, 0xCC, 0x00,
/* 39, 0x27 */ 0x66, 0xFF, 0xCC, 0x00,
/* 40, 0x28 */ 0x33, 0xFF, 0xCC, 0x00,
/* 41, 0x29 */ 0x00, 0xFF, 0xCC, 0x00,
/* 42, 0x2A */ 0xFF, 0xCC, 0xCC, 0x00,
/* 43, 0x2B */ 0xCC, 0xCC, 0xCC, 0x00,
/* 44, 0x2C */ 0x99, 0xCC, 0xCC, 0x00,
/* 45, 0x2D */ 0x66, 0xCC, 0xCC, 0x00,
/* 46, 0x2E */ 0x33, 0xCC, 0xCC, 0x00,
/* 47, 0x2F */ 0x00, 0xCC, 0xCC, 0x00,
/* 48, 0x30 */ 0xFF, 0x99, 0xCC, 0x00,
/* 49, 0x31 */ 0xCC, 0x99, 0xCC, 0x00,
/* 50, 0x32 */ 0x99, 0x99, 0xCC, 0x00,
/* 51, 0x33 */ 0x66, 0x99, 0xCC, 0x00,
/* 52, 0x34 */ 0x33, 0x99, 0xCC, 0x00,
/* 53, 0x35 */ 0x00, 0x99, 0xCC, 0x00,
/* 54, 0x36 */ 0xFF, 0x66, 0xCC, 0x00,
/* 55, 0x37 */ 0xCC, 0x66, 0xCC, 0x00,
/* 56, 0x38 */ 0x99, 0x66, 0xCC, 0x00,
/* 57, 0x39 */ 0x66, 0x66, 0xCC, 0x00,
/* 58, 0x3A */ 0x33, 0x66, 0xCC, 0x00,
/* 59, 0x3B */ 0x00, 0x66, 0xCC, 0x00,
/* 60, 0x3C */ 0xFF, 0x33, 0xCC, 0x00,
/* 61, 0x3D */ 0xCC, 0x33, 0xCC, 0x00,
/* 62, 0x3E */ 0x99, 0x33, 0xCC, 0x00,
/* 63, 0x3F */ 0x66, 0x33, 0xCC, 0x00,
/* 64, 0x40 */ 0x33, 0x33, 0xCC, 0x00,
/* 65, 0x41 */ 0x00, 0x33, 0xCC, 0x00,
/* 66, 0x42 */ 0xFF, 0x00, 0xCC, 0x00,
/* 67, 0x43 */ 0xCC, 0x00, 0xCC, 0x00,
/* 68, 0x44 */ 0x99, 0x00, 0xCC, 0x00,
/* 69, 0x45 */ 0x66, 0x00, 0xCC, 0x00,
/* 70, 0x46 */ 0x33, 0x00, 0xCC, 0x00,
/* 71, 0x47 */ 0x00, 0x00, 0xCC, 0x00,
/* 72, 0x48 */ 0xFF, 0xFF, 0x99, 0x00,
/* 73, 0x49 */ 0xCC, 0xFF, 0x99, 0x00,
/* 74, 0x4A */ 0x99, 0xFF, 0x99, 0x00,
/* 75, 0x4B */ 0x66, 0xFF, 0x99, 0x00,
/* 76, 0x4C */ 0x33, 0xFF, 0x99, 0x00,
/* 77, 0x4D */ 0x00, 0xFF, 0x99, 0x00,
/* 78, 0x4E */ 0xFF, 0xCC, 0x99, 0x00,
/* 79, 0x4F */ 0xCC, 0xCC, 0x99, 0x00,
/* 80, 0x50 */ 0x99, 0xCC, 0x99, 0x00,
/* 81, 0x51 */ 0x66, 0xCC, 0x99, 0x00,
/* 82, 0x52 */ 0x33, 0xCC, 0x99, 0x00,
/* 83, 0x53 */ 0x00, 0xCC, 0x99, 0x00,
/* 84, 0x54 */ 0xFF, 0x99, 0x99, 0x00,
/* 85, 0x55 */ 0xCC, 0x99, 0x99, 0x00,
/* 86, 0x56 */ 0x99, 0x99, 0x99, 0x00,
/* 87, 0x57 */ 0x66, 0x99, 0x99, 0x00,
/* 88, 0x58 */ 0x33, 0x99, 0x99, 0x00,
/* 89, 0x59 */ 0x00, 0x99, 0x99, 0x00,
/* 90, 0x5A */ 0xFF, 0x66, 0x99, 0x00,
/* 91, 0x5B */ 0xCC, 0x66, 0x99, 0x00,
/* 92, 0x5C */ 0x99, 0x66, 0x99, 0x00,
/* 93, 0x5D */ 0x66, 0x66, 0x99, 0x00,
/* 94, 0x5E */ 0x33, 0x66, 0x99, 0x00,
/* 95, 0x5F */ 0x00, 0x66, 0x99, 0x00,
/* 96, 0x60 */ 0xFF, 0x33, 0x99, 0x00,
/* 97, 0x61 */ 0xCC, 0x33, 0x99, 0x00,
/* 98, 0x62 */ 0x99, 0x33, 0x99, 0x00,
/* 99, 0x63 */ 0x66, 0x33, 0x99, 0x00,
/* 100, 0x64 */ 0x33, 0x33, 0x99, 0x00,
/* 101, 0x65 */ 0x00, 0x33, 0x99, 0x00,
/* 102, 0x66 */ 0xFF, 0x00, 0x99, 0x00,
/* 103, 0x67 */ 0xCC, 0x00, 0x99, 0x00,
/* 104, 0x68 */ 0x99, 0x00, 0x99, 0x00,
/* 105, 0x69 */ 0x66, 0x00, 0x99, 0x00,
/* 106, 0x6A */ 0x33, 0x00, 0x99, 0x00,
/* 107, 0x6B */ 0x00, 0x00, 0x99, 0x00,
/* 108, 0x6C */ 0xFF, 0xFF, 0x66, 0x00,
/* 109, 0x6D */ 0xCC, 0xFF, 0x66, 0x00,
/* 110, 0x6E */ 0x99, 0xFF, 0x66, 0x00,
/* 111, 0x6F */ 0x66, 0xFF, 0x66, 0x00,
/* 112, 0x70 */ 0x33, 0xFF, 0x66, 0x00,
/* 113, 0x71 */ 0x00, 0xFF, 0x66, 0x00,
/* 114, 0x72 */ 0xFF, 0xCC, 0x66, 0x00,
/* 115, 0x73 */ 0xCC, 0xCC, 0x66, 0x00,
/* 116, 0x74 */ 0x99, 0xCC, 0x66, 0x00,
/* 117, 0x75 */ 0x66, 0xCC, 0x66, 0x00,
/* 118, 0x76 */ 0x33, 0xCC, 0x66, 0x00,
/* 119, 0x77 */ 0x00, 0xCC, 0x66, 0x00,
/* 120, 0x78 */ 0xFF, 0x99, 0x66, 0x00,
/* 121, 0x79 */ 0xCC, 0x99, 0x66, 0x00,
/* 122, 0x7A */ 0x99, 0x99, 0x66, 0x00,
/* 123, 0x7B */ 0x66, 0x99, 0x66, 0x00,
/* 124, 0x7C */ 0x33, 0x99, 0x66, 0x00,
/* 125, 0x7D */ 0x00, 0x99, 0x66, 0x00,
/* 126, 0x7E */ 0xFF, 0x66, 0x66, 0x00,
/* 127, 0x7F */ 0xCC, 0x66, 0x66, 0x00,
/* 128, 0x80 */ 0x99, 0x66, 0x66, 0x00,
/* 129, 0x81 */ 0x66, 0x66, 0x66, 0x00,
/* 130, 0x82 */ 0x33, 0x66, 0x66, 0x00,
/* 131, 0x83 */ 0x00, 0x66, 0x66, 0x00,
/* 132, 0x84 */ 0xFF, 0x33, 0x66, 0x00,
/* 133, 0x85 */ 0xCC, 0x33, 0x66, 0x00,
/* 134, 0x86 */ 0x99, 0x33, 0x66, 0x00,
/* 135, 0x87 */ 0x66, 0x33, 0x66, 0x00,
/* 136, 0x88 */ 0x33, 0x33, 0x66, 0x00,
/* 137, 0x89 */ 0x00, 0x33, 0x66, 0x00,
/* 138, 0x8A */ 0xFF, 0x00, 0x66, 0x00,
/* 139, 0x8B */ 0xCC, 0x00, 0x66, 0x00,
/* 140, 0x8C */ 0x99, 0x00, 0x66, 0x00,
/* 141, 0x8D */ 0x66, 0x00, 0x66, 0x00,
/* 142, 0x8E */ 0x33, 0x00, 0x66, 0x00,
/* 143, 0x8F */ 0x00, 0x00, 0x66, 0x00,
/* 144, 0x90 */ 0xFF, 0xFF, 0x33, 0x00,
/* 145, 0x91 */ 0xCC, 0xFF, 0x33, 0x00,
/* 146, 0x92 */ 0x99, 0xFF, 0x33, 0x00,
/* 147, 0x93 */ 0x66, 0xFF, 0x33, 0x00,
/* 148, 0x94 */ 0x33, 0xFF, 0x33, 0x00,
/* 149, 0x95 */ 0x00, 0xFF, 0x33, 0x00,
/* 150, 0x96 */ 0xFF, 0xCC, 0x33, 0x00,
/* 151, 0x97 */ 0xCC, 0xCC, 0x33, 0x00,
/* 152, 0x98 */ 0x99, 0xCC, 0x33, 0x00,
/* 153, 0x99 */ 0x66, 0xCC, 0x33, 0x00,
/* 154, 0x9A */ 0x33, 0xCC, 0x33, 0x00,
/* 155, 0x9B */ 0x00, 0xCC, 0x33, 0x00,
/* 156, 0x9C */ 0xFF, 0x99, 0x33, 0x00,
/* 157, 0x9D */ 0xCC, 0x99, 0x33, 0x00,
/* 158, 0x9E */ 0x99, 0x99, 0x33, 0x00,
/* 159, 0x9F */ 0x66, 0x99, 0x33, 0x00,
/* 160, 0xA0 */ 0x33, 0x99, 0x33, 0x00,
/* 161, 0xA1 */ 0x00, 0x99, 0x33, 0x00,
/* 162, 0xA2 */ 0xFF, 0x66, 0x33, 0x00,
/* 163, 0xA3 */ 0xCC, 0x66, 0x33, 0x00,
/* 164, 0xA4 */ 0x99, 0x66, 0x33, 0x00,
/* 165, 0xA5 */ 0x66, 0x66, 0x33, 0x00,
/* 166, 0xA6 */ 0x33, 0x66, 0x33, 0x00,
/* 167, 0xA7 */ 0x00, 0x66, 0x33, 0x00,
/* 168, 0xA8 */ 0xFF, 0x33, 0x33, 0x00,
/* 169, 0xA9 */ 0xCC, 0x33, 0x33, 0x00,
/* 170, 0xAA */ 0x99, 0x33, 0x33, 0x00,
/* 171, 0xAB */ 0x66, 0x33, 0x33, 0x00,
/* 172, 0xAC */ 0x33, 0x33, 0x33, 0x00,
/* 173, 0xAD */ 0x00, 0x33, 0x33, 0x00,
/* 174, 0xAE */ 0xFF, 0x00, 0x33, 0x00,
/* 175, 0xAF */ 0xCC, 0x00, 0x33, 0x00,
/* 176, 0xB0 */ 0x99, 0x00, 0x33, 0x00,
/* 177, 0xB1 */ 0x66, 0x00, 0x33, 0x00,
/* 178, 0xB2 */ 0x33, 0x00, 0x33, 0x00,
/* 179, 0xB3 */ 0x00, 0x00, 0x33, 0x00,
/* 180, 0xB4 */ 0xFF, 0xFF, 0x00, 0x00,
/* 181, 0xB5 */ 0xCC, 0xFF, 0x00, 0x00,
/* 182, 0xB6 */ 0x99, 0xFF, 0x00, 0x00,
/* 183, 0xB7 */ 0x66, 0xFF, 0x00, 0x00,
/* 184, 0xB8 */ 0x33, 0xFF, 0x00, 0x00,
/* 185, 0xB9 */ 0x00, 0xFF, 0x00, 0x00,
/* 186, 0xBA */ 0xFF, 0xCC, 0x00, 0x00,
/* 187, 0xBB */ 0xCC, 0xCC, 0x00, 0x00,
/* 188, 0xBC */ 0x99, 0xCC, 0x00, 0x00,
/* 189, 0xBD */ 0x66, 0xCC, 0x00, 0x00,
/* 190, 0xBE */ 0x33, 0xCC, 0x00, 0x00,
/* 191, 0xBF */ 0x00, 0xCC, 0x00, 0x00,
/* 192, 0xC0 */ 0xFF, 0x99, 0x00, 0x00,
/* 193, 0xC1 */ 0xCC, 0x99, 0x00, 0x00,
/* 194, 0xC2 */ 0x99, 0x99, 0x00, 0x00,
/* 195, 0xC3 */ 0x66, 0x99, 0x00, 0x00,
/* 196, 0xC4 */ 0x33, 0x99, 0x00, 0x00,
/* 197, 0xC5 */ 0x00, 0x99, 0x00, 0x00,
/* 198, 0xC6 */ 0xFF, 0x66, 0x00, 0x00,
/* 199, 0xC7 */ 0xCC, 0x66, 0x00, 0x00,
/* 200, 0xC8 */ 0x99, 0x66, 0x00, 0x00,
/* 201, 0xC9 */ 0x66, 0x66, 0x00, 0x00,
/* 202, 0xCA */ 0x33, 0x66, 0x00, 0x00,
/* 203, 0xCB */ 0x00, 0x66, 0x00, 0x00,
/* 204, 0xCC */ 0xFF, 0x33, 0x00, 0x00,
/* 205, 0xCD */ 0xCC, 0x33, 0x00, 0x00,
/* 206, 0xCE */ 0x99, 0x33, 0x00, 0x00,
/* 207, 0xCF */ 0x66, 0x33, 0x00, 0x00,
/* 208, 0xD0 */ 0x33, 0x33, 0x00, 0x00,
/* 209, 0xD1 */ 0x00, 0x33, 0x00, 0x00,
/* 210, 0xD2 */ 0xFF, 0x00, 0x00, 0x00,
/* 211, 0xD3 */ 0xCC, 0x00, 0x00, 0x00,
/* 212, 0xD4 */ 0x99, 0x00, 0x00, 0x00,
/* 213, 0xD5 */ 0x66, 0x00, 0x00, 0x00,
/* 214, 0xD6 */ 0x33, 0x00, 0x00, 0x00,
/* 215, 0xD7 */ 0x00, 0x00, 0xEE, 0x00,
/* 216, 0xD8 */ 0x00, 0x00, 0xDD, 0x00,
/* 217, 0xD9 */ 0x00, 0x00, 0xBB, 0x00,
/* 218, 0xDA */ 0x00, 0x00, 0xAA, 0x00,
/* 219, 0xDB */ 0x00, 0x00, 0x88, 0x00,
/* 220, 0xDC */ 0x00, 0x00, 0x77, 0x00,
/* 221, 0xDD */ 0x00, 0x00, 0x55, 0x00,
/* 222, 0xDE */ 0x00, 0x00, 0x44, 0x00,
/* 223, 0xDF */ 0x00, 0x00, 0x22, 0x00,
/* 224, 0xE0 */ 0x00, 0x00, 0x11, 0x00,
/* 225, 0xE1 */ 0x00, 0xEE, 0x00, 0x00,
/* 226, 0xE2 */ 0x00, 0xDD, 0x00, 0x00,
/* 227, 0xE3 */ 0x00, 0xBB, 0x00, 0x00,
/* 228, 0xE4 */ 0x00, 0xAA, 0x00, 0x00,
/* 229, 0xE5 */ 0x00, 0x88, 0x00, 0x00,
/* 230, 0xE6 */ 0x00, 0x77, 0x00, 0x00,
/* 231, 0xE7 */ 0x00, 0x55, 0x00, 0x00,
/* 232, 0xE8 */ 0x00, 0x44, 0x00, 0x00,
/* 233, 0xE9 */ 0x00, 0x22, 0x00, 0x00,
/* 234, 0xEA */ 0x00, 0x11, 0x00, 0x00,
/* 235, 0xEB */ 0xEE, 0x00, 0x00, 0x00,
/* 236, 0xEC */ 0xDD, 0x00, 0x00, 0x00,
/* 237, 0xED */ 0xBB, 0x00, 0x00, 0x00,
/* 238, 0xEE */ 0xAA, 0x00, 0x00, 0x00,
/* 239, 0xEF */ 0x88, 0x00, 0x00, 0x00,
/* 240, 0xF0 */ 0x77, 0x00, 0x00, 0x00,
/* 241, 0xF1 */ 0x55, 0x00, 0x00, 0x00,
/* 242, 0xF2 */ 0x44, 0x00, 0x00, 0x00,
/* 243, 0xF3 */ 0x22, 0x00, 0x00, 0x00,
/* 244, 0xF4 */ 0x11, 0x00, 0x00, 0x00,
/* 245, 0xF5 */ 0xEE, 0xEE, 0xEE, 0x00,
/* 246, 0xF6 */ 0xDD, 0xDD, 0xDD, 0x00,
/* 247, 0xF7 */ 0xBB, 0xBB, 0xBB, 0x00,
/* 248, 0xF8 */ 0xAA, 0xAA, 0xAA, 0x00,
/* 249, 0xF9 */ 0x88, 0x88, 0x88, 0x00,
/* 250, 0xFA */ 0x77, 0x77, 0x77, 0x00,
/* 251, 0xFB */ 0x55, 0x55, 0x55, 0x00,
/* 252, 0xFC */ 0x44, 0x44, 0x44, 0x00,
/* 253, 0xFD */ 0x22, 0x22, 0x22, 0x00,
/* 254, 0xFE */ 0x11, 0x11, 0x11, 0x00,
/* 255, 0xFF */ 0x00, 0x00, 0x00, 0x00
};
static const unsigned char qt_default_grayscale_palette_16[16 * 4] = {
0xFF, 0xFF, 0xFF, 0xFF,
0xEE, 0xEE, 0xEE, 0xEE,
0xDD, 0xDD, 0xDD, 0xDD,
0xCC, 0xCC, 0xCC, 0xCC,
0xBB, 0xBB, 0xBB, 0xBB,
0xAA, 0xAA, 0xAA, 0xAA,
0x99, 0x99, 0x99, 0x99,
0x88, 0x88, 0x88, 0x88,
0x77, 0x77, 0x77, 0x77,
0x66, 0x66, 0x66, 0x66,
0x55, 0x55, 0x55, 0x55,
0x44, 0x44, 0x44, 0x44,
0x33, 0x33, 0x33, 0x33,
0x22, 0x22, 0x22, 0x22,
0x11, 0x11, 0x11, 0x11,
0x00, 0x00, 0x00, 0x00
};
static const unsigned char qt_default_grayscale_palette_256[256 * 4] = {
/* 0, 0x00 */ 0xFF, 0xFF, 0xFF, 0xFF,
/* 1, 0x01 */ 0xFE, 0xFE, 0xFE, 0xFE,
/* 2, 0x02 */ 0xFD, 0xFD, 0xFD, 0xFD,
/* 3, 0x03 */ 0xFC, 0xFC, 0xFC, 0xFC,
/* 4, 0x04 */ 0xFB, 0xFB, 0xFB, 0xFB,
/* 5, 0x05 */ 0xFA, 0xFA, 0xFA, 0xFA,
/* 6, 0x06 */ 0xF9, 0xF9, 0xF9, 0xF9,
/* 7, 0x07 */ 0xF8, 0xF8, 0xF8, 0xF8,
/* 8, 0x08 */ 0xF7, 0xF7, 0xF7, 0xF7,
/* 9, 0x09 */ 0xF6, 0xF6, 0xF6, 0xF6,
/* 10, 0x0A */ 0xF5, 0xF5, 0xF5, 0xF5,
/* 11, 0x0B */ 0xF4, 0xF4, 0xF4, 0xF4,
/* 12, 0x0C */ 0xF3, 0xF3, 0xF3, 0xF3,
/* 13, 0x0D */ 0xF2, 0xF2, 0xF2, 0xF2,
/* 14, 0x0E */ 0xF1, 0xF1, 0xF1, 0xF1,
/* 15, 0x0F */ 0xF0, 0xF0, 0xF0, 0xF0,
/* 16, 0x10 */ 0xEF, 0xEF, 0xEF, 0xEF,
/* 17, 0x11 */ 0xEE, 0xEE, 0xEE, 0xEE,
/* 18, 0x12 */ 0xED, 0xED, 0xED, 0xED,
/* 19, 0x13 */ 0xEC, 0xEC, 0xEC, 0xEC,
/* 20, 0x14 */ 0xEB, 0xEB, 0xEB, 0xEB,
/* 21, 0x15 */ 0xEA, 0xEA, 0xEA, 0xEA,
/* 22, 0x16 */ 0xE9, 0xE9, 0xE9, 0xE9,
/* 23, 0x17 */ 0xE8, 0xE8, 0xE8, 0xE8,
/* 24, 0x18 */ 0xE7, 0xE7, 0xE7, 0xE7,
/* 25, 0x19 */ 0xE6, 0xE6, 0xE6, 0xE6,
/* 26, 0x1A */ 0xE5, 0xE5, 0xE5, 0xE5,
/* 27, 0x1B */ 0xE4, 0xE4, 0xE4, 0xE4,
/* 28, 0x1C */ 0xE3, 0xE3, 0xE3, 0xE3,
/* 29, 0x1D */ 0xE2, 0xE2, 0xE2, 0xE2,
/* 30, 0x1E */ 0xE1, 0xE1, 0xE1, 0xE1,
/* 31, 0x1F */ 0xE0, 0xE0, 0xE0, 0xE0,
/* 32, 0x20 */ 0xDF, 0xDF, 0xDF, 0xDF,
/* 33, 0x21 */ 0xDE, 0xDE, 0xDE, 0xDE,
/* 34, 0x22 */ 0xDD, 0xDD, 0xDD, 0xDD,
/* 35, 0x23 */ 0xDC, 0xDC, 0xDC, 0xDC,
/* 36, 0x24 */ 0xDB, 0xDB, 0xDB, 0xDB,
/* 37, 0x25 */ 0xDA, 0xDA, 0xDA, 0xDA,
/* 38, 0x26 */ 0xD9, 0xD9, 0xD9, 0xD9,
/* 39, 0x27 */ 0xD8, 0xD8, 0xD8, 0xD8,
/* 40, 0x28 */ 0xD7, 0xD7, 0xD7, 0xD7,
/* 41, 0x29 */ 0xD6, 0xD6, 0xD6, 0xD6,
/* 42, 0x2A */ 0xD5, 0xD5, 0xD5, 0xD5,
/* 43, 0x2B */ 0xD4, 0xD4, 0xD4, 0xD4,
/* 44, 0x2C */ 0xD3, 0xD3, 0xD3, 0xD3,
/* 45, 0x2D */ 0xD2, 0xD2, 0xD2, 0xD2,
/* 46, 0x2E */ 0xD1, 0xD1, 0xD1, 0xD1,
/* 47, 0x2F */ 0xD0, 0xD0, 0xD0, 0xD0,
/* 48, 0x30 */ 0xCF, 0xCF, 0xCF, 0xCF,
/* 49, 0x31 */ 0xCE, 0xCE, 0xCE, 0xCE,
/* 50, 0x32 */ 0xCD, 0xCD, 0xCD, 0xCD,
/* 51, 0x33 */ 0xCC, 0xCC, 0xCC, 0xCC,
/* 52, 0x34 */ 0xCB, 0xCB, 0xCB, 0xCB,
/* 53, 0x35 */ 0xCA, 0xCA, 0xCA, 0xCA,
/* 54, 0x36 */ 0xC9, 0xC9, 0xC9, 0xC9,
/* 55, 0x37 */ 0xC8, 0xC8, 0xC8, 0xC8,
/* 56, 0x38 */ 0xC7, 0xC7, 0xC7, 0xC7,
/* 57, 0x39 */ 0xC6, 0xC6, 0xC6, 0xC6,
/* 58, 0x3A */ 0xC5, 0xC5, 0xC5, 0xC5,
/* 59, 0x3B */ 0xC4, 0xC4, 0xC4, 0xC4,
/* 60, 0x3C */ 0xC3, 0xC3, 0xC3, 0xC3,
/* 61, 0x3D */ 0xC2, 0xC2, 0xC2, 0xC2,
/* 62, 0x3E */ 0xC1, 0xC1, 0xC1, 0xC1,
/* 63, 0x3F */ 0xC0, 0xC0, 0xC0, 0xC0,
/* 64, 0x40 */ 0xBF, 0xBF, 0xBF, 0xBF,
/* 65, 0x41 */ 0xBE, 0xBE, 0xBE, 0xBE,
/* 66, 0x42 */ 0xBD, 0xBD, 0xBD, 0xBD,
/* 67, 0x43 */ 0xBC, 0xBC, 0xBC, 0xBC,
/* 68, 0x44 */ 0xBB, 0xBB, 0xBB, 0xBB,
/* 69, 0x45 */ 0xBA, 0xBA, 0xBA, 0xBA,
/* 70, 0x46 */ 0xB9, 0xB9, 0xB9, 0xB9,
/* 71, 0x47 */ 0xB8, 0xB8, 0xB8, 0xB8,
/* 72, 0x48 */ 0xB7, 0xB7, 0xB7, 0xB7,
/* 73, 0x49 */ 0xB6, 0xB6, 0xB6, 0xB6,
/* 74, 0x4A */ 0xB5, 0xB5, 0xB5, 0xB5,
/* 75, 0x4B */ 0xB4, 0xB4, 0xB4, 0xB4,
/* 76, 0x4C */ 0xB3, 0xB3, 0xB3, 0xB3,
/* 77, 0x4D */ 0xB2, 0xB2, 0xB2, 0xB2,
/* 78, 0x4E */ 0xB1, 0xB1, 0xB1, 0xB1,
/* 79, 0x4F */ 0xB0, 0xB0, 0xB0, 0xB0,
/* 80, 0x50 */ 0xAF, 0xAF, 0xAF, 0xAF,
/* 81, 0x51 */ 0xAE, 0xAE, 0xAE, 0xAE,
/* 82, 0x52 */ 0xAD, 0xAD, 0xAD, 0xAD,
/* 83, 0x53 */ 0xAC, 0xAC, 0xAC, 0xAC,
/* 84, 0x54 */ 0xAB, 0xAB, 0xAB, 0xAB,
/* 85, 0x55 */ 0xAA, 0xAA, 0xAA, 0xAA,
/* 86, 0x56 */ 0xA9, 0xA9, 0xA9, 0xA9,
/* 87, 0x57 */ 0xA8, 0xA8, 0xA8, 0xA8,
/* 88, 0x58 */ 0xA7, 0xA7, 0xA7, 0xA7,
/* 89, 0x59 */ 0xA6, 0xA6, 0xA6, 0xA6,
/* 90, 0x5A */ 0xA5, 0xA5, 0xA5, 0xA5,
/* 91, 0x5B */ 0xA4, 0xA4, 0xA4, 0xA4,
/* 92, 0x5C */ 0xA3, 0xA3, 0xA3, 0xA3,
/* 93, 0x5D */ 0xA2, 0xA2, 0xA2, 0xA2,
/* 94, 0x5E */ 0xA1, 0xA1, 0xA1, 0xA1,
/* 95, 0x5F */ 0xA0, 0xA0, 0xA0, 0xA0,
/* 96, 0x60 */ 0x9F, 0x9F, 0x9F, 0x9F,
/* 97, 0x61 */ 0x9E, 0x9E, 0x9E, 0x9E,
/* 98, 0x62 */ 0x9D, 0x9D, 0x9D, 0x9D,
/* 99, 0x63 */ 0x9C, 0x9C, 0x9C, 0x9C,
/* 100, 0x64 */ 0x9B, 0x9B, 0x9B, 0x9B,
/* 101, 0x65 */ 0x9A, 0x9A, 0x9A, 0x9A,
/* 102, 0x66 */ 0x99, 0x99, 0x99, 0x99,
/* 103, 0x67 */ 0x98, 0x98, 0x98, 0x98,
/* 104, 0x68 */ 0x97, 0x97, 0x97, 0x97,
/* 105, 0x69 */ 0x96, 0x96, 0x96, 0x96,
/* 106, 0x6A */ 0x95, 0x95, 0x95, 0x95,
/* 107, 0x6B */ 0x94, 0x94, 0x94, 0x94,
/* 108, 0x6C */ 0x93, 0x93, 0x93, 0x93,
/* 109, 0x6D */ 0x92, 0x92, 0x92, 0x92,
/* 110, 0x6E */ 0x91, 0x91, 0x91, 0x91,
/* 111, 0x6F */ 0x90, 0x90, 0x90, 0x90,
/* 112, 0x70 */ 0x8F, 0x8F, 0x8F, 0x8F,
/* 113, 0x71 */ 0x8E, 0x8E, 0x8E, 0x8E,
/* 114, 0x72 */ 0x8D, 0x8D, 0x8D, 0x8D,
/* 115, 0x73 */ 0x8C, 0x8C, 0x8C, 0x8C,
/* 116, 0x74 */ 0x8B, 0x8B, 0x8B, 0x8B,
/* 117, 0x75 */ 0x8A, 0x8A, 0x8A, 0x8A,
/* 118, 0x76 */ 0x89, 0x89, 0x89, 0x89,
/* 119, 0x77 */ 0x88, 0x88, 0x88, 0x88,
/* 120, 0x78 */ 0x87, 0x87, 0x87, 0x87,
/* 121, 0x79 */ 0x86, 0x86, 0x86, 0x86,
/* 122, 0x7A */ 0x85, 0x85, 0x85, 0x85,
/* 123, 0x7B */ 0x84, 0x84, 0x84, 0x84,
/* 124, 0x7C */ 0x83, 0x83, 0x83, 0x83,
/* 125, 0x7D */ 0x82, 0x82, 0x82, 0x82,
/* 126, 0x7E */ 0x81, 0x81, 0x81, 0x81,
/* 127, 0x7F */ 0x80, 0x80, 0x80, 0x80,
/* 128, 0x80 */ 0x7F, 0x7F, 0x7F, 0x7F,
/* 129, 0x81 */ 0x7E, 0x7E, 0x7E, 0x7E,
/* 130, 0x82 */ 0x7D, 0x7D, 0x7D, 0x7D,
/* 131, 0x83 */ 0x7C, 0x7C, 0x7C, 0x7C,
/* 132, 0x84 */ 0x7B, 0x7B, 0x7B, 0x7B,
/* 133, 0x85 */ 0x7A, 0x7A, 0x7A, 0x7A,
/* 134, 0x86 */ 0x79, 0x79, 0x79, 0x79,
/* 135, 0x87 */ 0x78, 0x78, 0x78, 0x78,
/* 136, 0x88 */ 0x77, 0x77, 0x77, 0x77,
/* 137, 0x89 */ 0x76, 0x76, 0x76, 0x76,
/* 138, 0x8A */ 0x75, 0x75, 0x75, 0x75,
/* 139, 0x8B */ 0x74, 0x74, 0x74, 0x74,
/* 140, 0x8C */ 0x73, 0x73, 0x73, 0x73,
/* 141, 0x8D */ 0x72, 0x72, 0x72, 0x72,
/* 142, 0x8E */ 0x71, 0x71, 0x71, 0x71,
/* 143, 0x8F */ 0x70, 0x70, 0x70, 0x70,
/* 144, 0x90 */ 0x6F, 0x6F, 0x6F, 0x6F,
/* 145, 0x91 */ 0x6E, 0x6E, 0x6E, 0x6E,
/* 146, 0x92 */ 0x6D, 0x6D, 0x6D, 0x6D,
/* 147, 0x93 */ 0x6C, 0x6C, 0x6C, 0x6C,
/* 148, 0x94 */ 0x6B, 0x6B, 0x6B, 0x6B,
/* 149, 0x95 */ 0x6A, 0x6A, 0x6A, 0x6A,
/* 150, 0x96 */ 0x69, 0x69, 0x69, 0x69,
/* 151, 0x97 */ 0x68, 0x68, 0x68, 0x68,
/* 152, 0x98 */ 0x67, 0x67, 0x67, 0x67,
/* 153, 0x99 */ 0x66, 0x66, 0x66, 0x66,
/* 154, 0x9A */ 0x65, 0x65, 0x65, 0x65,
/* 155, 0x9B */ 0x64, 0x64, 0x64, 0x64,
/* 156, 0x9C */ 0x63, 0x63, 0x63, 0x63,
/* 157, 0x9D */ 0x62, 0x62, 0x62, 0x62,
/* 158, 0x9E */ 0x61, 0x61, 0x61, 0x61,
/* 159, 0x9F */ 0x60, 0x60, 0x60, 0x60,
/* 160, 0xA0 */ 0x5F, 0x5F, 0x5F, 0x5F,
/* 161, 0xA1 */ 0x5E, 0x5E, 0x5E, 0x5E,
/* 162, 0xA2 */ 0x5D, 0x5D, 0x5D, 0x5D,
/* 163, 0xA3 */ 0x5C, 0x5C, 0x5C, 0x5C,
/* 164, 0xA4 */ 0x5B, 0x5B, 0x5B, 0x5B,
/* 165, 0xA5 */ 0x5A, 0x5A, 0x5A, 0x5A,
/* 166, 0xA6 */ 0x59, 0x59, 0x59, 0x59,
/* 167, 0xA7 */ 0x58, 0x58, 0x58, 0x58,
/* 168, 0xA8 */ 0x57, 0x57, 0x57, 0x57,
/* 169, 0xA9 */ 0x56, 0x56, 0x56, 0x56,
/* 170, 0xAA */ 0x55, 0x55, 0x55, 0x55,
/* 171, 0xAB */ 0x54, 0x54, 0x54, 0x54,
/* 172, 0xAC */ 0x53, 0x53, 0x53, 0x53,
/* 173, 0xAD */ 0x52, 0x52, 0x52, 0x52,
/* 174, 0xAE */ 0x51, 0x51, 0x51, 0x51,
/* 175, 0xAF */ 0x50, 0x50, 0x50, 0x50,
/* 176, 0xB0 */ 0x4F, 0x4F, 0x4F, 0x4F,
/* 177, 0xB1 */ 0x4E, 0x4E, 0x4E, 0x4E,
/* 178, 0xB2 */ 0x4D, 0x4D, 0x4D, 0x4D,
/* 179, 0xB3 */ 0x4C, 0x4C, 0x4C, 0x4C,
/* 180, 0xB4 */ 0x4B, 0x4B, 0x4B, 0x4B,
/* 181, 0xB5 */ 0x4A, 0x4A, 0x4A, 0x4A,
/* 182, 0xB6 */ 0x49, 0x49, 0x49, 0x49,
/* 183, 0xB7 */ 0x48, 0x48, 0x48, 0x48,
/* 184, 0xB8 */ 0x47, 0x47, 0x47, 0x47,
/* 185, 0xB9 */ 0x46, 0x46, 0x46, 0x46,
/* 186, 0xBA */ 0x45, 0x45, 0x45, 0x45,
/* 187, 0xBB */ 0x44, 0x44, 0x44, 0x44,
/* 188, 0xBC */ 0x43, 0x43, 0x43, 0x43,
/* 189, 0xBD */ 0x42, 0x42, 0x42, 0x42,
/* 190, 0xBE */ 0x41, 0x41, 0x41, 0x41,
/* 191, 0xBF */ 0x40, 0x40, 0x40, 0x40,
/* 192, 0xC0 */ 0x3F, 0x3F, 0x3F, 0x3F,
/* 193, 0xC1 */ 0x3E, 0x3E, 0x3E, 0x3E,
/* 194, 0xC2 */ 0x3D, 0x3D, 0x3D, 0x3D,
/* 195, 0xC3 */ 0x3C, 0x3C, 0x3C, 0x3C,
/* 196, 0xC4 */ 0x3B, 0x3B, 0x3B, 0x3B,
/* 197, 0xC5 */ 0x3A, 0x3A, 0x3A, 0x3A,
/* 198, 0xC6 */ 0x39, 0x39, 0x39, 0x39,
/* 199, 0xC7 */ 0x38, 0x38, 0x38, 0x38,
/* 200, 0xC8 */ 0x37, 0x37, 0x37, 0x37,
/* 201, 0xC9 */ 0x36, 0x36, 0x36, 0x36,
/* 202, 0xCA */ 0x35, 0x35, 0x35, 0x35,
/* 203, 0xCB */ 0x34, 0x34, 0x34, 0x34,
/* 204, 0xCC */ 0x33, 0x33, 0x33, 0x33,
/* 205, 0xCD */ 0x32, 0x32, 0x32, 0x32,
/* 206, 0xCE */ 0x31, 0x31, 0x31, 0x31,
/* 207, 0xCF */ 0x30, 0x30, 0x30, 0x30,
/* 208, 0xD0 */ 0x2F, 0x2F, 0x2F, 0x2F,
/* 209, 0xD1 */ 0x2E, 0x2E, 0x2E, 0x2E,
/* 210, 0xD2 */ 0x2D, 0x2D, 0x2D, 0x2D,
/* 211, 0xD3 */ 0x2C, 0x2C, 0x2C, 0x2C,
/* 212, 0xD4 */ 0x2B, 0x2B, 0x2B, 0x2B,
/* 213, 0xD5 */ 0x2A, 0x2A, 0x2A, 0x2A,
/* 214, 0xD6 */ 0x29, 0x29, 0x29, 0x29,
/* 215, 0xD7 */ 0x28, 0x28, 0x28, 0x28,
/* 216, 0xD8 */ 0x27, 0x27, 0x27, 0x27,
/* 217, 0xD9 */ 0x26, 0x26, 0x26, 0x26,
/* 218, 0xDA */ 0x25, 0x25, 0x25, 0x25,
/* 219, 0xDB */ 0x24, 0x24, 0x24, 0x24,
/* 220, 0xDC */ 0x23, 0x23, 0x23, 0x23,
/* 221, 0xDD */ 0x22, 0x22, 0x22, 0x22,
/* 222, 0xDE */ 0x21, 0x21, 0x21, 0x21,
/* 223, 0xDF */ 0x20, 0x20, 0x20, 0x20,
/* 224, 0xE0 */ 0x1F, 0x1F, 0x1F, 0x1F,
/* 225, 0xE1 */ 0x1E, 0x1E, 0x1E, 0x1E,
/* 226, 0xE2 */ 0x1D, 0x1D, 0x1D, 0x1D,
/* 227, 0xE3 */ 0x1C, 0x1C, 0x1C, 0x1C,
/* 228, 0xE4 */ 0x1B, 0x1B, 0x1B, 0x1B,
/* 229, 0xE5 */ 0x1A, 0x1A, 0x1A, 0x1A,
/* 230, 0xE6 */ 0x19, 0x19, 0x19, 0x19,
/* 231, 0xE7 */ 0x18, 0x18, 0x18, 0x18,
/* 232, 0xE8 */ 0x17, 0x17, 0x17, 0x17,
/* 233, 0xE9 */ 0x16, 0x16, 0x16, 0x16,
/* 234, 0xEA */ 0x15, 0x15, 0x15, 0x15,
/* 235, 0xEB */ 0x14, 0x14, 0x14, 0x14,
/* 236, 0xEC */ 0x13, 0x13, 0x13, 0x13,
/* 237, 0xED */ 0x12, 0x12, 0x12, 0x12,
/* 238, 0xEE */ 0x11, 0x11, 0x11, 0x11,
/* 239, 0xEF */ 0x10, 0x10, 0x10, 0x10,
/* 240, 0xF0 */ 0x0F, 0x0F, 0x0F, 0x0F,
/* 241, 0xF1 */ 0x0E, 0x0E, 0x0E, 0x0E,
/* 242, 0xF2 */ 0x0D, 0x0D, 0x0D, 0x0D,
/* 243, 0xF3 */ 0x0C, 0x0C, 0x0C, 0x0C,
/* 244, 0xF4 */ 0x0B, 0x0B, 0x0B, 0x0B,
/* 245, 0xF5 */ 0x0A, 0x0A, 0x0A, 0x0A,
/* 246, 0xF6 */ 0x09, 0x09, 0x09, 0x09,
/* 247, 0xF7 */ 0x08, 0x08, 0x08, 0x08,
/* 248, 0xF8 */ 0x07, 0x07, 0x07, 0x07,
/* 249, 0xF9 */ 0x06, 0x06, 0x06, 0x06,
/* 250, 0xFA */ 0x05, 0x05, 0x05, 0x05,
/* 251, 0xFB */ 0x04, 0x04, 0x04, 0x04,
/* 252, 0xFC */ 0x03, 0x03, 0x03, 0x03,
/* 253, 0xFD */ 0x02, 0x02, 0x02, 0x02,
/* 254, 0xFE */ 0x01, 0x01, 0x01, 0x01,
/* 255, 0xFF */ 0x00, 0x00, 0x00, 0x00
};
#endif /* MPLAYER_QTPALETTE_H */