Upgraded FFmpeg to the release version 0.6 (only some minor compile fixes to the code
with regards to using the wrong #include scope in one file and disabling two apparently unmaintained asserts when compiling in DEBUG mode). I didn't yet test the GCC 2 build, but I need to get this into SVN since I am having some annoying file corruption troubles. In fact I am hoping I am not commiting broken files, but a few seconds ago everything was still building cleanly. One thing that definitely improved is the (disabled at the moment) AVI support. Every clip I tested so far plays, which can't be said about our native AVI reader. With the previous FFmpeg version (a random SVN revision is my guess), many old AVIs played completely broken. So far, I have not spotted any regressions git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38548 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
995b475caf
commit
8887a47ded
@ -63,6 +63,7 @@ if $(TARGET_ARCH) = x86 {
|
||||
HAIKU_FFMPEG_DEFINES += ARCH_SPARC=0 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_AMD3DNOW=$(HAIKU_FFMPEG_USE_AMD3DNOW) ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_AMD3DNOWEXT=$(HAIKU_FFMPEG_USE_AMD3DNOWEXT) ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_BIGENDIAN=0 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_MMX=$(HAIKU_FFMPEG_USE_MMX) ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_MMX2=$(HAIKU_FFMPEG_USE_MMX2) ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_SSE=$(HAIKU_FFMPEG_USE_SSE) ;
|
||||
@ -76,6 +77,7 @@ if $(TARGET_ARCH) = x86 {
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_AMD3DNOW=0 HAVE_AMD3DNOWEXT=0 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_MMX=0 HAVE_MMX2=0 HAVE_SSE=0 HAVE_SSSE3=0 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_ALTIVEC=1 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_BIGENDIAN=1 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_VIS=0 ;
|
||||
} else if $(TARGET_ARCH) = sparc {
|
||||
HAIKU_FFMPEG_DEFINES += ARCH_X86=0 ARCH_X86_32=0 ;
|
||||
@ -84,6 +86,7 @@ if $(TARGET_ARCH) = x86 {
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_AMD3DNOW=0 HAVE_AMD3DNOWEXT=0 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_MMX=0 HAVE_MMX2=0 HAVE_SSE=0 HAVE_SSSE3=0 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_ALTIVEC=0 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_BIGENDIAN=1 ;
|
||||
HAIKU_FFMPEG_DEFINES += HAVE_VIS=1 ;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,14 @@
|
||||
#ifndef FFMPEG_CONFIG_H
|
||||
#define FFMPEG_CONFIG_H
|
||||
#define FFMPEG_CONFIGURATION "--prefix=/boot/common --enable-shared --disable-debug --disable-mmx --disable-demuxer=audio-beos --disable-muxer=audio-beos"
|
||||
#define FFMPEG_LICENSE "nonfree and unredistributable"
|
||||
#define FFMPEG_DATADIR "/boot/common/share/ffmpeg"
|
||||
#define CC_TYPE "gcc"
|
||||
#define CC_VERSION __VERSION__
|
||||
#define restrict __restrict__
|
||||
#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\n\t"
|
||||
#define EXTERN_PREFIX ""
|
||||
#define EXTERN_ASM
|
||||
#define ARCH_ALPHA 0
|
||||
#define ARCH_ARM 0
|
||||
#define ARCH_AVR32 0
|
||||
@ -20,6 +27,7 @@
|
||||
#define ARCH_SH4 0
|
||||
// #define ARCH_SPARC 0
|
||||
#define ARCH_SPARC64 0
|
||||
#define ARCH_TOMI 0
|
||||
// #define ARCH_X86 1
|
||||
// #define ARCH_X86_32 1
|
||||
#define ARCH_X86_64 0
|
||||
@ -39,6 +47,7 @@
|
||||
// #define HAVE_SSE 0
|
||||
// #define HAVE_SSSE3 1
|
||||
// #define HAVE_VIS 0
|
||||
// #define HAVE_BIGENDIAN 0
|
||||
#define HAVE_BEOSTHREADS 0
|
||||
#define HAVE_OS2THREADS 0
|
||||
#define HAVE_PTHREADS 1
|
||||
@ -46,6 +55,7 @@
|
||||
#define HAVE_ALSA_ASOUNDLIB_H 0
|
||||
// #define HAVE_ALTIVEC_H 0
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
#define HAVE_ATTRIBUTE_MAY_ALIAS 1
|
||||
#define HAVE_ATTRIBUTE_PACKED 1
|
||||
#define HAVE_BIGENDIAN 0
|
||||
#define HAVE_BSWAP 1
|
||||
@ -65,13 +75,19 @@
|
||||
#define HAVE_EBP_AVAILABLE 1
|
||||
// We use position independant code so no EBX
|
||||
#define HAVE_EBX_AVAILABLE 0
|
||||
#define HAVE_EXP2 0
|
||||
#define HAVE_EXP2F 0
|
||||
#define HAVE_FAST_64BIT 0
|
||||
#define HAVE_FAST_CLZ 0
|
||||
#define HAVE_FAST_CMOV 0
|
||||
#define HAVE_FAST_UNALIGNED 1
|
||||
#define HAVE_FORK 1
|
||||
#define HAVE_GETADDRINFO 0
|
||||
#define HAVE_GETHRTIME 0
|
||||
#define HAVE_GETPROCESSMEMORYINFO 0
|
||||
#define HAVE_GETPROCESSTIMES 0
|
||||
#define HAVE_GETRUSAGE 1
|
||||
#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 0
|
||||
#define HAVE_INET_ATON 0
|
||||
#define HAVE_INLINE_ASM 1
|
||||
#define HAVE_ISATTY 1
|
||||
@ -79,7 +95,11 @@
|
||||
#define HAVE_LIBDC1394_1 0
|
||||
#define HAVE_LIBDC1394_2 0
|
||||
#define HAVE_LLRINT 1
|
||||
#define HAVE_LLRINTF 1
|
||||
#define HAVE_LOCAL_ALIGNED_16 1
|
||||
#define HAVE_LOCAL_ALIGNED_8 1
|
||||
#define HAVE_LOG2 1
|
||||
#define HAVE_LOG2F 1
|
||||
#define HAVE_LOONGSON 0
|
||||
#define HAVE_LRINT 1
|
||||
#define HAVE_LRINTF 1
|
||||
@ -99,6 +119,16 @@
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
#define HAVE_SOUNDCARD_H 0
|
||||
#define HAVE_POLL_H 1
|
||||
#define HAVE_SETRLIMIT 1
|
||||
#define HAVE_STRERROR_R 1
|
||||
#define HAVE_STRUCT_ADDRINFO 1
|
||||
#define HAVE_STRUCT_IPV6_MREQ 0
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 0
|
||||
#define HAVE_STRUCT_SOCKADDR_SA_LEN 1
|
||||
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
|
||||
#define HAVE_SYMVER 1
|
||||
#define HAVE_SYMVER_GNU_ASM 1
|
||||
#define HAVE_SYMVER_ASM_LABEL 0
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
@ -118,29 +148,37 @@
|
||||
#define CONFIG_DEMUXERS 1
|
||||
#define CONFIG_ENCODERS 1
|
||||
#define CONFIG_FILTERS 1
|
||||
#define CONFIG_HWACCELS 1
|
||||
#define CONFIG_HWACCELS 0
|
||||
#define CONFIG_INDEVS 0
|
||||
#define CONFIG_MUXERS 1
|
||||
#define CONFIG_OUTDEVS 0
|
||||
#define CONFIG_PARSERS 1
|
||||
#define CONFIG_PROTOCOLS 1
|
||||
#define CONFIG_AANDCT 1
|
||||
#define CONFIG_AVCODEC 1
|
||||
#define CONFIG_AVDEVICE 0
|
||||
#define CONFIG_AVFILTER 0
|
||||
#define CONFIG_AVFILTER_LAVF 0
|
||||
#define CONFIG_AVFORMAT 1
|
||||
#define CONFIG_AVISYNTH 0
|
||||
#define CONFIG_BEOS_NETSERVER 0
|
||||
#define CONFIG_BZLIB 0
|
||||
#define CONFIG_DCT 1
|
||||
#define CONFIG_DOC 0
|
||||
#define CONFIG_DWT 1
|
||||
#define CONFIG_DXVA2 0
|
||||
#define CONFIG_FASTDIV 1
|
||||
#define CONFIG_FFMPEG 0
|
||||
#define CONFIG_FFPLAY 0
|
||||
#define CONFIG_FFPROBE 0
|
||||
#define CONFIG_FFSERVER 0
|
||||
#define CONFIG_FFT 1
|
||||
#define CONFIG_GOLOMB 1
|
||||
//#define CONFIG_GPL 0 // defined in Jamfile depending on build config
|
||||
#define CONFIG_GPROF 0
|
||||
#define CONFIG_GRAY 0
|
||||
#define CONFIG_HARDCODED_TABLES 1
|
||||
#define CONFIG_IPV6 0
|
||||
#define CONFIG_H264DSP 1
|
||||
#define CONFIG_HARDCODED_TABLES 0
|
||||
#define CONFIG_LIBDC1394 0
|
||||
#define CONFIG_LIBDIRAC 0
|
||||
#define CONFIG_LIBFAAC 0
|
||||
@ -152,12 +190,16 @@
|
||||
#define CONFIG_LIBOPENCORE_AMRNB 0
|
||||
#define CONFIG_LIBOPENCORE_AMRWB 0
|
||||
#define CONFIG_LIBOPENJPEG 0
|
||||
#define CONFIG_LIBRTMP 0
|
||||
#define CONFIG_LIBSCHROEDINGER 0
|
||||
#define CONFIG_LIBSPEEX 0
|
||||
#define CONFIG_LIBTHEORA 0
|
||||
#define CONFIG_LIBVORBIS 0
|
||||
#define CONFIG_LIBVPX 0
|
||||
#define CONFIG_LIBX264 0
|
||||
#define CONFIG_LIBXVID 0
|
||||
#define CONFIG_LPC 1
|
||||
#define CONFIG_LSP 1
|
||||
#define CONFIG_MDCT 1
|
||||
#define CONFIG_MEMALIGN_HACK 0
|
||||
#define CONFIG_MLIB 0
|
||||
@ -171,25 +213,33 @@
|
||||
#define CONFIG_RUNTIME_CPUDETECT 0
|
||||
#define CONFIG_SHARED 0
|
||||
#define CONFIG_SMALL 0
|
||||
#define CONFIG_SRAM 0
|
||||
#define CONFIG_STATIC 1
|
||||
#define CONFIG_SWSCALE 1
|
||||
#define CONFIG_SWSCALE_ALPHA 1
|
||||
#define CONFIG_VAAPI 0
|
||||
#define CONFIG_VDPAU 0
|
||||
#define CONFIG_VERSION3 0
|
||||
#define CONFIG_X11GRAB 0
|
||||
#define CONFIG_ZLIB 1
|
||||
#define CONFIG_AVUTIL 1
|
||||
#define CONFIG_GPLV3 0
|
||||
#define CONFIG_LGPLV3 0
|
||||
#define CONFIG_AASC_DECODER 1
|
||||
#define CONFIG_AMV_DECODER 1
|
||||
#define CONFIG_ANM_DECODER 1
|
||||
#define CONFIG_ASV1_DECODER 1
|
||||
#define CONFIG_ASV2_DECODER 1
|
||||
#define CONFIG_AURA_DECODER 1
|
||||
#define CONFIG_AURA2_DECODER 1
|
||||
#define CONFIG_AVS_DECODER 1
|
||||
#define CONFIG_BETHSOFTVID_DECODER 1
|
||||
#define CONFIG_BFI_DECODER 1
|
||||
#define CONFIG_BINK_DECODER 1
|
||||
#define CONFIG_BMP_DECODER 1
|
||||
#define CONFIG_C93_DECODER 1
|
||||
#define CONFIG_CAVS_DECODER 0
|
||||
#define CONFIG_CDGRAPHICS_DECODER 1
|
||||
#define CONFIG_CINEPAK_DECODER 1
|
||||
#define CONFIG_CLJR_DECODER 1
|
||||
#define CONFIG_CSCD_DECODER 1
|
||||
@ -215,6 +265,7 @@
|
||||
#define CONFIG_FLV_DECODER 1
|
||||
#define CONFIG_FOURXM_DECODER 1
|
||||
#define CONFIG_FRAPS_DECODER 1
|
||||
#define CONFIG_FRWU_DECODER 1
|
||||
#define CONFIG_GIF_DECODER 1
|
||||
#define CONFIG_H261_DECODER 1
|
||||
#define CONFIG_H263_DECODER 1
|
||||
@ -223,10 +274,14 @@
|
||||
#define CONFIG_H264_VDPAU_DECODER 0
|
||||
#define CONFIG_HUFFYUV_DECODER 1
|
||||
#define CONFIG_IDCIN_DECODER 1
|
||||
#define CONFIG_IFF_BYTERUN1_DECODER 1
|
||||
#define CONFIG_IFF_ILBM_DECODER 1
|
||||
#define CONFIG_INDEO2_DECODER 1
|
||||
#define CONFIG_INDEO3_DECODER 1
|
||||
#define CONFIG_INDEO5_DECODER 1
|
||||
#define CONFIG_INTERPLAY_VIDEO_DECODER 1
|
||||
#define CONFIG_JPEGLS_DECODER 1
|
||||
#define CONFIG_KGV1_DECODER 1
|
||||
#define CONFIG_KMVC_DECODER 1
|
||||
#define CONFIG_LOCO_DECODER 1
|
||||
#define CONFIG_MDEC_DECODER 1
|
||||
@ -239,6 +294,7 @@
|
||||
#define CONFIG_MPEG1VIDEO_DECODER 1
|
||||
#define CONFIG_MPEG2VIDEO_DECODER 1
|
||||
#define CONFIG_MPEG4_DECODER 1
|
||||
#define CONFIG_MPEG4_VDPAU_DECODER 0
|
||||
#define CONFIG_MPEGVIDEO_DECODER 1
|
||||
#define CONFIG_MPEG_VDPAU_DECODER 0
|
||||
#define CONFIG_MPEG1_VDPAU_DECODER 0
|
||||
@ -260,6 +316,7 @@
|
||||
#define CONFIG_QDRAW_DECODER 1
|
||||
#define CONFIG_QPEG_DECODER 1
|
||||
#define CONFIG_QTRLE_DECODER 1
|
||||
#define CONFIG_R210_DECODER 1
|
||||
#define CONFIG_RAWVIDEO_DECODER 1
|
||||
#define CONFIG_RL2_DECODER 1
|
||||
#define CONFIG_ROQ_DECODER 1
|
||||
@ -308,13 +365,19 @@
|
||||
#define CONFIG_WNV1_DECODER 1
|
||||
#define CONFIG_XAN_WC3_DECODER 1
|
||||
#define CONFIG_XL_DECODER 1
|
||||
#define CONFIG_YOP_DECODER 1
|
||||
#define CONFIG_ZLIB_DECODER 1
|
||||
#define CONFIG_ZMBV_DECODER 1
|
||||
#define CONFIG_AAC_DECODER 1
|
||||
#define CONFIG_AC3_DECODER 1
|
||||
#define CONFIG_ALAC_DECODER 1
|
||||
#define CONFIG_ALS_DECODER 1
|
||||
#define CONFIG_AMRNB_DECODER 1
|
||||
#define CONFIG_APE_DECODER 1
|
||||
#define CONFIG_ATRAC1_DECODER 1
|
||||
#define CONFIG_ATRAC3_DECODER 1
|
||||
#define CONFIG_BINKAUDIO_DCT_DECODER 1
|
||||
#define CONFIG_BINKAUDIO_RDFT_DECODER 1
|
||||
#define CONFIG_COOK_DECODER 1
|
||||
#define CONFIG_DCA_DECODER 1
|
||||
#define CONFIG_DSICINAUDIO_DECODER 1
|
||||
@ -337,18 +400,23 @@
|
||||
#define CONFIG_RA_144_DECODER 1
|
||||
#define CONFIG_RA_288_DECODER 1
|
||||
#define CONFIG_SHORTEN_DECODER 1
|
||||
#define CONFIG_SIPR_DECODER 1
|
||||
#define CONFIG_SMACKAUD_DECODER 1
|
||||
#define CONFIG_SONIC_DECODER 1
|
||||
#define CONFIG_TRUEHD_DECODER 1
|
||||
#define CONFIG_TRUESPEECH_DECODER 1
|
||||
#define CONFIG_TTA_DECODER 1
|
||||
#define CONFIG_TWINVQ_DECODER 1
|
||||
#define CONFIG_VMDAUDIO_DECODER 1
|
||||
#define CONFIG_VORBIS_DECODER 1
|
||||
#define CONFIG_WAVPACK_DECODER 1
|
||||
#define CONFIG_WMAPRO_DECODER 1
|
||||
#define CONFIG_WMAV1_DECODER 1
|
||||
#define CONFIG_WMAV2_DECODER 1
|
||||
#define CONFIG_WMAVOICE_DECODER 1
|
||||
#define CONFIG_WS_SND1_DECODER 1
|
||||
#define CONFIG_PCM_ALAW_DECODER 1
|
||||
#define CONFIG_PCM_BLURAY_DECODER 1
|
||||
#define CONFIG_PCM_DVD_DECODER 1
|
||||
#define CONFIG_PCM_F32BE_DECODER 1
|
||||
#define CONFIG_PCM_F32LE_DECODER 1
|
||||
@ -406,6 +474,7 @@
|
||||
#define CONFIG_ADPCM_YAMAHA_DECODER 1
|
||||
#define CONFIG_DVBSUB_DECODER 1
|
||||
#define CONFIG_DVDSUB_DECODER 1
|
||||
#define CONFIG_PGSSUB_DECODER 1
|
||||
#define CONFIG_XSUB_DECODER 1
|
||||
#define CONFIG_LIBDIRAC_DECODER 0
|
||||
#define CONFIG_LIBFAAD_DECODER 0
|
||||
@ -416,6 +485,7 @@
|
||||
#define CONFIG_LIBOPENJPEG_DECODER 0
|
||||
#define CONFIG_LIBSCHROEDINGER_DECODER 0
|
||||
#define CONFIG_LIBSPEEX_DECODER 0
|
||||
#define CONFIG_LIBVPX_DECODER 0
|
||||
#define CONFIG_ASV1_ENCODER 0
|
||||
#define CONFIG_ASV2_ENCODER 0
|
||||
#define CONFIG_BMP_ENCODER 0
|
||||
@ -514,12 +584,17 @@
|
||||
#define CONFIG_LIBSCHROEDINGER_ENCODER 0
|
||||
#define CONFIG_LIBTHEORA_ENCODER 0
|
||||
#define CONFIG_LIBVORBIS_ENCODER 0
|
||||
#define CONFIG_LIBVPX_ENCODER 0
|
||||
#define CONFIG_LIBX264_ENCODER 0
|
||||
#define CONFIG_LIBXVID_ENCODER 0
|
||||
#define CONFIG_H263_VAAPI_HWACCEL 0
|
||||
#define CONFIG_H264_DXVA2_HWACCEL 0
|
||||
#define CONFIG_H264_VAAPI_HWACCEL 0
|
||||
#define CONFIG_MPEG2_VAAPI_HWACCEL 0
|
||||
#define CONFIG_MPEG4_VAAPI_HWACCEL 0
|
||||
#define CONFIG_VC1_DXVA2_HWACCEL 0
|
||||
#define CONFIG_VC1_VAAPI_HWACCEL 0
|
||||
#define CONFIG_WMV3_DXVA2_HWACCEL 0
|
||||
#define CONFIG_WMV3_VAAPI_HWACCEL 0
|
||||
#define CONFIG_AAC_PARSER 1
|
||||
#define CONFIG_AC3_PARSER 1
|
||||
@ -553,8 +628,10 @@
|
||||
#define CONFIG_TEXT2MOVSUB_BSF 1
|
||||
#define CONFIG_AAC_DEMUXER 1
|
||||
#define CONFIG_AC3_DEMUXER 1
|
||||
#define CONFIG_AEA_DEMUXER 1
|
||||
#define CONFIG_AIFF_DEMUXER 1
|
||||
#define CONFIG_AMR_DEMUXER 1
|
||||
#define CONFIG_ANM_DEMUXER 1
|
||||
#define CONFIG_APC_DEMUXER 1
|
||||
#define CONFIG_APE_DEMUXER 1
|
||||
#define CONFIG_ASF_DEMUXER 1
|
||||
@ -565,8 +642,11 @@
|
||||
#define CONFIG_AVS_DEMUXER 1
|
||||
#define CONFIG_BETHSOFTVID_DEMUXER 1
|
||||
#define CONFIG_BFI_DEMUXER 1
|
||||
#define CONFIG_BINK_DEMUXER 1
|
||||
#define CONFIG_C93_DEMUXER 1
|
||||
#define CONFIG_CAF_DEMUXER 1
|
||||
#define CONFIG_CAVSVIDEO_DEMUXER 1
|
||||
#define CONFIG_CDG_DEMUXER 1
|
||||
#define CONFIG_DAUD_DEMUXER 1
|
||||
#define CONFIG_DIRAC_DEMUXER 1
|
||||
#define CONFIG_DNXHD_DEMUXER 1
|
||||
@ -578,6 +658,7 @@
|
||||
#define CONFIG_EA_CDATA_DEMUXER 1
|
||||
#define CONFIG_EAC3_DEMUXER 1
|
||||
#define CONFIG_FFM_DEMUXER 1
|
||||
#define CONFIG_FILMSTRIP_DEMUXER 1
|
||||
#define CONFIG_FLAC_DEMUXER 1
|
||||
#define CONFIG_FLIC_DEMUXER 1
|
||||
#define CONFIG_FLV_DEMUXER 1
|
||||
@ -594,6 +675,7 @@
|
||||
#define CONFIG_INGENIENT_DEMUXER 1
|
||||
#define CONFIG_IPMOVIE_DEMUXER 1
|
||||
#define CONFIG_ISS_DEMUXER 1
|
||||
#define CONFIG_IV8_DEMUXER 1
|
||||
#define CONFIG_LMLM4_DEMUXER 0
|
||||
#define CONFIG_M4V_DEMUXER 1
|
||||
#define CONFIG_MATROSKA_DEMUXER 1
|
||||
@ -643,7 +725,6 @@
|
||||
#define CONFIG_QCP_DEMUXER 0
|
||||
#define CONFIG_R3D_DEMUXER 1
|
||||
#define CONFIG_RAWVIDEO_DEMUXER 1
|
||||
#define CONFIG_REDIR_DEMUXER 0
|
||||
#define CONFIG_RL2_DEMUXER 1
|
||||
#define CONFIG_RM_DEMUXER 1
|
||||
#define CONFIG_ROQ_DEMUXER 1
|
||||
@ -676,6 +757,7 @@
|
||||
#define CONFIG_WSVQA_DEMUXER 1
|
||||
#define CONFIG_WV_DEMUXER 1
|
||||
#define CONFIG_XA_DEMUXER 1
|
||||
#define CONFIG_YOP_DEMUXER 1
|
||||
#define CONFIG_YUV4MPEGPIPE_DEMUXER 1
|
||||
#define CONFIG_LIBNUT_DEMUXER 0
|
||||
#define CONFIG_AC3_MUXER 0
|
||||
@ -696,6 +778,7 @@
|
||||
#define CONFIG_DV_MUXER 0
|
||||
#define CONFIG_EAC3_MUXER 0
|
||||
#define CONFIG_FFM_MUXER 0
|
||||
#define CONFIG_FILMSTRIP_MUXER 0
|
||||
#define CONFIG_FLAC_MUXER 0
|
||||
#define CONFIG_FLV_MUXER 0
|
||||
#define CONFIG_FRAMECRC_MUXER 0
|
||||
@ -756,6 +839,7 @@
|
||||
#define CONFIG_RM_MUXER 0
|
||||
#define CONFIG_ROQ_MUXER 0
|
||||
#define CONFIG_RTP_MUXER 0
|
||||
#define CONFIG_RTSP_MUXER 0
|
||||
#define CONFIG_SOX_MUXER 0
|
||||
#define CONFIG_SPDIF_MUXER 0
|
||||
#define CONFIG_SWF_MUXER 0
|
||||
@ -765,17 +849,34 @@
|
||||
#define CONFIG_VC1T_MUXER 0
|
||||
#define CONFIG_VOC_MUXER 0
|
||||
#define CONFIG_WAV_MUXER 1
|
||||
#define CONFIG_WEBM_MUXER 1
|
||||
#define CONFIG_YUV4MPEGPIPE_MUXER 0
|
||||
#define CONFIG_LIBNUT_MUXER 0
|
||||
#define CONFIG_ASPECT_FILTER 1
|
||||
#define CONFIG_CROP_FILTER 1
|
||||
#define CONFIG_FORMAT_FILTER 1
|
||||
#define CONFIG_NOFORMAT_FILTER 1
|
||||
#define CONFIG_NULL_FILTER 1
|
||||
#define CONFIG_PIXELASPECT_FILTER 1
|
||||
#define CONFIG_SCALE_FILTER 1
|
||||
#define CONFIG_SLICIFY_FILTER 1
|
||||
#define CONFIG_UNSHARP_FILTER 1
|
||||
#define CONFIG_VFLIP_FILTER 1
|
||||
#define CONFIG_NULLSRC_FILTER 1
|
||||
#define CONFIG_NULLSINK_FILTER 1
|
||||
#define CONFIG_FILE_PROTOCOL 0
|
||||
#define CONFIG_GOPHER_PROTOCOL 0
|
||||
#define CONFIG_HTTP_PROTOCOL 0
|
||||
#define CONFIG_PIPE_PROTOCOL 0
|
||||
#define CONFIG_RTMP_PROTOCOL 0
|
||||
#define CONFIG_RTMPT_PROTOCOL 0
|
||||
#define CONFIG_RTMPE_PROTOCOL 0
|
||||
#define CONFIG_RTMPTE_PROTOCOL 0
|
||||
#define CONFIG_RTMPS_PROTOCOL 0
|
||||
#define CONFIG_RTP_PROTOCOL 0
|
||||
#define CONFIG_TCP_PROTOCOL 0
|
||||
#define CONFIG_UDP_PROTOCOL 0
|
||||
#define CONFIG_CONCAT_PROTOCOL 0
|
||||
#define CONFIG_ALSA_INDEV 0
|
||||
#define CONFIG_AUDIO_BEOS_INDEV 0
|
||||
#define CONFIG_BKTR_INDEV 0
|
||||
@ -790,7 +891,4 @@
|
||||
#define CONFIG_ALSA_OUTDEV 0
|
||||
#define CONFIG_AUDIO_BEOS_OUTDEV 0
|
||||
#define CONFIG_OSS_OUTDEV 0
|
||||
#define restrict __restrict__
|
||||
#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\n\t"
|
||||
#define EXTERN_PREFIX ""
|
||||
#endif /* FFMPEG_CONFIG_H */
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/4xm.c
|
||||
* @file
|
||||
* 4XM codec.
|
||||
*/
|
||||
|
||||
@ -137,7 +137,7 @@ typedef struct FourXContext{
|
||||
int mv[256];
|
||||
VLC pre_vlc;
|
||||
int last_dc;
|
||||
DECLARE_ALIGNED_8(DCTELEM, block[6][64]);
|
||||
DECLARE_ALIGNED(16, DCTELEM, block)[6][64];
|
||||
void *bitstream_buffer;
|
||||
unsigned int bitstream_buffer_size;
|
||||
int version;
|
||||
@ -815,7 +815,7 @@ static av_cold int decode_init(AVCodecContext *avctx){
|
||||
init_vlcs(f);
|
||||
|
||||
if(f->version>2) avctx->pix_fmt= PIX_FMT_RGB565;
|
||||
else avctx->pix_fmt= PIX_FMT_RGB555;
|
||||
else avctx->pix_fmt= PIX_FMT_BGR555;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -832,13 +832,17 @@ static av_cold int decode_end(AVCodecContext *avctx){
|
||||
f->cfrm[i].allocated_size= 0;
|
||||
}
|
||||
free_vlc(&f->pre_vlc);
|
||||
if(f->current_picture.data[0])
|
||||
avctx->release_buffer(avctx, &f->current_picture);
|
||||
if(f->last_picture.data[0])
|
||||
avctx->release_buffer(avctx, &f->last_picture);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVCodec fourxm_decoder = {
|
||||
"4xm",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_4XM,
|
||||
sizeof(FourXContext),
|
||||
decode_init,
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/8bps.c
|
||||
* @file
|
||||
* QT 8BPS Video Decoder by Roberto Togni
|
||||
* For more information about the 8BPS format, visit:
|
||||
* http://www.pcisys.net/~melanson/codecs/
|
||||
@ -159,10 +159,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
|
||||
c->pic.data[0] = NULL;
|
||||
|
||||
if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch (avctx->bits_per_coded_sample) {
|
||||
case 8:
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
@ -225,7 +221,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
|
||||
|
||||
AVCodec eightbps_decoder = {
|
||||
"8bps",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_8BPS,
|
||||
sizeof(EightBpsContext),
|
||||
decode_init,
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/8svx.c
|
||||
* @file
|
||||
* 8svx audio decoder
|
||||
* @author Jaikrishnan Menon
|
||||
* supports: fibonacci delta encoding
|
||||
@ -94,7 +94,7 @@ static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
|
||||
|
||||
AVCodec eightsvx_fib_decoder = {
|
||||
.name = "8svx_fib",
|
||||
.type = CODEC_TYPE_AUDIO,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = CODEC_ID_8SVX_FIB,
|
||||
.priv_data_size = sizeof (EightSvxContext),
|
||||
.init = eightsvx_decode_init,
|
||||
@ -104,7 +104,7 @@ AVCodec eightsvx_fib_decoder = {
|
||||
|
||||
AVCodec eightsvx_exp_decoder = {
|
||||
.name = "8svx_exp",
|
||||
.type = CODEC_TYPE_AUDIO,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = CODEC_ID_8SVX_EXP,
|
||||
.priv_data_size = sizeof (EightSvxContext),
|
||||
.init = eightsvx_decode_init,
|
||||
|
@ -23,6 +23,7 @@ StaticLibrary libavcodec.a :
|
||||
aac_ac3_parser.c
|
||||
aac_adtstoasc_bsf.c
|
||||
aac_parser.c
|
||||
aacsbr.c
|
||||
aactab.c
|
||||
aandcttab.c
|
||||
aasc.c
|
||||
@ -39,15 +40,26 @@ StaticLibrary libavcodec.a :
|
||||
adxdec.c
|
||||
alac.c
|
||||
allcodecs.c
|
||||
alsdec.c
|
||||
amrnbdec.c
|
||||
anm.c
|
||||
apedec.c
|
||||
asv1.c
|
||||
atrac.c
|
||||
atrac1.c
|
||||
atrac3.c
|
||||
audioconvert.c
|
||||
aura.c
|
||||
avfft.c
|
||||
avpacket.c
|
||||
avs.c
|
||||
beosthread.c
|
||||
bethsoftvideo.c
|
||||
bgmc.c
|
||||
bfi.c
|
||||
bink.c
|
||||
binkaudio.c
|
||||
binkidct.c
|
||||
bitstream.c
|
||||
bitstream_filter.c
|
||||
bmp.c
|
||||
@ -57,15 +69,21 @@ StaticLibrary libavcodec.a :
|
||||
cavs_parser.c
|
||||
cavsdec.c
|
||||
cavsdsp.c
|
||||
# cbrt_tablegen.c
|
||||
cdgraphics.c
|
||||
celp_filters.c
|
||||
celp_math.c
|
||||
cinepak.c
|
||||
cljr.c
|
||||
cook.c
|
||||
# costablegen.c
|
||||
cscd.c
|
||||
cyuv.c
|
||||
dca.c
|
||||
dca_parser.c
|
||||
dcadsp.c
|
||||
dct.c
|
||||
dirac.c
|
||||
dirac_parser.c
|
||||
dnxhd_parser.c
|
||||
dnxhddata.c
|
||||
@ -75,12 +93,18 @@ StaticLibrary libavcodec.a :
|
||||
dsputil.c
|
||||
dump_extradata_bsf.c
|
||||
dv.c
|
||||
# dv_tablegen.c
|
||||
dvbsub.c
|
||||
dvbsub_parser.c
|
||||
dvbsubdec.c
|
||||
dvdata.c
|
||||
dvdsub_parser.c
|
||||
dvdsubdec.c
|
||||
dwt.c
|
||||
dxa.c
|
||||
# dxva2.c
|
||||
# dxva2_h264.c
|
||||
# dxva2_vc1.c
|
||||
eac3dec.c
|
||||
eac3dec_data.c
|
||||
eacmv.c
|
||||
@ -103,7 +127,10 @@ StaticLibrary libavcodec.a :
|
||||
flacdec.c
|
||||
flashsv.c
|
||||
flicvideo.c
|
||||
flvenc.c
|
||||
flvdec.c
|
||||
fraps.c
|
||||
frwu.c
|
||||
g726.c
|
||||
# g729dec.c
|
||||
gif.c
|
||||
@ -116,27 +143,43 @@ StaticLibrary libavcodec.a :
|
||||
h263_parser.c
|
||||
h263dec.c
|
||||
h264.c
|
||||
h264_cabac.c
|
||||
h264_cavlc.c
|
||||
h264_direct.c
|
||||
h264_loopfilter.c
|
||||
h264_mp4toannexb_bsf.c
|
||||
h264_parser.c
|
||||
h264_ps.c
|
||||
h264_refs.c
|
||||
h264_sei.c
|
||||
h264dsp.c
|
||||
# h264dspenc.c
|
||||
h264idct.c
|
||||
h264pred.c
|
||||
huffman.c
|
||||
huffyuv.c
|
||||
idcinvideo.c
|
||||
iff.c
|
||||
imc.c
|
||||
imgconvert.c
|
||||
imx_dump_header_bsf.c
|
||||
indeo2.c
|
||||
indeo3.c
|
||||
indeo5.c
|
||||
intelh263dec.c
|
||||
interplayvideo.c
|
||||
intrax8.c
|
||||
intrax8dsp.c
|
||||
ituh263dec.c
|
||||
ituh263enc.c
|
||||
ivi_common.c
|
||||
ivi_dsp.c
|
||||
jfdctfst.c
|
||||
jfdctint.c
|
||||
jpegls.c
|
||||
jpeglsdec.c
|
||||
jrevdct.c
|
||||
kgv1dec.c
|
||||
kmvc.c
|
||||
lcldec.c
|
||||
# lclenc.c
|
||||
@ -148,6 +191,7 @@ StaticLibrary libavcodec.a :
|
||||
# lzwenc.c
|
||||
mace.c
|
||||
mdct.c
|
||||
# mdct_tablegen.c
|
||||
mdec.c
|
||||
mimic.c
|
||||
mjpeg.c
|
||||
@ -163,6 +207,7 @@ StaticLibrary libavcodec.a :
|
||||
mmvideo.c
|
||||
motion_est.c
|
||||
motionpixels.c
|
||||
# motionpixels_tablegen.c
|
||||
movsub_bsf.c
|
||||
mp3_header_compress_bsf.c
|
||||
mp3_header_decompress_bsf.c
|
||||
@ -170,12 +215,16 @@ StaticLibrary libavcodec.a :
|
||||
mpc7.c
|
||||
mpc8.c
|
||||
mpeg4audio.c
|
||||
mpeg4video.c
|
||||
mpeg4video_parser.c
|
||||
mpeg4videoenc.c
|
||||
mpeg4videodec.c
|
||||
mpeg12.c
|
||||
mpeg12data.c
|
||||
mpeg12enc.c
|
||||
mpegaudio.c
|
||||
mpegaudio_parser.c
|
||||
# mpegaudio_tablegen.c
|
||||
mpegaudiodata.c
|
||||
mpegaudiodec.c
|
||||
mpegaudiodecheader.c
|
||||
@ -195,21 +244,28 @@ StaticLibrary libavcodec.a :
|
||||
nuv.c
|
||||
opt.c
|
||||
options.c
|
||||
pamenc.c
|
||||
parser.c
|
||||
pcm.c
|
||||
pcm-mpeg.c
|
||||
# pcm_tablegen.c
|
||||
pcx.c
|
||||
pgssubdec.c
|
||||
png.c
|
||||
pngdec.c
|
||||
pnm.c
|
||||
pnm_parser.c
|
||||
pnmdec.c
|
||||
# pnmenc.c
|
||||
pthread.c
|
||||
ptx.c
|
||||
qcelpdec.c
|
||||
qdm2.c
|
||||
# qdm2_tablegen.c
|
||||
qdrw.c
|
||||
qpeg.c
|
||||
qtrle.c
|
||||
r210dec.c
|
||||
ra144.c
|
||||
ra288.c
|
||||
rangecoder.c
|
||||
@ -239,15 +295,19 @@ StaticLibrary libavcodec.a :
|
||||
sgidec.c
|
||||
shorten.c
|
||||
simple_idct.c
|
||||
sipr.c
|
||||
sipr16k.c
|
||||
smacker.c
|
||||
smc.c
|
||||
# snow.c
|
||||
snow.c
|
||||
sonic.c
|
||||
sp5xdec.c
|
||||
sunrast.c
|
||||
svq1.c
|
||||
svq1dec.c
|
||||
# svq3.c - Included by h264
|
||||
svq3.c
|
||||
synth_filter.c
|
||||
tableprint.c
|
||||
targa.c
|
||||
tiertexseqv.c
|
||||
tiff.c
|
||||
@ -257,9 +317,11 @@ StaticLibrary libavcodec.a :
|
||||
truespeech.c
|
||||
tscc.c
|
||||
tta.c
|
||||
twinvq.c
|
||||
txd.c
|
||||
ulti.c
|
||||
utils.c
|
||||
# vaapi_h264.c
|
||||
vb.c
|
||||
vc1.c
|
||||
vc1dec.c
|
||||
@ -278,12 +340,15 @@ StaticLibrary libavcodec.a :
|
||||
vp5.c
|
||||
vp56.c
|
||||
vp56data.c
|
||||
vp56dsp.c
|
||||
vp6.c
|
||||
vp6dsp.c
|
||||
vqavideo.c
|
||||
wavpack.c
|
||||
wma.c
|
||||
wmadec.c
|
||||
wmaprodec.c
|
||||
wmavoice.c
|
||||
wmv2.c
|
||||
wmv2dec.c
|
||||
wnv1.c
|
||||
@ -292,6 +357,7 @@ StaticLibrary libavcodec.a :
|
||||
xiph.c
|
||||
xl.c
|
||||
xsubdec.c
|
||||
yop.c
|
||||
zmbv.c
|
||||
;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aac.h
|
||||
* @file
|
||||
* AAC definitions and structures
|
||||
* @author Oded Shimon ( ods15 ods15 dyndns org )
|
||||
* @author Maxim Gavrilov ( maxim.gavrilov gmail com )
|
||||
@ -32,12 +32,14 @@
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
#include "mpeg4audio.h"
|
||||
#include "sbr.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define AAC_INIT_VLC_STATIC(num, size) \
|
||||
INIT_VLC_STATIC(&vlc_spectral[num], 6, ff_aac_spectral_sizes[num], \
|
||||
INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \
|
||||
ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \
|
||||
ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \
|
||||
size);
|
||||
@ -102,6 +104,17 @@ enum CouplingPoint {
|
||||
AFTER_IMDCT = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Output configuration status
|
||||
*/
|
||||
enum OCStatus {
|
||||
OC_NONE, //< Output unconfigured
|
||||
OC_TRIAL_PCE, //< Output configuration under trial specified by an inband PCE
|
||||
OC_TRIAL_FRAME, //< Output configuration under trial specified by a frame header
|
||||
OC_GLOBAL_HDR, //< Output configuration set in a global header but not yet locked
|
||||
OC_LOCKED, //< Output configuration locked in place
|
||||
};
|
||||
|
||||
/**
|
||||
* Predictor State
|
||||
*/
|
||||
@ -203,9 +216,9 @@ typedef struct {
|
||||
float sf[120]; ///< scalefactors
|
||||
int sf_idx[128]; ///< scalefactor indices (used by encoder)
|
||||
uint8_t zeroes[128]; ///< band is not coded (used by encoder)
|
||||
DECLARE_ALIGNED_16(float, coeffs[1024]); ///< coefficients for IMDCT
|
||||
DECLARE_ALIGNED_16(float, saved[1024]); ///< overlap
|
||||
DECLARE_ALIGNED_16(float, ret[1024]); ///< PCM output
|
||||
DECLARE_ALIGNED(16, float, coeffs)[1024]; ///< coefficients for IMDCT
|
||||
DECLARE_ALIGNED(16, float, saved)[1024]; ///< overlap
|
||||
DECLARE_ALIGNED(16, float, ret)[2048]; ///< PCM output
|
||||
PredictorState predictor_state[MAX_PREDICTORS];
|
||||
} SingleChannelElement;
|
||||
|
||||
@ -221,6 +234,7 @@ typedef struct {
|
||||
SingleChannelElement ch[2];
|
||||
// CCE specific
|
||||
ChannelCoupling coup;
|
||||
SpectralBandReplication sbr;
|
||||
} ChannelElement;
|
||||
|
||||
/**
|
||||
@ -250,15 +264,15 @@ typedef struct {
|
||||
* @defgroup temporary aligned temporary buffers (We do not want to have these on the stack.)
|
||||
* @{
|
||||
*/
|
||||
DECLARE_ALIGNED_16(float, buf_mdct[1024]);
|
||||
DECLARE_ALIGNED(16, float, buf_mdct)[1024];
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup tables Computed / set up during initialization.
|
||||
* @{
|
||||
*/
|
||||
MDCTContext mdct;
|
||||
MDCTContext mdct_small;
|
||||
FFTContext mdct;
|
||||
FFTContext mdct_small;
|
||||
DSPContext dsp;
|
||||
int random_state;
|
||||
/** @} */
|
||||
@ -273,9 +287,9 @@ typedef struct {
|
||||
int sf_offset; ///< offset into pow2sf_tab as appropriate for dsp.float_to_int16
|
||||
/** @} */
|
||||
|
||||
DECLARE_ALIGNED(16, float, temp[128]);
|
||||
DECLARE_ALIGNED(16, float, temp)[128];
|
||||
|
||||
int output_configured;
|
||||
enum OCStatus output_configured;
|
||||
} AACContext;
|
||||
|
||||
#endif /* AVCODEC_AAC_H */
|
||||
|
@ -71,24 +71,32 @@ get_next:
|
||||
*poutbuf_size = buf_size;
|
||||
|
||||
/* update codec info */
|
||||
avctx->sample_rate = s->sample_rate;
|
||||
if(s->codec_id)
|
||||
avctx->codec_id = s->codec_id;
|
||||
|
||||
/* allow downmixing to stereo (or mono for AC-3) */
|
||||
if(avctx->request_channels > 0 &&
|
||||
avctx->request_channels < s->channels &&
|
||||
(avctx->request_channels <= 2 ||
|
||||
(avctx->request_channels == 1 &&
|
||||
(avctx->codec_id == CODEC_ID_AC3 ||
|
||||
avctx->codec_id == CODEC_ID_EAC3)))) {
|
||||
avctx->channels = avctx->request_channels;
|
||||
} else if (avctx->codec_id != CODEC_ID_AAC || s->channels) {
|
||||
avctx->channels = s->channels;
|
||||
avctx->channel_layout = s->channel_layout;
|
||||
/* Due to backwards compatible HE-AAC the sample rate, channel count,
|
||||
and total number of samples found in an AAC ADTS header are not
|
||||
reliable. Bit rate is still accurate because the total frame duration in
|
||||
seconds is still correct (as is the number of bits in the frame). */
|
||||
if (avctx->codec_id != CODEC_ID_AAC) {
|
||||
avctx->sample_rate = s->sample_rate;
|
||||
|
||||
/* allow downmixing to stereo (or mono for AC-3) */
|
||||
if(avctx->request_channels > 0 &&
|
||||
avctx->request_channels < s->channels &&
|
||||
(avctx->request_channels <= 2 ||
|
||||
(avctx->request_channels == 1 &&
|
||||
(avctx->codec_id == CODEC_ID_AC3 ||
|
||||
avctx->codec_id == CODEC_ID_EAC3)))) {
|
||||
avctx->channels = avctx->request_channels;
|
||||
} else {
|
||||
avctx->channels = s->channels;
|
||||
avctx->channel_layout = s->channel_layout;
|
||||
}
|
||||
avctx->frame_size = s->samples;
|
||||
}
|
||||
|
||||
avctx->bit_rate = s->bit_rate;
|
||||
avctx->frame_size = s->samples;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc,
|
||||
buf += get_bits_count(&gb)/8;
|
||||
}
|
||||
avctx->extradata_size = 2 + pce_size;
|
||||
avctx->extradata = av_malloc(avctx->extradata_size);
|
||||
avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
init_put_bits(&pb, avctx->extradata, avctx->extradata_size);
|
||||
put_bits(&pb, 5, hdr.object_type);
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aaccoder.c
|
||||
* @file
|
||||
* AAC coefficients encoder
|
||||
*/
|
||||
|
||||
@ -100,7 +100,8 @@ static const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16}
|
||||
*
|
||||
* @return quantization distortion
|
||||
*/
|
||||
static float quantize_band_cost(struct AACEncContext *s, const float *in,
|
||||
static float quantize_and_encode_band_cost(struct AACEncContext *s,
|
||||
PutBitContext *pb, const float *in,
|
||||
const float *scaled, int size, int scale_idx,
|
||||
int cb, const float lambda, const float uplim,
|
||||
int *bits)
|
||||
@ -121,15 +122,19 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in,
|
||||
|
||||
if (!cb) {
|
||||
for (i = 0; i < size; i++)
|
||||
cost += in[i]*in[i]*lambda;
|
||||
cost += in[i]*in[i];
|
||||
if (bits)
|
||||
*bits = 0;
|
||||
return cost;
|
||||
return cost * lambda;
|
||||
}
|
||||
#ifndef USE_REALLY_FULL_SEARCH
|
||||
offs[0] = 1;
|
||||
for (i = 1; i < dim; i++)
|
||||
offs[i] = offs[i-1]*range;
|
||||
if (!scaled) {
|
||||
abs_pow34_v(s->scoefs, in, size);
|
||||
scaled = s->scoefs;
|
||||
}
|
||||
quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
|
||||
#endif /* USE_REALLY_FULL_SEARCH */
|
||||
for (i = 0; i < size; i += dim) {
|
||||
@ -141,10 +146,10 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in,
|
||||
int (*quants)[2] = &s->qcoefs[i];
|
||||
mincost = 0.0f;
|
||||
for (j = 0; j < dim; j++)
|
||||
mincost += in[i+j]*in[i+j]*lambda;
|
||||
mincost += in[i+j]*in[i+j];
|
||||
minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
|
||||
minbits = ff_aac_spectral_bits[cb-1][minidx];
|
||||
mincost += minbits;
|
||||
mincost = mincost * lambda + minbits;
|
||||
for (j = 0; j < (1<<dim); j++) {
|
||||
float rd = 0.0f;
|
||||
int curbits;
|
||||
@ -168,23 +173,24 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in,
|
||||
for (j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim) {
|
||||
float rd = 0.0f;
|
||||
int curbits = ff_aac_spectral_bits[cb-1][j];
|
||||
int curidx = j;
|
||||
#endif /* USE_REALLY_FULL_SEARCH */
|
||||
if (IS_CODEBOOK_UNSIGNED(cb)) {
|
||||
for (k = 0; k < dim; k++) {
|
||||
float t = fabsf(in[i+k]);
|
||||
float di;
|
||||
//do not code with escape sequence small values
|
||||
if (vec[k] == 64.0f && t < 39.0f*IQ) {
|
||||
rd = INFINITY;
|
||||
break;
|
||||
}
|
||||
if (vec[k] == 64.0f) { //FIXME: slow
|
||||
//do not code with escape sequence small values
|
||||
if (t < 39.0f*IQ) {
|
||||
rd = INFINITY;
|
||||
break;
|
||||
}
|
||||
if (t >= CLIPPED_ESCAPE) {
|
||||
di = t - CLIPPED_ESCAPE;
|
||||
curbits += 21;
|
||||
} else {
|
||||
int c = av_clip(quant(t, Q), 0, 8191);
|
||||
di = t - c*cbrt(c)*IQ;
|
||||
di = t - c*cbrtf(c)*IQ;
|
||||
curbits += av_log2(c)*2 - 4 + 1;
|
||||
}
|
||||
} else {
|
||||
@ -192,18 +198,18 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in,
|
||||
}
|
||||
if (vec[k] != 0.0f)
|
||||
curbits++;
|
||||
rd += di*di*lambda;
|
||||
rd += di*di;
|
||||
}
|
||||
} else {
|
||||
for (k = 0; k < dim; k++) {
|
||||
float di = in[i+k] - vec[k]*IQ;
|
||||
rd += di*di*lambda;
|
||||
rd += di*di;
|
||||
}
|
||||
}
|
||||
rd += curbits;
|
||||
rd = rd * lambda + curbits;
|
||||
if (rd < mincost) {
|
||||
mincost = rd;
|
||||
minidx = j;
|
||||
minidx = curidx;
|
||||
minbits = curbits;
|
||||
}
|
||||
}
|
||||
@ -211,117 +217,7 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in,
|
||||
resbits += minbits;
|
||||
if (cost >= uplim)
|
||||
return uplim;
|
||||
}
|
||||
|
||||
if (bits)
|
||||
*bits = resbits;
|
||||
return cost;
|
||||
}
|
||||
|
||||
static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb,
|
||||
const float *in, int size, int scale_idx,
|
||||
int cb, const float lambda)
|
||||
{
|
||||
const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
|
||||
const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
|
||||
const float CLIPPED_ESCAPE = 165140.0f*IQ;
|
||||
const int dim = (cb < FIRST_PAIR_BT) ? 4 : 2;
|
||||
int i, j, k;
|
||||
#ifndef USE_REALLY_FULL_SEARCH
|
||||
const float Q34 = sqrtf(Q * sqrtf(Q));
|
||||
const int range = aac_cb_range[cb];
|
||||
const int maxval = aac_cb_maxval[cb];
|
||||
int offs[4];
|
||||
float *scaled = s->scoefs;
|
||||
#endif /* USE_REALLY_FULL_SEARCH */
|
||||
|
||||
//START_TIMER
|
||||
if (!cb)
|
||||
return;
|
||||
|
||||
#ifndef USE_REALLY_FULL_SEARCH
|
||||
offs[0] = 1;
|
||||
for (i = 1; i < dim; i++)
|
||||
offs[i] = offs[i-1]*range;
|
||||
abs_pow34_v(scaled, in, size);
|
||||
quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
|
||||
#endif /* USE_REALLY_FULL_SEARCH */
|
||||
for (i = 0; i < size; i += dim) {
|
||||
float mincost;
|
||||
int minidx = 0;
|
||||
int minbits = 0;
|
||||
const float *vec;
|
||||
#ifndef USE_REALLY_FULL_SEARCH
|
||||
int (*quants)[2] = &s->qcoefs[i];
|
||||
mincost = 0.0f;
|
||||
for (j = 0; j < dim; j++)
|
||||
mincost += in[i+j]*in[i+j]*lambda;
|
||||
minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
|
||||
minbits = ff_aac_spectral_bits[cb-1][minidx];
|
||||
mincost += minbits;
|
||||
for (j = 0; j < (1<<dim); j++) {
|
||||
float rd = 0.0f;
|
||||
int curbits;
|
||||
int curidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
|
||||
int same = 0;
|
||||
for (k = 0; k < dim; k++) {
|
||||
if ((j & (1 << k)) && quants[k][0] == quants[k][1]) {
|
||||
same = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (same)
|
||||
continue;
|
||||
for (k = 0; k < dim; k++)
|
||||
curidx += quants[k][!!(j & (1 << k))] * offs[dim - 1 - k];
|
||||
curbits = ff_aac_spectral_bits[cb-1][curidx];
|
||||
vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
|
||||
#else
|
||||
vec = ff_aac_codebook_vectors[cb-1];
|
||||
mincost = INFINITY;
|
||||
for (j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim) {
|
||||
float rd = 0.0f;
|
||||
int curbits = ff_aac_spectral_bits[cb-1][j];
|
||||
int curidx = j;
|
||||
#endif /* USE_REALLY_FULL_SEARCH */
|
||||
if (IS_CODEBOOK_UNSIGNED(cb)) {
|
||||
for (k = 0; k < dim; k++) {
|
||||
float t = fabsf(in[i+k]);
|
||||
float di;
|
||||
//do not code with escape sequence small values
|
||||
if (vec[k] == 64.0f && t < 39.0f*IQ) {
|
||||
rd = INFINITY;
|
||||
break;
|
||||
}
|
||||
if (vec[k] == 64.0f) { //FIXME: slow
|
||||
if (t >= CLIPPED_ESCAPE) {
|
||||
di = t - CLIPPED_ESCAPE;
|
||||
curbits += 21;
|
||||
} else {
|
||||
int c = av_clip(quant(t, Q), 0, 8191);
|
||||
di = t - c*cbrt(c)*IQ;
|
||||
curbits += av_log2(c)*2 - 4 + 1;
|
||||
}
|
||||
} else {
|
||||
di = t - vec[k]*IQ;
|
||||
}
|
||||
if (vec[k] != 0.0f)
|
||||
curbits++;
|
||||
rd += di*di*lambda;
|
||||
}
|
||||
} else {
|
||||
for (k = 0; k < dim; k++) {
|
||||
float di = in[i+k] - vec[k]*IQ;
|
||||
rd += di*di*lambda;
|
||||
}
|
||||
}
|
||||
rd += curbits;
|
||||
if (rd < mincost) {
|
||||
mincost = rd;
|
||||
minidx = curidx;
|
||||
minbits = curbits;
|
||||
}
|
||||
}
|
||||
if (pb) {
|
||||
put_bits(pb, ff_aac_spectral_bits[cb-1][minidx], ff_aac_spectral_codes[cb-1][minidx]);
|
||||
if (IS_CODEBOOK_UNSIGNED(cb))
|
||||
for (j = 0; j < dim; j++)
|
||||
@ -338,8 +234,28 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//STOP_TIMER("quantize_and_encode")
|
||||
|
||||
if (bits)
|
||||
*bits = resbits;
|
||||
return cost;
|
||||
}
|
||||
static float quantize_band_cost(struct AACEncContext *s, const float *in,
|
||||
const float *scaled, int size, int scale_idx,
|
||||
int cb, const float lambda, const float uplim,
|
||||
int *bits)
|
||||
{
|
||||
return quantize_and_encode_band_cost(s, NULL, in, scaled, size, scale_idx,
|
||||
cb, lambda, uplim, bits);
|
||||
}
|
||||
|
||||
static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb,
|
||||
const float *in, int size, int scale_idx,
|
||||
int cb, const float lambda)
|
||||
{
|
||||
quantize_and_encode_band_cost(s, pb, in, NULL, size, scale_idx, cb, lambda,
|
||||
INFINITY, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -463,31 +379,36 @@ typedef struct TrellisPath {
|
||||
int max_val;
|
||||
} TrellisPath;
|
||||
|
||||
#define TRELLIS_STAGES 121
|
||||
#define TRELLIS_STATES 256
|
||||
|
||||
static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
|
||||
SingleChannelElement *sce,
|
||||
const float lambda)
|
||||
{
|
||||
int q, w, w2, g, start = 0;
|
||||
int i;
|
||||
int i, j;
|
||||
int idx;
|
||||
TrellisPath paths[256*121];
|
||||
int bandaddr[121];
|
||||
TrellisPath paths[TRELLIS_STAGES][TRELLIS_STATES];
|
||||
int bandaddr[TRELLIS_STAGES];
|
||||
int minq;
|
||||
float mincost;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
paths[i].cost = 0.0f;
|
||||
paths[i].prev = -1;
|
||||
paths[i].min_val = i;
|
||||
paths[i].max_val = i;
|
||||
for (i = 0; i < TRELLIS_STATES; i++) {
|
||||
paths[0][i].cost = 0.0f;
|
||||
paths[0][i].prev = -1;
|
||||
paths[0][i].min_val = i;
|
||||
paths[0][i].max_val = i;
|
||||
}
|
||||
for (i = 256; i < 256*121; i++) {
|
||||
paths[i].cost = INFINITY;
|
||||
paths[i].prev = -2;
|
||||
paths[i].min_val = INT_MAX;
|
||||
paths[i].max_val = 0;
|
||||
for (j = 1; j < TRELLIS_STAGES; j++) {
|
||||
for (i = 0; i < TRELLIS_STATES; i++) {
|
||||
paths[j][i].cost = INFINITY;
|
||||
paths[j][i].prev = -2;
|
||||
paths[j][i].min_val = INT_MAX;
|
||||
paths[j][i].max_val = 0;
|
||||
}
|
||||
}
|
||||
idx = 256;
|
||||
idx = 1;
|
||||
abs_pow34_v(s->scoefs, sce->coeffs, 1024);
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
start = w*128;
|
||||
@ -496,7 +417,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
|
||||
float qmin, qmax;
|
||||
int nz = 0;
|
||||
|
||||
bandaddr[idx >> 8] = w * 16 + g;
|
||||
bandaddr[idx] = w * 16 + g;
|
||||
qmin = INT_MAX;
|
||||
qmax = 0.0f;
|
||||
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
|
||||
@ -536,66 +457,67 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
|
||||
dist = FFMIN(dist, dists[i]);
|
||||
minrd = FFMIN(minrd, dist);
|
||||
|
||||
for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, 256); i++) {
|
||||
for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, TRELLIS_STATES); i++) {
|
||||
float cost;
|
||||
int minv, maxv;
|
||||
if (isinf(paths[idx - 256 + i].cost))
|
||||
if (isinf(paths[idx - 1][i].cost))
|
||||
continue;
|
||||
cost = paths[idx - 256 + i].cost + dist
|
||||
cost = paths[idx - 1][i].cost + dist
|
||||
+ ff_aac_scalefactor_bits[q - i + SCALE_DIFF_ZERO];
|
||||
minv = FFMIN(paths[idx - 256 + i].min_val, q);
|
||||
maxv = FFMAX(paths[idx - 256 + i].max_val, q);
|
||||
if (cost < paths[idx + q].cost && maxv-minv < SCALE_MAX_DIFF) {
|
||||
paths[idx + q].cost = cost;
|
||||
paths[idx + q].prev = idx - 256 + i;
|
||||
paths[idx + q].min_val = minv;
|
||||
paths[idx + q].max_val = maxv;
|
||||
minv = FFMIN(paths[idx - 1][i].min_val, q);
|
||||
maxv = FFMAX(paths[idx - 1][i].max_val, q);
|
||||
if (cost < paths[idx][q].cost && maxv-minv < SCALE_MAX_DIFF) {
|
||||
paths[idx][q].cost = cost;
|
||||
paths[idx][q].prev = i;
|
||||
paths[idx][q].min_val = minv;
|
||||
paths[idx][q].max_val = maxv;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (q = 0; q < 256; q++) {
|
||||
if (!isinf(paths[idx - 256 + q].cost)) {
|
||||
paths[idx + q].cost = paths[idx - 256 + q].cost + 1;
|
||||
paths[idx + q].prev = idx - 256 + q;
|
||||
paths[idx + q].min_val = FFMIN(paths[idx - 256 + q].min_val, q);
|
||||
paths[idx + q].max_val = FFMAX(paths[idx - 256 + q].max_val, q);
|
||||
for (q = 0; q < TRELLIS_STATES; q++) {
|
||||
if (!isinf(paths[idx - 1][q].cost)) {
|
||||
paths[idx][q].cost = paths[idx - 1][q].cost + 1;
|
||||
paths[idx][q].prev = q;
|
||||
paths[idx][q].min_val = FFMIN(paths[idx - 1][q].min_val, q);
|
||||
paths[idx][q].max_val = FFMAX(paths[idx - 1][q].max_val, q);
|
||||
continue;
|
||||
}
|
||||
for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, 256); i++) {
|
||||
for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, TRELLIS_STATES); i++) {
|
||||
float cost;
|
||||
int minv, maxv;
|
||||
if (isinf(paths[idx - 256 + i].cost))
|
||||
if (isinf(paths[idx - 1][i].cost))
|
||||
continue;
|
||||
cost = paths[idx - 256 + i].cost + ff_aac_scalefactor_bits[q - i + SCALE_DIFF_ZERO];
|
||||
minv = FFMIN(paths[idx - 256 + i].min_val, q);
|
||||
maxv = FFMAX(paths[idx - 256 + i].max_val, q);
|
||||
if (cost < paths[idx + q].cost && maxv-minv < SCALE_MAX_DIFF) {
|
||||
paths[idx + q].cost = cost;
|
||||
paths[idx + q].prev = idx - 256 + i;
|
||||
paths[idx + q].min_val = minv;
|
||||
paths[idx + q].max_val = maxv;
|
||||
cost = paths[idx - 1][i].cost + ff_aac_scalefactor_bits[q - i + SCALE_DIFF_ZERO];
|
||||
minv = FFMIN(paths[idx - 1][i].min_val, q);
|
||||
maxv = FFMAX(paths[idx - 1][i].max_val, q);
|
||||
if (cost < paths[idx][q].cost && maxv-minv < SCALE_MAX_DIFF) {
|
||||
paths[idx][q].cost = cost;
|
||||
paths[idx][q].prev = i;
|
||||
paths[idx][q].min_val = minv;
|
||||
paths[idx][q].max_val = maxv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sce->zeroes[w*16+g] = !nz;
|
||||
start += sce->ics.swb_sizes[g];
|
||||
idx += 256;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
idx -= 256;
|
||||
mincost = paths[idx].cost;
|
||||
minq = idx;
|
||||
for (i = 1; i < 256; i++) {
|
||||
if (paths[idx + i].cost < mincost) {
|
||||
mincost = paths[idx + i].cost;
|
||||
minq = idx + i;
|
||||
idx--;
|
||||
mincost = paths[idx][0].cost;
|
||||
minq = 0;
|
||||
for (i = 1; i < TRELLIS_STATES; i++) {
|
||||
if (paths[idx][i].cost < mincost) {
|
||||
mincost = paths[idx][i].cost;
|
||||
minq = i;
|
||||
}
|
||||
}
|
||||
while (minq >= 256) {
|
||||
sce->sf_idx[bandaddr[minq>>8]] = minq & 0xFF;
|
||||
minq = paths[minq].prev;
|
||||
while (idx) {
|
||||
sce->sf_idx[bandaddr[idx]] = minq;
|
||||
minq = paths[idx][minq].prev;
|
||||
idx--;
|
||||
}
|
||||
//set the same quantizers inside window groups
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
|
||||
@ -841,7 +763,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s,
|
||||
const float *scaled = s->scoefs + start;
|
||||
const int size = sce->ics.swb_sizes[g];
|
||||
int scf, prev_scf, step;
|
||||
int min_scf = 0, max_scf = 255;
|
||||
int min_scf = -1, max_scf = 256;
|
||||
float curdiff;
|
||||
if (maxq[w*16+g] < 21.544) {
|
||||
sce->zeroes[w*16+g] = 1;
|
||||
@ -875,21 +797,23 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s,
|
||||
}
|
||||
prev_scf = scf;
|
||||
curdiff = fabsf(dist - uplim[w*16+g]);
|
||||
if (curdiff == 0.0f)
|
||||
if (curdiff <= 1.0f)
|
||||
step = 0;
|
||||
else
|
||||
step = fabsf(log2(curdiff));
|
||||
step = log2(curdiff);
|
||||
if (dist > uplim[w*16+g])
|
||||
step = -step;
|
||||
scf += step;
|
||||
scf = av_clip_uint8(scf);
|
||||
step = scf - prev_scf;
|
||||
if (FFABS(step) <= 1 || (step > 0 && scf >= max_scf) || (step < 0 && scf <= min_scf)) {
|
||||
sce->sf_idx[w*16+g] = scf;
|
||||
sce->sf_idx[w*16+g] = av_clip(scf, min_scf, max_scf);
|
||||
break;
|
||||
}
|
||||
scf += step;
|
||||
if (step > 0)
|
||||
min_scf = scf;
|
||||
min_scf = prev_scf;
|
||||
else
|
||||
max_scf = scf;
|
||||
max_scf = prev_scf;
|
||||
}
|
||||
start += size;
|
||||
}
|
||||
@ -1013,24 +937,24 @@ AACCoefficientsEncoder ff_aac_coders[] = {
|
||||
search_for_quantizers_faac,
|
||||
encode_window_bands_info,
|
||||
quantize_and_encode_band,
|
||||
// search_for_ms,
|
||||
search_for_ms,
|
||||
},
|
||||
{
|
||||
search_for_quantizers_anmr,
|
||||
encode_window_bands_info,
|
||||
quantize_and_encode_band,
|
||||
// search_for_ms,
|
||||
search_for_ms,
|
||||
},
|
||||
{
|
||||
search_for_quantizers_twoloop,
|
||||
encode_window_bands_info,
|
||||
quantize_and_encode_band,
|
||||
// search_for_ms,
|
||||
search_for_ms,
|
||||
},
|
||||
{
|
||||
search_for_quantizers_fast,
|
||||
encode_window_bands_info,
|
||||
quantize_and_encode_band,
|
||||
// search_for_ms,
|
||||
search_for_ms,
|
||||
},
|
||||
};
|
||||
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aacdectab.h
|
||||
* @file
|
||||
* AAC decoder data
|
||||
* @author Oded Shimon ( ods15 ods15 dyndns org )
|
||||
* @author Maxim Gavrilov ( maxim.gavrilov gmail com )
|
||||
@ -69,4 +69,27 @@ static const float * const tns_tmp2_map[4] = {
|
||||
};
|
||||
// @}
|
||||
|
||||
static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
static const uint8_t aac_channel_layout_map[7][5][2] = {
|
||||
{ { TYPE_SCE, 0 }, },
|
||||
{ { TYPE_CPE, 0 }, },
|
||||
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, },
|
||||
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_SCE, 1 }, },
|
||||
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_CPE, 1 }, },
|
||||
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_LFE, 0 }, { TYPE_CPE, 1 }, },
|
||||
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_LFE, 0 }, { TYPE_CPE, 2 }, { TYPE_CPE, 1 }, },
|
||||
};
|
||||
|
||||
static const int64_t aac_channel_layout[8] = {
|
||||
CH_LAYOUT_MONO,
|
||||
CH_LAYOUT_STEREO,
|
||||
CH_LAYOUT_SURROUND,
|
||||
CH_LAYOUT_4POINT0,
|
||||
CH_LAYOUT_5POINT0_BACK,
|
||||
CH_LAYOUT_5POINT1_BACK,
|
||||
CH_LAYOUT_7POINT1_WIDE,
|
||||
0,
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_AACDECTAB_H */
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aacenc.c
|
||||
* @file
|
||||
* AAC encoder
|
||||
*/
|
||||
|
||||
@ -170,6 +170,14 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
|
||||
av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n", avctx->channels);
|
||||
return -1;
|
||||
}
|
||||
if (avctx->profile != FF_PROFILE_UNKNOWN && avctx->profile != FF_PROFILE_AAC_LOW) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Unsupported profile %d\n", avctx->profile);
|
||||
return -1;
|
||||
}
|
||||
if (1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * avctx->channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Too many bits per frame requested\n");
|
||||
return -1;
|
||||
}
|
||||
s->samplerate_index = i;
|
||||
|
||||
dsputil_init(&s->dsp, avctx);
|
||||
@ -178,8 +186,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
|
||||
// window init
|
||||
ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
|
||||
ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
|
||||
ff_sine_window_init(ff_sine_1024, 1024);
|
||||
ff_sine_window_init(ff_sine_128, 128);
|
||||
ff_init_ff_sine_windows(10);
|
||||
ff_init_ff_sine_windows(7);
|
||||
|
||||
s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0]));
|
||||
s->cpe = av_mallocz(sizeof(ChannelElement) * aac_chan_configs[avctx->channels-1][0]);
|
||||
@ -553,6 +561,7 @@ static int aac_encode_frame(AVCodecContext *avctx,
|
||||
chans = tag == TYPE_CPE ? 2 : 1;
|
||||
cpe = &s->cpe[i];
|
||||
for (j = 0; j < chans; j++) {
|
||||
s->cur_channel = start_ch + j;
|
||||
s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda);
|
||||
}
|
||||
cpe->common_window = 0;
|
||||
@ -568,6 +577,7 @@ static int aac_encode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
}
|
||||
}
|
||||
s->cur_channel = start_ch;
|
||||
if (cpe->common_window && s->coder->search_for_ms)
|
||||
s->coder->search_for_ms(s, cpe, s->lambda);
|
||||
adjust_frame_information(s, cpe, chans);
|
||||
@ -629,13 +639,13 @@ static av_cold int aac_encode_end(AVCodecContext *avctx)
|
||||
|
||||
AVCodec aac_encoder = {
|
||||
"aac",
|
||||
CODEC_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
CODEC_ID_AAC,
|
||||
sizeof(AACEncContext),
|
||||
aac_encode_init,
|
||||
aac_encode_frame,
|
||||
aac_encode_end,
|
||||
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
|
||||
.sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
|
||||
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL,
|
||||
.sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
|
||||
};
|
||||
|
@ -49,10 +49,10 @@ extern AACCoefficientsEncoder ff_aac_coders[];
|
||||
*/
|
||||
typedef struct AACEncContext {
|
||||
PutBitContext pb;
|
||||
MDCTContext mdct1024; ///< long (1024 samples) frame transform context
|
||||
MDCTContext mdct128; ///< short (128 samples) frame transform context
|
||||
FFTContext mdct1024; ///< long (1024 samples) frame transform context
|
||||
FFTContext mdct128; ///< short (128 samples) frame transform context
|
||||
DSPContext dsp;
|
||||
DECLARE_ALIGNED_16(FFTSample, output[2048]); ///< temporary buffer for MDCT input coefficients
|
||||
DECLARE_ALIGNED(16, FFTSample, output)[2048]; ///< temporary buffer for MDCT input coefficients
|
||||
int16_t* samples; ///< saved preprocessed input
|
||||
|
||||
int samplerate_index; ///< MPEG-4 samplerate index
|
||||
@ -64,8 +64,8 @@ typedef struct AACEncContext {
|
||||
int cur_channel;
|
||||
int last_frame;
|
||||
float lambda;
|
||||
DECLARE_ALIGNED_16(int, qcoefs[96][2]); ///< quantized coefficients
|
||||
DECLARE_ALIGNED_16(float, scoefs[1024]); ///< scaled coefficients
|
||||
DECLARE_ALIGNED(16, int, qcoefs)[96][2]; ///< quantized coefficients
|
||||
DECLARE_ALIGNED(16, float, scoefs)[1024]; ///< scaled coefficients
|
||||
} AACEncContext;
|
||||
|
||||
#endif /* AVCODEC_AACENC_H */
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aacpsy.c
|
||||
* @file
|
||||
* AAC encoder psychoacoustic model
|
||||
*/
|
||||
|
||||
|
1766
src/add-ons/media/plugins/ffmpeg/libavcodec/aacsbr.c
Normal file
1766
src/add-ons/media/plugins/ffmpeg/libavcodec/aacsbr.c
Normal file
File diff suppressed because it is too large
Load Diff
49
src/add-ons/media/plugins/ffmpeg/libavcodec/aacsbr.h
Normal file
49
src/add-ons/media/plugins/ffmpeg/libavcodec/aacsbr.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* AAC Spectral Band Replication function declarations
|
||||
* Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
|
||||
* Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
|
||||
*
|
||||
* 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 Spectral Band Replication function declarations
|
||||
* @author Robert Swain ( rob opendot cl )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACSBR_H
|
||||
#define AVCODEC_AACSBR_H
|
||||
|
||||
#include "get_bits.h"
|
||||
#include "aac.h"
|
||||
#include "sbr.h"
|
||||
|
||||
/** Initialize SBR. */
|
||||
av_cold void ff_aac_sbr_init(void);
|
||||
/** Initialize one SBR context. */
|
||||
av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr);
|
||||
/** Close one SBR context. */
|
||||
av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr);
|
||||
/** Decode one SBR element. */
|
||||
int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
|
||||
GetBitContext *gb, int crc, int cnt, int id_aac);
|
||||
/** Apply one SBR element to one AAC element. */
|
||||
void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
|
||||
float* L, float *R);
|
||||
|
||||
#endif /* AVCODEC_AACSBR_H */
|
614
src/add-ons/media/plugins/ffmpeg/libavcodec/aacsbrdata.h
Normal file
614
src/add-ons/media/plugins/ffmpeg/libavcodec/aacsbrdata.h
Normal file
@ -0,0 +1,614 @@
|
||||
/*
|
||||
* AAC Spectral Band Replication decoding data
|
||||
* Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
|
||||
*
|
||||
* 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 Spectral Band Replication decoding data
|
||||
* @author Robert Swain ( rob opendot cl )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACSBRDATA_H
|
||||
#define AVCODEC_AACSBRDATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/mem.h"
|
||||
|
||||
///< Huffman tables for SBR
|
||||
|
||||
static const uint8_t t_huffman_env_1_5dB_bits[121] = {
|
||||
18, 18, 18, 18, 18, 18, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 17, 18, 16, 17, 18, 17,
|
||||
16, 16, 16, 16, 15, 14, 14, 13,
|
||||
13, 12, 11, 10, 9, 8, 7, 6,
|
||||
5, 4, 3, 2, 2, 3, 4, 5,
|
||||
6, 7, 8, 9, 10, 12, 13, 14,
|
||||
14, 15, 16, 17, 16, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19,
|
||||
};
|
||||
|
||||
static const uint32_t t_huffman_env_1_5dB_codes[121] = {
|
||||
0x3ffd6, 0x3ffd7, 0x3ffd8, 0x3ffd9, 0x3ffda, 0x3ffdb, 0x7ffb8, 0x7ffb9,
|
||||
0x7ffba, 0x7ffbb, 0x7ffbc, 0x7ffbd, 0x7ffbe, 0x7ffbf, 0x7ffc0, 0x7ffc1,
|
||||
0x7ffc2, 0x7ffc3, 0x7ffc4, 0x7ffc5, 0x7ffc6, 0x7ffc7, 0x7ffc8, 0x7ffc9,
|
||||
0x7ffca, 0x7ffcb, 0x7ffcc, 0x7ffcd, 0x7ffce, 0x7ffcf, 0x7ffd0, 0x7ffd1,
|
||||
0x7ffd2, 0x7ffd3, 0x1ffe6, 0x3ffd4, 0x0fff0, 0x1ffe9, 0x3ffd5, 0x1ffe7,
|
||||
0x0fff1, 0x0ffec, 0x0ffed, 0x0ffee, 0x07ff4, 0x03ff9, 0x03ff7, 0x01ffa,
|
||||
0x01ff9, 0x00ffb, 0x007fc, 0x003fc, 0x001fd, 0x000fd, 0x0007d, 0x0003d,
|
||||
0x0001d, 0x0000d, 0x00005, 0x00001, 0x00000, 0x00004, 0x0000c, 0x0001c,
|
||||
0x0003c, 0x0007c, 0x000fc, 0x001fc, 0x003fd, 0x00ffa, 0x01ff8, 0x03ff6,
|
||||
0x03ff8, 0x07ff5, 0x0ffef, 0x1ffe8, 0x0fff2, 0x7ffd4, 0x7ffd5, 0x7ffd6,
|
||||
0x7ffd7, 0x7ffd8, 0x7ffd9, 0x7ffda, 0x7ffdb, 0x7ffdc, 0x7ffdd, 0x7ffde,
|
||||
0x7ffdf, 0x7ffe0, 0x7ffe1, 0x7ffe2, 0x7ffe3, 0x7ffe4, 0x7ffe5, 0x7ffe6,
|
||||
0x7ffe7, 0x7ffe8, 0x7ffe9, 0x7ffea, 0x7ffeb, 0x7ffec, 0x7ffed, 0x7ffee,
|
||||
0x7ffef, 0x7fff0, 0x7fff1, 0x7fff2, 0x7fff3, 0x7fff4, 0x7fff5, 0x7fff6,
|
||||
0x7fff7, 0x7fff8, 0x7fff9, 0x7fffa, 0x7fffb, 0x7fffc, 0x7fffd, 0x7fffe,
|
||||
0x7ffff,
|
||||
};
|
||||
|
||||
static const uint8_t f_huffman_env_1_5dB_bits[121] = {
|
||||
19, 19, 20, 20, 20, 20, 20, 20,
|
||||
20, 19, 20, 20, 20, 20, 19, 20,
|
||||
19, 19, 20, 18, 20, 20, 20, 19,
|
||||
20, 20, 20, 19, 20, 19, 18, 19,
|
||||
18, 18, 17, 18, 17, 17, 17, 16,
|
||||
16, 16, 15, 15, 14, 13, 13, 12,
|
||||
12, 11, 10, 9, 9, 8, 7, 6,
|
||||
5, 4, 3, 2, 2, 3, 4, 5,
|
||||
6, 8, 8, 9, 10, 11, 11, 11,
|
||||
12, 12, 13, 13, 14, 14, 16, 16,
|
||||
17, 17, 18, 18, 18, 18, 18, 18,
|
||||
18, 20, 19, 20, 20, 20, 20, 20,
|
||||
20, 19, 20, 20, 20, 20, 19, 20,
|
||||
18, 20, 20, 19, 19, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20,
|
||||
};
|
||||
|
||||
static const uint32_t f_huffman_env_1_5dB_codes[121] = {
|
||||
0x7ffe7, 0x7ffe8, 0xfffd2, 0xfffd3, 0xfffd4, 0xfffd5, 0xfffd6, 0xfffd7,
|
||||
0xfffd8, 0x7ffda, 0xfffd9, 0xfffda, 0xfffdb, 0xfffdc, 0x7ffdb, 0xfffdd,
|
||||
0x7ffdc, 0x7ffdd, 0xfffde, 0x3ffe4, 0xfffdf, 0xfffe0, 0xfffe1, 0x7ffde,
|
||||
0xfffe2, 0xfffe3, 0xfffe4, 0x7ffdf, 0xfffe5, 0x7ffe0, 0x3ffe8, 0x7ffe1,
|
||||
0x3ffe0, 0x3ffe9, 0x1ffef, 0x3ffe5, 0x1ffec, 0x1ffed, 0x1ffee, 0x0fff4,
|
||||
0x0fff3, 0x0fff0, 0x07ff7, 0x07ff6, 0x03ffa, 0x01ffa, 0x01ff9, 0x00ffa,
|
||||
0x00ff8, 0x007f9, 0x003fb, 0x001fc, 0x001fa, 0x000fb, 0x0007c, 0x0003c,
|
||||
0x0001c, 0x0000c, 0x00005, 0x00001, 0x00000, 0x00004, 0x0000d, 0x0001d,
|
||||
0x0003d, 0x000fa, 0x000fc, 0x001fb, 0x003fa, 0x007f8, 0x007fa, 0x007fb,
|
||||
0x00ff9, 0x00ffb, 0x01ff8, 0x01ffb, 0x03ff8, 0x03ff9, 0x0fff1, 0x0fff2,
|
||||
0x1ffea, 0x1ffeb, 0x3ffe1, 0x3ffe2, 0x3ffea, 0x3ffe3, 0x3ffe6, 0x3ffe7,
|
||||
0x3ffeb, 0xfffe6, 0x7ffe2, 0xfffe7, 0xfffe8, 0xfffe9, 0xfffea, 0xfffeb,
|
||||
0xfffec, 0x7ffe3, 0xfffed, 0xfffee, 0xfffef, 0xffff0, 0x7ffe4, 0xffff1,
|
||||
0x3ffec, 0xffff2, 0xffff3, 0x7ffe5, 0x7ffe6, 0xffff4, 0xffff5, 0xffff6,
|
||||
0xffff7, 0xffff8, 0xffff9, 0xffffa, 0xffffb, 0xffffc, 0xffffd, 0xffffe,
|
||||
0xfffff,
|
||||
};
|
||||
|
||||
static const uint8_t t_huffman_env_bal_1_5dB_bits[49] = {
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 12, 11, 9, 7, 5, 3,
|
||||
1, 2, 4, 6, 8, 11, 12, 15,
|
||||
16, 16, 16, 16, 16, 16, 16, 17,
|
||||
17, 17, 17, 17, 17, 17, 17, 17,
|
||||
17,
|
||||
};
|
||||
|
||||
static const uint32_t t_huffman_env_bal_1_5dB_codes[49] = {
|
||||
0x0ffe4, 0x0ffe5, 0x0ffe6, 0x0ffe7, 0x0ffe8, 0x0ffe9, 0x0ffea, 0x0ffeb,
|
||||
0x0ffec, 0x0ffed, 0x0ffee, 0x0ffef, 0x0fff0, 0x0fff1, 0x0fff2, 0x0fff3,
|
||||
0x0fff4, 0x0ffe2, 0x00ffc, 0x007fc, 0x001fe, 0x0007e, 0x0001e, 0x00006,
|
||||
0x00000, 0x00002, 0x0000e, 0x0003e, 0x000fe, 0x007fd, 0x00ffd, 0x07ff0,
|
||||
0x0ffe3, 0x0fff5, 0x0fff6, 0x0fff7, 0x0fff8, 0x0fff9, 0x0fffa, 0x1fff6,
|
||||
0x1fff7, 0x1fff8, 0x1fff9, 0x1fffa, 0x1fffb, 0x1fffc, 0x1fffd, 0x1fffe,
|
||||
0x1ffff,
|
||||
};
|
||||
|
||||
static const uint8_t f_huffman_env_bal_1_5dB_bits[49] = {
|
||||
18, 18, 18, 18, 18, 18, 18, 18,
|
||||
18, 18, 18, 18, 18, 18, 18, 16,
|
||||
17, 14, 11, 11, 8, 7, 4, 2,
|
||||
1, 3, 5, 6, 9, 11, 12, 15,
|
||||
16, 18, 18, 18, 18, 18, 18, 18,
|
||||
18, 18, 18, 18, 18, 18, 18, 19,
|
||||
19,
|
||||
};
|
||||
|
||||
static const uint32_t f_huffman_env_bal_1_5dB_codes[49] = {
|
||||
0x3ffe2, 0x3ffe3, 0x3ffe4, 0x3ffe5, 0x3ffe6, 0x3ffe7, 0x3ffe8, 0x3ffe9,
|
||||
0x3ffea, 0x3ffeb, 0x3ffec, 0x3ffed, 0x3ffee, 0x3ffef, 0x3fff0, 0x0fff7,
|
||||
0x1fff0, 0x03ffc, 0x007fe, 0x007fc, 0x000fe, 0x0007e, 0x0000e, 0x00002,
|
||||
0x00000, 0x00006, 0x0001e, 0x0003e, 0x001fe, 0x007fd, 0x00ffe, 0x07ffa,
|
||||
0x0fff6, 0x3fff1, 0x3fff2, 0x3fff3, 0x3fff4, 0x3fff5, 0x3fff6, 0x3fff7,
|
||||
0x3fff8, 0x3fff9, 0x3fffa, 0x3fffb, 0x3fffc, 0x3fffd, 0x3fffe, 0x7fffe,
|
||||
0x7ffff,
|
||||
};
|
||||
|
||||
static const uint8_t t_huffman_env_3_0dB_bits[63] = {
|
||||
18, 18, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 17, 16, 16, 16, 14, 14, 14,
|
||||
13, 12, 11, 8, 6, 4, 2, 1,
|
||||
3, 5, 7, 9, 11, 13, 14, 14,
|
||||
15, 16, 17, 18, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19,
|
||||
};
|
||||
|
||||
static const uint32_t t_huffman_env_3_0dB_codes[63] = {
|
||||
0x3ffed, 0x3ffee, 0x7ffde, 0x7ffdf, 0x7ffe0, 0x7ffe1, 0x7ffe2, 0x7ffe3,
|
||||
0x7ffe4, 0x7ffe5, 0x7ffe6, 0x7ffe7, 0x7ffe8, 0x7ffe9, 0x7ffea, 0x7ffeb,
|
||||
0x7ffec, 0x1fff4, 0x0fff7, 0x0fff9, 0x0fff8, 0x03ffb, 0x03ffa, 0x03ff8,
|
||||
0x01ffa, 0x00ffc, 0x007fc, 0x000fe, 0x0003e, 0x0000e, 0x00002, 0x00000,
|
||||
0x00006, 0x0001e, 0x0007e, 0x001fe, 0x007fd, 0x01ffb, 0x03ff9, 0x03ffc,
|
||||
0x07ffa, 0x0fff6, 0x1fff5, 0x3ffec, 0x7ffed, 0x7ffee, 0x7ffef, 0x7fff0,
|
||||
0x7fff1, 0x7fff2, 0x7fff3, 0x7fff4, 0x7fff5, 0x7fff6, 0x7fff7, 0x7fff8,
|
||||
0x7fff9, 0x7fffa, 0x7fffb, 0x7fffc, 0x7fffd, 0x7fffe, 0x7ffff,
|
||||
};
|
||||
|
||||
static const uint8_t f_huffman_env_3_0dB_bits[63] = {
|
||||
20, 20, 20, 20, 20, 20, 20, 18,
|
||||
19, 19, 19, 19, 18, 18, 20, 19,
|
||||
17, 18, 17, 16, 16, 15, 14, 12,
|
||||
11, 10, 9, 8, 6, 4, 2, 1,
|
||||
3, 5, 8, 9, 10, 11, 12, 13,
|
||||
14, 15, 15, 16, 16, 17, 17, 18,
|
||||
18, 18, 20, 19, 19, 19, 20, 19,
|
||||
19, 20, 20, 20, 20, 20, 20,
|
||||
};
|
||||
|
||||
static const uint32_t f_huffman_env_3_0dB_codes[63] = {
|
||||
0xffff0, 0xffff1, 0xffff2, 0xffff3, 0xffff4, 0xffff5, 0xffff6, 0x3fff3,
|
||||
0x7fff5, 0x7ffee, 0x7ffef, 0x7fff6, 0x3fff4, 0x3fff2, 0xffff7, 0x7fff0,
|
||||
0x1fff5, 0x3fff0, 0x1fff4, 0x0fff7, 0x0fff6, 0x07ff8, 0x03ffb, 0x00ffd,
|
||||
0x007fd, 0x003fd, 0x001fd, 0x000fd, 0x0003e, 0x0000e, 0x00002, 0x00000,
|
||||
0x00006, 0x0001e, 0x000fc, 0x001fc, 0x003fc, 0x007fc, 0x00ffc, 0x01ffc,
|
||||
0x03ffa, 0x07ff9, 0x07ffa, 0x0fff8, 0x0fff9, 0x1fff6, 0x1fff7, 0x3fff5,
|
||||
0x3fff6, 0x3fff1, 0xffff8, 0x7fff1, 0x7fff2, 0x7fff3, 0xffff9, 0x7fff7,
|
||||
0x7fff4, 0xffffa, 0xffffb, 0xffffc, 0xffffd, 0xffffe, 0xfffff,
|
||||
};
|
||||
|
||||
static const uint8_t t_huffman_env_bal_3_0dB_bits[25] = {
|
||||
13, 13, 13, 13, 13, 13, 13, 12,
|
||||
8, 7, 4, 3, 1, 2, 5, 6,
|
||||
9, 13, 13, 13, 13, 13, 13, 14,
|
||||
14,
|
||||
};
|
||||
|
||||
static const uint16_t t_huffman_env_bal_3_0dB_codes[25] = {
|
||||
0x1ff2, 0x1ff3, 0x1ff4, 0x1ff5, 0x1ff6, 0x1ff7, 0x1ff8, 0x0ff8,
|
||||
0x00fe, 0x007e, 0x000e, 0x0006, 0x0000, 0x0002, 0x001e, 0x003e,
|
||||
0x01fe, 0x1ff9, 0x1ffa, 0x1ffb, 0x1ffc, 0x1ffd, 0x1ffe, 0x3ffe,
|
||||
0x3fff,
|
||||
};
|
||||
|
||||
static const uint8_t f_huffman_env_bal_3_0dB_bits[25] = {
|
||||
13, 13, 13, 13, 13, 14, 14, 11,
|
||||
8, 7, 4, 2, 1, 3, 5, 6,
|
||||
9, 12, 13, 14, 14, 14, 14, 14,
|
||||
14,
|
||||
};
|
||||
|
||||
static const uint16_t f_huffman_env_bal_3_0dB_codes[25] = {
|
||||
0x1ff7, 0x1ff8, 0x1ff9, 0x1ffa, 0x1ffb, 0x3ff8, 0x3ff9, 0x07fc,
|
||||
0x00fe, 0x007e, 0x000e, 0x0002, 0x0000, 0x0006, 0x001e, 0x003e,
|
||||
0x01fe, 0x0ffa, 0x1ff6, 0x3ffa, 0x3ffb, 0x3ffc, 0x3ffd, 0x3ffe,
|
||||
0x3fff,
|
||||
};
|
||||
|
||||
static const uint8_t t_huffman_noise_3_0dB_bits[63] = {
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 11, 8, 6, 4, 3, 1,
|
||||
2, 5, 8, 10, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 14, 14,
|
||||
};
|
||||
|
||||
static const uint16_t t_huffman_noise_3_0dB_codes[63] = {
|
||||
0x1fce, 0x1fcf, 0x1fd0, 0x1fd1, 0x1fd2, 0x1fd3, 0x1fd4, 0x1fd5,
|
||||
0x1fd6, 0x1fd7, 0x1fd8, 0x1fd9, 0x1fda, 0x1fdb, 0x1fdc, 0x1fdd,
|
||||
0x1fde, 0x1fdf, 0x1fe0, 0x1fe1, 0x1fe2, 0x1fe3, 0x1fe4, 0x1fe5,
|
||||
0x1fe6, 0x1fe7, 0x07f2, 0x00fd, 0x003e, 0x000e, 0x0006, 0x0000,
|
||||
0x0002, 0x001e, 0x00fc, 0x03f8, 0x1fcc, 0x1fe8, 0x1fe9, 0x1fea,
|
||||
0x1feb, 0x1fec, 0x1fcd, 0x1fed, 0x1fee, 0x1fef, 0x1ff0, 0x1ff1,
|
||||
0x1ff2, 0x1ff3, 0x1ff4, 0x1ff5, 0x1ff6, 0x1ff7, 0x1ff8, 0x1ff9,
|
||||
0x1ffa, 0x1ffb, 0x1ffc, 0x1ffd, 0x1ffe, 0x3ffe, 0x3fff,
|
||||
};
|
||||
|
||||
static const uint8_t t_huffman_noise_bal_3_0dB_bits[25] = {
|
||||
8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 5, 2, 1, 3, 6, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8,
|
||||
};
|
||||
|
||||
static const uint8_t t_huffman_noise_bal_3_0dB_codes[25] = {
|
||||
0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3,
|
||||
0xf4, 0xf5, 0x1c, 0x02, 0x00, 0x06, 0x3a, 0xf6,
|
||||
0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe,
|
||||
0xff,
|
||||
};
|
||||
|
||||
static const int8_t sbr_offset[6][16] = {
|
||||
{-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}, // fs_sbr = 16000 Hz
|
||||
{-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13}, // fs_sbr = 22050 Hz
|
||||
{-5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, // fs_sbr = 24000 Hz
|
||||
{-6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, // fs_sbr = 32000 Hz
|
||||
{-4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20}, // 44100 Hz <= fs_sbr <= 64000 Hz
|
||||
{-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24}, // 64000 Hz < fs_sbr
|
||||
};
|
||||
|
||||
///< window coefficients for analysis/synthesis QMF banks
|
||||
static DECLARE_ALIGNED(16, float, sbr_qmf_window_ds)[320];
|
||||
static DECLARE_ALIGNED(16, float, sbr_qmf_window_us)[640] = {
|
||||
0.0000000000, -0.0005525286, -0.0005617692, -0.0004947518,
|
||||
-0.0004875227, -0.0004893791, -0.0005040714, -0.0005226564,
|
||||
-0.0005466565, -0.0005677802, -0.0005870930, -0.0006132747,
|
||||
-0.0006312493, -0.0006540333, -0.0006777690, -0.0006941614,
|
||||
-0.0007157736, -0.0007255043, -0.0007440941, -0.0007490598,
|
||||
-0.0007681371, -0.0007724848, -0.0007834332, -0.0007779869,
|
||||
-0.0007803664, -0.0007801449, -0.0007757977, -0.0007630793,
|
||||
-0.0007530001, -0.0007319357, -0.0007215391, -0.0006917937,
|
||||
-0.0006650415, -0.0006341594, -0.0005946118, -0.0005564576,
|
||||
-0.0005145572, -0.0004606325, -0.0004095121, -0.0003501175,
|
||||
-0.0002896981, -0.0002098337, -0.0001446380, -0.0000617334,
|
||||
0.0000134949, 0.0001094383, 0.0002043017, 0.0002949531,
|
||||
0.0004026540, 0.0005107388, 0.0006239376, 0.0007458025,
|
||||
0.0008608443, 0.0009885988, 0.0011250155, 0.0012577884,
|
||||
0.0013902494, 0.0015443219, 0.0016868083, 0.0018348265,
|
||||
0.0019841140, 0.0021461583, 0.0023017254, 0.0024625616,
|
||||
0.0026201758, 0.0027870464, 0.0029469447, 0.0031125420,
|
||||
0.0032739613, 0.0034418874, 0.0036008268, 0.0037603922,
|
||||
0.0039207432, 0.0040819753, 0.0042264269, 0.0043730719,
|
||||
0.0045209852, 0.0046606460, 0.0047932560, 0.0049137603,
|
||||
0.0050393022, 0.0051407353, 0.0052461166, 0.0053471681,
|
||||
0.0054196775, 0.0054876040, 0.0055475714, 0.0055938023,
|
||||
0.0056220643, 0.0056455196, 0.0056389199, 0.0056266114,
|
||||
0.0055917128, 0.0055404363, 0.0054753783, 0.0053838975,
|
||||
0.0052715758, 0.0051382275, 0.0049839687, 0.0048109469,
|
||||
0.0046039530, 0.0043801861, 0.0041251642, 0.0038456408,
|
||||
0.0035401246, 0.0032091885, 0.0028446757, 0.0024508540,
|
||||
0.0020274176, 0.0015784682, 0.0010902329, 0.0005832264,
|
||||
0.0000276045, -0.0005464280, -0.0011568135, -0.0018039472,
|
||||
-0.0024826723, -0.0031933778, -0.0039401124, -0.0047222596,
|
||||
-0.0055337211, -0.0063792293, -0.0072615816, -0.0081798233,
|
||||
-0.0091325329, -0.0101150215, -0.0111315548, -0.0121849995,
|
||||
0.0132718220, 0.0143904666, 0.0155405553, 0.0167324712,
|
||||
0.0179433381, 0.0191872431, 0.0204531793, 0.0217467550,
|
||||
0.0230680169, 0.0244160992, 0.0257875847, 0.0271859429,
|
||||
0.0286072173, 0.0300502657, 0.0315017608, 0.0329754081,
|
||||
0.0344620948, 0.0359697560, 0.0374812850, 0.0390053679,
|
||||
0.0405349170, 0.0420649094, 0.0436097542, 0.0451488405,
|
||||
0.0466843027, 0.0482165720, 0.0497385755, 0.0512556155,
|
||||
0.0527630746, 0.0542452768, 0.0557173648, 0.0571616450,
|
||||
0.0585915683, 0.0599837480, 0.0613455171, 0.0626857808,
|
||||
0.0639715898, 0.0652247106, 0.0664367512, 0.0676075985,
|
||||
0.0687043828, 0.0697630244, 0.0707628710, 0.0717002673,
|
||||
0.0725682583, 0.0733620255, 0.0741003642, 0.0747452558,
|
||||
0.0753137336, 0.0758008358, 0.0761992479, 0.0764992170,
|
||||
0.0767093490, 0.0768173975, 0.0768230011, 0.0767204924,
|
||||
0.0765050718, 0.0761748321, 0.0757305756, 0.0751576255,
|
||||
0.0744664394, 0.0736406005, 0.0726774642, 0.0715826364,
|
||||
0.0703533073, 0.0689664013, 0.0674525021, 0.0657690668,
|
||||
0.0639444805, 0.0619602779, 0.0598166570, 0.0575152691,
|
||||
0.0550460034, 0.0524093821, 0.0495978676, 0.0466303305,
|
||||
0.0434768782, 0.0401458278, 0.0366418116, 0.0329583930,
|
||||
0.0290824006, 0.0250307561, 0.0207997072, 0.0163701258,
|
||||
0.0117623832, 0.0069636862, 0.0019765601, -0.0032086896,
|
||||
-0.0085711749, -0.0141288827, -0.0198834129, -0.0258227288,
|
||||
-0.0319531274, -0.0382776572, -0.0447806821, -0.0514804176,
|
||||
-0.0583705326, -0.0654409853, -0.0726943300, -0.0801372934,
|
||||
-0.0877547536, -0.0955533352, -0.1035329531, -0.1116826931,
|
||||
-0.1200077984, -0.1285002850, -0.1371551761, -0.1459766491,
|
||||
-0.1549607071, -0.1640958855, -0.1733808172, -0.1828172548,
|
||||
-0.1923966745, -0.2021250176, -0.2119735853, -0.2219652696,
|
||||
-0.2320690870, -0.2423016884, -0.2526480309, -0.2631053299,
|
||||
-0.2736634040, -0.2843214189, -0.2950716717, -0.3059098575,
|
||||
-0.3168278913, -0.3278113727, -0.3388722693, -0.3499914122,
|
||||
0.3611589903, 0.3723795546, 0.3836350013, 0.3949211761,
|
||||
0.4062317676, 0.4175696896, 0.4289119920, 0.4402553754,
|
||||
0.4515996535, 0.4629308085, 0.4742453214, 0.4855253091,
|
||||
0.4967708254, 0.5079817500, 0.5191234970, 0.5302240895,
|
||||
0.5412553448, 0.5522051258, 0.5630789140, 0.5738524131,
|
||||
0.5845403235, 0.5951123086, 0.6055783538, 0.6159109932,
|
||||
0.6261242695, 0.6361980107, 0.6461269695, 0.6559016302,
|
||||
0.6655139880, 0.6749663190, 0.6842353293, 0.6933282376,
|
||||
0.7022388719, 0.7109410426, 0.7194462634, 0.7277448900,
|
||||
0.7358211758, 0.7436827863, 0.7513137456, 0.7587080760,
|
||||
0.7658674865, 0.7727780881, 0.7794287519, 0.7858353120,
|
||||
0.7919735841, 0.7978466413, 0.8034485751, 0.8087695004,
|
||||
0.8138191270, 0.8185776004, 0.8230419890, 0.8272275347,
|
||||
0.8311038457, 0.8346937361, 0.8379717337, 0.8409541392,
|
||||
0.8436238281, 0.8459818469, 0.8480315777, 0.8497805198,
|
||||
0.8511971524, 0.8523047035, 0.8531020949, 0.8535720573,
|
||||
0.8537385600,
|
||||
};
|
||||
|
||||
static const float sbr_noise_table[512][2] = {
|
||||
{-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647},
|
||||
{ 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647},
|
||||
{ 0.80705063769351, 0.29653668284408}, {-0.38981478896926, 0.89572605717087},
|
||||
{-0.01053049862020, -0.66959058036166}, {-0.91266367957293, -0.11522938140034},
|
||||
{ 0.54840422910309, 0.75221367176302}, { 0.40009252867955, -0.98929400334421},
|
||||
{-0.99867974711855, -0.88147068645358}, {-0.95531076805040, 0.90908757154593},
|
||||
{-0.45725933317144, -0.56716323646760}, {-0.72929675029275, -0.98008272727324},
|
||||
{ 0.75622801399036, 0.20950329995549}, { 0.07069442601050, -0.78247898470706},
|
||||
{ 0.74496252926055, -0.91169004445807}, {-0.96440182703856, -0.94739918296622},
|
||||
{ 0.30424629369539, -0.49438267012479}, { 0.66565033746925, 0.64652935542491},
|
||||
{ 0.91697008020594, 0.17514097332009}, {-0.70774918760427, 0.52548653416543},
|
||||
{-0.70051415345560, -0.45340028808763}, {-0.99496513054797, -0.90071908066973},
|
||||
{ 0.98164490790123, -0.77463155528697}, {-0.54671580548181, -0.02570928536004},
|
||||
{-0.01689629065389, 0.00287506445732}, {-0.86110349531986, 0.42548583726477},
|
||||
{-0.98892980586032, -0.87881132267556}, { 0.51756627678691, 0.66926784710139},
|
||||
{-0.99635026409640, -0.58107730574765}, {-0.99969370862163, 0.98369989360250},
|
||||
{ 0.55266258627194, 0.59449057465591}, { 0.34581177741673, 0.94879421061866},
|
||||
{ 0.62664209577999, -0.74402970906471}, {-0.77149701404973, -0.33883658042801},
|
||||
{-0.91592244254432, 0.03687901376713}, {-0.76285492357887, -0.91371867919124},
|
||||
{ 0.79788337195331, -0.93180971199849}, { 0.54473080610200, -0.11919206037186},
|
||||
{-0.85639281671058, 0.42429854760451}, {-0.92882402971423, 0.27871809078609},
|
||||
{-0.11708371046774, -0.99800843444966}, { 0.21356749817493, -0.90716295627033},
|
||||
{-0.76191692573909, 0.99768118356265}, { 0.98111043100884, -0.95854459734407},
|
||||
{-0.85913269895572, 0.95766566168880}, {-0.93307242253692, 0.49431757696466},
|
||||
{ 0.30485754879632, -0.70540034357529}, { 0.85289650925190, 0.46766131791044},
|
||||
{ 0.91328082618125, -0.99839597361769}, {-0.05890199924154, 0.70741827819497},
|
||||
{ 0.28398686150148, 0.34633555702188}, { 0.95258164539612, -0.54893416026939},
|
||||
{-0.78566324168507, -0.75568541079691}, {-0.95789495447877, -0.20423194696966},
|
||||
{ 0.82411158711197, 0.96654618432562}, {-0.65185446735885, -0.88734990773289},
|
||||
{-0.93643603134666, 0.99870790442385}, { 0.91427159529618, -0.98290505544444},
|
||||
{-0.70395684036886, 0.58796798221039}, { 0.00563771969365, 0.61768196727244},
|
||||
{ 0.89065051931895, 0.52783352697585}, {-0.68683707712762, 0.80806944710339},
|
||||
{ 0.72165342518718, -0.69259857349564}, {-0.62928247730667, 0.13627037407335},
|
||||
{ 0.29938434065514, -0.46051329682246}, {-0.91781958879280, -0.74012716684186},
|
||||
{ 0.99298717043688, 0.40816610075661}, { 0.82368298622748, -0.74036047190173},
|
||||
{-0.98512833386833, -0.99972330709594}, {-0.95915368242257, -0.99237800466040},
|
||||
{-0.21411126572790, -0.93424819052545}, {-0.68821476106884, -0.26892306315457},
|
||||
{ 0.91851997982317, 0.09358228901785}, {-0.96062769559127, 0.36099095133739},
|
||||
{ 0.51646184922287, -0.71373332873917}, { 0.61130721139669, 0.46950141175917},
|
||||
{ 0.47336129371299, -0.27333178296162}, { 0.90998308703519, 0.96715662938132},
|
||||
{ 0.44844799194357, 0.99211574628306}, { 0.66614891079092, 0.96590176169121},
|
||||
{ 0.74922239129237, -0.89879858826087}, {-0.99571588506485, 0.52785521494349},
|
||||
{ 0.97401082477563, -0.16855870075190}, { 0.72683747733879, -0.48060774432251},
|
||||
{ 0.95432193457128, 0.68849603408441}, {-0.72962208425191, -0.76608443420917},
|
||||
{-0.85359479233537, 0.88738125901579}, {-0.81412430338535, -0.97480768049637},
|
||||
{-0.87930772356786, 0.74748307690436}, {-0.71573331064977, -0.98570608178923},
|
||||
{ 0.83524300028228, 0.83702537075163}, {-0.48086065601423, -0.98848504923531},
|
||||
{ 0.97139128574778, 0.80093621198236}, { 0.51992825347895, 0.80247631400510},
|
||||
{-0.00848591195325, -0.76670128000486}, {-0.70294374303036, 0.55359910445577},
|
||||
{-0.95894428168140, -0.43265504344783}, { 0.97079252950321, 0.09325857238682},
|
||||
{-0.92404293670797, 0.85507704027855}, {-0.69506469500450, 0.98633412625459},
|
||||
{ 0.26559203620024, 0.73314307966524}, { 0.28038443336943, 0.14537913654427},
|
||||
{-0.74138124825523, 0.99310339807762}, {-0.01752795995444, -0.82616635284178},
|
||||
{-0.55126773094930, -0.98898543862153}, { 0.97960898850996, -0.94021446752851},
|
||||
{-0.99196309146936, 0.67019017358456}, {-0.67684928085260, 0.12631491649378},
|
||||
{ 0.09140039465500, -0.20537731453108}, {-0.71658965751996, -0.97788200391224},
|
||||
{ 0.81014640078925, 0.53722648362443}, { 0.40616991671205, -0.26469008598449},
|
||||
{-0.67680188682972, 0.94502052337695}, { 0.86849774348749, -0.18333598647899},
|
||||
{-0.99500381284851, -0.02634122068550}, { 0.84329189340667, 0.10406957462213},
|
||||
{-0.09215968531446, 0.69540012101253}, { 0.99956173327206, -0.12358542001404},
|
||||
{-0.79732779473535, -0.91582524736159}, { 0.96349973642406, 0.96640458041000},
|
||||
{-0.79942778496547, 0.64323902822857}, {-0.11566039853896, 0.28587846253726},
|
||||
{-0.39922954514662, 0.94129601616966}, { 0.99089197565987, -0.92062625581587},
|
||||
{ 0.28631285179909, -0.91035047143603}, {-0.83302725605608, -0.67330410892084},
|
||||
{ 0.95404443402072, 0.49162765398743}, {-0.06449863579434, 0.03250560813135},
|
||||
{-0.99575054486311, 0.42389784469507}, {-0.65501142790847, 0.82546114655624},
|
||||
{-0.81254441908887, -0.51627234660629}, {-0.99646369485481, 0.84490533520752},
|
||||
{ 0.00287840603348, 0.64768261158166}, { 0.70176989408455, -0.20453028573322},
|
||||
{ 0.96361882270190, 0.40706967140989}, {-0.68883758192426, 0.91338958840772},
|
||||
{-0.34875585502238, 0.71472290693300}, { 0.91980081243087, 0.66507455644919},
|
||||
{-0.99009048343881, 0.85868021604848}, { 0.68865791458395, 0.55660316809678},
|
||||
{-0.99484402129368, -0.20052559254934}, { 0.94214511408023, -0.99696425367461},
|
||||
{-0.67414626793544, 0.49548221180078}, {-0.47339353684664, -0.85904328834047},
|
||||
{ 0.14323651387360, -0.94145598222488}, {-0.29268293575672, 0.05759224927952},
|
||||
{ 0.43793861458754, -0.78904969892724}, {-0.36345126374441, 0.64874435357162},
|
||||
{-0.08750604656825, 0.97686944362527}, {-0.96495267812511, -0.53960305946511},
|
||||
{ 0.55526940659947, 0.78891523734774}, { 0.73538215752630, 0.96452072373404},
|
||||
{-0.30889773919437, -0.80664389776860}, { 0.03574995626194, -0.97325616900959},
|
||||
{ 0.98720684660488, 0.48409133691962}, {-0.81689296271203, -0.90827703628298},
|
||||
{ 0.67866860118215, 0.81284503870856}, {-0.15808569732583, 0.85279555024382},
|
||||
{ 0.80723395114371, -0.24717418514605}, { 0.47788757329038, -0.46333147839295},
|
||||
{ 0.96367554763201, 0.38486749303242}, {-0.99143875716818, -0.24945277239809},
|
||||
{ 0.83081876925833, -0.94780851414763}, {-0.58753191905341, 0.01290772389163},
|
||||
{ 0.95538108220960, -0.85557052096538}, {-0.96490920476211, -0.64020970923102},
|
||||
{-0.97327101028521, 0.12378128133110}, { 0.91400366022124, 0.57972471346930},
|
||||
{-0.99925837363824, 0.71084847864067}, {-0.86875903507313, -0.20291699203564},
|
||||
{-0.26240034795124, -0.68264554369108}, {-0.24664412953388, -0.87642273115183},
|
||||
{ 0.02416275806869, 0.27192914288905}, { 0.82068619590515, -0.85087787994476},
|
||||
{ 0.88547373760759, -0.89636802901469}, {-0.18173078152226, -0.26152145156800},
|
||||
{ 0.09355476558534, 0.54845123045604}, {-0.54668414224090, 0.95980774020221},
|
||||
{ 0.37050990604091, -0.59910140383171}, {-0.70373594262891, 0.91227665827081},
|
||||
{-0.34600785879594, -0.99441426144200}, {-0.68774481731008, -0.30238837956299},
|
||||
{-0.26843291251234, 0.83115668004362}, { 0.49072334613242, -0.45359708737775},
|
||||
{ 0.38975993093975, 0.95515358099121}, {-0.97757125224150, 0.05305894580606},
|
||||
{-0.17325552859616, -0.92770672250494}, { 0.99948035025744, 0.58285545563426},
|
||||
{-0.64946246527458, 0.68645507104960}, {-0.12016920576437, -0.57147322153312},
|
||||
{-0.58947456517751, -0.34847132454388}, {-0.41815140454465, 0.16276422358861},
|
||||
{ 0.99885650204884, 0.11136095490444}, {-0.56649614128386, -0.90494866361587},
|
||||
{ 0.94138021032330, 0.35281916733018}, {-0.75725076534641, 0.53650549640587},
|
||||
{ 0.20541973692630, -0.94435144369918}, { 0.99980371023351, 0.79835913565599},
|
||||
{ 0.29078277605775, 0.35393777921520}, {-0.62858772103030, 0.38765693387102},
|
||||
{ 0.43440904467688, -0.98546330463232}, {-0.98298583762390, 0.21021524625209},
|
||||
{ 0.19513029146934, -0.94239832251867}, {-0.95476662400101, 0.98364554179143},
|
||||
{ 0.93379635304810, -0.70881994583682}, {-0.85235410573336, -0.08342347966410},
|
||||
{-0.86425093011245, -0.45795025029466}, { 0.38879779059045, 0.97274429344593},
|
||||
{ 0.92045124735495, -0.62433652524220}, { 0.89162532251878, 0.54950955570563},
|
||||
{-0.36834336949252, 0.96458298020975}, { 0.93891760988045, -0.89968353740388},
|
||||
{ 0.99267657565094, -0.03757034316958}, {-0.94063471614176, 0.41332338538963},
|
||||
{ 0.99740224117019, -0.16830494996370}, {-0.35899413170555, -0.46633226649613},
|
||||
{ 0.05237237274947, -0.25640361602661}, { 0.36703583957424, -0.38653265641875},
|
||||
{ 0.91653180367913, -0.30587628726597}, { 0.69000803499316, 0.90952171386132},
|
||||
{-0.38658751133527, 0.99501571208985}, {-0.29250814029851, 0.37444994344615},
|
||||
{-0.60182204677608, 0.86779651036123}, {-0.97418588163217, 0.96468523666475},
|
||||
{ 0.88461574003963, 0.57508405276414}, { 0.05198933055162, 0.21269661669964},
|
||||
{-0.53499621979720, 0.97241553731237}, {-0.49429560226497, 0.98183865291903},
|
||||
{-0.98935142339139, -0.40249159006933}, {-0.98081380091130, -0.72856895534041},
|
||||
{-0.27338148835532, 0.99950922447209}, { 0.06310802338302, -0.54539587529618},
|
||||
{-0.20461677199539, -0.14209977628489}, { 0.66223843141647, 0.72528579940326},
|
||||
{-0.84764345483665, 0.02372316801261}, {-0.89039863483811, 0.88866581484602},
|
||||
{ 0.95903308477986, 0.76744927173873}, { 0.73504123909879, -0.03747203173192},
|
||||
{-0.31744434966056, -0.36834111883652}, {-0.34110827591623, 0.40211222807691},
|
||||
{ 0.47803883714199, -0.39423219786288}, { 0.98299195879514, 0.01989791390047},
|
||||
{-0.30963073129751, -0.18076720599336}, { 0.99992588229018, -0.26281872094289},
|
||||
{-0.93149731080767, -0.98313162570490}, { 0.99923472302773, -0.80142993767554},
|
||||
{-0.26024169633417, -0.75999759855752}, {-0.35712514743563, 0.19298963768574},
|
||||
{-0.99899084509530, 0.74645156992493}, { 0.86557171579452, 0.55593866696299},
|
||||
{ 0.33408042438752, 0.86185953874709}, { 0.99010736374716, 0.04602397576623},
|
||||
{-0.66694269691195, -0.91643611810148}, { 0.64016792079480, 0.15649530836856},
|
||||
{ 0.99570534804836, 0.45844586038111}, {-0.63431466947340, 0.21079116459234},
|
||||
{-0.07706847005931, -0.89581437101329}, { 0.98590090577724, 0.88241721133981},
|
||||
{ 0.80099335254678, -0.36851896710853}, { 0.78368131392666, 0.45506999802597},
|
||||
{ 0.08707806671691, 0.80938994918745}, {-0.86811883080712, 0.39347308654705},
|
||||
{-0.39466529740375, -0.66809432114456}, { 0.97875325649683, -0.72467840967746},
|
||||
{-0.95038560288864, 0.89563219587625}, { 0.17005239424212, 0.54683053962658},
|
||||
{-0.76910792026848, -0.96226617549298}, { 0.99743281016846, 0.42697157037567},
|
||||
{ 0.95437383549973, 0.97002324109952}, { 0.99578905365569, -0.54106826257356},
|
||||
{ 0.28058259829990, -0.85361420634036}, { 0.85256524470573, -0.64567607735589},
|
||||
{-0.50608540105128, -0.65846015480300}, {-0.97210735183243, -0.23095213067791},
|
||||
{ 0.95424048234441, -0.99240147091219}, {-0.96926570524023, 0.73775654896574},
|
||||
{ 0.30872163214726, 0.41514960556126}, {-0.24523839572639, 0.63206633394807},
|
||||
{-0.33813265086024, -0.38661779441897}, {-0.05826828420146, -0.06940774188029},
|
||||
{-0.22898461455054, 0.97054853316316}, {-0.18509915019881, 0.47565762892084},
|
||||
{-0.10488238045009, -0.87769947402394}, {-0.71886586182037, 0.78030982480538},
|
||||
{ 0.99793873738654, 0.90041310491497}, { 0.57563307626120, -0.91034337352097},
|
||||
{ 0.28909646383717, 0.96307783970534}, { 0.42188998312520, 0.48148651230437},
|
||||
{ 0.93335049681047, -0.43537023883588}, {-0.97087374418267, 0.86636445711364},
|
||||
{ 0.36722871286923, 0.65291654172961}, {-0.81093025665696, 0.08778370229363},
|
||||
{-0.26240603062237, -0.92774095379098}, { 0.83996497984604, 0.55839849139647},
|
||||
{-0.99909615720225, -0.96024605713970}, { 0.74649464155061, 0.12144893606462},
|
||||
{-0.74774595569805, -0.26898062008959}, { 0.95781667469567, -0.79047927052628},
|
||||
{ 0.95472308713099, -0.08588776019550}, { 0.48708332746299, 0.99999041579432},
|
||||
{ 0.46332038247497, 0.10964126185063}, {-0.76497004940162, 0.89210929242238},
|
||||
{ 0.57397389364339, 0.35289703373760}, { 0.75374316974495, 0.96705214651335},
|
||||
{-0.59174397685714, -0.89405370422752}, { 0.75087906691890, -0.29612672982396},
|
||||
{-0.98607857336230, 0.25034911730023}, {-0.40761056640505, -0.90045573444695},
|
||||
{ 0.66929266740477, 0.98629493401748}, {-0.97463695257310, -0.00190223301301},
|
||||
{ 0.90145509409859, 0.99781390365446}, {-0.87259289048043, 0.99233587353666},
|
||||
{-0.91529461447692, -0.15698707534206}, {-0.03305738840705, -0.37205262859764},
|
||||
{ 0.07223051368337, -0.88805001733626}, { 0.99498012188353, 0.97094358113387},
|
||||
{-0.74904939500519, 0.99985483641521}, { 0.04585228574211, 0.99812337444082},
|
||||
{-0.89054954257993, -0.31791913188064}, {-0.83782144651251, 0.97637632547466},
|
||||
{ 0.33454804933804, -0.86231516800408}, {-0.99707579362824, 0.93237990079441},
|
||||
{-0.22827527843994, 0.18874759397997}, { 0.67248046289143, -0.03646211390569},
|
||||
{-0.05146538187944, -0.92599700120679}, { 0.99947295749905, 0.93625229707912},
|
||||
{ 0.66951124390363, 0.98905825623893}, {-0.99602956559179, -0.44654715757688},
|
||||
{ 0.82104905483590, 0.99540741724928}, { 0.99186510988782, 0.72023001312947},
|
||||
{-0.65284592392918, 0.52186723253637}, { 0.93885443798188, -0.74895312615259},
|
||||
{ 0.96735248738388, 0.90891816978629}, {-0.22225968841114, 0.57124029781228},
|
||||
{-0.44132783753414, -0.92688840659280}, {-0.85694974219574, 0.88844532719844},
|
||||
{ 0.91783042091762, -0.46356892383970}, { 0.72556974415690, -0.99899555770747},
|
||||
{-0.99711581834508, 0.58211560180426}, { 0.77638976371966, 0.94321834873819},
|
||||
{ 0.07717324253925, 0.58638399856595}, {-0.56049829194163, 0.82522301569036},
|
||||
{ 0.98398893639988, 0.39467440420569}, { 0.47546946844938, 0.68613044836811},
|
||||
{ 0.65675089314631, 0.18331637134880}, { 0.03273375457980, -0.74933109564108},
|
||||
{-0.38684144784738, 0.51337349030406}, {-0.97346267944545, -0.96549364384098},
|
||||
{-0.53282156061942, -0.91423265091354}, { 0.99817310731176, 0.61133572482148},
|
||||
{-0.50254500772635, -0.88829338134294}, { 0.01995873238855, 0.85223515096765},
|
||||
{ 0.99930381973804, 0.94578896296649}, { 0.82907767600783, -0.06323442598128},
|
||||
{-0.58660709669728, 0.96840773806582}, {-0.17573736667267, -0.48166920859485},
|
||||
{ 0.83434292401346, -0.13023450646997}, { 0.05946491307025, 0.20511047074866},
|
||||
{ 0.81505484574602, -0.94685947861369}, {-0.44976380954860, 0.40894572671545},
|
||||
{-0.89746474625671, 0.99846578838537}, { 0.39677256130792, -0.74854668609359},
|
||||
{-0.07588948563079, 0.74096214084170}, { 0.76343198951445, 0.41746629422634},
|
||||
{-0.74490104699626, 0.94725911744610}, { 0.64880119792759, 0.41336660830571},
|
||||
{ 0.62319537462542, -0.93098313552599}, { 0.42215817594807, -0.07712787385208},
|
||||
{ 0.02704554141885, -0.05417518053666}, { 0.80001773566818, 0.91542195141039},
|
||||
{-0.79351832348816, -0.36208897989136}, { 0.63872359151636, 0.08128252493444},
|
||||
{ 0.52890520960295, 0.60048872455592}, { 0.74238552914587, 0.04491915291044},
|
||||
{ 0.99096131449250, -0.19451182854402}, {-0.80412329643109, -0.88513818199457},
|
||||
{-0.64612616129736, 0.72198674804544}, { 0.11657770663191, -0.83662833815041},
|
||||
{-0.95053182488101, -0.96939905138082}, {-0.62228872928622, 0.82767262846661},
|
||||
{ 0.03004475787316, -0.99738896333384}, {-0.97987214341034, 0.36526129686425},
|
||||
{-0.99986980746200, -0.36021610299715}, { 0.89110648599879, -0.97894250343044},
|
||||
{ 0.10407960510582, 0.77357793811619}, { 0.95964737821728, -0.35435818285502},
|
||||
{ 0.50843233159162, 0.96107691266205}, { 0.17006334670615, -0.76854025314829},
|
||||
{ 0.25872675063360, 0.99893303933816}, {-0.01115998681937, 0.98496019742444},
|
||||
{-0.79598702973261, 0.97138411318894}, {-0.99264708948101, -0.99542822402536},
|
||||
{-0.99829663752818, 0.01877138824311}, {-0.70801016548184, 0.33680685948117},
|
||||
{-0.70467057786826, 0.93272777501857}, { 0.99846021905254, -0.98725746254433},
|
||||
{-0.63364968534650, -0.16473594423746}, {-0.16258217500792, -0.95939125400802},
|
||||
{-0.43645594360633, -0.94805030113284}, {-0.99848471702976, 0.96245166923809},
|
||||
{-0.16796458968998, -0.98987511890470}, {-0.87979225745213, -0.71725725041680},
|
||||
{ 0.44183099021786, -0.93568974498761}, { 0.93310180125532, -0.99913308068246},
|
||||
{-0.93941931782002, -0.56409379640356}, {-0.88590003188677, 0.47624600491382},
|
||||
{ 0.99971463703691, -0.83889954253462}, {-0.75376385639978, 0.00814643438625},
|
||||
{ 0.93887685615875, -0.11284528204636}, { 0.85126435782309, 0.52349251543547},
|
||||
{ 0.39701421446381, 0.81779634174316}, {-0.37024464187437, -0.87071656222959},
|
||||
{-0.36024828242896, 0.34655735648287}, {-0.93388812549209, -0.84476541096429},
|
||||
{-0.65298804552119, -0.18439575450921}, { 0.11960319006843, 0.99899346780168},
|
||||
{ 0.94292565553160, 0.83163906518293}, { 0.75081145286948, -0.35533223142265},
|
||||
{ 0.56721979748394, -0.24076836414499}, { 0.46857766746029, -0.30140233457198},
|
||||
{ 0.97312313923635, -0.99548191630031}, {-0.38299976567017, 0.98516909715427},
|
||||
{ 0.41025800019463, 0.02116736935734}, { 0.09638062008048, 0.04411984381457},
|
||||
{-0.85283249275397, 0.91475563922421}, { 0.88866808958124, -0.99735267083226},
|
||||
{-0.48202429536989, -0.96805608884164}, { 0.27572582416567, 0.58634753335832},
|
||||
{-0.65889129659168, 0.58835634138583}, { 0.98838086953732, 0.99994349600236},
|
||||
{-0.20651349620689, 0.54593044066355}, {-0.62126416356920, -0.59893681700392},
|
||||
{ 0.20320105410437, -0.86879180355289}, {-0.97790548600584, 0.96290806999242},
|
||||
{ 0.11112534735126, 0.21484763313301}, {-0.41368337314182, 0.28216837680365},
|
||||
{ 0.24133038992960, 0.51294362630238}, {-0.66393410674885, -0.08249679629081},
|
||||
{-0.53697829178752, -0.97649903936228}, {-0.97224737889348, 0.22081333579837},
|
||||
{ 0.87392477144549, -0.12796173740361}, { 0.19050361015753, 0.01602615387195},
|
||||
{-0.46353441212724, -0.95249041539006}, {-0.07064096339021, -0.94479803205886},
|
||||
{-0.92444085484466, -0.10457590187436}, {-0.83822593578728, -0.01695043208885},
|
||||
{ 0.75214681811150, -0.99955681042665}, {-0.42102998829339, 0.99720941999394},
|
||||
{-0.72094786237696, -0.35008961934255}, { 0.78843311019251, 0.52851398958271},
|
||||
{ 0.97394027897442, -0.26695944086561}, { 0.99206463477946, -0.57010120849429},
|
||||
{ 0.76789609461795, -0.76519356730966}, {-0.82002421836409, -0.73530179553767},
|
||||
{ 0.81924990025724, 0.99698425250579}, {-0.26719850873357, 0.68903369776193},
|
||||
{-0.43311260380975, 0.85321815947490}, { 0.99194979673836, 0.91876249766422},
|
||||
{-0.80692001248487, -0.32627540663214}, { 0.43080003649976, -0.21919095636638},
|
||||
{ 0.67709491937357, -0.95478075822906}, { 0.56151770568316, -0.70693811747778},
|
||||
{ 0.10831862810749, -0.08628837174592}, { 0.91229417540436, -0.65987351408410},
|
||||
{-0.48972893932274, 0.56289246362686}, {-0.89033658689697, -0.71656563987082},
|
||||
{ 0.65269447475094, 0.65916004833932}, { 0.67439478141121, -0.81684380846796},
|
||||
{-0.47770832416973, -0.16789556203025}, {-0.99715979260878, -0.93565784007648},
|
||||
{-0.90889593602546, 0.62034397054380}, {-0.06618622548177, -0.23812217221359},
|
||||
{ 0.99430266919728, 0.18812555317553}, { 0.97686402381843, -0.28664534366620},
|
||||
{ 0.94813650221268, -0.97506640027128}, {-0.95434497492853, -0.79607978501983},
|
||||
{-0.49104783137150, 0.32895214359663}, { 0.99881175120751, 0.88993983831354},
|
||||
{ 0.50449166760303, -0.85995072408434}, { 0.47162891065108, -0.18680204049569},
|
||||
{-0.62081581361840, 0.75000676218956}, {-0.43867015250812, 0.99998069244322},
|
||||
{ 0.98630563232075, -0.53578899600662}, {-0.61510362277374, -0.89515019899997},
|
||||
{-0.03841517601843, -0.69888815681179}, {-0.30102157304644, -0.07667808922205},
|
||||
{ 0.41881284182683, 0.02188098922282}, {-0.86135454941237, 0.98947480909359},
|
||||
{ 0.67226861393788, -0.13494389011014}, {-0.70737398842068, -0.76547349325992},
|
||||
{ 0.94044946687963, 0.09026201157416}, {-0.82386352534327, 0.08924768823676},
|
||||
{-0.32070666698656, 0.50143421908753}, { 0.57593163224487, -0.98966422921509},
|
||||
{-0.36326018419965, 0.07440243123228}, { 0.99979044674350, -0.14130287347405},
|
||||
{-0.92366023326932, -0.97979298068180}, {-0.44607178518598, -0.54233252016394},
|
||||
{ 0.44226800932956, 0.71326756742752}, { 0.03671907158312, 0.63606389366675},
|
||||
{ 0.52175424682195, -0.85396826735705}, {-0.94701139690956, -0.01826348194255},
|
||||
{-0.98759606946049, 0.82288714303073}, { 0.87434794743625, 0.89399495655433},
|
||||
{-0.93412041758744, 0.41374052024363}, { 0.96063943315511, 0.93116709541280},
|
||||
{ 0.97534253457837, 0.86150930812689}, { 0.99642466504163, 0.70190043427512},
|
||||
{-0.94705089665984, -0.29580042814306}, { 0.91599807087376, -0.98147830385781},
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_AACSBRDATA_H */
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aactab.c
|
||||
* @file
|
||||
* AAC data
|
||||
* @author Oded Shimon ( ods15 ods15 dyndns org )
|
||||
* @author Maxim Gavrilov ( maxim.gavrilov gmail com )
|
||||
@ -32,8 +32,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
DECLARE_ALIGNED(16, float, ff_aac_kbd_long_1024[1024]);
|
||||
DECLARE_ALIGNED(16, float, ff_aac_kbd_short_128[128]);
|
||||
DECLARE_ALIGNED(16, float, ff_aac_kbd_long_1024)[1024];
|
||||
DECLARE_ALIGNED(16, float, ff_aac_kbd_short_128)[128];
|
||||
|
||||
const uint8_t ff_aac_num_swb_1024[] = {
|
||||
41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40
|
||||
@ -409,7 +409,7 @@ const uint16_t ff_aac_spectral_sizes[11] = {
|
||||
* 64.0f is a special value indicating the existence of an escape code in the
|
||||
* bitstream.
|
||||
*/
|
||||
static const float codebook_vector0[324] = {
|
||||
static const DECLARE_ALIGNED(16, float, codebook_vector0)[324] = {
|
||||
-1.0000000, -1.0000000, -1.0000000, -1.0000000,
|
||||
-1.0000000, -1.0000000, -1.0000000, 0.0000000,
|
||||
-1.0000000, -1.0000000, -1.0000000, 1.0000000,
|
||||
@ -493,7 +493,7 @@ static const float codebook_vector0[324] = {
|
||||
1.0000000, 1.0000000, 1.0000000, 1.0000000,
|
||||
};
|
||||
|
||||
static const float codebook_vector2[324] = {
|
||||
static const DECLARE_ALIGNED(16, float, codebook_vector2)[324] = {
|
||||
0.0000000, 0.0000000, 0.0000000, 0.0000000,
|
||||
0.0000000, 0.0000000, 0.0000000, 1.0000000,
|
||||
0.0000000, 0.0000000, 0.0000000, 2.5198421,
|
||||
@ -577,7 +577,7 @@ static const float codebook_vector2[324] = {
|
||||
2.5198421, 2.5198421, 2.5198421, 2.5198421,
|
||||
};
|
||||
|
||||
static const float codebook_vector4[162] = {
|
||||
static const DECLARE_ALIGNED(16, float, codebook_vector4)[162] = {
|
||||
-6.3496042, -6.3496042, -6.3496042, -4.3267487,
|
||||
-6.3496042, -2.5198421, -6.3496042, -1.0000000,
|
||||
-6.3496042, 0.0000000, -6.3496042, 1.0000000,
|
||||
@ -621,7 +621,7 @@ static const float codebook_vector4[162] = {
|
||||
6.3496042, 6.3496042,
|
||||
};
|
||||
|
||||
static const float codebook_vector6[128] = {
|
||||
static const DECLARE_ALIGNED(16, float, codebook_vector6)[128] = {
|
||||
0.0000000, 0.0000000, 0.0000000, 1.0000000,
|
||||
0.0000000, 2.5198421, 0.0000000, 4.3267487,
|
||||
0.0000000, 6.3496042, 0.0000000, 8.5498797,
|
||||
@ -656,7 +656,7 @@ static const float codebook_vector6[128] = {
|
||||
13.3905183, 10.9027236, 13.3905183, 13.3905183,
|
||||
};
|
||||
|
||||
static const float codebook_vector8[338] = {
|
||||
static const DECLARE_ALIGNED(16, float, codebook_vector8)[338] = {
|
||||
0.0000000, 0.0000000, 0.0000000, 1.0000000,
|
||||
0.0000000, 2.5198421, 0.0000000, 4.3267487,
|
||||
0.0000000, 6.3496042, 0.0000000, 8.5498797,
|
||||
@ -744,7 +744,7 @@ static const float codebook_vector8[338] = {
|
||||
27.4731418, 27.4731418,
|
||||
};
|
||||
|
||||
static const float codebook_vector10[578] = {
|
||||
static const DECLARE_ALIGNED(16, float, codebook_vector10)[578] = {
|
||||
0.0000000, 0.0000000, 0.0000000, 1.0000000,
|
||||
0.0000000, 2.5198421, 0.0000000, 4.3267487,
|
||||
0.0000000, 6.3496042, 0.0000000, 8.5498797,
|
||||
@ -899,6 +899,173 @@ const float * const ff_aac_codebook_vectors[] = {
|
||||
codebook_vector8, codebook_vector10,
|
||||
};
|
||||
|
||||
static const float codebook_vector0_vals[] = {
|
||||
-1.0000000, 0.0000000, 1.0000000
|
||||
};
|
||||
|
||||
/*
|
||||
* bits 0:1, 2:3, 4:5, 6:7 index into _vals array
|
||||
* 8:11 number of non-zero values
|
||||
* 12:15 bit mask of non-zero values
|
||||
*/
|
||||
static const uint16_t codebook_vector02_idx[] = {
|
||||
0x0000, 0x8140, 0x8180, 0x4110, 0xc250, 0xc290, 0x4120, 0xc260, 0xc2a0,
|
||||
0x2104, 0xa244, 0xa284, 0x6214, 0xe354, 0xe394, 0x6224, 0xe364, 0xe3a4,
|
||||
0x2108, 0xa248, 0xa288, 0x6218, 0xe358, 0xe398, 0x6228, 0xe368, 0xe3a8,
|
||||
0x1101, 0x9241, 0x9281, 0x5211, 0xd351, 0xd391, 0x5221, 0xd361, 0xd3a1,
|
||||
0x3205, 0xb345, 0xb385, 0x7315, 0xf455, 0xf495, 0x7325, 0xf465, 0xf4a5,
|
||||
0x3209, 0xb349, 0xb389, 0x7319, 0xf459, 0xf499, 0x7329, 0xf469, 0xf4a9,
|
||||
0x1102, 0x9242, 0x9282, 0x5212, 0xd352, 0xd392, 0x5222, 0xd362, 0xd3a2,
|
||||
0x3206, 0xb346, 0xb386, 0x7316, 0xf456, 0xf496, 0x7326, 0xf466, 0xf4a6,
|
||||
0x320a, 0xb34a, 0xb38a, 0x731a, 0xf45a, 0xf49a, 0x732a, 0xf46a, 0xf4aa,
|
||||
};
|
||||
|
||||
static const float codebook_vector4_vals[] = {
|
||||
-6.3496042, -4.3267487,
|
||||
-2.5198421, -1.0000000,
|
||||
0.0000000, 1.0000000,
|
||||
2.5198421, 4.3267487,
|
||||
6.3496042,
|
||||
};
|
||||
|
||||
/*
|
||||
* bits 0:3, 4:7 index into _vals array
|
||||
*/
|
||||
static const uint16_t codebook_vector4_idx[] = {
|
||||
0x0000, 0x0010, 0x0020, 0x0030, 0x0040, 0x0050, 0x0060, 0x0070, 0x0080,
|
||||
0x0001, 0x0011, 0x0021, 0x0031, 0x0041, 0x0051, 0x0061, 0x0071, 0x0081,
|
||||
0x0002, 0x0012, 0x0022, 0x0032, 0x0042, 0x0052, 0x0062, 0x0072, 0x0082,
|
||||
0x0003, 0x0013, 0x0023, 0x0033, 0x0043, 0x0053, 0x0063, 0x0073, 0x0083,
|
||||
0x0004, 0x0014, 0x0024, 0x0034, 0x0044, 0x0054, 0x0064, 0x0074, 0x0084,
|
||||
0x0005, 0x0015, 0x0025, 0x0035, 0x0045, 0x0055, 0x0065, 0x0075, 0x0085,
|
||||
0x0006, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0066, 0x0076, 0x0086,
|
||||
0x0007, 0x0017, 0x0027, 0x0037, 0x0047, 0x0057, 0x0067, 0x0077, 0x0087,
|
||||
0x0008, 0x0018, 0x0028, 0x0038, 0x0048, 0x0058, 0x0068, 0x0078, 0x0088,
|
||||
};
|
||||
|
||||
/*
|
||||
* bits 0:3, 4:7 index into _vals array
|
||||
* 8:11 number of non-zero values
|
||||
* 12:15 1: only second value non-zero
|
||||
* 0: other cases
|
||||
*/
|
||||
static const uint16_t codebook_vector6_idx[] = {
|
||||
0x0000, 0x0110, 0x0120, 0x0130, 0x0140, 0x0150, 0x0160, 0x0170,
|
||||
0x1101, 0x0211, 0x0221, 0x0231, 0x0241, 0x0251, 0x0261, 0x0271,
|
||||
0x1102, 0x0212, 0x0222, 0x0232, 0x0242, 0x0252, 0x0262, 0x0272,
|
||||
0x1103, 0x0213, 0x0223, 0x0233, 0x0243, 0x0253, 0x0263, 0x0273,
|
||||
0x1104, 0x0214, 0x0224, 0x0234, 0x0244, 0x0254, 0x0264, 0x0274,
|
||||
0x1105, 0x0215, 0x0225, 0x0235, 0x0245, 0x0255, 0x0265, 0x0275,
|
||||
0x1106, 0x0216, 0x0226, 0x0236, 0x0246, 0x0256, 0x0266, 0x0276,
|
||||
0x1107, 0x0217, 0x0227, 0x0237, 0x0247, 0x0257, 0x0267, 0x0277,
|
||||
};
|
||||
|
||||
/*
|
||||
* bits 0:3, 4:7 index into _vals array
|
||||
* 8:11 number of non-zero values
|
||||
* 12:15 1: only second value non-zero
|
||||
* 0: other cases
|
||||
*/
|
||||
static const uint16_t codebook_vector8_idx[] = {
|
||||
0x0000, 0x0110, 0x0120, 0x0130, 0x0140, 0x0150, 0x0160,
|
||||
0x0170, 0x0180, 0x0190, 0x01a0, 0x01b0, 0x01c0,
|
||||
0x1101, 0x0211, 0x0221, 0x0231, 0x0241, 0x0251, 0x0261,
|
||||
0x0271, 0x0281, 0x0291, 0x02a1, 0x02b1, 0x02c1,
|
||||
0x1102, 0x0212, 0x0222, 0x0232, 0x0242, 0x0252, 0x0262,
|
||||
0x0272, 0x0282, 0x0292, 0x02a2, 0x02b2, 0x02c2,
|
||||
0x1103, 0x0213, 0x0223, 0x0233, 0x0243, 0x0253, 0x0263,
|
||||
0x0273, 0x0283, 0x0293, 0x02a3, 0x02b3, 0x02c3,
|
||||
0x1104, 0x0214, 0x0224, 0x0234, 0x0244, 0x0254, 0x0264,
|
||||
0x0274, 0x0284, 0x0294, 0x02a4, 0x02b4, 0x02c4,
|
||||
0x1105, 0x0215, 0x0225, 0x0235, 0x0245, 0x0255, 0x0265,
|
||||
0x0275, 0x0285, 0x0295, 0x02a5, 0x02b5, 0x02c5,
|
||||
0x1106, 0x0216, 0x0226, 0x0236, 0x0246, 0x0256, 0x0266,
|
||||
0x0276, 0x0286, 0x0296, 0x02a6, 0x02b6, 0x02c6,
|
||||
0x1107, 0x0217, 0x0227, 0x0237, 0x0247, 0x0257, 0x0267,
|
||||
0x0277, 0x0287, 0x0297, 0x02a7, 0x02b7, 0x02c7,
|
||||
0x1108, 0x0218, 0x0228, 0x0238, 0x0248, 0x0258, 0x0268,
|
||||
0x0278, 0x0288, 0x0298, 0x02a8, 0x02b8, 0x02c8,
|
||||
0x1109, 0x0219, 0x0229, 0x0239, 0x0249, 0x0259, 0x0269,
|
||||
0x0279, 0x0289, 0x0299, 0x02a9, 0x02b9, 0x02c9,
|
||||
0x110a, 0x021a, 0x022a, 0x023a, 0x024a, 0x025a, 0x026a,
|
||||
0x027a, 0x028a, 0x029a, 0x02aa, 0x02ba, 0x02ca,
|
||||
0x110b, 0x021b, 0x022b, 0x023b, 0x024b, 0x025b, 0x026b,
|
||||
0x027b, 0x028b, 0x029b, 0x02ab, 0x02bb, 0x02cb,
|
||||
0x110c, 0x021c, 0x022c, 0x023c, 0x024c, 0x025c, 0x026c,
|
||||
0x027c, 0x028c, 0x029c, 0x02ac, 0x02bc, 0x02cc,
|
||||
};
|
||||
|
||||
static const float codebook_vector10_vals[] = {
|
||||
0.0000000, 1.0000000,
|
||||
2.5198421, 4.3267487,
|
||||
6.3496042, 8.5498797,
|
||||
10.9027236, 13.3905183,
|
||||
16.0000000, 18.7207544,
|
||||
21.5443469, 24.4637810,
|
||||
27.4731418, 30.5673509,
|
||||
33.7419917, 36.9931811,
|
||||
};
|
||||
|
||||
/*
|
||||
* bits 0:3, 4:7 index into _vals array
|
||||
* 8:9 bit mask of escape-coded entries
|
||||
* 12:15 number of non-zero values
|
||||
*/
|
||||
static const uint16_t codebook_vector10_idx[] = {
|
||||
0x0000, 0x1010, 0x1020, 0x1030, 0x1040, 0x1050, 0x1060, 0x1070,
|
||||
0x1080, 0x1090, 0x10a0, 0x10b0, 0x10c0, 0x10d0, 0x10e0, 0x10f0, 0x1200,
|
||||
0x1001, 0x2011, 0x2021, 0x2031, 0x2041, 0x2051, 0x2061, 0x2071,
|
||||
0x2081, 0x2091, 0x20a1, 0x20b1, 0x20c1, 0x20d1, 0x20e1, 0x20f1, 0x2201,
|
||||
0x1002, 0x2012, 0x2022, 0x2032, 0x2042, 0x2052, 0x2062, 0x2072,
|
||||
0x2082, 0x2092, 0x20a2, 0x20b2, 0x20c2, 0x20d2, 0x20e2, 0x20f2, 0x2202,
|
||||
0x1003, 0x2013, 0x2023, 0x2033, 0x2043, 0x2053, 0x2063, 0x2073,
|
||||
0x2083, 0x2093, 0x20a3, 0x20b3, 0x20c3, 0x20d3, 0x20e3, 0x20f3, 0x2203,
|
||||
0x1004, 0x2014, 0x2024, 0x2034, 0x2044, 0x2054, 0x2064, 0x2074,
|
||||
0x2084, 0x2094, 0x20a4, 0x20b4, 0x20c4, 0x20d4, 0x20e4, 0x20f4, 0x2204,
|
||||
0x1005, 0x2015, 0x2025, 0x2035, 0x2045, 0x2055, 0x2065, 0x2075,
|
||||
0x2085, 0x2095, 0x20a5, 0x20b5, 0x20c5, 0x20d5, 0x20e5, 0x20f5, 0x2205,
|
||||
0x1006, 0x2016, 0x2026, 0x2036, 0x2046, 0x2056, 0x2066, 0x2076,
|
||||
0x2086, 0x2096, 0x20a6, 0x20b6, 0x20c6, 0x20d6, 0x20e6, 0x20f6, 0x2206,
|
||||
0x1007, 0x2017, 0x2027, 0x2037, 0x2047, 0x2057, 0x2067, 0x2077,
|
||||
0x2087, 0x2097, 0x20a7, 0x20b7, 0x20c7, 0x20d7, 0x20e7, 0x20f7, 0x2207,
|
||||
0x1008, 0x2018, 0x2028, 0x2038, 0x2048, 0x2058, 0x2068, 0x2078,
|
||||
0x2088, 0x2098, 0x20a8, 0x20b8, 0x20c8, 0x20d8, 0x20e8, 0x20f8, 0x2208,
|
||||
0x1009, 0x2019, 0x2029, 0x2039, 0x2049, 0x2059, 0x2069, 0x2079,
|
||||
0x2089, 0x2099, 0x20a9, 0x20b9, 0x20c9, 0x20d9, 0x20e9, 0x20f9, 0x2209,
|
||||
0x100a, 0x201a, 0x202a, 0x203a, 0x204a, 0x205a, 0x206a, 0x207a,
|
||||
0x208a, 0x209a, 0x20aa, 0x20ba, 0x20ca, 0x20da, 0x20ea, 0x20fa, 0x220a,
|
||||
0x100b, 0x201b, 0x202b, 0x203b, 0x204b, 0x205b, 0x206b, 0x207b,
|
||||
0x208b, 0x209b, 0x20ab, 0x20bb, 0x20cb, 0x20db, 0x20eb, 0x20fb, 0x220b,
|
||||
0x100c, 0x201c, 0x202c, 0x203c, 0x204c, 0x205c, 0x206c, 0x207c,
|
||||
0x208c, 0x209c, 0x20ac, 0x20bc, 0x20cc, 0x20dc, 0x20ec, 0x20fc, 0x220c,
|
||||
0x100d, 0x201d, 0x202d, 0x203d, 0x204d, 0x205d, 0x206d, 0x207d,
|
||||
0x208d, 0x209d, 0x20ad, 0x20bd, 0x20cd, 0x20dd, 0x20ed, 0x20fd, 0x220d,
|
||||
0x100e, 0x201e, 0x202e, 0x203e, 0x204e, 0x205e, 0x206e, 0x207e,
|
||||
0x208e, 0x209e, 0x20ae, 0x20be, 0x20ce, 0x20de, 0x20ee, 0x20fe, 0x220e,
|
||||
0x100f, 0x201f, 0x202f, 0x203f, 0x204f, 0x205f, 0x206f, 0x207f,
|
||||
0x208f, 0x209f, 0x20af, 0x20bf, 0x20cf, 0x20df, 0x20ef, 0x20ff, 0x220f,
|
||||
0x1100, 0x2110, 0x2120, 0x2130, 0x2140, 0x2150, 0x2160, 0x2170,
|
||||
0x2180, 0x2190, 0x21a0, 0x21b0, 0x21c0, 0x21d0, 0x21e0, 0x21f0, 0x2300,
|
||||
};
|
||||
|
||||
const float *const ff_aac_codebook_vector_vals[] = {
|
||||
codebook_vector0_vals, codebook_vector0_vals,
|
||||
codebook_vector10_vals, codebook_vector10_vals,
|
||||
codebook_vector4_vals, codebook_vector4_vals,
|
||||
codebook_vector10_vals, codebook_vector10_vals,
|
||||
codebook_vector10_vals, codebook_vector10_vals,
|
||||
codebook_vector10_vals,
|
||||
};
|
||||
|
||||
const uint16_t *const ff_aac_codebook_vector_idx[] = {
|
||||
codebook_vector02_idx, codebook_vector02_idx,
|
||||
codebook_vector02_idx, codebook_vector02_idx,
|
||||
codebook_vector4_idx, codebook_vector4_idx,
|
||||
codebook_vector6_idx, codebook_vector6_idx,
|
||||
codebook_vector8_idx, codebook_vector8_idx,
|
||||
codebook_vector10_idx,
|
||||
};
|
||||
|
||||
/* @name swb_offsets
|
||||
* Sample offset into the window indicating the beginning of a scalefactor
|
||||
* window band
|
||||
@ -1003,7 +1170,7 @@ static const uint16_t swb_offset_128_8[] = {
|
||||
36, 44, 52, 60, 72, 88, 108, 128
|
||||
};
|
||||
|
||||
const uint16_t *ff_swb_offset_1024[] = {
|
||||
const uint16_t * const ff_swb_offset_1024[] = {
|
||||
swb_offset_1024_96, swb_offset_1024_96, swb_offset_1024_64,
|
||||
swb_offset_1024_48, swb_offset_1024_48, swb_offset_1024_32,
|
||||
swb_offset_1024_24, swb_offset_1024_24, swb_offset_1024_16,
|
||||
@ -1011,7 +1178,7 @@ const uint16_t *ff_swb_offset_1024[] = {
|
||||
swb_offset_1024_8
|
||||
};
|
||||
|
||||
const uint16_t *ff_swb_offset_128[] = {
|
||||
const uint16_t * const ff_swb_offset_128[] = {
|
||||
/* The last entry on the following row is swb_offset_128_64 but is a
|
||||
duplicate of swb_offset_128_96. */
|
||||
swb_offset_128_96, swb_offset_128_96, swb_offset_128_96,
|
||||
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aactab.h
|
||||
* @file
|
||||
* AAC data declarations
|
||||
* @author Oded Shimon ( ods15 ods15 dyndns org )
|
||||
* @author Maxim Gavrilov ( maxim.gavrilov gmail com )
|
||||
@ -43,8 +43,8 @@
|
||||
/* @name window coefficients
|
||||
* @{
|
||||
*/
|
||||
DECLARE_ALIGNED(16, extern float, ff_aac_kbd_long_1024[1024]);
|
||||
DECLARE_ALIGNED(16, extern float, ff_aac_kbd_short_128[128]);
|
||||
DECLARE_ALIGNED(16, extern float, ff_aac_kbd_long_1024)[1024];
|
||||
DECLARE_ALIGNED(16, extern float, ff_aac_kbd_short_128)[128];
|
||||
// @}
|
||||
|
||||
/* @name number of scalefactor window bands for long and short transform windows respectively
|
||||
@ -64,9 +64,11 @@ extern const uint8_t * const ff_aac_spectral_bits [11];
|
||||
extern const uint16_t ff_aac_spectral_sizes[11];
|
||||
|
||||
extern const float *ff_aac_codebook_vectors[];
|
||||
extern const float *ff_aac_codebook_vector_vals[];
|
||||
extern const uint16_t *ff_aac_codebook_vector_idx[];
|
||||
|
||||
extern const uint16_t *ff_swb_offset_1024[13];
|
||||
extern const uint16_t *ff_swb_offset_128 [13];
|
||||
extern const uint16_t * const ff_swb_offset_1024[13];
|
||||
extern const uint16_t * const ff_swb_offset_128 [13];
|
||||
|
||||
extern const uint8_t ff_tns_max_bands_1024[13];
|
||||
extern const uint8_t ff_tns_max_bands_128 [13];
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aandcttab.c
|
||||
* @file
|
||||
* AAN (Arai Agui Aakajima) (I)DCT tables
|
||||
*/
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aandcttab.h
|
||||
* @file
|
||||
* AAN (Arai Agui Nakajima) (I)DCT tables
|
||||
*/
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/aasc.c
|
||||
* @file
|
||||
* Autodesk RLE Video Decoder by Konstantin Shishkov
|
||||
*/
|
||||
|
||||
@ -111,7 +111,7 @@ static av_cold int aasc_decode_end(AVCodecContext *avctx)
|
||||
|
||||
AVCodec aasc_decoder = {
|
||||
"aasc",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_AASC,
|
||||
sizeof(AascContext),
|
||||
aasc_decode_init,
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/ac3.c
|
||||
* @file
|
||||
* Common code between the AC-3 encoder and decoder.
|
||||
*/
|
||||
|
||||
@ -28,8 +28,51 @@
|
||||
#include "ac3.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
|
||||
/**
|
||||
* Starting frequency coefficient bin for each critical band.
|
||||
*/
|
||||
static const uint8_t band_start_tab[51] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
|
||||
34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
|
||||
79, 85, 97, 109, 121, 133, 157, 181, 205, 229, 253
|
||||
};
|
||||
|
||||
/**
|
||||
* Maps each frequency coefficient bin to the critical band that contains it.
|
||||
*/
|
||||
static const uint8_t bin_to_band_tab[253] = {
|
||||
0,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
|
||||
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 26, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30,
|
||||
31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34,
|
||||
35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36,
|
||||
37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38,
|
||||
39, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
||||
43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
|
||||
44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
|
||||
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
|
||||
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
|
||||
46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
|
||||
48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49
|
||||
};
|
||||
|
||||
#else /* CONFIG_HARDCODED_TABLES */
|
||||
static uint8_t band_start_tab[51];
|
||||
static uint8_t bin_to_band_tab[253];
|
||||
#endif
|
||||
|
||||
static inline int calc_lowcomp1(int a, int b0, int b1, int c)
|
||||
{
|
||||
@ -55,29 +98,27 @@ static inline int calc_lowcomp(int a, int b0, int b1, int bin)
|
||||
void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
|
||||
int16_t *band_psd)
|
||||
{
|
||||
int bin, i, j, k, end1, v;
|
||||
int bin, band;
|
||||
|
||||
/* exponent mapping to PSD */
|
||||
for(bin=start;bin<end;bin++) {
|
||||
for (bin = start; bin < end; bin++) {
|
||||
psd[bin]=(3072 - (exp[bin] << 7));
|
||||
}
|
||||
|
||||
/* PSD integration */
|
||||
j=start;
|
||||
k=bin_to_band_tab[start];
|
||||
bin = start;
|
||||
band = bin_to_band_tab[start];
|
||||
do {
|
||||
v=psd[j];
|
||||
j++;
|
||||
end1 = FFMIN(band_start_tab[k+1], end);
|
||||
for(i=j;i<end1;i++) {
|
||||
int v = psd[bin++];
|
||||
int band_end = FFMIN(band_start_tab[band+1], end);
|
||||
for (; bin < band_end; bin++) {
|
||||
int max = FFMAX(v, psd[bin]);
|
||||
/* logadd */
|
||||
int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255);
|
||||
v = FFMAX(v, psd[j]) + ff_ac3_log_add_tab[adr];
|
||||
j++;
|
||||
int adr = FFMIN(max - ((v + psd[bin] + 1) >> 1), 255);
|
||||
v = max + ff_ac3_log_add_tab[adr];
|
||||
}
|
||||
band_psd[k]=v;
|
||||
k++;
|
||||
} while (end > band_start_tab[k]);
|
||||
band_psd[band++] = v;
|
||||
} while (end > band_start_tab[band]);
|
||||
}
|
||||
|
||||
int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
||||
@ -87,75 +128,71 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
||||
int16_t *mask)
|
||||
{
|
||||
int16_t excite[50]; /* excitation */
|
||||
int bin, k;
|
||||
int bndstrt, bndend, begin, end1, tmp;
|
||||
int band;
|
||||
int band_start, band_end, begin, end1;
|
||||
int lowcomp, fastleak, slowleak;
|
||||
|
||||
/* excitation function */
|
||||
bndstrt = bin_to_band_tab[start];
|
||||
bndend = bin_to_band_tab[end-1] + 1;
|
||||
band_start = bin_to_band_tab[start];
|
||||
band_end = bin_to_band_tab[end-1] + 1;
|
||||
|
||||
if (bndstrt == 0) {
|
||||
if (band_start == 0) {
|
||||
lowcomp = 0;
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[0], band_psd[1], 384);
|
||||
excite[0] = band_psd[0] - fast_gain - lowcomp;
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[1], band_psd[2], 384);
|
||||
excite[1] = band_psd[1] - fast_gain - lowcomp;
|
||||
begin = 7;
|
||||
for (bin = 2; bin < 7; bin++) {
|
||||
if (!(is_lfe && bin == 6))
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[bin], band_psd[bin+1], 384);
|
||||
fastleak = band_psd[bin] - fast_gain;
|
||||
slowleak = band_psd[bin] - s->slow_gain;
|
||||
excite[bin] = fastleak - lowcomp;
|
||||
if (!(is_lfe && bin == 6)) {
|
||||
if (band_psd[bin] <= band_psd[bin+1]) {
|
||||
begin = bin + 1;
|
||||
for (band = 2; band < 7; band++) {
|
||||
if (!(is_lfe && band == 6))
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[band], band_psd[band+1], 384);
|
||||
fastleak = band_psd[band] - fast_gain;
|
||||
slowleak = band_psd[band] - s->slow_gain;
|
||||
excite[band] = fastleak - lowcomp;
|
||||
if (!(is_lfe && band == 6)) {
|
||||
if (band_psd[band] <= band_psd[band+1]) {
|
||||
begin = band + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end1=bndend;
|
||||
if (end1 > 22) end1=22;
|
||||
|
||||
for (bin = begin; bin < end1; bin++) {
|
||||
if (!(is_lfe && bin == 6))
|
||||
lowcomp = calc_lowcomp(lowcomp, band_psd[bin], band_psd[bin+1], bin);
|
||||
|
||||
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[bin] - fast_gain);
|
||||
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[bin] - s->slow_gain);
|
||||
excite[bin] = FFMAX(fastleak - lowcomp, slowleak);
|
||||
end1 = FFMIN(band_end, 22);
|
||||
for (band = begin; band < end1; band++) {
|
||||
if (!(is_lfe && band == 6))
|
||||
lowcomp = calc_lowcomp(lowcomp, band_psd[band], band_psd[band+1], band);
|
||||
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
|
||||
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
|
||||
excite[band] = FFMAX(fastleak - lowcomp, slowleak);
|
||||
}
|
||||
begin = 22;
|
||||
} else {
|
||||
/* coupling channel */
|
||||
begin = bndstrt;
|
||||
|
||||
begin = band_start;
|
||||
fastleak = (s->cpl_fast_leak << 8) + 768;
|
||||
slowleak = (s->cpl_slow_leak << 8) + 768;
|
||||
}
|
||||
|
||||
for (bin = begin; bin < bndend; bin++) {
|
||||
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[bin] - fast_gain);
|
||||
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[bin] - s->slow_gain);
|
||||
excite[bin] = FFMAX(fastleak, slowleak);
|
||||
for (band = begin; band < band_end; band++) {
|
||||
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
|
||||
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
|
||||
excite[band] = FFMAX(fastleak, slowleak);
|
||||
}
|
||||
|
||||
/* compute masking curve */
|
||||
|
||||
for (bin = bndstrt; bin < bndend; bin++) {
|
||||
tmp = s->db_per_bit - band_psd[bin];
|
||||
for (band = band_start; band < band_end; band++) {
|
||||
int tmp = s->db_per_bit - band_psd[band];
|
||||
if (tmp > 0) {
|
||||
excite[bin] += tmp >> 2;
|
||||
excite[band] += tmp >> 2;
|
||||
}
|
||||
mask[bin] = FFMAX(ff_ac3_hearing_threshold_tab[bin >> s->sr_shift][s->sr_code], excite[bin]);
|
||||
mask[band] = FFMAX(ff_ac3_hearing_threshold_tab[band >> s->sr_shift][s->sr_code], excite[band]);
|
||||
}
|
||||
|
||||
/* delta bit allocation */
|
||||
|
||||
if (dba_mode == DBA_REUSE || dba_mode == DBA_NEW) {
|
||||
int band, seg, delta;
|
||||
int i, seg, delta;
|
||||
if (dba_nsegs >= 8)
|
||||
return -1;
|
||||
band = 0;
|
||||
@ -168,9 +205,8 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
||||
} else {
|
||||
delta = (dba_values[seg] - 4) << 7;
|
||||
}
|
||||
for (k = 0; k < dba_lengths[seg]; k++) {
|
||||
mask[band] += delta;
|
||||
band++;
|
||||
for (i = 0; i < dba_lengths[seg]; i++) {
|
||||
mask[band++] += delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,25 +217,24 @@ void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
|
||||
int snr_offset, int floor,
|
||||
const uint8_t *bap_tab, uint8_t *bap)
|
||||
{
|
||||
int i, j, k, end1, v, address;
|
||||
int bin, band;
|
||||
|
||||
/* special case, if snr offset is -960, set all bap's to zero */
|
||||
if(snr_offset == -960) {
|
||||
if (snr_offset == -960) {
|
||||
memset(bap, 0, 256);
|
||||
return;
|
||||
}
|
||||
|
||||
i = start;
|
||||
j = bin_to_band_tab[start];
|
||||
bin = start;
|
||||
band = bin_to_band_tab[start];
|
||||
do {
|
||||
v = (FFMAX(mask[j] - snr_offset - floor, 0) & 0x1FE0) + floor;
|
||||
end1 = FFMIN(band_start_tab[j] + ff_ac3_critical_band_size_tab[j], end);
|
||||
for (k = i; k < end1; k++) {
|
||||
address = av_clip((psd[i] - v) >> 5, 0, 63);
|
||||
bap[i] = bap_tab[address];
|
||||
i++;
|
||||
int m = (FFMAX(mask[band] - snr_offset - floor, 0) & 0x1FE0) + floor;
|
||||
int band_end = FFMIN(band_start_tab[band+1], end);
|
||||
for (; bin < band_end; bin++) {
|
||||
int address = av_clip((psd[bin] - m) >> 5, 0, 63);
|
||||
bap[bin] = bap_tab[address];
|
||||
}
|
||||
} while (end > band_start_tab[j++]);
|
||||
} while (end > band_start_tab[band++]);
|
||||
}
|
||||
|
||||
/* AC-3 bit allocation. The algorithm is the one described in the AC-3
|
||||
@ -218,8 +253,8 @@ void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
|
||||
ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, band_psd);
|
||||
|
||||
ff_ac3_bit_alloc_calc_mask(s, band_psd, start, end, fast_gain, is_lfe,
|
||||
dba_mode, dba_nsegs, dba_offsets, dba_lengths, dba_values,
|
||||
mask);
|
||||
dba_mode, dba_nsegs, dba_offsets, dba_lengths,
|
||||
dba_values, mask);
|
||||
|
||||
ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snr_offset, s->floor,
|
||||
ff_ac3_bap_tab, bap);
|
||||
@ -232,15 +267,15 @@ void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
|
||||
*/
|
||||
av_cold void ac3_common_init(void)
|
||||
{
|
||||
int i, j, k, l, v;
|
||||
#if !CONFIG_HARDCODED_TABLES
|
||||
/* compute bndtab and masktab from bandsz */
|
||||
k = 0;
|
||||
l = 0;
|
||||
for(i=0;i<50;i++) {
|
||||
band_start_tab[i] = l;
|
||||
v = ff_ac3_critical_band_size_tab[i];
|
||||
for(j=0;j<v;j++) bin_to_band_tab[k++]=i;
|
||||
l += v;
|
||||
int bin = 0, band;
|
||||
for (band = 0; band < 50; band++) {
|
||||
int band_end = bin + ff_ac3_critical_band_size_tab[band];
|
||||
band_start_tab[band] = bin;
|
||||
while (bin < band_end)
|
||||
bin_to_band_tab[bin++] = band;
|
||||
}
|
||||
band_start_tab[50] = l;
|
||||
band_start_tab[50] = bin;
|
||||
#endif /* !CONFIG_HARDCODED_TABLES */
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/ac3.h
|
||||
* @file
|
||||
* Common code between the AC-3 encoder and decoder.
|
||||
*/
|
||||
|
||||
|
@ -216,7 +216,7 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
|
||||
if (avctx->error_recognition >= FF_ER_CAREFUL) {
|
||||
s->input_buffer = av_mallocz(AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!s->input_buffer)
|
||||
return AVERROR_NOMEM;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
avctx->sample_fmt = SAMPLE_FMT_S16;
|
||||
@ -412,20 +412,25 @@ static int decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps,
|
||||
*/
|
||||
static void calc_transform_coeffs_cpl(AC3DecodeContext *s)
|
||||
{
|
||||
int i, j, ch, bnd;
|
||||
int bin, band, ch;
|
||||
|
||||
i = s->start_freq[CPL_CH];
|
||||
for(bnd=0; bnd<s->num_cpl_bands; bnd++) {
|
||||
for (j = 0; j < s->cpl_band_sizes[bnd]; j++,i++) {
|
||||
for(ch=1; ch<=s->fbw_channels; ch++) {
|
||||
if(s->channel_in_cpl[ch]) {
|
||||
s->fixed_coeffs[ch][i] = ((int64_t)s->fixed_coeffs[CPL_CH][i] *
|
||||
(int64_t)s->cpl_coords[ch][bnd]) >> 23;
|
||||
if (ch == 2 && s->phase_flags[bnd])
|
||||
s->fixed_coeffs[ch][i] = -s->fixed_coeffs[ch][i];
|
||||
bin = s->start_freq[CPL_CH];
|
||||
for (band = 0; band < s->num_cpl_bands; band++) {
|
||||
int band_start = bin;
|
||||
int band_end = bin + s->cpl_band_sizes[band];
|
||||
for (ch = 1; ch <= s->fbw_channels; ch++) {
|
||||
if (s->channel_in_cpl[ch]) {
|
||||
int cpl_coord = s->cpl_coords[ch][band] << 5;
|
||||
for (bin = band_start; bin < band_end; bin++) {
|
||||
s->fixed_coeffs[ch][bin] = MULH(s->fixed_coeffs[CPL_CH][bin] << 4, cpl_coord);
|
||||
}
|
||||
if (ch == 2 && s->phase_flags[band]) {
|
||||
for (bin = band_start; bin < band_end; bin++)
|
||||
s->fixed_coeffs[2][bin] = -s->fixed_coeffs[2][bin];
|
||||
}
|
||||
}
|
||||
}
|
||||
bin = band_end;
|
||||
}
|
||||
}
|
||||
|
||||
@ -598,7 +603,6 @@ static void do_rematrixing(AC3DecodeContext *s)
|
||||
{
|
||||
int bnd, i;
|
||||
int end, bndend;
|
||||
int tmp0, tmp1;
|
||||
|
||||
end = FFMIN(s->end_freq[1], s->end_freq[2]);
|
||||
|
||||
@ -606,10 +610,9 @@ static void do_rematrixing(AC3DecodeContext *s)
|
||||
if(s->rematrixing_flags[bnd]) {
|
||||
bndend = FFMIN(end, ff_ac3_rematrix_band_tab[bnd+1]);
|
||||
for(i=ff_ac3_rematrix_band_tab[bnd]; i<bndend; i++) {
|
||||
tmp0 = s->fixed_coeffs[1][i];
|
||||
tmp1 = s->fixed_coeffs[2][i];
|
||||
s->fixed_coeffs[1][i] = tmp0 + tmp1;
|
||||
s->fixed_coeffs[2][i] = tmp0 - tmp1;
|
||||
int tmp0 = s->fixed_coeffs[1][i];
|
||||
s->fixed_coeffs[1][i] += s->fixed_coeffs[2][i];
|
||||
s->fixed_coeffs[2][i] = tmp0 - s->fixed_coeffs[2][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -812,14 +815,105 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
|
||||
/* spectral extension strategy */
|
||||
if (s->eac3 && (!blk || get_bits1(gbc))) {
|
||||
if (get_bits1(gbc)) {
|
||||
av_log_missing_feature(s->avctx, "Spectral extension", 1);
|
||||
return -1;
|
||||
s->spx_in_use = get_bits1(gbc);
|
||||
if (s->spx_in_use) {
|
||||
int dst_start_freq, dst_end_freq, src_start_freq,
|
||||
start_subband, end_subband;
|
||||
|
||||
/* determine which channels use spx */
|
||||
if (s->channel_mode == AC3_CHMODE_MONO) {
|
||||
s->channel_uses_spx[1] = 1;
|
||||
} else {
|
||||
for (ch = 1; ch <= fbw_channels; ch++)
|
||||
s->channel_uses_spx[ch] = get_bits1(gbc);
|
||||
}
|
||||
|
||||
/* get the frequency bins of the spx copy region and the spx start
|
||||
and end subbands */
|
||||
dst_start_freq = get_bits(gbc, 2);
|
||||
start_subband = get_bits(gbc, 3) + 2;
|
||||
if (start_subband > 7)
|
||||
start_subband += start_subband - 7;
|
||||
end_subband = get_bits(gbc, 3) + 5;
|
||||
if (end_subband > 7)
|
||||
end_subband += end_subband - 7;
|
||||
dst_start_freq = dst_start_freq * 12 + 25;
|
||||
src_start_freq = start_subband * 12 + 25;
|
||||
dst_end_freq = end_subband * 12 + 25;
|
||||
|
||||
/* check validity of spx ranges */
|
||||
if (start_subband >= end_subband) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
|
||||
"range (%d >= %d)\n", start_subband, end_subband);
|
||||
return -1;
|
||||
}
|
||||
if (dst_start_freq >= src_start_freq) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
|
||||
"copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
s->spx_dst_start_freq = dst_start_freq;
|
||||
s->spx_src_start_freq = src_start_freq;
|
||||
s->spx_dst_end_freq = dst_end_freq;
|
||||
|
||||
decode_band_structure(gbc, blk, s->eac3, 0,
|
||||
start_subband, end_subband,
|
||||
ff_eac3_default_spx_band_struct,
|
||||
&s->num_spx_bands,
|
||||
s->spx_band_sizes);
|
||||
} else {
|
||||
for (ch = 1; ch <= fbw_channels; ch++) {
|
||||
s->channel_uses_spx[ch] = 0;
|
||||
s->first_spx_coords[ch] = 1;
|
||||
}
|
||||
}
|
||||
/* TODO: parse spectral extension strategy info */
|
||||
}
|
||||
|
||||
/* TODO: spectral extension coordinates */
|
||||
/* spectral extension coordinates */
|
||||
if (s->spx_in_use) {
|
||||
for (ch = 1; ch <= fbw_channels; ch++) {
|
||||
if (s->channel_uses_spx[ch]) {
|
||||
if (s->first_spx_coords[ch] || get_bits1(gbc)) {
|
||||
float spx_blend;
|
||||
int bin, master_spx_coord;
|
||||
|
||||
s->first_spx_coords[ch] = 0;
|
||||
spx_blend = get_bits(gbc, 5) * (1.0f/32);
|
||||
master_spx_coord = get_bits(gbc, 2) * 3;
|
||||
|
||||
bin = s->spx_src_start_freq;
|
||||
for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
|
||||
int bandsize;
|
||||
int spx_coord_exp, spx_coord_mant;
|
||||
float nratio, sblend, nblend, spx_coord;
|
||||
|
||||
/* calculate blending factors */
|
||||
bandsize = s->spx_band_sizes[bnd];
|
||||
nratio = ((float)((bin + (bandsize >> 1))) / s->spx_dst_end_freq) - spx_blend;
|
||||
nratio = av_clipf(nratio, 0.0f, 1.0f);
|
||||
nblend = sqrtf(3.0f * nratio); // noise is scaled by sqrt(3) to give unity variance
|
||||
sblend = sqrtf(1.0f - nratio);
|
||||
bin += bandsize;
|
||||
|
||||
/* decode spx coordinates */
|
||||
spx_coord_exp = get_bits(gbc, 4);
|
||||
spx_coord_mant = get_bits(gbc, 2);
|
||||
if (spx_coord_exp == 15) spx_coord_mant <<= 1;
|
||||
else spx_coord_mant += 4;
|
||||
spx_coord_mant <<= (25 - spx_coord_exp - master_spx_coord);
|
||||
spx_coord = spx_coord_mant * (1.0f/(1<<23));
|
||||
|
||||
/* multiply noise and signal blending factors by spx coordinate */
|
||||
s->spx_noise_blend [ch][bnd] = nblend * spx_coord;
|
||||
s->spx_signal_blend[ch][bnd] = sblend * spx_coord;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s->first_spx_coords[ch] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* coupling strategy */
|
||||
if (s->eac3 ? s->cpl_strategy_exists[blk] : get_bits1(gbc)) {
|
||||
@ -856,9 +950,9 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
s->phase_flags_in_use = get_bits1(gbc);
|
||||
|
||||
/* coupling frequency range */
|
||||
/* TODO: modify coupling end freq if spectral extension is used */
|
||||
cpl_start_subband = get_bits(gbc, 4);
|
||||
cpl_end_subband = get_bits(gbc, 4) + 3;
|
||||
cpl_end_subband = s->spx_in_use ? (s->spx_src_start_freq - 37) / 12 :
|
||||
get_bits(gbc, 4) + 3;
|
||||
if (cpl_start_subband >= cpl_end_subband) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "invalid coupling range (%d >= %d)\n",
|
||||
cpl_start_subband, cpl_end_subband);
|
||||
@ -931,13 +1025,16 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
if (channel_mode == AC3_CHMODE_STEREO) {
|
||||
if ((s->eac3 && !blk) || get_bits1(gbc)) {
|
||||
s->num_rematrixing_bands = 4;
|
||||
if(cpl_in_use && s->start_freq[CPL_CH] <= 61)
|
||||
if (cpl_in_use && s->start_freq[CPL_CH] <= 61) {
|
||||
s->num_rematrixing_bands -= 1 + (s->start_freq[CPL_CH] == 37);
|
||||
} else if (s->spx_in_use && s->spx_src_start_freq <= 61) {
|
||||
s->num_rematrixing_bands--;
|
||||
}
|
||||
for(bnd=0; bnd<s->num_rematrixing_bands; bnd++)
|
||||
s->rematrixing_flags[bnd] = get_bits1(gbc);
|
||||
} else if (!blk) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "new rematrixing strategy must be present in block 0\n");
|
||||
return -1;
|
||||
av_log(s->avctx, AV_LOG_WARNING, "Warning: new rematrixing strategy not present in block 0\n");
|
||||
s->num_rematrixing_bands = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -957,6 +1054,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
int prev = s->end_freq[ch];
|
||||
if (s->channel_in_cpl[ch])
|
||||
s->end_freq[ch] = s->start_freq[CPL_CH];
|
||||
else if (s->channel_uses_spx[ch])
|
||||
s->end_freq[ch] = s->spx_src_start_freq;
|
||||
else {
|
||||
int bandwidth_code = get_bits(gbc, 6);
|
||||
if (bandwidth_code > 60) {
|
||||
@ -1153,8 +1252,6 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
|
||||
/* TODO: generate enhanced coupling coordinates and uncouple */
|
||||
|
||||
/* TODO: apply spectral extension */
|
||||
|
||||
/* recover coefficients if rematrixing is in use */
|
||||
if(s->channel_mode == AC3_CHMODE_STEREO)
|
||||
do_rematrixing(s);
|
||||
@ -1163,13 +1260,18 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
for(ch=1; ch<=s->channels; ch++) {
|
||||
float gain = s->mul_bias / 4194304.0f;
|
||||
if(s->channel_mode == AC3_CHMODE_DUALMONO) {
|
||||
gain *= s->dynamic_range[ch-1];
|
||||
gain *= s->dynamic_range[2-ch];
|
||||
} else {
|
||||
gain *= s->dynamic_range[0];
|
||||
}
|
||||
s->dsp.int32_to_float_fmul_scalar(s->transform_coeffs[ch], s->fixed_coeffs[ch], gain, 256);
|
||||
}
|
||||
|
||||
/* apply spectral extension to high frequency bins */
|
||||
if (s->spx_in_use && CONFIG_EAC3_DECODER) {
|
||||
ff_eac3_apply_spectral_extension(s);
|
||||
}
|
||||
|
||||
/* downmix and MDCT. order depends on whether block switching is used for
|
||||
any channel in this block. this is because coefficients for the long
|
||||
and short transforms cannot be mixed. */
|
||||
@ -1233,21 +1335,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
|
||||
*data_size = 0;
|
||||
err = parse_frame_header(s);
|
||||
|
||||
/* check that reported frame size fits in input buffer */
|
||||
if(s->frame_size > buf_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
|
||||
err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;
|
||||
}
|
||||
|
||||
/* check for crc mismatch */
|
||||
if(err != AAC_AC3_PARSE_ERROR_FRAME_SIZE && avctx->error_recognition >= FF_ER_CAREFUL) {
|
||||
if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
|
||||
err = AAC_AC3_PARSE_ERROR_CRC;
|
||||
}
|
||||
}
|
||||
|
||||
if(err && err != AAC_AC3_PARSE_ERROR_CRC) {
|
||||
if (err) {
|
||||
switch(err) {
|
||||
case AAC_AC3_PARSE_ERROR_SYNC:
|
||||
av_log(avctx, AV_LOG_ERROR, "frame sync error\n");
|
||||
@ -1275,6 +1363,18 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid header\n");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* check that reported frame size fits in input buffer */
|
||||
if (s->frame_size > buf_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
|
||||
err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;
|
||||
} else if (avctx->error_recognition >= FF_ER_CAREFUL) {
|
||||
/* check for crc mismatch */
|
||||
if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
|
||||
err = AAC_AC3_PARSE_ERROR_CRC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if frame is ok, set audio parameters */
|
||||
@ -1320,7 +1420,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
|
||||
out_samples += 256 * s->out_channels;
|
||||
}
|
||||
*data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
|
||||
return s->frame_size;
|
||||
return FFMIN(buf_size, s->frame_size);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1339,7 +1439,7 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
|
||||
|
||||
AVCodec ac3_decoder = {
|
||||
.name = "ac3",
|
||||
.type = CODEC_TYPE_AUDIO,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = CODEC_ID_AC3,
|
||||
.priv_data_size = sizeof (AC3DecodeContext),
|
||||
.init = ac3_decode_init,
|
||||
@ -1351,7 +1451,7 @@ AVCodec ac3_decoder = {
|
||||
#if CONFIG_EAC3_DECODER
|
||||
AVCodec eac3_decoder = {
|
||||
.name = "eac3",
|
||||
.type = CODEC_TYPE_AUDIO,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = CODEC_ID_EAC3,
|
||||
.priv_data_size = sizeof (AC3DecodeContext),
|
||||
.init = ac3_decode_init,
|
||||
|
@ -20,8 +20,31 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/ac3.h
|
||||
* @file
|
||||
* Common code between the AC-3 and E-AC-3 decoders.
|
||||
*
|
||||
* Summary of MDCT Coefficient Grouping:
|
||||
* The individual MDCT coefficient indices are often referred to in the
|
||||
* (E-)AC-3 specification as frequency bins. These bins are grouped together
|
||||
* into subbands of 12 coefficients each. The subbands are grouped together
|
||||
* into bands as defined in the bitstream by the band structures, which
|
||||
* determine the number of bands and the size of each band. The full spectrum
|
||||
* of 256 frequency bins is divided into 1 DC bin + 21 subbands = 253 bins.
|
||||
* This system of grouping coefficients is used for channel bandwidth, stereo
|
||||
* rematrixing, channel coupling, enhanced coupling, and spectral extension.
|
||||
*
|
||||
* +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
|
||||
* |1| |12| | [12|12|12|12] | | | | | | | | | | | | |3|
|
||||
* +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
|
||||
* ~~~ ~~~~ ~~~~~~~~~~~~~ ~~~
|
||||
* | | | |
|
||||
* | | | 3 unused frequency bins--+
|
||||
* | | |
|
||||
* | | +--1 band containing 4 subbands
|
||||
* | |
|
||||
* | +--1 subband of 12 frequency bins
|
||||
* |
|
||||
* +--DC frequency bin
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AC3DEC_H
|
||||
@ -31,6 +54,7 @@
|
||||
#include "ac3.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
|
||||
/* override ac3.h to include coupling channel */
|
||||
#undef AC3_MAX_CHANNELS
|
||||
@ -42,6 +66,7 @@
|
||||
#define AC3_MAX_COEFS 256
|
||||
#define AC3_BLOCK_SIZE 256
|
||||
#define MAX_BLOCKS 6
|
||||
#define SPX_MAX_BANDS 17
|
||||
|
||||
typedef struct {
|
||||
AVCodecContext *avctx; ///< parent context
|
||||
@ -88,6 +113,22 @@ typedef struct {
|
||||
int cpl_coords[AC3_MAX_CHANNELS][18]; ///< coupling coordinates (cplco)
|
||||
///@}
|
||||
|
||||
///@defgroup spx spectral extension
|
||||
///@{
|
||||
int spx_in_use; ///< spectral extension in use (spxinu)
|
||||
uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; ///< channel uses spectral extension (chinspx)
|
||||
int8_t spx_atten_code[AC3_MAX_CHANNELS]; ///< spx attenuation code (spxattencod)
|
||||
int spx_src_start_freq; ///< spx start frequency bin
|
||||
int spx_dst_end_freq; ///< spx end frequency bin
|
||||
int spx_dst_start_freq; ///< spx starting frequency bin for copying (copystartmant)
|
||||
///< the copy region ends at the start of the spx region.
|
||||
int num_spx_bands; ///< number of spx bands (nspxbnds)
|
||||
uint8_t spx_band_sizes[SPX_MAX_BANDS]; ///< number of bins in each spx band
|
||||
uint8_t first_spx_coords[AC3_MAX_CHANNELS]; ///< first spx coordinates states (firstspxcos)
|
||||
float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; ///< spx noise blending factor (nblendfact)
|
||||
float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact)
|
||||
///@}
|
||||
|
||||
///@defgroup aht adaptive hybrid transform
|
||||
int channel_uses_aht[AC3_MAX_CHANNELS]; ///< channel AHT in use (chahtinu)
|
||||
int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][MAX_BLOCKS]; ///< pre-IDCT mantissas
|
||||
@ -146,8 +187,8 @@ typedef struct {
|
||||
|
||||
///@defgroup imdct IMDCT
|
||||
int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags (blksw)
|
||||
MDCTContext imdct_512; ///< for 512 sample IMDCT
|
||||
MDCTContext imdct_256; ///< for 256 sample IMDCT
|
||||
FFTContext imdct_512; ///< for 512 sample IMDCT
|
||||
FFTContext imdct_256; ///< for 256 sample IMDCT
|
||||
///@}
|
||||
|
||||
///@defgroup opt optimization
|
||||
@ -157,12 +198,12 @@ typedef struct {
|
||||
///@}
|
||||
|
||||
///@defgroup arrays aligned arrays
|
||||
DECLARE_ALIGNED_16(int, fixed_coeffs[AC3_MAX_CHANNELS][AC3_MAX_COEFS]); ///> fixed-point transform coefficients
|
||||
DECLARE_ALIGNED_16(float, transform_coeffs[AC3_MAX_CHANNELS][AC3_MAX_COEFS]); ///< transform coefficients
|
||||
DECLARE_ALIGNED_16(float, delay[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]); ///< delay - added to the next block
|
||||
DECLARE_ALIGNED_16(float, window[AC3_BLOCK_SIZE]); ///< window coefficients
|
||||
DECLARE_ALIGNED_16(float, tmp_output[AC3_BLOCK_SIZE]); ///< temporary storage for output before windowing
|
||||
DECLARE_ALIGNED_16(float, output[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]); ///< output after imdct transform and windowing
|
||||
DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///> fixed-point transform coefficients
|
||||
DECLARE_ALIGNED(16, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients
|
||||
DECLARE_ALIGNED(16, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< delay - added to the next block
|
||||
DECLARE_ALIGNED(16, float, window)[AC3_BLOCK_SIZE]; ///< window coefficients
|
||||
DECLARE_ALIGNED(16, float, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing
|
||||
DECLARE_ALIGNED(16, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing
|
||||
///@}
|
||||
} AC3DecodeContext;
|
||||
|
||||
@ -178,4 +219,14 @@ int ff_eac3_parse_header(AC3DecodeContext *s);
|
||||
*/
|
||||
void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
|
||||
|
||||
void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2],
|
||||
int out_ch, int in_ch, int len);
|
||||
|
||||
/**
|
||||
* Apply spectral extension to each channel by copying lower frequency
|
||||
* coefficients to higher frequency bins and applying side information to
|
||||
* approximate the original high frequency signal.
|
||||
*/
|
||||
void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
|
||||
|
||||
#endif /* AVCODEC_AC3DEC_H */
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/ac3dec_data.c
|
||||
* @file
|
||||
* Tables taken directly from the AC-3 spec.
|
||||
*/
|
||||
|
||||
@ -64,3 +64,9 @@ const uint8_t ff_eac3_hebap_tab[64] = {
|
||||
*/
|
||||
const uint8_t ff_eac3_default_cpl_band_struct[18] =
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1 };
|
||||
|
||||
/**
|
||||
* Table E2.15 Default Spectral Extension Banding Structure
|
||||
*/
|
||||
const uint8_t ff_eac3_default_spx_band_struct[17] =
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
|
||||
|
@ -29,5 +29,6 @@ extern const uint8_t ff_ac3_rematrix_band_tab[5];
|
||||
|
||||
extern const uint8_t ff_eac3_hebap_tab[64];
|
||||
extern const uint8_t ff_eac3_default_cpl_band_struct[18];
|
||||
extern const uint8_t ff_eac3_default_spx_band_struct[17];
|
||||
|
||||
#endif /* AVCODEC_AC3DEC_DATA_H */
|
||||
|
@ -20,14 +20,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/ac3enc.c
|
||||
* @file
|
||||
* The simplest AC-3 encoder.
|
||||
*/
|
||||
//#define DEBUG
|
||||
//#define DEBUG_BITALLOC
|
||||
#include "libavutil/crc.h"
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h" // for ff_reverse
|
||||
#include "libavutil/common.h" /* for av_reverse */
|
||||
#include "put_bits.h"
|
||||
#include "ac3.h"
|
||||
#include "audioconvert.h"
|
||||
@ -138,7 +138,7 @@ static void fft(IComplex *z, int ln)
|
||||
|
||||
/* reverse */
|
||||
for(j=0;j<np;j++) {
|
||||
int k = ff_reverse[j] >> (8 - ln);
|
||||
int k = av_reverse[j] >> (8 - ln);
|
||||
if (k < j)
|
||||
FFSWAP(IComplex, z[k], z[j]);
|
||||
}
|
||||
@ -1393,16 +1393,16 @@ void test_ac3(void)
|
||||
|
||||
AVCodec ac3_encoder = {
|
||||
"ac3",
|
||||
CODEC_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
CODEC_ID_AC3,
|
||||
sizeof(AC3EncodeContext),
|
||||
AC3_encode_init,
|
||||
AC3_encode_frame,
|
||||
AC3_encode_close,
|
||||
NULL,
|
||||
.sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
|
||||
.sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
|
||||
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
|
||||
.channel_layouts = (int64_t[]){
|
||||
.channel_layouts = (const int64_t[]){
|
||||
CH_LAYOUT_MONO,
|
||||
CH_LAYOUT_STEREO,
|
||||
CH_LAYOUT_2_1,
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/ac3tab.c
|
||||
* @file
|
||||
* tables taken directly from the AC-3 spec.
|
||||
*/
|
||||
|
||||
@ -108,7 +108,7 @@ const uint16_t ff_ac3_channel_layout_tab[8] = {
|
||||
*/
|
||||
const uint8_t ff_ac3_enc_channel_map[8][2][6] = {
|
||||
COMMON_CHANNEL_MAP
|
||||
{ { 0, 1, 2, 3, 4, }, { 0, 1, 3, 4, 2, } },
|
||||
{ { 0, 1, 2, 3, }, { 0, 1, 3, 4, 2, } },
|
||||
{ { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } },
|
||||
};
|
||||
|
||||
@ -118,7 +118,7 @@ const uint8_t ff_ac3_enc_channel_map[8][2][6] = {
|
||||
*/
|
||||
const uint8_t ff_ac3_dec_channel_map[8][2][6] = {
|
||||
COMMON_CHANNEL_MAP
|
||||
{ { 0, 1, 2, 3, 4, }, { 0, 1, 4, 2, 3, } },
|
||||
{ { 0, 1, 2, 3, }, { 0, 1, 4, 2, 3, } },
|
||||
{ { 0, 2, 1, 3, 4, }, { 0, 2, 1, 5, 3, 4 } },
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,7 @@ void ff_acelp_interpolate(int16_t* out, const int16_t* in,
|
||||
{
|
||||
int n, i;
|
||||
|
||||
assert(pitch_delay_frac >= 0 && pitch_delay_frac < precision);
|
||||
assert(frac_pos >= 0 && frac_pos < precision);
|
||||
|
||||
for (n = 0; n < length; n++) {
|
||||
int idx = 0;
|
||||
@ -73,6 +73,26 @@ void ff_acelp_interpolate(int16_t* out, const int16_t* in,
|
||||
}
|
||||
}
|
||||
|
||||
void ff_acelp_interpolatef(float *out, const float *in,
|
||||
const float *filter_coeffs, int precision,
|
||||
int frac_pos, int filter_length, int length)
|
||||
{
|
||||
int n, i;
|
||||
|
||||
for (n = 0; n < length; n++) {
|
||||
int idx = 0;
|
||||
float v = 0;
|
||||
|
||||
for (i = 0; i < filter_length;) {
|
||||
v += in[n + i] * filter_coeffs[idx + frac_pos];
|
||||
idx += precision;
|
||||
i++;
|
||||
v += in[n - i] * filter_coeffs[idx - frac_pos];
|
||||
}
|
||||
out[n] = v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
|
||||
const int16_t* in, int length)
|
||||
@ -94,7 +114,7 @@ void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
|
||||
}
|
||||
}
|
||||
|
||||
void ff_acelp_apply_order_2_transfer_function(float *buf,
|
||||
void ff_acelp_apply_order_2_transfer_function(float *out, const float *in,
|
||||
const float zero_coeffs[2],
|
||||
const float pole_coeffs[2],
|
||||
float gain, float mem[2], int n)
|
||||
@ -103,10 +123,23 @@ void ff_acelp_apply_order_2_transfer_function(float *buf,
|
||||
float tmp;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
tmp = gain * buf[i] - pole_coeffs[0] * mem[0] - pole_coeffs[1] * mem[1];
|
||||
buf[i] = tmp + zero_coeffs[0] * mem[0] + zero_coeffs[1] * mem[1];
|
||||
tmp = gain * in[i] - pole_coeffs[0] * mem[0] - pole_coeffs[1] * mem[1];
|
||||
out[i] = tmp + zero_coeffs[0] * mem[0] + zero_coeffs[1] * mem[1];
|
||||
|
||||
mem[1] = mem[0];
|
||||
mem[0] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void ff_tilt_compensation(float *mem, float tilt, float *samples, int size)
|
||||
{
|
||||
float new_tilt_mem = samples[size - 1];
|
||||
int i;
|
||||
|
||||
for (i = size - 1; i > 0; i--)
|
||||
samples[i] -= tilt * samples[i - 1];
|
||||
|
||||
samples[0] -= tilt * *mem;
|
||||
*mem = new_tilt_mem;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,14 @@ void ff_acelp_interpolate(int16_t* out, const int16_t* in,
|
||||
const int16_t* filter_coeffs, int precision,
|
||||
int frac_pos, int filter_length, int length);
|
||||
|
||||
/**
|
||||
* Floating point version of ff_acelp_interpolate()
|
||||
*/
|
||||
void ff_acelp_interpolatef(float *out, const float *in,
|
||||
const float *filter_coeffs, int precision,
|
||||
int frac_pos, int filter_length, int length);
|
||||
|
||||
|
||||
/**
|
||||
* high-pass filtering and upscaling (4.2.5 of G.729).
|
||||
* @param out [out] output buffer for filtered speech data
|
||||
@ -84,17 +92,29 @@ void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
|
||||
/**
|
||||
* Apply an order 2 rational transfer function in-place.
|
||||
*
|
||||
* @param samples [in/out]
|
||||
* @param out output buffer for filtered speech samples
|
||||
* @param in input buffer containing speech data (may be the same as out)
|
||||
* @param zero_coeffs z^-1 and z^-2 coefficients of the numerator
|
||||
* @param pole_coeffs z^-1 and z^-2 coefficients of the denominator
|
||||
* @param gain scale factor for final output
|
||||
* @param mem intermediate values used by filter (should be 0 initially)
|
||||
* @param n number of samples
|
||||
*/
|
||||
void ff_acelp_apply_order_2_transfer_function(float *samples,
|
||||
void ff_acelp_apply_order_2_transfer_function(float *out, const float *in,
|
||||
const float zero_coeffs[2],
|
||||
const float pole_coeffs[2],
|
||||
float gain,
|
||||
float mem[2], int n);
|
||||
|
||||
/**
|
||||
* Apply tilt compensation filter, 1 - tilt * z-1.
|
||||
*
|
||||
* @param mem pointer to the filter's state (one single float)
|
||||
* @param tilt tilt factor
|
||||
* @param samples array where the filter is applied
|
||||
* @param size the size of the samples array
|
||||
*/
|
||||
void ff_tilt_compensation(float *mem, float tilt, float *samples, int size);
|
||||
|
||||
|
||||
#endif /* AVCODEC_ACELP_FILTERS_H */
|
||||
|
@ -119,3 +119,68 @@ int16_t ff_acelp_decode_gain_code(
|
||||
return mr_energy >> 12;
|
||||
#endif
|
||||
}
|
||||
|
||||
float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy,
|
||||
float *prediction_error, float energy_mean,
|
||||
const float *pred_table)
|
||||
{
|
||||
// Equations 66-69:
|
||||
// ^g_c = ^gamma_gc * 100.05 (predicted dB + mean dB - dB of fixed vector)
|
||||
// Note 10^(0.05 * -10log(average x2)) = 1/sqrt((average x2)).
|
||||
float val = fixed_gain_factor *
|
||||
exp2f(M_LOG2_10 * 0.05 *
|
||||
(ff_dot_productf(pred_table, prediction_error, 4) +
|
||||
energy_mean)) /
|
||||
sqrtf(fixed_mean_energy);
|
||||
|
||||
// update quantified prediction error energy history
|
||||
memmove(&prediction_error[0], &prediction_error[1],
|
||||
3 * sizeof(prediction_error[0]));
|
||||
prediction_error[3] = 20.0 * log10f(fixed_gain_factor);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index,
|
||||
const int prev_lag_int, const int subframe,
|
||||
int third_as_first, int resolution)
|
||||
{
|
||||
/* Note n * 10923 >> 15 is floor(x/3) for 0 <= n <= 32767 */
|
||||
if (subframe == 0 || (subframe == 2 && third_as_first)) {
|
||||
|
||||
if (pitch_index < 197)
|
||||
pitch_index += 59;
|
||||
else
|
||||
pitch_index = 3 * pitch_index - 335;
|
||||
|
||||
} else {
|
||||
if (resolution == 4) {
|
||||
int search_range_min = av_clip(prev_lag_int - 5, PITCH_DELAY_MIN,
|
||||
PITCH_DELAY_MAX - 9);
|
||||
|
||||
// decoding with 4-bit resolution
|
||||
if (pitch_index < 4) {
|
||||
// integer only precision for [search_range_min, search_range_min+3]
|
||||
pitch_index = 3 * (pitch_index + search_range_min) + 1;
|
||||
} else if (pitch_index < 12) {
|
||||
// 1/3 fractional precision for [search_range_min+3 1/3, search_range_min+5 2/3]
|
||||
pitch_index += 3 * search_range_min + 7;
|
||||
} else {
|
||||
// integer only precision for [search_range_min+6, search_range_min+9]
|
||||
pitch_index = 3 * (pitch_index + search_range_min - 6) + 1;
|
||||
}
|
||||
} else {
|
||||
// decoding with 5 or 6 bit resolution, 1/3 fractional precision
|
||||
pitch_index--;
|
||||
|
||||
if (resolution == 5) {
|
||||
pitch_index += 3 * av_clip(prev_lag_int - 10, PITCH_DELAY_MIN,
|
||||
PITCH_DELAY_MAX - 19);
|
||||
} else
|
||||
pitch_index += 3 * av_clip(prev_lag_int - 5, PITCH_DELAY_MIN,
|
||||
PITCH_DELAY_MAX - 9);
|
||||
}
|
||||
}
|
||||
*lag_int = pitch_index * 10923 >> 15;
|
||||
*lag_frac = pitch_index - 3 * *lag_int - 1;
|
||||
}
|
||||
|
@ -220,4 +220,36 @@ int16_t ff_acelp_decode_gain_code(
|
||||
int subframe_size,
|
||||
int max_pred_order);
|
||||
|
||||
/**
|
||||
* Calculate fixed gain (part of section 6.1.3 of AMR spec)
|
||||
*
|
||||
* @param fixed_gain_factor gain correction factor
|
||||
* @param fixed_energy decoded algebraic codebook vector energy
|
||||
* @param prediction_error vector of the quantified predictor errors of
|
||||
* the four previous subframes. It is updated by this function.
|
||||
* @param energy_mean desired mean innovation energy
|
||||
* @param pred_table table of four moving average coefficients
|
||||
*/
|
||||
float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy,
|
||||
float *prediction_error, float energy_mean,
|
||||
const float *pred_table);
|
||||
|
||||
|
||||
/**
|
||||
* Decode the adaptive codebook index to the integer and fractional parts
|
||||
* of the pitch lag for one subframe at 1/3 fractional precision.
|
||||
*
|
||||
* The choice of pitch lag is described in 3GPP TS 26.090 section 5.6.1.
|
||||
*
|
||||
* @param lag_int integer part of pitch lag of the current subframe
|
||||
* @param lag_frac fractional part of pitch lag of the current subframe
|
||||
* @param pitch_index parsed adaptive codebook (pitch) index
|
||||
* @param prev_lag_int integer part of pitch lag for the previous subframe
|
||||
* @param subframe current subframe number
|
||||
* @param third_as_first treat the third frame the same way as the first
|
||||
*/
|
||||
void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index,
|
||||
const int prev_lag_int, const int subframe,
|
||||
int third_as_first, int resolution);
|
||||
|
||||
#endif /* AVCODEC_ACELP_PITCH_DELAY_H */
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <inttypes.h>
|
||||
#include "avcodec.h"
|
||||
#include "acelp_vectors.h"
|
||||
#include "celp_math.h"
|
||||
|
||||
const uint8_t ff_fc_2pulses_9bits_track1[16] =
|
||||
{
|
||||
@ -102,6 +103,35 @@ static uint8_t gray_decode[32] =
|
||||
};
|
||||
#endif
|
||||
|
||||
const float ff_pow_0_7[10] = {
|
||||
0.700000, 0.490000, 0.343000, 0.240100, 0.168070,
|
||||
0.117649, 0.082354, 0.057648, 0.040354, 0.028248
|
||||
};
|
||||
|
||||
const float ff_pow_0_75[10] = {
|
||||
0.750000, 0.562500, 0.421875, 0.316406, 0.237305,
|
||||
0.177979, 0.133484, 0.100113, 0.075085, 0.056314
|
||||
};
|
||||
|
||||
const float ff_pow_0_55[10] = {
|
||||
0.550000, 0.302500, 0.166375, 0.091506, 0.050328,
|
||||
0.027681, 0.015224, 0.008373, 0.004605, 0.002533
|
||||
};
|
||||
|
||||
const float ff_b60_sinc[61] = {
|
||||
0.898529 , 0.865051 , 0.769257 , 0.624054 , 0.448639 , 0.265289 ,
|
||||
0.0959167 , -0.0412598 , -0.134338 , -0.178986 , -0.178528 , -0.142609 ,
|
||||
-0.0849304 , -0.0205078 , 0.0369568 , 0.0773926 , 0.0955200 , 0.0912781 ,
|
||||
0.0689392 , 0.0357056 , 0. , -0.0305481 , -0.0504150 , -0.0570068 ,
|
||||
-0.0508423 , -0.0350037 , -0.0141602 , 0.00665283, 0.0230713 , 0.0323486 ,
|
||||
0.0335388 , 0.0275879 , 0.0167847 , 0.00411987, -0.00747681, -0.0156860 ,
|
||||
-0.0193481 , -0.0183716 , -0.0137634 , -0.00704956, 0. , 0.00582886 ,
|
||||
0.00939941, 0.0103760 , 0.00903320, 0.00604248, 0.00238037, -0.00109863 ,
|
||||
-0.00366211, -0.00497437, -0.00503540, -0.00402832, -0.00241089, -0.000579834,
|
||||
0.00103760, 0.00222778, 0.00277710, 0.00271606, 0.00213623, 0.00115967 ,
|
||||
0.
|
||||
};
|
||||
|
||||
void ff_acelp_fc_pulse_per_track(
|
||||
int16_t* fc_v,
|
||||
const uint8_t *tab1,
|
||||
@ -126,6 +156,27 @@ void ff_acelp_fc_pulse_per_track(
|
||||
fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192;
|
||||
}
|
||||
|
||||
void ff_decode_10_pulses_35bits(const int16_t *fixed_index,
|
||||
AMRFixed *fixed_sparse,
|
||||
const uint8_t *gray_decode,
|
||||
int half_pulse_count, int bits)
|
||||
{
|
||||
int i;
|
||||
int mask = (1 << bits) - 1;
|
||||
|
||||
fixed_sparse->no_repeat_mask = 0;
|
||||
fixed_sparse->n = 2 * half_pulse_count;
|
||||
for (i = 0; i < half_pulse_count; i++) {
|
||||
const int pos1 = gray_decode[fixed_index[2*i+1] & mask] + i;
|
||||
const int pos2 = gray_decode[fixed_index[2*i ] & mask] + i;
|
||||
const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0;
|
||||
fixed_sparse->x[2*i+1] = pos1;
|
||||
fixed_sparse->x[2*i ] = pos2;
|
||||
fixed_sparse->y[2*i+1] = sign;
|
||||
fixed_sparse->y[2*i ] = pos2 < pos1 ? -sign : sign;
|
||||
}
|
||||
}
|
||||
|
||||
void ff_acelp_weighted_vector_sum(
|
||||
int16_t* out,
|
||||
const int16_t *in_a,
|
||||
@ -155,3 +206,65 @@ void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
|
||||
out[i] = weight_coeff_a * in_a[i]
|
||||
+ weight_coeff_b * in_b[i];
|
||||
}
|
||||
|
||||
void ff_adaptive_gain_control(float *out, const float *in, float speech_energ,
|
||||
int size, float alpha, float *gain_mem)
|
||||
{
|
||||
int i;
|
||||
float postfilter_energ = ff_dot_productf(in, in, size);
|
||||
float gain_scale_factor = 1.0;
|
||||
float mem = *gain_mem;
|
||||
|
||||
if (postfilter_energ)
|
||||
gain_scale_factor = sqrt(speech_energ / postfilter_energ);
|
||||
|
||||
gain_scale_factor *= 1.0 - alpha;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
mem = alpha * mem + gain_scale_factor;
|
||||
out[i] = in[i] * mem;
|
||||
}
|
||||
|
||||
*gain_mem = mem;
|
||||
}
|
||||
|
||||
void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in,
|
||||
float sum_of_squares, const int n)
|
||||
{
|
||||
int i;
|
||||
float scalefactor = ff_dot_productf(in, in, n);
|
||||
if (scalefactor)
|
||||
scalefactor = sqrt(sum_of_squares / scalefactor);
|
||||
for (i = 0; i < n; i++)
|
||||
out[i] = in[i] * scalefactor;
|
||||
}
|
||||
|
||||
void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i < in->n; i++) {
|
||||
int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
|
||||
float y = in->y[i] * scale;
|
||||
|
||||
do {
|
||||
out[x] += y;
|
||||
y *= in->pitch_fac;
|
||||
x += in->pitch_lag;
|
||||
} while (x < size && repeats);
|
||||
}
|
||||
}
|
||||
|
||||
void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i < in->n; i++) {
|
||||
int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
|
||||
|
||||
do {
|
||||
out[x] = 0.0;
|
||||
x += in->pitch_lag;
|
||||
} while (x < size && repeats);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,16 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** Sparse representation for the algebraic codebook (fixed) vector */
|
||||
typedef struct {
|
||||
int n;
|
||||
int x[10];
|
||||
float y[10];
|
||||
int no_repeat_mask;
|
||||
int pitch_lag;
|
||||
float pitch_fac;
|
||||
} AMRFixed;
|
||||
|
||||
/**
|
||||
* Track|Pulse| Positions
|
||||
* -------------------------------------------------------------------------
|
||||
@ -102,6 +112,26 @@ extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16];
|
||||
*/
|
||||
extern const uint8_t ff_fc_2pulses_9bits_track2_gray[32];
|
||||
|
||||
/**
|
||||
* b60 hamming windowed sinc function coefficients
|
||||
*/
|
||||
extern const float ff_b60_sinc[61];
|
||||
|
||||
/**
|
||||
* Table of pow(0.7,n)
|
||||
*/
|
||||
extern const float ff_pow_0_7[10];
|
||||
|
||||
/**
|
||||
* Table of pow(0.75,n)
|
||||
*/
|
||||
extern const float ff_pow_0_75[10];
|
||||
|
||||
/**
|
||||
* Table of pow(0.55,n)
|
||||
*/
|
||||
extern const float ff_pow_0_55[10];
|
||||
|
||||
/**
|
||||
* Decode fixed-codebook vector (3.8 and D.5.8 of G.729, 5.7.1 of AMR).
|
||||
* @param fc_v [out] decoded fixed codebook vector (2.13)
|
||||
@ -116,14 +146,31 @@ extern const uint8_t ff_fc_2pulses_9bits_track2_gray[32];
|
||||
*
|
||||
* Used in G.729 @8k, G.729 @4.4k, G.729 @6.4k, AMR @7.95k, AMR @7.40k
|
||||
*/
|
||||
void ff_acelp_fc_pulse_per_track(
|
||||
int16_t* fc_v,
|
||||
const uint8_t *tab1,
|
||||
const uint8_t *tab2,
|
||||
int pulse_indexes,
|
||||
int pulse_signs,
|
||||
int pulse_count,
|
||||
int bits);
|
||||
void ff_acelp_fc_pulse_per_track(int16_t* fc_v,
|
||||
const uint8_t *tab1,
|
||||
const uint8_t *tab2,
|
||||
int pulse_indexes,
|
||||
int pulse_signs,
|
||||
int pulse_count,
|
||||
int bits);
|
||||
|
||||
/**
|
||||
* Decode the algebraic codebook index to pulse positions and signs and
|
||||
* construct the algebraic codebook vector for MODE_12k2.
|
||||
*
|
||||
* @note: The positions and signs are explicitly coded in MODE_12k2.
|
||||
*
|
||||
* @param fixed_index positions of the ten pulses
|
||||
* @param fixed_sparse pointer to the algebraic codebook vector
|
||||
* @param gray_decode gray decoding table
|
||||
* @param half_pulse_count number of couples of pulses
|
||||
* @param bits length of one pulse index in bits
|
||||
*/
|
||||
void ff_decode_10_pulses_35bits(const int16_t *fixed_index,
|
||||
AMRFixed *fixed_sparse,
|
||||
const uint8_t *gray_decode,
|
||||
int half_pulse_count, int bits);
|
||||
|
||||
|
||||
/**
|
||||
* weighted sum of two vectors with rounding.
|
||||
@ -140,15 +187,14 @@ void ff_acelp_fc_pulse_per_track(
|
||||
*
|
||||
* out[i] = (in_a[i]*weight_a + in_b[i]*weight_b + rounder) >> shift
|
||||
*/
|
||||
void ff_acelp_weighted_vector_sum(
|
||||
int16_t* out,
|
||||
const int16_t *in_a,
|
||||
const int16_t *in_b,
|
||||
int16_t weight_coeff_a,
|
||||
int16_t weight_coeff_b,
|
||||
int16_t rounder,
|
||||
int shift,
|
||||
int length);
|
||||
void ff_acelp_weighted_vector_sum(int16_t* out,
|
||||
const int16_t *in_a,
|
||||
const int16_t *in_b,
|
||||
int16_t weight_coeff_a,
|
||||
int16_t weight_coeff_b,
|
||||
int16_t rounder,
|
||||
int shift,
|
||||
int length);
|
||||
|
||||
/**
|
||||
* float implementation of weighted sum of two vectors.
|
||||
@ -162,6 +208,57 @@ void ff_acelp_weighted_vector_sum(
|
||||
* @note It is safe to pass the same buffer for out and in_a or in_b.
|
||||
*/
|
||||
void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
|
||||
float weight_coeff_a, float weight_coeff_b, int length);
|
||||
float weight_coeff_a, float weight_coeff_b,
|
||||
int length);
|
||||
|
||||
/**
|
||||
* Adaptive gain control (as used in AMR postfiltering)
|
||||
*
|
||||
* @param out output buffer for filtered speech data
|
||||
* @param in the input speech buffer (may be the same as out)
|
||||
* @param speech_energ input energy
|
||||
* @param size the input buffer size
|
||||
* @param alpha exponential filter factor
|
||||
* @param gain_mem a pointer to the filter memory (single float of size)
|
||||
*/
|
||||
void ff_adaptive_gain_control(float *out, const float *in, float speech_energ,
|
||||
int size, float alpha, float *gain_mem);
|
||||
|
||||
/**
|
||||
* Set the sum of squares of a signal by scaling
|
||||
*
|
||||
* @param out output samples
|
||||
* @param in input samples
|
||||
* @param sum_of_squares new sum of squares
|
||||
* @param n number of samples
|
||||
*
|
||||
* @note If the input is zero (or its energy underflows), the output is zero.
|
||||
* This is the behavior of AGC in the AMR reference decoder. The QCELP
|
||||
* reference decoder seems to have undefined behavior.
|
||||
*
|
||||
* TIA/EIA/IS-733 2.4.8.3-2/3/4/5, 2.4.8.6
|
||||
* 3GPP TS 26.090 6.1 (6)
|
||||
*/
|
||||
void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in,
|
||||
float sum_of_squares, const int n);
|
||||
|
||||
/**
|
||||
* Add fixed vector to an array from a sparse representation
|
||||
*
|
||||
* @param out fixed vector with pitch sharpening
|
||||
* @param in sparse fixed vector
|
||||
* @param scale number to multiply the fixed vector by
|
||||
* @param size the output vector size
|
||||
*/
|
||||
void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size);
|
||||
|
||||
/**
|
||||
* Clear array values set by set_fixed_vector
|
||||
*
|
||||
* @param out fixed vector to be cleared
|
||||
* @param in sparse fixed vector
|
||||
* @param size the output vector size
|
||||
*/
|
||||
void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size);
|
||||
|
||||
#endif /* AVCODEC_ACELP_VECTORS_H */
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "bytestream.h"
|
||||
|
||||
/**
|
||||
* @file libavcodec/adpcm.c
|
||||
* @file
|
||||
* ADPCM codecs.
|
||||
* First version by Francois Revol (revol@free.fr)
|
||||
* Fringe ADPCM codecs (e.g., DK3, DK4, Westwood)
|
||||
@ -86,10 +86,12 @@ static const int AdaptationTable[] = {
|
||||
768, 614, 512, 409, 307, 230, 230, 230
|
||||
};
|
||||
|
||||
/** Divided by 4 to fit in 8-bit integers */
|
||||
static const uint8_t AdaptCoeff1[] = {
|
||||
64, 128, 0, 48, 60, 115, 98
|
||||
};
|
||||
|
||||
/** Divided by 4 to fit in 8-bit integers */
|
||||
static const int8_t AdaptCoeff2[] = {
|
||||
0, -64, 0, 16, 0, -52, -58
|
||||
};
|
||||
@ -152,6 +154,8 @@ typedef struct ADPCMContext {
|
||||
#if CONFIG_ENCODERS
|
||||
static av_cold int adpcm_encode_init(AVCodecContext *avctx)
|
||||
{
|
||||
uint8_t *extradata;
|
||||
int i;
|
||||
if (avctx->channels > 2)
|
||||
return -1; /* only stereo or mono =) */
|
||||
|
||||
@ -175,6 +179,16 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
|
||||
avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2; /* each 16 bits sample gives one nibble */
|
||||
/* and we have 7 bytes per channel overhead */
|
||||
avctx->block_align = BLKSIZE;
|
||||
avctx->extradata_size = 32;
|
||||
extradata = avctx->extradata = av_malloc(avctx->extradata_size);
|
||||
if (!extradata)
|
||||
return AVERROR(ENOMEM);
|
||||
bytestream_put_le16(&extradata, avctx->frame_size);
|
||||
bytestream_put_le16(&extradata, 7); /* wNumCoef */
|
||||
for (i = 0; i < 7; i++) {
|
||||
bytestream_put_le16(&extradata, AdaptCoeff1[i] * 4);
|
||||
bytestream_put_le16(&extradata, AdaptCoeff2[i] * 4);
|
||||
}
|
||||
break;
|
||||
case CODEC_ID_ADPCM_YAMAHA:
|
||||
avctx->frame_size = BLKSIZE * avctx->channels;
|
||||
@ -1624,14 +1638,14 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
|
||||
#define ADPCM_ENCODER(id,name,long_name_) \
|
||||
AVCodec name ## _encoder = { \
|
||||
#name, \
|
||||
CODEC_TYPE_AUDIO, \
|
||||
AVMEDIA_TYPE_AUDIO, \
|
||||
id, \
|
||||
sizeof(ADPCMContext), \
|
||||
adpcm_encode_init, \
|
||||
adpcm_encode_frame, \
|
||||
adpcm_encode_close, \
|
||||
NULL, \
|
||||
.sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, \
|
||||
.sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, \
|
||||
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
|
||||
};
|
||||
#else
|
||||
@ -1642,7 +1656,7 @@ AVCodec name ## _encoder = { \
|
||||
#define ADPCM_DECODER(id,name,long_name_) \
|
||||
AVCodec name ## _decoder = { \
|
||||
#name, \
|
||||
CODEC_TYPE_AUDIO, \
|
||||
AVMEDIA_TYPE_AUDIO, \
|
||||
id, \
|
||||
sizeof(ADPCMContext), \
|
||||
adpcm_decode_init, \
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/adx.h
|
||||
* @file
|
||||
* SEGA CRI adx codecs.
|
||||
*
|
||||
* Reference documents:
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "adx.h"
|
||||
|
||||
/**
|
||||
* @file libavcodec/adxdec.c
|
||||
* @file
|
||||
* SEGA CRI adx codecs.
|
||||
*
|
||||
* Reference documents:
|
||||
@ -168,7 +168,7 @@ static int adx_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
AVCodec adpcm_adx_decoder = {
|
||||
"adpcm_adx",
|
||||
CODEC_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
CODEC_ID_ADPCM_ADX,
|
||||
sizeof(ADXContext),
|
||||
adx_decode_init,
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "adx.h"
|
||||
|
||||
/**
|
||||
* @file libavcodec/adxenc.c
|
||||
* @file
|
||||
* SEGA CRI adx codecs.
|
||||
*
|
||||
* Reference documents:
|
||||
@ -185,13 +185,13 @@ static int adx_encode_frame(AVCodecContext *avctx,
|
||||
|
||||
AVCodec adpcm_adx_encoder = {
|
||||
"adpcm_adx",
|
||||
CODEC_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
CODEC_ID_ADPCM_ADX,
|
||||
sizeof(ADXContext),
|
||||
adx_encode_init,
|
||||
adx_encode_frame,
|
||||
adx_encode_close,
|
||||
NULL,
|
||||
.sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
|
||||
.sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
|
||||
.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
|
||||
};
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/alac.c
|
||||
* @file
|
||||
* ALAC (Apple Lossless Audio Codec) decoder
|
||||
* @author 2005 David Hammerton
|
||||
*
|
||||
@ -77,6 +77,8 @@ typedef struct {
|
||||
|
||||
int32_t *outputsamples_buffer[MAX_CHANNELS];
|
||||
|
||||
int32_t *wasted_bits_buffer[MAX_CHANNELS];
|
||||
|
||||
/* stuff from setinfo */
|
||||
uint32_t setinfo_max_samples_per_frame; /* 0x1000 = 4096 */ /* max samples per frame? */
|
||||
uint8_t setinfo_sample_size; /* 0x10 */
|
||||
@ -85,6 +87,7 @@ typedef struct {
|
||||
uint8_t setinfo_rice_kmodifier; /* 0x0e */
|
||||
/* end setinfo stuff */
|
||||
|
||||
int wasted_bits;
|
||||
} ALACContext;
|
||||
|
||||
static void allocate_buffers(ALACContext *alac)
|
||||
@ -96,6 +99,8 @@ static void allocate_buffers(ALACContext *alac)
|
||||
|
||||
alac->outputsamples_buffer[chan] =
|
||||
av_malloc(alac->setinfo_max_samples_per_frame * 4);
|
||||
|
||||
alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,6 +403,56 @@ static void reconstruct_stereo_16(int32_t *buffer[MAX_CHANNELS],
|
||||
}
|
||||
}
|
||||
|
||||
static void decorrelate_stereo_24(int32_t *buffer[MAX_CHANNELS],
|
||||
int32_t *buffer_out,
|
||||
int32_t *wasted_bits_buffer[MAX_CHANNELS],
|
||||
int wasted_bits,
|
||||
int numchannels, int numsamples,
|
||||
uint8_t interlacing_shift,
|
||||
uint8_t interlacing_leftweight)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (numsamples <= 0)
|
||||
return;
|
||||
|
||||
/* weighted interlacing */
|
||||
if (interlacing_leftweight) {
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
int32_t a, b;
|
||||
|
||||
a = buffer[0][i];
|
||||
b = buffer[1][i];
|
||||
|
||||
a -= (b * interlacing_leftweight) >> interlacing_shift;
|
||||
b += a;
|
||||
|
||||
if (wasted_bits) {
|
||||
b = (b << wasted_bits) | wasted_bits_buffer[0][i];
|
||||
a = (a << wasted_bits) | wasted_bits_buffer[1][i];
|
||||
}
|
||||
|
||||
buffer_out[i * numchannels] = b << 8;
|
||||
buffer_out[i * numchannels + 1] = a << 8;
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
int32_t left, right;
|
||||
|
||||
left = buffer[0][i];
|
||||
right = buffer[1][i];
|
||||
|
||||
if (wasted_bits) {
|
||||
left = (left << wasted_bits) | wasted_bits_buffer[0][i];
|
||||
right = (right << wasted_bits) | wasted_bits_buffer[1][i];
|
||||
}
|
||||
|
||||
buffer_out[i * numchannels] = left << 8;
|
||||
buffer_out[i * numchannels + 1] = right << 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int alac_decode_frame(AVCodecContext *avctx,
|
||||
void *outbuffer, int *outputsize,
|
||||
AVPacket *avpkt)
|
||||
@ -410,7 +465,6 @@ static int alac_decode_frame(AVCodecContext *avctx,
|
||||
unsigned int outputsamples;
|
||||
int hassize;
|
||||
unsigned int readsamplesize;
|
||||
int wasted_bytes;
|
||||
int isnotcompressed;
|
||||
uint8_t interlacing_shift;
|
||||
uint8_t interlacing_leftweight;
|
||||
@ -452,7 +506,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
|
||||
/* the output sample size is stored soon */
|
||||
hassize = get_bits1(&alac->gb);
|
||||
|
||||
wasted_bytes = get_bits(&alac->gb, 2); /* unknown ? */
|
||||
alac->wasted_bits = get_bits(&alac->gb, 2) << 3;
|
||||
|
||||
/* whether the frame is compressed */
|
||||
isnotcompressed = get_bits1(&alac->gb);
|
||||
@ -467,13 +521,25 @@ static int alac_decode_frame(AVCodecContext *avctx,
|
||||
} else
|
||||
outputsamples = alac->setinfo_max_samples_per_frame;
|
||||
|
||||
switch (alac->setinfo_sample_size) {
|
||||
case 16: avctx->sample_fmt = SAMPLE_FMT_S16;
|
||||
alac->bytespersample = channels << 1;
|
||||
break;
|
||||
case 24: avctx->sample_fmt = SAMPLE_FMT_S32;
|
||||
alac->bytespersample = channels << 2;
|
||||
break;
|
||||
default: av_log(avctx, AV_LOG_ERROR, "Sample depth %d is not supported.\n",
|
||||
alac->setinfo_sample_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(outputsamples > *outputsize / alac->bytespersample){
|
||||
av_log(avctx, AV_LOG_ERROR, "sample buffer too small\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*outputsize = outputsamples * alac->bytespersample;
|
||||
readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + channels - 1;
|
||||
readsamplesize = alac->setinfo_sample_size - (alac->wasted_bits) + channels - 1;
|
||||
if (readsamplesize > MIN_CACHE_BITS) {
|
||||
av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize);
|
||||
return -1;
|
||||
@ -503,9 +569,13 @@ static int alac_decode_frame(AVCodecContext *avctx,
|
||||
predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16);
|
||||
}
|
||||
|
||||
if (wasted_bytes)
|
||||
av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n");
|
||||
|
||||
if (alac->wasted_bits) {
|
||||
int i, ch;
|
||||
for (i = 0; i < outputsamples; i++) {
|
||||
for (ch = 0; ch < channels; ch++)
|
||||
alac->wasted_bits_buffer[ch][i] = get_bits(&alac->gb, alac->wasted_bits);
|
||||
}
|
||||
}
|
||||
for (chan = 0; chan < channels; chan++) {
|
||||
bastardized_rice_decompress(alac,
|
||||
alac->predicterror_buffer[chan],
|
||||
@ -538,6 +608,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
|
||||
} else {
|
||||
/* not compressed, easy case */
|
||||
int i, chan;
|
||||
if (alac->setinfo_sample_size <= 16) {
|
||||
for (i = 0; i < outputsamples; i++)
|
||||
for (chan = 0; chan < channels; chan++) {
|
||||
int32_t audiobits;
|
||||
@ -546,7 +617,17 @@ static int alac_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
alac->outputsamples_buffer[chan][i] = audiobits;
|
||||
}
|
||||
/* wasted_bytes = 0; */
|
||||
} else {
|
||||
for (i = 0; i < outputsamples; i++) {
|
||||
for (chan = 0; chan < channels; chan++) {
|
||||
alac->outputsamples_buffer[chan][i] = get_bits(&alac->gb,
|
||||
alac->setinfo_sample_size);
|
||||
alac->outputsamples_buffer[chan][i] = sign_extend(alac->outputsamples_buffer[chan][i],
|
||||
alac->setinfo_sample_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
alac->wasted_bits = 0;
|
||||
interlacing_shift = 0;
|
||||
interlacing_leftweight = 0;
|
||||
}
|
||||
@ -565,19 +646,25 @@ static int alac_decode_frame(AVCodecContext *avctx,
|
||||
} else {
|
||||
int i;
|
||||
for (i = 0; i < outputsamples; i++) {
|
||||
int16_t sample = alac->outputsamples_buffer[0][i];
|
||||
((int16_t*)outbuffer)[i * alac->numchannels] = sample;
|
||||
((int16_t*)outbuffer)[i] = alac->outputsamples_buffer[0][i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 20:
|
||||
case 24:
|
||||
// It is not clear if there exist any encoder that creates 24 bit ALAC
|
||||
// files. iTunes convert 24 bit raw files to 16 bit before encoding.
|
||||
case 32:
|
||||
av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size);
|
||||
break;
|
||||
default:
|
||||
if (channels == 2) {
|
||||
decorrelate_stereo_24(alac->outputsamples_buffer,
|
||||
outbuffer,
|
||||
alac->wasted_bits_buffer,
|
||||
alac->wasted_bits,
|
||||
alac->numchannels,
|
||||
outputsamples,
|
||||
interlacing_shift,
|
||||
interlacing_leftweight);
|
||||
} else {
|
||||
int i;
|
||||
for (i = 0; i < outputsamples; i++)
|
||||
((int32_t *)outbuffer)[i] = alac->outputsamples_buffer[0][i] << 8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -594,8 +681,6 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
|
||||
alac->context_initialized = 0;
|
||||
|
||||
alac->numchannels = alac->avctx->channels;
|
||||
alac->bytespersample = 2 * alac->numchannels;
|
||||
avctx->sample_fmt = SAMPLE_FMT_S16;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -606,8 +691,9 @@ static av_cold int alac_decode_close(AVCodecContext *avctx)
|
||||
|
||||
int chan;
|
||||
for (chan = 0; chan < MAX_CHANNELS; chan++) {
|
||||
av_free(alac->predicterror_buffer[chan]);
|
||||
av_free(alac->outputsamples_buffer[chan]);
|
||||
av_freep(&alac->predicterror_buffer[chan]);
|
||||
av_freep(&alac->outputsamples_buffer[chan]);
|
||||
av_freep(&alac->wasted_bits_buffer[chan]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -615,7 +701,7 @@ static av_cold int alac_decode_close(AVCodecContext *avctx)
|
||||
|
||||
AVCodec alac_decoder = {
|
||||
"alac",
|
||||
CODEC_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
CODEC_ID_ALAC,
|
||||
sizeof(ALACContext),
|
||||
alac_decode_init,
|
||||
|
@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "put_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "lpc.h"
|
||||
@ -123,7 +122,7 @@ static void write_frame_header(AlacEncodeContext *s, int is_verbatim)
|
||||
put_bits(&s->pbctx, 1, 1); // Sample count is in the header
|
||||
put_bits(&s->pbctx, 2, 0); // FIXME: Wasted bytes field
|
||||
put_bits(&s->pbctx, 1, is_verbatim); // Audio block is verbatim
|
||||
put_bits(&s->pbctx, 32, s->avctx->frame_size); // No. of samples in the frame
|
||||
put_bits32(&s->pbctx, s->avctx->frame_size); // No. of samples in the frame
|
||||
}
|
||||
|
||||
static void calc_predictor_params(AlacEncodeContext *s, int ch)
|
||||
@ -132,12 +131,27 @@ static void calc_predictor_params(AlacEncodeContext *s, int ch)
|
||||
int shift[MAX_LPC_ORDER];
|
||||
int opt_order;
|
||||
|
||||
opt_order = ff_lpc_calc_coefs(&s->dspctx, s->sample_buf[ch], s->avctx->frame_size, s->min_prediction_order, s->max_prediction_order,
|
||||
ALAC_MAX_LPC_PRECISION, coefs, shift, 1, ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
|
||||
if (s->compression_level == 1) {
|
||||
s->lpc[ch].lpc_order = 6;
|
||||
s->lpc[ch].lpc_quant = 6;
|
||||
s->lpc[ch].lpc_coeff[0] = 160;
|
||||
s->lpc[ch].lpc_coeff[1] = -190;
|
||||
s->lpc[ch].lpc_coeff[2] = 170;
|
||||
s->lpc[ch].lpc_coeff[3] = -130;
|
||||
s->lpc[ch].lpc_coeff[4] = 80;
|
||||
s->lpc[ch].lpc_coeff[5] = -25;
|
||||
} else {
|
||||
opt_order = ff_lpc_calc_coefs(&s->dspctx, s->sample_buf[ch],
|
||||
s->avctx->frame_size,
|
||||
s->min_prediction_order,
|
||||
s->max_prediction_order,
|
||||
ALAC_MAX_LPC_PRECISION, coefs, shift, 1,
|
||||
ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
|
||||
|
||||
s->lpc[ch].lpc_order = opt_order;
|
||||
s->lpc[ch].lpc_quant = shift[opt_order-1];
|
||||
memcpy(s->lpc[ch].lpc_coeff, coefs[opt_order-1], opt_order*sizeof(int));
|
||||
s->lpc[ch].lpc_order = opt_order;
|
||||
s->lpc[ch].lpc_quant = shift[opt_order-1];
|
||||
memcpy(s->lpc[ch].lpc_coeff, coefs[opt_order-1], opt_order*sizeof(int));
|
||||
}
|
||||
}
|
||||
|
||||
static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n)
|
||||
@ -375,9 +389,9 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
|
||||
|
||||
// Set default compression level
|
||||
if(avctx->compression_level == FF_COMPRESSION_DEFAULT)
|
||||
s->compression_level = 1;
|
||||
s->compression_level = 2;
|
||||
else
|
||||
s->compression_level = av_clip(avctx->compression_level, 0, 1);
|
||||
s->compression_level = av_clip(avctx->compression_level, 0, 2);
|
||||
|
||||
// Initialize default Rice parameters
|
||||
s->rc.history_mult = 40;
|
||||
@ -385,8 +399,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
|
||||
s->rc.k_modifier = 14;
|
||||
s->rc.rice_modifier = 4;
|
||||
|
||||
s->max_coded_frame_size = (ALAC_FRAME_HEADER_SIZE + ALAC_FRAME_FOOTER_SIZE +
|
||||
avctx->frame_size*avctx->channels*avctx->bits_per_coded_sample)>>3;
|
||||
s->max_coded_frame_size = 8 + (avctx->frame_size*avctx->channels*avctx->bits_per_coded_sample>>3);
|
||||
|
||||
s->write_sample_size = avctx->bits_per_coded_sample + avctx->channels - 1; // FIXME: consider wasted_bytes
|
||||
|
||||
@ -507,12 +520,13 @@ static av_cold int alac_encode_close(AVCodecContext *avctx)
|
||||
|
||||
AVCodec alac_encoder = {
|
||||
"alac",
|
||||
CODEC_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
CODEC_ID_ALAC,
|
||||
sizeof(AlacEncodeContext),
|
||||
alac_encode_init,
|
||||
alac_encode_frame,
|
||||
alac_encode_close,
|
||||
.capabilities = CODEC_CAP_SMALL_LAST_FRAME,
|
||||
.sample_fmts = (const enum SampleFormat[]){ SAMPLE_FMT_S16, SAMPLE_FMT_NONE},
|
||||
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
|
||||
};
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/allcodecs.c
|
||||
* @file
|
||||
* Provides registration of all codecs, parsers and bitstream filters for libavcodec.
|
||||
*/
|
||||
|
||||
@ -55,22 +55,31 @@ void avcodec_register_all(void)
|
||||
|
||||
/* hardware accelerators */
|
||||
REGISTER_HWACCEL (H263_VAAPI, h263_vaapi);
|
||||
REGISTER_HWACCEL (H264_DXVA2, h264_dxva2);
|
||||
REGISTER_HWACCEL (H264_VAAPI, h264_vaapi);
|
||||
REGISTER_HWACCEL (MPEG2_VAAPI, mpeg2_vaapi);
|
||||
REGISTER_HWACCEL (MPEG4_VAAPI, mpeg4_vaapi);
|
||||
REGISTER_HWACCEL (VC1_DXVA2, vc1_dxva2);
|
||||
REGISTER_HWACCEL (VC1_VAAPI, vc1_vaapi);
|
||||
REGISTER_HWACCEL (WMV3_DXVA2, wmv3_dxva2);
|
||||
REGISTER_HWACCEL (WMV3_VAAPI, wmv3_vaapi);
|
||||
|
||||
/* video codecs */
|
||||
REGISTER_DECODER (AASC, aasc);
|
||||
REGISTER_DECODER (AMV, amv);
|
||||
REGISTER_DECODER (ANM, anm);
|
||||
REGISTER_ENCDEC (ASV1, asv1);
|
||||
REGISTER_ENCDEC (ASV2, asv2);
|
||||
REGISTER_DECODER (AURA, aura);
|
||||
REGISTER_DECODER (AURA2, aura2);
|
||||
REGISTER_DECODER (AVS, avs);
|
||||
REGISTER_DECODER (BETHSOFTVID, bethsoftvid);
|
||||
REGISTER_DECODER (BFI, bfi);
|
||||
REGISTER_DECODER (BINK, bink);
|
||||
REGISTER_ENCDEC (BMP, bmp);
|
||||
REGISTER_DECODER (C93, c93);
|
||||
REGISTER_DECODER (CAVS, cavs);
|
||||
REGISTER_DECODER (CDGRAPHICS, cdgraphics);
|
||||
REGISTER_DECODER (CINEPAK, cinepak);
|
||||
REGISTER_DECODER (CLJR, cljr);
|
||||
REGISTER_DECODER (CSCD, cscd);
|
||||
@ -96,6 +105,7 @@ void avcodec_register_all(void)
|
||||
REGISTER_ENCDEC (FLV, flv);
|
||||
REGISTER_DECODER (FOURXM, fourxm);
|
||||
REGISTER_DECODER (FRAPS, fraps);
|
||||
REGISTER_DECODER (FRWU, frwu);
|
||||
REGISTER_ENCDEC (GIF, gif);
|
||||
REGISTER_ENCDEC (H261, h261);
|
||||
REGISTER_ENCDEC (H263, h263);
|
||||
@ -105,10 +115,14 @@ void avcodec_register_all(void)
|
||||
REGISTER_DECODER (H264_VDPAU, h264_vdpau);
|
||||
REGISTER_ENCDEC (HUFFYUV, huffyuv);
|
||||
REGISTER_DECODER (IDCIN, idcin);
|
||||
REGISTER_DECODER (IFF_BYTERUN1, iff_byterun1);
|
||||
REGISTER_DECODER (IFF_ILBM, iff_ilbm);
|
||||
REGISTER_DECODER (INDEO2, indeo2);
|
||||
REGISTER_DECODER (INDEO3, indeo3);
|
||||
REGISTER_DECODER (INDEO5, indeo5);
|
||||
REGISTER_DECODER (INTERPLAY_VIDEO, interplay_video);
|
||||
REGISTER_ENCDEC (JPEGLS, jpegls);
|
||||
REGISTER_DECODER (KGV1, kgv1);
|
||||
REGISTER_DECODER (KMVC, kmvc);
|
||||
REGISTER_ENCODER (LJPEG, ljpeg);
|
||||
REGISTER_DECODER (LOCO, loco);
|
||||
@ -122,6 +136,7 @@ void avcodec_register_all(void)
|
||||
REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video);
|
||||
REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video);
|
||||
REGISTER_ENCDEC (MPEG4, mpeg4);
|
||||
REGISTER_DECODER (MPEG4_VDPAU, mpeg4_vdpau);
|
||||
REGISTER_DECODER (MPEGVIDEO, mpegvideo);
|
||||
REGISTER_DECODER (MPEG_VDPAU, mpeg_vdpau);
|
||||
REGISTER_DECODER (MPEG1_VDPAU, mpeg1_vdpau);
|
||||
@ -143,6 +158,7 @@ void avcodec_register_all(void)
|
||||
REGISTER_DECODER (QDRAW, qdraw);
|
||||
REGISTER_DECODER (QPEG, qpeg);
|
||||
REGISTER_ENCDEC (QTRLE, qtrle);
|
||||
REGISTER_DECODER (R210, r210);
|
||||
REGISTER_ENCDEC (RAWVIDEO, rawvideo);
|
||||
REGISTER_DECODER (RL2, rl2);
|
||||
REGISTER_ENCDEC (ROQ, roq);
|
||||
@ -191,6 +207,7 @@ void avcodec_register_all(void)
|
||||
REGISTER_DECODER (WNV1, wnv1);
|
||||
REGISTER_DECODER (XAN_WC3, xan_wc3);
|
||||
REGISTER_DECODER (XL, xl);
|
||||
REGISTER_DECODER (YOP, yop);
|
||||
REGISTER_ENCDEC (ZLIB, zlib);
|
||||
REGISTER_ENCDEC (ZMBV, zmbv);
|
||||
|
||||
@ -198,8 +215,13 @@ void avcodec_register_all(void)
|
||||
REGISTER_ENCDEC (AAC, aac);
|
||||
REGISTER_ENCDEC (AC3, ac3);
|
||||
REGISTER_ENCDEC (ALAC, alac);
|
||||
REGISTER_DECODER (ALS, als);
|
||||
REGISTER_DECODER (AMRNB, amrnb);
|
||||
REGISTER_DECODER (APE, ape);
|
||||
REGISTER_DECODER (ATRAC1, atrac1);
|
||||
REGISTER_DECODER (ATRAC3, atrac3);
|
||||
REGISTER_DECODER (BINKAUDIO_DCT, binkaudio_dct);
|
||||
REGISTER_DECODER (BINKAUDIO_RDFT, binkaudio_rdft);
|
||||
REGISTER_DECODER (COOK, cook);
|
||||
REGISTER_DECODER (DCA, dca);
|
||||
REGISTER_DECODER (DSICINAUDIO, dsicinaudio);
|
||||
@ -222,21 +244,26 @@ void avcodec_register_all(void)
|
||||
REGISTER_DECODER (RA_144, ra_144);
|
||||
REGISTER_DECODER (RA_288, ra_288);
|
||||
REGISTER_DECODER (SHORTEN, shorten);
|
||||
REGISTER_DECODER (SIPR, sipr);
|
||||
REGISTER_DECODER (SMACKAUD, smackaud);
|
||||
REGISTER_ENCDEC (SONIC, sonic);
|
||||
REGISTER_ENCODER (SONIC_LS, sonic_ls);
|
||||
REGISTER_DECODER (TRUEHD, truehd);
|
||||
REGISTER_DECODER (TRUESPEECH, truespeech);
|
||||
REGISTER_DECODER (TTA, tta);
|
||||
REGISTER_DECODER (TWINVQ, twinvq);
|
||||
REGISTER_DECODER (VMDAUDIO, vmdaudio);
|
||||
REGISTER_ENCDEC (VORBIS, vorbis);
|
||||
REGISTER_DECODER (VORBIS, vorbis);
|
||||
REGISTER_DECODER (WAVPACK, wavpack);
|
||||
REGISTER_DECODER (WMAPRO, wmapro);
|
||||
REGISTER_ENCDEC (WMAV1, wmav1);
|
||||
REGISTER_ENCDEC (WMAV2, wmav2);
|
||||
REGISTER_DECODER (WMAVOICE, wmavoice);
|
||||
REGISTER_DECODER (WS_SND1, ws_snd1);
|
||||
|
||||
/* PCM codecs */
|
||||
REGISTER_ENCDEC (PCM_ALAW, pcm_alaw);
|
||||
REGISTER_DECODER (PCM_BLURAY, pcm_bluray);
|
||||
REGISTER_DECODER (PCM_DVD, pcm_dvd);
|
||||
REGISTER_ENCDEC (PCM_F32BE, pcm_f32be);
|
||||
REGISTER_ENCDEC (PCM_F32LE, pcm_f32le);
|
||||
@ -300,6 +327,7 @@ void avcodec_register_all(void)
|
||||
/* subtitles */
|
||||
REGISTER_ENCDEC (DVBSUB, dvbsub);
|
||||
REGISTER_ENCDEC (DVDSUB, dvdsub);
|
||||
REGISTER_DECODER (PGSSUB, pgssub);
|
||||
REGISTER_ENCDEC (XSUB, xsub);
|
||||
|
||||
/* external libraries */
|
||||
@ -316,6 +344,7 @@ void avcodec_register_all(void)
|
||||
REGISTER_DECODER (LIBSPEEX, libspeex);
|
||||
REGISTER_ENCODER (LIBTHEORA, libtheora);
|
||||
REGISTER_ENCODER (LIBVORBIS, libvorbis);
|
||||
REGISTER_ENCDEC (LIBVPX, libvpx);
|
||||
REGISTER_ENCODER (LIBX264, libx264);
|
||||
REGISTER_ENCODER (LIBXVID, libxvid);
|
||||
|
||||
|
1636
src/add-ons/media/plugins/ffmpeg/libavcodec/alsdec.c
Normal file
1636
src/add-ons/media/plugins/ffmpeg/libavcodec/alsdec.c
Normal file
File diff suppressed because it is too large
Load Diff
1672
src/add-ons/media/plugins/ffmpeg/libavcodec/amrnbdata.h
Normal file
1672
src/add-ons/media/plugins/ffmpeg/libavcodec/amrnbdata.h
Normal file
File diff suppressed because it is too large
Load Diff
1076
src/add-ons/media/plugins/ffmpeg/libavcodec/amrnbdec.c
Normal file
1076
src/add-ons/media/plugins/ffmpeg/libavcodec/amrnbdec.c
Normal file
File diff suppressed because it is too large
Load Diff
197
src/add-ons/media/plugins/ffmpeg/libavcodec/anm.c
Normal file
197
src/add-ons/media/plugins/ffmpeg/libavcodec/anm.c
Normal file
@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Deluxe Paint Animation decoder
|
||||
* Copyright (c) 2009 Peter Ross
|
||||
*
|
||||
* 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
|
||||
* Deluxe Paint Animation decoder
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "bytestream.h"
|
||||
|
||||
typedef struct AnmContext {
|
||||
AVFrame frame;
|
||||
int x; ///< x coordinate position
|
||||
} AnmContext;
|
||||
|
||||
static av_cold int decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
AnmContext *s = avctx->priv_data;
|
||||
const uint8_t *buf;
|
||||
int i;
|
||||
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
|
||||
if (avctx->extradata_size != 16*8 + 4*256)
|
||||
return -1;
|
||||
|
||||
s->frame.reference = 1;
|
||||
if (avctx->get_buffer(avctx, &s->frame) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf = avctx->extradata + 16*8;
|
||||
for (i = 0; i < 256; i++)
|
||||
((uint32_t*)s->frame.data[1])[i] = bytestream_get_le32(&buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform decode operation
|
||||
* @param dst, dst_end Destination image buffer
|
||||
* @param buf, buf_end Source buffer (optional, see below)
|
||||
* @param pixel Fill color (optional, see below)
|
||||
* @param count Pixel count
|
||||
* @param x Pointer to x-axis counter
|
||||
* @param width Image width
|
||||
* @param linesize Destination image buffer linesize
|
||||
* @return non-zero if destination buffer is exhausted
|
||||
*
|
||||
* a copy operation is achieved when 'buf' is set
|
||||
* a fill operation is acheived when 'buf' is null and pixel is >= 0
|
||||
* a skip operation is acheived when 'buf' is null and pixel is < 0
|
||||
*/
|
||||
static inline int op(uint8_t **dst, const uint8_t *dst_end,
|
||||
const uint8_t **buf, const uint8_t *buf_end,
|
||||
int pixel, int count,
|
||||
int *x, int width, int linesize)
|
||||
{
|
||||
int remaining = width - *x;
|
||||
while(count > 0) {
|
||||
int striplen = FFMIN(count, remaining);
|
||||
if (buf) {
|
||||
striplen = FFMIN(striplen, buf_end - *buf);
|
||||
memcpy(*dst, *buf, striplen);
|
||||
*buf += striplen;
|
||||
} else if (pixel >= 0)
|
||||
memset(*dst, pixel, striplen);
|
||||
*dst += striplen;
|
||||
remaining -= striplen;
|
||||
count -= striplen;
|
||||
if (remaining <= 0) {
|
||||
*dst += linesize - width;
|
||||
remaining = width;
|
||||
}
|
||||
if (linesize > 0) {
|
||||
if (*dst >= dst_end) goto exhausted;
|
||||
} else {
|
||||
if (*dst <= dst_end) goto exhausted;
|
||||
}
|
||||
}
|
||||
*x = width - remaining;
|
||||
return 0;
|
||||
|
||||
exhausted:
|
||||
*x = width - remaining;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int decode_frame(AVCodecContext *avctx,
|
||||
void *data, int *data_size,
|
||||
AVPacket *avpkt)
|
||||
{
|
||||
AnmContext *s = avctx->priv_data;
|
||||
const uint8_t *buf = avpkt->data;
|
||||
const int buf_size = avpkt->size;
|
||||
const uint8_t *buf_end = buf + buf_size;
|
||||
uint8_t *dst, *dst_end;
|
||||
int count;
|
||||
|
||||
if(avctx->reget_buffer(avctx, &s->frame) < 0){
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return -1;
|
||||
}
|
||||
dst = s->frame.data[0];
|
||||
dst_end = s->frame.data[0] + s->frame.linesize[0]*avctx->height;
|
||||
|
||||
if (buf[0] != 0x42) {
|
||||
av_log_ask_for_sample(avctx, "unknown record type\n");
|
||||
return buf_size;
|
||||
}
|
||||
if (buf[1]) {
|
||||
av_log_ask_for_sample(avctx, "padding bytes not supported\n");
|
||||
return buf_size;
|
||||
}
|
||||
buf += 4;
|
||||
|
||||
s->x = 0;
|
||||
do {
|
||||
/* if statements are ordered by probability */
|
||||
#define OP(buf, pixel, count) \
|
||||
op(&dst, dst_end, (buf), buf_end, (pixel), (count), &s->x, avctx->width, s->frame.linesize[0])
|
||||
|
||||
int type = bytestream_get_byte(&buf);
|
||||
count = type & 0x7F;
|
||||
type >>= 7;
|
||||
if (count) {
|
||||
if (OP(type ? NULL : &buf, -1, count)) break;
|
||||
} else if (!type) {
|
||||
int pixel;
|
||||
count = bytestream_get_byte(&buf); /* count==0 gives nop */
|
||||
pixel = bytestream_get_byte(&buf);
|
||||
if (OP(NULL, pixel, count)) break;
|
||||
} else {
|
||||
int pixel;
|
||||
type = bytestream_get_le16(&buf);
|
||||
count = type & 0x3FFF;
|
||||
type >>= 14;
|
||||
if (!count) {
|
||||
if (type == 0)
|
||||
break; // stop
|
||||
if (type == 2) {
|
||||
av_log_ask_for_sample(avctx, "unknown opcode");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
pixel = type == 3 ? bytestream_get_byte(&buf) : -1;
|
||||
if (type == 1) count += 0x4000;
|
||||
if (OP(type == 2 ? &buf : NULL, pixel, count)) break;
|
||||
}
|
||||
} while (buf + 1 < buf_end);
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
*(AVFrame*)data = s->frame;
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
static av_cold int decode_end(AVCodecContext *avctx)
|
||||
{
|
||||
AnmContext *s = avctx->priv_data;
|
||||
if (s->frame.data[0])
|
||||
avctx->release_buffer(avctx, &s->frame);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVCodec anm_decoder = {
|
||||
"anm",
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_ANM,
|
||||
sizeof(AnmContext),
|
||||
decode_init,
|
||||
NULL,
|
||||
decode_end,
|
||||
decode_frame,
|
||||
CODEC_CAP_DR1,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Deluxe Paint Animation"),
|
||||
};
|
@ -27,7 +27,7 @@
|
||||
#include "bytestream.h"
|
||||
|
||||
/**
|
||||
* @file libavcodec/apedec.c
|
||||
* @file
|
||||
* Monkey's Audio lossless audio decoder
|
||||
*/
|
||||
|
||||
@ -211,6 +211,7 @@ static av_cold int ape_decode_close(AVCodecContext * avctx)
|
||||
for (i = 0; i < APE_FILTER_LEVELS; i++)
|
||||
av_freep(&s->filterbuf[i]);
|
||||
|
||||
av_freep(&s->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -408,8 +409,24 @@ static inline int ape_decode_value(APEContext * ctx, APERice *rice)
|
||||
overflow |= range_decode_bits(ctx, 16);
|
||||
}
|
||||
|
||||
base = range_decode_culfreq(ctx, pivot);
|
||||
range_decode_update(ctx, 1, base);
|
||||
if (pivot < 0x10000) {
|
||||
base = range_decode_culfreq(ctx, pivot);
|
||||
range_decode_update(ctx, 1, base);
|
||||
} else {
|
||||
int base_hi = pivot, base_lo;
|
||||
int bbits = 0;
|
||||
|
||||
while (base_hi & ~0xFFFF) {
|
||||
base_hi >>= 1;
|
||||
bbits++;
|
||||
}
|
||||
base_hi = range_decode_culfreq(ctx, base_hi + 1);
|
||||
range_decode_update(ctx, 1, base_hi);
|
||||
base_lo = range_decode_culfreq(ctx, 1 << bbits);
|
||||
range_decode_update(ctx, 1, base_lo);
|
||||
|
||||
base = (base_hi << bbits) + base_lo;
|
||||
}
|
||||
|
||||
x = base + overflow * pivot;
|
||||
}
|
||||
@ -501,9 +518,9 @@ static inline int APESIGN(int32_t x) {
|
||||
return (x < 0) - (x > 0);
|
||||
}
|
||||
|
||||
static int predictor_update_filter(APEPredictor *p, const int decoded, const int filter, const int delayA, const int delayB, const int adaptA, const int adaptB)
|
||||
static av_always_inline int predictor_update_filter(APEPredictor *p, const int decoded, const int filter, const int delayA, const int delayB, const int adaptA, const int adaptB)
|
||||
{
|
||||
int32_t predictionA, predictionB;
|
||||
int32_t predictionA, predictionB, sign;
|
||||
|
||||
p->buf[delayA] = p->lastA[filter];
|
||||
p->buf[adaptA] = APESIGN(p->buf[delayA]);
|
||||
@ -531,48 +548,32 @@ static int predictor_update_filter(APEPredictor *p, const int decoded, const int
|
||||
p->lastA[filter] = decoded + ((predictionA + (predictionB >> 1)) >> 10);
|
||||
p->filterA[filter] = p->lastA[filter] + ((p->filterA[filter] * 31) >> 5);
|
||||
|
||||
if (!decoded) // no need updating filter coefficients
|
||||
return p->filterA[filter];
|
||||
sign = APESIGN(decoded);
|
||||
p->coeffsA[filter][0] += p->buf[adaptA ] * sign;
|
||||
p->coeffsA[filter][1] += p->buf[adaptA - 1] * sign;
|
||||
p->coeffsA[filter][2] += p->buf[adaptA - 2] * sign;
|
||||
p->coeffsA[filter][3] += p->buf[adaptA - 3] * sign;
|
||||
p->coeffsB[filter][0] += p->buf[adaptB ] * sign;
|
||||
p->coeffsB[filter][1] += p->buf[adaptB - 1] * sign;
|
||||
p->coeffsB[filter][2] += p->buf[adaptB - 2] * sign;
|
||||
p->coeffsB[filter][3] += p->buf[adaptB - 3] * sign;
|
||||
p->coeffsB[filter][4] += p->buf[adaptB - 4] * sign;
|
||||
|
||||
if (decoded > 0) {
|
||||
p->coeffsA[filter][0] -= p->buf[adaptA ];
|
||||
p->coeffsA[filter][1] -= p->buf[adaptA - 1];
|
||||
p->coeffsA[filter][2] -= p->buf[adaptA - 2];
|
||||
p->coeffsA[filter][3] -= p->buf[adaptA - 3];
|
||||
|
||||
p->coeffsB[filter][0] -= p->buf[adaptB ];
|
||||
p->coeffsB[filter][1] -= p->buf[adaptB - 1];
|
||||
p->coeffsB[filter][2] -= p->buf[adaptB - 2];
|
||||
p->coeffsB[filter][3] -= p->buf[adaptB - 3];
|
||||
p->coeffsB[filter][4] -= p->buf[adaptB - 4];
|
||||
} else {
|
||||
p->coeffsA[filter][0] += p->buf[adaptA ];
|
||||
p->coeffsA[filter][1] += p->buf[adaptA - 1];
|
||||
p->coeffsA[filter][2] += p->buf[adaptA - 2];
|
||||
p->coeffsA[filter][3] += p->buf[adaptA - 3];
|
||||
|
||||
p->coeffsB[filter][0] += p->buf[adaptB ];
|
||||
p->coeffsB[filter][1] += p->buf[adaptB - 1];
|
||||
p->coeffsB[filter][2] += p->buf[adaptB - 2];
|
||||
p->coeffsB[filter][3] += p->buf[adaptB - 3];
|
||||
p->coeffsB[filter][4] += p->buf[adaptB - 4];
|
||||
}
|
||||
return p->filterA[filter];
|
||||
}
|
||||
|
||||
static void predictor_decode_stereo(APEContext * ctx, int count)
|
||||
{
|
||||
int32_t predictionA, predictionB;
|
||||
APEPredictor *p = &ctx->predictor;
|
||||
int32_t *decoded0 = ctx->decoded0;
|
||||
int32_t *decoded1 = ctx->decoded1;
|
||||
|
||||
while (count--) {
|
||||
/* Predictor Y */
|
||||
predictionA = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, YADAPTCOEFFSA, YADAPTCOEFFSB);
|
||||
predictionB = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, XADAPTCOEFFSA, XADAPTCOEFFSB);
|
||||
*(decoded0++) = predictionA;
|
||||
*(decoded1++) = predictionB;
|
||||
*decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, YADAPTCOEFFSA, YADAPTCOEFFSB);
|
||||
decoded0++;
|
||||
*decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, XADAPTCOEFFSA, XADAPTCOEFFSB);
|
||||
decoded1++;
|
||||
|
||||
/* Combined */
|
||||
p->buf++;
|
||||
@ -589,7 +590,7 @@ static void predictor_decode_mono(APEContext * ctx, int count)
|
||||
{
|
||||
APEPredictor *p = &ctx->predictor;
|
||||
int32_t *decoded0 = ctx->decoded0;
|
||||
int32_t predictionA, currentA, A;
|
||||
int32_t predictionA, currentA, A, sign;
|
||||
|
||||
currentA = p->lastA[0];
|
||||
|
||||
@ -609,17 +610,11 @@ static void predictor_decode_mono(APEContext * ctx, int count)
|
||||
p->buf[YADAPTCOEFFSA] = APESIGN(p->buf[YDELAYA ]);
|
||||
p->buf[YADAPTCOEFFSA - 1] = APESIGN(p->buf[YDELAYA - 1]);
|
||||
|
||||
if (A > 0) {
|
||||
p->coeffsA[0][0] -= p->buf[YADAPTCOEFFSA ];
|
||||
p->coeffsA[0][1] -= p->buf[YADAPTCOEFFSA - 1];
|
||||
p->coeffsA[0][2] -= p->buf[YADAPTCOEFFSA - 2];
|
||||
p->coeffsA[0][3] -= p->buf[YADAPTCOEFFSA - 3];
|
||||
} else if (A < 0) {
|
||||
p->coeffsA[0][0] += p->buf[YADAPTCOEFFSA ];
|
||||
p->coeffsA[0][1] += p->buf[YADAPTCOEFFSA - 1];
|
||||
p->coeffsA[0][2] += p->buf[YADAPTCOEFFSA - 2];
|
||||
p->coeffsA[0][3] += p->buf[YADAPTCOEFFSA - 3];
|
||||
}
|
||||
sign = APESIGN(A);
|
||||
p->coeffsA[0][0] += p->buf[YADAPTCOEFFSA ] * sign;
|
||||
p->coeffsA[0][1] += p->buf[YADAPTCOEFFSA - 1] * sign;
|
||||
p->coeffsA[0][2] += p->buf[YADAPTCOEFFSA - 2] * sign;
|
||||
p->coeffsA[0][3] += p->buf[YADAPTCOEFFSA - 3] * sign;
|
||||
|
||||
p->buf++;
|
||||
|
||||
@ -654,22 +649,16 @@ static void init_filter(APEContext * ctx, APEFilter *f, int16_t * buf, int order
|
||||
do_init_filter(&f[1], buf + order * 3 + HISTORY_SIZE, order);
|
||||
}
|
||||
|
||||
static inline void do_apply_filter(APEContext * ctx, int version, APEFilter *f, int32_t *data, int count, int order, int fracbits)
|
||||
static void do_apply_filter(APEContext * ctx, int version, APEFilter *f, int32_t *data, int count, int order, int fracbits)
|
||||
{
|
||||
int res;
|
||||
int absres;
|
||||
|
||||
while (count--) {
|
||||
/* round fixedpoint scalar product */
|
||||
res = (ctx->dsp.scalarproduct_int16(f->delay - order, f->coeffs, order, 0) + (1 << (fracbits - 1))) >> fracbits;
|
||||
|
||||
if (*data < 0)
|
||||
ctx->dsp.add_int16(f->coeffs, f->adaptcoeffs - order, order);
|
||||
else if (*data > 0)
|
||||
ctx->dsp.sub_int16(f->coeffs, f->adaptcoeffs - order, order);
|
||||
|
||||
res = ctx->dsp.scalarproduct_and_madd_int16(f->coeffs, f->delay - order, f->adaptcoeffs - order, order, APESIGN(*data));
|
||||
res = (res + (1 << (fracbits - 1))) >> fracbits;
|
||||
res += *data;
|
||||
|
||||
*data++ = res;
|
||||
|
||||
/* Update the output history */
|
||||
@ -684,14 +673,9 @@ static inline void do_apply_filter(APEContext * ctx, int version, APEFilter *f,
|
||||
/* Version 3.98 and later files */
|
||||
|
||||
/* Update the adaption coefficients */
|
||||
absres = (res < 0 ? -res : res);
|
||||
|
||||
if (absres > (f->avg * 3))
|
||||
*f->adaptcoeffs = ((res >> 25) & 64) - 32;
|
||||
else if (absres > (f->avg * 4) / 3)
|
||||
*f->adaptcoeffs = ((res >> 26) & 32) - 16;
|
||||
else if (absres > 0)
|
||||
*f->adaptcoeffs = ((res >> 27) & 16) - 8;
|
||||
absres = FFABS(res);
|
||||
if (absres)
|
||||
*f->adaptcoeffs = ((res & (1<<31)) - (1<<30)) >> (25 + (absres <= f->avg*3) + (absres <= f->avg*4/3));
|
||||
else
|
||||
*f->adaptcoeffs = 0;
|
||||
|
||||
@ -871,6 +855,7 @@ static int ape_decode_frame(AVCodecContext * avctx,
|
||||
ape_unpack_mono(s, blockstodecode);
|
||||
else
|
||||
ape_unpack_stereo(s, blockstodecode);
|
||||
emms_c();
|
||||
|
||||
if(s->error || s->ptr > s->data_end){
|
||||
s->samples=0;
|
||||
@ -894,12 +879,13 @@ static int ape_decode_frame(AVCodecContext * avctx,
|
||||
|
||||
AVCodec ape_decoder = {
|
||||
"ape",
|
||||
CODEC_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
CODEC_ID_APE,
|
||||
sizeof(APEContext),
|
||||
ape_decode_init,
|
||||
NULL,
|
||||
ape_decode_close,
|
||||
ape_decode_frame,
|
||||
.capabilities = CODEC_CAP_SUBFRAMES,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"),
|
||||
};
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/apiexample.c
|
||||
* @file
|
||||
* avcodec API use example.
|
||||
*
|
||||
* Note that this library only handles codecs (mpeg, mpeg4, etc...),
|
||||
@ -35,10 +35,12 @@
|
||||
#undef HAVE_AV_CONFIG_H
|
||||
#endif
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
|
||||
#define INBUF_SIZE 4096
|
||||
#define AUDIO_INBUF_SIZE 20480
|
||||
#define AUDIO_REFILL_THRESH 4096
|
||||
|
||||
/*
|
||||
* Audio encoding example
|
||||
@ -118,7 +120,7 @@ static void audio_decode_example(const char *outfilename, const char *filename)
|
||||
int out_size, len;
|
||||
FILE *f, *outfile;
|
||||
uint8_t *outbuf;
|
||||
uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
|
||||
uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
|
||||
AVPacket avpkt;
|
||||
|
||||
av_init_packet(&avpkt);
|
||||
@ -155,25 +157,32 @@ static void audio_decode_example(const char *outfilename, const char *filename)
|
||||
|
||||
/* decode until eof */
|
||||
avpkt.data = inbuf;
|
||||
for(;;) {
|
||||
avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
|
||||
if (avpkt.size == 0)
|
||||
break;
|
||||
avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
|
||||
|
||||
avpkt.data = inbuf;
|
||||
while (avpkt.size > 0) {
|
||||
out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
||||
len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt);
|
||||
if (len < 0) {
|
||||
fprintf(stderr, "Error while decoding\n");
|
||||
exit(1);
|
||||
}
|
||||
if (out_size > 0) {
|
||||
/* if a frame has been decoded, output it */
|
||||
fwrite(outbuf, 1, out_size, outfile);
|
||||
}
|
||||
avpkt.size -= len;
|
||||
avpkt.data += len;
|
||||
while (avpkt.size > 0) {
|
||||
out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
||||
len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt);
|
||||
if (len < 0) {
|
||||
fprintf(stderr, "Error while decoding\n");
|
||||
exit(1);
|
||||
}
|
||||
if (out_size > 0) {
|
||||
/* if a frame has been decoded, output it */
|
||||
fwrite(outbuf, 1, out_size, outfile);
|
||||
}
|
||||
avpkt.size -= len;
|
||||
avpkt.data += len;
|
||||
if (avpkt.size < AUDIO_REFILL_THRESH) {
|
||||
/* Refill the input buffer, to avoid trying to decode
|
||||
* incomplete frames. Instead of this, one could also use
|
||||
* a parser, or use a proper container format through
|
||||
* libavformat. */
|
||||
memmove(inbuf, avpkt.data, avpkt.size);
|
||||
avpkt.data = inbuf;
|
||||
len = fread(avpkt.data + avpkt.size, 1,
|
||||
AUDIO_INBUF_SIZE - avpkt.size, f);
|
||||
if (len > 0)
|
||||
avpkt.size += len;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/asv1.c
|
||||
* @file
|
||||
* ASUS V1/V2 codec.
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "put_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "mpeg12data.h"
|
||||
@ -48,9 +48,9 @@ typedef struct ASV1Context{
|
||||
int mb_height;
|
||||
int mb_width2;
|
||||
int mb_height2;
|
||||
DECLARE_ALIGNED_16(DCTELEM, block[6][64]);
|
||||
DECLARE_ALIGNED_8(uint16_t, intra_matrix[64]);
|
||||
DECLARE_ALIGNED_8(int, q_intra_matrix[64]);
|
||||
DECLARE_ALIGNED(16, DCTELEM, block)[6][64];
|
||||
uint16_t intra_matrix[64];
|
||||
int q_intra_matrix[64];
|
||||
uint8_t *bitstream_buffer;
|
||||
unsigned int bitstream_buffer_size;
|
||||
} ASV1Context;
|
||||
@ -140,11 +140,11 @@ static av_cold void init_vlcs(ASV1Context *a){
|
||||
|
||||
//FIXME write a reversed bitstream reader to avoid the double reverse
|
||||
static inline int asv2_get_bits(GetBitContext *gb, int n){
|
||||
return ff_reverse[ get_bits(gb, n) << (8-n) ];
|
||||
return av_reverse[ get_bits(gb, n) << (8-n) ];
|
||||
}
|
||||
|
||||
static inline void asv2_put_bits(PutBitContext *pb, int n, int v){
|
||||
put_bits(pb, n, ff_reverse[ v << (8-n) ]);
|
||||
put_bits(pb, n, av_reverse[ v << (8-n) ]);
|
||||
}
|
||||
|
||||
static inline int asv1_get_level(GetBitContext *gb){
|
||||
@ -394,7 +394,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
int buf_size = avpkt->size;
|
||||
ASV1Context * const a = avctx->priv_data;
|
||||
AVFrame *picture = data;
|
||||
AVFrame * const p= (AVFrame*)&a->picture;
|
||||
AVFrame * const p= &a->picture;
|
||||
int mb_x, mb_y;
|
||||
|
||||
if(p->data[0])
|
||||
@ -417,7 +417,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
else{
|
||||
int i;
|
||||
for(i=0; i<buf_size; i++)
|
||||
a->bitstream_buffer[i]= ff_reverse[ buf[i] ];
|
||||
a->bitstream_buffer[i]= av_reverse[ buf[i] ];
|
||||
}
|
||||
|
||||
init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8);
|
||||
@ -474,7 +474,7 @@ for(i=0; i<s->avctx->extradata_size; i++){
|
||||
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
|
||||
ASV1Context * const a = avctx->priv_data;
|
||||
AVFrame *pict = data;
|
||||
AVFrame * const p= (AVFrame*)&a->picture;
|
||||
AVFrame * const p= &a->picture;
|
||||
int size;
|
||||
int mb_x, mb_y;
|
||||
|
||||
@ -519,7 +519,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
|
||||
else{
|
||||
int i;
|
||||
for(i=0; i<4*size; i++)
|
||||
buf[i]= ff_reverse[ buf[i] ];
|
||||
buf[i]= av_reverse[ buf[i] ];
|
||||
}
|
||||
|
||||
return size*4;
|
||||
@ -536,13 +536,13 @@ static av_cold void common_init(AVCodecContext *avctx){
|
||||
a->mb_width2 = (avctx->width + 0) / 16;
|
||||
a->mb_height2 = (avctx->height + 0) / 16;
|
||||
|
||||
avctx->coded_frame= (AVFrame*)&a->picture;
|
||||
avctx->coded_frame= &a->picture;
|
||||
a->avctx= avctx;
|
||||
}
|
||||
|
||||
static av_cold int decode_init(AVCodecContext *avctx){
|
||||
ASV1Context * const a = avctx->priv_data;
|
||||
AVFrame *p= (AVFrame*)&a->picture;
|
||||
AVFrame *p= &a->picture;
|
||||
int i;
|
||||
const int scale= avctx->codec_id == CODEC_ID_ASV1 ? 1 : 2;
|
||||
|
||||
@ -551,7 +551,7 @@ static av_cold int decode_init(AVCodecContext *avctx){
|
||||
ff_init_scantable(a->dsp.idct_permutation, &a->scantable, scantab);
|
||||
avctx->pix_fmt= PIX_FMT_YUV420P;
|
||||
|
||||
a->inv_qscale= ((uint8_t*)avctx->extradata)[0];
|
||||
a->inv_qscale= avctx->extradata[0];
|
||||
if(a->inv_qscale == 0){
|
||||
av_log(avctx, AV_LOG_ERROR, "illegal qscale 0\n");
|
||||
if(avctx->codec_id == CODEC_ID_ASV1)
|
||||
@ -607,12 +607,15 @@ static av_cold int decode_end(AVCodecContext *avctx){
|
||||
av_freep(&a->picture.qscale_table);
|
||||
a->bitstream_buffer_size=0;
|
||||
|
||||
if(a->picture.data[0])
|
||||
avctx->release_buffer(avctx, &a->picture);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVCodec asv1_decoder = {
|
||||
"asv1",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_ASV1,
|
||||
sizeof(ASV1Context),
|
||||
decode_init,
|
||||
@ -625,7 +628,7 @@ AVCodec asv1_decoder = {
|
||||
|
||||
AVCodec asv2_decoder = {
|
||||
"asv2",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_ASV2,
|
||||
sizeof(ASV1Context),
|
||||
decode_init,
|
||||
@ -639,13 +642,13 @@ AVCodec asv2_decoder = {
|
||||
#if CONFIG_ASV1_ENCODER
|
||||
AVCodec asv1_encoder = {
|
||||
"asv1",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_ASV1,
|
||||
sizeof(ASV1Context),
|
||||
encode_init,
|
||||
encode_frame,
|
||||
//encode_end,
|
||||
.pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
|
||||
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
|
||||
.long_name= NULL_IF_CONFIG_SMALL("ASUS V1"),
|
||||
};
|
||||
#endif
|
||||
@ -653,13 +656,13 @@ AVCodec asv1_encoder = {
|
||||
#if CONFIG_ASV2_ENCODER
|
||||
AVCodec asv2_encoder = {
|
||||
"asv2",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_ASV2,
|
||||
sizeof(ASV1Context),
|
||||
encode_init,
|
||||
encode_frame,
|
||||
//encode_end,
|
||||
.pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
|
||||
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
|
||||
.long_name= NULL_IF_CONFIG_SMALL("ASUS V2"),
|
||||
};
|
||||
#endif
|
||||
|
120
src/add-ons/media/plugins/ffmpeg/libavcodec/atrac.c
Normal file
120
src/add-ons/media/plugins/ffmpeg/libavcodec/atrac.c
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Atrac common functions
|
||||
* Copyright (c) 2006-2008 Maxim Poliakovski
|
||||
* Copyright (c) 2006-2008 Benjamin Larsson
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "dsputil.h"
|
||||
#include "atrac.h"
|
||||
|
||||
float sf_table[64];
|
||||
float qmf_window[48];
|
||||
|
||||
static const float qmf_48tap_half[24] = {
|
||||
-0.00001461907, -0.00009205479,-0.000056157569,0.00030117269,
|
||||
0.0002422519, -0.00085293897,-0.0005205574, 0.0020340169,
|
||||
0.00078333891, -0.0042153862, -0.00075614988, 0.0078402944,
|
||||
-0.000061169922,-0.01344162, 0.0024626821, 0.021736089,
|
||||
-0.007801671, -0.034090221, 0.01880949, 0.054326009,
|
||||
-0.043596379, -0.099384367, 0.13207909, 0.46424159
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate common tables
|
||||
*/
|
||||
|
||||
void atrac_generate_tables(void)
|
||||
{
|
||||
int i;
|
||||
float s;
|
||||
|
||||
/* Generate scale factors */
|
||||
if (!sf_table[63])
|
||||
for (i=0 ; i<64 ; i++)
|
||||
sf_table[i] = pow(2.0, (i - 15) / 3.0);
|
||||
|
||||
/* Generate the QMF window. */
|
||||
if (!qmf_window[47])
|
||||
for (i=0 ; i<24; i++) {
|
||||
s = qmf_48tap_half[i] * 2.0;
|
||||
qmf_window[i] = qmf_window[47 - i] = s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Quadrature mirror synthesis filter.
|
||||
*
|
||||
* @param inlo lower part of spectrum
|
||||
* @param inhi higher part of spectrum
|
||||
* @param nIn size of spectrum buffer
|
||||
* @param pOut out buffer
|
||||
* @param delayBuf delayBuf buffer
|
||||
* @param temp temp buffer
|
||||
*/
|
||||
|
||||
|
||||
void atrac_iqmf (float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp)
|
||||
{
|
||||
int i, j;
|
||||
float *p1, *p3;
|
||||
|
||||
memcpy(temp, delayBuf, 46*sizeof(float));
|
||||
|
||||
p3 = temp + 46;
|
||||
|
||||
/* loop1 */
|
||||
for(i=0; i<nIn; i+=2){
|
||||
p3[2*i+0] = inlo[i ] + inhi[i ];
|
||||
p3[2*i+1] = inlo[i ] - inhi[i ];
|
||||
p3[2*i+2] = inlo[i+1] + inhi[i+1];
|
||||
p3[2*i+3] = inlo[i+1] - inhi[i+1];
|
||||
}
|
||||
|
||||
/* loop2 */
|
||||
p1 = temp;
|
||||
for (j = nIn; j != 0; j--) {
|
||||
float s1 = 0.0;
|
||||
float s2 = 0.0;
|
||||
|
||||
for (i = 0; i < 48; i += 2) {
|
||||
s1 += p1[i] * qmf_window[i];
|
||||
s2 += p1[i+1] * qmf_window[i+1];
|
||||
}
|
||||
|
||||
pOut[0] = s2;
|
||||
pOut[1] = s1;
|
||||
|
||||
p1 += 2;
|
||||
pOut += 2;
|
||||
}
|
||||
|
||||
/* Update the delay buffer. */
|
||||
memcpy(delayBuf, temp + nIn*2, 46*sizeof(float));
|
||||
}
|
||||
|
38
src/add-ons/media/plugins/ffmpeg/libavcodec/atrac.h
Normal file
38
src/add-ons/media/plugins/ffmpeg/libavcodec/atrac.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Atrac common data
|
||||
* Copyright (c) 2009 Maxim Poliakovski
|
||||
* Copyright (c) 2009 Benjamin Larsson
|
||||
*
|
||||
* 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
|
||||
* Atrac common header
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ATRAC_H
|
||||
#define AVCODEC_ATRAC_H
|
||||
|
||||
|
||||
extern float sf_table[64];
|
||||
extern float qmf_window[48];
|
||||
|
||||
void atrac_generate_tables(void);
|
||||
void atrac_iqmf (float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp);
|
||||
|
||||
#endif /* AVCODEC_ATRAC_H */
|
377
src/add-ons/media/plugins/ffmpeg/libavcodec/atrac1.c
Normal file
377
src/add-ons/media/plugins/ffmpeg/libavcodec/atrac1.c
Normal file
@ -0,0 +1,377 @@
|
||||
/*
|
||||
* Atrac 1 compatible decoder
|
||||
* Copyright (c) 2009 Maxim Poliakovski
|
||||
* Copyright (c) 2009 Benjamin Larsson
|
||||
*
|
||||
* 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
|
||||
* Atrac 1 compatible decoder.
|
||||
* This decoder handles raw ATRAC1 data and probably SDDS data.
|
||||
*/
|
||||
|
||||
/* Many thanks to Tim Craig for all the help! */
|
||||
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
|
||||
#include "atrac.h"
|
||||
#include "atrac1data.h"
|
||||
|
||||
#define AT1_MAX_BFU 52 ///< max number of block floating units in a sound unit
|
||||
#define AT1_SU_SIZE 212 ///< number of bytes in a sound unit
|
||||
#define AT1_SU_SAMPLES 512 ///< number of samples in a sound unit
|
||||
#define AT1_FRAME_SIZE AT1_SU_SIZE * 2
|
||||
#define AT1_SU_MAX_BITS AT1_SU_SIZE * 8
|
||||
#define AT1_MAX_CHANNELS 2
|
||||
|
||||
#define AT1_QMF_BANDS 3
|
||||
#define IDX_LOW_BAND 0
|
||||
#define IDX_MID_BAND 1
|
||||
#define IDX_HIGH_BAND 2
|
||||
|
||||
/**
|
||||
* Sound unit struct, one unit is used per channel
|
||||
*/
|
||||
typedef struct {
|
||||
int log2_block_count[AT1_QMF_BANDS]; ///< log2 number of blocks in a band
|
||||
int num_bfus; ///< number of Block Floating Units
|
||||
float* spectrum[2];
|
||||
DECLARE_ALIGNED(16, float, spec1)[AT1_SU_SAMPLES]; ///< mdct buffer
|
||||
DECLARE_ALIGNED(16, float, spec2)[AT1_SU_SAMPLES]; ///< mdct buffer
|
||||
DECLARE_ALIGNED(16, float, fst_qmf_delay)[46]; ///< delay line for the 1st stacked QMF filter
|
||||
DECLARE_ALIGNED(16, float, snd_qmf_delay)[46]; ///< delay line for the 2nd stacked QMF filter
|
||||
DECLARE_ALIGNED(16, float, last_qmf_delay)[256+23]; ///< delay line for the last stacked QMF filter
|
||||
} AT1SUCtx;
|
||||
|
||||
/**
|
||||
* The atrac1 context, holds all needed parameters for decoding
|
||||
*/
|
||||
typedef struct {
|
||||
AT1SUCtx SUs[AT1_MAX_CHANNELS]; ///< channel sound unit
|
||||
DECLARE_ALIGNED(16, float, spec)[AT1_SU_SAMPLES]; ///< the mdct spectrum buffer
|
||||
|
||||
DECLARE_ALIGNED(16, float, low)[256];
|
||||
DECLARE_ALIGNED(16, float, mid)[256];
|
||||
DECLARE_ALIGNED(16, float, high)[512];
|
||||
float* bands[3];
|
||||
DECLARE_ALIGNED(16, float, out_samples)[AT1_MAX_CHANNELS][AT1_SU_SAMPLES];
|
||||
FFTContext mdct_ctx[3];
|
||||
int channels;
|
||||
DSPContext dsp;
|
||||
} AT1Ctx;
|
||||
|
||||
/** size of the transform in samples in the long mode for each QMF band */
|
||||
static const uint16_t samples_per_band[3] = {128, 128, 256};
|
||||
static const uint8_t mdct_long_nbits[3] = {7, 7, 8};
|
||||
|
||||
|
||||
static void at1_imdct(AT1Ctx *q, float *spec, float *out, int nbits,
|
||||
int rev_spec)
|
||||
{
|
||||
FFTContext* mdct_context = &q->mdct_ctx[nbits - 5 - (nbits > 6)];
|
||||
int transf_size = 1 << nbits;
|
||||
|
||||
if (rev_spec) {
|
||||
int i;
|
||||
for (i = 0; i < transf_size / 2; i++)
|
||||
FFSWAP(float, spec[i], spec[transf_size - 1 - i]);
|
||||
}
|
||||
ff_imdct_half(mdct_context, out, spec);
|
||||
}
|
||||
|
||||
|
||||
static int at1_imdct_block(AT1SUCtx* su, AT1Ctx *q)
|
||||
{
|
||||
int band_num, band_samples, log2_block_count, nbits, num_blocks, block_size;
|
||||
unsigned int start_pos, ref_pos = 0, pos = 0;
|
||||
|
||||
for (band_num = 0; band_num < AT1_QMF_BANDS; band_num++) {
|
||||
float *prev_buf;
|
||||
int j;
|
||||
|
||||
band_samples = samples_per_band[band_num];
|
||||
log2_block_count = su->log2_block_count[band_num];
|
||||
|
||||
/* number of mdct blocks in the current QMF band: 1 - for long mode */
|
||||
/* 4 for short mode(low/middle bands) and 8 for short mode(high band)*/
|
||||
num_blocks = 1 << log2_block_count;
|
||||
|
||||
if (num_blocks == 1) {
|
||||
/* mdct block size in samples: 128 (long mode, low & mid bands), */
|
||||
/* 256 (long mode, high band) and 32 (short mode, all bands) */
|
||||
block_size = band_samples >> log2_block_count;
|
||||
|
||||
/* calc transform size in bits according to the block_size_mode */
|
||||
nbits = mdct_long_nbits[band_num] - log2_block_count;
|
||||
|
||||
if (nbits != 5 && nbits != 7 && nbits != 8)
|
||||
return -1;
|
||||
} else {
|
||||
block_size = 32;
|
||||
nbits = 5;
|
||||
}
|
||||
|
||||
start_pos = 0;
|
||||
prev_buf = &su->spectrum[1][ref_pos + band_samples - 16];
|
||||
for (j=0; j < num_blocks; j++) {
|
||||
at1_imdct(q, &q->spec[pos], &su->spectrum[0][ref_pos + start_pos], nbits, band_num);
|
||||
|
||||
/* overlap and window */
|
||||
q->dsp.vector_fmul_window(&q->bands[band_num][start_pos], prev_buf,
|
||||
&su->spectrum[0][ref_pos + start_pos], ff_sine_32, 0, 16);
|
||||
|
||||
prev_buf = &su->spectrum[0][ref_pos+start_pos + 16];
|
||||
start_pos += block_size;
|
||||
pos += block_size;
|
||||
}
|
||||
|
||||
if (num_blocks == 1)
|
||||
memcpy(q->bands[band_num] + 32, &su->spectrum[0][ref_pos + 16], 240 * sizeof(float));
|
||||
|
||||
ref_pos += band_samples;
|
||||
}
|
||||
|
||||
/* Swap buffers so the mdct overlap works */
|
||||
FFSWAP(float*, su->spectrum[0], su->spectrum[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the block size mode byte
|
||||
*/
|
||||
|
||||
static int at1_parse_bsm(GetBitContext* gb, int log2_block_cnt[AT1_QMF_BANDS])
|
||||
{
|
||||
int log2_block_count_tmp, i;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
/* low and mid band */
|
||||
log2_block_count_tmp = get_bits(gb, 2);
|
||||
if (log2_block_count_tmp & 1)
|
||||
return -1;
|
||||
log2_block_cnt[i] = 2 - log2_block_count_tmp;
|
||||
}
|
||||
|
||||
/* high band */
|
||||
log2_block_count_tmp = get_bits(gb, 2);
|
||||
if (log2_block_count_tmp != 0 && log2_block_count_tmp != 3)
|
||||
return -1;
|
||||
log2_block_cnt[IDX_HIGH_BAND] = 3 - log2_block_count_tmp;
|
||||
|
||||
skip_bits(gb, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int at1_unpack_dequant(GetBitContext* gb, AT1SUCtx* su,
|
||||
float spec[AT1_SU_SAMPLES])
|
||||
{
|
||||
int bits_used, band_num, bfu_num, i;
|
||||
uint8_t idwls[AT1_MAX_BFU]; ///< the word length indexes for each BFU
|
||||
uint8_t idsfs[AT1_MAX_BFU]; ///< the scalefactor indexes for each BFU
|
||||
|
||||
/* parse the info byte (2nd byte) telling how much BFUs were coded */
|
||||
su->num_bfus = bfu_amount_tab1[get_bits(gb, 3)];
|
||||
|
||||
/* calc number of consumed bits:
|
||||
num_BFUs * (idwl(4bits) + idsf(6bits)) + log2_block_count(8bits) + info_byte(8bits)
|
||||
+ info_byte_copy(8bits) + log2_block_count_copy(8bits) */
|
||||
bits_used = su->num_bfus * 10 + 32 +
|
||||
bfu_amount_tab2[get_bits(gb, 2)] +
|
||||
(bfu_amount_tab3[get_bits(gb, 3)] << 1);
|
||||
|
||||
/* get word length index (idwl) for each BFU */
|
||||
for (i = 0; i < su->num_bfus; i++)
|
||||
idwls[i] = get_bits(gb, 4);
|
||||
|
||||
/* get scalefactor index (idsf) for each BFU */
|
||||
for (i = 0; i < su->num_bfus; i++)
|
||||
idsfs[i] = get_bits(gb, 6);
|
||||
|
||||
/* zero idwl/idsf for empty BFUs */
|
||||
for (i = su->num_bfus; i < AT1_MAX_BFU; i++)
|
||||
idwls[i] = idsfs[i] = 0;
|
||||
|
||||
/* read in the spectral data and reconstruct MDCT spectrum of this channel */
|
||||
for (band_num = 0; band_num < AT1_QMF_BANDS; band_num++) {
|
||||
for (bfu_num = bfu_bands_t[band_num]; bfu_num < bfu_bands_t[band_num+1]; bfu_num++) {
|
||||
int pos;
|
||||
|
||||
int num_specs = specs_per_bfu[bfu_num];
|
||||
int word_len = !!idwls[bfu_num] + idwls[bfu_num];
|
||||
float scale_factor = sf_table[idsfs[bfu_num]];
|
||||
bits_used += word_len * num_specs; /* add number of bits consumed by current BFU */
|
||||
|
||||
/* check for bitstream overflow */
|
||||
if (bits_used > AT1_SU_MAX_BITS)
|
||||
return -1;
|
||||
|
||||
/* get the position of the 1st spec according to the block size mode */
|
||||
pos = su->log2_block_count[band_num] ? bfu_start_short[bfu_num] : bfu_start_long[bfu_num];
|
||||
|
||||
if (word_len) {
|
||||
float max_quant = 1.0 / (float)((1 << (word_len - 1)) - 1);
|
||||
|
||||
for (i = 0; i < num_specs; i++) {
|
||||
/* read in a quantized spec and convert it to
|
||||
* signed int and then inverse quantization
|
||||
*/
|
||||
spec[pos+i] = get_sbits(gb, word_len) * scale_factor * max_quant;
|
||||
}
|
||||
} else { /* word_len = 0 -> empty BFU, zero all specs in the emty BFU */
|
||||
memset(&spec[pos], 0, num_specs * sizeof(float));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void at1_subband_synthesis(AT1Ctx *q, AT1SUCtx* su, float *pOut)
|
||||
{
|
||||
float temp[256];
|
||||
float iqmf_temp[512 + 46];
|
||||
|
||||
/* combine low and middle bands */
|
||||
atrac_iqmf(q->bands[0], q->bands[1], 128, temp, su->fst_qmf_delay, iqmf_temp);
|
||||
|
||||
/* delay the signal of the high band by 23 samples */
|
||||
memcpy( su->last_qmf_delay, &su->last_qmf_delay[256], sizeof(float) * 23);
|
||||
memcpy(&su->last_qmf_delay[23], q->bands[2], sizeof(float) * 256);
|
||||
|
||||
/* combine (low + middle) and high bands */
|
||||
atrac_iqmf(temp, su->last_qmf_delay, 256, pOut, su->snd_qmf_delay, iqmf_temp);
|
||||
}
|
||||
|
||||
|
||||
static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
int *data_size, AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
AT1Ctx *q = avctx->priv_data;
|
||||
int ch, ret, i;
|
||||
GetBitContext gb;
|
||||
float* samples = data;
|
||||
|
||||
|
||||
if (buf_size < 212 * q->channels) {
|
||||
av_log(q,AV_LOG_ERROR,"Not enought data to decode!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (ch = 0; ch < q->channels; ch++) {
|
||||
AT1SUCtx* su = &q->SUs[ch];
|
||||
|
||||
init_get_bits(&gb, &buf[212 * ch], 212 * 8);
|
||||
|
||||
/* parse block_size_mode, 1st byte */
|
||||
ret = at1_parse_bsm(&gb, su->log2_block_count);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = at1_unpack_dequant(&gb, su, q->spec);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = at1_imdct_block(su, q);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
at1_subband_synthesis(q, su, q->out_samples[ch]);
|
||||
}
|
||||
|
||||
/* interleave; FIXME, should create/use a DSP function */
|
||||
if (q->channels == 1) {
|
||||
/* mono */
|
||||
memcpy(samples, q->out_samples[0], AT1_SU_SAMPLES * 4);
|
||||
} else {
|
||||
/* stereo */
|
||||
for (i = 0; i < AT1_SU_SAMPLES; i++) {
|
||||
samples[i * 2] = q->out_samples[0][i];
|
||||
samples[i * 2 + 1] = q->out_samples[1][i];
|
||||
}
|
||||
}
|
||||
|
||||
*data_size = q->channels * AT1_SU_SAMPLES * sizeof(*samples);
|
||||
return avctx->block_align;
|
||||
}
|
||||
|
||||
|
||||
static av_cold int atrac1_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
AT1Ctx *q = avctx->priv_data;
|
||||
|
||||
avctx->sample_fmt = SAMPLE_FMT_FLT;
|
||||
|
||||
q->channels = avctx->channels;
|
||||
|
||||
/* Init the mdct transforms */
|
||||
ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15));
|
||||
ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15));
|
||||
ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15));
|
||||
|
||||
ff_init_ff_sine_windows(5);
|
||||
|
||||
atrac_generate_tables();
|
||||
|
||||
dsputil_init(&q->dsp, avctx);
|
||||
|
||||
q->bands[0] = q->low;
|
||||
q->bands[1] = q->mid;
|
||||
q->bands[2] = q->high;
|
||||
|
||||
/* Prepare the mdct overlap buffers */
|
||||
q->SUs[0].spectrum[0] = q->SUs[0].spec1;
|
||||
q->SUs[0].spectrum[1] = q->SUs[0].spec2;
|
||||
q->SUs[1].spectrum[0] = q->SUs[1].spec1;
|
||||
q->SUs[1].spectrum[1] = q->SUs[1].spec2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static av_cold int atrac1_decode_end(AVCodecContext * avctx) {
|
||||
AT1Ctx *q = avctx->priv_data;
|
||||
|
||||
ff_mdct_end(&q->mdct_ctx[0]);
|
||||
ff_mdct_end(&q->mdct_ctx[1]);
|
||||
ff_mdct_end(&q->mdct_ctx[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
AVCodec atrac1_decoder = {
|
||||
.name = "atrac1",
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = CODEC_ID_ATRAC1,
|
||||
.priv_data_size = sizeof(AT1Ctx),
|
||||
.init = atrac1_decode_init,
|
||||
.close = atrac1_decode_end,
|
||||
.decode = atrac1_decode_frame,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Atrac 1 (Adaptive TRansform Acoustic Coding)"),
|
||||
};
|
64
src/add-ons/media/plugins/ffmpeg/libavcodec/atrac1data.h
Normal file
64
src/add-ons/media/plugins/ffmpeg/libavcodec/atrac1data.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Atrac 1 compatible decoder data
|
||||
* Copyright (c) 2009 Maxim Poliakovski
|
||||
* Copyright (c) 2009 Benjamin Larsson
|
||||
*
|
||||
* 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
|
||||
* Atrac 1 compatible decoder data
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ATRAC1DATA_H
|
||||
#define AVCODEC_ATRAC1DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static const uint8_t bfu_amount_tab1[8] = {20, 28, 32, 36, 40, 44, 48, 52};
|
||||
static const uint8_t bfu_amount_tab2[4] = { 0, 112, 176, 208};
|
||||
static const uint8_t bfu_amount_tab3[8] = { 0, 24, 36, 48, 72, 108, 132, 156};
|
||||
|
||||
/** number of BFUs in each QMF band */
|
||||
static const uint8_t bfu_bands_t[4] = {0, 20, 36, 52};
|
||||
|
||||
/** number of spectral lines in each BFU
|
||||
* block floating unit = group of spectral frequencies having the
|
||||
* same quantization parameters like word length and scale factor
|
||||
*/
|
||||
static const uint8_t specs_per_bfu[52] = {
|
||||
8, 8, 8, 8, 4, 4, 4, 4, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 6, // low band
|
||||
6, 6, 6, 6, 7, 7, 7, 7, 9, 9, 9, 9, 10, 10, 10, 10, // midle band
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 20, 20, 20, 20, 20, 20, 20, 20 // high band
|
||||
};
|
||||
|
||||
/** start position of each BFU in the MDCT spectrum for the long mode */
|
||||
static const uint16_t bfu_start_long[52] = {
|
||||
0, 8, 16, 24, 32, 36, 40, 44, 48, 56, 64, 72, 80, 86, 92, 98, 104, 110, 116, 122,
|
||||
128, 134, 140, 146, 152, 159, 166, 173, 180, 189, 198, 207, 216, 226, 236, 246,
|
||||
256, 268, 280, 292, 304, 316, 328, 340, 352, 372, 392, 412, 432, 452, 472, 492,
|
||||
};
|
||||
|
||||
/** start position of each BFU in the MDCT spectrum for the short mode */
|
||||
static const uint16_t bfu_start_short[52] = {
|
||||
0, 32, 64, 96, 8, 40, 72, 104, 12, 44, 76, 108, 20, 52, 84, 116, 26, 58, 90, 122,
|
||||
128, 160, 192, 224, 134, 166, 198, 230, 141, 173, 205, 237, 150, 182, 214, 246,
|
||||
256, 288, 320, 352, 384, 416, 448, 480, 268, 300, 332, 364, 396, 428, 460, 492
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_ATRAC1DATA_H */
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/atrac3.c
|
||||
* @file
|
||||
* Atrac 3 compatible decoder.
|
||||
* This decoder handles Sony's ATRAC3 data.
|
||||
*
|
||||
@ -40,7 +40,9 @@
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "bytestream.h"
|
||||
#include "fft.h"
|
||||
|
||||
#include "atrac.h"
|
||||
#include "atrac3data.h"
|
||||
|
||||
#define JOINT_STEREO 0x12
|
||||
@ -72,8 +74,8 @@ typedef struct {
|
||||
int gcBlkSwitch;
|
||||
gain_block gainBlock[2];
|
||||
|
||||
DECLARE_ALIGNED_16(float, spectrum[1024]);
|
||||
DECLARE_ALIGNED_16(float, IMDCT_buf[1024]);
|
||||
DECLARE_ALIGNED(16, float, spectrum)[1024];
|
||||
DECLARE_ALIGNED(16, float, IMDCT_buf)[1024];
|
||||
|
||||
float delayBuf1[46]; ///<qmf delay buffers
|
||||
float delayBuf2[46];
|
||||
@ -118,69 +120,14 @@ typedef struct {
|
||||
//@}
|
||||
} ATRAC3Context;
|
||||
|
||||
static DECLARE_ALIGNED_16(float,mdct_window[512]);
|
||||
static float qmf_window[48];
|
||||
static DECLARE_ALIGNED(16, float,mdct_window)[512];
|
||||
static VLC spectral_coeff_tab[7];
|
||||
static float SFTable[64];
|
||||
static float gain_tab1[16];
|
||||
static float gain_tab2[31];
|
||||
static MDCTContext mdct_ctx;
|
||||
static FFTContext mdct_ctx;
|
||||
static DSPContext dsp;
|
||||
|
||||
|
||||
/* quadrature mirror synthesis filter */
|
||||
|
||||
/**
|
||||
* Quadrature mirror synthesis filter.
|
||||
*
|
||||
* @param inlo lower part of spectrum
|
||||
* @param inhi higher part of spectrum
|
||||
* @param nIn size of spectrum buffer
|
||||
* @param pOut out buffer
|
||||
* @param delayBuf delayBuf buffer
|
||||
* @param temp temp buffer
|
||||
*/
|
||||
|
||||
|
||||
static void iqmf (float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp)
|
||||
{
|
||||
int i, j;
|
||||
float *p1, *p3;
|
||||
|
||||
memcpy(temp, delayBuf, 46*sizeof(float));
|
||||
|
||||
p3 = temp + 46;
|
||||
|
||||
/* loop1 */
|
||||
for(i=0; i<nIn; i+=2){
|
||||
p3[2*i+0] = inlo[i ] + inhi[i ];
|
||||
p3[2*i+1] = inlo[i ] - inhi[i ];
|
||||
p3[2*i+2] = inlo[i+1] + inhi[i+1];
|
||||
p3[2*i+3] = inlo[i+1] - inhi[i+1];
|
||||
}
|
||||
|
||||
/* loop2 */
|
||||
p1 = temp;
|
||||
for (j = nIn; j != 0; j--) {
|
||||
float s1 = 0.0;
|
||||
float s2 = 0.0;
|
||||
|
||||
for (i = 0; i < 48; i += 2) {
|
||||
s1 += p1[i] * qmf_window[i];
|
||||
s2 += p1[i+1] * qmf_window[i+1];
|
||||
}
|
||||
|
||||
pOut[0] = s2;
|
||||
pOut[1] = s1;
|
||||
|
||||
p1 += 2;
|
||||
pOut += 2;
|
||||
}
|
||||
|
||||
/* Update the delay buffer. */
|
||||
memcpy(delayBuf, temp + nIn*2, 46*sizeof(float));
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular 512 points IMDCT without overlapping, with the exception of the swapping of odd bands
|
||||
* caused by the reverse spectra of the QMF.
|
||||
@ -246,7 +193,6 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){
|
||||
|
||||
static av_cold void init_atrac3_transforms(ATRAC3Context *q) {
|
||||
float enc_window[256];
|
||||
float s;
|
||||
int i;
|
||||
|
||||
/* Generate the mdct window, for details see
|
||||
@ -260,13 +206,6 @@ static av_cold void init_atrac3_transforms(ATRAC3Context *q) {
|
||||
mdct_window[511-i] = mdct_window[i];
|
||||
}
|
||||
|
||||
/* Generate the QMF window. */
|
||||
for (i=0 ; i<24; i++) {
|
||||
s = qmf_48tap_half[i] * 2.0;
|
||||
qmf_window[i] = s;
|
||||
qmf_window[47 - i] = s;
|
||||
}
|
||||
|
||||
/* Initialize the MDCT transform. */
|
||||
ff_mdct_init(&mdct_ctx, 9, 1, 1.0);
|
||||
}
|
||||
@ -386,7 +325,7 @@ static int decodeSpectrum (GetBitContext *gb, float *pOut)
|
||||
readQuantSpectralCoeffs (gb, subband_vlc_index[cnt], codingMode, mantissas, subbWidth);
|
||||
|
||||
/* Decode the scale factor for this subband. */
|
||||
SF = SFTable[SF_idxs[cnt]] * iMaxQuant[subband_vlc_index[cnt]];
|
||||
SF = sf_table[SF_idxs[cnt]] * iMaxQuant[subband_vlc_index[cnt]];
|
||||
|
||||
/* Inverse quantize the coefficients. */
|
||||
for (pIn=mantissas ; first<last; first++, pIn++)
|
||||
@ -459,7 +398,7 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
|
||||
coded_values = coded_values_per_component + 1;
|
||||
coded_values = FFMIN(max_coded_values,coded_values);
|
||||
|
||||
scalefactor = SFTable[sfIndx] * iMaxQuant[quant_step_index];
|
||||
scalefactor = sf_table[sfIndx] * iMaxQuant[quant_step_index];
|
||||
|
||||
readQuantSpectralCoeffs(gb, quant_step_index, coding_mode, mantissa, coded_values);
|
||||
|
||||
@ -860,9 +799,9 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
|
||||
p2= p1+256;
|
||||
p3= p2+256;
|
||||
p4= p3+256;
|
||||
iqmf (p1, p2, 256, p1, q->pUnits[i].delayBuf1, q->tempBuf);
|
||||
iqmf (p4, p3, 256, p3, q->pUnits[i].delayBuf2, q->tempBuf);
|
||||
iqmf (p1, p3, 512, p1, q->pUnits[i].delayBuf3, q->tempBuf);
|
||||
atrac_iqmf (p1, p2, 256, p1, q->pUnits[i].delayBuf1, q->tempBuf);
|
||||
atrac_iqmf (p4, p3, 256, p3, q->pUnits[i].delayBuf2, q->tempBuf);
|
||||
atrac_iqmf (p1, p3, 512, p1, q->pUnits[i].delayBuf3, q->tempBuf);
|
||||
p1 +=1024;
|
||||
}
|
||||
|
||||
@ -1038,9 +977,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
|
||||
|
||||
init_atrac3_transforms(q);
|
||||
|
||||
/* Generate the scale factors. */
|
||||
for (i=0 ; i<64 ; i++)
|
||||
SFTable[i] = pow(2.0, (i - 15) / 3.0);
|
||||
atrac_generate_tables();
|
||||
|
||||
/* Generate gain tables. */
|
||||
for (i=0 ; i<16 ; i++)
|
||||
@ -1079,7 +1016,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
|
||||
AVCodec atrac3_decoder =
|
||||
{
|
||||
.name = "atrac3",
|
||||
.type = CODEC_TYPE_AUDIO,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = CODEC_ID_ATRAC3,
|
||||
.priv_data_size = sizeof(ATRAC3Context),
|
||||
.init = atrac3_decode_init,
|
||||
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/atrac3data.h
|
||||
* @file
|
||||
* Atrac 3 AKA RealAudio 8 compatible decoder data
|
||||
*/
|
||||
|
||||
@ -127,17 +127,6 @@ static const uint16_t subbandTab[33] = {
|
||||
256, 288, 320, 352, 384, 416, 448, 480, 512, 576, 640, 704, 768, 896, 1024
|
||||
};
|
||||
|
||||
/* transform data */
|
||||
|
||||
static const float qmf_48tap_half[24] = {
|
||||
-0.00001461907, -0.00009205479, -0.000056157569, 0.00030117269,
|
||||
0.0002422519,-0.00085293897, -0.0005205574, 0.0020340169,
|
||||
0.00078333891, -0.0042153862, -0.00075614988, 0.0078402944,
|
||||
-0.000061169922, -0.01344162, 0.0024626821, 0.021736089,
|
||||
-0.007801671, -0.034090221, 0.01880949, 0.054326009,
|
||||
-0.043596379, -0.099384367, 0.13207909, 0.46424159
|
||||
};
|
||||
|
||||
/* joint stereo related tables */
|
||||
static const float matrixCoeffs[8] = {0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0};
|
||||
|
||||
|
@ -20,12 +20,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/audioconvert.c
|
||||
* @file
|
||||
* audio conversion
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#include "libavutil/avstring.h"
|
||||
#include "libavutil/libm.h"
|
||||
#include "avcodec.h"
|
||||
#include "audioconvert.h"
|
||||
|
||||
@ -79,7 +80,7 @@ static const char* const channel_names[]={
|
||||
[30] = "DR",
|
||||
};
|
||||
|
||||
const char *get_channel_name(int channel_id)
|
||||
static const char *get_channel_name(int channel_id)
|
||||
{
|
||||
if (channel_id<0 || channel_id>=FF_ARRAY_ELEMS(channel_names))
|
||||
return NULL;
|
||||
@ -209,7 +210,7 @@ if(ctx->fmt_pair == ofmt + SAMPLE_FMT_NB*ifmt){\
|
||||
}
|
||||
|
||||
//FIXME put things below under ifdefs so we do not waste space for cases no codec will need
|
||||
//FIXME rounding and clipping ?
|
||||
//FIXME rounding ?
|
||||
|
||||
CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_U8 , *(const uint8_t*)pi)
|
||||
else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<8)
|
||||
@ -226,14 +227,14 @@ if(ctx->fmt_pair == ofmt + SAMPLE_FMT_NB*ifmt){\
|
||||
else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S32, *(const int32_t*)pi)
|
||||
else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31)))
|
||||
else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31)))
|
||||
else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<7)) + 0x80)
|
||||
else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<15)))
|
||||
else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<31)))
|
||||
else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT, av_clip_uint8( lrintf(*(const float*)pi * (1<<7)) + 0x80))
|
||||
else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT, av_clip_int16( lrintf(*(const float*)pi * (1<<15))))
|
||||
else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float*)pi * (1U<<31))))
|
||||
else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_FLT, *(const float*)pi)
|
||||
else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_FLT, *(const float*)pi)
|
||||
else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_DBL, lrint(*(const double*)pi * (1<<7)) + 0x80)
|
||||
else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_DBL, lrint(*(const double*)pi * (1<<15)))
|
||||
else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_DBL, lrint(*(const double*)pi * (1<<31)))
|
||||
else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_DBL, av_clip_uint8( lrint(*(const double*)pi * (1<<7)) + 0x80))
|
||||
else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_DBL, av_clip_int16( lrint(*(const double*)pi * (1<<15))))
|
||||
else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double*)pi * (1U<<31))))
|
||||
else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_DBL, *(const double*)pi)
|
||||
else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_DBL, *(const double*)pi)
|
||||
else return -1;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define AVCODEC_AUDIOCONVERT_H
|
||||
|
||||
/**
|
||||
* @file libavcodec/audioconvert.h
|
||||
* @file
|
||||
* Audio format conversion routines
|
||||
*/
|
||||
|
||||
@ -103,9 +103,9 @@ void av_audio_convert_free(AVAudioConvert *ctx);
|
||||
/**
|
||||
* Convert between audio sample formats
|
||||
* @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
|
||||
* @param[in] out_stride distance between consecutive input samples (measured in bytes)
|
||||
* @param[in] out_stride distance between consecutive output samples (measured in bytes)
|
||||
* @param[in] in array of input buffers for each channel
|
||||
* @param[in] in_stride distance between consecutive output samples (measured in bytes)
|
||||
* @param[in] in_stride distance between consecutive input samples (measured in bytes)
|
||||
* @param len length of audio frame size (measured in samples)
|
||||
*/
|
||||
int av_audio_convert(AVAudioConvert *ctx,
|
||||
|
138
src/add-ons/media/plugins/ffmpeg/libavcodec/aura.c
Normal file
138
src/add-ons/media/plugins/ffmpeg/libavcodec/aura.c
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Aura 2 decoder
|
||||
*
|
||||
* 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
|
||||
* Aura 2 decoder
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
typedef struct AuraDecodeContext {
|
||||
AVCodecContext *avctx;
|
||||
AVFrame frame;
|
||||
} AuraDecodeContext;
|
||||
|
||||
static av_cold int aura_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
AuraDecodeContext *s = avctx->priv_data;
|
||||
|
||||
s->avctx = avctx;
|
||||
/* width needs to be divisible by 4 for this codec to work */
|
||||
if (avctx->width & 0x3)
|
||||
return -1;
|
||||
avctx->pix_fmt = PIX_FMT_YUV422P;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int aura_decode_frame(AVCodecContext *avctx,
|
||||
void *data, int *data_size,
|
||||
AVPacket *pkt)
|
||||
{
|
||||
AuraDecodeContext *s=avctx->priv_data;
|
||||
|
||||
uint8_t *Y, *U, *V;
|
||||
uint8_t val;
|
||||
int x, y;
|
||||
const uint8_t *buf = pkt->data;
|
||||
|
||||
/* prediction error tables (make it clear that they are signed values) */
|
||||
const int8_t *delta_table = (const int8_t*)buf + 16;
|
||||
|
||||
if (pkt->size != 48 + avctx->height * avctx->width) {
|
||||
av_log(avctx, AV_LOG_ERROR, "got a buffer with %d bytes when %d were expected\n",
|
||||
pkt->size, 48 + avctx->height * avctx->width);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* pixel data starts 48 bytes in, after 3x16-byte tables */
|
||||
buf += 48;
|
||||
|
||||
if(s->frame.data[0])
|
||||
avctx->release_buffer(avctx, &s->frame);
|
||||
|
||||
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
|
||||
s->frame.reference = 0;
|
||||
if(avctx->get_buffer(avctx, &s->frame) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Y = s->frame.data[0];
|
||||
U = s->frame.data[1];
|
||||
V = s->frame.data[2];
|
||||
|
||||
/* iterate through each line in the height */
|
||||
for (y = 0; y < avctx->height; y++) {
|
||||
/* reset predictors */
|
||||
val = *buf++;
|
||||
U[0] = val & 0xF0;
|
||||
Y[0] = val << 4;
|
||||
val = *buf++;
|
||||
V[0] = val & 0xF0;
|
||||
Y[1] = Y[0] + delta_table[val & 0xF];
|
||||
Y += 2; U++; V++;
|
||||
|
||||
/* iterate through the remaining pixel groups (4 pixels/group) */
|
||||
for (x = 1; x < (avctx->width >> 1); x++) {
|
||||
val = *buf++;
|
||||
U[0] = U[-1] + delta_table[val >> 4];
|
||||
Y[0] = Y[-1] + delta_table[val & 0xF];
|
||||
val = *buf++;
|
||||
V[0] = V[-1] + delta_table[val >> 4];
|
||||
Y[1] = Y[ 0] + delta_table[val & 0xF];
|
||||
Y += 2; U++; V++;
|
||||
}
|
||||
Y += s->frame.linesize[0] - avctx->width;
|
||||
U += s->frame.linesize[1] - (avctx->width >> 1);
|
||||
V += s->frame.linesize[2] - (avctx->width >> 1);
|
||||
}
|
||||
|
||||
*data_size=sizeof(AVFrame);
|
||||
*(AVFrame*)data= s->frame;
|
||||
|
||||
return pkt->size;
|
||||
}
|
||||
|
||||
static av_cold int aura_decode_end(AVCodecContext *avctx)
|
||||
{
|
||||
AuraDecodeContext *s = avctx->priv_data;
|
||||
|
||||
if (s->frame.data[0])
|
||||
avctx->release_buffer(avctx, &s->frame);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVCodec aura2_decoder = {
|
||||
"aura2",
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_AURA2,
|
||||
sizeof(AuraDecodeContext),
|
||||
aura_decode_init,
|
||||
NULL,
|
||||
aura_decode_end,
|
||||
aura_decode_frame,
|
||||
CODEC_CAP_DR1,
|
||||
NULL,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Auravision Aura 2"),
|
||||
};
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define AVCODEC_AVCODEC_H
|
||||
|
||||
/**
|
||||
* @file libavcodec/avcodec.h
|
||||
* @file
|
||||
* external API header
|
||||
*/
|
||||
|
||||
@ -30,8 +30,8 @@
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 52
|
||||
#define LIBAVCODEC_VERSION_MINOR 32
|
||||
#define LIBAVCODEC_VERSION_MICRO 0
|
||||
#define LIBAVCODEC_VERSION_MINOR 72
|
||||
#define LIBAVCODEC_VERSION_MICRO 2
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
@ -125,7 +125,9 @@ enum CodecID {
|
||||
CODEC_ID_QDRAW,
|
||||
CODEC_ID_VIXL,
|
||||
CODEC_ID_QPEG,
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
CODEC_ID_XVID,
|
||||
#endif
|
||||
CODEC_ID_PNG,
|
||||
CODEC_ID_PPM,
|
||||
CODEC_ID_PBM,
|
||||
@ -198,6 +200,17 @@ enum CodecID {
|
||||
CODEC_ID_V210,
|
||||
CODEC_ID_DPX,
|
||||
CODEC_ID_MAD,
|
||||
CODEC_ID_FRWU,
|
||||
CODEC_ID_FLASHSV2,
|
||||
CODEC_ID_CDGRAPHICS,
|
||||
CODEC_ID_R210,
|
||||
CODEC_ID_ANM,
|
||||
CODEC_ID_BINKVIDEO,
|
||||
CODEC_ID_IFF_ILBM,
|
||||
CODEC_ID_IFF_BYTERUN1,
|
||||
CODEC_ID_KGV1,
|
||||
CODEC_ID_YOP,
|
||||
CODEC_ID_VP8,
|
||||
|
||||
/* various PCM "codecs" */
|
||||
CODEC_ID_PCM_S16LE= 0x10000,
|
||||
@ -224,6 +237,7 @@ enum CodecID {
|
||||
CODEC_ID_PCM_F32LE,
|
||||
CODEC_ID_PCM_F64BE,
|
||||
CODEC_ID_PCM_F64LE,
|
||||
CODEC_ID_PCM_BLURAY,
|
||||
|
||||
/* various ADPCM codecs */
|
||||
CODEC_ID_ADPCM_IMA_QT= 0x11000,
|
||||
@ -319,6 +333,9 @@ enum CodecID {
|
||||
CODEC_ID_TWINVQ,
|
||||
CODEC_ID_TRUEHD,
|
||||
CODEC_ID_MP4ALS,
|
||||
CODEC_ID_ATRAC1,
|
||||
CODEC_ID_BINKAUDIO_RDFT,
|
||||
CODEC_ID_BINKAUDIO_DCT,
|
||||
|
||||
/* subtitle codecs */
|
||||
CODEC_ID_DVD_SUBTITLE= 0x17000,
|
||||
@ -327,6 +344,8 @@ enum CodecID {
|
||||
CODEC_ID_XSUB,
|
||||
CODEC_ID_SSA,
|
||||
CODEC_ID_MOV_TEXT,
|
||||
CODEC_ID_HDMV_PGS_SUBTITLE,
|
||||
CODEC_ID_DVB_TELETEXT,
|
||||
|
||||
/* other specific kind of codecs (generally used for attachments) */
|
||||
CODEC_ID_TTF= 0x18000,
|
||||
@ -337,15 +356,17 @@ enum CodecID {
|
||||
* stream (only used by libavformat) */
|
||||
};
|
||||
|
||||
enum CodecType {
|
||||
CODEC_TYPE_UNKNOWN = -1,
|
||||
CODEC_TYPE_VIDEO,
|
||||
CODEC_TYPE_AUDIO,
|
||||
CODEC_TYPE_DATA,
|
||||
CODEC_TYPE_SUBTITLE,
|
||||
CODEC_TYPE_ATTACHMENT,
|
||||
CODEC_TYPE_NB
|
||||
};
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
#define CodecType AVMediaType
|
||||
|
||||
#define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN
|
||||
#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
|
||||
#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
|
||||
#define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA
|
||||
#define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE
|
||||
#define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT
|
||||
#define CODEC_TYPE_NB AVMEDIA_TYPE_NB
|
||||
#endif
|
||||
|
||||
/**
|
||||
* all in native-endian format
|
||||
@ -382,6 +403,11 @@ enum SampleFormat {
|
||||
#define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
|
||||
#define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT.
|
||||
|
||||
/** Channel mask value used for AVCodecContext.request_channel_layout
|
||||
to indicate that the user requests the channel order of the decoder output
|
||||
to be the native codec channel order. */
|
||||
#define CH_LAYOUT_NATIVE 0x8000000000000000LL
|
||||
|
||||
/* Audio channel convenience macros */
|
||||
#define CH_LAYOUT_MONO (CH_FRONT_CENTER)
|
||||
#define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT)
|
||||
@ -394,6 +420,7 @@ enum SampleFormat {
|
||||
#define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY)
|
||||
#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
|
||||
#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
|
||||
#define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT)
|
||||
#define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT)
|
||||
#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
|
||||
CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
|
||||
@ -568,6 +595,9 @@ typedef struct RcOverride{
|
||||
#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
|
||||
#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
|
||||
#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
|
||||
#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
|
||||
#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations.
|
||||
#define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined.
|
||||
|
||||
/* Unsupported options :
|
||||
* Syntax Arithmetic coding (SAC)
|
||||
@ -578,8 +608,9 @@ typedef struct RcOverride{
|
||||
|
||||
#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
|
||||
/**
|
||||
* Codec uses get_buffer() for allocating buffers.
|
||||
* direct rendering method 1
|
||||
* Codec uses get_buffer() for allocating buffers and supports custom allocators.
|
||||
* If not set, it might not use get_buffer() at all or use operations that
|
||||
* assume the buffer was allocated by avcodec_default_get_buffer.
|
||||
*/
|
||||
#define CODEC_CAP_DR1 0x0002
|
||||
/* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */
|
||||
@ -601,6 +632,23 @@ typedef struct RcOverride{
|
||||
* Codec can export data for HW decoding (VDPAU).
|
||||
*/
|
||||
#define CODEC_CAP_HWACCEL_VDPAU 0x0080
|
||||
/**
|
||||
* Codec can output multiple frames per AVPacket
|
||||
* Normally demuxers return one frame at a time, demuxers which do not do
|
||||
* are connected to a parser to split what they return into proper frames.
|
||||
* This flag is reserved to the very rare category of codecs which have a
|
||||
* bitstream that cannot be split into frames without timeconsuming
|
||||
* operations like full decoding. Demuxers carring such bitstreams thus
|
||||
* may return multiple frames in a packet. This has many disadvantages like
|
||||
* prohibiting stream copy in many cases thus it should only be considered
|
||||
* as a last resort.
|
||||
*/
|
||||
#define CODEC_CAP_SUBFRAMES 0x0100
|
||||
/**
|
||||
* Codec is experimental and is thus avoided in favor of non experimental
|
||||
* encoders
|
||||
*/
|
||||
#define CODEC_CAP_EXPERIMENTAL 0x0200
|
||||
|
||||
//The following defines may change, don't expect compatibility if you use them.
|
||||
#define MB_TYPE_INTRA4x4 0x0001
|
||||
@ -860,7 +908,8 @@ typedef struct AVPanScan{
|
||||
short *dct_coeff;\
|
||||
\
|
||||
/**\
|
||||
* motion referece frame index\
|
||||
* motion reference frame index\
|
||||
* the order in which these are stored can depend on the codec.\
|
||||
* - encoding: Set by user.\
|
||||
* - decoding: Set by libavcodec.\
|
||||
*/\
|
||||
@ -885,6 +934,7 @@ typedef struct AVPanScan{
|
||||
#define FF_QSCALE_TYPE_MPEG1 0
|
||||
#define FF_QSCALE_TYPE_MPEG2 1
|
||||
#define FF_QSCALE_TYPE_H264 2
|
||||
#define FF_QSCALE_TYPE_VP56 3
|
||||
|
||||
#define FF_BUFFER_TYPE_INTERNAL 1
|
||||
#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
|
||||
@ -1235,7 +1285,7 @@ typedef struct AVCodecContext {
|
||||
void *opaque;
|
||||
|
||||
char codec_name[32];
|
||||
enum CodecType codec_type; /* see CODEC_TYPE_xxx */
|
||||
enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
|
||||
enum CodecID codec_id; /* see CODEC_ID_xxx */
|
||||
|
||||
/**
|
||||
@ -1274,6 +1324,7 @@ typedef struct AVCodecContext {
|
||||
#define FF_BUG_HPEL_CHROMA 2048
|
||||
#define FF_BUG_DC_CLIP 4096
|
||||
#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
|
||||
#define FF_BUG_TRUNCATED 16384
|
||||
//#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%.
|
||||
|
||||
/**
|
||||
@ -1331,7 +1382,7 @@ typedef struct AVCodecContext {
|
||||
/**
|
||||
* Called at the beginning of each frame to get a buffer for it.
|
||||
* If pic.reference is set then the frame will be read later by libavcodec.
|
||||
* avcodec_align_dimensions() should be used to find the required width and
|
||||
* avcodec_align_dimensions2() should be used to find the required width and
|
||||
* height, as they normally need to be rounded up to the next multiple of 16.
|
||||
* if CODEC_CAP_DR1 is not set then get_buffer() must call
|
||||
* avcodec_default_get_buffer() instead of providing buffers allocated by
|
||||
@ -1540,6 +1591,7 @@ typedef struct AVCodecContext {
|
||||
#define FF_IDCT_EA 21
|
||||
#define FF_IDCT_SIMPLENEON 22
|
||||
#define FF_IDCT_SIMPLEALPHA 23
|
||||
#define FF_IDCT_BINK 24
|
||||
|
||||
/**
|
||||
* slice count
|
||||
@ -2095,11 +2147,21 @@ typedef struct AVCodecContext {
|
||||
*/
|
||||
int profile;
|
||||
#define FF_PROFILE_UNKNOWN -99
|
||||
|
||||
#define FF_PROFILE_AAC_MAIN 0
|
||||
#define FF_PROFILE_AAC_LOW 1
|
||||
#define FF_PROFILE_AAC_SSR 2
|
||||
#define FF_PROFILE_AAC_LTP 3
|
||||
|
||||
#define FF_PROFILE_H264_BASELINE 66
|
||||
#define FF_PROFILE_H264_MAIN 77
|
||||
#define FF_PROFILE_H264_EXTENDED 88
|
||||
#define FF_PROFILE_H264_HIGH 100
|
||||
#define FF_PROFILE_H264_HIGH_10 110
|
||||
#define FF_PROFILE_H264_HIGH_422 122
|
||||
#define FF_PROFILE_H264_HIGH_444 244
|
||||
#define FF_PROFILE_H264_CAVLC_444 44
|
||||
|
||||
/**
|
||||
* level
|
||||
* - encoding: Set by user.
|
||||
@ -2517,7 +2579,79 @@ typedef struct AVCodecContext {
|
||||
* - encoding: Set by user
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
enum AVChromaLocation chroma_sample_location;
|
||||
enum AVChromaLocation chroma_sample_location;
|
||||
|
||||
/**
|
||||
* The codec may call this to execute several independent things.
|
||||
* It will return only after finishing all tasks.
|
||||
* The user may replace this with some multithreaded implementation,
|
||||
* the default implementation will execute the parts serially.
|
||||
* Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
|
||||
* @param c context passed also to func
|
||||
* @param count the number of things to execute
|
||||
* @param arg2 argument passed unchanged to func
|
||||
* @param ret return values of executed functions, must have space for "count" values. May be NULL.
|
||||
* @param func function that will be called count times, with jobnr from 0 to count-1.
|
||||
* threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
|
||||
* two instances of func executing at the same time will have the same threadnr.
|
||||
* @return always 0 currently, but code should handle a future improvement where when any call to func
|
||||
* returns < 0 no further calls to func may be done and < 0 is returned.
|
||||
* - encoding: Set by libavcodec, user can override.
|
||||
* - decoding: Set by libavcodec, user can override.
|
||||
*/
|
||||
int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
|
||||
|
||||
/**
|
||||
* explicit P-frame weighted prediction analysis method
|
||||
* 0: off
|
||||
* 1: fast blind weighting (one reference duplicate with -1 offset)
|
||||
* 2: smart weighting (full fade detection analysis)
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
int weighted_p_pred;
|
||||
|
||||
/**
|
||||
* AQ mode
|
||||
* 0: Disabled
|
||||
* 1: Variance AQ (complexity mask)
|
||||
* 2: Auto-variance AQ (experimental)
|
||||
* - encoding: Set by user
|
||||
* - decoding: unused
|
||||
*/
|
||||
int aq_mode;
|
||||
|
||||
/**
|
||||
* AQ strength
|
||||
* Reduces blocking and blurring in flat and textured areas.
|
||||
* - encoding: Set by user
|
||||
* - decoding: unused
|
||||
*/
|
||||
float aq_strength;
|
||||
|
||||
/**
|
||||
* PSY RD
|
||||
* Strength of psychovisual optimization
|
||||
* - encoding: Set by user
|
||||
* - decoding: unused
|
||||
*/
|
||||
float psy_rd;
|
||||
|
||||
/**
|
||||
* PSY trellis
|
||||
* Strength of psychovisual optimization
|
||||
* - encoding: Set by user
|
||||
* - decoding: unused
|
||||
*/
|
||||
float psy_trellis;
|
||||
|
||||
/**
|
||||
* RC lookahead
|
||||
* Number of frames for frametype and ratecontrol lookahead
|
||||
* - encoding: Set by user
|
||||
* - decoding: unused
|
||||
*/
|
||||
int rc_lookahead;
|
||||
} AVCodecContext;
|
||||
|
||||
/**
|
||||
@ -2531,7 +2665,7 @@ typedef struct AVCodec {
|
||||
* This is the primary way to find a codec from the user perspective.
|
||||
*/
|
||||
const char *name;
|
||||
enum CodecType type;
|
||||
enum AVMediaType type;
|
||||
enum CodecID id;
|
||||
int priv_data_size;
|
||||
int (*init)(AVCodecContext *);
|
||||
@ -2575,9 +2709,9 @@ typedef struct AVHWAccel {
|
||||
/**
|
||||
* Type of codec implemented by the hardware accelerator.
|
||||
*
|
||||
* See CODEC_TYPE_xxx
|
||||
* See AVMEDIA_TYPE_xxx
|
||||
*/
|
||||
enum CodecType type;
|
||||
enum AVMediaType type;
|
||||
|
||||
/**
|
||||
* Codec implemented by the hardware accelerator.
|
||||
@ -2923,6 +3057,7 @@ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *
|
||||
const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
|
||||
void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
* Returns the pixel format corresponding to the name name.
|
||||
*
|
||||
@ -2933,9 +3068,18 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
|
||||
* then for "gray16le".
|
||||
*
|
||||
* Finally if no pixel format has been found, returns PIX_FMT_NONE.
|
||||
*
|
||||
* @deprecated Deprecated in favor of av_get_pix_fmt().
|
||||
*/
|
||||
enum PixelFormat avcodec_get_pix_fmt(const char* name);
|
||||
unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
|
||||
attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns a value representing the fourCC code associated to the
|
||||
* pixel format pix_fmt, or 0 if no associated fourCC code can be
|
||||
* found.
|
||||
*/
|
||||
unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
|
||||
|
||||
#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
|
||||
#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
|
||||
@ -3031,6 +3175,16 @@ AVCodec *av_codec_next(AVCodec *c);
|
||||
*/
|
||||
unsigned avcodec_version(void);
|
||||
|
||||
/**
|
||||
* Returns the libavcodec build-time configuration.
|
||||
*/
|
||||
const char *avcodec_configuration(void);
|
||||
|
||||
/**
|
||||
* Returns the libavcodec license.
|
||||
*/
|
||||
const char *avcodec_license(void);
|
||||
|
||||
/**
|
||||
* Initializes libavcodec.
|
||||
*
|
||||
@ -3095,7 +3249,7 @@ void avcodec_get_context_defaults(AVCodecContext *s);
|
||||
|
||||
/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
|
||||
* we WILL change its arguments and name a few times! */
|
||||
void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType);
|
||||
void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
|
||||
|
||||
/**
|
||||
* Allocates an AVCodecContext and sets its fields to default values. The
|
||||
@ -3108,7 +3262,20 @@ AVCodecContext *avcodec_alloc_context(void);
|
||||
|
||||
/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
|
||||
* we WILL change its arguments and name a few times! */
|
||||
AVCodecContext *avcodec_alloc_context2(enum CodecType);
|
||||
AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
|
||||
|
||||
/**
|
||||
* Copy the settings of the source AVCodecContext into the destination
|
||||
* AVCodecContext. The resulting destination codec context will be
|
||||
* unopened, i.e. you are required to call avcodec_open() before you
|
||||
* can use this AVCodecContext to decode/encode video/audio data.
|
||||
*
|
||||
* @param dest target codec context, should be initialized with
|
||||
* avcodec_alloc_context(), but otherwise uninitialized
|
||||
* @param src source codec context
|
||||
* @return AVERROR() on error (e.g. memory allocation error), 0 on success
|
||||
*/
|
||||
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
|
||||
|
||||
/**
|
||||
* Sets the fields of the given AVFrame to default values.
|
||||
@ -3129,7 +3296,36 @@ AVFrame *avcodec_alloc_frame(void);
|
||||
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
|
||||
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
|
||||
int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
|
||||
|
||||
/**
|
||||
* Returns the amount of padding in pixels which the get_buffer callback must
|
||||
* provide around the edge of the image for codecs which do not have the
|
||||
* CODEC_FLAG_EMU_EDGE flag.
|
||||
*
|
||||
* @return Required padding in pixels.
|
||||
*/
|
||||
unsigned avcodec_get_edge_width(void);
|
||||
/**
|
||||
* Modifies width and height values so that they will result in a memory
|
||||
* buffer that is acceptable for the codec if you do not use any horizontal
|
||||
* padding.
|
||||
*
|
||||
* May only be used if a codec with CODEC_CAP_DR1 has been opened.
|
||||
* If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
|
||||
* according to avcodec_get_edge_width() before.
|
||||
*/
|
||||
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
|
||||
/**
|
||||
* Modifies width and height values so that they will result in a memory
|
||||
* buffer that is acceptable for the codec if you also ensure that all
|
||||
* line sizes are a multiple of the respective linesize_align[i].
|
||||
*
|
||||
* May only be used if a codec with CODEC_CAP_DR1 has been opened.
|
||||
* If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
|
||||
* according to avcodec_get_edge_width() before.
|
||||
*/
|
||||
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
int linesize_align[4]);
|
||||
|
||||
/**
|
||||
* Checks if the given dimension of a picture is valid, meaning that all
|
||||
@ -3144,8 +3340,8 @@ enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum
|
||||
|
||||
int avcodec_thread_init(AVCodecContext *s, int thread_count);
|
||||
void avcodec_thread_free(AVCodecContext *s);
|
||||
int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
|
||||
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
|
||||
int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
|
||||
//FIXME func typedef
|
||||
|
||||
/**
|
||||
@ -3199,9 +3395,11 @@ attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *s
|
||||
/**
|
||||
* Decodes the audio frame of size avpkt->size from avpkt->data into samples.
|
||||
* Some decoders may support multiple frames in a single AVPacket, such
|
||||
* decoders would then just decode the first frame.
|
||||
* decoders would then just decode the first frame. In this case,
|
||||
* avcodec_decode_audio3 has to be called again with an AVPacket that contains
|
||||
* the remaining data in order to decode the second frame etc.
|
||||
* If no frame
|
||||
* could be decompressed, frame_size_ptr is zero. Otherwise, it is the
|
||||
* could be outputted, frame_size_ptr is zero. Otherwise, it is the
|
||||
* decompressed frame size in bytes.
|
||||
*
|
||||
* @warning You must set frame_size_ptr to the allocated size of the
|
||||
@ -3231,7 +3429,7 @@ attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *s
|
||||
* data and size, some decoders might in addition need other fields.
|
||||
* All decoders are designed to use the least fields possible though.
|
||||
* @return On error a negative value is returned, otherwise the number of bytes
|
||||
* used or zero if no frame could be decompressed.
|
||||
* used or zero if no frame data was decompressed (used) from the input AVPacket.
|
||||
*/
|
||||
int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
|
||||
int *frame_size_ptr,
|
||||
@ -3276,14 +3474,16 @@ attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *pi
|
||||
* In practice, avpkt->data should have 4 byte alignment at minimum.
|
||||
*
|
||||
* @note Some codecs have a delay between input and output, these need to be
|
||||
* feeded with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
|
||||
* fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
|
||||
*
|
||||
* @param avctx the codec context
|
||||
* @param[out] picture The AVFrame in which the decoded video frame will be stored.
|
||||
* Use avcodec_alloc_frame to get an AVFrame, the codec will
|
||||
* allocate memory for the actual bitmap.
|
||||
* @param[in] avpkt The input AVpacket containing the input buffer.
|
||||
* You can create such packet with av_init_packet() and by then setting
|
||||
* data and size, some decoders might in addition need other fields like
|
||||
* flags&PKT_FLAG_KEY. All decoders are designed to use the least
|
||||
* flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
|
||||
* fields possible.
|
||||
* @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
|
||||
* @return On error a negative value is returned, otherwise the number of bytes
|
||||
@ -3670,6 +3870,13 @@ int av_picture_crop(AVPicture *dst, const AVPicture *src,
|
||||
int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt,
|
||||
int padtop, int padbottom, int padleft, int padright, int *color);
|
||||
|
||||
/**
|
||||
* Encodes extradata length to a buffer. Used by xiph codecs.
|
||||
*
|
||||
* @param s buffer to write to; must be at least (v/255+1) bytes long
|
||||
* @param v size of extradata in bytes
|
||||
* @return number of bytes written to the buffer.
|
||||
*/
|
||||
unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
|
||||
|
||||
/**
|
||||
@ -3696,26 +3903,6 @@ int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
|
||||
*/
|
||||
int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
|
||||
|
||||
/* error handling */
|
||||
#if EINVAL > 0
|
||||
#define AVERROR(e) (-(e)) /**< Returns a negative error code from a POSIX error code, to return from library functions. */
|
||||
#define AVUNERROR(e) (-(e)) /**< Returns a POSIX error code from a library function error return value. */
|
||||
#else
|
||||
/* Some platforms have E* and errno already negated. */
|
||||
#define AVERROR(e) (e)
|
||||
#define AVUNERROR(e) (e)
|
||||
#endif
|
||||
#define AVERROR_UNKNOWN AVERROR(EINVAL) /**< unknown error */
|
||||
#define AVERROR_IO AVERROR(EIO) /**< I/O error */
|
||||
#define AVERROR_NUMEXPECTED AVERROR(EDOM) /**< Number syntax expected in filename. */
|
||||
#define AVERROR_INVALIDDATA AVERROR(EINVAL) /**< invalid data found */
|
||||
#define AVERROR_NOMEM AVERROR(ENOMEM) /**< not enough memory */
|
||||
#define AVERROR_NOFMT AVERROR(EILSEQ) /**< unknown format */
|
||||
#define AVERROR_NOTSUPP AVERROR(ENOSYS) /**< Operation not supported. */
|
||||
#define AVERROR_NOENT AVERROR(ENOENT) /**< No such file or directory. */
|
||||
#define AVERROR_EOF AVERROR(EPIPE) /**< End of file. */
|
||||
#define AVERROR_PATCHWELCOME -MKTAG('P','A','W','E') /**< Not yet implemented in FFmpeg. Patches welcome. */
|
||||
|
||||
/**
|
||||
* Logs a generic warning message about a missing feature. This function is
|
||||
* intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
|
||||
|
142
src/add-ons/media/plugins/ffmpeg/libavcodec/avfft.c
Normal file
142
src/add-ons/media/plugins/ffmpeg/libavcodec/avfft.c
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "libavutil/mem.h"
|
||||
#include "avfft.h"
|
||||
#include "fft.h"
|
||||
|
||||
/* FFT */
|
||||
|
||||
FFTContext *av_fft_init(int nbits, int inverse)
|
||||
{
|
||||
FFTContext *s = av_malloc(sizeof(*s));
|
||||
|
||||
if (s)
|
||||
ff_fft_init(s, nbits, inverse);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void av_fft_permute(FFTContext *s, FFTComplex *z)
|
||||
{
|
||||
s->fft_permute(s, z);
|
||||
}
|
||||
|
||||
void av_fft_calc(FFTContext *s, FFTComplex *z)
|
||||
{
|
||||
s->fft_calc(s, z);
|
||||
}
|
||||
|
||||
void av_fft_end(FFTContext *s)
|
||||
{
|
||||
if (s) {
|
||||
ff_fft_end(s);
|
||||
av_free(s);
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_MDCT
|
||||
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale)
|
||||
{
|
||||
FFTContext *s = av_malloc(sizeof(*s));
|
||||
|
||||
if (s)
|
||||
ff_mdct_init(s, nbits, inverse, scale);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
|
||||
{
|
||||
s->imdct_calc(s, output, input);
|
||||
}
|
||||
|
||||
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
|
||||
{
|
||||
s->imdct_half(s, output, input);
|
||||
}
|
||||
|
||||
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
|
||||
{
|
||||
s->mdct_calc(s, output, input);
|
||||
}
|
||||
|
||||
void av_mdct_end(FFTContext *s)
|
||||
{
|
||||
if (s) {
|
||||
ff_mdct_end(s);
|
||||
av_free(s);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_MDCT */
|
||||
|
||||
#if CONFIG_RDFT
|
||||
|
||||
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)
|
||||
{
|
||||
RDFTContext *s = av_malloc(sizeof(*s));
|
||||
|
||||
if (s)
|
||||
ff_rdft_init(s, nbits, trans);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void av_rdft_calc(RDFTContext *s, FFTSample *data)
|
||||
{
|
||||
ff_rdft_calc(s, data);
|
||||
}
|
||||
|
||||
void av_rdft_end(RDFTContext *s)
|
||||
{
|
||||
if (s) {
|
||||
ff_rdft_end(s);
|
||||
av_free(s);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_RDFT */
|
||||
|
||||
#if CONFIG_DCT
|
||||
|
||||
DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse)
|
||||
{
|
||||
DCTContext *s = av_malloc(sizeof(*s));
|
||||
|
||||
if (s)
|
||||
ff_dct_init(s, nbits, inverse);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void av_dct_calc(DCTContext *s, FFTSample *data)
|
||||
{
|
||||
ff_dct_calc(s, data);
|
||||
}
|
||||
|
||||
void av_dct_end(DCTContext *s)
|
||||
{
|
||||
if (s) {
|
||||
ff_dct_end(s);
|
||||
av_free(s);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DCT */
|
99
src/add-ons/media/plugins/ffmpeg/libavcodec/avfft.h
Normal file
99
src/add-ons/media/plugins/ffmpeg/libavcodec/avfft.h
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AVFFT_H
|
||||
#define AVCODEC_AVFFT_H
|
||||
|
||||
typedef float FFTSample;
|
||||
|
||||
typedef struct FFTComplex {
|
||||
FFTSample re, im;
|
||||
} FFTComplex;
|
||||
|
||||
typedef struct FFTContext FFTContext;
|
||||
|
||||
/**
|
||||
* Set up a complex FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
|
||||
*/
|
||||
FFTContext *av_fft_init(int nbits, int inverse);
|
||||
|
||||
/**
|
||||
* Do the permutation needed BEFORE calling ff_fft_calc().
|
||||
*/
|
||||
void av_fft_permute(FFTContext *s, FFTComplex *z);
|
||||
|
||||
/**
|
||||
* Do a complex FFT with the parameters defined in av_fft_init(). The
|
||||
* input data must be permuted before. No 1.0/sqrt(n) normalization is done.
|
||||
*/
|
||||
void av_fft_calc(FFTContext *s, FFTComplex *z);
|
||||
|
||||
void av_fft_end(FFTContext *s);
|
||||
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale);
|
||||
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_end(FFTContext *s);
|
||||
|
||||
/* Real Discrete Fourier Transform */
|
||||
|
||||
enum RDFTransformType {
|
||||
DFT_R2C,
|
||||
IDFT_C2R,
|
||||
IDFT_R2C,
|
||||
DFT_C2R,
|
||||
};
|
||||
|
||||
typedef struct RDFTContext RDFTContext;
|
||||
|
||||
/**
|
||||
* Set up a real FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param trans the type of transform
|
||||
*/
|
||||
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
|
||||
void av_rdft_calc(RDFTContext *s, FFTSample *data);
|
||||
void av_rdft_end(RDFTContext *s);
|
||||
|
||||
/* Discrete Cosine Transform */
|
||||
|
||||
typedef struct DCTContext DCTContext;
|
||||
|
||||
enum DCTTransformType {
|
||||
DCT_II = 0,
|
||||
DCT_III,
|
||||
DCT_I,
|
||||
DST_I,
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets up DCT.
|
||||
* @param nbits size of the input array:
|
||||
* (1 << nbits) for DCT-II, DCT-III and DST-I
|
||||
* (1 << nbits) + 1 for DCT-I
|
||||
*
|
||||
* @note the first element of the input of DST-I is ignored
|
||||
*/
|
||||
DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
|
||||
void av_dct_calc(DCTContext *s, FFTSample *data);
|
||||
void av_dct_end (DCTContext *s);
|
||||
|
||||
#endif /* AVCODEC_AVFFT_H */
|
@ -47,18 +47,20 @@ void av_init_packet(AVPacket *pkt)
|
||||
|
||||
int av_new_packet(AVPacket *pkt, int size)
|
||||
{
|
||||
uint8_t *data;
|
||||
if((unsigned)size > (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
|
||||
return AVERROR(ENOMEM);
|
||||
data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!data)
|
||||
return AVERROR(ENOMEM);
|
||||
memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
uint8_t *data= NULL;
|
||||
if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
|
||||
data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (data){
|
||||
memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
}else
|
||||
size=0;
|
||||
|
||||
av_init_packet(pkt);
|
||||
pkt->data = data;
|
||||
pkt->size = size;
|
||||
pkt->destruct = av_destruct_packet;
|
||||
if(!data)
|
||||
return AVERROR(ENOMEM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ static av_cold int avs_decode_init(AVCodecContext * avctx)
|
||||
|
||||
AVCodec avs_decoder = {
|
||||
"avs",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_AVS,
|
||||
sizeof(AvsContext),
|
||||
avs_decode_init,
|
||||
|
@ -92,7 +92,7 @@ void avcodec_thread_free(AVCodecContext *s){
|
||||
av_freep(&s->thread_opaque);
|
||||
}
|
||||
|
||||
int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){
|
||||
static int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){
|
||||
ThreadContext *c= s->thread_opaque;
|
||||
int i;
|
||||
|
||||
@ -123,6 +123,9 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count){
|
||||
|
||||
s->thread_count= thread_count;
|
||||
|
||||
if (thread_count <= 1)
|
||||
return 0;
|
||||
|
||||
assert(!s->thread_opaque);
|
||||
c= av_mallocz(sizeof(ThreadContext)*thread_count);
|
||||
s->thread_opaque= c;
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/bethsoftvideo.c
|
||||
* @file
|
||||
* @brief Bethesda Softworks VID Video Decoder
|
||||
* @author Nicholas Tung [ntung (at. ntung com] (2007-03)
|
||||
* @sa http://wiki.multimedia.cx/index.php?title=Bethsoft_VID
|
||||
@ -132,7 +132,7 @@ static av_cold int bethsoftvid_decode_end(AVCodecContext *avctx)
|
||||
|
||||
AVCodec bethsoftvid_decoder = {
|
||||
.name = "bethsoftvid",
|
||||
.type = CODEC_TYPE_VIDEO,
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = CODEC_ID_BETHSOFTVID,
|
||||
.priv_data_size = sizeof(BethsoftvidContext),
|
||||
.init = bethsoftvid_decode_init,
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/bfi.c
|
||||
* @file
|
||||
* @brief Brute Force & Ignorance (.bfi) video decoder
|
||||
* @author Sisir Koppaka ( sisir.koppaka at gmail dot com )
|
||||
* @sa http://wiki.multimedia.cx/index.php?title=BFI
|
||||
@ -173,7 +173,7 @@ static av_cold int bfi_decode_close(AVCodecContext * avctx)
|
||||
|
||||
AVCodec bfi_decoder = {
|
||||
.name = "bfi",
|
||||
.type = CODEC_TYPE_VIDEO,
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = CODEC_ID_BFI,
|
||||
.priv_data_size = sizeof(BFIContext),
|
||||
.init = bfi_decode_init,
|
||||
|
567
src/add-ons/media/plugins/ffmpeg/libavcodec/bgmc.c
Normal file
567
src/add-ons/media/plugins/ffmpeg/libavcodec/bgmc.c
Normal file
@ -0,0 +1,567 @@
|
||||
/*
|
||||
* Block Gilbert-Moore decoder
|
||||
* Copyright (c) 2010 Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
|
||||
*
|
||||
* 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
|
||||
* Block Gilbert-Moore decoder as used by MPEG-4 ALS
|
||||
* @author Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "bgmc.h"
|
||||
|
||||
|
||||
#define FREQ_BITS 14 // bits used by frequency counters
|
||||
#define VALUE_BITS 18 // bits used to represent the values
|
||||
#define TOP_VALUE ((1 << VALUE_BITS) - 1) // maximum value
|
||||
#define FIRST_QTR (TOP_VALUE / 4 + 1) // first quarter of values maximum value
|
||||
#define HALF (2 * FIRST_QTR) // first half of values maximum value
|
||||
#define THIRD_QTR (3 * FIRST_QTR) // third quarter of values maximum value
|
||||
|
||||
#define LUT_BITS (FREQ_BITS - 8) // number of bits used to index lookup tables
|
||||
#define LUT_SIZE (1 << LUT_BITS) // size of the lookup tables
|
||||
#define LUT_BUFF 4 // number of buffered lookup tables
|
||||
|
||||
|
||||
/** Cumulative frequency tables for block Gilbert-Moore coding.
|
||||
*/
|
||||
static const uint16_t cf_tables_1[3][129] = {
|
||||
{
|
||||
16384, 16066, 15748, 15431, 15114, 14799, 14485, 14173, 13861, 13552,
|
||||
13243, 12939, 12635, 12336, 12038, 11745, 11452, 11161, 10870, 10586,
|
||||
10303, 10027, 9751, 9483, 9215, 8953, 8692, 8440, 8189, 7946,
|
||||
7704, 7472, 7240, 7008, 6776, 6554, 6333, 6122, 5912, 5711,
|
||||
5512, 5320, 5128, 4947, 4766, 4595, 4425, 4264, 4104, 3946,
|
||||
3788, 3640, 3493, 3355, 3218, 3090, 2963, 2842, 2721, 2609,
|
||||
2498, 2395, 2292, 2196, 2100, 2004, 1908, 1820, 1732, 1651,
|
||||
1570, 1497, 1424, 1355, 1287, 1223, 1161, 1100, 1044, 988,
|
||||
938, 888, 839, 790, 746, 702, 662, 623, 588, 553,
|
||||
520, 488, 459, 431, 405, 380, 357, 334, 311, 288,
|
||||
268, 248, 230, 213, 197, 182, 168, 154, 142, 130,
|
||||
119, 108, 99, 90, 81, 72, 64, 56, 49, 42,
|
||||
36, 30, 25, 20, 15, 11, 7, 3, 0
|
||||
},
|
||||
{
|
||||
16384, 16080, 15776, 15473, 15170, 14868, 14567, 14268, 13970, 13674,
|
||||
13378, 13086, 12794, 12505, 12218, 11936, 11654, 11373, 11092, 10818,
|
||||
10544, 10276, 10008, 9749, 9490, 9236, 8982, 8737, 8492, 8256,
|
||||
8020, 7792, 7564, 7336, 7108, 6888, 6669, 6459, 6249, 6050,
|
||||
5852, 5660, 5468, 5286, 5104, 4931, 4760, 4598, 4436, 4275,
|
||||
4115, 3965, 3816, 3674, 3534, 3403, 3272, 3147, 3023, 2907,
|
||||
2792, 2684, 2577, 2476, 2375, 2274, 2173, 2079, 1986, 1897,
|
||||
1810, 1724, 1645, 1567, 1493, 1419, 1351, 1284, 1222, 1161,
|
||||
1105, 1050, 995, 941, 891, 842, 797, 753, 713, 673,
|
||||
636, 599, 566, 533, 503, 473, 446, 419, 392, 365,
|
||||
340, 316, 294, 272, 253, 234, 216, 199, 184, 169,
|
||||
155, 142, 130, 118, 106, 95, 85, 75, 66, 57,
|
||||
49, 41, 34, 27, 21, 15, 10, 5, 0
|
||||
},
|
||||
{
|
||||
16384, 16092, 15801, 15510, 15219, 14930, 14641, 14355, 14069, 13785,
|
||||
13501, 13219, 12938, 12661, 12384, 12112, 11841, 11571, 11301, 11037,
|
||||
10773, 10514, 10256, 10005, 9754, 9508, 9263, 9025, 8787, 8557,
|
||||
8327, 8103, 7879, 7655, 7431, 7215, 7000, 6792, 6585, 6387,
|
||||
6190, 5998, 5807, 5625, 5445, 5272, 5100, 4937, 4774, 4613,
|
||||
4452, 4301, 4150, 4007, 3865, 3731, 3597, 3469, 3341, 3218,
|
||||
3099, 2981, 2869, 2758, 2652, 2546, 2440, 2334, 2234, 2134,
|
||||
2041, 1949, 1864, 1779, 1699, 1620, 1547, 1474, 1407, 1340,
|
||||
1278, 1217, 1157, 1097, 1043, 989, 940, 891, 846, 801,
|
||||
759, 718, 680, 643, 609, 575, 543, 511, 479, 447,
|
||||
418, 389, 363, 337, 314, 291, 270, 249, 230, 212,
|
||||
195, 179, 164, 149, 135, 121, 108, 96, 85, 74,
|
||||
64, 54, 45, 36, 28, 20, 13, 6, 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static const uint16_t cf_tables_2[8][193] = {
|
||||
{
|
||||
16384, 16104, 15825, 15546, 15268, 14991, 14714, 14439, 14164, 13891,
|
||||
13620, 13350, 13081, 12815, 12549, 12287, 12025, 11765, 11505, 11250,
|
||||
10996, 10746, 10497, 10254, 10011, 9772, 9534, 9303, 9072, 8848,
|
||||
8624, 8406, 8188, 7970, 7752, 7539, 7327, 7123, 6919, 6724,
|
||||
6529, 6339, 6150, 5970, 5790, 5618, 5446, 5282, 5119, 4957,
|
||||
4795, 4642, 4490, 4345, 4201, 4065, 3929, 3798, 3669, 3547,
|
||||
3425, 3310, 3196, 3086, 2976, 2866, 2756, 2650, 2545, 2447,
|
||||
2350, 2260, 2170, 2085, 2000, 1921, 1843, 1770, 1698, 1632,
|
||||
1566, 1501, 1436, 1376, 1316, 1261, 1207, 1157, 1108, 1061,
|
||||
1015, 973, 931, 893, 855, 819, 783, 747, 711, 677,
|
||||
644, 614, 584, 557, 530, 505, 480, 458, 436, 416,
|
||||
396, 378, 360, 343, 326, 310, 295, 281, 267, 255,
|
||||
243, 232, 221, 211, 201, 192, 183, 174, 166, 158,
|
||||
150, 142, 134, 126, 119, 112, 106, 100, 95, 90,
|
||||
85, 80, 76, 72, 69, 66, 63, 60, 57, 54,
|
||||
51, 48, 46, 44, 42, 40, 38, 36, 34, 33,
|
||||
32, 31, 30, 29, 28, 27, 26, 25, 24, 23,
|
||||
22, 21, 20, 19, 18, 17, 16, 15, 14, 13,
|
||||
12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
|
||||
2, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16116, 15849, 15582, 15316, 15050, 14785, 14521, 14257, 13995,
|
||||
13734, 13476, 13218, 12963, 12708, 12457, 12206, 11956, 11706, 11460,
|
||||
11215, 10975, 10735, 10500, 10265, 10034, 9803, 9579, 9355, 9136,
|
||||
8917, 8703, 8489, 8275, 8061, 7853, 7645, 7444, 7244, 7051,
|
||||
6858, 6671, 6484, 6305, 6127, 5956, 5785, 5622, 5459, 5298,
|
||||
5137, 4983, 4830, 4684, 4539, 4401, 4263, 4131, 3999, 3874,
|
||||
3750, 3632, 3515, 3401, 3287, 3173, 3059, 2949, 2840, 2737,
|
||||
2635, 2539, 2444, 2354, 2264, 2181, 2098, 2020, 1943, 1872,
|
||||
1801, 1731, 1661, 1596, 1532, 1472, 1412, 1357, 1303, 1251,
|
||||
1200, 1153, 1106, 1063, 1020, 979, 938, 897, 856, 818,
|
||||
780, 746, 712, 681, 650, 621, 592, 566, 540, 517,
|
||||
494, 473, 452, 431, 410, 391, 373, 356, 340, 325,
|
||||
310, 296, 282, 270, 258, 247, 236, 225, 214, 203,
|
||||
192, 182, 172, 162, 153, 144, 136, 128, 121, 114,
|
||||
108, 102, 97, 92, 87, 82, 77, 73, 69, 65,
|
||||
62, 59, 56, 53, 50, 47, 45, 43, 41, 39,
|
||||
37, 35, 33, 31, 29, 27, 26, 25, 24, 23,
|
||||
22, 21, 20, 19, 18, 17, 16, 15, 14, 13,
|
||||
12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
|
||||
2, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16128, 15872, 15617, 15362, 15107, 14853, 14600, 14347, 14096,
|
||||
13846, 13597, 13350, 13105, 12860, 12618, 12376, 12135, 11894, 11657,
|
||||
11421, 11189, 10957, 10730, 10503, 10279, 10056, 9838, 9620, 9407,
|
||||
9195, 8987, 8779, 8571, 8363, 8159, 7955, 7758, 7561, 7371,
|
||||
7182, 6997, 6812, 6635, 6459, 6289, 6120, 5957, 5795, 5634,
|
||||
5473, 5319, 5165, 5018, 4871, 4732, 4593, 4458, 4324, 4197,
|
||||
4071, 3951, 3831, 3714, 3597, 3480, 3363, 3250, 3138, 3032,
|
||||
2927, 2828, 2729, 2635, 2541, 2453, 2366, 2284, 2202, 2126,
|
||||
2050, 1975, 1900, 1830, 1761, 1697, 1633, 1574, 1515, 1459,
|
||||
1403, 1351, 1300, 1252, 1205, 1160, 1115, 1070, 1025, 982,
|
||||
939, 899, 860, 824, 789, 756, 723, 693, 663, 636,
|
||||
609, 584, 559, 535, 511, 489, 467, 447, 427, 409,
|
||||
391, 374, 358, 343, 328, 313, 300, 287, 274, 261,
|
||||
248, 235, 223, 211, 200, 189, 179, 169, 160, 151,
|
||||
143, 135, 128, 121, 115, 109, 103, 97, 92, 87,
|
||||
82, 77, 73, 69, 65, 61, 58, 55, 52, 49,
|
||||
46, 43, 40, 37, 35, 33, 31, 29, 27, 25,
|
||||
23, 21, 20, 19, 18, 17, 16, 15, 14, 13,
|
||||
12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
|
||||
2, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16139, 15894, 15649, 15405, 15162, 14919, 14677, 14435, 14195,
|
||||
13955, 13717, 13479, 13243, 13008, 12775, 12542, 12310, 12079, 11851,
|
||||
11623, 11399, 11176, 10956, 10737, 10521, 10305, 10094, 9883, 9677,
|
||||
9471, 9268, 9065, 8862, 8659, 8459, 8260, 8067, 7874, 7688,
|
||||
7502, 7321, 7140, 6965, 6790, 6621, 6452, 6290, 6128, 5968,
|
||||
5808, 5655, 5503, 5356, 5209, 5069, 4929, 4794, 4660, 4532,
|
||||
4404, 4282, 4160, 4041, 3922, 3803, 3684, 3568, 3452, 3343,
|
||||
3234, 3131, 3029, 2931, 2833, 2741, 2649, 2563, 2477, 2396,
|
||||
2316, 2236, 2157, 2083, 2009, 1940, 1871, 1807, 1743, 1683,
|
||||
1623, 1567, 1511, 1459, 1407, 1357, 1307, 1257, 1207, 1159,
|
||||
1111, 1067, 1023, 983, 943, 905, 868, 834, 800, 769,
|
||||
738, 709, 681, 653, 625, 600, 575, 552, 529, 508,
|
||||
487, 466, 447, 428, 410, 392, 376, 360, 344, 328,
|
||||
313, 298, 283, 268, 255, 242, 230, 218, 207, 196,
|
||||
186, 176, 167, 158, 150, 142, 135, 128, 121, 114,
|
||||
108, 102, 97, 92, 87, 82, 78, 74, 70, 66,
|
||||
62, 58, 54, 50, 47, 44, 41, 38, 35, 32,
|
||||
30, 28, 26, 24, 22, 20, 18, 16, 14, 13,
|
||||
12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
|
||||
2, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16149, 15915, 15681, 15447, 15214, 14981, 14749, 14517, 14286,
|
||||
14055, 13827, 13599, 13373, 13147, 12923, 12699, 12476, 12253, 12034,
|
||||
11815, 11599, 11383, 11171, 10959, 10750, 10541, 10337, 10133, 9933,
|
||||
9733, 9536, 9339, 9142, 8945, 8751, 8557, 8369, 8181, 7998,
|
||||
7816, 7638, 7460, 7288, 7116, 6950, 6785, 6625, 6465, 6306,
|
||||
6147, 5995, 5843, 5697, 5551, 5411, 5271, 5135, 5000, 4871,
|
||||
4742, 4618, 4495, 4374, 4253, 4132, 4011, 3893, 3775, 3663,
|
||||
3552, 3446, 3340, 3239, 3138, 3043, 2948, 2858, 2768, 2684,
|
||||
2600, 2516, 2433, 2355, 2278, 2205, 2133, 2065, 1997, 1932,
|
||||
1867, 1807, 1747, 1690, 1634, 1580, 1526, 1472, 1418, 1366,
|
||||
1314, 1266, 1218, 1174, 1130, 1088, 1047, 1009, 971, 936,
|
||||
901, 868, 836, 804, 772, 743, 714, 685, 658, 631,
|
||||
606, 582, 559, 536, 515, 494, 475, 456, 437, 418,
|
||||
399, 380, 362, 344, 328, 312, 297, 283, 270, 257,
|
||||
245, 233, 222, 211, 201, 191, 181, 172, 163, 155,
|
||||
147, 139, 132, 125, 119, 113, 107, 101, 96, 91,
|
||||
86, 81, 76, 71, 66, 62, 58, 54, 50, 46,
|
||||
43, 40, 37, 34, 31, 28, 26, 24, 22, 20,
|
||||
18, 16, 14, 12, 10, 8, 6, 5, 4, 3,
|
||||
2, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16159, 15934, 15709, 15485, 15261, 15038, 14816, 14594, 14373,
|
||||
14152, 13933, 13714, 13497, 13280, 13065, 12850, 12636, 12422, 12211,
|
||||
12000, 11791, 11583, 11378, 11173, 10971, 10769, 10571, 10373, 10179,
|
||||
9985, 9793, 9601, 9409, 9217, 9029, 8842, 8658, 8475, 8297,
|
||||
8120, 7946, 7773, 7604, 7435, 7271, 7108, 6950, 6792, 6634,
|
||||
6477, 6326, 6175, 6029, 5883, 5742, 5602, 5466, 5330, 5199,
|
||||
5068, 4943, 4818, 4696, 4574, 4452, 4330, 4211, 4093, 3979,
|
||||
3866, 3759, 3652, 3549, 3446, 3348, 3250, 3157, 3065, 2977,
|
||||
2889, 2802, 2716, 2634, 2553, 2476, 2399, 2326, 2254, 2185,
|
||||
2117, 2052, 1987, 1926, 1866, 1808, 1750, 1692, 1634, 1578,
|
||||
1522, 1470, 1418, 1369, 1321, 1275, 1229, 1187, 1145, 1105,
|
||||
1066, 1027, 991, 955, 919, 883, 850, 817, 786, 756,
|
||||
728, 700, 674, 648, 624, 600, 578, 556, 534, 512,
|
||||
490, 468, 447, 426, 407, 388, 371, 354, 338, 322,
|
||||
307, 293, 280, 267, 255, 243, 231, 219, 209, 199,
|
||||
189, 179, 170, 161, 153, 145, 138, 131, 124, 117,
|
||||
111, 105, 99, 93, 87, 81, 76, 71, 66, 61,
|
||||
57, 53, 49, 45, 42, 39, 36, 33, 30, 27,
|
||||
24, 21, 19, 17, 15, 13, 11, 9, 7, 5,
|
||||
3, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16169, 15954, 15739, 15524, 15310, 15096, 14883, 14670, 14458,
|
||||
14246, 14035, 13824, 13614, 13405, 13198, 12991, 12785, 12579, 12376,
|
||||
12173, 11972, 11772, 11574, 11377, 11182, 10987, 10795, 10603, 10414,
|
||||
10226, 10040, 9854, 9668, 9482, 9299, 9116, 8937, 8759, 8585,
|
||||
8411, 8241, 8071, 7906, 7741, 7580, 7419, 7263, 7107, 6952,
|
||||
6797, 6647, 6497, 6353, 6209, 6070, 5931, 5796, 5661, 5531,
|
||||
5401, 5275, 5150, 5027, 4904, 4781, 4658, 4538, 4419, 4304,
|
||||
4190, 4081, 3972, 3867, 3762, 3662, 3562, 3467, 3372, 3281,
|
||||
3191, 3101, 3012, 2928, 2844, 2764, 2684, 2608, 2533, 2460,
|
||||
2387, 2318, 2250, 2185, 2121, 2059, 1997, 1935, 1873, 1813,
|
||||
1754, 1698, 1642, 1588, 1535, 1483, 1433, 1384, 1338, 1292,
|
||||
1249, 1206, 1165, 1125, 1085, 1045, 1008, 971, 937, 903,
|
||||
871, 840, 810, 780, 752, 724, 698, 672, 647, 622,
|
||||
597, 572, 548, 524, 502, 480, 460, 440, 421, 403,
|
||||
386, 369, 353, 337, 323, 309, 295, 281, 268, 255,
|
||||
243, 231, 220, 209, 199, 189, 180, 171, 163, 155,
|
||||
147, 139, 131, 123, 116, 109, 102, 95, 89, 83,
|
||||
77, 72, 67, 62, 57, 52, 48, 44, 40, 36,
|
||||
32, 28, 25, 22, 19, 16, 13, 10, 8, 6,
|
||||
4, 2, 0
|
||||
},
|
||||
{
|
||||
16384, 16177, 15970, 15764, 15558, 15353, 15148, 14944, 14740, 14537,
|
||||
14334, 14132, 13930, 13729, 13529, 13330, 13131, 12933, 12735, 12539,
|
||||
12343, 12150, 11957, 11766, 11576, 11388, 11200, 11015, 10830, 10647,
|
||||
10465, 10285, 10105, 9925, 9745, 9568, 9391, 9218, 9045, 8876,
|
||||
8707, 8541, 8375, 8213, 8051, 7894, 7737, 7583, 7429, 7277,
|
||||
7125, 6977, 6830, 6687, 6544, 6406, 6268, 6133, 5998, 5868,
|
||||
5738, 5612, 5487, 5364, 5241, 5118, 4995, 4875, 4755, 4640,
|
||||
4525, 4414, 4304, 4198, 4092, 3990, 3888, 3790, 3693, 3600,
|
||||
3507, 3415, 3323, 3235, 3147, 3064, 2981, 2902, 2823, 2746,
|
||||
2670, 2594, 2522, 2450, 2382, 2314, 2248, 2182, 2116, 2050,
|
||||
1987, 1924, 1864, 1804, 1748, 1692, 1638, 1585, 1534, 1484,
|
||||
1437, 1390, 1346, 1302, 1258, 1215, 1174, 1133, 1095, 1057,
|
||||
1021, 986, 952, 918, 887, 856, 827, 798, 770, 742,
|
||||
714, 686, 659, 632, 607, 582, 559, 536, 514, 492,
|
||||
472, 452, 433, 415, 398, 381, 364, 348, 333, 318,
|
||||
304, 290, 277, 264, 252, 240, 229, 218, 208, 198,
|
||||
188, 178, 168, 158, 149, 140, 132, 124, 116, 108,
|
||||
101, 94, 87, 81, 75, 69, 64, 59, 54, 49,
|
||||
44, 39, 35, 31, 27, 23, 19, 15, 12, 9,
|
||||
6, 3, 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static const uint16_t cf_tables_3[5][257] = {
|
||||
{
|
||||
16384, 16187, 15990, 15793, 15597, 15401, 15205, 15009, 14813, 14618,
|
||||
14423, 14230, 14037, 13845, 13653, 13463, 13273, 13083, 12894, 12706,
|
||||
12518, 12332, 12146, 11962, 11778, 11597, 11416, 11237, 11059, 10882,
|
||||
10706, 10532, 10358, 10184, 10010, 9838, 9666, 9497, 9328, 9163,
|
||||
8999, 8837, 8675, 8517, 8359, 8205, 8051, 7901, 7751, 7602,
|
||||
7453, 7308, 7163, 7022, 6882, 6745, 6609, 6476, 6343, 6214,
|
||||
6085, 5960, 5835, 5712, 5589, 5466, 5343, 5223, 5103, 4987,
|
||||
4872, 4761, 4650, 4542, 4435, 4332, 4229, 4130, 4031, 3936,
|
||||
3841, 3747, 3653, 3563, 3473, 3387, 3302, 3220, 3138, 3059,
|
||||
2980, 2905, 2830, 2759, 2688, 2619, 2550, 2481, 2412, 2345,
|
||||
2278, 2215, 2152, 2092, 2032, 1974, 1917, 1863, 1809, 1758,
|
||||
1707, 1659, 1611, 1564, 1517, 1473, 1429, 1387, 1346, 1307,
|
||||
1268, 1230, 1193, 1158, 1123, 1090, 1058, 1026, 994, 962,
|
||||
930, 899, 869, 841, 813, 786, 760, 735, 710, 687,
|
||||
664, 643, 622, 602, 582, 562, 543, 525, 507, 490,
|
||||
473, 457, 442, 427, 412, 398, 385, 373, 361, 349,
|
||||
337, 325, 313, 301, 290, 279, 269, 259, 249, 240,
|
||||
231, 222, 214, 206, 199, 192, 185, 178, 171, 165,
|
||||
159, 153, 148, 143, 138, 133, 128, 123, 119, 115,
|
||||
111, 107, 103, 99, 95, 91, 87, 83, 80, 77,
|
||||
74, 71, 68, 65, 63, 61, 59, 57, 55, 53,
|
||||
51, 49, 47, 45, 43, 41, 40, 39, 38, 37,
|
||||
36, 35, 34, 33, 32, 31, 30, 29, 28, 27,
|
||||
26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
|
||||
16, 15, 14, 13, 12, 11, 10, 9, 8, 7,
|
||||
6, 5, 4, 3, 2, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16195, 16006, 15817, 15629, 15441, 15253, 15065, 14878, 14692,
|
||||
14506, 14321, 14136, 13952, 13768, 13585, 13402, 13219, 13037, 12857,
|
||||
12677, 12499, 12321, 12144, 11967, 11792, 11617, 11444, 11271, 11100,
|
||||
10930, 10762, 10594, 10426, 10258, 10091, 9925, 9761, 9598, 9438,
|
||||
9278, 9120, 8963, 8809, 8655, 8504, 8354, 8207, 8060, 7914,
|
||||
7769, 7627, 7485, 7347, 7209, 7074, 6939, 6807, 6676, 6548,
|
||||
6420, 6296, 6172, 6050, 5928, 5806, 5684, 5564, 5444, 5328,
|
||||
5212, 5100, 4988, 4879, 4771, 4667, 4563, 4462, 4362, 4265,
|
||||
4169, 4073, 3978, 3886, 3795, 3707, 3619, 3535, 3451, 3369,
|
||||
3288, 3210, 3133, 3059, 2985, 2913, 2841, 2769, 2697, 2627,
|
||||
2557, 2490, 2424, 2360, 2297, 2237, 2177, 2119, 2062, 2007,
|
||||
1953, 1901, 1849, 1798, 1748, 1700, 1652, 1607, 1562, 1519,
|
||||
1476, 1435, 1394, 1355, 1317, 1281, 1245, 1210, 1175, 1140,
|
||||
1105, 1071, 1037, 1005, 973, 943, 913, 885, 857, 830,
|
||||
804, 779, 754, 731, 708, 685, 663, 642, 621, 601,
|
||||
581, 563, 545, 528, 511, 495, 479, 463, 448, 433,
|
||||
419, 405, 391, 377, 364, 351, 338, 326, 314, 302,
|
||||
291, 280, 270, 260, 251, 242, 234, 226, 218, 210,
|
||||
202, 195, 188, 181, 174, 168, 162, 156, 150, 144,
|
||||
139, 134, 129, 124, 119, 114, 109, 104, 100, 96,
|
||||
92, 88, 84, 80, 77, 74, 71, 68, 65, 62,
|
||||
59, 56, 54, 52, 50, 48, 46, 44, 42, 40,
|
||||
38, 36, 34, 33, 32, 31, 30, 29, 28, 27,
|
||||
26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
|
||||
16, 15, 14, 13, 12, 11, 10, 9, 8, 7,
|
||||
6, 5, 4, 3, 2, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16203, 16022, 15842, 15662, 15482, 15302, 15122, 14942, 14763,
|
||||
14584, 14406, 14228, 14051, 13874, 13698, 13522, 13347, 13172, 12998,
|
||||
12824, 12652, 12480, 12310, 12140, 11971, 11803, 11637, 11471, 11307,
|
||||
11143, 10980, 10817, 10654, 10491, 10330, 10169, 10011, 9853, 9697,
|
||||
9542, 9389, 9236, 9086, 8936, 8789, 8642, 8498, 8355, 8212,
|
||||
8070, 7931, 7792, 7656, 7520, 7388, 7256, 7126, 6996, 6870,
|
||||
6744, 6621, 6498, 6377, 6256, 6135, 6014, 5895, 5776, 5660,
|
||||
5545, 5433, 5321, 5212, 5104, 4999, 4895, 4793, 4692, 4594,
|
||||
4496, 4400, 4304, 4211, 4118, 4028, 3939, 3853, 3767, 3684,
|
||||
3601, 3521, 3441, 3364, 3287, 3212, 3137, 3062, 2987, 2915,
|
||||
2843, 2773, 2704, 2638, 2572, 2508, 2445, 2384, 2324, 2266,
|
||||
2208, 2153, 2098, 2044, 1990, 1939, 1888, 1839, 1791, 1745,
|
||||
1699, 1655, 1611, 1569, 1527, 1487, 1448, 1409, 1370, 1331,
|
||||
1292, 1255, 1218, 1183, 1148, 1115, 1082, 1051, 1020, 990,
|
||||
960, 932, 904, 878, 852, 826, 801, 777, 753, 731,
|
||||
709, 687, 666, 645, 625, 605, 586, 567, 550, 533,
|
||||
516, 499, 482, 465, 449, 433, 418, 403, 389, 375,
|
||||
362, 349, 337, 325, 314, 303, 293, 283, 273, 263,
|
||||
254, 245, 236, 227, 219, 211, 204, 197, 190, 183,
|
||||
177, 171, 165, 159, 153, 147, 141, 135, 130, 125,
|
||||
120, 115, 110, 105, 101, 97, 93, 89, 85, 81,
|
||||
77, 74, 71, 68, 65, 62, 59, 56, 53, 51,
|
||||
49, 47, 45, 43, 41, 39, 37, 35, 33, 31,
|
||||
29, 27, 25, 23, 22, 21, 20, 19, 18, 17,
|
||||
16, 15, 14, 13, 12, 11, 10, 9, 8, 7,
|
||||
6, 5, 4, 3, 2, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16210, 16036, 15863, 15690, 15517, 15344, 15172, 15000, 14828,
|
||||
14656, 14485, 14314, 14145, 13976, 13808, 13640, 13472, 13304, 13137,
|
||||
12970, 12804, 12639, 12475, 12312, 12149, 11987, 11827, 11667, 11508,
|
||||
11349, 11192, 11035, 10878, 10721, 10565, 10410, 10257, 10104, 9953,
|
||||
9802, 9654, 9506, 9359, 9213, 9070, 8927, 8787, 8647, 8508,
|
||||
8369, 8233, 8097, 7964, 7831, 7700, 7570, 7442, 7315, 7190,
|
||||
7065, 6943, 6821, 6701, 6581, 6461, 6341, 6223, 6105, 5990,
|
||||
5876, 5764, 5653, 5545, 5437, 5331, 5226, 5124, 5022, 4924,
|
||||
4826, 4729, 4632, 4538, 4444, 4353, 4262, 4174, 4087, 4002,
|
||||
3917, 3835, 3753, 3674, 3595, 3518, 3441, 3364, 3287, 3212,
|
||||
3138, 3066, 2995, 2926, 2858, 2792, 2726, 2662, 2599, 2538,
|
||||
2478, 2420, 2362, 2305, 2249, 2195, 2141, 2089, 2037, 1988,
|
||||
1939, 1891, 1844, 1799, 1754, 1711, 1668, 1626, 1584, 1542,
|
||||
1500, 1459, 1418, 1380, 1342, 1305, 1269, 1234, 1199, 1166,
|
||||
1133, 1102, 1071, 1041, 1012, 983, 954, 926, 899, 872,
|
||||
847, 822, 798, 774, 751, 728, 707, 686, 666, 646,
|
||||
627, 608, 589, 570, 552, 534, 517, 500, 484, 468,
|
||||
453, 438, 424, 410, 397, 384, 372, 360, 348, 336,
|
||||
325, 314, 303, 293, 283, 273, 264, 255, 246, 237,
|
||||
229, 221, 213, 205, 197, 189, 181, 174, 167, 160,
|
||||
154, 148, 142, 136, 131, 126, 121, 116, 111, 106,
|
||||
101, 97, 93, 89, 85, 81, 77, 73, 70, 67,
|
||||
64, 61, 58, 55, 52, 49, 46, 43, 40, 37,
|
||||
35, 33, 31, 29, 27, 25, 23, 21, 19, 17,
|
||||
16, 15, 14, 13, 12, 11, 10, 9, 8, 7,
|
||||
6, 5, 4, 3, 2, 1, 0
|
||||
},
|
||||
{
|
||||
16384, 16218, 16052, 15886, 15720, 15554, 15389, 15224, 15059, 14895,
|
||||
14731, 14567, 14403, 14240, 14077, 13915, 13753, 13591, 13429, 13269,
|
||||
13109, 12950, 12791, 12633, 12476, 12320, 12164, 12009, 11854, 11701,
|
||||
11548, 11396, 11244, 11092, 10940, 10790, 10640, 10492, 10344, 10198,
|
||||
10052, 9908, 9764, 9622, 9481, 9342, 9203, 9066, 8929, 8793,
|
||||
8657, 8524, 8391, 8261, 8131, 8003, 7875, 7749, 7624, 7502,
|
||||
7380, 7260, 7140, 7022, 6904, 6786, 6668, 6551, 6435, 6322,
|
||||
6209, 6099, 5989, 5881, 5773, 5668, 5563, 5461, 5359, 5260,
|
||||
5161, 5063, 4965, 4871, 4777, 4686, 4595, 4506, 4417, 4331,
|
||||
4245, 4162, 4079, 3999, 3919, 3841, 3763, 3685, 3607, 3530,
|
||||
3454, 3380, 3307, 3236, 3166, 3097, 3029, 2963, 2897, 2834,
|
||||
2771, 2710, 2650, 2591, 2532, 2475, 2418, 2363, 2309, 2257,
|
||||
2205, 2155, 2105, 2057, 2009, 1963, 1918, 1873, 1828, 1783,
|
||||
1738, 1694, 1650, 1607, 1565, 1524, 1484, 1445, 1407, 1369,
|
||||
1333, 1297, 1263, 1229, 1197, 1165, 1134, 1103, 1073, 1043,
|
||||
1015, 987, 960, 933, 907, 882, 858, 834, 811, 788,
|
||||
766, 744, 722, 700, 679, 658, 638, 618, 599, 581,
|
||||
563, 545, 528, 511, 495, 480, 465, 451, 437, 423,
|
||||
410, 397, 384, 372, 360, 348, 337, 326, 315, 305,
|
||||
295, 285, 275, 265, 255, 245, 236, 227, 219, 211,
|
||||
203, 195, 188, 181, 174, 167, 161, 155, 149, 143,
|
||||
137, 131, 126, 121, 116, 111, 106, 101, 97, 93,
|
||||
89, 85, 81, 77, 73, 69, 65, 61, 58, 55,
|
||||
52, 49, 46, 43, 40, 37, 34, 32, 30, 28,
|
||||
26, 24, 22, 20, 18, 16, 14, 12, 10, 8,
|
||||
6, 5, 4, 3, 2, 1, 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static const uint16_t * const cf_table[16] = {
|
||||
cf_tables_1[0], cf_tables_1[1], cf_tables_1[2], cf_tables_2[0],
|
||||
cf_tables_2[1], cf_tables_2[2], cf_tables_2[3], cf_tables_2[4],
|
||||
cf_tables_2[5], cf_tables_2[6], cf_tables_2[7], cf_tables_3[0],
|
||||
cf_tables_3[1], cf_tables_3[2], cf_tables_3[3], cf_tables_3[4]
|
||||
};
|
||||
|
||||
|
||||
/** Initializes a given lookup table using a given delta
|
||||
*/
|
||||
static void bgmc_lut_fillp(uint8_t *lut, unsigned int *lut_status,
|
||||
unsigned int delta)
|
||||
{
|
||||
unsigned int sx, i;
|
||||
|
||||
for (sx = 0; sx < 16; sx++)
|
||||
for (i = 0; i < LUT_SIZE; i++) {
|
||||
unsigned int target = (i + 1) << (FREQ_BITS - LUT_BITS);
|
||||
unsigned int symbol = 1 << delta;
|
||||
|
||||
while (cf_table[sx][symbol] > target)
|
||||
symbol += 1 << delta;
|
||||
|
||||
*lut++ = symbol >> delta;
|
||||
}
|
||||
|
||||
*lut_status = delta;
|
||||
}
|
||||
|
||||
|
||||
/** Retunes the index of a suitable lookup table for a given delta
|
||||
*/
|
||||
static uint8_t* bgmc_lut_getp(uint8_t *lut, unsigned int *lut_status,
|
||||
unsigned int delta)
|
||||
{
|
||||
unsigned int i = av_clip(delta, 0, LUT_BUFF - 1);
|
||||
|
||||
lut += (i * LUT_SIZE) << 4;
|
||||
|
||||
if (lut_status[i] != delta)
|
||||
bgmc_lut_fillp(lut, &lut_status[i], delta);
|
||||
|
||||
return lut;
|
||||
}
|
||||
|
||||
|
||||
/** Initializes the lookup table arrays
|
||||
*/
|
||||
int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_status)
|
||||
{
|
||||
*cf_lut = av_malloc(sizeof(*cf_lut ) * LUT_BUFF * 16 * LUT_SIZE);
|
||||
*cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
|
||||
|
||||
if (!cf_lut || !cf_lut_status) {
|
||||
ff_bgmc_end(cf_lut, cf_lut_status);
|
||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** Releases the lookup table arrays
|
||||
*/
|
||||
void ff_bgmc_end(uint8_t **cf_lut, unsigned int **cf_lut_status)
|
||||
{
|
||||
av_freep(cf_lut);
|
||||
av_freep(cf_lut_status);
|
||||
}
|
||||
|
||||
|
||||
/** Initializes decoding and reads the first value
|
||||
*/
|
||||
void ff_bgmc_decode_init(GetBitContext *gb,
|
||||
unsigned int *h, unsigned int *l, unsigned int *v)
|
||||
{
|
||||
*h = TOP_VALUE;
|
||||
*l = 0;
|
||||
*v = get_bits_long(gb, VALUE_BITS);
|
||||
}
|
||||
|
||||
|
||||
/** Finish decoding
|
||||
*/
|
||||
void ff_bgmc_decode_end(GetBitContext *gb)
|
||||
{
|
||||
skip_bits_long(gb, -(VALUE_BITS - 2));
|
||||
}
|
||||
|
||||
|
||||
/** Reads and decodes a block Gilbert-Moore coded symbol
|
||||
*/
|
||||
void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
|
||||
unsigned int delta, unsigned int sx,
|
||||
unsigned int *h, unsigned int *l, unsigned int *v,
|
||||
uint8_t *cf_lut, unsigned int *cf_lut_status)
|
||||
{
|
||||
unsigned int i;
|
||||
uint8_t *lut = bgmc_lut_getp(cf_lut, cf_lut_status, delta);
|
||||
|
||||
// read current state
|
||||
unsigned int high = *h;
|
||||
unsigned int low = *l;
|
||||
unsigned int value = *v;
|
||||
|
||||
lut += sx * LUT_SIZE;
|
||||
|
||||
// decode num samples
|
||||
for (i = 0; i < num; i++) {
|
||||
unsigned int range = high - low + 1;
|
||||
unsigned int target = (((value - low + 1) << FREQ_BITS) - 1) / range;
|
||||
unsigned int symbol = lut[target >> (FREQ_BITS - LUT_BITS)] << delta;
|
||||
|
||||
while (cf_table[sx][symbol] > target)
|
||||
symbol += 1 << delta;
|
||||
|
||||
symbol = (symbol >> delta) - 1;
|
||||
|
||||
high = low + ((range * cf_table[sx][(symbol ) << delta] - (1 << FREQ_BITS)) >> FREQ_BITS);
|
||||
low = low + ((range * cf_table[sx][(symbol + 1) << delta] ) >> FREQ_BITS);
|
||||
|
||||
while (1) {
|
||||
if (high >= HALF) {
|
||||
if (low >= HALF) {
|
||||
value -= HALF;
|
||||
low -= HALF;
|
||||
high -= HALF;
|
||||
} else if (low >= FIRST_QTR && high < THIRD_QTR) {
|
||||
value -= FIRST_QTR;
|
||||
low -= FIRST_QTR;
|
||||
high -= FIRST_QTR;
|
||||
} else break;
|
||||
}
|
||||
|
||||
low *= 2;
|
||||
high = 2 * high + 1;
|
||||
value = 2 * value + get_bits1(gb);
|
||||
}
|
||||
|
||||
*dst++ = symbol;
|
||||
}
|
||||
|
||||
// save current state
|
||||
*h = high;
|
||||
*l = low;
|
||||
*v = value;
|
||||
}
|
||||
|
56
src/add-ons/media/plugins/ffmpeg/libavcodec/bgmc.h
Normal file
56
src/add-ons/media/plugins/ffmpeg/libavcodec/bgmc.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Block Gilbert-Moore decoder
|
||||
* Copyright (c) 2010 Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
|
||||
*
|
||||
* 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
|
||||
* Block Gilbert-Moore decoder header
|
||||
* @author Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AVCODEC_BGMC_H
|
||||
#define AVCODEC_BGMC_H
|
||||
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
|
||||
int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_status);
|
||||
|
||||
|
||||
void ff_bgmc_end(uint8_t **cf_lut, unsigned int **cf_lut_status);
|
||||
|
||||
|
||||
void ff_bgmc_decode_init(GetBitContext *gb,
|
||||
unsigned int *h, unsigned int *l, unsigned int *v);
|
||||
|
||||
|
||||
void ff_bgmc_decode_end(GetBitContext *gb);
|
||||
|
||||
|
||||
void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
|
||||
unsigned int delta, unsigned int sx,
|
||||
unsigned int *h, unsigned int *l, unsigned int *v,
|
||||
uint8_t *cf_lut, unsigned int *cf_lut_status);
|
||||
|
||||
|
||||
#endif /* AVCODEC_BGMC_H */
|
1012
src/add-ons/media/plugins/ffmpeg/libavcodec/bink.c
Normal file
1012
src/add-ons/media/plugins/ffmpeg/libavcodec/bink.c
Normal file
File diff suppressed because it is too large
Load Diff
311
src/add-ons/media/plugins/ffmpeg/libavcodec/binkaudio.c
Normal file
311
src/add-ons/media/plugins/ffmpeg/libavcodec/binkaudio.c
Normal file
@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Bink Audio decoder
|
||||
* Copyright (c) 2007-2010 Peter Ross (pross@xvid.org)
|
||||
* Copyright (c) 2009 Daniel Verkamp (daniel@drv.nu)
|
||||
*
|
||||
* 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
|
||||
* Bink Audio decoder
|
||||
*
|
||||
* Technical details here:
|
||||
* http://wiki.multimedia.cx/index.php?title=Bink_Audio
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#define ALT_BITSTREAM_READER_LE
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
|
||||
extern const uint16_t ff_wma_critical_freqs[25];
|
||||
|
||||
#define MAX_CHANNELS 2
|
||||
#define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
|
||||
|
||||
typedef struct {
|
||||
AVCodecContext *avctx;
|
||||
GetBitContext gb;
|
||||
DSPContext dsp;
|
||||
int first;
|
||||
int channels;
|
||||
int frame_len; ///< transform size (samples)
|
||||
int overlap_len; ///< overlap size (samples)
|
||||
int block_size;
|
||||
int num_bands;
|
||||
unsigned int *bands;
|
||||
float root;
|
||||
DECLARE_ALIGNED(16, FFTSample, coeffs)[BINK_BLOCK_MAX_SIZE];
|
||||
DECLARE_ALIGNED(16, short, previous)[BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs from previous audio block
|
||||
float *coeffs_ptr[MAX_CHANNELS]; ///< pointers to the coeffs arrays for float_to_int16_interleave
|
||||
union {
|
||||
RDFTContext rdft;
|
||||
DCTContext dct;
|
||||
} trans;
|
||||
} BinkAudioContext;
|
||||
|
||||
|
||||
static av_cold int decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
BinkAudioContext *s = avctx->priv_data;
|
||||
int sample_rate = avctx->sample_rate;
|
||||
int sample_rate_half;
|
||||
int i;
|
||||
int frame_len_bits;
|
||||
|
||||
s->avctx = avctx;
|
||||
dsputil_init(&s->dsp, avctx);
|
||||
|
||||
/* determine frame length */
|
||||
if (avctx->sample_rate < 22050) {
|
||||
frame_len_bits = 9;
|
||||
} else if (avctx->sample_rate < 44100) {
|
||||
frame_len_bits = 10;
|
||||
} else {
|
||||
frame_len_bits = 11;
|
||||
}
|
||||
s->frame_len = 1 << frame_len_bits;
|
||||
|
||||
if (s->channels > MAX_CHANNELS) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT) {
|
||||
// audio is already interleaved for the RDFT format variant
|
||||
sample_rate *= avctx->channels;
|
||||
s->frame_len *= avctx->channels;
|
||||
s->channels = 1;
|
||||
if (avctx->channels == 2)
|
||||
frame_len_bits++;
|
||||
} else {
|
||||
s->channels = avctx->channels;
|
||||
}
|
||||
|
||||
s->overlap_len = s->frame_len / 16;
|
||||
s->block_size = (s->frame_len - s->overlap_len) * s->channels;
|
||||
sample_rate_half = (sample_rate + 1) / 2;
|
||||
s->root = 2.0 / sqrt(s->frame_len);
|
||||
|
||||
/* calculate number of bands */
|
||||
for (s->num_bands = 1; s->num_bands < 25; s->num_bands++)
|
||||
if (sample_rate_half <= ff_wma_critical_freqs[s->num_bands - 1])
|
||||
break;
|
||||
|
||||
s->bands = av_malloc((s->num_bands + 1) * sizeof(*s->bands));
|
||||
if (!s->bands)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
/* populate bands data */
|
||||
s->bands[0] = 1;
|
||||
for (i = 1; i < s->num_bands; i++)
|
||||
s->bands[i] = ff_wma_critical_freqs[i - 1] * (s->frame_len / 2) / sample_rate_half;
|
||||
s->bands[s->num_bands] = s->frame_len / 2;
|
||||
|
||||
s->first = 1;
|
||||
avctx->sample_fmt = SAMPLE_FMT_S16;
|
||||
|
||||
for (i = 0; i < s->channels; i++)
|
||||
s->coeffs_ptr[i] = s->coeffs + i * s->frame_len;
|
||||
|
||||
if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT)
|
||||
ff_rdft_init(&s->trans.rdft, frame_len_bits, DFT_C2R);
|
||||
else if (CONFIG_BINKAUDIO_DCT_DECODER)
|
||||
ff_dct_init(&s->trans.dct, frame_len_bits, DCT_III);
|
||||
else
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static float get_float(GetBitContext *gb)
|
||||
{
|
||||
int power = get_bits(gb, 5);
|
||||
float f = ldexpf(get_bits_long(gb, 23), power - 23);
|
||||
if (get_bits1(gb))
|
||||
f = -f;
|
||||
return f;
|
||||
}
|
||||
|
||||
static const uint8_t rle_length_tab[16] = {
|
||||
2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode Bink Audio block
|
||||
* @param[out] out Output buffer (must contain s->block_size elements)
|
||||
*/
|
||||
static void decode_block(BinkAudioContext *s, short *out, int use_dct)
|
||||
{
|
||||
int ch, i, j, k;
|
||||
float q, quant[25];
|
||||
int width, coeff;
|
||||
GetBitContext *gb = &s->gb;
|
||||
|
||||
if (use_dct)
|
||||
skip_bits(gb, 2);
|
||||
|
||||
for (ch = 0; ch < s->channels; ch++) {
|
||||
FFTSample *coeffs = s->coeffs_ptr[ch];
|
||||
q = 0.0f;
|
||||
coeffs[0] = get_float(gb) * s->root;
|
||||
coeffs[1] = get_float(gb) * s->root;
|
||||
|
||||
for (i = 0; i < s->num_bands; i++) {
|
||||
/* constant is result of 0.066399999/log10(M_E) */
|
||||
int value = get_bits(gb, 8);
|
||||
quant[i] = expf(FFMIN(value, 95) * 0.15289164787221953823f) * s->root;
|
||||
}
|
||||
|
||||
// find band (k)
|
||||
for (k = 0; s->bands[k] < 1; k++) {
|
||||
q = quant[k];
|
||||
}
|
||||
|
||||
// parse coefficients
|
||||
i = 2;
|
||||
while (i < s->frame_len) {
|
||||
if (get_bits1(gb)) {
|
||||
j = i + rle_length_tab[get_bits(gb, 4)] * 8;
|
||||
} else {
|
||||
j = i + 8;
|
||||
}
|
||||
|
||||
j = FFMIN(j, s->frame_len);
|
||||
|
||||
width = get_bits(gb, 4);
|
||||
if (width == 0) {
|
||||
memset(coeffs + i, 0, (j - i) * sizeof(*coeffs));
|
||||
i = j;
|
||||
while (s->bands[k] * 2 < i)
|
||||
q = quant[k++];
|
||||
} else {
|
||||
while (i < j) {
|
||||
if (s->bands[k] * 2 == i)
|
||||
q = quant[k++];
|
||||
coeff = get_bits(gb, width);
|
||||
if (coeff) {
|
||||
if (get_bits1(gb))
|
||||
coeffs[i] = -q * coeff;
|
||||
else
|
||||
coeffs[i] = q * coeff;
|
||||
} else {
|
||||
coeffs[i] = 0.0f;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
|
||||
coeffs[0] /= 0.5;
|
||||
ff_dct_calc (&s->trans.dct, coeffs);
|
||||
s->dsp.vector_fmul_scalar(coeffs, coeffs, s->frame_len / 2, s->frame_len);
|
||||
}
|
||||
else if (CONFIG_BINKAUDIO_RDFT_DECODER)
|
||||
ff_rdft_calc(&s->trans.rdft, coeffs);
|
||||
}
|
||||
|
||||
if (s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
|
||||
for (i = 0; i < s->channels; i++)
|
||||
for (j = 0; j < s->frame_len; j++)
|
||||
s->coeffs_ptr[i][j] = 385.0 + s->coeffs_ptr[i][j]*(1.0/32767.0);
|
||||
}
|
||||
s->dsp.float_to_int16_interleave(out, (const float **)s->coeffs_ptr, s->frame_len, s->channels);
|
||||
|
||||
if (!s->first) {
|
||||
int count = s->overlap_len * s->channels;
|
||||
int shift = av_log2(count);
|
||||
for (i = 0; i < count; i++) {
|
||||
out[i] = (s->previous[i] * (count - i) + out[i] * i) >> shift;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(s->previous, out + s->block_size,
|
||||
s->overlap_len * s->channels * sizeof(*out));
|
||||
|
||||
s->first = 0;
|
||||
}
|
||||
|
||||
static av_cold int decode_end(AVCodecContext *avctx)
|
||||
{
|
||||
BinkAudioContext * s = avctx->priv_data;
|
||||
av_freep(&s->bands);
|
||||
if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT)
|
||||
ff_rdft_end(&s->trans.rdft);
|
||||
else if (CONFIG_BINKAUDIO_DCT_DECODER)
|
||||
ff_dct_end(&s->trans.dct);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_bits_align32(GetBitContext *s)
|
||||
{
|
||||
int n = (-get_bits_count(s)) & 31;
|
||||
if (n) skip_bits(s, n);
|
||||
}
|
||||
|
||||
static int decode_frame(AVCodecContext *avctx,
|
||||
void *data, int *data_size,
|
||||
AVPacket *avpkt)
|
||||
{
|
||||
BinkAudioContext *s = avctx->priv_data;
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
short *samples = data;
|
||||
short *samples_end = (short*)((uint8_t*)data + *data_size);
|
||||
int reported_size;
|
||||
GetBitContext *gb = &s->gb;
|
||||
|
||||
init_get_bits(gb, buf, buf_size * 8);
|
||||
|
||||
reported_size = get_bits_long(gb, 32);
|
||||
while (get_bits_count(gb) / 8 < buf_size &&
|
||||
samples + s->block_size <= samples_end) {
|
||||
decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT);
|
||||
samples += s->block_size;
|
||||
get_bits_align32(gb);
|
||||
}
|
||||
|
||||
*data_size = FFMIN(reported_size, (uint8_t*)samples - (uint8_t*)data);
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
AVCodec binkaudio_rdft_decoder = {
|
||||
"binkaudio_rdft",
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
CODEC_ID_BINKAUDIO_RDFT,
|
||||
sizeof(BinkAudioContext),
|
||||
decode_init,
|
||||
NULL,
|
||||
decode_end,
|
||||
decode_frame,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)")
|
||||
};
|
||||
|
||||
AVCodec binkaudio_dct_decoder = {
|
||||
"binkaudio_dct",
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
CODEC_ID_BINKAUDIO_DCT,
|
||||
sizeof(BinkAudioContext),
|
||||
decode_init,
|
||||
NULL,
|
||||
decode_end,
|
||||
decode_frame,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)")
|
||||
};
|
614
src/add-ons/media/plugins/ffmpeg/libavcodec/binkdata.h
Normal file
614
src/add-ons/media/plugins/ffmpeg/libavcodec/binkdata.h
Normal file
@ -0,0 +1,614 @@
|
||||
/*
|
||||
* Bink video decoder
|
||||
* Copyright (C) 2009 Kostya Shishkov
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_BINKDATA_H
|
||||
#define AVCODEC_BINKDATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** Bink DCT and residue 8x8 block scan order */
|
||||
static const uint8_t bink_scan[64] = {
|
||||
0, 1, 8, 9, 2, 3, 10, 11,
|
||||
4, 5, 12, 13, 6, 7, 14, 15,
|
||||
20, 21, 28, 29, 22, 23, 30, 31,
|
||||
16, 17, 24, 25, 32, 33, 40, 41,
|
||||
34, 35, 42, 43, 48, 49, 56, 57,
|
||||
50, 51, 58, 59, 18, 19, 26, 27,
|
||||
36, 37, 44, 45, 38, 39, 46, 47,
|
||||
52, 53, 60, 61, 54, 55, 62, 63
|
||||
};
|
||||
|
||||
static const uint8_t bink_tree_bits[16][16] = {
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D,
|
||||
0x0F, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x01, 0x09, 0x05, 0x15, 0x0D, 0x1D,
|
||||
0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x06, 0x01, 0x09, 0x05, 0x0D, 0x1D,
|
||||
0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x04, 0x02, 0x06, 0x01, 0x09, 0x05, 0x0D,
|
||||
0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x04, 0x02, 0x0A, 0x06, 0x0E, 0x01, 0x09,
|
||||
0x05, 0x0D, 0x03, 0x0B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x0A, 0x06, 0x0E, 0x01, 0x09, 0x05,
|
||||
0x0D, 0x03, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x05, 0x03, 0x13, 0x0B, 0x1B, 0x3B,
|
||||
0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x03, 0x13, 0x0B, 0x2B, 0x1B, 0x3B,
|
||||
0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x05, 0x0D, 0x03, 0x13, 0x0B, 0x1B,
|
||||
0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x01, 0x05, 0x0D, 0x03, 0x13, 0x0B,
|
||||
0x1B, 0x07, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x09, 0x05, 0x0D, 0x03, 0x13, 0x0B,
|
||||
0x1B, 0x07, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x01, 0x03, 0x13, 0x0B, 0x1B, 0x3B,
|
||||
0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x05, 0x03, 0x07, 0x27, 0x17, 0x37,
|
||||
0x0F, 0x4F, 0x2F, 0x6F, 0x1F, 0x5F, 0x3F, 0x7F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x05, 0x03, 0x07, 0x17, 0x37, 0x77,
|
||||
0x0F, 0x4F, 0x2F, 0x6F, 0x1F, 0x5F, 0x3F, 0x7F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x01, 0x05, 0x03, 0x07, 0x27, 0x17,
|
||||
0x37, 0x0F, 0x2F, 0x6F, 0x1F, 0x5F, 0x3F, 0x7F,
|
||||
},
|
||||
};
|
||||
|
||||
static const uint8_t bink_tree_lens[16][16] = {
|
||||
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 },
|
||||
{ 1, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 },
|
||||
{ 2, 2, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 },
|
||||
{ 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 },
|
||||
{ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5 },
|
||||
{ 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5 },
|
||||
{ 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5 },
|
||||
{ 1, 3, 3, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
|
||||
{ 1, 2, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
|
||||
{ 1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6 },
|
||||
{ 2, 2, 3, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 },
|
||||
{ 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 },
|
||||
{ 2, 2, 2, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
|
||||
{ 1, 3, 3, 3, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7 },
|
||||
{ 1, 3, 3, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 },
|
||||
{ 2, 2, 3, 3, 3, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7 },
|
||||
};
|
||||
|
||||
static const uint8_t bink_patterns[16][64] = {
|
||||
{
|
||||
0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38,
|
||||
0x39, 0x31, 0x29, 0x21, 0x19, 0x11, 0x09, 0x01,
|
||||
0x02, 0x0A, 0x12, 0x1A, 0x22, 0x2A, 0x32, 0x3A,
|
||||
0x3B, 0x33, 0x2B, 0x23, 0x1B, 0x13, 0x0B, 0x03,
|
||||
0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C,
|
||||
0x3D, 0x35, 0x2D, 0x25, 0x1D, 0x15, 0x0D, 0x05,
|
||||
0x06, 0x0E, 0x16, 0x1E, 0x26, 0x2E, 0x36, 0x3E,
|
||||
0x3F, 0x37, 0x2F, 0x27, 0x1F, 0x17, 0x0F, 0x07,
|
||||
},
|
||||
{
|
||||
0x3B, 0x3A, 0x39, 0x38, 0x30, 0x31, 0x32, 0x33,
|
||||
0x2B, 0x2A, 0x29, 0x28, 0x20, 0x21, 0x22, 0x23,
|
||||
0x1B, 0x1A, 0x19, 0x18, 0x10, 0x11, 0x12, 0x13,
|
||||
0x0B, 0x0A, 0x09, 0x08, 0x00, 0x01, 0x02, 0x03,
|
||||
0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C,
|
||||
0x14, 0x15, 0x16, 0x17, 0x1F, 0x1E, 0x1D, 0x1C,
|
||||
0x24, 0x25, 0x26, 0x27, 0x2F, 0x2E, 0x2D, 0x2C,
|
||||
0x34, 0x35, 0x36, 0x37, 0x3F, 0x3E, 0x3D, 0x3C,
|
||||
},
|
||||
{
|
||||
0x19, 0x11, 0x12, 0x1A, 0x1B, 0x13, 0x0B, 0x03,
|
||||
0x02, 0x0A, 0x09, 0x01, 0x00, 0x08, 0x10, 0x18,
|
||||
0x20, 0x28, 0x30, 0x38, 0x39, 0x31, 0x29, 0x2A,
|
||||
0x32, 0x3A, 0x3B, 0x33, 0x2B, 0x23, 0x22, 0x21,
|
||||
0x1D, 0x15, 0x16, 0x1E, 0x1F, 0x17, 0x0F, 0x07,
|
||||
0x06, 0x0E, 0x0D, 0x05, 0x04, 0x0C, 0x14, 0x1C,
|
||||
0x24, 0x2C, 0x34, 0x3C, 0x3D, 0x35, 0x2D, 0x2E,
|
||||
0x36, 0x3E, 0x3F, 0x37, 0x2F, 0x27, 0x26, 0x25,
|
||||
},
|
||||
{
|
||||
0x03, 0x0B, 0x02, 0x0A, 0x01, 0x09, 0x00, 0x08,
|
||||
0x10, 0x18, 0x11, 0x19, 0x12, 0x1A, 0x13, 0x1B,
|
||||
0x23, 0x2B, 0x22, 0x2A, 0x21, 0x29, 0x20, 0x28,
|
||||
0x30, 0x38, 0x31, 0x39, 0x32, 0x3A, 0x33, 0x3B,
|
||||
0x3C, 0x34, 0x3D, 0x35, 0x3E, 0x36, 0x3F, 0x37,
|
||||
0x2F, 0x27, 0x2E, 0x26, 0x2D, 0x25, 0x2C, 0x24,
|
||||
0x1C, 0x14, 0x1D, 0x15, 0x1E, 0x16, 0x1F, 0x17,
|
||||
0x0F, 0x07, 0x0E, 0x06, 0x0D, 0x05, 0x0C, 0x04,
|
||||
},
|
||||
{
|
||||
0x18, 0x19, 0x10, 0x11, 0x08, 0x09, 0x00, 0x01,
|
||||
0x02, 0x03, 0x0A, 0x0B, 0x12, 0x13, 0x1A, 0x1B,
|
||||
0x1C, 0x1D, 0x14, 0x15, 0x0C, 0x0D, 0x04, 0x05,
|
||||
0x06, 0x07, 0x0E, 0x0F, 0x16, 0x17, 0x1E, 0x1F,
|
||||
0x27, 0x26, 0x2F, 0x2E, 0x37, 0x36, 0x3F, 0x3E,
|
||||
0x3D, 0x3C, 0x35, 0x34, 0x2D, 0x2C, 0x25, 0x24,
|
||||
0x23, 0x22, 0x2B, 0x2A, 0x33, 0x32, 0x3B, 0x3A,
|
||||
0x39, 0x38, 0x31, 0x30, 0x29, 0x28, 0x21, 0x20,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B,
|
||||
0x20, 0x21, 0x22, 0x23, 0x28, 0x29, 0x2A, 0x2B,
|
||||
0x30, 0x31, 0x32, 0x33, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||
0x24, 0x25, 0x26, 0x27, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x34, 0x35, 0x36, 0x37, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
},
|
||||
{
|
||||
0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x05, 0x0C, 0x04,
|
||||
0x03, 0x0B, 0x02, 0x0A, 0x09, 0x01, 0x00, 0x08,
|
||||
0x10, 0x18, 0x11, 0x19, 0x12, 0x1A, 0x13, 0x1B,
|
||||
0x14, 0x1C, 0x15, 0x1D, 0x16, 0x1E, 0x17, 0x1F,
|
||||
0x27, 0x2F, 0x26, 0x2E, 0x25, 0x2D, 0x24, 0x2C,
|
||||
0x23, 0x2B, 0x22, 0x2A, 0x21, 0x29, 0x20, 0x28,
|
||||
0x31, 0x30, 0x38, 0x39, 0x3A, 0x32, 0x3B, 0x33,
|
||||
0x3C, 0x34, 0x3D, 0x35, 0x36, 0x37, 0x3F, 0x3E,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x2F, 0x2E, 0x2D, 0x2C, 0x2B, 0x2A, 0x29, 0x28,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x09, 0x01, 0x02, 0x03, 0x0B, 0x0A,
|
||||
0x12, 0x13, 0x1B, 0x1A, 0x19, 0x11, 0x10, 0x18,
|
||||
0x20, 0x28, 0x29, 0x21, 0x22, 0x23, 0x2B, 0x2A,
|
||||
0x32, 0x31, 0x30, 0x38, 0x39, 0x3A, 0x3B, 0x33,
|
||||
0x34, 0x3C, 0x3D, 0x3E, 0x3F, 0x37, 0x36, 0x35,
|
||||
0x2D, 0x2C, 0x24, 0x25, 0x26, 0x2E, 0x2F, 0x27,
|
||||
0x1F, 0x17, 0x16, 0x1E, 0x1D, 0x1C, 0x14, 0x15,
|
||||
0x0D, 0x0C, 0x04, 0x05, 0x06, 0x0E, 0x0F, 0x07,
|
||||
},
|
||||
{
|
||||
0x18, 0x19, 0x10, 0x11, 0x08, 0x09, 0x00, 0x01,
|
||||
0x02, 0x03, 0x0A, 0x0B, 0x12, 0x13, 0x1A, 0x1B,
|
||||
0x1C, 0x1D, 0x14, 0x15, 0x0C, 0x0D, 0x04, 0x05,
|
||||
0x06, 0x07, 0x0E, 0x0F, 0x16, 0x17, 0x1E, 0x1F,
|
||||
0x26, 0x27, 0x2E, 0x2F, 0x36, 0x37, 0x3E, 0x3F,
|
||||
0x3C, 0x3D, 0x34, 0x35, 0x2C, 0x2D, 0x24, 0x25,
|
||||
0x22, 0x23, 0x2A, 0x2B, 0x32, 0x33, 0x3A, 0x3B,
|
||||
0x38, 0x39, 0x30, 0x31, 0x28, 0x29, 0x20, 0x21,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x01, 0x09, 0x02, 0x0A, 0x03, 0x0B,
|
||||
0x13, 0x1B, 0x12, 0x1A, 0x11, 0x19, 0x10, 0x18,
|
||||
0x20, 0x28, 0x21, 0x29, 0x22, 0x2A, 0x23, 0x2B,
|
||||
0x33, 0x3B, 0x32, 0x3A, 0x31, 0x39, 0x30, 0x38,
|
||||
0x3C, 0x34, 0x3D, 0x35, 0x3E, 0x36, 0x3F, 0x37,
|
||||
0x2F, 0x27, 0x2E, 0x26, 0x2D, 0x25, 0x2C, 0x24,
|
||||
0x1F, 0x17, 0x1E, 0x16, 0x1D, 0x15, 0x1C, 0x14,
|
||||
0x0C, 0x04, 0x0D, 0x05, 0x0E, 0x06, 0x0F, 0x07,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x10, 0x18, 0x19, 0x1A, 0x1B, 0x13,
|
||||
0x0B, 0x03, 0x02, 0x01, 0x09, 0x11, 0x12, 0x0A,
|
||||
0x04, 0x0C, 0x14, 0x1C, 0x1D, 0x1E, 0x1F, 0x17,
|
||||
0x0F, 0x07, 0x06, 0x05, 0x0D, 0x15, 0x16, 0x0E,
|
||||
0x24, 0x2C, 0x34, 0x3C, 0x3D, 0x3E, 0x3F, 0x37,
|
||||
0x2F, 0x27, 0x26, 0x25, 0x2D, 0x35, 0x36, 0x2E,
|
||||
0x20, 0x28, 0x30, 0x38, 0x39, 0x3A, 0x3B, 0x33,
|
||||
0x2B, 0x23, 0x22, 0x21, 0x29, 0x31, 0x32, 0x2A,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x09, 0x01, 0x02, 0x03, 0x0B, 0x0A,
|
||||
0x13, 0x1B, 0x1A, 0x12, 0x11, 0x10, 0x18, 0x19,
|
||||
0x21, 0x20, 0x28, 0x29, 0x2A, 0x22, 0x23, 0x2B,
|
||||
0x33, 0x3B, 0x3A, 0x32, 0x31, 0x39, 0x38, 0x30,
|
||||
0x34, 0x3C, 0x3D, 0x35, 0x36, 0x3E, 0x3F, 0x37,
|
||||
0x2F, 0x27, 0x26, 0x2E, 0x2D, 0x2C, 0x24, 0x25,
|
||||
0x1D, 0x1C, 0x14, 0x15, 0x16, 0x1E, 0x1F, 0x17,
|
||||
0x0E, 0x0F, 0x07, 0x06, 0x05, 0x0D, 0x0C, 0x04,
|
||||
},
|
||||
{
|
||||
0x18, 0x10, 0x08, 0x00, 0x01, 0x02, 0x03, 0x0B,
|
||||
0x13, 0x1B, 0x1A, 0x19, 0x11, 0x0A, 0x09, 0x12,
|
||||
0x1C, 0x14, 0x0C, 0x04, 0x05, 0x06, 0x07, 0x0F,
|
||||
0x17, 0x1F, 0x1E, 0x1D, 0x15, 0x0E, 0x0D, 0x16,
|
||||
0x3C, 0x34, 0x2C, 0x24, 0x25, 0x26, 0x27, 0x2F,
|
||||
0x37, 0x3F, 0x3E, 0x3D, 0x35, 0x2E, 0x2D, 0x36,
|
||||
0x38, 0x30, 0x28, 0x20, 0x21, 0x22, 0x23, 0x2B,
|
||||
0x33, 0x3B, 0x3A, 0x39, 0x31, 0x2A, 0x29, 0x32,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x09, 0x01, 0x02, 0x0A, 0x12, 0x11,
|
||||
0x10, 0x18, 0x19, 0x1A, 0x1B, 0x13, 0x0B, 0x03,
|
||||
0x07, 0x06, 0x0E, 0x0F, 0x17, 0x16, 0x15, 0x0D,
|
||||
0x05, 0x04, 0x0C, 0x14, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||
0x3F, 0x3E, 0x36, 0x37, 0x2F, 0x2E, 0x2D, 0x35,
|
||||
0x3D, 0x3C, 0x34, 0x2C, 0x24, 0x25, 0x26, 0x27,
|
||||
0x38, 0x30, 0x31, 0x39, 0x3A, 0x32, 0x2A, 0x29,
|
||||
0x28, 0x20, 0x21, 0x22, 0x23, 0x2B, 0x33, 0x3B,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x08, 0x09, 0x10, 0x11, 0x18, 0x19,
|
||||
0x20, 0x21, 0x28, 0x29, 0x30, 0x31, 0x38, 0x39,
|
||||
0x3A, 0x3B, 0x32, 0x33, 0x2A, 0x2B, 0x22, 0x23,
|
||||
0x1A, 0x1B, 0x12, 0x13, 0x0A, 0x0B, 0x02, 0x03,
|
||||
0x04, 0x05, 0x0C, 0x0D, 0x14, 0x15, 0x1C, 0x1D,
|
||||
0x24, 0x25, 0x2C, 0x2D, 0x34, 0x35, 0x3C, 0x3D,
|
||||
0x3E, 0x3F, 0x36, 0x37, 0x2E, 0x2F, 0x26, 0x27,
|
||||
0x1E, 0x1F, 0x16, 0x17, 0x0E, 0x0F, 0x06, 0x07,
|
||||
}
|
||||
};
|
||||
|
||||
static const uint32_t bink_intra_quant[16][64] = {
|
||||
{
|
||||
0x010000, 0x016315, 0x01E83D, 0x02A535, 0x014E7B, 0x016577, 0x02F1E6, 0x02724C,
|
||||
0x010000, 0x00EEDA, 0x024102, 0x017F9B, 0x00BE80, 0x00611E, 0x01083C, 0x00A552,
|
||||
0x021F88, 0x01DC53, 0x027FAD, 0x01F697, 0x014819, 0x00A743, 0x015A31, 0x009688,
|
||||
0x02346F, 0x030EE5, 0x01FBFA, 0x02C096, 0x01D000, 0x028396, 0x019247, 0x01F9AA,
|
||||
0x02346F, 0x01FBFA, 0x01DC53, 0x0231B8, 0x012F12, 0x01E06C, 0x00CB10, 0x0119A8,
|
||||
0x01C48C, 0x019748, 0x014E86, 0x0122AF, 0x02C628, 0x027F20, 0x0297B5, 0x023F32,
|
||||
0x025000, 0x01AB6B, 0x01D122, 0x0159B3, 0x012669, 0x008D43, 0x00EE1F, 0x0075ED,
|
||||
0x01490C, 0x010288, 0x00F735, 0x00EF51, 0x00E0F1, 0x0072AD, 0x00A4D8, 0x006517,
|
||||
},
|
||||
{
|
||||
0x015555, 0x01D971, 0x028AFC, 0x0386F1, 0x01BDF9, 0x01DC9F, 0x03ED33, 0x034311,
|
||||
0x015555, 0x013E78, 0x030158, 0x01FF7A, 0x00FE00, 0x00817D, 0x01604F, 0x00DC6D,
|
||||
0x02D4B5, 0x027B19, 0x0354E7, 0x029E1F, 0x01B577, 0x00DF04, 0x01CD96, 0x00C8B6,
|
||||
0x02F095, 0x0413DC, 0x02A54E, 0x03AB73, 0x026AAB, 0x035A1E, 0x02185E, 0x02A238,
|
||||
0x02F095, 0x02A54E, 0x027B19, 0x02ECF5, 0x019418, 0x028090, 0x010EC0, 0x01778A,
|
||||
0x025B66, 0x021F0B, 0x01BE09, 0x018394, 0x03B2E0, 0x03542A, 0x0374F1, 0x02FEEE,
|
||||
0x031555, 0x0239E4, 0x026C2D, 0x01CCEE, 0x01888C, 0x00BC59, 0x013D7E, 0x009D3C,
|
||||
0x01B6BB, 0x0158B5, 0x01499C, 0x013F17, 0x012BEC, 0x0098E6, 0x00DBCB, 0x0086C9,
|
||||
},
|
||||
{
|
||||
0x01AAAB, 0x024FCE, 0x032DBB, 0x0468AD, 0x022D78, 0x0253C7, 0x04E87F, 0x0413D5,
|
||||
0x01AAAB, 0x018E16, 0x03C1AE, 0x027F58, 0x013D80, 0x00A1DC, 0x01B863, 0x011388,
|
||||
0x0389E2, 0x0319DF, 0x042A21, 0x0345A7, 0x0222D4, 0x0116C5, 0x0240FC, 0x00FAE3,
|
||||
0x03ACBA, 0x0518D3, 0x034EA1, 0x04964F, 0x030555, 0x0430A5, 0x029E76, 0x034AC5,
|
||||
0x03ACBA, 0x034EA1, 0x0319DF, 0x03A833, 0x01F91E, 0x0320B4, 0x015270, 0x01D56D,
|
||||
0x02F23F, 0x02A6CE, 0x022D8B, 0x01E479, 0x049F98, 0x042935, 0x04522D, 0x03BEA9,
|
||||
0x03DAAB, 0x02C85D, 0x030738, 0x02402A, 0x01EAAF, 0x00EB6F, 0x018CDE, 0x00C48A,
|
||||
0x022469, 0x01AEE2, 0x019C02, 0x018EDD, 0x0176E7, 0x00BF20, 0x0112BE, 0x00A87B,
|
||||
},
|
||||
{
|
||||
0x020000, 0x02C62A, 0x03D07A, 0x054A69, 0x029CF6, 0x02CAEF, 0x05E3CC, 0x04E499,
|
||||
0x020000, 0x01DDB4, 0x048204, 0x02FF36, 0x017D01, 0x00C23C, 0x021077, 0x014AA3,
|
||||
0x043F0F, 0x03B8A6, 0x04FF5A, 0x03ED2E, 0x029032, 0x014E86, 0x02B461, 0x012D11,
|
||||
0x0468DF, 0x061DCA, 0x03F7F5, 0x05812C, 0x03A000, 0x05072C, 0x03248D, 0x03F353,
|
||||
0x0468DF, 0x03F7F5, 0x03B8A6, 0x046370, 0x025E24, 0x03C0D8, 0x019620, 0x02334F,
|
||||
0x038919, 0x032E91, 0x029D0D, 0x02455E, 0x058C50, 0x04FE3F, 0x052F69, 0x047E65,
|
||||
0x04A000, 0x0356D6, 0x03A243, 0x02B365, 0x024CD2, 0x011A85, 0x01DC3E, 0x00EBD9,
|
||||
0x029218, 0x020510, 0x01EE69, 0x01DEA2, 0x01C1E2, 0x00E559, 0x0149B0, 0x00CA2D,
|
||||
},
|
||||
{
|
||||
0x02AAAB, 0x03B2E3, 0x0515F8, 0x070DE2, 0x037BF2, 0x03B93E, 0x07DA65, 0x068621,
|
||||
0x02AAAB, 0x027CF0, 0x0602B1, 0x03FEF3, 0x01FC01, 0x0102FA, 0x02C09F, 0x01B8DA,
|
||||
0x05A96A, 0x04F632, 0x06A9CE, 0x053C3E, 0x036AED, 0x01BE09, 0x039B2D, 0x01916B,
|
||||
0x05E129, 0x0827B8, 0x054A9C, 0x0756E5, 0x04D555, 0x06B43B, 0x0430BC, 0x05446F,
|
||||
0x05E129, 0x054A9C, 0x04F632, 0x05D9EB, 0x032830, 0x050121, 0x021D80, 0x02EF14,
|
||||
0x04B6CC, 0x043E16, 0x037C11, 0x030728, 0x0765C0, 0x06A855, 0x06E9E2, 0x05FDDB,
|
||||
0x062AAB, 0x0473C8, 0x04D85A, 0x0399DC, 0x031118, 0x0178B2, 0x027AFD, 0x013A77,
|
||||
0x036D76, 0x02B16A, 0x029337, 0x027E2E, 0x0257D8, 0x0131CC, 0x01B796, 0x010D91,
|
||||
},
|
||||
{
|
||||
0x038000, 0x04DACA, 0x06ACD5, 0x094238, 0x0492AE, 0x04E322, 0x0A4EA5, 0x08900C,
|
||||
0x038000, 0x0343FB, 0x07E388, 0x053E9F, 0x029AC1, 0x0153E8, 0x039CD0, 0x02429E,
|
||||
0x076E5B, 0x068322, 0x08BEDE, 0x06DF11, 0x047C57, 0x02496B, 0x04BBAB, 0x020EDD,
|
||||
0x07B786, 0x0AB421, 0x06F1ED, 0x09A20D, 0x065800, 0x08CC8E, 0x057FF7, 0x06E9D2,
|
||||
0x07B786, 0x06F1ED, 0x068322, 0x07AE04, 0x0424BF, 0x06917B, 0x02C6B8, 0x03D9CB,
|
||||
0x062FEB, 0x05917D, 0x0492D7, 0x03F964, 0x09B58C, 0x08BCEF, 0x0912F8, 0x07DD30,
|
||||
0x081800, 0x05D7F7, 0x065BF6, 0x04B9F1, 0x040670, 0x01EE69, 0x03416C, 0x019CBC,
|
||||
0x047FAA, 0x0388DC, 0x036138, 0x03459C, 0x03134C, 0x01915C, 0x0240F5, 0x0161CF,
|
||||
},
|
||||
{
|
||||
0x040000, 0x058C54, 0x07A0F4, 0x0A94D3, 0x0539EC, 0x0595DD, 0x0BC798, 0x09C932,
|
||||
0x040000, 0x03BB68, 0x090409, 0x05FE6D, 0x02FA01, 0x018477, 0x0420EE, 0x029547,
|
||||
0x087E1F, 0x07714C, 0x09FEB5, 0x07DA5D, 0x052064, 0x029D0D, 0x0568C3, 0x025A21,
|
||||
0x08D1BE, 0x0C3B94, 0x07EFEA, 0x0B0258, 0x074000, 0x0A0E59, 0x06491A, 0x07E6A7,
|
||||
0x08D1BE, 0x07EFEA, 0x07714C, 0x08C6E0, 0x04BC48, 0x0781B1, 0x032C3F, 0x04669F,
|
||||
0x071232, 0x065D22, 0x053A1A, 0x048ABC, 0x0B18A0, 0x09FC7F, 0x0A5ED3, 0x08FCC9,
|
||||
0x094000, 0x06ADAC, 0x074487, 0x0566CA, 0x0499A5, 0x02350B, 0x03B87B, 0x01D7B3,
|
||||
0x052430, 0x040A20, 0x03DCD3, 0x03BD45, 0x0383C5, 0x01CAB3, 0x029361, 0x01945A,
|
||||
},
|
||||
{
|
||||
0x050000, 0x06EF69, 0x098931, 0x0D3A07, 0x068867, 0x06FB55, 0x0EB97E, 0x0C3B7E,
|
||||
0x050000, 0x04AA42, 0x0B450B, 0x077E08, 0x03B881, 0x01E595, 0x05292A, 0x033A99,
|
||||
0x0A9DA7, 0x094D9F, 0x0C7E62, 0x09D0F4, 0x06687D, 0x034450, 0x06C2F4, 0x02F0AA,
|
||||
0x0B062D, 0x0F4A78, 0x09EBE4, 0x0DC2EE, 0x091000, 0x0C91EF, 0x07DB61, 0x09E050,
|
||||
0x0B062D, 0x09EBE4, 0x094D9F, 0x0AF898, 0x05EB59, 0x09621D, 0x03F74F, 0x058046,
|
||||
0x08D6BE, 0x07F46A, 0x0688A0, 0x05AD6B, 0x0DDEC8, 0x0C7B9F, 0x0CF687, 0x0B3BFB,
|
||||
0x0B9000, 0x085917, 0x0915A8, 0x06C07D, 0x05C00E, 0x02C24D, 0x04A69A, 0x024D9F,
|
||||
0x066D3C, 0x050CA7, 0x04D407, 0x04AC96, 0x0464B6, 0x023D5F, 0x033839, 0x01F971,
|
||||
},
|
||||
{
|
||||
0x060000, 0x08527E, 0x0B716E, 0x0FDF3C, 0x07D6E1, 0x0860CC, 0x11AB63, 0x0EADCB,
|
||||
0x060000, 0x05991C, 0x0D860D, 0x08FDA3, 0x047702, 0x0246B3, 0x063165, 0x03DFEA,
|
||||
0x0CBD2E, 0x0B29F1, 0x0EFE0F, 0x0BC78B, 0x07B096, 0x03EB93, 0x081D24, 0x038732,
|
||||
0x0D3A9C, 0x12595D, 0x0BE7DF, 0x108384, 0x0AE000, 0x0F1585, 0x096DA8, 0x0BD9FA,
|
||||
0x0D3A9C, 0x0BE7DF, 0x0B29F1, 0x0D2A50, 0x071A6B, 0x0B4289, 0x04C25F, 0x0699EE,
|
||||
0x0A9B4A, 0x098BB2, 0x07D727, 0x06D01A, 0x10A4F0, 0x0EFABE, 0x0F8E3C, 0x0D7B2E,
|
||||
0x0DE000, 0x0A0482, 0x0AE6CA, 0x081A2F, 0x06E677, 0x034F90, 0x0594B9, 0x02C38C,
|
||||
0x07B649, 0x060F2F, 0x05CB3C, 0x059BE7, 0x0545A7, 0x02B00C, 0x03DD11, 0x025E87,
|
||||
},
|
||||
{
|
||||
0x080000, 0x0B18A8, 0x0F41E8, 0x1529A5, 0x0A73D7, 0x0B2BBB, 0x178F2F, 0x139264,
|
||||
0x080000, 0x0776CF, 0x120812, 0x0BFCD9, 0x05F402, 0x0308EF, 0x0841DC, 0x052A8E,
|
||||
0x10FC3E, 0x0EE297, 0x13FD69, 0x0FB4B9, 0x0A40C8, 0x053A1A, 0x0AD186, 0x04B442,
|
||||
0x11A37B, 0x187727, 0x0FDFD4, 0x1604B0, 0x0E8000, 0x141CB1, 0x0C9235, 0x0FCD4D,
|
||||
0x11A37B, 0x0FDFD4, 0x0EE297, 0x118DC0, 0x09788F, 0x0F0362, 0x06587F, 0x08CD3D,
|
||||
0x0E2463, 0x0CBA43, 0x0A7434, 0x091577, 0x163140, 0x13F8FE, 0x14BDA5, 0x11F992,
|
||||
0x128000, 0x0D5B58, 0x0E890D, 0x0ACD94, 0x093349, 0x046A15, 0x0770F7, 0x03AF65,
|
||||
0x0A4861, 0x08143F, 0x07B9A6, 0x077A89, 0x070789, 0x039565, 0x0526C2, 0x0328B4,
|
||||
},
|
||||
{
|
||||
0x0C0000, 0x10A4FD, 0x16E2DB, 0x1FBE78, 0x0FADC3, 0x10C198, 0x2356C7, 0x1D5B96,
|
||||
0x0C0000, 0x0B3237, 0x1B0C1A, 0x11FB46, 0x08EE03, 0x048D66, 0x0C62CA, 0x07BFD5,
|
||||
0x197A5D, 0x1653E3, 0x1DFC1E, 0x178F16, 0x0F612C, 0x07D727, 0x103A49, 0x070E64,
|
||||
0x1A7539, 0x24B2BB, 0x17CFBD, 0x210709, 0x15C000, 0x1E2B0A, 0x12DB4F, 0x17B3F4,
|
||||
0x1A7539, 0x17CFBD, 0x1653E3, 0x1A54A0, 0x0E34D7, 0x168513, 0x0984BE, 0x0D33DC,
|
||||
0x153695, 0x131765, 0x0FAE4E, 0x0DA033, 0x2149E1, 0x1DF57D, 0x1F1C78, 0x1AF65B,
|
||||
0x1BC000, 0x140904, 0x15CD94, 0x10345E, 0x0DCCEE, 0x069F20, 0x0B2972, 0x058718,
|
||||
0x0F6C91, 0x0C1E5E, 0x0B9678, 0x0B37CE, 0x0A8B4E, 0x056018, 0x07BA22, 0x04BD0E,
|
||||
},
|
||||
{
|
||||
0x110000, 0x179466, 0x206C0C, 0x2CF87F, 0x16362A, 0x17BCED, 0x321044, 0x299714,
|
||||
0x110000, 0x0FDC79, 0x265125, 0x19794E, 0x0CA685, 0x0672FB, 0x118BF4, 0x0AFA6D,
|
||||
0x241804, 0x1FA181, 0x2A7A80, 0x21600A, 0x15C9A9, 0x0B1B77, 0x16FD3C, 0x09FF0D,
|
||||
0x257B66, 0x33FD33, 0x21BBA2, 0x2EC9F7, 0x1ED000, 0x2ABCF9, 0x1AB6B0, 0x219444,
|
||||
0x257B66, 0x21BBA2, 0x1FA181, 0x254D38, 0x142030, 0x1FE730, 0x0D7C0E, 0x12B423,
|
||||
0x1E0D52, 0x1B0BCF, 0x1636EE, 0x134D9E, 0x2F28A9, 0x2A711B, 0x2C12FF, 0x263256,
|
||||
0x275000, 0x1C621B, 0x1EE33C, 0x16F4DB, 0x138CFB, 0x09616E, 0x0FD00C, 0x07D4B7,
|
||||
0x15D9CE, 0x112B06, 0x106A80, 0x0FE464, 0x0EF004, 0x079D77, 0x0AF25B, 0x06B67F,
|
||||
},
|
||||
{
|
||||
0x160000, 0x1E83CF, 0x29F53D, 0x3A3286, 0x1CBE90, 0x1EB842, 0x40C9C2, 0x35D293,
|
||||
0x160000, 0x1486BA, 0x319630, 0x20F756, 0x105F06, 0x085891, 0x16B51E, 0x0E3506,
|
||||
0x2EB5AA, 0x28EF20, 0x36F8E1, 0x2B30FE, 0x1C3225, 0x0E5FC7, 0x1DC030, 0x0CEFB7,
|
||||
0x308193, 0x4347AC, 0x2BA786, 0x3C8CE5, 0x27E000, 0x374EE7, 0x229212, 0x2B7494,
|
||||
0x308193, 0x2BA786, 0x28EF20, 0x3045D0, 0x1A0B89, 0x29494D, 0x11735D, 0x183469,
|
||||
0x26E410, 0x230039, 0x1CBF8F, 0x18FB09, 0x3D0771, 0x36ECBA, 0x390986, 0x316E52,
|
||||
0x32E000, 0x24BB33, 0x27F8E4, 0x1DB557, 0x194D09, 0x0C23BB, 0x1476A6, 0x0A2256,
|
||||
0x1C470A, 0x1637AD, 0x153E87, 0x1490FA, 0x1354B9, 0x09DAD6, 0x0E2A94, 0x08AFF0,
|
||||
},
|
||||
{
|
||||
0x1C0000, 0x26D64D, 0x3566AA, 0x4A11C2, 0x249572, 0x27190E, 0x527525, 0x44805E,
|
||||
0x1C0000, 0x1A1FD6, 0x3F1C3E, 0x29F4F9, 0x14D607, 0x0A9F44, 0x1CE683, 0x1214F0,
|
||||
0x3B72D9, 0x341911, 0x45F6F0, 0x36F889, 0x23E2BB, 0x124B5B, 0x25DD54, 0x1076E9,
|
||||
0x3DBC30, 0x55A109, 0x378F64, 0x4D1069, 0x32C000, 0x46646C, 0x2BFFB9, 0x374E8E,
|
||||
0x3DBC30, 0x378F64, 0x341911, 0x3D7020, 0x2125F5, 0x348BD6, 0x1635BC, 0x1ECE57,
|
||||
0x317F5B, 0x2C8BEB, 0x2496B6, 0x1FCB22, 0x4DAC61, 0x45E778, 0x4897C2, 0x3EE97F,
|
||||
0x40C000, 0x2EBFB5, 0x32DFAE, 0x25CF86, 0x203380, 0x0F734B, 0x1A0B5F, 0x0CE5E2,
|
||||
0x23FD53, 0x1C46DC, 0x1B09C4, 0x1A2CE1, 0x189A60, 0x0C8AE2, 0x1207A5, 0x0B0E77,
|
||||
},
|
||||
{
|
||||
0x220000, 0x2F28CC, 0x40D818, 0x59F0FE, 0x2C6C53, 0x2F79DA, 0x642089, 0x532E29,
|
||||
0x220000, 0x1FB8F1, 0x4CA24B, 0x32F29C, 0x194D09, 0x0CE5F7, 0x2317E8, 0x15F4DB,
|
||||
0x483007, 0x3F4303, 0x54F4FF, 0x42C014, 0x2B9351, 0x1636EE, 0x2DFA79, 0x13FE1A,
|
||||
0x4AF6CC, 0x67FA67, 0x437743, 0x5D93EE, 0x3DA000, 0x5579F1, 0x356D61, 0x432888,
|
||||
0x4AF6CC, 0x437743, 0x3F4303, 0x4A9A70, 0x284060, 0x3FCE60, 0x1AF81B, 0x256845,
|
||||
0x3C1AA5, 0x36179D, 0x2C6DDD, 0x269B3C, 0x5E5152, 0x54E237, 0x5825FE, 0x4C64AD,
|
||||
0x4EA000, 0x38C437, 0x3DC678, 0x2DE9B5, 0x2719F7, 0x12C2DB, 0x1FA018, 0x0FA96E,
|
||||
0x2BB39B, 0x22560C, 0x20D500, 0x1FC8C8, 0x1DE007, 0x0F3AEE, 0x15E4B7, 0x0D6CFE,
|
||||
},
|
||||
{
|
||||
0x2C0000, 0x3D079E, 0x53EA79, 0x74650C, 0x397D20, 0x3D7083, 0x819383, 0x6BA525,
|
||||
0x2C0000, 0x290D75, 0x632C61, 0x41EEAC, 0x20BE0C, 0x10B121, 0x2D6A3B, 0x1C6A0C,
|
||||
0x5D6B54, 0x51DE40, 0x6DF1C2, 0x5661FB, 0x38644B, 0x1CBF8F, 0x3B8060, 0x19DF6D,
|
||||
0x610326, 0x868F57, 0x574F0B, 0x7919CA, 0x4FC000, 0x6E9DCE, 0x452423, 0x56E928,
|
||||
0x610326, 0x574F0B, 0x51DE40, 0x608BA0, 0x341713, 0x52929A, 0x22E6BA, 0x3068D2,
|
||||
0x4DC821, 0x460071, 0x397F1E, 0x31F611, 0x7A0EE2, 0x6DD974, 0x72130C, 0x62DCA3,
|
||||
0x65C000, 0x497665, 0x4FF1C9, 0x3B6AAE, 0x329A12, 0x184776, 0x28ED4D, 0x1444AC,
|
||||
0x388E14, 0x2C6F5A, 0x2A7D0F, 0x2921F4, 0x26A973, 0x13B5AD, 0x1C5528, 0x115FDF,
|
||||
},
|
||||
};
|
||||
|
||||
static const uint32_t bink_inter_quant[16][64] = {
|
||||
{
|
||||
0x010000, 0x017946, 0x01A5A9, 0x0248DC, 0x016363, 0x0152A7, 0x0243EC, 0x0209EA,
|
||||
0x012000, 0x00E248, 0x01BBDA, 0x015CBC, 0x00A486, 0x0053E0, 0x00F036, 0x008095,
|
||||
0x01B701, 0x016959, 0x01B0B9, 0x0153FD, 0x00F8E7, 0x007EE4, 0x00EA30, 0x007763,
|
||||
0x01B701, 0x0260EB, 0x019DE9, 0x023E1B, 0x017000, 0x01FE6E, 0x012DB5, 0x01A27B,
|
||||
0x01E0D1, 0x01B0B9, 0x018A33, 0x01718D, 0x00D87A, 0x014449, 0x007B9A, 0x00AB71,
|
||||
0x013178, 0x0112EA, 0x00AD08, 0x009BB9, 0x023D97, 0x020437, 0x021CCC, 0x01E6B4,
|
||||
0x018000, 0x012DB5, 0x0146D9, 0x0100CE, 0x00CFD2, 0x006E5C, 0x00B0E4, 0x005A2D,
|
||||
0x00E9CC, 0x00B7B1, 0x00846F, 0x006B85, 0x008337, 0x0042E5, 0x004A10, 0x002831,
|
||||
},
|
||||
{
|
||||
0x015555, 0x01F708, 0x023237, 0x030BD0, 0x01D9D9, 0x01C389, 0x03053B, 0x02B7E3,
|
||||
0x018000, 0x012DB5, 0x024FCE, 0x01D0FA, 0x00DB5D, 0x006FD5, 0x014048, 0x00AB71,
|
||||
0x024957, 0x01E1CC, 0x0240F7, 0x01C551, 0x014BDE, 0x00A92F, 0x013840, 0x009F2F,
|
||||
0x024957, 0x032BE4, 0x0227E1, 0x02FD7A, 0x01EAAB, 0x02A893, 0x019247, 0x022DF9,
|
||||
0x028116, 0x0240F7, 0x020D99, 0x01ECBC, 0x0120A3, 0x01B061, 0x00A4CE, 0x00E497,
|
||||
0x01974B, 0x016E8E, 0x00E6B5, 0x00CFA2, 0x02FCC9, 0x02B04A, 0x02D110, 0x0288F1,
|
||||
0x020000, 0x019247, 0x01B3CC, 0x015668, 0x011518, 0x009325, 0x00EBDA, 0x00783D,
|
||||
0x0137BB, 0x00F4ED, 0x00B093, 0x008F5C, 0x00AEF4, 0x005931, 0x0062BF, 0x003597,
|
||||
},
|
||||
{
|
||||
0x01AAAB, 0x0274CB, 0x02BEC4, 0x03CEC4, 0x02504F, 0x02346C, 0x03C689, 0x0365DC,
|
||||
0x01E000, 0x017922, 0x02E3C1, 0x024539, 0x011235, 0x008BCA, 0x01905A, 0x00D64D,
|
||||
0x02DBAD, 0x025A40, 0x02D134, 0x0236A5, 0x019ED6, 0x00D37B, 0x018650, 0x00C6FB,
|
||||
0x02DBAD, 0x03F6DD, 0x02B1D9, 0x03BCD8, 0x026555, 0x0352B8, 0x01F6D8, 0x02B977,
|
||||
0x03215C, 0x02D134, 0x029100, 0x0267EB, 0x0168CC, 0x021C7A, 0x00CE01, 0x011DBD,
|
||||
0x01FD1E, 0x01CA31, 0x012062, 0x01038A, 0x03BBFB, 0x035C5C, 0x038554, 0x032B2D,
|
||||
0x028000, 0x01F6D8, 0x0220C0, 0x01AC02, 0x015A5E, 0x00B7EF, 0x0126D1, 0x00964C,
|
||||
0x0185A9, 0x013228, 0x00DCB8, 0x00B333, 0x00DAB2, 0x006F7D, 0x007B6F, 0x0042FC,
|
||||
},
|
||||
{
|
||||
0x020000, 0x02F28D, 0x034B52, 0x0491B8, 0x02C6C5, 0x02A54E, 0x0487D8, 0x0413D5,
|
||||
0x024000, 0x01C48F, 0x0377B5, 0x02B977, 0x01490C, 0x00A7BF, 0x01E06C, 0x01012A,
|
||||
0x036E03, 0x02D2B3, 0x036172, 0x02A7FA, 0x01F1CE, 0x00FDC7, 0x01D460, 0x00EEC7,
|
||||
0x036E03, 0x04C1D6, 0x033BD1, 0x047C37, 0x02E000, 0x03FCDD, 0x025B6A, 0x0344F5,
|
||||
0x03C1A1, 0x036172, 0x031466, 0x02E31B, 0x01B0F5, 0x028892, 0x00F735, 0x0156E2,
|
||||
0x0262F1, 0x0225D5, 0x015A10, 0x013772, 0x047B2D, 0x04086E, 0x043998, 0x03CD69,
|
||||
0x030000, 0x025B6A, 0x028DB3, 0x02019B, 0x019FA3, 0x00DCB8, 0x0161C7, 0x00B45B,
|
||||
0x01D398, 0x016F63, 0x0108DD, 0x00D70A, 0x01066F, 0x0085C9, 0x00941F, 0x005062,
|
||||
},
|
||||
{
|
||||
0x02AAAB, 0x03EE11, 0x04646D, 0x0617A0, 0x03B3B2, 0x038713, 0x060A75, 0x056FC6,
|
||||
0x030000, 0x025B6A, 0x049F9B, 0x03A1F4, 0x01B6BB, 0x00DFAA, 0x028090, 0x0156E2,
|
||||
0x0492AE, 0x03C399, 0x0481ED, 0x038AA2, 0x0297BD, 0x01525F, 0x027080, 0x013E5E,
|
||||
0x0492AE, 0x0657C8, 0x044FC1, 0x05FAF4, 0x03D555, 0x055126, 0x03248D, 0x045BF2,
|
||||
0x05022D, 0x0481ED, 0x041B33, 0x03D979, 0x024147, 0x0360C3, 0x01499C, 0x01C92E,
|
||||
0x032E96, 0x02DD1C, 0x01CD6A, 0x019F43, 0x05F991, 0x056093, 0x05A220, 0x0511E1,
|
||||
0x040000, 0x03248D, 0x036799, 0x02ACCF, 0x022A2F, 0x01264B, 0x01D7B5, 0x00F079,
|
||||
0x026F75, 0x01E9D9, 0x016127, 0x011EB8, 0x015DE9, 0x00B262, 0x00C57F, 0x006B2D,
|
||||
},
|
||||
{
|
||||
0x038000, 0x052876, 0x05C3CF, 0x07FF02, 0x04DBD9, 0x04A148, 0x07EDBA, 0x0722B4,
|
||||
0x03F000, 0x0317FB, 0x06117C, 0x04C491, 0x023FD5, 0x01258F, 0x0348BD, 0x01C209,
|
||||
0x060085, 0x04F0B9, 0x05EA87, 0x04A5F5, 0x036728, 0x01BC1C, 0x0333A8, 0x01A1DB,
|
||||
0x060085, 0x085336, 0x05A8AE, 0x07D960, 0x050800, 0x06FA82, 0x041FF9, 0x05B8AE,
|
||||
0x0692DA, 0x05EA87, 0x0563B2, 0x050D6E, 0x02F5AD, 0x046F00, 0x01B09C, 0x02580C,
|
||||
0x042D25, 0x03C235, 0x025D9B, 0x022108, 0x07D78F, 0x070EC1, 0x0764CA, 0x06A777,
|
||||
0x054000, 0x041FF9, 0x0477F9, 0x0382D0, 0x02D75E, 0x018242, 0x026B1D, 0x013B9F,
|
||||
0x03324A, 0x0282ED, 0x01CF83, 0x017851, 0x01CB42, 0x00EA21, 0x010336, 0x008CAC,
|
||||
},
|
||||
{
|
||||
0x040000, 0x05E519, 0x0696A4, 0x092370, 0x058D8A, 0x054A9C, 0x090FB0, 0x0827AA,
|
||||
0x048000, 0x03891F, 0x06EF69, 0x0572EE, 0x029218, 0x014F7E, 0x03C0D8, 0x020254,
|
||||
0x06DC05, 0x05A565, 0x06C2E4, 0x054FF3, 0x03E39B, 0x01FB8E, 0x03A8C0, 0x01DD8D,
|
||||
0x06DC05, 0x0983AC, 0x0677A2, 0x08F86E, 0x05C000, 0x07F9B9, 0x04B6D4, 0x0689EB,
|
||||
0x078343, 0x06C2E4, 0x0628CC, 0x05C635, 0x0361EA, 0x051124, 0x01EE69, 0x02ADC5,
|
||||
0x04C5E1, 0x044BAA, 0x02B41F, 0x026EE5, 0x08F65A, 0x0810DD, 0x087330, 0x079AD1,
|
||||
0x060000, 0x04B6D4, 0x051B65, 0x040337, 0x033F47, 0x01B970, 0x02C38F, 0x0168B6,
|
||||
0x03A730, 0x02DEC6, 0x0211BA, 0x01AE14, 0x020CDD, 0x010B93, 0x01283E, 0x00A0C4,
|
||||
},
|
||||
{
|
||||
0x050000, 0x075E60, 0x083C4D, 0x0B6C4C, 0x06F0ED, 0x069D43, 0x0B539C, 0x0A3194,
|
||||
0x05A000, 0x046B67, 0x08AB44, 0x06CFAA, 0x03369E, 0x01A35E, 0x04B10F, 0x0282E8,
|
||||
0x089307, 0x070EBF, 0x08739C, 0x06A3F0, 0x04DC82, 0x027A72, 0x0492F0, 0x0254F0,
|
||||
0x089307, 0x0BE497, 0x08158B, 0x0B3689, 0x073000, 0x09F827, 0x05E489, 0x082C66,
|
||||
0x096413, 0x08739C, 0x07B2FF, 0x0737C2, 0x043A64, 0x06556D, 0x026A04, 0x035936,
|
||||
0x05F75A, 0x055E94, 0x036127, 0x030A9E, 0x0B33F1, 0x0A1514, 0x0A8FFC, 0x098186,
|
||||
0x078000, 0x05E489, 0x06623F, 0x050405, 0x040F19, 0x0227CC, 0x037473, 0x01C2E3,
|
||||
0x0490FC, 0x039677, 0x029629, 0x021999, 0x029015, 0x014E78, 0x01724E, 0x00C8F5,
|
||||
},
|
||||
{
|
||||
0x060000, 0x08D7A6, 0x09E1F6, 0x0DB528, 0x085450, 0x07EFEA, 0x0D9788, 0x0C3B7E,
|
||||
0x06C000, 0x054DAE, 0x0A671E, 0x082C66, 0x03DB24, 0x01F73E, 0x05A145, 0x03037D,
|
||||
0x0A4A08, 0x087818, 0x0A2455, 0x07F7ED, 0x05D569, 0x02F955, 0x057D20, 0x02CC54,
|
||||
0x0A4A08, 0x0E4582, 0x09B373, 0x0D74A5, 0x08A000, 0x0BF696, 0x07123E, 0x09CEE0,
|
||||
0x0B44E4, 0x0A2455, 0x093D32, 0x08A950, 0x0512DF, 0x0799B6, 0x02E59E, 0x0404A7,
|
||||
0x0728D2, 0x06717F, 0x040E2F, 0x03A657, 0x0D7187, 0x0C194B, 0x0CACC8, 0x0B683A,
|
||||
0x090000, 0x07123E, 0x07A918, 0x0604D2, 0x04DEEA, 0x029629, 0x042556, 0x021D11,
|
||||
0x057AC8, 0x044E28, 0x031A97, 0x02851E, 0x03134C, 0x01915C, 0x01BC5D, 0x00F126,
|
||||
},
|
||||
{
|
||||
0x080000, 0x0BCA33, 0x0D2D48, 0x1246E0, 0x0B1B15, 0x0A9538, 0x121F5F, 0x104F53,
|
||||
0x090000, 0x07123E, 0x0DDED2, 0x0AE5DD, 0x052430, 0x029EFD, 0x0781B1, 0x0404A7,
|
||||
0x0DB80B, 0x0B4ACB, 0x0D85C7, 0x0A9FE7, 0x07C736, 0x03F71D, 0x075180, 0x03BB1A,
|
||||
0x0DB80B, 0x130757, 0x0CEF44, 0x11F0DC, 0x0B8000, 0x0FF372, 0x096DA8, 0x0D13D6,
|
||||
0x0F0686, 0x0D85C7, 0x0C5198, 0x0B8C6A, 0x06C3D4, 0x0A2248, 0x03DCD3, 0x055B8A,
|
||||
0x098BC3, 0x089754, 0x05683E, 0x04DDC9, 0x11ECB4, 0x1021B9, 0x10E661, 0x0F35A3,
|
||||
0x0C0000, 0x096DA8, 0x0A36CB, 0x08066E, 0x067E8E, 0x0372E1, 0x05871E, 0x02D16B,
|
||||
0x074E60, 0x05BD8B, 0x042374, 0x035C28, 0x0419BB, 0x021726, 0x02507C, 0x014188,
|
||||
},
|
||||
{
|
||||
0x0C0000, 0x11AF4C, 0x13C3EC, 0x1B6A50, 0x10A89F, 0x0FDFD4, 0x1B2F0F, 0x1876FD,
|
||||
0x0D8000, 0x0A9B5D, 0x14CE3C, 0x1058CB, 0x07B649, 0x03EE7B, 0x0B4289, 0x0606FB,
|
||||
0x149410, 0x10F030, 0x1448AB, 0x0FEFDA, 0x0BAAD2, 0x05F2AB, 0x0AFA40, 0x0598A7,
|
||||
0x149410, 0x1C8B03, 0x1366E6, 0x1AE949, 0x114000, 0x17ED2B, 0x0E247C, 0x139DC1,
|
||||
0x1689C8, 0x1448AB, 0x127A63, 0x11529F, 0x0A25BE, 0x0F336D, 0x05CB3C, 0x08094E,
|
||||
0x0E51A4, 0x0CE2FE, 0x081C5D, 0x074CAE, 0x1AE30E, 0x183296, 0x195991, 0x16D074,
|
||||
0x120000, 0x0E247C, 0x0F5230, 0x0C09A5, 0x09BDD5, 0x052C51, 0x084AAC, 0x043A21,
|
||||
0x0AF590, 0x089C51, 0x06352E, 0x050A3B, 0x062698, 0x0322B9, 0x0378BA, 0x01E24D,
|
||||
},
|
||||
{
|
||||
0x110000, 0x190DAC, 0x1C0039, 0x26D69C, 0x17998C, 0x167D16, 0x2682AB, 0x22A891,
|
||||
0x132000, 0x0F06C3, 0x1D797F, 0x172876, 0x0AECE7, 0x0591D9, 0x0FF398, 0x0889E3,
|
||||
0x1D2717, 0x17FEEF, 0x1CBC47, 0x1693CA, 0x108754, 0x086D1D, 0x0F8D30, 0x07ED98,
|
||||
0x1D2717, 0x286F9A, 0x1B7C71, 0x261FD3, 0x187000, 0x21E552, 0x140904, 0x1BCA27,
|
||||
0x1FEDDC, 0x1CBC47, 0x1A2D62, 0x188A62, 0x0E6022, 0x1588DA, 0x083540, 0x0B6284,
|
||||
0x1448FE, 0x124192, 0x0B7D84, 0x0A574B, 0x2616FF, 0x2247AA, 0x23E98D, 0x2051FA,
|
||||
0x198000, 0x140904, 0x15B46F, 0x110DAA, 0x0DCCEE, 0x07541E, 0x0BBF1F, 0x05FD04,
|
||||
0x0F868B, 0x0C32C8, 0x08CB57, 0x0723D4, 0x08B6AD, 0x047130, 0x04EB08, 0x02AB42,
|
||||
},
|
||||
{
|
||||
0x160000, 0x206C0C, 0x243C86, 0x3242E8, 0x1E8A79, 0x1D1A59, 0x31D646, 0x2CDA25,
|
||||
0x18C000, 0x13722A, 0x2624C3, 0x1DF820, 0x0E2385, 0x073537, 0x14A4A7, 0x0B0CCC,
|
||||
0x25BA1D, 0x1F0DAE, 0x252FE4, 0x1D37BB, 0x1563D6, 0x0AE78E, 0x142021, 0x0A4288,
|
||||
0x25BA1D, 0x345430, 0x2391FB, 0x31565C, 0x1FA000, 0x2BDD7A, 0x19ED8D, 0x23F68C,
|
||||
0x2951EF, 0x252FE4, 0x21E061, 0x1FC224, 0x129A87, 0x1BDE47, 0x0A9F44, 0x0EBBBA,
|
||||
0x1A4058, 0x17A026, 0x0EDEAB, 0x0D61E9, 0x314AEF, 0x2C5CBE, 0x2E798A, 0x29D380,
|
||||
0x210000, 0x19ED8D, 0x1C16AE, 0x1611AE, 0x11DC06, 0x097BEA, 0x0F3391, 0x07BFE7,
|
||||
0x141787, 0x0FC93E, 0x0B617F, 0x093D6D, 0x0B46C1, 0x05BFA8, 0x065D55, 0x037437,
|
||||
},
|
||||
{
|
||||
0x1C0000, 0x2943B2, 0x2E1E7C, 0x3FF810, 0x26DEC9, 0x250A43, 0x3F6DCE, 0x3915A3,
|
||||
0x1F8000, 0x18BFD8, 0x308BE1, 0x262485, 0x11FEA9, 0x092C75, 0x1A45EB, 0x0E1049,
|
||||
0x300425, 0x2785C6, 0x2F5439, 0x252FA8, 0x1B393F, 0x0DE0E4, 0x199D41, 0x0D0EDC,
|
||||
0x300425, 0x4299B2, 0x2D456E, 0x3ECB00, 0x284000, 0x37D40F, 0x20FFCB, 0x2DC56D,
|
||||
0x3496D3, 0x2F5439, 0x2B1D93, 0x286B74, 0x17AD66, 0x2377FE, 0x0D84E2, 0x12C062,
|
||||
0x21692A, 0x1E11A5, 0x12ECDA, 0x110840, 0x3EBC76, 0x387608, 0x3B2652, 0x353BBA,
|
||||
0x2A0000, 0x20FFCB, 0x23BFC6, 0x1C1681, 0x16BAF1, 0x0C1213, 0x1358E8, 0x09DCF8,
|
||||
0x19924F, 0x141767, 0x0E7C16, 0x0BC28A, 0x0E5A0D, 0x075104, 0x0819B2, 0x04655D,
|
||||
},
|
||||
{
|
||||
0x220000, 0x321B58, 0x380072, 0x4DAD38, 0x2F3318, 0x2CFA2D, 0x4D0556, 0x455122,
|
||||
0x264000, 0x1E0D86, 0x3AF2FE, 0x2E50EB, 0x15D9CE, 0x0B23B2, 0x1FE730, 0x1113C7,
|
||||
0x3A4E2D, 0x2FFDDF, 0x39788E, 0x2D2795, 0x210EA8, 0x10DA39, 0x1F1A61, 0x0FDB2F,
|
||||
0x3A4E2D, 0x50DF33, 0x36F8E1, 0x4C3FA5, 0x30E000, 0x43CAA5, 0x281209, 0x37944D,
|
||||
0x3FDBB7, 0x39788E, 0x345AC4, 0x3114C3, 0x1CC044, 0x2B11B4, 0x106A80, 0x16C509,
|
||||
0x2891FC, 0x248324, 0x16FB08, 0x14AE97, 0x4C2DFD, 0x448F54, 0x47D31B, 0x40A3F5,
|
||||
0x330000, 0x281209, 0x2B68DF, 0x221B53, 0x1B99DB, 0x0EA83B, 0x177E3E, 0x0BFA09,
|
||||
0x1F0D17, 0x18658F, 0x1196AE, 0x0E47A8, 0x116D5A, 0x08E260, 0x09D60F, 0x055684,
|
||||
},
|
||||
{
|
||||
0x2C0000, 0x40D818, 0x48790C, 0x6485D0, 0x3D14F2, 0x3A34B2, 0x63AC8D, 0x59B44A,
|
||||
0x318000, 0x26E454, 0x4C4986, 0x3BF03F, 0x1C470A, 0x0E6A6E, 0x29494D, 0x161998,
|
||||
0x4B743A, 0x3E1B5C, 0x4A5FC7, 0x3A6F75, 0x2AC7AC, 0x15CF1D, 0x284041, 0x148510,
|
||||
0x4B743A, 0x68A861, 0x4723F6, 0x62ACB8, 0x3F4000, 0x57BAF3, 0x33DB1A, 0x47ED19,
|
||||
0x52A3DE, 0x4A5FC7, 0x43C0C2, 0x3F8448, 0x25350D, 0x37BC8E, 0x153E87, 0x1D7775,
|
||||
0x3480B0, 0x2F404C, 0x1DBD56, 0x1AC3D2, 0x6295DE, 0x58B97B, 0x5CF313, 0x53A701,
|
||||
0x420000, 0x33DB1A, 0x382D5C, 0x2C235D, 0x23B80D, 0x12F7D4, 0x1E6723, 0x0F7FCF,
|
||||
0x282F0E, 0x1F927D, 0x16C2FF, 0x127AD9, 0x168D83, 0x0B7F50, 0x0CBAAA, 0x06E86E,
|
||||
},
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_BINKDATA_H */
|
112
src/add-ons/media/plugins/ffmpeg/libavcodec/binkidct.c
Normal file
112
src/add-ons/media/plugins/ffmpeg/libavcodec/binkidct.c
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Bink IDCT algorithm
|
||||
* Copyright (c) 2009 Kostya Shishkov
|
||||
*
|
||||
* 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
|
||||
* Bink IDCT algorithm
|
||||
*/
|
||||
|
||||
#include "dsputil.h"
|
||||
|
||||
#define A1 2896 /* (1/sqrt(2))<<12 */
|
||||
#define A2 2217
|
||||
#define A3 3784
|
||||
#define A4 -5352
|
||||
|
||||
#define IDCT_TRANSFORM(dest,s0,s1,s2,s3,s4,s5,s6,s7,d0,d1,d2,d3,d4,d5,d6,d7,munge,src) {\
|
||||
const int a0 = (src)[s0] + (src)[s4]; \
|
||||
const int a1 = (src)[s0] - (src)[s4]; \
|
||||
const int a2 = (src)[s2] + (src)[s6]; \
|
||||
const int a3 = (A1*((src)[s2] - (src)[s6])) >> 11; \
|
||||
const int a4 = (src)[s5] + (src)[s3]; \
|
||||
const int a5 = (src)[s5] - (src)[s3]; \
|
||||
const int a6 = (src)[s1] + (src)[s7]; \
|
||||
const int a7 = (src)[s1] - (src)[s7]; \
|
||||
const int b0 = a4 + a6; \
|
||||
const int b1 = (A3*(a5 + a7)) >> 11; \
|
||||
const int b2 = ((A4*a5) >> 11) - b0 + b1; \
|
||||
const int b3 = (A1*(a6 - a4) >> 11) - b2; \
|
||||
const int b4 = ((A2*a7) >> 11) + b3 - b1; \
|
||||
(dest)[d0] = munge(a0+a2 +b0); \
|
||||
(dest)[d1] = munge(a1+a3-a2+b2); \
|
||||
(dest)[d2] = munge(a1-a3+a2+b3); \
|
||||
(dest)[d3] = munge(a0-a2 -b4); \
|
||||
(dest)[d4] = munge(a0-a2 +b4); \
|
||||
(dest)[d5] = munge(a1-a3+a2-b3); \
|
||||
(dest)[d6] = munge(a1+a3-a2-b2); \
|
||||
(dest)[d7] = munge(a0+a2 -b0); \
|
||||
}
|
||||
/* end IDCT_TRANSFORM macro */
|
||||
|
||||
#define MUNGE_NONE(x) (x)
|
||||
#define IDCT_COL(dest,src) IDCT_TRANSFORM(dest,0,8,16,24,32,40,48,56,0,8,16,24,32,40,48,56,MUNGE_NONE,src)
|
||||
|
||||
#define MUNGE_ROW(x) (((x) + 0x7F)>>8)
|
||||
#define IDCT_ROW(dest,src) IDCT_TRANSFORM(dest,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,MUNGE_ROW,src)
|
||||
|
||||
static inline void bink_idct_col(DCTELEM *dest, const DCTELEM *src)
|
||||
{
|
||||
if ((src[8]|src[16]|src[24]|src[32]|src[40]|src[48]|src[56])==0) {
|
||||
dest[0] =
|
||||
dest[8] =
|
||||
dest[16] =
|
||||
dest[24] =
|
||||
dest[32] =
|
||||
dest[40] =
|
||||
dest[48] =
|
||||
dest[56] = src[0];
|
||||
} else {
|
||||
IDCT_COL(dest, src);
|
||||
}
|
||||
}
|
||||
|
||||
void ff_bink_idct_c(DCTELEM *block)
|
||||
{
|
||||
int i;
|
||||
DCTELEM temp[64];
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
bink_idct_col(&temp[i], &block[i]);
|
||||
for (i = 0; i < 8; i++) {
|
||||
IDCT_ROW( (&block[8*i]), (&temp[8*i]) );
|
||||
}
|
||||
}
|
||||
|
||||
void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
ff_bink_idct_c(block);
|
||||
for (i = 0; i < 8; i++, dest += linesize, block += 8)
|
||||
for (j = 0; j < 8; j++)
|
||||
dest[j] += block[j];
|
||||
}
|
||||
|
||||
void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block)
|
||||
{
|
||||
int i;
|
||||
DCTELEM temp[64];
|
||||
for (i = 0; i < 8; i++)
|
||||
bink_idct_col(&temp[i], &block[i]);
|
||||
for (i = 0; i < 8; i++) {
|
||||
IDCT_ROW( (&dest[i*linesize]), (&temp[8*i]) );
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
* Common bit i/o utils
|
||||
* Copyright (c) 2000, 2001 Fabrice Bellard
|
||||
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (c) 2010 Loren Merritt
|
||||
*
|
||||
* alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
@ -23,7 +24,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/bitstream.c
|
||||
* @file
|
||||
* bitstream api.
|
||||
*/
|
||||
|
||||
@ -38,25 +39,6 @@ const uint8_t ff_log2_run[32]={
|
||||
8, 9,10,11,12,13,14,15
|
||||
};
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
* Same as av_mallocz_static(), but does a realloc.
|
||||
*
|
||||
* @param[in] ptr The block of memory to reallocate.
|
||||
* @param[in] size The requested size.
|
||||
* @return Block of memory of requested size.
|
||||
* @deprecated. Code which uses ff_realloc_static is broken/misdesigned
|
||||
* and should correctly use static arrays
|
||||
*/
|
||||
attribute_deprecated av_alloc_size(2)
|
||||
static void *ff_realloc_static(void *ptr, unsigned int size);
|
||||
|
||||
static void *ff_realloc_static(void *ptr, unsigned int size)
|
||||
{
|
||||
return av_realloc(ptr, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
void align_put_bits(PutBitContext *s)
|
||||
{
|
||||
#ifdef ALT_BITSTREAM_WRITER
|
||||
@ -66,14 +48,14 @@ void align_put_bits(PutBitContext *s)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ff_put_string(PutBitContext * pbc, const char *s, int terminate_string)
|
||||
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
|
||||
{
|
||||
while(*s){
|
||||
put_bits(pbc, 8, *s);
|
||||
s++;
|
||||
while(*string){
|
||||
put_bits(pb, 8, *string);
|
||||
string++;
|
||||
}
|
||||
if(terminate_string)
|
||||
put_bits(pbc, 8, 0);
|
||||
put_bits(pb, 8, 0);
|
||||
}
|
||||
|
||||
void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
|
||||
@ -124,123 +106,137 @@ static int alloc_table(VLC *vlc, int size, int use_static)
|
||||
index = vlc->table_size;
|
||||
vlc->table_size += size;
|
||||
if (vlc->table_size > vlc->table_allocated) {
|
||||
if(use_static>1)
|
||||
if(use_static)
|
||||
abort(); //cant do anything, init_vlc() is used with too little memory
|
||||
vlc->table_allocated += (1 << vlc->bits);
|
||||
if(use_static)
|
||||
vlc->table = ff_realloc_static(vlc->table,
|
||||
sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
|
||||
else
|
||||
vlc->table = av_realloc(vlc->table,
|
||||
sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
|
||||
vlc->table = av_realloc(vlc->table,
|
||||
sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
|
||||
if (!vlc->table)
|
||||
return -1;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
static int build_table(VLC *vlc, int table_nb_bits,
|
||||
int nb_codes,
|
||||
const void *bits, int bits_wrap, int bits_size,
|
||||
const void *codes, int codes_wrap, int codes_size,
|
||||
const void *symbols, int symbols_wrap, int symbols_size,
|
||||
uint32_t code_prefix, int n_prefix, int flags)
|
||||
static av_always_inline uint32_t bitswap_32(uint32_t x) {
|
||||
return av_reverse[x&0xFF]<<24
|
||||
| av_reverse[(x>>8)&0xFF]<<16
|
||||
| av_reverse[(x>>16)&0xFF]<<8
|
||||
| av_reverse[x>>24];
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint8_t bits;
|
||||
uint16_t symbol;
|
||||
/** codeword, with the first bit-to-be-read in the msb
|
||||
* (even if intended for a little-endian bitstream reader) */
|
||||
uint32_t code;
|
||||
} VLCcode;
|
||||
|
||||
static int compare_vlcspec(const void *a, const void *b)
|
||||
{
|
||||
int i, j, k, n, table_size, table_index, nb, n1, index, code_prefix2, symbol;
|
||||
const VLCcode *sa=a, *sb=b;
|
||||
return (sa->code >> 1) - (sb->code >> 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build VLC decoding tables suitable for use with get_vlc().
|
||||
*
|
||||
* @param vlc the context to be initted
|
||||
*
|
||||
* @param table_nb_bits max length of vlc codes to store directly in this table
|
||||
* (Longer codes are delegated to subtables.)
|
||||
*
|
||||
* @param nb_codes number of elements in codes[]
|
||||
*
|
||||
* @param codes descriptions of the vlc codes
|
||||
* These must be ordered such that codes going into the same subtable are contiguous.
|
||||
* Sorting by VLCcode.code is sufficient, though not necessary.
|
||||
*/
|
||||
static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
|
||||
VLCcode *codes, int flags)
|
||||
{
|
||||
int table_size, table_index, index, code_prefix, symbol, subtable_bits;
|
||||
int i, j, k, n, nb, inc;
|
||||
uint32_t code;
|
||||
VLC_TYPE (*table)[2];
|
||||
|
||||
table_size = 1 << table_nb_bits;
|
||||
table_index = alloc_table(vlc, table_size, flags & (INIT_VLC_USE_STATIC|INIT_VLC_USE_NEW_STATIC));
|
||||
table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC);
|
||||
#ifdef DEBUG_VLC
|
||||
av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d code_prefix=%x n=%d\n",
|
||||
table_index, table_size, code_prefix, n_prefix);
|
||||
av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n",
|
||||
table_index, table_size);
|
||||
#endif
|
||||
if (table_index < 0)
|
||||
return -1;
|
||||
table = &vlc->table[table_index];
|
||||
|
||||
for(i=0;i<table_size;i++) {
|
||||
for (i = 0; i < table_size; i++) {
|
||||
table[i][1] = 0; //bits
|
||||
table[i][0] = -1; //codes
|
||||
}
|
||||
|
||||
/* first pass: map codes and compute auxillary table sizes */
|
||||
for(i=0;i<nb_codes;i++) {
|
||||
GET_DATA(n, bits, i, bits_wrap, bits_size);
|
||||
GET_DATA(code, codes, i, codes_wrap, codes_size);
|
||||
/* we accept tables with holes */
|
||||
if (n <= 0)
|
||||
continue;
|
||||
if (!symbols)
|
||||
symbol = i;
|
||||
else
|
||||
GET_DATA(symbol, symbols, i, symbols_wrap, symbols_size);
|
||||
for (i = 0; i < nb_codes; i++) {
|
||||
n = codes[i].bits;
|
||||
code = codes[i].code;
|
||||
symbol = codes[i].symbol;
|
||||
#if defined(DEBUG_VLC) && 0
|
||||
av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code);
|
||||
#endif
|
||||
/* if code matches the prefix, it is in the table */
|
||||
n -= n_prefix;
|
||||
if(flags & INIT_VLC_LE)
|
||||
code_prefix2= code & (n_prefix>=32 ? 0xffffffff : (1 << n_prefix)-1);
|
||||
else
|
||||
code_prefix2= code >> n;
|
||||
if (n > 0 && code_prefix2 == code_prefix) {
|
||||
if (n <= table_nb_bits) {
|
||||
/* no need to add another table */
|
||||
j = (code << (table_nb_bits - n)) & (table_size - 1);
|
||||
nb = 1 << (table_nb_bits - n);
|
||||
for(k=0;k<nb;k++) {
|
||||
if(flags & INIT_VLC_LE)
|
||||
j = (code >> n_prefix) + (k<<n);
|
||||
if (n <= table_nb_bits) {
|
||||
/* no need to add another table */
|
||||
j = code >> (32 - table_nb_bits);
|
||||
nb = 1 << (table_nb_bits - n);
|
||||
inc = 1;
|
||||
if (flags & INIT_VLC_LE) {
|
||||
j = bitswap_32(code);
|
||||
inc = 1 << n;
|
||||
}
|
||||
for (k = 0; k < nb; k++) {
|
||||
#ifdef DEBUG_VLC
|
||||
av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
|
||||
j, i, n);
|
||||
av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
|
||||
j, i, n);
|
||||
#endif
|
||||
if (table[j][1] /*bits*/ != 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
|
||||
return -1;
|
||||
}
|
||||
table[j][1] = n; //bits
|
||||
table[j][0] = symbol;
|
||||
j++;
|
||||
if (table[j][1] /*bits*/ != 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
n -= table_nb_bits;
|
||||
j = (code >> ((flags & INIT_VLC_LE) ? n_prefix : n)) & ((1 << table_nb_bits) - 1);
|
||||
table[j][1] = n; //bits
|
||||
table[j][0] = symbol;
|
||||
j += inc;
|
||||
}
|
||||
} else {
|
||||
/* fill auxiliary table recursively */
|
||||
n -= table_nb_bits;
|
||||
code_prefix = code >> (32 - table_nb_bits);
|
||||
subtable_bits = n;
|
||||
codes[i].bits = n;
|
||||
codes[i].code = code << table_nb_bits;
|
||||
for (k = i+1; k < nb_codes; k++) {
|
||||
n = codes[k].bits - table_nb_bits;
|
||||
if (n <= 0)
|
||||
break;
|
||||
code = codes[k].code;
|
||||
if (code >> (32 - table_nb_bits) != code_prefix)
|
||||
break;
|
||||
codes[k].bits = n;
|
||||
codes[k].code = code << table_nb_bits;
|
||||
subtable_bits = FFMAX(subtable_bits, n);
|
||||
}
|
||||
subtable_bits = FFMIN(subtable_bits, table_nb_bits);
|
||||
j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix;
|
||||
table[j][1] = -subtable_bits;
|
||||
#ifdef DEBUG_VLC
|
||||
av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n",
|
||||
j, n);
|
||||
av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n",
|
||||
j, codes[i].bits + table_nb_bits);
|
||||
#endif
|
||||
/* compute table size */
|
||||
n1 = -table[j][1]; //bits
|
||||
if (n > n1)
|
||||
n1 = n;
|
||||
table[j][1] = -n1; //bits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* second pass : fill auxillary tables recursively */
|
||||
for(i=0;i<table_size;i++) {
|
||||
n = table[i][1]; //bits
|
||||
if (n < 0) {
|
||||
n = -n;
|
||||
if (n > table_nb_bits) {
|
||||
n = table_nb_bits;
|
||||
table[i][1] = -n; //bits
|
||||
}
|
||||
index = build_table(vlc, n, nb_codes,
|
||||
bits, bits_wrap, bits_size,
|
||||
codes, codes_wrap, codes_size,
|
||||
symbols, symbols_wrap, symbols_size,
|
||||
(flags & INIT_VLC_LE) ? (code_prefix | (i << n_prefix)) : ((code_prefix << table_nb_bits) | i),
|
||||
n_prefix + table_nb_bits, flags);
|
||||
index = build_table(vlc, subtable_bits, k-i, codes+i, flags);
|
||||
if (index < 0)
|
||||
return -1;
|
||||
/* note: realloc has been done, so reload tables */
|
||||
table = &vlc->table[table_index];
|
||||
table[i][0] = index; //code
|
||||
table[j][0] = index; //code
|
||||
i = k-1;
|
||||
}
|
||||
}
|
||||
return table_index;
|
||||
@ -279,6 +275,9 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
|
||||
const void *symbols, int symbols_wrap, int symbols_size,
|
||||
int flags)
|
||||
{
|
||||
VLCcode buf[nb_codes];
|
||||
int i, j;
|
||||
|
||||
vlc->bits = nb_bits;
|
||||
if(flags & INIT_VLC_USE_NEW_STATIC){
|
||||
if(vlc->table_size && vlc->table_size == vlc->table_allocated){
|
||||
@ -286,26 +285,41 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
|
||||
}else if(vlc->table_size){
|
||||
abort(); // fatal error, we are called on a partially initialized table
|
||||
}
|
||||
}else if(!(flags & INIT_VLC_USE_STATIC)) {
|
||||
}else {
|
||||
vlc->table = NULL;
|
||||
vlc->table_allocated = 0;
|
||||
vlc->table_size = 0;
|
||||
} else {
|
||||
/* Static tables are initially always NULL, return
|
||||
if vlc->table != NULL to avoid double allocation */
|
||||
if(vlc->table)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_VLC
|
||||
av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes);
|
||||
#endif
|
||||
|
||||
if (build_table(vlc, nb_bits, nb_codes,
|
||||
bits, bits_wrap, bits_size,
|
||||
codes, codes_wrap, codes_size,
|
||||
symbols, symbols_wrap, symbols_size,
|
||||
0, 0, flags) < 0) {
|
||||
assert(symbols_size <= 2 || !symbols);
|
||||
j = 0;
|
||||
#define COPY(condition)\
|
||||
for (i = 0; i < nb_codes; i++) {\
|
||||
GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\
|
||||
if (!(condition))\
|
||||
continue;\
|
||||
GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\
|
||||
if (flags & INIT_VLC_LE)\
|
||||
buf[j].code = bitswap_32(buf[j].code);\
|
||||
else\
|
||||
buf[j].code <<= 32 - buf[j].bits;\
|
||||
if (symbols)\
|
||||
GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\
|
||||
else\
|
||||
buf[j].symbol = i;\
|
||||
j++;\
|
||||
}
|
||||
COPY(buf[j].bits > nb_bits);
|
||||
// qsort is the slowest part of init_vlc, and could probably be improved or avoided
|
||||
qsort(buf, j, sizeof(VLCcode), compare_vlcspec);
|
||||
COPY(buf[j].bits && buf[j].bits <= nb_bits);
|
||||
nb_codes = j;
|
||||
|
||||
if (build_table(vlc, nb_bits, nb_codes, buf, flags) < 0) {
|
||||
av_freep(&vlc->table);
|
||||
return -1;
|
||||
}
|
||||
|
@ -231,18 +231,37 @@ static int bmp_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
if(avctx->pix_fmt == PIX_FMT_PAL8){
|
||||
int colors = 1 << depth;
|
||||
if(ihsize >= 36){
|
||||
int t;
|
||||
buf = buf0 + 46;
|
||||
t = bytestream_get_le32(&buf);
|
||||
if(t < 0 || t > (1 << depth)){
|
||||
av_log(avctx, AV_LOG_ERROR, "Incorrect number of colors - %X for bitdepth %d\n", t, depth);
|
||||
}else if(t){
|
||||
colors = t;
|
||||
}
|
||||
}
|
||||
buf = buf0 + 14 + ihsize; //palette location
|
||||
if((hsize-ihsize-14)>>depth < 4){ // OS/2 bitmap, 3 bytes per palette entry
|
||||
for(i = 0; i < (1 << depth); i++)
|
||||
if((hsize-ihsize-14) < (colors << 2)){ // OS/2 bitmap, 3 bytes per palette entry
|
||||
for(i = 0; i < colors; i++)
|
||||
((uint32_t*)p->data[1])[i] = bytestream_get_le24(&buf);
|
||||
}else{
|
||||
for(i = 0; i < (1 << depth); i++)
|
||||
for(i = 0; i < colors; i++)
|
||||
((uint32_t*)p->data[1])[i] = bytestream_get_le32(&buf);
|
||||
}
|
||||
buf = buf0 + hsize;
|
||||
}
|
||||
if(comp == BMP_RLE4 || comp == BMP_RLE8){
|
||||
if(height < 0){
|
||||
p->data[0] += p->linesize[0] * (avctx->height - 1);
|
||||
p->linesize[0] = -p->linesize[0];
|
||||
}
|
||||
ff_msrle_decode(avctx, (AVPicture*)p, depth, buf, dsize);
|
||||
if(height < 0){
|
||||
p->data[0] += p->linesize[0] * (avctx->height - 1);
|
||||
p->linesize[0] = -p->linesize[0];
|
||||
}
|
||||
}else{
|
||||
switch(depth){
|
||||
case 1:
|
||||
@ -318,7 +337,7 @@ static av_cold int bmp_decode_end(AVCodecContext *avctx)
|
||||
|
||||
AVCodec bmp_decoder = {
|
||||
"bmp",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_BMP,
|
||||
sizeof(BMPContext),
|
||||
bmp_decode_init,
|
||||
|
@ -133,13 +133,13 @@ static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_s
|
||||
|
||||
AVCodec bmp_encoder = {
|
||||
"bmp",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_BMP,
|
||||
sizeof(BMPContext),
|
||||
bmp_encode_init,
|
||||
bmp_encode_frame,
|
||||
NULL, //encode_end,
|
||||
.pix_fmts = (enum PixelFormat[]){
|
||||
.pix_fmts = (const enum PixelFormat[]){
|
||||
PIX_FMT_BGR24,
|
||||
PIX_FMT_RGB555, PIX_FMT_RGB565,
|
||||
PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8,
|
||||
|
@ -244,7 +244,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
AVCodec c93_decoder = {
|
||||
"c93",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_C93,
|
||||
sizeof(C93DecoderContext),
|
||||
decode_init,
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cabac.c
|
||||
* @file
|
||||
* Context Adaptive Binary Arithmetic Coder.
|
||||
*/
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cabac.h
|
||||
* @file
|
||||
* Context Adaptive Binary Arithmetic Coder.
|
||||
*/
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cavs.c
|
||||
* @file
|
||||
* Chinese AVS video (AVS1-P2, JiZhun profile) decoder
|
||||
* @author Stefan Gehrer <stefan.gehrer@gmx.de>
|
||||
*/
|
||||
@ -73,7 +73,7 @@ static inline int get_bs(cavs_vector *mvP, cavs_vector *mvQ, int b) {
|
||||
*
|
||||
*/
|
||||
void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type) {
|
||||
DECLARE_ALIGNED_8(uint8_t, bs[8]);
|
||||
uint8_t bs[8];
|
||||
int qp_avg, alpha, beta, tc;
|
||||
int i;
|
||||
|
||||
@ -93,9 +93,9 @@ void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type) {
|
||||
if(!h->loop_filter_disable) {
|
||||
/* determine bs */
|
||||
if(mb_type == I_8X8)
|
||||
*((uint64_t *)bs) = 0x0202020202020202ULL;
|
||||
memset(bs,2,8);
|
||||
else{
|
||||
*((uint64_t *)bs) = 0;
|
||||
memset(bs,0,8);
|
||||
if(ff_cavs_partition_flags[mb_type] & SPLITV){
|
||||
bs[2] = get_bs(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1], mb_type > P_8X8);
|
||||
bs[3] = get_bs(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3], mb_type > P_8X8);
|
||||
@ -109,7 +109,7 @@ void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type) {
|
||||
bs[4] = get_bs(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0], mb_type > P_8X8);
|
||||
bs[5] = get_bs(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1], mb_type > P_8X8);
|
||||
}
|
||||
if( *((uint64_t *)bs) ) {
|
||||
if(AV_RN64(bs)) {
|
||||
if(h->flags & A_AVAIL) {
|
||||
qp_avg = (h->qp + h->left_qp + 1) >> 1;
|
||||
SET_PARAMS;
|
||||
@ -572,7 +572,7 @@ void ff_cavs_init_mb(AVSContext *h) {
|
||||
/**
|
||||
* save predictors for later macroblocks and increase
|
||||
* macroblock address
|
||||
* @returns 0 if end of frame is reached, 1 otherwise
|
||||
* @return 0 if end of frame is reached, 1 otherwise
|
||||
*/
|
||||
int ff_cavs_next_mb(AVSContext *h) {
|
||||
int i;
|
||||
|
@ -136,7 +136,7 @@ enum cavs_mv_loc {
|
||||
MV_BWD_X3
|
||||
};
|
||||
|
||||
DECLARE_ALIGNED_8(typedef, struct) {
|
||||
DECLARE_ALIGNED(8, typedef, struct) {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t dist;
|
||||
@ -160,6 +160,7 @@ typedef struct {
|
||||
int aspect_ratio;
|
||||
int mb_width, mb_height;
|
||||
int pic_type;
|
||||
int stream_revision; ///<0 for samples from 2006, 1 for rm52j encoder
|
||||
int progressive;
|
||||
int pic_structure;
|
||||
int skip_mode_flag; ///< select between skip_count or one skip_flag per MB
|
||||
@ -247,8 +248,13 @@ static inline void modify_pred(const int_fast8_t *mod_table, int *mode) {
|
||||
}
|
||||
|
||||
static inline void set_intra_mode_default(AVSContext *h) {
|
||||
h->pred_mode_Y[3] = h->pred_mode_Y[6] = INTRA_L_LP;
|
||||
h->top_pred_Y[h->mbx*2+0] = h->top_pred_Y[h->mbx*2+1] = INTRA_L_LP;
|
||||
if(h->stream_revision > 0) {
|
||||
h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
|
||||
h->top_pred_Y[h->mbx*2+0] = h->top_pred_Y[h->mbx*2+1] = NOT_AVAIL;
|
||||
} else {
|
||||
h->pred_mode_Y[3] = h->pred_mode_Y[6] = INTRA_L_LP;
|
||||
h->top_pred_Y[h->mbx*2+0] = h->top_pred_Y[h->mbx*2+1] = INTRA_L_LP;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void set_mvs(cavs_vector *mv, enum cavs_block size) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cavs_parser.c
|
||||
* @file
|
||||
* Chinese AVS video (AVS1-P2, JiZhun profile) parser
|
||||
* @author Stefan Gehrer <stefan.gehrer@gmx.de>
|
||||
*/
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cavsdec.c
|
||||
* @file
|
||||
* Chinese AVS video (AVS1-P2, JiZhun profile) decoder
|
||||
* @author Stefan Gehrer <stefan.gehrer@gmx.de>
|
||||
*/
|
||||
@ -483,6 +483,15 @@ static int decode_pic(AVSContext *h) {
|
||||
h->pic_type = FF_I_TYPE;
|
||||
if(get_bits1(&s->gb))
|
||||
skip_bits(&s->gb,24);//time_code
|
||||
/* old sample clips were all progressive and no low_delay,
|
||||
bump stream revision if detected otherwise */
|
||||
if((s->low_delay) || !(show_bits(&s->gb,9) & 1))
|
||||
h->stream_revision = 1;
|
||||
/* similarly test top_field_first and repeat_first_field */
|
||||
else if(show_bits(&s->gb,11) & 3)
|
||||
h->stream_revision = 1;
|
||||
if(h->stream_revision > 0)
|
||||
skip_bits(&s->gb,1); //marker_bit
|
||||
}
|
||||
/* release last B frame */
|
||||
if(h->picture.data[0])
|
||||
@ -702,7 +711,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
|
||||
|
||||
AVCodec cavs_decoder = {
|
||||
"cavs",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_CAVS,
|
||||
sizeof(AVSContext),
|
||||
ff_cavs_init,
|
||||
|
@ -510,12 +510,7 @@ CAVS_MC(put_, 16)
|
||||
CAVS_MC(avg_, 8)
|
||||
CAVS_MC(avg_, 16)
|
||||
|
||||
void ff_put_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
|
||||
void ff_avg_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
|
||||
void ff_put_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
|
||||
void ff_avg_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
|
||||
|
||||
void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) {
|
||||
av_cold void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) {
|
||||
#define dspfunc(PFX, IDX, NUM) \
|
||||
c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_c; \
|
||||
c->PFX ## _pixels_tab[IDX][ 1] = ff_ ## PFX ## NUM ## _mc10_c; \
|
||||
|
39
src/add-ons/media/plugins/ffmpeg/libavcodec/cbrt_tablegen.c
Normal file
39
src/add-ons/media/plugins/ffmpeg/libavcodec/cbrt_tablegen.c
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Generate a header file for hardcoded AAC cube-root table
|
||||
*
|
||||
* Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#define CONFIG_HARDCODED_TABLES 0
|
||||
#include "cbrt_tablegen.h"
|
||||
#include "tableprint.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
cbrt_tableinit();
|
||||
|
||||
write_fileheader();
|
||||
|
||||
printf("static const uint32_t cbrt_tab[1<<13] = {\n");
|
||||
write_uint32_array(cbrt_tab, 1 << 13);
|
||||
printf("};\n");
|
||||
|
||||
return 0;
|
||||
}
|
51
src/add-ons/media/plugins/ffmpeg/libavcodec/cbrt_tablegen.h
Normal file
51
src/add-ons/media/plugins/ffmpeg/libavcodec/cbrt_tablegen.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Header file for hardcoded AAC cube-root table
|
||||
*
|
||||
* Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef CBRT_TABLEGEN_H
|
||||
#define CBRT_TABLEGEN_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
#define cbrt_tableinit()
|
||||
#include "libavcodec/cbrt_tables.h"
|
||||
#else
|
||||
static uint32_t cbrt_tab[1 << 13];
|
||||
|
||||
static void cbrt_tableinit(void)
|
||||
{
|
||||
if (!cbrt_tab[(1<<13) - 1]) {
|
||||
int i;
|
||||
for (i = 0; i < 1<<13; i++) {
|
||||
union {
|
||||
float f;
|
||||
uint32_t i;
|
||||
} f;
|
||||
f.f = cbrtf(i) * i;
|
||||
cbrt_tab[i] = f.i;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_HARDCODED_TABLES */
|
||||
|
||||
#endif /* CBRT_TABLEGEN_H */
|
381
src/add-ons/media/plugins/ffmpeg/libavcodec/cdgraphics.c
Normal file
381
src/add-ons/media/plugins/ffmpeg/libavcodec/cdgraphics.c
Normal file
@ -0,0 +1,381 @@
|
||||
/*
|
||||
* CD Graphics Video Decoder
|
||||
* Copyright (c) 2009 Michael Tison
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "bytestream.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief CD Graphics Video Decoder
|
||||
* @author Michael Tison
|
||||
* @sa http://wiki.multimedia.cx/index.php?title=CD_Graphics
|
||||
* @sa http://www.ccs.neu.edu/home/bchafy/cdb/info/cdg
|
||||
*/
|
||||
|
||||
/// default screen sizes
|
||||
#define CDG_FULL_WIDTH 300
|
||||
#define CDG_FULL_HEIGHT 216
|
||||
#define CDG_DISPLAY_WIDTH 294
|
||||
#define CDG_DISPLAY_HEIGHT 204
|
||||
#define CDG_BORDER_WIDTH 6
|
||||
#define CDG_BORDER_HEIGHT 12
|
||||
|
||||
/// masks
|
||||
#define CDG_COMMAND 0x09
|
||||
#define CDG_MASK 0x3F
|
||||
|
||||
/// instruction codes
|
||||
#define CDG_INST_MEMORY_PRESET 1
|
||||
#define CDG_INST_BORDER_PRESET 2
|
||||
#define CDG_INST_TILE_BLOCK 6
|
||||
#define CDG_INST_SCROLL_PRESET 20
|
||||
#define CDG_INST_SCROLL_COPY 24
|
||||
#define CDG_INST_LOAD_PAL_LO 30
|
||||
#define CDG_INST_LOAD_PAL_HIGH 31
|
||||
#define CDG_INST_TILE_BLOCK_XOR 38
|
||||
|
||||
/// data sizes
|
||||
#define CDG_PACKET_SIZE 24
|
||||
#define CDG_DATA_SIZE 16
|
||||
#define CDG_TILE_HEIGHT 12
|
||||
#define CDG_TILE_WIDTH 6
|
||||
#define CDG_MINIMUM_PKT_SIZE 6
|
||||
#define CDG_MINIMUM_SCROLL_SIZE 3
|
||||
#define CDG_HEADER_SIZE 8
|
||||
#define CDG_PALETTE_SIZE 16
|
||||
|
||||
typedef struct CDGraphicsContext {
|
||||
AVFrame frame;
|
||||
int hscroll;
|
||||
int vscroll;
|
||||
} CDGraphicsContext;
|
||||
|
||||
static void cdg_init_frame(AVFrame *frame)
|
||||
{
|
||||
avcodec_get_frame_defaults(frame);
|
||||
frame->reference = 3;
|
||||
frame->buffer_hints = FF_BUFFER_HINTS_VALID |
|
||||
FF_BUFFER_HINTS_READABLE |
|
||||
FF_BUFFER_HINTS_PRESERVE |
|
||||
FF_BUFFER_HINTS_REUSABLE;
|
||||
}
|
||||
|
||||
static av_cold int cdg_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
CDGraphicsContext *cc = avctx->priv_data;
|
||||
|
||||
cdg_init_frame(&cc->frame);
|
||||
|
||||
avctx->width = CDG_FULL_WIDTH;
|
||||
avctx->height = CDG_FULL_HEIGHT;
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
|
||||
{
|
||||
int y;
|
||||
int lsize = cc->frame.linesize[0];
|
||||
uint8_t *buf = cc->frame.data[0];
|
||||
int color = data[0] & 0x0F;
|
||||
|
||||
if (!(data[1] & 0x0F)) {
|
||||
/// fill the top and bottom borders
|
||||
memset(buf, color, CDG_BORDER_HEIGHT * lsize);
|
||||
memset(buf + (CDG_FULL_HEIGHT - CDG_BORDER_HEIGHT) * lsize,
|
||||
color, CDG_BORDER_HEIGHT * lsize);
|
||||
|
||||
/// fill the side borders
|
||||
for (y = CDG_BORDER_HEIGHT; y < CDG_FULL_HEIGHT - CDG_BORDER_HEIGHT; y++) {
|
||||
memset(buf + y * lsize, color, CDG_BORDER_WIDTH);
|
||||
memset(buf + CDG_FULL_WIDTH - CDG_BORDER_WIDTH + y * lsize,
|
||||
color, CDG_BORDER_WIDTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low)
|
||||
{
|
||||
uint8_t r, g, b;
|
||||
uint16_t color;
|
||||
int i;
|
||||
int array_offset = low ? 0 : 8;
|
||||
uint32_t *palette = (uint32_t *) cc->frame.data[1];
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
color = (data[2 * i] << 6) + (data[2 * i + 1] & 0x3F);
|
||||
r = ((color >> 8) & 0x000F) * 17;
|
||||
g = ((color >> 4) & 0x000F) * 17;
|
||||
b = ((color ) & 0x000F) * 17;
|
||||
palette[i + array_offset] = r << 16 | g << 8 | b;
|
||||
}
|
||||
cc->frame.palette_has_changed = 1;
|
||||
}
|
||||
|
||||
static int cdg_tile_block(CDGraphicsContext *cc, uint8_t *data, int b)
|
||||
{
|
||||
unsigned ci, ri;
|
||||
int color;
|
||||
int x, y;
|
||||
int ai;
|
||||
int stride = cc->frame.linesize[0];
|
||||
uint8_t *buf = cc->frame.data[0];
|
||||
|
||||
ri = (data[2] & 0x1F) * CDG_TILE_HEIGHT + cc->vscroll;
|
||||
ci = (data[3] & 0x3F) * CDG_TILE_WIDTH + cc->hscroll;
|
||||
|
||||
if (ri > (CDG_FULL_HEIGHT - CDG_TILE_HEIGHT))
|
||||
return AVERROR(EINVAL);
|
||||
if (ci > (CDG_FULL_WIDTH - CDG_TILE_WIDTH))
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
for (y = 0; y < CDG_TILE_HEIGHT; y++) {
|
||||
for (x = 0; x < CDG_TILE_WIDTH; x++) {
|
||||
if (!((data[4 + y] >> (5 - x)) & 0x01))
|
||||
color = data[0] & 0x0F;
|
||||
else
|
||||
color = data[1] & 0x0F;
|
||||
|
||||
ai = ci + x + (stride * (ri + y));
|
||||
if (b)
|
||||
color ^= buf[ai];
|
||||
buf[ai] = color;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define UP 2
|
||||
#define DOWN 1
|
||||
#define LEFT 2
|
||||
#define RIGHT 1
|
||||
|
||||
static void cdg_copy_rect_buf(int out_tl_x, int out_tl_y, uint8_t *out,
|
||||
int in_tl_x, int in_tl_y, uint8_t *in,
|
||||
int w, int h, int stride)
|
||||
{
|
||||
int y;
|
||||
|
||||
in += in_tl_x + in_tl_y * stride;
|
||||
out += out_tl_x + out_tl_y * stride;
|
||||
for (y = 0; y < h; y++)
|
||||
memcpy(out + y * stride, in + y * stride, w);
|
||||
}
|
||||
|
||||
static void cdg_fill_rect_preset(int tl_x, int tl_y, uint8_t *out,
|
||||
int color, int w, int h, int stride)
|
||||
{
|
||||
int y;
|
||||
|
||||
for (y = tl_y; y < tl_y + h; y++)
|
||||
memset(out + tl_x + y * stride, color, w);
|
||||
}
|
||||
|
||||
static void cdg_fill_wrapper(int out_tl_x, int out_tl_y, uint8_t *out,
|
||||
int in_tl_x, int in_tl_y, uint8_t *in,
|
||||
int color, int w, int h, int stride, int roll)
|
||||
{
|
||||
if (roll) {
|
||||
cdg_copy_rect_buf(out_tl_x, out_tl_y, out, in_tl_x, in_tl_y,
|
||||
in, w, h, stride);
|
||||
} else {
|
||||
cdg_fill_rect_preset(out_tl_x, out_tl_y, out, color, w, h, stride);
|
||||
}
|
||||
}
|
||||
|
||||
static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data,
|
||||
AVFrame *new_frame, int roll_over)
|
||||
{
|
||||
int color;
|
||||
int hscmd, h_off, hinc, vscmd, v_off, vinc;
|
||||
int y;
|
||||
int stride = cc->frame.linesize[0];
|
||||
uint8_t *in = cc->frame.data[0];
|
||||
uint8_t *out = new_frame->data[0];
|
||||
|
||||
color = data[0] & 0x0F;
|
||||
hscmd = (data[1] & 0x30) >> 4;
|
||||
vscmd = (data[2] & 0x30) >> 4;
|
||||
|
||||
h_off = FFMIN(data[1] & 0x07, CDG_BORDER_WIDTH - 1);
|
||||
v_off = FFMIN(data[2] & 0x07, CDG_BORDER_HEIGHT - 1);
|
||||
|
||||
/// find the difference and save the offset for cdg_tile_block usage
|
||||
hinc = h_off - cc->hscroll;
|
||||
vinc = v_off - cc->vscroll;
|
||||
cc->hscroll = h_off;
|
||||
cc->vscroll = v_off;
|
||||
|
||||
if (vscmd == UP)
|
||||
vinc -= 12;
|
||||
if (vscmd == DOWN)
|
||||
vinc += 12;
|
||||
if (hscmd == LEFT)
|
||||
hinc -= 6;
|
||||
if (hscmd == RIGHT)
|
||||
hinc += 6;
|
||||
|
||||
if (!hinc && !vinc)
|
||||
return;
|
||||
|
||||
memcpy(new_frame->data[1], cc->frame.data[1], CDG_PALETTE_SIZE * 4);
|
||||
|
||||
for (y = FFMAX(0, vinc); y < FFMIN(CDG_FULL_HEIGHT + vinc, CDG_FULL_HEIGHT); y++)
|
||||
memcpy(out + FFMAX(0, hinc) + stride * y,
|
||||
in + FFMAX(0, hinc) - hinc + (y - vinc) * stride,
|
||||
FFMIN(stride + hinc, stride));
|
||||
|
||||
if (vinc > 0)
|
||||
cdg_fill_wrapper(0, 0, out,
|
||||
0, CDG_FULL_HEIGHT - vinc, in, color,
|
||||
stride, vinc, stride, roll_over);
|
||||
else if (vinc < 0)
|
||||
cdg_fill_wrapper(0, CDG_FULL_HEIGHT + vinc, out,
|
||||
0, 0, in, color,
|
||||
stride, -1 * vinc, stride, roll_over);
|
||||
|
||||
if (hinc > 0)
|
||||
cdg_fill_wrapper(0, 0, out,
|
||||
CDG_FULL_WIDTH - hinc, 0, in, color,
|
||||
hinc, CDG_FULL_HEIGHT, stride, roll_over);
|
||||
else if (hinc < 0)
|
||||
cdg_fill_wrapper(CDG_FULL_WIDTH + hinc, 0, out,
|
||||
0, 0, in, color,
|
||||
-1 * hinc, CDG_FULL_HEIGHT, stride, roll_over);
|
||||
|
||||
}
|
||||
|
||||
static int cdg_decode_frame(AVCodecContext *avctx,
|
||||
void *data, int *data_size, AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
int ret;
|
||||
uint8_t command, inst;
|
||||
uint8_t cdg_data[CDG_DATA_SIZE];
|
||||
AVFrame new_frame;
|
||||
CDGraphicsContext *cc = avctx->priv_data;
|
||||
|
||||
if (buf_size < CDG_MINIMUM_PKT_SIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "buffer too small for decoder\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ret = avctx->reget_buffer(avctx, &cc->frame);
|
||||
if (ret) {
|
||||
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
command = bytestream_get_byte(&buf);
|
||||
inst = bytestream_get_byte(&buf);
|
||||
inst &= CDG_MASK;
|
||||
buf += 2; /// skipping 2 unneeded bytes
|
||||
bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
|
||||
|
||||
if ((command & CDG_MASK) == CDG_COMMAND) {
|
||||
switch (inst) {
|
||||
case CDG_INST_MEMORY_PRESET:
|
||||
if (!(cdg_data[1] & 0x0F))
|
||||
memset(cc->frame.data[0], cdg_data[0] & 0x0F,
|
||||
cc->frame.linesize[0] * CDG_FULL_HEIGHT);
|
||||
break;
|
||||
case CDG_INST_LOAD_PAL_LO:
|
||||
case CDG_INST_LOAD_PAL_HIGH:
|
||||
if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "buffer too small for loading palette\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
cdg_load_palette(cc, cdg_data, inst == CDG_INST_LOAD_PAL_LO);
|
||||
break;
|
||||
case CDG_INST_BORDER_PRESET:
|
||||
cdg_border_preset(cc, cdg_data);
|
||||
break;
|
||||
case CDG_INST_TILE_BLOCK_XOR:
|
||||
case CDG_INST_TILE_BLOCK:
|
||||
if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "buffer too small for drawing tile\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ret = cdg_tile_block(cc, cdg_data, inst == CDG_INST_TILE_BLOCK_XOR);
|
||||
if (ret) {
|
||||
av_log(avctx, AV_LOG_ERROR, "tile is out of range\n");
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
case CDG_INST_SCROLL_PRESET:
|
||||
case CDG_INST_SCROLL_COPY:
|
||||
if (buf_size - CDG_HEADER_SIZE < CDG_MINIMUM_SCROLL_SIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "buffer too small for scrolling\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
cdg_init_frame(&new_frame);
|
||||
ret = avctx->get_buffer(avctx, &new_frame);
|
||||
if (ret) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
cdg_scroll(cc, cdg_data, &new_frame, inst == CDG_INST_SCROLL_COPY);
|
||||
avctx->release_buffer(avctx, &cc->frame);
|
||||
cc->frame = new_frame;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
} else {
|
||||
*data_size = 0;
|
||||
buf_size = 0;
|
||||
}
|
||||
|
||||
*(AVFrame *) data = cc->frame;
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
static av_cold int cdg_decode_end(AVCodecContext *avctx)
|
||||
{
|
||||
CDGraphicsContext *cc = avctx->priv_data;
|
||||
|
||||
if (cc->frame.data[0])
|
||||
avctx->release_buffer(avctx, &cc->frame);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVCodec cdgraphics_decoder = {
|
||||
"cdgraphics",
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_CDGRAPHICS,
|
||||
sizeof(CDGraphicsContext),
|
||||
cdg_decode_init,
|
||||
NULL,
|
||||
cdg_decode_end,
|
||||
cdg_decode_frame,
|
||||
CODEC_CAP_DR1,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"),
|
||||
};
|
@ -25,10 +25,8 @@
|
||||
#include "avcodec.h"
|
||||
#include "celp_filters.h"
|
||||
|
||||
void ff_celp_convolve_circ(int16_t* fc_out,
|
||||
const int16_t* fc_in,
|
||||
const int16_t* filter,
|
||||
int len)
|
||||
void ff_celp_convolve_circ(int16_t* fc_out, const int16_t* fc_in,
|
||||
const int16_t* filter, int len)
|
||||
{
|
||||
int i, k;
|
||||
|
||||
@ -57,22 +55,16 @@ void ff_celp_circ_addf(float *out, const float *in,
|
||||
out[k] = in[k] + fac * lagged[ k - lag];
|
||||
}
|
||||
|
||||
int ff_celp_lp_synthesis_filter(int16_t *out,
|
||||
const int16_t* filter_coeffs,
|
||||
const int16_t* in,
|
||||
int buffer_length,
|
||||
int filter_length,
|
||||
int stop_on_overflow,
|
||||
int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
|
||||
const int16_t *in, int buffer_length,
|
||||
int filter_length, int stop_on_overflow,
|
||||
int rounder)
|
||||
{
|
||||
int i,n;
|
||||
|
||||
// Avoids a +1 in the inner loop.
|
||||
filter_length++;
|
||||
|
||||
for (n = 0; n < buffer_length; n++) {
|
||||
int sum = rounder;
|
||||
for (i = 1; i < filter_length; i++)
|
||||
for (i = 1; i <= filter_length; i++)
|
||||
sum -= filter_coeffs[i-1] * out[n-i];
|
||||
|
||||
sum = (sum >> 12) + in[n];
|
||||
@ -88,38 +80,131 @@ int ff_celp_lp_synthesis_filter(int16_t *out,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ff_celp_lp_synthesis_filterf(float *out,
|
||||
const float* filter_coeffs,
|
||||
const float* in,
|
||||
int buffer_length,
|
||||
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
|
||||
const float* in, int buffer_length,
|
||||
int filter_length)
|
||||
{
|
||||
int i,n;
|
||||
|
||||
// Avoids a +1 in the inner loop.
|
||||
filter_length++;
|
||||
|
||||
#if 0 // Unoptimized code path for improved readability
|
||||
for (n = 0; n < buffer_length; n++) {
|
||||
out[n] = in[n];
|
||||
for (i = 1; i < filter_length; i++)
|
||||
for (i = 1; i <= filter_length; i++)
|
||||
out[n] -= filter_coeffs[i-1] * out[n-i];
|
||||
}
|
||||
#else
|
||||
float out0, out1, out2, out3;
|
||||
float old_out0, old_out1, old_out2, old_out3;
|
||||
float a,b,c;
|
||||
|
||||
a = filter_coeffs[0];
|
||||
b = filter_coeffs[1];
|
||||
c = filter_coeffs[2];
|
||||
b -= filter_coeffs[0] * filter_coeffs[0];
|
||||
c -= filter_coeffs[1] * filter_coeffs[0];
|
||||
c -= filter_coeffs[0] * b;
|
||||
|
||||
old_out0 = out[-4];
|
||||
old_out1 = out[-3];
|
||||
old_out2 = out[-2];
|
||||
old_out3 = out[-1];
|
||||
for (n = 0; n <= buffer_length - 4; n+=4) {
|
||||
float tmp0,tmp1,tmp2,tmp3;
|
||||
float val;
|
||||
|
||||
out0 = in[0];
|
||||
out1 = in[1];
|
||||
out2 = in[2];
|
||||
out3 = in[3];
|
||||
|
||||
out0 -= filter_coeffs[2] * old_out1;
|
||||
out1 -= filter_coeffs[2] * old_out2;
|
||||
out2 -= filter_coeffs[2] * old_out3;
|
||||
|
||||
out0 -= filter_coeffs[1] * old_out2;
|
||||
out1 -= filter_coeffs[1] * old_out3;
|
||||
|
||||
out0 -= filter_coeffs[0] * old_out3;
|
||||
|
||||
val = filter_coeffs[3];
|
||||
|
||||
out0 -= val * old_out0;
|
||||
out1 -= val * old_out1;
|
||||
out2 -= val * old_out2;
|
||||
out3 -= val * old_out3;
|
||||
|
||||
old_out3 = out[-5];
|
||||
|
||||
for (i = 5; i <= filter_length; i += 2) {
|
||||
val = filter_coeffs[i-1];
|
||||
|
||||
out0 -= val * old_out3;
|
||||
out1 -= val * old_out0;
|
||||
out2 -= val * old_out1;
|
||||
out3 -= val * old_out2;
|
||||
|
||||
old_out2 = out[-i-1];
|
||||
|
||||
val = filter_coeffs[i];
|
||||
|
||||
out0 -= val * old_out2;
|
||||
out1 -= val * old_out3;
|
||||
out2 -= val * old_out0;
|
||||
out3 -= val * old_out1;
|
||||
|
||||
FFSWAP(float, old_out0, old_out2);
|
||||
old_out1 = old_out3;
|
||||
old_out3 = out[-i-2];
|
||||
}
|
||||
|
||||
tmp0 = out0;
|
||||
tmp1 = out1;
|
||||
tmp2 = out2;
|
||||
tmp3 = out3;
|
||||
|
||||
out3 -= a * tmp2;
|
||||
out2 -= a * tmp1;
|
||||
out1 -= a * tmp0;
|
||||
|
||||
out3 -= b * tmp1;
|
||||
out2 -= b * tmp0;
|
||||
|
||||
out3 -= c * tmp0;
|
||||
|
||||
|
||||
out[0] = out0;
|
||||
out[1] = out1;
|
||||
out[2] = out2;
|
||||
out[3] = out3;
|
||||
|
||||
old_out0 = out0;
|
||||
old_out1 = out1;
|
||||
old_out2 = out2;
|
||||
old_out3 = out3;
|
||||
|
||||
out += 4;
|
||||
in += 4;
|
||||
}
|
||||
|
||||
out -= n;
|
||||
in -= n;
|
||||
for (; n < buffer_length; n++) {
|
||||
out[n] = in[n];
|
||||
for (i = 1; i <= filter_length; i++)
|
||||
out[n] -= filter_coeffs[i-1] * out[n-i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ff_celp_lp_zero_synthesis_filterf(float *out,
|
||||
const float* filter_coeffs,
|
||||
const float* in,
|
||||
int buffer_length,
|
||||
void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
|
||||
const float *in, int buffer_length,
|
||||
int filter_length)
|
||||
{
|
||||
int i,n;
|
||||
|
||||
// Avoids a +1 in the inner loop.
|
||||
filter_length++;
|
||||
|
||||
for (n = 0; n < buffer_length; n++) {
|
||||
out[n] = in[n];
|
||||
for (i = 1; i < filter_length; i++)
|
||||
for (i = 1; i <= filter_length; i++)
|
||||
out[n] += filter_coeffs[i-1] * in[n-i];
|
||||
}
|
||||
}
|
||||
|
@ -36,10 +36,8 @@
|
||||
*
|
||||
* \note fc_in and fc_out should not overlap!
|
||||
*/
|
||||
void ff_celp_convolve_circ(int16_t* fc_out,
|
||||
const int16_t* fc_in,
|
||||
const int16_t* filter,
|
||||
int len);
|
||||
void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in,
|
||||
const int16_t *filter, int len);
|
||||
|
||||
/**
|
||||
* Add an array to a rotated array.
|
||||
@ -74,12 +72,9 @@ void ff_celp_circ_addf(float *out, const float *in,
|
||||
*
|
||||
* Routine applies 1/A(z) filter to given speech data.
|
||||
*/
|
||||
int ff_celp_lp_synthesis_filter(int16_t *out,
|
||||
const int16_t* filter_coeffs,
|
||||
const int16_t* in,
|
||||
int buffer_length,
|
||||
int filter_length,
|
||||
int stop_on_overflow,
|
||||
int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
|
||||
const int16_t *in, int buffer_length,
|
||||
int filter_length, int stop_on_overflow,
|
||||
int rounder);
|
||||
|
||||
/**
|
||||
@ -90,17 +85,16 @@ int ff_celp_lp_synthesis_filter(int16_t *out,
|
||||
* @param filter_coeffs filter coefficients.
|
||||
* @param in input signal
|
||||
* @param buffer_length amount of data to process
|
||||
* @param filter_length filter length (10 for 10th order LP filter)
|
||||
* @param filter_length filter length (10 for 10th order LP filter). Must be
|
||||
* greater than 4 and even.
|
||||
*
|
||||
* @note Output buffer must contain filter_length samples of past
|
||||
* speech data before pointer.
|
||||
*
|
||||
* Routine applies 1/A(z) filter to given speech data.
|
||||
*/
|
||||
void ff_celp_lp_synthesis_filterf(float *out,
|
||||
const float* filter_coeffs,
|
||||
const float* in,
|
||||
int buffer_length,
|
||||
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
|
||||
const float *in, int buffer_length,
|
||||
int filter_length);
|
||||
|
||||
/**
|
||||
@ -118,10 +112,8 @@ void ff_celp_lp_synthesis_filterf(float *out,
|
||||
*
|
||||
* Routine applies A(z) filter to given speech data.
|
||||
*/
|
||||
void ff_celp_lp_zero_synthesis_filterf(float *out,
|
||||
const float* filter_coeffs,
|
||||
const float* in,
|
||||
int buffer_length,
|
||||
void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
|
||||
const float *in, int buffer_length,
|
||||
int filter_length);
|
||||
|
||||
#endif /* AVCODEC_CELP_FILTERS_H */
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cinepak.c
|
||||
* @file
|
||||
* Cinepak video decoder
|
||||
* by Ewald Snel <ewald@rambo.its.tudelft.nl>
|
||||
* For more information on the Cinepak algorithm, visit:
|
||||
@ -457,7 +457,7 @@ static av_cold int cinepak_decode_end(AVCodecContext *avctx)
|
||||
|
||||
AVCodec cinepak_decoder = {
|
||||
"cinepak",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_CINEPAK,
|
||||
sizeof(CinepakContext),
|
||||
cinepak_decode_init,
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cljr.c
|
||||
* @file
|
||||
* Cirrus Logic AccuPak codec.
|
||||
*/
|
||||
|
||||
@ -137,7 +137,7 @@ static av_cold int encode_init(AVCodecContext *avctx){
|
||||
|
||||
AVCodec cljr_decoder = {
|
||||
"cljr",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_CLJR,
|
||||
sizeof(CLJRContext),
|
||||
decode_init,
|
||||
@ -151,7 +151,7 @@ AVCodec cljr_decoder = {
|
||||
#if CONFIG_CLJR_ENCODER
|
||||
AVCodec cljr_encoder = {
|
||||
"cljr",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_CLJR,
|
||||
sizeof(CLJRContext),
|
||||
encode_init,
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/colorspace.h
|
||||
* @file
|
||||
* Various defines for YUV<->RGB conversion
|
||||
*/
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cook.c
|
||||
* @file
|
||||
* Cook compatible decoder. Bastardization of the G.722.1 standard.
|
||||
* This decoder handles RealNetworks, RealAudio G2 data.
|
||||
* Cook is identified by the codec name cook in RM files.
|
||||
@ -52,6 +52,7 @@
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "bytestream.h"
|
||||
#include "fft.h"
|
||||
|
||||
#include "cookdata.h"
|
||||
|
||||
@ -136,7 +137,7 @@ typedef struct cook {
|
||||
AVLFG random_state;
|
||||
|
||||
/* transform data */
|
||||
MDCTContext mdct_ctx;
|
||||
FFTContext mdct_ctx;
|
||||
float* mlt_window;
|
||||
|
||||
/* VLC data */
|
||||
@ -150,7 +151,7 @@ typedef struct cook {
|
||||
/* data buffers */
|
||||
|
||||
uint8_t* decoded_bytes_buffer;
|
||||
DECLARE_ALIGNED_16(float,mono_mdct_output[2048]);
|
||||
DECLARE_ALIGNED(16, float,mono_mdct_output)[2048];
|
||||
float decode_buffer_1[1024];
|
||||
float decode_buffer_2[1024];
|
||||
float decode_buffer_0[1060]; /* static allocation for joint decode */
|
||||
@ -1101,7 +1102,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
|
||||
q->bit_rate = avctx->bit_rate;
|
||||
|
||||
/* Initialize RNG. */
|
||||
av_lfg_init(&q->random_state, ff_random_get_seed());
|
||||
av_lfg_init(&q->random_state, 0);
|
||||
|
||||
while(edata_ptr < edata_ptr_end){
|
||||
/* 8 for mono, 16 for stereo, ? for multichannel
|
||||
@ -1287,7 +1288,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
|
||||
AVCodec cook_decoder =
|
||||
{
|
||||
.name = "cook",
|
||||
.type = CODEC_TYPE_AUDIO,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = CODEC_ID_COOK,
|
||||
.priv_data_size = sizeof(COOKContext),
|
||||
.init = cook_decode_init,
|
||||
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cookdata.h
|
||||
* @file
|
||||
* Cook AKA RealAudio G2 compatible decoderdata
|
||||
*/
|
||||
|
||||
|
56
src/add-ons/media/plugins/ffmpeg/libavcodec/costablegen.c
Normal file
56
src/add-ons/media/plugins/ffmpeg/libavcodec/costablegen.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Generate a header file for hardcoded ff_cos_* tables
|
||||
*
|
||||
* Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
#define BITS 16
|
||||
#define FLOATFMT "%.18e"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, j;
|
||||
int do_sin = argc == 2 && !strcmp(argv[1], "sin");
|
||||
double (*func)(double) = do_sin ? sin : cos;
|
||||
|
||||
printf("/* This file was generated by libavcodec/costablegen */\n");
|
||||
printf("#include \"libavcodec/fft.h\"\n");
|
||||
for (i = 4; i <= BITS; i++) {
|
||||
int m = 1 << i;
|
||||
double freq = 2*M_PI/m;
|
||||
printf("%s(%i) = {\n ", do_sin ? "SINTABLE" : "COSTABLE", m);
|
||||
for (j = 0; j < m/2 - 1; j++) {
|
||||
int idx = j > m/4 ? m/2 - j : j;
|
||||
if (do_sin && j >= m/4)
|
||||
idx = m/4 - j;
|
||||
printf(" "FLOATFMT",", func(idx*freq));
|
||||
if ((j & 3) == 3)
|
||||
printf("\n ");
|
||||
}
|
||||
printf(" "FLOATFMT"\n};\n", func(do_sin ? -(m/4 - 1)*freq : freq));
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -216,9 +216,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
|
||||
static av_cold int decode_init(AVCodecContext *avctx) {
|
||||
CamStudioContext *c = avctx->priv_data;
|
||||
if (avcodec_check_dimensions(avctx, avctx->height, avctx->width) < 0) {
|
||||
return 1;
|
||||
}
|
||||
switch (avctx->bits_per_coded_sample) {
|
||||
case 16: avctx->pix_fmt = PIX_FMT_RGB555; break;
|
||||
case 24: avctx->pix_fmt = PIX_FMT_BGR24; break;
|
||||
@ -252,7 +249,7 @@ static av_cold int decode_end(AVCodecContext *avctx) {
|
||||
|
||||
AVCodec cscd_decoder = {
|
||||
"camstudio",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_CSCD,
|
||||
sizeof(CamStudioContext),
|
||||
decode_init,
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/cyuv.c
|
||||
* @file
|
||||
* Creative YUV (CYUV) Video Decoder.
|
||||
*/
|
||||
|
||||
@ -82,26 +82,29 @@ static int cyuv_decode_frame(AVCodecContext *avctx,
|
||||
unsigned char cur_byte;
|
||||
int pixel_groups;
|
||||
|
||||
if (avctx->codec_id == CODEC_ID_AURA) {
|
||||
y_table = u_table;
|
||||
u_table = v_table;
|
||||
}
|
||||
/* sanity check the buffer size: A buffer has 3x16-bytes tables
|
||||
* followed by (height) lines each with 3 bytes to represent groups
|
||||
* of 4 pixels. Thus, the total size of the buffer ought to be:
|
||||
* (3 * 16) + height * (width * 3 / 4) */
|
||||
if (buf_size != 48 + s->height * (s->width * 3 / 4)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "ffmpeg: cyuv: got a buffer with %d bytes when %d were expected\n",
|
||||
buf_size,
|
||||
48 + s->height * (s->width * 3 / 4));
|
||||
return -1;
|
||||
av_log(avctx, AV_LOG_ERROR, "got a buffer with %d bytes when %d were expected\n",
|
||||
buf_size, 48 + s->height * (s->width * 3 / 4));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* pixel data starts 48 bytes in, after 3x16-byte tables */
|
||||
stream_ptr = 48;
|
||||
|
||||
if(s->frame.data[0])
|
||||
if (s->frame.data[0])
|
||||
avctx->release_buffer(avctx, &s->frame);
|
||||
|
||||
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
|
||||
s->frame.reference = 0;
|
||||
if(avctx->get_buffer(avctx, &s->frame) < 0) {
|
||||
if (avctx->get_buffer(avctx, &s->frame) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return -1;
|
||||
}
|
||||
@ -164,17 +167,44 @@ static int cyuv_decode_frame(AVCodecContext *avctx,
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
static av_cold int cyuv_decode_end(AVCodecContext *avctx)
|
||||
{
|
||||
CyuvDecodeContext *s = avctx->priv_data;
|
||||
|
||||
if (s->frame.data[0])
|
||||
avctx->release_buffer(avctx, &s->frame);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_AURA_DECODER
|
||||
AVCodec aura_decoder = {
|
||||
"aura",
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_AURA,
|
||||
sizeof(CyuvDecodeContext),
|
||||
cyuv_decode_init,
|
||||
NULL,
|
||||
cyuv_decode_end,
|
||||
cyuv_decode_frame,
|
||||
CODEC_CAP_DR1,
|
||||
NULL,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Auravision AURA"),
|
||||
};
|
||||
#endif
|
||||
|
||||
#if CONFIG_CYUV_DECODER
|
||||
AVCodec cyuv_decoder = {
|
||||
"cyuv",
|
||||
CODEC_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_CYUV,
|
||||
sizeof(CyuvDecodeContext),
|
||||
cyuv_decode_init,
|
||||
NULL,
|
||||
NULL,
|
||||
cyuv_decode_end,
|
||||
cyuv_decode_frame,
|
||||
CODEC_CAP_DR1,
|
||||
NULL,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Creative YUV (CYUV)"),
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,21 +22,22 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/dca.c
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "libavutil/intmath.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "avcodec.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
#include "get_bits.h"
|
||||
#include "put_bits.h"
|
||||
#include "dcadata.h"
|
||||
#include "dcahuff.h"
|
||||
#include "dca.h"
|
||||
#include "synth_filter.h"
|
||||
#include "dcadsp.h"
|
||||
|
||||
//#define TRACE
|
||||
|
||||
@ -227,15 +228,16 @@ typedef struct {
|
||||
|
||||
/* Subband samples history (for ADPCM) */
|
||||
float subband_samples_hist[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4];
|
||||
DECLARE_ALIGNED_16(float, subband_fir_hist[DCA_PRIM_CHANNELS_MAX][512]);
|
||||
float subband_fir_noidea[DCA_PRIM_CHANNELS_MAX][32];
|
||||
DECLARE_ALIGNED(16, float, subband_fir_hist)[DCA_PRIM_CHANNELS_MAX][512];
|
||||
DECLARE_ALIGNED(16, float, subband_fir_noidea)[DCA_PRIM_CHANNELS_MAX][32];
|
||||
int hist_index[DCA_PRIM_CHANNELS_MAX];
|
||||
DECLARE_ALIGNED(16, float, raXin)[32];
|
||||
|
||||
int output; ///< type of output
|
||||
float add_bias; ///< output bias
|
||||
float scale_bias; ///< output scale
|
||||
|
||||
DECLARE_ALIGNED_16(float, samples[1536]); /* 6 * 256 = 1536, might only need 5 */
|
||||
DECLARE_ALIGNED(16, float, samples)[1536]; /* 6 * 256 = 1536, might only need 5 */
|
||||
const float *samples_chanptr[6];
|
||||
|
||||
uint8_t dca_buffer[DCA_MAX_FRAME_SIZE];
|
||||
@ -249,7 +251,9 @@ typedef struct {
|
||||
|
||||
int debug_flag; ///< used for suppressing repeated error messages output
|
||||
DSPContext dsp;
|
||||
MDCTContext imdct;
|
||||
FFTContext imdct;
|
||||
SynthFilterContext synth;
|
||||
DCADSPContext dcadsp;
|
||||
} DCAContext;
|
||||
|
||||
static const uint16_t dca_vlc_offs[] = {
|
||||
@ -608,7 +612,7 @@ static int dca_subframe_header(DCAContext * s)
|
||||
s->joint_scale_factor[j][k] = scale; /*joint_scale_table[scale]; */
|
||||
}
|
||||
|
||||
if (!s->debug_flag & 0x02) {
|
||||
if (!(s->debug_flag & 0x02)) {
|
||||
av_log(s->avctx, AV_LOG_DEBUG,
|
||||
"Joint stereo coding not supported\n");
|
||||
s->debug_flag |= 0x02;
|
||||
@ -750,12 +754,9 @@ static void qmf_32_subbands(DCAContext * s, int chans,
|
||||
float scale, float bias)
|
||||
{
|
||||
const float *prCoeff;
|
||||
int i, j;
|
||||
DECLARE_ALIGNED_16(float, raXin[32]);
|
||||
|
||||
int hist_index= s->hist_index[chans];
|
||||
float *subband_fir_hist2 = s->subband_fir_noidea[chans];
|
||||
int i;
|
||||
|
||||
int sb_act = s->subband_activity[chans];
|
||||
int subindex;
|
||||
|
||||
scale *= sqrt(1/8.0);
|
||||
@ -768,48 +769,24 @@ static void qmf_32_subbands(DCAContext * s, int chans,
|
||||
|
||||
/* Reconstructed channel sample index */
|
||||
for (subindex = 0; subindex < 8; subindex++) {
|
||||
float *subband_fir_hist = s->subband_fir_hist[chans] + hist_index;
|
||||
/* Load in one sample from each subband and clear inactive subbands */
|
||||
for (i = 0; i < s->subband_activity[chans]; i++){
|
||||
if((i-1)&2) raXin[i] = -samples_in[i][subindex];
|
||||
else raXin[i] = samples_in[i][subindex];
|
||||
for (i = 0; i < sb_act; i++){
|
||||
uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ ((i-1)&2)<<30;
|
||||
AV_WN32A(&s->raXin[i], v);
|
||||
}
|
||||
for (; i < 32; i++)
|
||||
raXin[i] = 0.0;
|
||||
s->raXin[i] = 0.0;
|
||||
|
||||
ff_imdct_half(&s->imdct, subband_fir_hist, raXin);
|
||||
|
||||
/* Multiply by filter coefficients */
|
||||
for (i = 0; i < 16; i++){
|
||||
float a= subband_fir_hist2[i ];
|
||||
float b= subband_fir_hist2[i+16];
|
||||
float c= 0;
|
||||
float d= 0;
|
||||
for (j = 0; j < 512-hist_index; j += 64){
|
||||
a += prCoeff[i+j ]*(-subband_fir_hist[15-i+j]);
|
||||
b += prCoeff[i+j+16]*( subband_fir_hist[ i+j]);
|
||||
c += prCoeff[i+j+32]*( subband_fir_hist[16+i+j]);
|
||||
d += prCoeff[i+j+48]*( subband_fir_hist[31-i+j]);
|
||||
}
|
||||
for ( ; j < 512; j += 64){
|
||||
a += prCoeff[i+j ]*(-subband_fir_hist[15-i+j-512]);
|
||||
b += prCoeff[i+j+16]*( subband_fir_hist[ i+j-512]);
|
||||
c += prCoeff[i+j+32]*( subband_fir_hist[16+i+j-512]);
|
||||
d += prCoeff[i+j+48]*( subband_fir_hist[31-i+j-512]);
|
||||
}
|
||||
samples_out[i ] = a * scale + bias;
|
||||
samples_out[i+16] = b * scale + bias;
|
||||
subband_fir_hist2[i ] = c;
|
||||
subband_fir_hist2[i+16] = d;
|
||||
}
|
||||
s->synth.synth_filter_float(&s->imdct,
|
||||
s->subband_fir_hist[chans], &s->hist_index[chans],
|
||||
s->subband_fir_noidea[chans], prCoeff,
|
||||
samples_out, s->raXin, scale, bias);
|
||||
samples_out+= 32;
|
||||
|
||||
hist_index = (hist_index-32)&511;
|
||||
}
|
||||
s->hist_index[chans]= hist_index;
|
||||
}
|
||||
|
||||
static void lfe_interpolation_fir(int decimation_select,
|
||||
static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
|
||||
int num_deci_sample, float *samples_in,
|
||||
float *samples_out, float scale,
|
||||
float bias)
|
||||
@ -822,30 +799,24 @@ static void lfe_interpolation_fir(int decimation_select,
|
||||
* samples_out: An array holding interpolated samples
|
||||
*/
|
||||
|
||||
int decifactor, k, j;
|
||||
int decifactor;
|
||||
const float *prCoeff;
|
||||
|
||||
int interp_index = 0; /* Index to the interpolated samples */
|
||||
int deciindex;
|
||||
|
||||
/* Select decimation filter */
|
||||
if (decimation_select == 1) {
|
||||
decifactor = 128;
|
||||
decifactor = 64;
|
||||
prCoeff = lfe_fir_128;
|
||||
} else {
|
||||
decifactor = 64;
|
||||
decifactor = 32;
|
||||
prCoeff = lfe_fir_64;
|
||||
}
|
||||
/* Interpolation */
|
||||
for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
|
||||
/* One decimated sample generates decifactor interpolated ones */
|
||||
for (k = 0; k < decifactor; k++) {
|
||||
float rTmp = 0.0;
|
||||
//FIXME the coeffs are symetric, fix that
|
||||
for (j = 0; j < 512 / decifactor; j++)
|
||||
rTmp += samples_in[deciindex - j] * prCoeff[k + j * decifactor];
|
||||
samples_out[interp_index++] = (rTmp * scale) + bias;
|
||||
}
|
||||
s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor,
|
||||
scale, bias);
|
||||
samples_in++;
|
||||
samples_out += 2 * decifactor;
|
||||
}
|
||||
}
|
||||
|
||||
@ -920,8 +891,9 @@ static int decode_blockcode(int code, int levels, int *values)
|
||||
int offset = (levels - 1) >> 1;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
values[i] = (code % levels) - offset;
|
||||
code /= levels;
|
||||
int div = FASTDIV(code, levels);
|
||||
values[i] = code - offset - div*levels;
|
||||
code = div;
|
||||
}
|
||||
|
||||
if (code == 0)
|
||||
@ -943,7 +915,8 @@ static int dca_subsubframe(DCAContext * s)
|
||||
const float *quant_step_table;
|
||||
|
||||
/* FIXME */
|
||||
float subband_samples[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8];
|
||||
LOCAL_ALIGNED_16(float, subband_samples, [DCA_PRIM_CHANNELS_MAX], [DCA_SUBBANDS][8]);
|
||||
LOCAL_ALIGNED_16(int, block, [8]);
|
||||
|
||||
/*
|
||||
* Audio data
|
||||
@ -963,7 +936,6 @@ static int dca_subsubframe(DCAContext * s)
|
||||
int abits = s->bitalloc[k][l];
|
||||
|
||||
float quant_step_size = quant_step_table[abits];
|
||||
float rscale;
|
||||
|
||||
/*
|
||||
* Determine quantization index code book and its type
|
||||
@ -977,45 +949,39 @@ static int dca_subsubframe(DCAContext * s)
|
||||
*/
|
||||
if(!abits){
|
||||
memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0]));
|
||||
}else if(abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){
|
||||
if(abits <= 7){
|
||||
/* Block code */
|
||||
int block_code1, block_code2, size, levels;
|
||||
int block[8];
|
||||
} else {
|
||||
/* Deal with transients */
|
||||
int sfi = s->transition_mode[k][l] && subsubframe >= s->transition_mode[k][l];
|
||||
float rscale = quant_step_size * s->scale_factor[k][l][sfi] * s->scalefactor_adj[k][sel];
|
||||
|
||||
size = abits_sizes[abits-1];
|
||||
levels = abits_levels[abits-1];
|
||||
if(abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){
|
||||
if(abits <= 7){
|
||||
/* Block code */
|
||||
int block_code1, block_code2, size, levels;
|
||||
|
||||
block_code1 = get_bits(&s->gb, size);
|
||||
/* FIXME Should test return value */
|
||||
decode_blockcode(block_code1, levels, block);
|
||||
block_code2 = get_bits(&s->gb, size);
|
||||
decode_blockcode(block_code2, levels, &block[4]);
|
||||
for (m = 0; m < 8; m++)
|
||||
subband_samples[k][l][m] = block[m];
|
||||
size = abits_sizes[abits-1];
|
||||
levels = abits_levels[abits-1];
|
||||
|
||||
block_code1 = get_bits(&s->gb, size);
|
||||
/* FIXME Should test return value */
|
||||
decode_blockcode(block_code1, levels, block);
|
||||
block_code2 = get_bits(&s->gb, size);
|
||||
decode_blockcode(block_code2, levels, &block[4]);
|
||||
}else{
|
||||
/* no coding */
|
||||
for (m = 0; m < 8; m++)
|
||||
block[m] = get_sbits(&s->gb, abits - 3);
|
||||
}
|
||||
}else{
|
||||
/* no coding */
|
||||
/* Huffman coded */
|
||||
for (m = 0; m < 8; m++)
|
||||
subband_samples[k][l][m] = get_sbits(&s->gb, abits - 3);
|
||||
block[m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel);
|
||||
}
|
||||
}else{
|
||||
/* Huffman coded */
|
||||
for (m = 0; m < 8; m++)
|
||||
subband_samples[k][l][m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel);
|
||||
|
||||
s->dsp.int32_to_float_fmul_scalar(subband_samples[k][l],
|
||||
block, rscale, 8);
|
||||
}
|
||||
|
||||
/* Deal with transients */
|
||||
if (s->transition_mode[k][l] &&
|
||||
subsubframe >= s->transition_mode[k][l])
|
||||
rscale = quant_step_size * s->scale_factor[k][l][1];
|
||||
else
|
||||
rscale = quant_step_size * s->scale_factor[k][l][0];
|
||||
|
||||
rscale *= s->scalefactor_adj[k][sel];
|
||||
|
||||
for (m = 0; m < 8; m++)
|
||||
subband_samples[k][l][m] *= rscale;
|
||||
|
||||
/*
|
||||
* Inverse ADPCM if in prediction mode
|
||||
*/
|
||||
@ -1094,7 +1060,7 @@ static int dca_subsubframe(DCAContext * s)
|
||||
if (s->output & DCA_LFE) {
|
||||
int lfe_samples = 2 * s->lfe * s->subsubframes;
|
||||
|
||||
lfe_interpolation_fir(s->lfe, 2 * s->lfe,
|
||||
lfe_interpolation_fir(s, s->lfe, 2 * s->lfe,
|
||||
s->lfe_data + lfe_samples +
|
||||
2 * s->lfe * subsubframe,
|
||||
&s->samples[256 * dca_lfe_index[s->amode]],
|
||||
@ -1270,6 +1236,10 @@ static int dca_decode_frame(AVCodecContext * avctx,
|
||||
} else
|
||||
s->channel_order_tab = dca_channel_reorder_nolfe[s->amode];
|
||||
|
||||
if (s->prim_channels > 0 &&
|
||||
s->channel_order_tab[s->prim_channels - 1] < 0)
|
||||
return -1;
|
||||
|
||||
if(avctx->request_channels == 2 && s->prim_channels > 2) {
|
||||
channels = 2;
|
||||
s->output = DCA_STEREO;
|
||||
@ -1319,12 +1289,14 @@ static av_cold int dca_decode_init(AVCodecContext * avctx)
|
||||
|
||||
dsputil_init(&s->dsp, avctx);
|
||||
ff_mdct_init(&s->imdct, 6, 1, 1.0);
|
||||
ff_synth_filter_init(&s->synth);
|
||||
ff_dcadsp_init(&s->dcadsp);
|
||||
|
||||
for(i = 0; i < 6; i++)
|
||||
s->samples_chanptr[i] = s->samples + i * 256;
|
||||
avctx->sample_fmt = SAMPLE_FMT_S16;
|
||||
|
||||
if(s->dsp.float_to_int16 == ff_float_to_int16_c) {
|
||||
if(s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
|
||||
s->add_bias = 385.0f;
|
||||
s->scale_bias = 1.0 / 32768.0;
|
||||
} else {
|
||||
@ -1351,7 +1323,7 @@ static av_cold int dca_decode_end(AVCodecContext * avctx)
|
||||
|
||||
AVCodec dca_decoder = {
|
||||
.name = "dca",
|
||||
.type = CODEC_TYPE_AUDIO,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = CODEC_ID_DTS,
|
||||
.priv_data_size = sizeof(DCAContext),
|
||||
.init = dca_decode_init,
|
||||
|
@ -22,10 +22,6 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file libavcodec/dca_parser.c
|
||||
*/
|
||||
|
||||
#include "parser.h"
|
||||
#include "dca.h"
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user