Unified · Split
| @@ -429,7 +429,7 @@ OBJS-$(CONFIG_TRUEMOTION2_DECODER) += truemotion2.o · 428 unmodified lines | ||
| 429 | 429 | OBJS-$(CONFIG_TRUESPEECH_DECODER) += truespeech.o |
| 430 | 430 | OBJS-$(CONFIG_TSCC_DECODER) += tscc.o msrledec.o |
| 431 | 431 | OBJS-$(CONFIG_TSCC2_DECODER) += tscc2.o |
| 432 | −OBJS-$(CONFIG_TTA_DECODER) += tta.o | |
| 432 | +OBJS-$(CONFIG_TTA_DECODER) += tta.o ttadata.o | |
| 433 | 433 | OBJS-$(CONFIG_TWINVQ_DECODER) += twinvq.o |
| 434 | 434 | OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o |
| 435 | 435 | OBJS-$(CONFIG_ULTI_DECODER) += ulti.o |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | #define BITSTREAM_READER_LE |
| 31 | 31 | #include <limits.h> |
| 32 | +#include "ttadata.h" | |
| 32 | 33 | #include "avcodec.h" |
| 33 | 34 | #include "get_bits.h" |
| 34 | 35 | #include "unary.h" |
| @@ -40,24 +41,6 @@ · 5 unmodified lines | ||
| 40 | 41 | #define FORMAT_SIMPLE 1 |
| 41 | 42 | #define FORMAT_ENCRYPTED 2 |
| 42 | 43 | |
| 43 | −#define MAX_ORDER 16 | |
| 44 | −typedef struct TTAFilter { | |
| 45 | − int32_t shift, round, error; | |
| 46 | − int32_t qm[MAX_ORDER]; | |
| 47 | − int32_t dx[MAX_ORDER]; | |
| 48 | − int32_t dl[MAX_ORDER]; | |
| 49 | −} TTAFilter; | |
| 50 | − | |
| 51 | −typedef struct TTARice { | |
| 52 | − uint32_t k0, k1, sum0, sum1; | |
| 53 | −} TTARice; | |
| 54 | − | |
| 55 | −typedef struct TTAChannel { | |
| 56 | − int32_t predictor; | |
| 57 | − TTAFilter filter; | |
| 58 | − TTARice rice; | |
| 59 | −} TTAChannel; | |
| 60 | − | |
| 61 | 44 | typedef struct TTAContext { |
| 62 | 45 | AVClass *class; |
| 63 | 46 | AVCodecContext *avctx; |
| @@ -75,40 +58,6 @@ typedef struct TTAContext { · 11 unmodified lines | ||
| 75 | 58 | TTAChannel *ch_ctx; |
| 76 | 59 | } TTAContext; |
| 77 | 60 | |
| 78 | −static const uint32_t shift_1[] = { | |
| 79 | − 0x00000001, 0x00000002, 0x00000004, 0x00000008, | |
| 80 | − 0x00000010, 0x00000020, 0x00000040, 0x00000080, | |
| 81 | − 0x00000100, 0x00000200, 0x00000400, 0x00000800, | |
| 82 | − 0x00001000, 0x00002000, 0x00004000, 0x00008000, | |
| 83 | − 0x00010000, 0x00020000, 0x00040000, 0x00080000, | |
| 84 | − 0x00100000, 0x00200000, 0x00400000, 0x00800000, | |
| 85 | − 0x01000000, 0x02000000, 0x04000000, 0x08000000, | |
| 86 | − 0x10000000, 0x20000000, 0x40000000, 0x80000000, | |
| 87 | − 0x80000000, 0x80000000, 0x80000000, 0x80000000, | |
| 88 | − 0x80000000, 0x80000000, 0x80000000, 0x80000000 | |
| 89 | −}; | |
| 90 | − | |
| 91 | −static const uint32_t * const shift_16 = shift_1 + 4; | |
| 92 | − | |
| 93 | −static const int32_t ttafilter_configs[4] = { | |
| 94 | − 10, | |
| 95 | − 9, | |
| 96 | − 10, | |
| 97 | − 12 | |
| 98 | −}; | |
| 99 | − | |
| 100 | −static void ttafilter_init(TTAContext *s, TTAFilter *c, int32_t shift) { | |
| 101 | − memset(c, 0, sizeof(TTAFilter)); | |
| 102 | − if (s->format == FORMAT_ENCRYPTED) { | |
| 103 | − int i; | |
| 104 | − for (i = 0; i < 8; i++) | |
| 105 | − c->qm[i] = sign_extend(s->crc_pass[i], 8); | |
| 106 | − } | |
| 107 | − c->shift = shift; | |
| 108 | − c->round = shift_1[shift-1]; | |
| 109 | −// c->round = 1 << (shift - 1); | |
| 110 | −} | |
| 111 | − | |
| 112 | 61 | static inline void ttafilter_process(TTAFilter *c, int32_t *in) |
| 113 | 62 | { |
| 114 | 63 | register int32_t *dl = c->dl, *qm = c->qm, *dx = c->dx, sum = c->round; |
| @@ -140,14 +89,6 @@ static inline void ttafilter_process(TTAFilter *c, int32_t *in) · 25 unmodified lines | ||
| 140 | 89 | dl[5] += dl[6]; dl[4] += dl[5]; |
| 141 | 90 | } |
| 142 | 91 | |
| 143 | −static void rice_init(TTARice *c, uint32_t k0, uint32_t k1) | |
| 144 | −{ | |
| 145 | − c->k0 = k0; | |
| 146 | − c->k1 = k1; | |
| 147 | − c->sum0 = shift_16[k0]; | |
| 148 | − c->sum1 = shift_16[k1]; | |
| 149 | −} | |
| 150 | − | |
| 151 | 92 | static const int64_t tta_channel_layouts[7] = { |
| 152 | 93 | AV_CH_LAYOUT_STEREO, |
| 153 | 94 | AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY, |
| @@ -319,9 +260,15 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data, · 165 unmodified lines | ||
| 319 | 260 | |
| 320 | 261 | // init per channel states |
| 321 | 262 | for (i = 0; i < s->channels; i++) { |
| 263 | + TTAFilter *filter = &s->ch_ctx[i].filter; | |
| 322 | 264 | s->ch_ctx[i].predictor = 0; |
| 323 | − ttafilter_init(s, &s->ch_ctx[i].filter, ttafilter_configs[s->bps-1]); | |
| 324 | − rice_init(&s->ch_ctx[i].rice, 10, 10); | |
| 265 | + ff_tta_filter_init(filter, ff_tta_filter_configs[s->bps-1]); | |
| 266 | + if (s->format == FORMAT_ENCRYPTED) { | |
| 267 | + int i; | |
| 268 | + for (i = 0; i < 8; i++) | |
| 269 | + filter->qm[i] = sign_extend(s->crc_pass[i], 8); | |
| 270 | + } | |
| 271 | + ff_tta_rice_init(&s->ch_ctx[i].rice, 10, 10); | |
| 325 | 272 | } |
| 326 | 273 | |
| 327 | 274 | i = 0; |
| @@ -361,16 +308,16 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data, · 33 unmodified lines | ||
| 361 | 308 | switch (depth) { |
| 362 | 309 | case 1: |
| 363 | 310 | rice->sum1 += value - (rice->sum1 >> 4); |
| 364 | − if (rice->k1 > 0 && rice->sum1 < shift_16[rice->k1]) | |
| 311 | + if (rice->k1 > 0 && rice->sum1 < ff_tta_shift_16[rice->k1]) | |
| 365 | 312 | rice->k1--; |
| 366 | − else if(rice->sum1 > shift_16[rice->k1 + 1]) | |
| 313 | + else if(rice->sum1 > ff_tta_shift_16[rice->k1 + 1]) | |
| 367 | 314 | rice->k1++; |
| 368 | − value += shift_1[rice->k0]; | |
| 315 | + value += ff_tta_shift_1[rice->k0]; | |
| 369 | 316 | default: |
| 370 | 317 | rice->sum0 += value - (rice->sum0 >> 4); |
| 371 | − if (rice->k0 > 0 && rice->sum0 < shift_16[rice->k0]) | |
| 318 | + if (rice->k0 > 0 && rice->sum0 < ff_tta_shift_16[rice->k0]) | |
| 372 | 319 | rice->k0--; |
| 373 | − else if(rice->sum0 > shift_16[rice->k0 + 1]) | |
| 320 | + else if(rice->sum0 > ff_tta_shift_16[rice->k0 + 1]) | |
| 374 | 321 | rice->k0++; |
| 375 | 322 | } |
| 376 | 323 | |
| @@ -0,0 +1,52 @@ | ||
| 1 | +/* | |
| 2 | + * TTA (The Lossless True Audio) data | |
| 3 | + * | |
| 4 | + * This file is part of FFmpeg. | |
| 5 | + * | |
| 6 | + * FFmpeg is free software; you can redistribute it and/or | |
| 7 | + * modify it under the terms of the GNU Lesser General Public | |
| 8 | + * License as published by the Free Software Foundation; either | |
| 9 | + * version 2.1 of the License, or (at your option) any later version. | |
| 10 | + * | |
| 11 | + * FFmpeg is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | + * Lesser General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public | |
| 17 | + * License along with FFmpeg; if not, write to the Free Software | |
| 18 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#include "ttadata.h" | |
| 22 | + | |
| 23 | +const uint32_t ff_tta_shift_1[] = { | |
| 24 | + 0x00000001, 0x00000002, 0x00000004, 0x00000008, | |
| 25 | + 0x00000010, 0x00000020, 0x00000040, 0x00000080, | |
| 26 | + 0x00000100, 0x00000200, 0x00000400, 0x00000800, | |
| 27 | + 0x00001000, 0x00002000, 0x00004000, 0x00008000, | |
| 28 | + 0x00010000, 0x00020000, 0x00040000, 0x00080000, | |
| 29 | + 0x00100000, 0x00200000, 0x00400000, 0x00800000, | |
| 30 | + 0x01000000, 0x02000000, 0x04000000, 0x08000000, | |
| 31 | + 0x10000000, 0x20000000, 0x40000000, 0x80000000, | |
| 32 | + 0x80000000, 0x80000000, 0x80000000, 0x80000000, | |
| 33 | + 0x80000000, 0x80000000, 0x80000000, 0x80000000 | |
| 34 | +}; | |
| 35 | + | |
| 36 | +const uint32_t * const ff_tta_shift_16 = ff_tta_shift_1 + 4; | |
| 37 | + | |
| 38 | +const uint8_t ff_tta_filter_configs[] = { 10, 9, 10, 12 }; | |
| 39 | + | |
| 40 | +void ff_tta_rice_init(TTARice *c, uint32_t k0, uint32_t k1) | |
| 41 | +{ | |
| 42 | + c->k0 = k0; | |
| 43 | + c->k1 = k1; | |
| 44 | + c->sum0 = ff_tta_shift_16[k0]; | |
| 45 | + c->sum1 = ff_tta_shift_16[k1]; | |
| 46 | +} | |
| 47 | + | |
| 48 | +void ff_tta_filter_init(TTAFilter *c, int32_t shift) { | |
| 49 | + memset(c, 0, sizeof(TTAFilter)); | |
| 50 | + c->shift = shift; | |
| 51 | + c->round = ff_tta_shift_1[shift-1]; | |
| 52 | +} | |
| @@ -0,0 +1,50 @@ | ||
| 1 | +/* | |
| 2 | + * TTA (The Lossless True Audio) data | |
| 3 | + * | |
| 4 | + * This file is part of FFmpeg. | |
| 5 | + * | |
| 6 | + * FFmpeg is free software; you can redistribute it and/or | |
| 7 | + * modify it under the terms of the GNU Lesser General Public | |
| 8 | + * License as published by the Free Software Foundation; either | |
| 9 | + * version 2.1 of the License, or (at your option) any later version. | |
| 10 | + * | |
| 11 | + * FFmpeg is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | + * Lesser General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public | |
| 17 | + * License along with FFmpeg; if not, write to the Free Software | |
| 18 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#ifndef AVCODEC_TTADATA_H | |
| 22 | +#define AVCODEC_TTADATA_H | |
| 23 | + | |
| 24 | +#include "internal.h" | |
| 25 | + | |
| 26 | +#define MAX_ORDER 16 | |
| 27 | +typedef struct TTAFilter { | |
| 28 | + int32_t shift, round, error; | |
| 29 | + int32_t qm[MAX_ORDER]; | |
| 30 | + int32_t dx[MAX_ORDER]; | |
| 31 | + int32_t dl[MAX_ORDER]; | |
| 32 | +} TTAFilter; | |
| 33 | + | |
| 34 | +typedef struct TTARice { | |
| 35 | + uint32_t k0, k1, sum0, sum1; | |
| 36 | +} TTARice; | |
| 37 | + | |
| 38 | +typedef struct TTAChannel { | |
| 39 | + int32_t predictor; | |
| 40 | + TTAFilter filter; | |
| 41 | + TTARice rice; | |
| 42 | +} TTAChannel; | |
| 43 | + | |
| 44 | +extern const uint32_t ff_tta_shift_1[]; | |
| 45 | +extern const uint32_t * const ff_tta_shift_16; | |
| 46 | +extern const uint8_t ff_tta_filter_configs[]; | |
| 47 | + | |
| 48 | +void ff_tta_rice_init(TTARice *c, uint32_t k0, uint32_t k1); | |
| 49 | +void ff_tta_filter_init(TTAFilter *c, int32_t shift); | |
| 50 | +#endif /* AVCODEC_TTADATA_H */ | |