diff options
author | Mohamed Tarek <mt@rockbox.org> | 2009-08-14 15:26:04 +0000 |
---|---|---|
committer | Mohamed Tarek <mt@rockbox.org> | 2009-08-14 15:26:04 +0000 |
commit | 3ee45ab7bed6447f09aaf1a24f5d35f212cd8b14 (patch) | |
tree | b68bafeb9000ed1bc8c680bff65d66b1f146bd05 /apps/codecs/libatrac/atrac3.c | |
parent | 466b2ae2481477a2797f785c269e0a996401597b (diff) | |
download | rockbox-3ee45ab7bed6447f09aaf1a24f5d35f212cd8b14.tar.gz rockbox-3ee45ab7bed6447f09aaf1a24f5d35f212cd8b14.zip |
Use the bytestream reading functions form librm and drop bytestream.h and libavutil/
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22309 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libatrac/atrac3.c')
-rw-r--r-- | apps/codecs/libatrac/atrac3.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c index 26bffd42d4..9e61db1686 100644 --- a/apps/codecs/libatrac/atrac3.c +++ b/apps/codecs/libatrac/atrac3.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <stddef.h> | 36 | #include <stddef.h> |
37 | #include <stdio.h> | 37 | #include <stdio.h> |
38 | 38 | ||
39 | #include "bytestream.h" | ||
40 | #include "atrac3.h" | 39 | #include "atrac3.h" |
41 | #include "atrac3data.h" | 40 | #include "atrac3data.h" |
42 | #include "atrac3data_fixed.h" | 41 | #include "atrac3data_fixed.h" |
@@ -48,6 +47,20 @@ | |||
48 | 47 | ||
49 | #define AVERROR(...) -1 | 48 | #define AVERROR(...) -1 |
50 | 49 | ||
50 | /* FFMAX/MIN/SWAP and av_clip were taken from libavutil/common.h */ | ||
51 | #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) | ||
52 | #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) | ||
53 | #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) | ||
54 | |||
55 | /** | ||
56 | * Clips a signed integer value into the -32768,32767 range. | ||
57 | */ | ||
58 | static inline int16_t av_clip_int16(int a) | ||
59 | { | ||
60 | if ((a+32768) & ~65535) return (a>>31) ^ 32767; | ||
61 | else return a; | ||
62 | } | ||
63 | |||
51 | static int32_t qmf_window[48]; | 64 | static int32_t qmf_window[48]; |
52 | static VLC spectral_coeff_tab[7]; | 65 | static VLC spectral_coeff_tab[7]; |
53 | static channel_unit channel_units[2]; | 66 | static channel_unit channel_units[2]; |
@@ -169,7 +182,7 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ | |||
169 | } | 182 | } |
170 | 183 | ||
171 | 184 | ||
172 | static av_cold void init_atrac3_transforms(ATRAC3Context *q) { | 185 | static void init_atrac3_transforms(ATRAC3Context *q) { |
173 | int32_t s; | 186 | int32_t s; |
174 | int i; | 187 | int i; |
175 | 188 | ||
@@ -830,7 +843,7 @@ int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q, | |||
830 | int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx) | 843 | int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx) |
831 | { | 844 | { |
832 | int i; | 845 | int i; |
833 | const uint8_t *edata_ptr = rmctx->codec_extradata; | 846 | uint8_t *edata_ptr = rmctx->codec_extradata; |
834 | static VLC_TYPE atrac3_vlc_table[4096][2]; | 847 | static VLC_TYPE atrac3_vlc_table[4096][2]; |
835 | static int vlcs_initialized = 0; | 848 | static int vlcs_initialized = 0; |
836 | 849 | ||
@@ -844,12 +857,12 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx) | |||
844 | /* Take care of the codec-specific extradata. */ | 857 | /* Take care of the codec-specific extradata. */ |
845 | if (rmctx->extradata_size == 14) { | 858 | if (rmctx->extradata_size == 14) { |
846 | /* Parse the extradata, WAV format */ | 859 | /* Parse the extradata, WAV format */ |
847 | DEBUGF("[0-1] %d\n",bytestream_get_le16(&edata_ptr)); //Unknown value always 1 | 860 | DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); //Unknown value always 1 |
848 | q->samples_per_channel = bytestream_get_le32(&edata_ptr); | 861 | q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]); |
849 | q->codingMode = bytestream_get_le16(&edata_ptr); | 862 | q->codingMode = rm_get_uint16le(&edata_ptr[6]); |
850 | DEBUGF("[8-9] %d\n",bytestream_get_le16(&edata_ptr)); //Dupe of coding mode | 863 | DEBUGF("[8-9] %d\n",rm_get_uint16le(&edata_ptr[8])); //Dupe of coding mode |
851 | q->frame_factor = bytestream_get_le16(&edata_ptr); //Unknown always 1 | 864 | q->frame_factor = rm_get_uint16le(&edata_ptr[10]); //Unknown always 1 |
852 | DEBUGF("[12-13] %d\n",bytestream_get_le16(&edata_ptr)); //Unknown always 0 | 865 | DEBUGF("[12-13] %d\n",rm_get_uint16le(&edata_ptr[12])); //Unknown always 0 |
853 | 866 | ||
854 | /* setup */ | 867 | /* setup */ |
855 | q->samples_per_frame = 1024 * q->channels; | 868 | q->samples_per_frame = 1024 * q->channels; |
@@ -869,10 +882,10 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx) | |||
869 | 882 | ||
870 | } else if (rmctx->extradata_size == 10) { | 883 | } else if (rmctx->extradata_size == 10) { |
871 | /* Parse the extradata, RM format. */ | 884 | /* Parse the extradata, RM format. */ |
872 | q->atrac3version = bytestream_get_be32(&edata_ptr); | 885 | q->atrac3version = rm_get_uint32be(&edata_ptr[0]); |
873 | q->samples_per_frame = bytestream_get_be16(&edata_ptr); | 886 | q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]); |
874 | q->delay = bytestream_get_be16(&edata_ptr); | 887 | q->delay = rm_get_uint16be(&edata_ptr[6]); |
875 | q->codingMode = bytestream_get_be16(&edata_ptr); | 888 | q->codingMode = rm_get_uint16be(&edata_ptr[8]); |
876 | 889 | ||
877 | q->samples_per_channel = q->samples_per_frame / q->channels; | 890 | q->samples_per_channel = q->samples_per_frame / q->channels; |
878 | q->scrambled_stream = 1; | 891 | q->scrambled_stream = 1; |