- if (*data_size < (framelen * s->channels * 2)) {
- av_log(avctx, AV_LOG_ERROR, "Output buffer size is too small.\n");
- return -1;
- }
- // FIXME: seeking
- s->total_frames--;
- if (!s->total_frames && s->last_frame_length)
- framelen = s->last_frame_length;
-
- // init per channel states
- for (i = 0; i < s->channels; i++) {
- s->ch_ctx[i].predictor = 0;
- ttafilter_init(&s->ch_ctx[i].filter, ttafilter_configs[s->bps-1][0], ttafilter_configs[s->bps-1][1]);
- rice_init(&s->ch_ctx[i].rice, 10, 10);
+ // FIXME: seeking
+ s->total_frames--;
+ if (!s->total_frames && s->last_frame_length)
+ framelen = s->last_frame_length;
+
+ /* get output buffer */
+ s->frame.nb_samples = framelen;
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
+ }
+
+ // decode directly to output buffer for 24-bit sample format
+ if (s->bps == 3)
+ s->decode_buffer = (int32_t *)s->frame.data[0];
+
+ // init per channel states
+ for (i = 0; i < s->channels; i++) {
+ s->ch_ctx[i].predictor = 0;
+ ttafilter_init(&s->ch_ctx[i].filter, ttafilter_configs[s->bps-1][0], ttafilter_configs[s->bps-1][1]);
+ rice_init(&s->ch_ctx[i].rice, 10, 10);
+ }
+
+ for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) {
+ int32_t *predictor = &s->ch_ctx[cur_chan].predictor;
+ TTAFilter *filter = &s->ch_ctx[cur_chan].filter;
+ TTARice *rice = &s->ch_ctx[cur_chan].rice;
+ uint32_t unary, depth, k;
+ int32_t value;
+
+ unary = tta_get_unary(&s->gb);
+
+ if (unary == 0) {
+ depth = 0;
+ k = rice->k0;
+ } else {
+ depth = 1;
+ k = rice->k1;
+ unary--;