Commit 012c4511 authored by Alexandra Hájková's avatar Alexandra Hájková Committed by Anton Khirnov

adpcm: Convert to the new bitstream header

Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent ed006ae4
...@@ -29,8 +29,9 @@ ...@@ -29,8 +29,9 @@
* License along with Libav; if not, write to the Free Software * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "avcodec.h" #include "avcodec.h"
#include "get_bits.h" #include "bitstream.h"
#include "put_bits.h" #include "put_bits.h"
#include "bytestream.h" #include "bytestream.h"
#include "adpcm.h" #include "adpcm.h"
...@@ -366,32 +367,33 @@ static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, ...@@ -366,32 +367,33 @@ static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1,
static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int16_t *samples) static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int16_t *samples)
{ {
ADPCMDecodeContext *c = avctx->priv_data; ADPCMDecodeContext *c = avctx->priv_data;
GetBitContext gb; BitstreamContext bc;
const int *table; const int *table;
int k0, signmask, nb_bits, count; int k0, signmask, nb_bits, count;
int size = buf_size*8; int size = buf_size*8;
int i; int i;
init_get_bits(&gb, buf, size); bitstream_init(&bc, buf, size);
//read bits & initial values //read bits & initial values
nb_bits = get_bits(&gb, 2)+2; nb_bits = bitstream_read(&bc, 2)+2;
table = swf_index_tables[nb_bits-2]; table = swf_index_tables[nb_bits-2];
k0 = 1 << (nb_bits-2); k0 = 1 << (nb_bits-2);
signmask = 1 << (nb_bits-1); signmask = 1 << (nb_bits-1);
while (get_bits_count(&gb) <= size - 22*avctx->channels) { while (bitstream_tell(&bc) <= size - 22 * avctx->channels) {
for (i = 0; i < avctx->channels; i++) { for (i = 0; i < avctx->channels; i++) {
*samples++ = c->status[i].predictor = get_sbits(&gb, 16); *samples++ =
c->status[i].step_index = get_bits(&gb, 6); c->status[i].predictor = bitstream_read_signed(&bc, 16);
c->status[i].step_index = bitstream_read(&bc, 6);
} }
for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) { for (count = 0; bitstream_tell(&bc) <= size - nb_bits * avctx->channels && count < 4095; count++) {
int i; int i;
for (i = 0; i < avctx->channels; i++) { for (i = 0; i < avctx->channels; i++) {
// similar to IMA adpcm // similar to IMA adpcm
int delta = get_bits(&gb, nb_bits); int delta = bitstream_read(&bc, nb_bits);
int step = ff_adpcm_step_table[c->status[i].step_index]; int step = ff_adpcm_step_table[c->status[i].step_index];
long vpdiff = 0; // vpdiff = (delta+0.5)*step/4 long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
int k = k0; int k = k0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment