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 "get_bits.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, AVPacket *avpkt)
00355 {
00356 const uint8_t *buf = avpkt->data;
00357 int buf_size = avpkt->size;
00358 SmackVContext * const smk = avctx->priv_data;
00359 uint8_t *out;
00360 uint32_t *pal;
00361 GetBitContext gb;
00362 int blocks, blk, bw, bh;
00363 int i;
00364 int stride;
00365
00366 if(buf_size <= 769)
00367 return 0;
00368 if(smk->pic.data[0])
00369 avctx->release_buffer(avctx, &smk->pic);
00370
00371 smk->pic.reference = 1;
00372 smk->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
00373 if(avctx->reget_buffer(avctx, &smk->pic) < 0){
00374 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
00375 return -1;
00376 }
00377
00378
00379 pal = (uint32_t*)smk->pic.data[1];
00380 smk->pic.palette_has_changed = buf[0] & 1;
00381 smk->pic.key_frame = !!(buf[0] & 2);
00382 if(smk->pic.key_frame)
00383 smk->pic.pict_type = FF_I_TYPE;
00384 else
00385 smk->pic.pict_type = FF_P_TYPE;
00386
00387 buf++;
00388 for(i = 0; i < 256; i++)
00389 *pal++ = bytestream_get_be24(&buf);
00390 buf_size -= 769;
00391
00392 last_reset(smk->mmap_tbl, smk->mmap_last);
00393 last_reset(smk->mclr_tbl, smk->mclr_last);
00394 last_reset(smk->full_tbl, smk->full_last);
00395 last_reset(smk->type_tbl, smk->type_last);
00396 init_get_bits(&gb, buf, buf_size * 8);
00397
00398 blk = 0;
00399 bw = avctx->width >> 2;
00400 bh = avctx->height >> 2;
00401 blocks = bw * bh;
00402 out = smk->pic.data[0];
00403 stride = smk->pic.linesize[0];
00404 while(blk < blocks) {
00405 int type, run, mode;
00406 uint16_t pix;
00407
00408 type = smk_get_code(&gb, smk->type_tbl, smk->type_last);
00409 run = block_runs[(type >> 2) & 0x3F];
00410 switch(type & 3){
00411 case SMK_BLK_MONO:
00412 while(run-- && blk < blocks){
00413 int clr, map;
00414 int hi, lo;
00415 clr = smk_get_code(&gb, smk->mclr_tbl, smk->mclr_last);
00416 map = smk_get_code(&gb, smk->mmap_tbl, smk->mmap_last);
00417 out = smk->pic.data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
00418 hi = clr >> 8;
00419 lo = clr & 0xFF;
00420 for(i = 0; i < 4; i++) {
00421 if(map & 1) out[0] = hi; else out[0] = lo;
00422 if(map & 2) out[1] = hi; else out[1] = lo;
00423 if(map & 4) out[2] = hi; else out[2] = lo;
00424 if(map & 8) out[3] = hi; else out[3] = lo;
00425 map >>= 4;
00426 out += stride;
00427 }
00428 blk++;
00429 }
00430 break;
00431 case SMK_BLK_FULL:
00432 mode = 0;
00433 if(avctx->codec_tag == MKTAG('S', 'M', 'K', '4')) {
00434 if(get_bits1(&gb)) mode = 1;
00435 else if(get_bits1(&gb)) mode = 2;
00436 }
00437 while(run-- && blk < blocks){
00438 out = smk->pic.data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
00439 switch(mode){
00440 case 0:
00441 for(i = 0; i < 4; i++) {
00442 pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00443 AV_WL16(out+2,pix);
00444 pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00445 AV_WL16(out,pix);
00446 out += stride;
00447 }
00448 break;
00449 case 1:
00450 pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00451 out[0] = out[1] = pix & 0xFF;
00452 out[2] = out[3] = pix >> 8;
00453 out += stride;
00454 out[0] = out[1] = pix & 0xFF;
00455 out[2] = out[3] = pix >> 8;
00456 out += stride;
00457 pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00458 out[0] = out[1] = pix & 0xFF;
00459 out[2] = out[3] = pix >> 8;
00460 out += stride;
00461 out[0] = out[1] = pix & 0xFF;
00462 out[2] = out[3] = pix >> 8;
00463 out += stride;
00464 break;
00465 case 2:
00466 for(i = 0; i < 2; i++) {
00467 uint16_t pix1, pix2;
00468 pix2 = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00469 pix1 = smk_get_code(&gb, smk->full_tbl, smk->full_last);
00470 AV_WL16(out,pix1);
00471 AV_WL16(out+2,pix2);
00472 out += stride;
00473 AV_WL16(out,pix1);
00474 AV_WL16(out+2,pix2);
00475 out += stride;
00476 }
00477 break;
00478 }
00479 blk++;
00480 }
00481 break;
00482 case SMK_BLK_SKIP:
00483 while(run-- && blk < blocks)
00484 blk++;
00485 break;
00486 case SMK_BLK_FILL:
00487 mode = type >> 8;
00488 while(run-- && blk < blocks){
00489 uint32_t col;
00490 out = smk->pic.data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
00491 col = mode * 0x01010101;
00492 for(i = 0; i < 4; i++) {
00493 *((uint32_t*)out) = col;
00494 out += stride;
00495 }
00496 blk++;
00497 }
00498 break;
00499 }
00500
00501 }
00502
00503 *data_size = sizeof(AVFrame);
00504 *(AVFrame*)data = smk->pic;
00505
00506
00507 return buf_size;
00508 }
00509
00510
00511
00512
00513
00514
00515
00516
00517 static av_cold int decode_init(AVCodecContext *avctx)
00518 {
00519 SmackVContext * const c = avctx->priv_data;
00520
00521 c->avctx = avctx;
00522
00523 avctx->pix_fmt = PIX_FMT_PAL8;
00524
00525
00526
00527 if(avctx->extradata_size < 16){
00528 av_log(avctx, AV_LOG_ERROR, "Extradata missing!\n");
00529 return -1;
00530 }
00531
00532 if (decode_header_trees(c))
00533 return -1;
00534
00535 return 0;
00536 }
00537
00538
00539
00540
00541
00542
00543
00544
00545 static av_cold int decode_end(AVCodecContext *avctx)
00546 {
00547 SmackVContext * const smk = avctx->priv_data;
00548
00549 av_freep(&smk->mmap_tbl);
00550 av_freep(&smk->mclr_tbl);
00551 av_freep(&smk->full_tbl);
00552 av_freep(&smk->type_tbl);
00553
00554 if (smk->pic.data[0])
00555 avctx->release_buffer(avctx, &smk->pic);
00556
00557 return 0;
00558 }
00559
00560
00561 static av_cold int smka_decode_init(AVCodecContext *avctx)
00562 {
00563 avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
00564 avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? SAMPLE_FMT_U8 : SAMPLE_FMT_S16;
00565 return 0;
00566 }
00567
00571 static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
00572 {
00573 const uint8_t *buf = avpkt->data;
00574 int buf_size = avpkt->size;
00575 GetBitContext gb;
00576 HuffContext h[4];
00577 VLC vlc[4];
00578 int16_t *samples = data;
00579 int8_t *samples8 = data;
00580 int val;
00581 int i, res;
00582 int unp_size;
00583 int bits, stereo;
00584 int pred[2] = {0, 0};
00585
00586 unp_size = AV_RL32(buf);
00587
00588 init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
00589
00590 if(!get_bits1(&gb)){
00591 av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
00592 *data_size = 0;
00593 return 1;
00594 }
00595 stereo = get_bits1(&gb);
00596 bits = get_bits1(&gb);
00597 if (unp_size & 0xC0000000 || unp_size > *data_size) {
00598 av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
00599 return -1;
00600 }
00601
00602 memset(vlc, 0, sizeof(VLC) * 4);
00603 memset(h, 0, sizeof(HuffContext) * 4);
00604
00605 for(i = 0; i < (1 << (bits + stereo)); i++) {
00606 h[i].length = 256;
00607 h[i].maxlength = 0;
00608 h[i].current = 0;
00609 h[i].bits = av_mallocz(256 * 4);
00610 h[i].lengths = av_mallocz(256 * sizeof(int));
00611 h[i].values = av_mallocz(256 * sizeof(int));
00612 skip_bits1(&gb);
00613 smacker_decode_tree(&gb, &h[i], 0, 0);
00614 skip_bits1(&gb);
00615 if(h[i].current > 1) {
00616 res = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length,
00617 h[i].lengths, sizeof(int), sizeof(int),
00618 h[i].bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
00619 if(res < 0) {
00620 av_log(avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
00621 return -1;
00622 }
00623 }
00624 }
00625 if(bits) {
00626 for(i = stereo; i >= 0; i--)
00627 pred[i] = bswap_16(get_bits(&gb, 16));
00628 for(i = 0; i <= stereo; i++)
00629 *samples++ = pred[i];
00630 for(; i < unp_size / 2; i++) {
00631 if(i & stereo) {
00632 if(vlc[2].table)
00633 res = get_vlc2(&gb, vlc[2].table, SMKTREE_BITS, 3);
00634 else
00635 res = 0;
00636 val = h[2].values[res];
00637 if(vlc[3].table)
00638 res = get_vlc2(&gb, vlc[3].table, SMKTREE_BITS, 3);
00639 else
00640 res = 0;
00641 val |= h[3].values[res] << 8;
00642 pred[1] += (int16_t)val;
00643 *samples++ = pred[1];
00644 } else {
00645 if(vlc[0].table)
00646 res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
00647 else
00648 res = 0;
00649 val = h[0].values[res];
00650 if(vlc[1].table)
00651 res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
00652 else
00653 res = 0;
00654 val |= h[1].values[res] << 8;
00655 pred[0] += val;
00656 *samples++ = pred[0];
00657 }
00658 }
00659 } else {
00660 for(i = stereo; i >= 0; i--)
00661 pred[i] = get_bits(&gb, 8);
00662 for(i = 0; i <= stereo; i++)
00663 *samples8++ = pred[i];
00664 for(; i < unp_size; i++) {
00665 if(i & stereo){
00666 if(vlc[1].table)
00667 res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
00668 else
00669 res = 0;
00670 pred[1] += (int8_t)h[1].values[res];
00671 *samples8++ = pred[1];
00672 } else {
00673 if(vlc[0].table)
00674 res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
00675 else
00676 res = 0;
00677 pred[0] += (int8_t)h[0].values[res];
00678 *samples8++ = pred[0];
00679 }
00680 }
00681 }
00682
00683 for(i = 0; i < 4; i++) {
00684 if(vlc[i].table)
00685 free_vlc(&vlc[i]);
00686 if(h[i].bits)
00687 av_free(h[i].bits);
00688 if(h[i].lengths)
00689 av_free(h[i].lengths);
00690 if(h[i].values)
00691 av_free(h[i].values);
00692 }
00693
00694 *data_size = unp_size;
00695 return buf_size;
00696 }
00697
00698 AVCodec smacker_decoder = {
00699 "smackvid",
00700 AVMEDIA_TYPE_VIDEO,
00701 CODEC_ID_SMACKVIDEO,
00702 sizeof(SmackVContext),
00703 decode_init,
00704 NULL,
00705 decode_end,
00706 decode_frame,
00707 CODEC_CAP_DR1,
00708 .long_name = NULL_IF_CONFIG_SMALL("Smacker video"),
00709 };
00710
00711 AVCodec smackaud_decoder = {
00712 "smackaud",
00713 AVMEDIA_TYPE_AUDIO,
00714 CODEC_ID_SMACKAUDIO,
00715 0,
00716 smka_decode_init,
00717 NULL,
00718 NULL,
00719 smka_decode_frame,
00720 .long_name = NULL_IF_CONFIG_SMALL("Smacker audio"),
00721 };
00722