00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027
00028
00029
00030
00031 #include <stdio.h>
00032 #include <stdlib.h>
00033
00034 #include "avcodec.h"
00035
00036 #define ALT_BITSTREAM_READER_LE
00037 #include "bitstream.h"
00038 #include "bytestream.h"
00039
00040 #define SMKTREE_BITS 9
00041 #define SMK_NODE 0x80000000
00042
00043
00044
00045
00046 typedef struct SmackVContext {
00047 AVCodecContext *avctx;
00048 AVFrame pic;
00049
00050 int *mmap_tbl, *mclr_tbl, *full_tbl, *type_tbl;
00051 int mmap_last[3], mclr_last[3], full_last[3], type_last[3];
00052 } SmackVContext;
00053
00057 typedef struct HuffContext {
00058 int length;
00059 int maxlength;
00060 int current;
00061 uint32_t *bits;
00062 int *lengths;
00063 int *values;
00064 } HuffContext;
00065
00066
00067 typedef struct DBCtx {
00068 VLC *v1, *v2;
00069 int *recode1, *recode2;
00070 int escapes[3];
00071 int *last;
00072 int lcur;
00073 } DBCtx;
00074
00075
00076 static const int block_runs[64] = {
00077 1, 2, 3, 4, 5, 6, 7, 8,
00078 9, 10, 11, 12, 13, 14, 15, 16,
00079 17, 18, 19, 20, 21, 22, 23, 24,
00080 25, 26, 27, 28, 29, 30, 31, 32,
00081 33, 34, 35, 36, 37, 38, 39, 40,
00082 41, 42, 43, 44, 45, 46, 47, 48,
00083 49, 50, 51, 52, 53, 54, 55, 56,
00084 57, 58, 59, 128, 256, 512, 1024, 2048 };
00085
00086 enum SmkBlockTypes {
00087 SMK_BLK_MONO = 0,
00088 SMK_BLK_FULL = 1,
00089 SMK_BLK_SKIP = 2,
00090 SMK_BLK_FILL = 3 };
00091
00095 static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t prefix, int length)
00096 {
00097 if(!get_bits1(gb)){
00098 if(hc->current >= 256){
00099 av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
00100 return -1;
00101 }
00102 if(length){
00103 hc->bits[hc->current] = prefix;
00104 hc->lengths[hc->current] = length;
00105 } else {
00106 hc->bits[hc->current] = 0;
00107 hc->lengths[hc->current] = 0;
00108 }
00109 hc->values[hc->current] = get_bits(gb, 8);
00110 hc->current++;
00111 if(hc->maxlength < length)
00112 hc->maxlength = length;
00113 return 0;
00114 } else {
00115 int r;
00116 length++;
00117 r = smacker_decode_tree(gb, hc, prefix, length);
00118 if(r)
00119 return r;
00120 return smacker_decode_tree(gb, hc, prefix | (1 << (length - 1)), length);
00121 }
00122 }
00123
00127 static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx)
00128 {
00129 if(!get_bits1(gb)){
00130 int val, i1, i2, b1, b2;
00131 if(hc->current >= hc->length){
00132 av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
00133 return -1;
00134 }
00135 b1 = get_bits_count(gb);
00136 i1 = ctx->v1->table ? get_vlc2(gb, ctx->v1->table, SMKTREE_BITS, 3) : 0;
00137 b1 = get_bits_count(gb) - b1;
00138 b2 = get_bits_count(gb);
00139 i2 = ctx->v2->table ? get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3) : 0;
00140 b2 = get_bits_count(gb) - b2;
00141 if (i1 < 0 || i2 < 0)
00142 return -1;
00143 val = ctx->recode1[i1] | (ctx->recode2[i2] << 8);
00144 if(val == ctx->escapes[0]) {
00145 ctx->last[0] = hc->current;
00146 val = 0;
00147 } else if(val == ctx->escapes[1]) {
00148 ctx->last[1] = hc->current;
00149 val = 0;
00150 } else if(val == ctx->escapes[2]) {
00151 ctx->last[2] = hc->current;
00152 val = 0;
00153 }
00154
00155 hc->values[hc->current++] = val;
00156 return 1;
00157 } else {
00158 int r = 0, t;
00159
00160 t = hc->current++;
00161 r = smacker_decode_bigtree(gb, hc, ctx);
00162 if(r < 0)
00163 return r;
00164 hc->values[t] = SMK_NODE | r;
00165 r++;
00166 r += smacker_decode_bigtree(gb, hc, ctx);
00167 return r;
00168 }
00169 }
00170
00174 static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int **recodes, int *last, int size)
00175 {
00176 int res;
00177 HuffContext huff;
00178 HuffContext tmp1, tmp2;
00179 VLC vlc[2];
00180 int escapes[3];
00181 DBCtx ctx;
00182
00183 if(size >= UINT_MAX>>4){
00184 av_log(smk->avctx, AV_LOG_ERROR, "size too large\n");
00185 return -1;
00186 }
00187
00188 tmp1.length = 256;
00189 tmp1.maxlength = 0;
00190 tmp1.current = 0;
00191 tmp1.bits = av_mallocz(256 * 4);
00192 tmp1.lengths = av_mallocz(256 * sizeof(int));
00193 tmp1.values = av_mallocz(256 * sizeof(int));
00194
00195 tmp2.length = 256;
00196 tmp2.maxlength = 0;
00197 tmp2.current = 0;
00198 tmp2.bits = av_mallocz(256 * 4);
00199 tmp2.lengths = av_mallocz(256 * sizeof(int));
00200 tmp2.values = av_mallocz(256 * sizeof(int));
00201
00202 memset(&vlc[0], 0, sizeof(VLC));
00203 memset(&vlc[1], 0, sizeof(VLC));
00204
00205 if(get_bits1(gb)) {
00206 smacker_decode_tree(gb, &tmp1, 0, 0);
00207 skip_bits1(gb);
00208 res = init_vlc(&vlc[0], SMKTREE_BITS, tmp1.length,
00209 tmp1.lengths, sizeof(int), sizeof(int),
00210 tmp1.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
00211 if(res < 0) {
00212 av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
00213 return -1;
00214 }
00215 } else {
00216 av_log(smk->avctx, AV_LOG_ERROR, "Skipping low bytes tree\n");
00217 }
00218 if(get_bits1(gb)){
00219 smacker_decode_tree(gb, &tmp2, 0, 0);
00220 skip_bits1(gb);
00221 res = init_vlc(&vlc[1], SMKTREE_BITS, tmp2.length,
00222 tmp2.lengths, sizeof(int), sizeof(int),
00223 tmp2.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
00224 if(res < 0) {
00225 av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
00226 return -1;
00227 }
00228 } else {
00229 av_log(smk->avctx, AV_LOG_ERROR, "Skipping high bytes tree\n");
00230 }
00231
00232 escapes[0] = get_bits(gb, 8);
00233 escapes[0] |= get_bits(gb, 8) << 8;
00234 escapes[1] = get_bits(gb, 8);
00235 escapes[1] |= get_bits(gb, 8) << 8;
00236 escapes[2] = get_bits(gb, 8);
00237 escapes[2] |= get_bits(gb, 8) << 8;
00238
00239 last[0] = last[1] = last[2] = -1;
00240
00241 ctx.escapes[0] = escapes[0];
00242 ctx.escapes[1] = escapes[1];
00243 ctx.escapes[2] = escapes[2];
00244 ctx.v1 = &vlc[0];
00245 ctx.v2 = &vlc[1];
00246 ctx.recode1 = tmp1.values;
00247 ctx.recode2 = tmp2.values;
00248 ctx.last = last;
00249
00250 huff.length = ((size + 3) >> 2) + 3;
00251 huff.maxlength = 0;
00252 huff.current = 0;
00253 huff.values = av_mallocz(huff.length * sizeof(int));
00254
00255 smacker_decode_bigtree(gb, &huff, &ctx);
00256 skip_bits1(gb);
00257 if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
00258 if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
00259 if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
00260
00261 *recodes = huff.values;
00262
00263 if(vlc[0].table)
00264 free_vlc(&vlc[0]);
00265 if(vlc[1].table)
00266 free_vlc(&vlc[1]);
00267 av_free(tmp1.bits);
00268 av_free(tmp1.lengths);
00269 av_free(tmp1.values);
00270 av_free(tmp2.bits);
00271 av_free(tmp2.lengths);
00272 av_free(tmp2.values);
00273
00274 return 0;
00275 }
00276
00277 static int decode_header_trees(SmackVContext *smk) {
00278 GetBitContext gb;
00279 int mmap_size, mclr_size, full_size, type_size;
00280
00281 mmap_size = AV_RL32(smk->avctx->extradata);
00282 mclr_size = AV_RL32(smk->avctx->extradata + 4);
00283 full_size = AV_RL32(smk->avctx->extradata + 8);
00284 type_size = AV_RL32(smk->avctx->extradata + 12);
00285
00286 init_get_bits(&gb, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);
00287
00288 if(!get_bits1(&gb)) {
00289 av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
00290 smk->mmap_tbl = av_malloc(sizeof(int) * 2);
00291 smk->mmap_tbl[0] = 0;
00292 smk->mmap_last[0] = smk->mmap_last[1] = smk->mmap_last[2] = 1;
00293 } else {
00294 if (smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size))
00295 return -1;
00296 }
00297 if(!get_bits1(&gb)) {
00298 av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
00299 smk->mclr_tbl = av_malloc(sizeof(int) * 2);
00300 smk->mclr_tbl[0] = 0;
00301 smk->mclr_last[0] = smk->mclr_last[1] = smk->mclr_last[2] = 1;
00302 } else {
00303 if (smacker_decode_header_tree(smk, &gb, &smk->mclr_tbl, smk->mclr_last, mclr_size))
00304 return -1;
00305 }
00306 if(!get_bits1(&gb)) {
00307 av_log(smk->avctx, AV_LOG_INFO, "Skipping FULL tree\n");
00308 smk->full_tbl = av_malloc(sizeof(int) * 2);
00309 smk->full_tbl[0] = 0;
00310 smk->full_last[0] = smk->full_last[1] = smk->full_last[2] = 1;
00311 } else {
00312 if (smacker_decode_header_tree(smk, &gb, &smk->full_tbl, smk->full_last, full_size))
00313 return -1;
00314 }
00315 if(!get_bits1(&gb)) {
00316 av_log(smk->avctx, AV_LOG_INFO, "Skipping TYPE tree\n");
00317 smk->type_tbl = av_malloc(sizeof(int) * 2);
00318 smk->type_tbl[0] = 0;
00319 smk->type_last[0] = smk->type_last[1] = smk->type_last[2] = 1;
00320 } else {
00321 if (smacker_decode_header_tree(smk, &gb, &smk->type_tbl, smk->type_last, type_size))
00322 return -1;
00323 }
00324
00325 return 0;
00326 }
00327
00328 static av_always_inline void last_reset(int *recode, int *last) {
00329 recode[last[0]] = recode[last[1]] = recode[last[2]] = 0;
00330 }
00331
00332
00333 static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *last) {
00334 register int *table = recode;
00335 int v, b;
00336
00337 b = get_bits_count(gb);
00338 while(*table & SMK_NODE) {
00339 if(get_bits1(gb))
00340 table += (*table) & (~SMK_NODE);
00341 table++;
00342 }
00343 v = *table;
00344 b = get_bits_count(gb) - b;
00345
00346 if(v != recode[last[0]]) {
00347 recode[last[2]] = recode[last[1]];
00348 recode[last[1]] = recode[last[0]];
00349 recode[last[0]] = v;
00350 }
00351 return v;
00352 }
00353
00354 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
00355 {
00356 SmackVContext * const smk = avctx->priv_data;
00357 uint8_t *out;
00358 uint32_t *pal;
00359 GetBitContext gb;
00360 int blocks, blk, bw, bh;
00361 int i;
00362 int stride;
00363
00364 if(buf_size <= 769)
00365 return 0;
00366 if(smk->pic.data[0])
00367 avctx->release_buffer(avctx, &smk->pic);
00368
00369 smk->pic.reference = 1;
00370 smk->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
00371 if(avctx->reget_buffer(avctx, &smk->pic) < 0){
00372 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
00373 return -1;
00374 }
00375
00376
00377 pal = (uint32_t*)smk->pic.data[1];
00378 smk->pic.palette_has_changed = buf[0] & 1;
00379 smk->pic.key_frame = !!(buf[0] & 2);
00380 if(smk->pic.key_frame)
00381 smk->pic.pict_type = FF_I_TYPE;
00382 else
00383 smk->pic.pict_type = FF_P_TYPE;
00384
00385 buf++;
00386 for(i = 0; i < 256; i++)
00387 *pal++ = bytestream_get_be24(&buf);
00388 buf_size -= 769;
00389
00390 last_reset(smk->mmap_tbl, smk->mmap_last);
00391 last_reset(smk->mclr_tbl, smk->mclr_last);
00392 last_reset(smk->full_tbl, smk->full_last);
00393 last_reset(smk->type_tbl, smk->type_last);
00394 init_get_bits(&gb, buf, buf_size * 8);
00395
00396 blk = 0;
00397 bw = avctx->width >> 2;
00398 bh = avctx->height >> 2;
00399 blocks = bw * bh;
00400 out = smk->pic.data[0];
00401 stride = smk->pic.linesize[0];
00402 while(blk < blocks) {
00403 int type, run, mode;
00404 uint16_t pix;
00405
00406 type = smk_get_code(&gb, smk->type_tbl, smk->type_last);
00407 run = block_runs[(type >> 2) & 0x3F];
00408 switch(type & 3){
00409 case SMK_BLK_MONO:
00410 while(run-- && blk < blocks){
00411 int clr, map;
00412 int hi, lo;
00413 clr = smk_get_code(&gb, smk->mclr_tbl, smk->mclr_last);
00414 map = smk_get_code(&gb, smk->mmap_tbl, smk->mmap_last);
00415 out = smk->pic.data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
00416 hi = clr >> 8;
00417 lo = clr & 0xFF;
00418 for(i = 0; i < 4; i++) {
00419 if(map & 1) out[0] = hi; else out[0] = lo;
00420 if(map & 2) out[1] = hi; else out[1] = lo;
00421 if(map & 4) out[2] = hi; else out[2] = lo;
00422 if(map & 8) out[3] = hi; else out[3] = lo;
00423 map >>= 4;
00424 out += stride;
00425 }
00426 blk++;
00427 }
00428 break;
00429 case SMK_BLK_FULL:
00430 mode = 0;
00431 if(avctx->codec_tag == MKTAG('S', 'M', 'K', '4')) {
00432 if(get_bits1(&gb)) mode = 1;
00433 else if(get_bits1(&gb)) mode = 2;
00434 }
00435 while(run-- && blk < blocks){
00436 out = smk->pic.data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
00437 switch(mode){
00438 case 0:
00439 for(i = 0; i < 4; i++) {
00440 pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00441 AV_WL16(out+2,pix);
00442 pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00443 AV_WL16(out,pix);
00444 out += stride;
00445 }
00446 break;
00447 case 1:
00448 pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00449 out[0] = out[1] = pix & 0xFF;
00450 out[2] = out[3] = pix >> 8;
00451 out += stride;
00452 out[0] = out[1] = pix & 0xFF;
00453 out[2] = out[3] = pix >> 8;
00454 out += stride;
00455 pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00456 out[0] = out[1] = pix & 0xFF;
00457 out[2] = out[3] = pix >> 8;
00458 out += stride;
00459 out[0] = out[1] = pix & 0xFF;
00460 out[2] = out[3] = pix >> 8;
00461 out += stride;
00462 break;
00463 case 2:
00464 for(i = 0; i < 2; i++) {
00465 uint16_t pix1, pix2;
00466 pix2 = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00467 pix1 = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00468 AV_WL16(out,pix1);
00469 AV_WL16(out+2,pix2);
00470 out += stride;
00471 AV_WL16(out,pix1);
00472 AV_WL16(out+2,pix2);
00473 out += stride;
00474 }
00475 break;
00476 }
00477 blk++;
00478 }
00479 break;
00480 case SMK_BLK_SKIP:
00481 while(run-- && blk < blocks)
00482 blk++;
00483 break;
00484 case SMK_BLK_FILL:
00485 mode = type >> 8;
00486 while(run-- && blk < blocks){
00487 uint32_t col;
00488 out = smk->pic.data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
00489 col = mode * 0x01010101;
00490 for(i = 0; i < 4; i++) {
00491 *((uint32_t*)out) = col;
00492 out += stride;
00493 }
00494 blk++;
00495 }
00496 break;
00497 }
00498
00499 }
00500
00501 *data_size = sizeof(AVFrame);
00502 *(AVFrame*)data = smk->pic;
00503
00504
00505 return buf_size;
00506 }
00507
00508
00509
00510
00511
00512
00513
00514
00515 static av_cold int decode_init(AVCodecContext *avctx)
00516 {
00517 SmackVContext * const c = avctx->priv_data;
00518
00519 c->avctx = avctx;
00520
00521 c->pic.data[0] = NULL;
00522
00523 if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
00524 return 1;
00525 }
00526
00527 avctx->pix_fmt = PIX_FMT_PAL8;
00528
00529
00530
00531 if(avctx->extradata_size < 16){
00532 av_log(avctx, AV_LOG_ERROR, "Extradata missing!\n");
00533 return -1;
00534 }
00535
00536 if (decode_header_trees(c))
00537 return -1;
00538
00539 return 0;
00540 }
00541
00542
00543
00544
00545
00546
00547
00548
00549 static av_cold int decode_end(AVCodecContext *avctx)
00550 {
00551 SmackVContext * const smk = avctx->priv_data;
00552
00553 av_freep(&smk->mmap_tbl);
00554 av_freep(&smk->mclr_tbl);
00555 av_freep(&smk->full_tbl);
00556 av_freep(&smk->type_tbl);
00557
00558 if (smk->pic.data[0])
00559 avctx->release_buffer(avctx, &smk->pic);
00560
00561 return 0;
00562 }
00563
00564
00565 static av_cold int smka_decode_init(AVCodecContext *avctx)
00566 {
00567 avctx->sample_fmt = SAMPLE_FMT_S16;
00568 avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
00569 return 0;
00570 }
00571
00575 static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
00576 {
00577 GetBitContext gb;
00578 HuffContext h[4];
00579 VLC vlc[4];
00580 int16_t *samples = data;
00581 int val;
00582 int i, res;
00583 int unp_size;
00584 int bits, stereo;
00585 int pred[2] = {0, 0};
00586
00587 unp_size = AV_RL32(buf);
00588
00589 init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
00590
00591 if(!get_bits1(&gb)){
00592 av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
00593 *data_size = 0;
00594 return 1;
00595 }
00596 stereo = get_bits1(&gb);
00597 bits = get_bits1(&gb);
00598 if (unp_size & 0xC0000000 || (unp_size << !bits) > *data_size) {
00599 av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
00600 return -1;
00601 }
00602
00603 memset(vlc, 0, sizeof(VLC) * 4);
00604 memset(h, 0, sizeof(HuffContext) * 4);
00605
00606 for(i = 0; i < (1 << (bits + stereo)); i++) {
00607 h[i].length = 256;
00608 h[i].maxlength = 0;
00609 h[i].current = 0;
00610 h[i].bits = av_mallocz(256 * 4);
00611 h[i].lengths = av_mallocz(256 * sizeof(int));
00612 h[i].values = av_mallocz(256 * sizeof(int));
00613 skip_bits1(&gb);
00614 smacker_decode_tree(&gb, &h[i], 0, 0);
00615 skip_bits1(&gb);
00616 if(h[i].current > 1) {
00617 res = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length,
00618 h[i].lengths, sizeof(int), sizeof(int),
00619 h[i].bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
00620 if(res < 0) {
00621 av_log(avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
00622 return -1;
00623 }
00624 }
00625 }
00626 if(bits) {
00627 for(i = stereo; i >= 0; i--)
00628 pred[i] = bswap_16(get_bits(&gb, 16));
00629 for(i = 0; i < stereo; i++)
00630 *samples++ = pred[i];
00631 for(i = 0; i < unp_size / 2; i++) {
00632 if(i & stereo) {
00633 if(vlc[2].table)
00634 res = get_vlc2(&gb, vlc[2].table, SMKTREE_BITS, 3);
00635 else
00636 res = 0;
00637 val = h[2].values[res];
00638 if(vlc[3].table)
00639 res = get_vlc2(&gb, vlc[3].table, SMKTREE_BITS, 3);
00640 else
00641 res = 0;
00642 val |= h[3].values[res] << 8;
00643 pred[1] += (int16_t)val;
00644 *samples++ = pred[1];
00645 } else {
00646 if(vlc[0].table)
00647 res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
00648 else
00649 res = 0;
00650 val = h[0].values[res];
00651 if(vlc[1].table)
00652 res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
00653 else
00654 res = 0;
00655 val |= h[1].values[res] << 8;
00656 pred[0] += val;
00657 *samples++ = pred[0];
00658 }
00659 }
00660 } else {
00661 for(i = stereo; i >= 0; i--)
00662 pred[i] = get_bits(&gb, 8);
00663 if (stereo + unp_size > *data_size)
00664 return -1;
00665 for(i = 0; i < stereo; i++)
00666 *samples++ = (pred[i] - 0x80) << 8;
00667 for(i = 0; i < unp_size; i++) {
00668 if(i & stereo){
00669 if(vlc[1].table)
00670 res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
00671 else
00672 res = 0;
00673 pred[1] += (int8_t)h[1].values[res];
00674 *samples++ = (pred[1] - 0x80) << 8;
00675 } else {
00676 if(vlc[0].table)
00677 res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
00678 else
00679 res = 0;
00680 pred[0] += (int8_t)h[0].values[res];
00681 *samples++ = (pred[0] - 0x80) << 8;
00682 }
00683 }
00684 unp_size *= 2;
00685 }
00686
00687 for(i = 0; i < 4; i++) {
00688 if(vlc[i].table)
00689 free_vlc(&vlc[i]);
00690 if(h[i].bits)
00691 av_free(h[i].bits);
00692 if(h[i].lengths)
00693 av_free(h[i].lengths);
00694 if(h[i].values)
00695 av_free(h[i].values);
00696 }
00697
00698 *data_size = unp_size;
00699 return buf_size;
00700 }
00701
00702 AVCodec smacker_decoder = {
00703 "smackvid",
00704 CODEC_TYPE_VIDEO,
00705 CODEC_ID_SMACKVIDEO,
00706 sizeof(SmackVContext),
00707 decode_init,
00708 NULL,
00709 decode_end,
00710 decode_frame,
00711 .long_name = NULL_IF_CONFIG_SMALL("Smacker video"),
00712 };
00713
00714 AVCodec smackaud_decoder = {
00715 "smackaud",
00716 CODEC_TYPE_AUDIO,
00717 CODEC_ID_SMACKAUDIO,
00718 0,
00719 smka_decode_init,
00720 NULL,
00721 NULL,
00722 smka_decode_frame,
00723 .long_name = NULL_IF_CONFIG_SMALL("Smacker audio"),
00724 };
00725