Commit bb67674a authored by Alexander Strange's avatar Alexander Strange

Merge branch 'master' of git://git.mplayerhq.hu/ffmpeg

parents 06ac5ac9 60518381
...@@ -12,6 +12,7 @@ version <next>: ...@@ -12,6 +12,7 @@ version <next>:
- Demuxer for On2's IVF format - Demuxer for On2's IVF format
- Pictor/PC Paint decoder - Pictor/PC Paint decoder
- HE-AAC v2 decoder - HE-AAC v2 decoder
- libfaad2 wrapper removed
......
...@@ -169,8 +169,6 @@ External library support: ...@@ -169,8 +169,6 @@ External library support:
and libraw1394 [no] and libraw1394 [no]
--enable-libdirac enable Dirac support via libdirac [no] --enable-libdirac enable Dirac support via libdirac [no]
--enable-libfaac enable FAAC support via libfaac [no] --enable-libfaac enable FAAC support via libfaac [no]
--enable-libfaad enable FAAD support via libfaad [no]
--enable-libfaadbin open libfaad.so.0 at runtime [no]
--enable-libgsm enable GSM support via libgsm [no] --enable-libgsm enable GSM support via libgsm [no]
--enable-libmp3lame enable MP3 encoding via libmp3lame [no] --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
--enable-libnut enable NUT (de)muxing via libnut, --enable-libnut enable NUT (de)muxing via libnut,
...@@ -915,8 +913,6 @@ CONFIG_LIST=" ...@@ -915,8 +913,6 @@ CONFIG_LIST="
libdc1394 libdc1394
libdirac libdirac
libfaac libfaac
libfaad
libfaadbin
libgsm libgsm
libmp3lame libmp3lame
libnut libnut
...@@ -1343,8 +1339,6 @@ aac_adtstoasc_bsf_select="aac_parser" ...@@ -1343,8 +1339,6 @@ aac_adtstoasc_bsf_select="aac_parser"
libdirac_decoder_deps="libdirac !libschroedinger" libdirac_decoder_deps="libdirac !libschroedinger"
libdirac_encoder_deps="libdirac" libdirac_encoder_deps="libdirac"
libfaac_encoder_deps="libfaac" libfaac_encoder_deps="libfaac"
libfaad_decoder_deps="libfaad"
libfaadbin_extralibs='$ldl'
libgsm_decoder_deps="libgsm" libgsm_decoder_deps="libgsm"
libgsm_encoder_deps="libgsm" libgsm_encoder_deps="libgsm"
libgsm_ms_decoder_deps="libgsm" libgsm_ms_decoder_deps="libgsm"
...@@ -2170,7 +2164,7 @@ case $target_os in ...@@ -2170,7 +2164,7 @@ case $target_os in
darwin) darwin)
enable malloc_aligned enable malloc_aligned
SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress' SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
strip="strip -x" strip="${strip} -x"
FFLDFLAGS="-Wl,-dynamic,-search_paths_first" FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
SLIBSUF=".dylib" SLIBSUF=".dylib"
SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)' SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
...@@ -2300,27 +2294,10 @@ fi ...@@ -2300,27 +2294,10 @@ fi
disabled static && LIBNAME="" disabled static && LIBNAME=""
if enabled_any libfaad libfaadbin ; then
if check_header faad.h; then
check_cc <<EOF
#include <faad.h>
#ifndef FAAD2_VERSION
ok faad1
#endif
int main(void) { return 0; }
EOF
test $? = 0 && enable libfaad2
else
die "FAAD test failed."
fi
fi
die_license_disabled() { die_license_disabled() {
enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; } enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
} }
die_license_disabled gpl libfaad2
die_license_disabled gpl libx264 die_license_disabled gpl libx264
die_license_disabled gpl libxvid die_license_disabled gpl libxvid
die_license_disabled gpl postproc die_license_disabled gpl postproc
...@@ -2594,7 +2571,6 @@ enabled libdirac && add_cflags $(pkg-config --cflags dirac) && ...@@ -2594,7 +2571,6 @@ enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) && require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac) require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
enabled libnut && require libnut libnut.h nut_demuxer_init -lnut enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
...@@ -2870,8 +2846,6 @@ echo "AVISynth enabled ${avisynth-no}" ...@@ -2870,8 +2846,6 @@ echo "AVISynth enabled ${avisynth-no}"
echo "libdc1394 support ${libdc1394-no}" echo "libdc1394 support ${libdc1394-no}"
echo "libdirac enabled ${libdirac-no}" echo "libdirac enabled ${libdirac-no}"
echo "libfaac enabled ${libfaac-no}" echo "libfaac enabled ${libfaac-no}"
echo "libfaad enabled ${libfaad-no}"
echo "libfaad dlopened ${libfaadbin-no}"
echo "libgsm enabled ${libgsm-no}" echo "libgsm enabled ${libgsm-no}"
echo "libmp3lame enabled ${libmp3lame-no}" echo "libmp3lame enabled ${libmp3lame-no}"
echo "libnut enabled ${libnut-no}" echo "libnut enabled ${libnut-no}"
......
...@@ -1025,7 +1025,7 @@ These library packages are only available from Cygwin Ports ...@@ -1025,7 +1025,7 @@ These library packages are only available from Cygwin Ports
(@url{http://sourceware.org/cygwinports/}) : (@url{http://sourceware.org/cygwinports/}) :
@example @example
yasm, libSDL-devel, libdirac-devel, libfaac-devel, libfaad-devel, libgsm-devel, yasm, libSDL-devel, libdirac-devel, libfaac-devel, libgsm-devel,
libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel, libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel,
libxvidcore-devel libxvidcore-devel
@end example @end example
......
...@@ -521,7 +521,6 @@ OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \ ...@@ -521,7 +521,6 @@ OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \
OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o
OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o
OBJS-$(CONFIG_LIBFAAC_ENCODER) += libfaac.o OBJS-$(CONFIG_LIBFAAC_ENCODER) += libfaac.o
OBJS-$(CONFIG_LIBFAAD_DECODER) += libfaad.o
OBJS-$(CONFIG_LIBGSM_DECODER) += libgsm.o OBJS-$(CONFIG_LIBGSM_DECODER) += libgsm.o
OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o
OBJS-$(CONFIG_LIBGSM_MS_DECODER) += libgsm.o OBJS-$(CONFIG_LIBGSM_MS_DECODER) += libgsm.o
......
...@@ -379,8 +379,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, ...@@ -379,8 +379,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr,
} }
if (!spectrum->bs_freq_scale) { if (!spectrum->bs_freq_scale) {
unsigned int dk; int dk, k2diff;
int k2diff;
dk = spectrum->bs_alter_scale + 1; dk = spectrum->bs_alter_scale + 1;
sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1; sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1;
...@@ -393,7 +392,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, ...@@ -393,7 +392,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr,
k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk; k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk;
if (k2diff < 0) { if (k2diff < 0) {
sbr->f_master[1]--; sbr->f_master[1]--;
sbr->f_master[2]-= (k2diff < 1); sbr->f_master[2]-= (k2diff < -1);
} else if (k2diff) { } else if (k2diff) {
sbr->f_master[sbr->n_master]++; sbr->f_master[sbr->n_master]++;
} }
......
...@@ -340,7 +340,6 @@ void avcodec_register_all(void) ...@@ -340,7 +340,6 @@ void avcodec_register_all(void)
/* external libraries */ /* external libraries */
REGISTER_ENCDEC (LIBDIRAC, libdirac); REGISTER_ENCDEC (LIBDIRAC, libdirac);
REGISTER_ENCODER (LIBFAAC, libfaac); REGISTER_ENCODER (LIBFAAC, libfaac);
REGISTER_DECODER (LIBFAAD, libfaad);
REGISTER_ENCDEC (LIBGSM, libgsm); REGISTER_ENCDEC (LIBGSM, libgsm);
REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms); REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms);
REGISTER_ENCODER (LIBMP3LAME, libmp3lame); REGISTER_ENCODER (LIBMP3LAME, libmp3lame);
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#define DCA_PRIM_CHANNELS_MAX (5) #define DCA_PRIM_CHANNELS_MAX (5)
#define DCA_SUBBANDS (32) #define DCA_SUBBANDS (32)
#define DCA_ABITS_MAX (32) /* Should be 28 */ #define DCA_ABITS_MAX (32) /* Should be 28 */
#define DCA_SUBSUBFAMES_MAX (4) #define DCA_SUBSUBFRAMES_MAX (4)
#define DCA_LFE_MAX (3) #define DCA_LFE_MAX (3)
enum DCAMode { enum DCAMode {
...@@ -222,7 +222,7 @@ typedef struct { ...@@ -222,7 +222,7 @@ typedef struct {
int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< VQ encoded high frequency subbands int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< VQ encoded high frequency subbands
float lfe_data[2 * DCA_SUBSUBFAMES_MAX * DCA_LFE_MAX * float lfe_data[2 * DCA_SUBSUBFRAMES_MAX * DCA_LFE_MAX *
2 /*history */ ]; ///< Low frequency effect data 2 /*history */ ]; ///< Low frequency effect data
int lfe_scale_factor; int lfe_scale_factor;
......
/*
* Faad decoder
* Copyright (c) 2003 Zdenek Kabelac
* Copyright (c) 2004 Thomas Raivio
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* AAC decoder.
*
* still a bit unfinished - but it plays something
*/
#include "avcodec.h"
#include "faad.h"
#ifndef FAADAPI
#define FAADAPI
#endif
/*
* when CONFIG_LIBFAADBIN is true libfaad will be opened at runtime
*/
//#undef CONFIG_LIBFAADBIN
//#define CONFIG_LIBFAADBIN 0
//#define CONFIG_LIBFAADBIN 1
#if CONFIG_LIBFAADBIN
#include <dlfcn.h>
static const char* const libfaadname = "libfaad.so";
#else
#define dlopen(a)
#define dlclose(a)
#endif
typedef struct {
void* handle; /* dlopen handle */
void* faac_handle; /* FAAD library handle */
int sample_size;
int init;
/* faad calls */
faacDecHandle FAADAPI (*faacDecOpen)(void);
faacDecConfigurationPtr FAADAPI (*faacDecGetCurrentConfiguration)(faacDecHandle hDecoder);
#ifndef FAAD2_VERSION
int FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder,
faacDecConfigurationPtr config);
int FAADAPI (*faacDecInit)(faacDecHandle hDecoder,
unsigned char *buffer,
unsigned long *samplerate,
unsigned long *channels);
int FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer,
unsigned long SizeOfDecoderSpecificInfo,
unsigned long *samplerate, unsigned long *channels);
int FAADAPI (*faacDecDecode)(faacDecHandle hDecoder,
unsigned char *buffer,
unsigned long *bytesconsumed,
short *sample_buffer,
unsigned long *samples);
#else
unsigned char FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder,
faacDecConfigurationPtr config);
long FAADAPI (*faacDecInit)(faacDecHandle hDecoder,
unsigned char *buffer,
unsigned long buffer_size,
unsigned long *samplerate,
unsigned char *channels);
char FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer,
unsigned long SizeOfDecoderSpecificInfo,
unsigned long *samplerate, unsigned char *channels);
void *FAADAPI (*faacDecDecode)(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo,
unsigned char *buffer,
unsigned long buffer_size);
char* FAADAPI (*faacDecGetErrorMessage)(unsigned char errcode);
#endif
void FAADAPI (*faacDecClose)(faacDecHandle hDecoder);
} FAACContext;
static const unsigned long faac_srates[] =
{
96000, 88200, 64000, 48000, 44100, 32000,
24000, 22050, 16000, 12000, 11025, 8000
};
static void channel_setup(AVCodecContext *avctx)
{
#ifdef FAAD2_VERSION
FAACContext *s = avctx->priv_data;
if (avctx->request_channels > 0 && avctx->request_channels == 2 &&
avctx->request_channels < avctx->channels) {
faacDecConfigurationPtr faac_cfg;
avctx->channels = 2;
faac_cfg = s->faacDecGetCurrentConfiguration(s->faac_handle);
faac_cfg->downMatrix = 1;
s->faacDecSetConfiguration(s->faac_handle, faac_cfg);
}
#endif
}
static av_cold int faac_init_mp4(AVCodecContext *avctx)
{
FAACContext *s = avctx->priv_data;
unsigned long samplerate;
#ifndef FAAD2_VERSION
unsigned long channels;
#else
unsigned char channels;
#endif
int r = 0;
if (avctx->extradata){
r = s->faacDecInit2(s->faac_handle, (uint8_t*) avctx->extradata,
avctx->extradata_size,
&samplerate, &channels);
if (r < 0){
av_log(avctx, AV_LOG_ERROR,
"faacDecInit2 failed r:%d sr:%ld ch:%ld s:%d\n",
r, samplerate, (long)channels, avctx->extradata_size);
} else {
avctx->sample_rate = samplerate;
avctx->channels = channels;
channel_setup(avctx);
s->init = 1;
}
}
return r;
}
static int faac_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
FAACContext *s = avctx->priv_data;
#ifndef FAAD2_VERSION
unsigned long bytesconsumed;
short *sample_buffer = NULL;
unsigned long samples;
int out;
#else
faacDecFrameInfo frame_info;
void *out;
#endif
if(buf_size == 0)
return 0;
#ifndef FAAD2_VERSION
out = s->faacDecDecode(s->faac_handle,
(unsigned char*)buf,
&bytesconsumed,
data,
&samples);
samples *= s->sample_size;
if (data_size)
*data_size = samples;
return (buf_size < (int)bytesconsumed)
? buf_size : (int)bytesconsumed;
#else
if(!s->init){
unsigned long srate;
unsigned char channels;
int r = s->faacDecInit(s->faac_handle, buf, buf_size, &srate, &channels);
if(r < 0){
av_log(avctx, AV_LOG_ERROR, "libfaad: codec init failed.\n");
return -1;
}
avctx->sample_rate = srate;
avctx->channels = channels;
channel_setup(avctx);
s->init = 1;
}
out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf, (unsigned long)buf_size);
if (frame_info.error > 0) {
av_log(avctx, AV_LOG_ERROR, "libfaad: frame decoding failed: %s\n",
s->faacDecGetErrorMessage(frame_info.error));
return -1;
}
if (!avctx->frame_size)
avctx->frame_size = frame_info.samples/avctx->channels;
frame_info.samples *= s->sample_size;
memcpy(data, out, frame_info.samples); // CHECKME - can we cheat this one
if (data_size)
*data_size = frame_info.samples;
return (buf_size < (int)frame_info.bytesconsumed)
? buf_size : (int)frame_info.bytesconsumed;
#endif
}
static av_cold int faac_decode_end(AVCodecContext *avctx)
{
FAACContext *s = avctx->priv_data;
s->faacDecClose(s->faac_handle);
dlclose(s->handle);
return 0;
}
static av_cold int faac_decode_init(AVCodecContext *avctx)
{
FAACContext *s = avctx->priv_data;
faacDecConfigurationPtr faac_cfg;
#if CONFIG_LIBFAADBIN
const char* err = 0;
s->handle = dlopen(libfaadname, RTLD_LAZY);
if (!s->handle)
{
av_log(avctx, AV_LOG_ERROR, "FAAD library: %s could not be opened! \n%s\n",
libfaadname, dlerror());
return -1;
}
#define dfaac(a) do { \
const char* n = AV_STRINGIFY(faacDec ## a); \
if (!err && !(s->faacDec ## a = dlsym(s->handle, n))) { \
err = n; \
} \
} while(0)
#else /* !CONFIG_LIBFAADBIN */
#define dfaac(a) s->faacDec ## a = faacDec ## a
#endif /* CONFIG_LIBFAADBIN */
// resolve all needed function calls
dfaac(Open);
dfaac(Close);
dfaac(GetCurrentConfiguration);
dfaac(SetConfiguration);
dfaac(Init);
dfaac(Init2);
dfaac(Decode);
#ifdef FAAD2_VERSION
dfaac(GetErrorMessage);
#endif
#undef dfaac
#if CONFIG_LIBFAADBIN
if (err) {
dlclose(s->handle);
av_log(avctx, AV_LOG_ERROR, "FAAD library: cannot resolve %s in %s!\n",
err, libfaadname);
return -1;
}
#endif
s->faac_handle = s->faacDecOpen();
if (!s->faac_handle) {
av_log(avctx, AV_LOG_ERROR, "FAAD library: cannot create handler!\n");
faac_decode_end(avctx);
return -1;
}
faac_cfg = s->faacDecGetCurrentConfiguration(s->faac_handle);
if (faac_cfg) {
switch (avctx->bits_per_coded_sample) {
case 8: av_log(avctx, AV_LOG_ERROR, "FAADlib unsupported bps %d\n", avctx->bits_per_coded_sample); break;
default:
case 16:
#ifdef FAAD2_VERSION
faac_cfg->outputFormat = FAAD_FMT_16BIT;
#endif
s->sample_size = 2;
break;
case 24:
#ifdef FAAD2_VERSION
faac_cfg->outputFormat = FAAD_FMT_24BIT;
#endif
s->sample_size = 3;
break;
case 32:
#ifdef FAAD2_VERSION
faac_cfg->outputFormat = FAAD_FMT_32BIT;
#endif
s->sample_size = 4;
break;
}
faac_cfg->defSampleRate = (!avctx->sample_rate) ? 44100 : avctx->sample_rate;
faac_cfg->defObjectType = LC;
}
s->faacDecSetConfiguration(s->faac_handle, faac_cfg);
faac_init_mp4(avctx);
if(!s->init && avctx->channels > 0)
channel_setup(avctx);
avctx->sample_fmt = SAMPLE_FMT_S16;
return 0;
}
AVCodec libfaad_decoder = {
"libfaad",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_AAC,
sizeof(FAACContext),
faac_decode_init,
NULL,
faac_decode_end,
faac_decode_frame,
.long_name = NULL_IF_CONFIG_SMALL("libfaad AAC (Advanced Audio Codec)"),
};
...@@ -926,6 +926,7 @@ void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, ...@@ -926,6 +926,7 @@ void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
int offset; int offset;
#if FRAC_BITS <= 15 #if FRAC_BITS <= 15
int32_t tmp[32]; int32_t tmp[32];
int j;
#endif #endif
offset = *synth_buf_offset; offset = *synth_buf_offset;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include "libavutil/common.h"
#include "libavutil/mathematics.h" #include "libavutil/mathematics.h"
#include "avcodec.h" #include "avcodec.h"
#include "get_bits.h" #include "get_bits.h"
...@@ -27,7 +28,9 @@ ...@@ -27,7 +28,9 @@
#include "ps_tablegen.h" #include "ps_tablegen.h"
#include "psdata.c" #include "psdata.c"
#define PS_BASELINE 0 #define PS_BASELINE 0 //< Operate in Baseline PS mode
//< Baseline implies 10 or 20 stereo bands,
//< mixing mode A, and no ipd/opd
#define numQMFSlots 32 //numTimeSlots * RATE #define numQMFSlots 32 //numTimeSlots * RATE
...@@ -79,7 +82,7 @@ static VLC vlc_ps[10]; ...@@ -79,7 +82,7 @@ static VLC vlc_ps[10];
* @param dt 1: time delta-coded, 0: frequency delta-coded * @param dt 1: time delta-coded, 0: frequency delta-coded
*/ */
#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \ #define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \
static int PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \ static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \
int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \ int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \
{ \ { \
int b, num = ps->nr_ ## PAR ## _par; \ int b, num = ps->nr_ ## PAR ## _par; \
...@@ -114,7 +117,7 @@ READ_PAR_DATA(iid, huff_offset[table_idx], 0, FFABS(ps->iid_par[e][b]) > 7 ...@@ -114,7 +117,7 @@ READ_PAR_DATA(iid, huff_offset[table_idx], 0, FFABS(ps->iid_par[e][b]) > 7
READ_PAR_DATA(icc, huff_offset[table_idx], 0, ps->icc_par[e][b] > 7U) READ_PAR_DATA(icc, huff_offset[table_idx], 0, ps->icc_par[e][b] > 7U)
READ_PAR_DATA(ipdopd, 0, 0x07, 0) READ_PAR_DATA(ipdopd, 0, 0x07, 0)
static int ps_extension(GetBitContext *gb, PSContext *ps, int ps_extension_id) static int ps_read_extension_data(GetBitContext *gb, PSContext *ps, int ps_extension_id)
{ {
int e; int e;
int count = get_bits_count(gb); int count = get_bits_count(gb);
...@@ -126,9 +129,9 @@ static int ps_extension(GetBitContext *gb, PSContext *ps, int ps_extension_id) ...@@ -126,9 +129,9 @@ static int ps_extension(GetBitContext *gb, PSContext *ps, int ps_extension_id)
if (ps->enable_ipdopd) { if (ps->enable_ipdopd) {
for (e = 0; e < ps->num_env; e++) { for (e = 0; e < ps->num_env; e++) {
int dt = get_bits1(gb); int dt = get_bits1(gb);
ipdopd_data(NULL, gb, ps, ps->ipd_par, dt ? huff_ipd_dt : huff_ipd_df, e, dt); read_ipdopd_data(NULL, gb, ps, ps->ipd_par, dt ? huff_ipd_dt : huff_ipd_df, e, dt);
dt = get_bits1(gb); dt = get_bits1(gb);
ipdopd_data(NULL, gb, ps, ps->opd_par, dt ? huff_opd_dt : huff_opd_df, e, dt); read_ipdopd_data(NULL, gb, ps, ps->opd_par, dt ? huff_opd_dt : huff_opd_df, e, dt);
} }
} }
skip_bits1(gb); //reserved_ps skip_bits1(gb); //reserved_ps
...@@ -156,15 +159,15 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps ...@@ -156,15 +159,15 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps
if (header) { //enable_ps_header if (header) { //enable_ps_header
ps->enable_iid = get_bits1(gb); ps->enable_iid = get_bits1(gb);
if (ps->enable_iid) { if (ps->enable_iid) {
ps->iid_mode = get_bits(gb, 3); int iid_mode = get_bits(gb, 3);
if (ps->iid_mode > 5) { if (iid_mode > 5) {
av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n", av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n",
ps->iid_mode); iid_mode);
goto err; goto err;
} }
ps->nr_iid_par = nr_iidicc_par_tab[ps->iid_mode]; ps->nr_iid_par = nr_iidicc_par_tab[iid_mode];
ps->iid_quant = ps->iid_mode > 2; ps->iid_quant = iid_mode > 2;
ps->nr_ipdopd_par = nr_iidopd_par_tab[ps->iid_mode]; ps->nr_ipdopd_par = nr_iidopd_par_tab[iid_mode];
} }
ps->enable_icc = get_bits1(gb); ps->enable_icc = get_bits1(gb);
if (ps->enable_icc) { if (ps->enable_icc) {
...@@ -189,12 +192,12 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps ...@@ -189,12 +192,12 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps
ps->border_position[e] = get_bits(gb, 5); ps->border_position[e] = get_bits(gb, 5);
} else } else
for (e = 1; e <= ps->num_env; e++) for (e = 1; e <= ps->num_env; e++)
ps->border_position[e] = e * numQMFSlots / ps->num_env - 1; ps->border_position[e] = (e * numQMFSlots >> ff_log2_tab[ps->num_env]) - 1;
if (ps->enable_iid) { if (ps->enable_iid) {
for (e = 0; e < ps->num_env; e++) { for (e = 0; e < ps->num_env; e++) {
int dt = get_bits1(gb); int dt = get_bits1(gb);
if (iid_data(avctx, gb, ps, ps->iid_par, huff_iid[2*dt+ps->iid_quant], e, dt)) if (read_iid_data(avctx, gb, ps, ps->iid_par, huff_iid[2*dt+ps->iid_quant], e, dt))
goto err; goto err;
} }
} else } else
...@@ -203,7 +206,7 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps ...@@ -203,7 +206,7 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps
if (ps->enable_icc) if (ps->enable_icc)
for (e = 0; e < ps->num_env; e++) { for (e = 0; e < ps->num_env; e++) {
int dt = get_bits1(gb); int dt = get_bits1(gb);
if (icc_data(avctx, gb, ps, ps->icc_par, dt ? huff_icc_dt : huff_icc_df, e, dt)) if (read_icc_data(avctx, gb, ps, ps->icc_par, dt ? huff_icc_dt : huff_icc_df, e, dt))
goto err; goto err;
} }
else else
...@@ -217,7 +220,7 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps ...@@ -217,7 +220,7 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps
cnt *= 8; cnt *= 8;
while (cnt > 7) { while (cnt > 7) {
int ps_extension_id = get_bits(gb, 2); int ps_extension_id = get_bits(gb, 2);
cnt -= 2 + ps_extension(gb, ps, ps_extension_id); cnt -= 2 + ps_read_extension_data(gb, ps, ps_extension_id);
} }
if (cnt < 0) { if (cnt < 0) {
av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d", cnt); av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d", cnt);
...@@ -233,13 +236,13 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps ...@@ -233,13 +236,13 @@ int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps
//Create a fake envelope //Create a fake envelope
int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1; int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1;
if (source >= 0 && source != ps->num_env) { if (source >= 0 && source != ps->num_env) {
if (ps->enable_iid && ps->num_env_old > 1) { if (ps->enable_iid) {
memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0])); memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0]));
} }
if (ps->enable_icc && ps->num_env_old > 1) { if (ps->enable_icc) {
memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0])); memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0]));
} }
if (ps->enable_ipdopd && ps->num_env_old > 1) { if (ps->enable_ipdopd) {
memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0])); memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0]));
memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0])); memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0]));
} }
...@@ -280,14 +283,14 @@ err: ...@@ -280,14 +283,14 @@ err:
static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[7], int len, int reverse) static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[7], int len, int reverse)
{ {
int i, j; int i, j;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++, in++) {
float re_in = filter[6] * in[6+i][0]; //real inphase float re_in = filter[6] * in[6][0]; //real inphase
float re_op = 0.0f; //real out of phase float re_op = 0.0f; //real out of phase
float im_in = filter[6] * in[6+i][1]; //imag inphase float im_in = filter[6] * in[6][1]; //imag inphase
float im_op = 0.0f; //imag out of phase float im_op = 0.0f; //imag out of phase
for (j = 0; j < 6; j += 2) { for (j = 0; j < 6; j += 2) {
re_op += filter[j+1] * (in[i+j+1][0] + in[12-j-1+i][0]); re_op += filter[j+1] * (in[j+1][0] + in[12-j-1][0]);
im_op += filter[j+1] * (in[i+j+1][1] + in[12-j-1+i][1]); im_op += filter[j+1] * (in[j+1][1] + in[12-j-1][1]);
} }
out[ reverse][i][0] = re_in + re_op; out[ reverse][i][0] = re_in + re_op;
out[ reverse][i][1] = im_in + im_op; out[ reverse][i][1] = im_in + im_op;
...@@ -303,14 +306,14 @@ static void hybrid6_cx(float (*in)[2], float (*out)[32][2], const float (*filter ...@@ -303,14 +306,14 @@ static void hybrid6_cx(float (*in)[2], float (*out)[32][2], const float (*filter
int N = 8; int N = 8;
float temp[8][2]; float temp[8][2];
for (i = 0; i < len; i++) { for (i = 0; i < len; i++, in++) {
for (ssb = 0; ssb < N; ssb++) { for (ssb = 0; ssb < N; ssb++) {
float sum_re = filter[ssb][6][0] * in[i+6][0], sum_im = filter[ssb][6][0] * in[i+6][1]; float sum_re = filter[ssb][6][0] * in[6][0], sum_im = filter[ssb][6][0] * in[6][1];
for (j = 0; j < 6; j++) { for (j = 0; j < 6; j++) {
float in0_re = in[i+j][0]; float in0_re = in[j][0];
float in0_im = in[i+j][1]; float in0_im = in[j][1];
float in1_re = in[i+12-j][0]; float in1_re = in[12-j][0];
float in1_im = in[i+12-j][1]; float in1_im = in[12-j][1];
sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im); sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im);
sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re); sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re);
} }
...@@ -336,14 +339,14 @@ static void hybrid4_8_12_cx(float (*in)[2], float (*out)[32][2], const float (*f ...@@ -336,14 +339,14 @@ static void hybrid4_8_12_cx(float (*in)[2], float (*out)[32][2], const float (*f
{ {
int i, j, ssb; int i, j, ssb;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++, in++) {
for (ssb = 0; ssb < N; ssb++) { for (ssb = 0; ssb < N; ssb++) {
float sum_re = filter[ssb][6][0] * in[i+6][0], sum_im = filter[ssb][6][0] * in[i+6][1]; float sum_re = filter[ssb][6][0] * in[6][0], sum_im = filter[ssb][6][0] * in[6][1];
for (j = 0; j < 6; j++) { for (j = 0; j < 6; j++) {
float in0_re = in[i+j][0]; float in0_re = in[j][0];
float in0_im = in[i+j][1]; float in0_im = in[j][1];
float in1_re = in[i+12-j][0]; float in1_re = in[12-j][0];
float in1_im = in[i+12-j][1]; float in1_im = in[12-j][1];
sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im); sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im);
sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re); sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re);
} }
...@@ -810,16 +813,14 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 ...@@ -810,16 +813,14 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2
const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
//Remapping //Remapping
for (b = 0; b < PS_MAX_NR_IIDICC; b++) { memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0]));
H11[0][0][b] = H11[0][ps->num_env_old][b]; memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0]));
H12[0][0][b] = H12[0][ps->num_env_old][b]; memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0]));
H21[0][0][b] = H21[0][ps->num_env_old][b]; memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0]));
H22[0][0][b] = H22[0][ps->num_env_old][b]; memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0]));
H11[1][0][b] = H11[1][ps->num_env_old][b]; memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0]));
H12[1][0][b] = H12[1][ps->num_env_old][b]; memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0]));
H21[1][0][b] = H21[1][ps->num_env_old][b]; memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0]));
H22[1][0][b] = H22[1][ps->num_env_old][b];
}
if (is34) { if (is34) {
remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
...@@ -949,20 +950,20 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 ...@@ -949,20 +950,20 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2
h21r += h21r_step; h21r += h21r_step;
h22r += h22r_step; h22r += h22r_step;
if (!PS_BASELINE && ps->enable_ipdopd) { if (!PS_BASELINE && ps->enable_ipdopd) {
h11i += h11i_step; h11i += h11i_step;
h12i += h12i_step; h12i += h12i_step;
h21i += h21i_step; h21i += h21i_step;
h22i += h22i_step; h22i += h22i_step;
l[k][n][0] = h11r*l_re + h21r*r_re - h11i*l_im - h21i*r_im; l[k][n][0] = h11r*l_re + h21r*r_re - h11i*l_im - h21i*r_im;
l[k][n][1] = h11r*l_im + h21r*r_im + h11i*l_re + h21i*r_re; l[k][n][1] = h11r*l_im + h21r*r_im + h11i*l_re + h21i*r_re;
r[k][n][0] = h12r*l_re + h22r*r_re - h12i*l_im - h22i*r_im; r[k][n][0] = h12r*l_re + h22r*r_re - h12i*l_im - h22i*r_im;
r[k][n][1] = h12r*l_im + h22r*r_im + h12i*l_re + h22i*r_re; r[k][n][1] = h12r*l_im + h22r*r_im + h12i*l_re + h22i*r_re;
} else { } else {
l[k][n][0] = h11r*l_re + h21r*r_re; l[k][n][0] = h11r*l_re + h21r*r_re;
l[k][n][1] = h11r*l_im + h21r*r_im; l[k][n][1] = h11r*l_im + h21r*r_im;
r[k][n][0] = h12r*l_re + h22r*r_re; r[k][n][0] = h12r*l_re + h22r*r_re;
r[k][n][1] = h12r*l_im + h22r*r_im; r[k][n][1] = h12r*l_im + h22r*r_im;
} }
} }
} }
...@@ -1033,5 +1034,4 @@ av_cold void ff_ps_init(void) { ...@@ -1033,5 +1034,4 @@ av_cold void ff_ps_init(void) {
av_cold void ff_ps_ctx_init(PSContext *ps) av_cold void ff_ps_ctx_init(PSContext *ps)
{ {
ipdopd_reset(ps->ipd_hist, ps->opd_hist);
} }
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
typedef struct { typedef struct {
int start; int start;
int enable_iid; int enable_iid;
int iid_mode;
int iid_quant; int iid_quant;
int nr_iid_par; int nr_iid_par;
int nr_ipdopd_par; int nr_ipdopd_par;
......
...@@ -53,7 +53,6 @@ typedef struct { ...@@ -53,7 +53,6 @@ typedef struct {
static int http_connect(URLContext *h, const char *path, const char *hoststr, static int http_connect(URLContext *h, const char *path, const char *hoststr,
const char *auth, int *new_location); const char *auth, int *new_location);
static int http_write(URLContext *h, const uint8_t *buf, int size);
void ff_http_set_headers(URLContext *h, const char *headers) void ff_http_set_headers(URLContext *h, const char *headers)
{ {
...@@ -153,7 +152,6 @@ static int http_open(URLContext *h, const char *uri, int flags) ...@@ -153,7 +152,6 @@ static int http_open(URLContext *h, const char *uri, int flags)
} }
h->priv_data = s; h->priv_data = s;
s->filesize = -1; s->filesize = -1;
s->chunksize = -1;
s->is_chunked = 1; s->is_chunked = 1;
s->off = 0; s->off = 0;
s->init = 0; s->init = 0;
...@@ -323,7 +321,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr, ...@@ -323,7 +321,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
authstr ? authstr : ""); authstr ? authstr : "");
av_freep(&authstr); av_freep(&authstr);
if (http_write(h, s->buffer, strlen(s->buffer)) < 0) if (url_write(s->hd, s->buffer, strlen(s->buffer)) < 0)
return AVERROR(EIO); return AVERROR(EIO);
/* init input buffer */ /* init input buffer */
...@@ -332,6 +330,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr, ...@@ -332,6 +330,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
s->line_count = 0; s->line_count = 0;
s->off = 0; s->off = 0;
s->filesize = -1; s->filesize = -1;
s->chunksize = -1;
if (post) { if (post) {
/* always use chunked encoding for upload data */ /* always use chunked encoding for upload data */
s->chunksize = 0; s->chunksize = 0;
......
...@@ -64,9 +64,12 @@ enum IEC958DataType { ...@@ -64,9 +64,12 @@ enum IEC958DataType {
IEC958_ATRAC = 0x0E, ///< Atrac data IEC958_ATRAC = 0x0E, ///< Atrac data
IEC958_ATRAC3 = 0x0F, ///< Atrac 3 data IEC958_ATRAC3 = 0x0F, ///< Atrac 3 data
IEC958_ATRACX = 0x10, ///< Atrac 3 plus data IEC958_ATRACX = 0x10, ///< Atrac 3 plus data
IEC958_DTSHD = 0x11, ///< DTS HD data
IEC958_WMAPRO = 0x12, ///< WMA 9 Professional data IEC958_WMAPRO = 0x12, ///< WMA 9 Professional data
IEC958_MPEG2_AAC_LSF_2048 = 0x13, ///< MPEG-2 AAC ADTS half-rate low sampling frequency IEC958_MPEG2_AAC_LSF_2048 = 0x13, ///< MPEG-2 AAC ADTS half-rate low sampling frequency
IEC958_MPEG2_AAC_LSF_4096 = 0x13 | 0x20, ///< MPEG-2 AAC ADTS quarter-rate low sampling frequency IEC958_MPEG2_AAC_LSF_4096 = 0x13 | 0x20, ///< MPEG-2 AAC ADTS quarter-rate low sampling frequency
IEC958_EAC3 = 0x15, ///< E-AC-3 data
IEC958_TRUEHD = 0x16, ///< TrueHD data
}; };
typedef struct IEC958Context { typedef struct IEC958Context {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment