00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "libavutil/imgutils.h"
00024 #include "avcodec.h"
00025 #include "dsputil.h"
00026 #include "binkdata.h"
00027 #include "binkdsp.h"
00028 #include "mathops.h"
00029
00030 #define ALT_BITSTREAM_READER_LE
00031 #include "get_bits.h"
00032
00033 #define BINK_FLAG_ALPHA 0x00100000
00034 #define BINK_FLAG_GRAY 0x00020000
00035
00036 static VLC bink_trees[16];
00037
00041 enum OldSources {
00042 BINKB_SRC_BLOCK_TYPES = 0,
00043 BINKB_SRC_COLORS,
00044 BINKB_SRC_PATTERN,
00045 BINKB_SRC_X_OFF,
00046 BINKB_SRC_Y_OFF,
00047 BINKB_SRC_INTRA_DC,
00048 BINKB_SRC_INTER_DC,
00049 BINKB_SRC_INTRA_Q,
00050 BINKB_SRC_INTER_Q,
00051 BINKB_SRC_INTER_COEFS,
00052
00053 BINKB_NB_SRC
00054 };
00055
00056 static const int binkb_bundle_sizes[BINKB_NB_SRC] = {
00057 4, 8, 8, 5, 5, 11, 11, 4, 4, 7
00058 };
00059
00060 static const int binkb_bundle_signed[BINKB_NB_SRC] = {
00061 0, 0, 0, 1, 1, 0, 1, 0, 0, 0
00062 };
00063
00064 static int32_t binkb_intra_quant[16][64];
00065 static int32_t binkb_inter_quant[16][64];
00066
00070 enum Sources {
00071 BINK_SRC_BLOCK_TYPES = 0,
00072 BINK_SRC_SUB_BLOCK_TYPES,
00073 BINK_SRC_COLORS,
00074 BINK_SRC_PATTERN,
00075 BINK_SRC_X_OFF,
00076 BINK_SRC_Y_OFF,
00077 BINK_SRC_INTRA_DC,
00078 BINK_SRC_INTER_DC,
00079 BINK_SRC_RUN,
00080
00081 BINK_NB_SRC
00082 };
00083
00087 typedef struct Tree {
00088 int vlc_num;
00089 uint8_t syms[16];
00090 } Tree;
00091
00092 #define GET_HUFF(gb, tree) (tree).syms[get_vlc2(gb, bink_trees[(tree).vlc_num].table,\
00093 bink_trees[(tree).vlc_num].bits, 1)]
00094
00098 typedef struct Bundle {
00099 int len;
00100 Tree tree;
00101 uint8_t *data;
00102 uint8_t *data_end;
00103 uint8_t *cur_dec;
00104 uint8_t *cur_ptr;
00105 } Bundle;
00106
00107
00108
00109
00110 typedef struct BinkContext {
00111 AVCodecContext *avctx;
00112 DSPContext dsp;
00113 BinkDSPContext bdsp;
00114 AVFrame pic, last;
00115 int version;
00116 int has_alpha;
00117 int swap_planes;
00118
00119 Bundle bundle[BINKB_NB_SRC];
00120 Tree col_high[16];
00121 int col_lastval;
00122 } BinkContext;
00123
00127 enum BlockTypes {
00128 SKIP_BLOCK = 0,
00129 SCALED_BLOCK,
00130 MOTION_BLOCK,
00131 RUN_BLOCK,
00132 RESIDUE_BLOCK,
00133 INTRA_BLOCK,
00134 FILL_BLOCK,
00135 INTER_BLOCK,
00136 PATTERN_BLOCK,
00137 RAW_BLOCK,
00138 };
00139
00147 static void init_lengths(BinkContext *c, int width, int bw)
00148 {
00149 c->bundle[BINK_SRC_BLOCK_TYPES].len = av_log2((width >> 3) + 511) + 1;
00150
00151 c->bundle[BINK_SRC_SUB_BLOCK_TYPES].len = av_log2((width >> 4) + 511) + 1;
00152
00153 c->bundle[BINK_SRC_COLORS].len = av_log2(bw*64 + 511) + 1;
00154
00155 c->bundle[BINK_SRC_INTRA_DC].len =
00156 c->bundle[BINK_SRC_INTER_DC].len =
00157 c->bundle[BINK_SRC_X_OFF].len =
00158 c->bundle[BINK_SRC_Y_OFF].len = av_log2((width >> 3) + 511) + 1;
00159
00160 c->bundle[BINK_SRC_PATTERN].len = av_log2((bw << 3) + 511) + 1;
00161
00162 c->bundle[BINK_SRC_RUN].len = av_log2(bw*48 + 511) + 1;
00163 }
00164
00170 static av_cold void init_bundles(BinkContext *c)
00171 {
00172 int bw, bh, blocks;
00173 int i;
00174
00175 bw = (c->avctx->width + 7) >> 3;
00176 bh = (c->avctx->height + 7) >> 3;
00177 blocks = bw * bh;
00178
00179 for (i = 0; i < BINKB_NB_SRC; i++) {
00180 c->bundle[i].data = av_malloc(blocks * 64);
00181 c->bundle[i].data_end = c->bundle[i].data + blocks * 64;
00182 }
00183 }
00184
00190 static av_cold void free_bundles(BinkContext *c)
00191 {
00192 int i;
00193 for (i = 0; i < BINKB_NB_SRC; i++)
00194 av_freep(&c->bundle[i].data);
00195 }
00196
00205 static void merge(GetBitContext *gb, uint8_t *dst, uint8_t *src, int size)
00206 {
00207 uint8_t *src2 = src + size;
00208 int size2 = size;
00209
00210 do {
00211 if (!get_bits1(gb)) {
00212 *dst++ = *src++;
00213 size--;
00214 } else {
00215 *dst++ = *src2++;
00216 size2--;
00217 }
00218 } while (size && size2);
00219
00220 while (size--)
00221 *dst++ = *src++;
00222 while (size2--)
00223 *dst++ = *src2++;
00224 }
00225
00232 static void read_tree(GetBitContext *gb, Tree *tree)
00233 {
00234 uint8_t tmp1[16], tmp2[16], *in = tmp1, *out = tmp2;
00235 int i, t, len;
00236
00237 tree->vlc_num = get_bits(gb, 4);
00238 if (!tree->vlc_num) {
00239 for (i = 0; i < 16; i++)
00240 tree->syms[i] = i;
00241 return;
00242 }
00243 if (get_bits1(gb)) {
00244 len = get_bits(gb, 3);
00245 memset(tmp1, 0, sizeof(tmp1));
00246 for (i = 0; i <= len; i++) {
00247 tree->syms[i] = get_bits(gb, 4);
00248 tmp1[tree->syms[i]] = 1;
00249 }
00250 for (i = 0; i < 16 && len < 16 - 1; i++)
00251 if (!tmp1[i])
00252 tree->syms[++len] = i;
00253 } else {
00254 len = get_bits(gb, 2);
00255 for (i = 0; i < 16; i++)
00256 in[i] = i;
00257 for (i = 0; i <= len; i++) {
00258 int size = 1 << i;
00259 for (t = 0; t < 16; t += size << 1)
00260 merge(gb, out + t, in + t, size);
00261 FFSWAP(uint8_t*, in, out);
00262 }
00263 memcpy(tree->syms, in, 16);
00264 }
00265 }
00266
00274 static void read_bundle(GetBitContext *gb, BinkContext *c, int bundle_num)
00275 {
00276 int i;
00277
00278 if (bundle_num == BINK_SRC_COLORS) {
00279 for (i = 0; i < 16; i++)
00280 read_tree(gb, &c->col_high[i]);
00281 c->col_lastval = 0;
00282 }
00283 if (bundle_num != BINK_SRC_INTRA_DC && bundle_num != BINK_SRC_INTER_DC)
00284 read_tree(gb, &c->bundle[bundle_num].tree);
00285 c->bundle[bundle_num].cur_dec =
00286 c->bundle[bundle_num].cur_ptr = c->bundle[bundle_num].data;
00287 }
00288
00296 #define CHECK_READ_VAL(gb, b, t) \
00297 if (!b->cur_dec || (b->cur_dec > b->cur_ptr)) \
00298 return 0; \
00299 t = get_bits(gb, b->len); \
00300 if (!t) { \
00301 b->cur_dec = NULL; \
00302 return 0; \
00303 } \
00304
00305 static int read_runs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
00306 {
00307 int t, v;
00308 const uint8_t *dec_end;
00309
00310 CHECK_READ_VAL(gb, b, t);
00311 dec_end = b->cur_dec + t;
00312 if (dec_end > b->data_end) {
00313 av_log(avctx, AV_LOG_ERROR, "Run value went out of bounds\n");
00314 return -1;
00315 }
00316 if (get_bits1(gb)) {
00317 v = get_bits(gb, 4);
00318 memset(b->cur_dec, v, t);
00319 b->cur_dec += t;
00320 } else {
00321 while (b->cur_dec < dec_end)
00322 *b->cur_dec++ = GET_HUFF(gb, b->tree);
00323 }
00324 return 0;
00325 }
00326
00327 static int read_motion_values(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
00328 {
00329 int t, sign, v;
00330 const uint8_t *dec_end;
00331
00332 CHECK_READ_VAL(gb, b, t);
00333 dec_end = b->cur_dec + t;
00334 if (dec_end > b->data_end) {
00335 av_log(avctx, AV_LOG_ERROR, "Too many motion values\n");
00336 return -1;
00337 }
00338 if (get_bits1(gb)) {
00339 v = get_bits(gb, 4);
00340 if (v) {
00341 sign = -get_bits1(gb);
00342 v = (v ^ sign) - sign;
00343 }
00344 memset(b->cur_dec, v, t);
00345 b->cur_dec += t;
00346 } else {
00347 while (b->cur_dec < dec_end) {
00348 v = GET_HUFF(gb, b->tree);
00349 if (v) {
00350 sign = -get_bits1(gb);
00351 v = (v ^ sign) - sign;
00352 }
00353 *b->cur_dec++ = v;
00354 }
00355 }
00356 return 0;
00357 }
00358
00359 static const uint8_t bink_rlelens[4] = { 4, 8, 12, 32 };
00360
00361 static int read_block_types(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
00362 {
00363 int t, v;
00364 int last = 0;
00365 const uint8_t *dec_end;
00366
00367 CHECK_READ_VAL(gb, b, t);
00368 dec_end = b->cur_dec + t;
00369 if (dec_end > b->data_end) {
00370 av_log(avctx, AV_LOG_ERROR, "Too many block type values\n");
00371 return -1;
00372 }
00373 if (get_bits1(gb)) {
00374 v = get_bits(gb, 4);
00375 memset(b->cur_dec, v, t);
00376 b->cur_dec += t;
00377 } else {
00378 while (b->cur_dec < dec_end) {
00379 v = GET_HUFF(gb, b->tree);
00380 if (v < 12) {
00381 last = v;
00382 *b->cur_dec++ = v;
00383 } else {
00384 int run = bink_rlelens[v - 12];
00385
00386 if (dec_end - b->cur_dec < run)
00387 return -1;
00388 memset(b->cur_dec, last, run);
00389 b->cur_dec += run;
00390 }
00391 }
00392 }
00393 return 0;
00394 }
00395
00396 static int read_patterns(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
00397 {
00398 int t, v;
00399 const uint8_t *dec_end;
00400
00401 CHECK_READ_VAL(gb, b, t);
00402 dec_end = b->cur_dec + t;
00403 if (dec_end > b->data_end) {
00404 av_log(avctx, AV_LOG_ERROR, "Too many pattern values\n");
00405 return -1;
00406 }
00407 while (b->cur_dec < dec_end) {
00408 v = GET_HUFF(gb, b->tree);
00409 v |= GET_HUFF(gb, b->tree) << 4;
00410 *b->cur_dec++ = v;
00411 }
00412
00413 return 0;
00414 }
00415
00416 static int read_colors(GetBitContext *gb, Bundle *b, BinkContext *c)
00417 {
00418 int t, sign, v;
00419 const uint8_t *dec_end;
00420
00421 CHECK_READ_VAL(gb, b, t);
00422 dec_end = b->cur_dec + t;
00423 if (dec_end > b->data_end) {
00424 av_log(c->avctx, AV_LOG_ERROR, "Too many color values\n");
00425 return -1;
00426 }
00427 if (get_bits1(gb)) {
00428 c->col_lastval = GET_HUFF(gb, c->col_high[c->col_lastval]);
00429 v = GET_HUFF(gb, b->tree);
00430 v = (c->col_lastval << 4) | v;
00431 if (c->version < 'i') {
00432 sign = ((int8_t) v) >> 7;
00433 v = ((v & 0x7F) ^ sign) - sign;
00434 v += 0x80;
00435 }
00436 memset(b->cur_dec, v, t);
00437 b->cur_dec += t;
00438 } else {
00439 while (b->cur_dec < dec_end) {
00440 c->col_lastval = GET_HUFF(gb, c->col_high[c->col_lastval]);
00441 v = GET_HUFF(gb, b->tree);
00442 v = (c->col_lastval << 4) | v;
00443 if (c->version < 'i') {
00444 sign = ((int8_t) v) >> 7;
00445 v = ((v & 0x7F) ^ sign) - sign;
00446 v += 0x80;
00447 }
00448 *b->cur_dec++ = v;
00449 }
00450 }
00451 return 0;
00452 }
00453
00455 #define DC_START_BITS 11
00456
00457 static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b,
00458 int start_bits, int has_sign)
00459 {
00460 int i, j, len, len2, bsize, sign, v, v2;
00461 int16_t *dst = (int16_t*)b->cur_dec;
00462 int16_t *dst_end = (int16_t*)b->data_end;
00463
00464 CHECK_READ_VAL(gb, b, len);
00465 v = get_bits(gb, start_bits - has_sign);
00466 if (v && has_sign) {
00467 sign = -get_bits1(gb);
00468 v = (v ^ sign) - sign;
00469 }
00470 if (dst_end - dst < 1)
00471 return -1;
00472 *dst++ = v;
00473 len--;
00474 for (i = 0; i < len; i += 8) {
00475 len2 = FFMIN(len - i, 8);
00476 if (dst_end - dst < len2)
00477 return -1;
00478 bsize = get_bits(gb, 4);
00479 if (bsize) {
00480 for (j = 0; j < len2; j++) {
00481 v2 = get_bits(gb, bsize);
00482 if (v2) {
00483 sign = -get_bits1(gb);
00484 v2 = (v2 ^ sign) - sign;
00485 }
00486 v += v2;
00487 *dst++ = v;
00488 if (v < -32768 || v > 32767) {
00489 av_log(avctx, AV_LOG_ERROR, "DC value went out of bounds: %d\n", v);
00490 return -1;
00491 }
00492 }
00493 } else {
00494 for (j = 0; j < len2; j++)
00495 *dst++ = v;
00496 }
00497 }
00498
00499 b->cur_dec = (uint8_t*)dst;
00500 return 0;
00501 }
00502
00509 static inline int get_value(BinkContext *c, int bundle)
00510 {
00511 int ret;
00512
00513 if (bundle < BINK_SRC_X_OFF || bundle == BINK_SRC_RUN)
00514 return *c->bundle[bundle].cur_ptr++;
00515 if (bundle == BINK_SRC_X_OFF || bundle == BINK_SRC_Y_OFF)
00516 return (int8_t)*c->bundle[bundle].cur_ptr++;
00517 ret = *(int16_t*)c->bundle[bundle].cur_ptr;
00518 c->bundle[bundle].cur_ptr += 2;
00519 return ret;
00520 }
00521
00522 static void binkb_init_bundle(BinkContext *c, int bundle_num)
00523 {
00524 c->bundle[bundle_num].cur_dec =
00525 c->bundle[bundle_num].cur_ptr = c->bundle[bundle_num].data;
00526 c->bundle[bundle_num].len = 13;
00527 }
00528
00529 static void binkb_init_bundles(BinkContext *c)
00530 {
00531 int i;
00532 for (i = 0; i < BINKB_NB_SRC; i++)
00533 binkb_init_bundle(c, i);
00534 }
00535
00536 static int binkb_read_bundle(BinkContext *c, GetBitContext *gb, int bundle_num)
00537 {
00538 const int bits = binkb_bundle_sizes[bundle_num];
00539 const int mask = 1 << (bits - 1);
00540 const int issigned = binkb_bundle_signed[bundle_num];
00541 Bundle *b = &c->bundle[bundle_num];
00542 int i, len;
00543
00544 CHECK_READ_VAL(gb, b, len);
00545 if (b->data_end - b->cur_dec < len * (1 + (bits > 8)))
00546 return -1;
00547 if (bits <= 8) {
00548 if (!issigned) {
00549 for (i = 0; i < len; i++)
00550 *b->cur_dec++ = get_bits(gb, bits);
00551 } else {
00552 for (i = 0; i < len; i++)
00553 *b->cur_dec++ = get_bits(gb, bits) - mask;
00554 }
00555 } else {
00556 int16_t *dst = (int16_t*)b->cur_dec;
00557
00558 if (!issigned) {
00559 for (i = 0; i < len; i++)
00560 *dst++ = get_bits(gb, bits);
00561 } else {
00562 for (i = 0; i < len; i++)
00563 *dst++ = get_bits(gb, bits) - mask;
00564 }
00565 b->cur_dec = (uint8_t*)dst;
00566 }
00567 return 0;
00568 }
00569
00570 static inline int binkb_get_value(BinkContext *c, int bundle_num)
00571 {
00572 int16_t ret;
00573 const int bits = binkb_bundle_sizes[bundle_num];
00574
00575 if (bits <= 8) {
00576 int val = *c->bundle[bundle_num].cur_ptr++;
00577 return binkb_bundle_signed[bundle_num] ? (int8_t)val : val;
00578 }
00579 ret = *(int16_t*)c->bundle[bundle_num].cur_ptr;
00580 c->bundle[bundle_num].cur_ptr += 2;
00581 return ret;
00582 }
00583
00593 static int read_dct_coeffs(GetBitContext *gb, int32_t block[64], const uint8_t *scan,
00594 const int32_t quant_matrices[16][64], int q)
00595 {
00596 int coef_list[128];
00597 int mode_list[128];
00598 int i, t, bits, ccoef, mode, sign;
00599 int list_start = 64, list_end = 64, list_pos;
00600 int coef_count = 0;
00601 int coef_idx[64];
00602 int quant_idx;
00603 const int32_t *quant;
00604
00605 coef_list[list_end] = 4; mode_list[list_end++] = 0;
00606 coef_list[list_end] = 24; mode_list[list_end++] = 0;
00607 coef_list[list_end] = 44; mode_list[list_end++] = 0;
00608 coef_list[list_end] = 1; mode_list[list_end++] = 3;
00609 coef_list[list_end] = 2; mode_list[list_end++] = 3;
00610 coef_list[list_end] = 3; mode_list[list_end++] = 3;
00611
00612 for (bits = get_bits(gb, 4) - 1; bits >= 0; bits--) {
00613 list_pos = list_start;
00614 while (list_pos < list_end) {
00615 if (!(mode_list[list_pos] | coef_list[list_pos]) || !get_bits1(gb)) {
00616 list_pos++;
00617 continue;
00618 }
00619 ccoef = coef_list[list_pos];
00620 mode = mode_list[list_pos];
00621 switch (mode) {
00622 case 0:
00623 coef_list[list_pos] = ccoef + 4;
00624 mode_list[list_pos] = 1;
00625 case 2:
00626 if (mode == 2) {
00627 coef_list[list_pos] = 0;
00628 mode_list[list_pos++] = 0;
00629 }
00630 for (i = 0; i < 4; i++, ccoef++) {
00631 if (get_bits1(gb)) {
00632 coef_list[--list_start] = ccoef;
00633 mode_list[ list_start] = 3;
00634 } else {
00635 if (!bits) {
00636 t = 1 - (get_bits1(gb) << 1);
00637 } else {
00638 t = get_bits(gb, bits) | 1 << bits;
00639 sign = -get_bits1(gb);
00640 t = (t ^ sign) - sign;
00641 }
00642 block[scan[ccoef]] = t;
00643 coef_idx[coef_count++] = ccoef;
00644 }
00645 }
00646 break;
00647 case 1:
00648 mode_list[list_pos] = 2;
00649 for (i = 0; i < 3; i++) {
00650 ccoef += 4;
00651 coef_list[list_end] = ccoef;
00652 mode_list[list_end++] = 2;
00653 }
00654 break;
00655 case 3:
00656 if (!bits) {
00657 t = 1 - (get_bits1(gb) << 1);
00658 } else {
00659 t = get_bits(gb, bits) | 1 << bits;
00660 sign = -get_bits1(gb);
00661 t = (t ^ sign) - sign;
00662 }
00663 block[scan[ccoef]] = t;
00664 coef_idx[coef_count++] = ccoef;
00665 coef_list[list_pos] = 0;
00666 mode_list[list_pos++] = 0;
00667 break;
00668 }
00669 }
00670 }
00671
00672 if (q == -1) {
00673 quant_idx = get_bits(gb, 4);
00674 } else {
00675 quant_idx = q;
00676 }
00677
00678 quant = quant_matrices[quant_idx];
00679
00680 block[0] = (block[0] * quant[0]) >> 11;
00681 for (i = 0; i < coef_count; i++) {
00682 int idx = coef_idx[i];
00683 block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11;
00684 }
00685
00686 return 0;
00687 }
00688
00697 static int read_residue(GetBitContext *gb, DCTELEM block[64], int masks_count)
00698 {
00699 int coef_list[128];
00700 int mode_list[128];
00701 int i, sign, mask, ccoef, mode;
00702 int list_start = 64, list_end = 64, list_pos;
00703 int nz_coeff[64];
00704 int nz_coeff_count = 0;
00705
00706 coef_list[list_end] = 4; mode_list[list_end++] = 0;
00707 coef_list[list_end] = 24; mode_list[list_end++] = 0;
00708 coef_list[list_end] = 44; mode_list[list_end++] = 0;
00709 coef_list[list_end] = 0; mode_list[list_end++] = 2;
00710
00711 for (mask = 1 << get_bits(gb, 3); mask; mask >>= 1) {
00712 for (i = 0; i < nz_coeff_count; i++) {
00713 if (!get_bits1(gb))
00714 continue;
00715 if (block[nz_coeff[i]] < 0)
00716 block[nz_coeff[i]] -= mask;
00717 else
00718 block[nz_coeff[i]] += mask;
00719 masks_count--;
00720 if (masks_count < 0)
00721 return 0;
00722 }
00723 list_pos = list_start;
00724 while (list_pos < list_end) {
00725 if (!(coef_list[list_pos] | mode_list[list_pos]) || !get_bits1(gb)) {
00726 list_pos++;
00727 continue;
00728 }
00729 ccoef = coef_list[list_pos];
00730 mode = mode_list[list_pos];
00731 switch (mode) {
00732 case 0:
00733 coef_list[list_pos] = ccoef + 4;
00734 mode_list[list_pos] = 1;
00735 case 2:
00736 if (mode == 2) {
00737 coef_list[list_pos] = 0;
00738 mode_list[list_pos++] = 0;
00739 }
00740 for (i = 0; i < 4; i++, ccoef++) {
00741 if (get_bits1(gb)) {
00742 coef_list[--list_start] = ccoef;
00743 mode_list[ list_start] = 3;
00744 } else {
00745 nz_coeff[nz_coeff_count++] = bink_scan[ccoef];
00746 sign = -get_bits1(gb);
00747 block[bink_scan[ccoef]] = (mask ^ sign) - sign;
00748 masks_count--;
00749 if (masks_count < 0)
00750 return 0;
00751 }
00752 }
00753 break;
00754 case 1:
00755 mode_list[list_pos] = 2;
00756 for (i = 0; i < 3; i++) {
00757 ccoef += 4;
00758 coef_list[list_end] = ccoef;
00759 mode_list[list_end++] = 2;
00760 }
00761 break;
00762 case 3:
00763 nz_coeff[nz_coeff_count++] = bink_scan[ccoef];
00764 sign = -get_bits1(gb);
00765 block[bink_scan[ccoef]] = (mask ^ sign) - sign;
00766 coef_list[list_pos] = 0;
00767 mode_list[list_pos++] = 0;
00768 masks_count--;
00769 if (masks_count < 0)
00770 return 0;
00771 break;
00772 }
00773 }
00774 }
00775
00776 return 0;
00777 }
00778
00782 static inline void put_pixels8x8_overlapped(uint8_t *dst, uint8_t *src, int stride)
00783 {
00784 uint8_t tmp[64];
00785 int i;
00786 for (i = 0; i < 8; i++)
00787 memcpy(tmp + i*8, src + i*stride, 8);
00788 for (i = 0; i < 8; i++)
00789 memcpy(dst + i*stride, tmp + i*8, 8);
00790 }
00791
00792 static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
00793 int is_key, int is_chroma)
00794 {
00795 int blk;
00796 int i, j, bx, by;
00797 uint8_t *dst, *ref, *ref_start, *ref_end;
00798 int v, col[2];
00799 const uint8_t *scan;
00800 int xoff, yoff;
00801 LOCAL_ALIGNED_16(DCTELEM, block, [64]);
00802 LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
00803 int coordmap[64];
00804 int ybias = is_key ? -15 : 0;
00805 int qp;
00806
00807 const int stride = c->pic.linesize[plane_idx];
00808 int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3;
00809 int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;
00810
00811 binkb_init_bundles(c);
00812 ref_start = c->pic.data[plane_idx];
00813 ref_end = c->pic.data[plane_idx] + (bh * c->pic.linesize[plane_idx] + bw) * 8;
00814
00815 for (i = 0; i < 64; i++)
00816 coordmap[i] = (i & 7) + (i >> 3) * stride;
00817
00818 for (by = 0; by < bh; by++) {
00819 for (i = 0; i < BINKB_NB_SRC; i++) {
00820 if (binkb_read_bundle(c, gb, i) < 0)
00821 return -1;
00822 }
00823
00824 dst = c->pic.data[plane_idx] + 8*by*stride;
00825 for (bx = 0; bx < bw; bx++, dst += 8) {
00826 blk = binkb_get_value(c, BINKB_SRC_BLOCK_TYPES);
00827 switch (blk) {
00828 case 0:
00829 break;
00830 case 1:
00831 scan = bink_patterns[get_bits(gb, 4)];
00832 i = 0;
00833 do {
00834 int mode, run;
00835
00836 mode = get_bits1(gb);
00837 run = get_bits(gb, binkb_runbits[i]) + 1;
00838
00839 i += run;
00840 if (i > 64) {
00841 av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
00842 return -1;
00843 }
00844 if (mode) {
00845 v = binkb_get_value(c, BINKB_SRC_COLORS);
00846 for (j = 0; j < run; j++)
00847 dst[coordmap[*scan++]] = v;
00848 } else {
00849 for (j = 0; j < run; j++)
00850 dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);
00851 }
00852 } while (i < 63);
00853 if (i == 63)
00854 dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);
00855 break;
00856 case 2:
00857 memset(dctblock, 0, sizeof(*dctblock) * 64);
00858 dctblock[0] = binkb_get_value(c, BINKB_SRC_INTRA_DC);
00859 qp = binkb_get_value(c, BINKB_SRC_INTRA_Q);
00860 read_dct_coeffs(gb, dctblock, bink_scan, binkb_intra_quant, qp);
00861 c->bdsp.idct_put(dst, stride, dctblock);
00862 break;
00863 case 3:
00864 xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
00865 yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
00866 ref = dst + xoff + yoff * stride;
00867 if (ref < ref_start || ref + 8*stride > ref_end) {
00868 av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
00869 } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
00870 c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
00871 } else {
00872 put_pixels8x8_overlapped(dst, ref, stride);
00873 }
00874 c->dsp.clear_block(block);
00875 v = binkb_get_value(c, BINKB_SRC_INTER_COEFS);
00876 read_residue(gb, block, v);
00877 c->dsp.add_pixels8(dst, block, stride);
00878 break;
00879 case 4:
00880 xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
00881 yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
00882 ref = dst + xoff + yoff * stride;
00883 if (ref < ref_start || ref + 8 * stride > ref_end) {
00884 av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
00885 } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
00886 c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
00887 } else {
00888 put_pixels8x8_overlapped(dst, ref, stride);
00889 }
00890 memset(dctblock, 0, sizeof(*dctblock) * 64);
00891 dctblock[0] = binkb_get_value(c, BINKB_SRC_INTER_DC);
00892 qp = binkb_get_value(c, BINKB_SRC_INTER_Q);
00893 read_dct_coeffs(gb, dctblock, bink_scan, binkb_inter_quant, qp);
00894 c->bdsp.idct_add(dst, stride, dctblock);
00895 break;
00896 case 5:
00897 v = binkb_get_value(c, BINKB_SRC_COLORS);
00898 c->dsp.fill_block_tab[1](dst, v, stride, 8);
00899 break;
00900 case 6:
00901 for (i = 0; i < 2; i++)
00902 col[i] = binkb_get_value(c, BINKB_SRC_COLORS);
00903 for (i = 0; i < 8; i++) {
00904 v = binkb_get_value(c, BINKB_SRC_PATTERN);
00905 for (j = 0; j < 8; j++, v >>= 1)
00906 dst[i*stride + j] = col[v & 1];
00907 }
00908 break;
00909 case 7:
00910 xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
00911 yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
00912 ref = dst + xoff + yoff * stride;
00913 if (ref < ref_start || ref + 8 * stride > ref_end) {
00914 av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
00915 } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
00916 c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
00917 } else {
00918 put_pixels8x8_overlapped(dst, ref, stride);
00919 }
00920 break;
00921 case 8:
00922 for (i = 0; i < 8; i++)
00923 memcpy(dst + i*stride, c->bundle[BINKB_SRC_COLORS].cur_ptr + i*8, 8);
00924 c->bundle[BINKB_SRC_COLORS].cur_ptr += 64;
00925 break;
00926 default:
00927 av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);
00928 return -1;
00929 }
00930 }
00931 }
00932 if (get_bits_count(gb) & 0x1F)
00933 skip_bits_long(gb, 32 - (get_bits_count(gb) & 0x1F));
00934
00935 return 0;
00936 }
00937
00938 static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
00939 int is_chroma)
00940 {
00941 int blk;
00942 int i, j, bx, by;
00943 uint8_t *dst, *prev, *ref, *ref_start, *ref_end;
00944 int v, col[2];
00945 const uint8_t *scan;
00946 int xoff, yoff;
00947 LOCAL_ALIGNED_16(DCTELEM, block, [64]);
00948 LOCAL_ALIGNED_16(uint8_t, ublock, [64]);
00949 LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
00950 int coordmap[64];
00951
00952 const int stride = c->pic.linesize[plane_idx];
00953 int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3;
00954 int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;
00955 int width = c->avctx->width >> is_chroma;
00956
00957 init_lengths(c, FFMAX(width, 8), bw);
00958 for (i = 0; i < BINK_NB_SRC; i++)
00959 read_bundle(gb, c, i);
00960
00961 ref_start = c->last.data[plane_idx] ? c->last.data[plane_idx]
00962 : c->pic.data[plane_idx];
00963 ref_end = ref_start
00964 + (bw - 1 + c->last.linesize[plane_idx] * (bh - 1)) * 8;
00965
00966 for (i = 0; i < 64; i++)
00967 coordmap[i] = (i & 7) + (i >> 3) * stride;
00968
00969 for (by = 0; by < bh; by++) {
00970 if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_BLOCK_TYPES]) < 0)
00971 return -1;
00972 if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES]) < 0)
00973 return -1;
00974 if (read_colors(gb, &c->bundle[BINK_SRC_COLORS], c) < 0)
00975 return -1;
00976 if (read_patterns(c->avctx, gb, &c->bundle[BINK_SRC_PATTERN]) < 0)
00977 return -1;
00978 if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_X_OFF]) < 0)
00979 return -1;
00980 if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_Y_OFF]) < 0)
00981 return -1;
00982 if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0) < 0)
00983 return -1;
00984 if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1) < 0)
00985 return -1;
00986 if (read_runs(c->avctx, gb, &c->bundle[BINK_SRC_RUN]) < 0)
00987 return -1;
00988
00989 if (by == bh)
00990 break;
00991 dst = c->pic.data[plane_idx] + 8*by*stride;
00992 prev = (c->last.data[plane_idx] ? c->last.data[plane_idx]
00993 : c->pic.data[plane_idx]) + 8*by*stride;
00994 for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
00995 blk = get_value(c, BINK_SRC_BLOCK_TYPES);
00996
00997 if ((by & 1) && blk == SCALED_BLOCK) {
00998 bx++;
00999 dst += 8;
01000 prev += 8;
01001 continue;
01002 }
01003 switch (blk) {
01004 case SKIP_BLOCK:
01005 c->dsp.put_pixels_tab[1][0](dst, prev, stride, 8);
01006 break;
01007 case SCALED_BLOCK:
01008 blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES);
01009 switch (blk) {
01010 case RUN_BLOCK:
01011 scan = bink_patterns[get_bits(gb, 4)];
01012 i = 0;
01013 do {
01014 int run = get_value(c, BINK_SRC_RUN) + 1;
01015
01016 i += run;
01017 if (i > 64) {
01018 av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
01019 return -1;
01020 }
01021 if (get_bits1(gb)) {
01022 v = get_value(c, BINK_SRC_COLORS);
01023 for (j = 0; j < run; j++)
01024 ublock[*scan++] = v;
01025 } else {
01026 for (j = 0; j < run; j++)
01027 ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
01028 }
01029 } while (i < 63);
01030 if (i == 63)
01031 ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
01032 break;
01033 case INTRA_BLOCK:
01034 memset(dctblock, 0, sizeof(*dctblock) * 64);
01035 dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
01036 read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1);
01037 c->bdsp.idct_put(ublock, 8, dctblock);
01038 break;
01039 case FILL_BLOCK:
01040 v = get_value(c, BINK_SRC_COLORS);
01041 c->dsp.fill_block_tab[0](dst, v, stride, 16);
01042 break;
01043 case PATTERN_BLOCK:
01044 for (i = 0; i < 2; i++)
01045 col[i] = get_value(c, BINK_SRC_COLORS);
01046 for (j = 0; j < 8; j++) {
01047 v = get_value(c, BINK_SRC_PATTERN);
01048 for (i = 0; i < 8; i++, v >>= 1)
01049 ublock[i + j*8] = col[v & 1];
01050 }
01051 break;
01052 case RAW_BLOCK:
01053 for (j = 0; j < 8; j++)
01054 for (i = 0; i < 8; i++)
01055 ublock[i + j*8] = get_value(c, BINK_SRC_COLORS);
01056 break;
01057 default:
01058 av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk);
01059 return -1;
01060 }
01061 if (blk != FILL_BLOCK)
01062 c->bdsp.scale_block(ublock, dst, stride);
01063 bx++;
01064 dst += 8;
01065 prev += 8;
01066 break;
01067 case MOTION_BLOCK:
01068 xoff = get_value(c, BINK_SRC_X_OFF);
01069 yoff = get_value(c, BINK_SRC_Y_OFF);
01070 ref = prev + xoff + yoff * stride;
01071 if (ref < ref_start || ref > ref_end) {
01072 av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
01073 bx*8 + xoff, by*8 + yoff);
01074 return -1;
01075 }
01076 c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
01077 break;
01078 case RUN_BLOCK:
01079 scan = bink_patterns[get_bits(gb, 4)];
01080 i = 0;
01081 do {
01082 int run = get_value(c, BINK_SRC_RUN) + 1;
01083
01084 i += run;
01085 if (i > 64) {
01086 av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
01087 return -1;
01088 }
01089 if (get_bits1(gb)) {
01090 v = get_value(c, BINK_SRC_COLORS);
01091 for (j = 0; j < run; j++)
01092 dst[coordmap[*scan++]] = v;
01093 } else {
01094 for (j = 0; j < run; j++)
01095 dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
01096 }
01097 } while (i < 63);
01098 if (i == 63)
01099 dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
01100 break;
01101 case RESIDUE_BLOCK:
01102 xoff = get_value(c, BINK_SRC_X_OFF);
01103 yoff = get_value(c, BINK_SRC_Y_OFF);
01104 ref = prev + xoff + yoff * stride;
01105 if (ref < ref_start || ref > ref_end) {
01106 av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
01107 bx*8 + xoff, by*8 + yoff);
01108 return -1;
01109 }
01110 c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
01111 c->dsp.clear_block(block);
01112 v = get_bits(gb, 7);
01113 read_residue(gb, block, v);
01114 c->dsp.add_pixels8(dst, block, stride);
01115 break;
01116 case INTRA_BLOCK:
01117 memset(dctblock, 0, sizeof(*dctblock) * 64);
01118 dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
01119 read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1);
01120 c->bdsp.idct_put(dst, stride, dctblock);
01121 break;
01122 case FILL_BLOCK:
01123 v = get_value(c, BINK_SRC_COLORS);
01124 c->dsp.fill_block_tab[1](dst, v, stride, 8);
01125 break;
01126 case INTER_BLOCK:
01127 xoff = get_value(c, BINK_SRC_X_OFF);
01128 yoff = get_value(c, BINK_SRC_Y_OFF);
01129 ref = prev + xoff + yoff * stride;
01130 c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
01131 memset(dctblock, 0, sizeof(*dctblock) * 64);
01132 dctblock[0] = get_value(c, BINK_SRC_INTER_DC);
01133 read_dct_coeffs(gb, dctblock, bink_scan, bink_inter_quant, -1);
01134 c->bdsp.idct_add(dst, stride, dctblock);
01135 break;
01136 case PATTERN_BLOCK:
01137 for (i = 0; i < 2; i++)
01138 col[i] = get_value(c, BINK_SRC_COLORS);
01139 for (i = 0; i < 8; i++) {
01140 v = get_value(c, BINK_SRC_PATTERN);
01141 for (j = 0; j < 8; j++, v >>= 1)
01142 dst[i*stride + j] = col[v & 1];
01143 }
01144 break;
01145 case RAW_BLOCK:
01146 for (i = 0; i < 8; i++)
01147 memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8);
01148 c->bundle[BINK_SRC_COLORS].cur_ptr += 64;
01149 break;
01150 default:
01151 av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);
01152 return -1;
01153 }
01154 }
01155 }
01156 if (get_bits_count(gb) & 0x1F)
01157 skip_bits_long(gb, 32 - (get_bits_count(gb) & 0x1F));
01158
01159 return 0;
01160 }
01161
01162 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt)
01163 {
01164 BinkContext * const c = avctx->priv_data;
01165 GetBitContext gb;
01166 int plane, plane_idx;
01167 int bits_count = pkt->size << 3;
01168
01169 if (c->version > 'b') {
01170 if(c->pic.data[0])
01171 avctx->release_buffer(avctx, &c->pic);
01172
01173 if(avctx->get_buffer(avctx, &c->pic) < 0){
01174 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
01175 return -1;
01176 }
01177 } else {
01178 if(avctx->reget_buffer(avctx, &c->pic) < 0){
01179 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
01180 return -1;
01181 }
01182 }
01183
01184 init_get_bits(&gb, pkt->data, bits_count);
01185 if (c->has_alpha) {
01186 if (c->version >= 'i')
01187 skip_bits_long(&gb, 32);
01188 if (bink_decode_plane(c, &gb, 3, 0) < 0)
01189 return -1;
01190 }
01191 if (c->version >= 'i')
01192 skip_bits_long(&gb, 32);
01193
01194 for (plane = 0; plane < 3; plane++) {
01195 plane_idx = (!plane || !c->swap_planes) ? plane : (plane ^ 3);
01196
01197 if (c->version > 'b') {
01198 if (bink_decode_plane(c, &gb, plane_idx, !!plane) < 0)
01199 return -1;
01200 } else {
01201 if (binkb_decode_plane(c, &gb, plane_idx, !pkt->pts, !!plane) < 0)
01202 return -1;
01203 }
01204 if (get_bits_count(&gb) >= bits_count)
01205 break;
01206 }
01207 emms_c();
01208
01209 *data_size = sizeof(AVFrame);
01210 *(AVFrame*)data = c->pic;
01211
01212 if (c->version > 'b')
01213 FFSWAP(AVFrame, c->pic, c->last);
01214
01215
01216 return pkt->size;
01217 }
01218
01222 static av_cold void binkb_calc_quant(void)
01223 {
01224 uint8_t inv_bink_scan[64];
01225 double s[64];
01226 int i, j;
01227
01228 for (j = 0; j < 8; j++) {
01229 for (i = 0; i < 8; i++) {
01230 if (j && j != 4)
01231 if (i && i != 4)
01232 s[j*8 + i] = cos(j * M_PI/16.0) * cos(i * M_PI/16.0) * 2.0;
01233 else
01234 s[j*8 + i] = cos(j * M_PI/16.0) * sqrt(2.0);
01235 else
01236 if (i && i != 4)
01237 s[j*8 + i] = cos(i * M_PI/16.0) * sqrt(2.0);
01238 else
01239 s[j*8 + i] = 1.0;
01240 }
01241 }
01242
01243 for (i = 0; i < 64; i++)
01244 inv_bink_scan[bink_scan[i]] = i;
01245
01246 for (j = 0; j < 16; j++) {
01247 for (i = 0; i < 64; i++) {
01248 int k = inv_bink_scan[i];
01249 if (s[i] == 1.0) {
01250 binkb_intra_quant[j][k] = (1L << 12) * binkb_intra_seed[i] *
01251 binkb_num[j]/binkb_den[j];
01252 binkb_inter_quant[j][k] = (1L << 12) * binkb_inter_seed[i] *
01253 binkb_num[j]/binkb_den[j];
01254 } else {
01255 binkb_intra_quant[j][k] = (1L << 12) * binkb_intra_seed[i] * s[i] *
01256 binkb_num[j]/(double)binkb_den[j];
01257 binkb_inter_quant[j][k] = (1L << 12) * binkb_inter_seed[i] * s[i] *
01258 binkb_num[j]/(double)binkb_den[j];
01259 }
01260 }
01261 }
01262 }
01263
01264 static av_cold int decode_init(AVCodecContext *avctx)
01265 {
01266 BinkContext * const c = avctx->priv_data;
01267 static VLC_TYPE table[16 * 128][2];
01268 static int binkb_initialised = 0;
01269 int i;
01270 int flags;
01271
01272 c->version = avctx->codec_tag >> 24;
01273 if (avctx->extradata_size < 4) {
01274 av_log(avctx, AV_LOG_ERROR, "Extradata missing or too short\n");
01275 return -1;
01276 }
01277 flags = AV_RL32(avctx->extradata);
01278 c->has_alpha = flags & BINK_FLAG_ALPHA;
01279 c->swap_planes = c->version >= 'h';
01280 if (!bink_trees[15].table) {
01281 for (i = 0; i < 16; i++) {
01282 const int maxbits = bink_tree_lens[i][15];
01283 bink_trees[i].table = table + i*128;
01284 bink_trees[i].table_allocated = 1 << maxbits;
01285 init_vlc(&bink_trees[i], maxbits, 16,
01286 bink_tree_lens[i], 1, 1,
01287 bink_tree_bits[i], 1, 1, INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE);
01288 }
01289 }
01290 c->avctx = avctx;
01291
01292 c->pic.data[0] = NULL;
01293
01294 if (av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) {
01295 return 1;
01296 }
01297
01298 avctx->pix_fmt = c->has_alpha ? PIX_FMT_YUVA420P : PIX_FMT_YUV420P;
01299
01300 avctx->idct_algo = FF_IDCT_BINK;
01301 dsputil_init(&c->dsp, avctx);
01302 ff_binkdsp_init(&c->bdsp);
01303
01304 init_bundles(c);
01305
01306 if (c->version == 'b') {
01307 if (!binkb_initialised) {
01308 binkb_calc_quant();
01309 binkb_initialised = 1;
01310 }
01311 }
01312
01313 return 0;
01314 }
01315
01316 static av_cold int decode_end(AVCodecContext *avctx)
01317 {
01318 BinkContext * const c = avctx->priv_data;
01319
01320 if (c->pic.data[0])
01321 avctx->release_buffer(avctx, &c->pic);
01322 if (c->last.data[0])
01323 avctx->release_buffer(avctx, &c->last);
01324
01325 free_bundles(c);
01326 return 0;
01327 }
01328
01329 AVCodec ff_bink_decoder = {
01330 .name = "binkvideo",
01331 .type = AVMEDIA_TYPE_VIDEO,
01332 .id = CODEC_ID_BINKVIDEO,
01333 .priv_data_size = sizeof(BinkContext),
01334 .init = decode_init,
01335 .close = decode_end,
01336 .decode = decode_frame,
01337 .long_name = NULL_IF_CONFIG_SMALL("Bink video"),
01338 };