| 1018 | } |
| 1019 | |
| 1020 | static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, |
| 1021 | int plane_idx, int is_chroma) |
| 1022 | { |
| 1023 | int blk, ret; |
| 1024 | int i, j, bx, by; |
| 1025 | uint8_t *dst, *prev, *ref_start, *ref_end; |
| 1026 | int v, col[2]; |
| 1027 | const uint8_t *scan; |
| 1028 | LOCAL_ALIGNED_32(int16_t, block, [64]); |
| 1029 | LOCAL_ALIGNED_16(uint8_t, ublock, [64]); |
| 1030 | LOCAL_ALIGNED_16(int32_t, dctblock, [64]); |
| 1031 | int coordmap[64], quant_idx, coef_count, coef_idx[64]; |
| 1032 | |
| 1033 | const int stride = frame->linesize[plane_idx]; |
| 1034 | int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3; |
| 1035 | int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3; |
| 1036 | int width = c->avctx->width >> is_chroma; |
| 1037 | int height = c->avctx->height >> is_chroma; |
| 1038 | |
| 1039 | if (c->version == 'k' && get_bits1(gb)) { |
| 1040 | int fill = get_bits(gb, 8); |
| 1041 | |
| 1042 | dst = frame->data[plane_idx]; |
| 1043 | |
| 1044 | for (i = 0; i < height; i++) |
| 1045 | memset(dst + i * stride, fill, width); |
| 1046 | goto end; |
| 1047 | } |
| 1048 | |
| 1049 | init_lengths(c, FFMAX(width, 8), bw); |
| 1050 | for (i = 0; i < BINK_NB_SRC; i++) { |
| 1051 | ret = read_bundle(gb, c, i); |
| 1052 | if (ret < 0) |
| 1053 | return ret; |
| 1054 | } |
| 1055 | |
| 1056 | ref_start = c->last->data[plane_idx] ? c->last->data[plane_idx] |
| 1057 | : frame->data[plane_idx]; |
| 1058 | ref_end = ref_start |
| 1059 | + (bw - 1 + c->last->linesize[plane_idx] * (bh - 1)) * 8; |
| 1060 | |
| 1061 | for (i = 0; i < 64; i++) |
| 1062 | coordmap[i] = (i & 7) + (i >> 3) * stride; |
| 1063 | |
| 1064 | for (by = 0; by < bh; by++) { |
| 1065 | if ((ret = read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_BLOCK_TYPES])) < 0) |
| 1066 | return ret; |
| 1067 | if ((ret = read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0) |
| 1068 | return ret; |
| 1069 | if ((ret = read_colors(gb, &c->bundle[BINK_SRC_COLORS], c)) < 0) |
| 1070 | return ret; |
| 1071 | if ((ret = read_patterns(c->avctx, gb, &c->bundle[BINK_SRC_PATTERN])) < 0) |
| 1072 | return ret; |
| 1073 | if ((ret = read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_X_OFF])) < 0) |
| 1074 | return ret; |
| 1075 | if ((ret = read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_Y_OFF])) < 0) |
| 1076 | return ret; |
| 1077 | if ((ret = read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0) |
no test coverage detected