51 #define FRAGMENT_PIXELS 8
60 #define SB_NOT_CODED 0
61 #define SB_PARTIALLY_CODED 1
62 #define SB_FULLY_CODED 2
67 #define MAXIMUM_LONG_BIT_RUN 4129
69 #define MODE_INTER_NO_MV 0
71 #define MODE_INTER_PLUS_MV 2
72 #define MODE_INTER_LAST_MV 3
73 #define MODE_INTER_PRIOR_LAST 4
74 #define MODE_USING_GOLDEN 5
75 #define MODE_GOLDEN_MV 6
76 #define MODE_INTER_FOURMV 7
77 #define CODING_MODE_COUNT 8
126 { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 },
127 { 0, 2 }, { 0, 3 }, { 1, 3 }, { 1, 2 },
128 { 2, 2 }, { 2, 3 }, { 3, 3 }, { 3, 2 },
129 { 3, 1 }, { 2, 1 }, { 2, 0 }, { 3, 0 }
156 #define MIN_DEQUANT_VAL 2
241 #define TOKEN_EOB(eob_run) ((eob_run) << 2)
242 #define TOKEN_ZERO_RUN(coeff, zero_run) (((coeff) * 512) + ((zero_run) << 2) + 1)
243 #define TOKEN_COEFF(coeff) (((coeff) * 4) + 2)
326 if (
s->golden_frame.f)
330 if (
s->current_frame.f)
342 s->theora_tables = 0;
350 for (
i = 0;
i < 16;
i++) {
363 for (j = 0; j < 2; j++)
364 for (
i = 0;
i < 7;
i++)
367 for (
i = 0;
i < 2;
i++)
381 int sb_x, sb_y, plane;
384 for (plane = 0; plane < 3; plane++) {
385 int sb_width = plane ?
s->c_superblock_width
386 :
s->y_superblock_width;
387 int sb_height = plane ?
s->c_superblock_height
388 :
s->y_superblock_height;
389 int frag_width =
s->fragment_width[!!plane];
390 int frag_height =
s->fragment_height[!!plane];
392 for (sb_y = 0; sb_y < sb_height; sb_y++)
393 for (sb_x = 0; sb_x < sb_width; sb_x++)
394 for (
i = 0;
i < 16;
i++) {
398 if (x < frag_width && y < frag_height)
399 s->superblock_fragments[j++] =
s->fragment_start[plane] +
402 s->superblock_fragments[j++] = -1;
415 int ac_scale_factor =
s->coded_ac_scale_factor[
s->qps[qpi]];
416 int i, plane, inter, qri, bmi, bmj, qistart;
418 for (inter = 0; inter < 2; inter++) {
419 for (plane = 0; plane < 3; plane++) {
420 int dc_scale_factor =
s->coded_dc_scale_factor[!!plane][
s->qps[qpi]];
422 for (qri = 0; qri <
s->qr_count[inter][plane]; qri++) {
423 sum +=
s->qr_size[inter][plane][qri];
424 if (
s->qps[qpi] <= sum)
427 qistart = sum -
s->qr_size[inter][plane][qri];
428 bmi =
s->qr_base[inter][plane][qri];
429 bmj =
s->qr_base[inter][plane][qri + 1];
430 for (
i = 0;
i < 64;
i++) {
431 int coeff = (2 * (sum -
s->qps[qpi]) *
s->base_matrix[bmi][
i] -
432 2 * (qistart -
s->qps[qpi]) *
s->base_matrix[bmj][
i] +
433 s->qr_size[inter][plane][qri]) /
434 (2 *
s->qr_size[inter][plane][qri]);
436 int qmin = 8 << (inter + !
i);
437 int qscale =
i ? ac_scale_factor : dc_scale_factor;
438 int qbias = (1 + inter) * 3;
439 s->qmat[qpi][inter][plane][
s->idct_permutation[
i]] =
440 (
i == 0 ||
s->version < 2) ? av_clip((qscale *
coeff) / 100 * 4, qmin, 4096)
441 : (qscale * (
coeff - qbias) / 100 + qbias) * 4;
445 s->qmat[qpi][inter][plane][0] =
s->qmat[0][inter][plane][0];
467 int superblock_starts[3] = {
468 0,
s->u_superblock_start,
s->v_superblock_start
471 int current_superblock = 0;
473 int num_partial_superblocks = 0;
476 int current_fragment;
478 int plane0_num_coded_frags = 0;
487 while (current_superblock < s->superblock_count &&
get_bits_left(gb) > 0) {
493 current_run =
get_vlc2(gb,
s->superblock_run_length_vlc.table,
495 if (current_run == 34)
498 if (current_run >
s->superblock_count - current_superblock) {
500 "Invalid partially coded superblock run length\n");
504 memset(
s->superblock_coding + current_superblock,
bit, current_run);
506 current_superblock += current_run;
508 num_partial_superblocks += current_run;
513 if (num_partial_superblocks < s->superblock_count) {
514 int superblocks_decoded = 0;
516 current_superblock = 0;
520 while (superblocks_decoded < s->superblock_count - num_partial_superblocks &&
527 current_run =
get_vlc2(gb,
s->superblock_run_length_vlc.table,
529 if (current_run == 34)
532 for (j = 0; j < current_run; current_superblock++) {
533 if (current_superblock >=
s->superblock_count) {
535 "Invalid fully coded superblock run length\n");
540 if (
s->superblock_coding[current_superblock] ==
SB_NOT_CODED) {
541 s->superblock_coding[current_superblock] = 2 *
bit;
545 superblocks_decoded += current_run;
551 if (num_partial_superblocks) {
562 s->total_num_coded_frags = 0;
563 memset(
s->macroblock_coding,
MODE_COPY,
s->macroblock_count);
565 s->coded_fragment_list[0] =
s->keyframe ?
s->kf_coded_fragment_list
566 :
s->nkf_coded_fragment_list;
568 for (plane = 0; plane < 3; plane++) {
569 int sb_start = superblock_starts[plane];
570 int sb_end = sb_start + (plane ?
s->c_superblock_count
571 :
s->y_superblock_count);
572 int num_coded_frags = 0;
575 if (
s->num_kf_coded_fragment[plane] == -1) {
576 for (
i = sb_start;
i < sb_end;
i++) {
578 for (j = 0; j < 16; j++) {
580 current_fragment =
s->superblock_fragments[
i * 16 + j];
581 if (current_fragment != -1) {
582 s->coded_fragment_list[plane][num_coded_frags++] =
587 s->num_kf_coded_fragment[plane] = num_coded_frags;
589 num_coded_frags =
s->num_kf_coded_fragment[plane];
596 for (j = 0; j < 16; j++) {
598 current_fragment =
s->superblock_fragments[
i * 16 + j];
599 if (current_fragment != -1) {
600 int coded =
s->superblock_coding[
i];
605 if (current_run-- == 0) {
607 current_run =
get_vlc2(gb,
s->fragment_run_length_vlc.table, 5, 2);
615 s->all_fragments[current_fragment].coding_method =
617 s->coded_fragment_list[plane][num_coded_frags++] =
621 s->all_fragments[current_fragment].coding_method =
629 plane0_num_coded_frags = num_coded_frags;
630 s->total_num_coded_frags += num_coded_frags;
631 for (
i = 0;
i < 64;
i++)
632 s->num_coded_frags[plane][
i] = num_coded_frags;
634 s->coded_fragment_list[plane + 1] =
s->coded_fragment_list[plane] +
640 #define BLOCK_X (2 * mb_x + (k & 1))
641 #define BLOCK_Y (2 * mb_y + (k >> 1))
643 #if CONFIG_VP4_DECODER
655 if (v >
s->yuv_macroblock_count) {
661 skip_bits(gb, 2 + n); \
662 v += (1 << n) + get_bits(gb, n); }
663 #define thresh(n) (0x200 - (0x80 >> n))
664 #define else_if(n) else if (bits < thresh(n)) body(n)
667 }
else if (
bits < thresh(0)) {
686 int v =
get_vlc2(gb,
s->block_pattern_vlc[*next_block_pattern_table].table, 3, 2);
689 *next_block_pattern_table = 0;
699 int next_block_pattern_table;
700 int bit, current_run, has_partial;
702 memset(
s->macroblock_coding,
MODE_COPY,
s->macroblock_count);
709 for (
i = 0;
i <
s->yuv_macroblock_count;
i += current_run) {
712 current_run = vp4_get_mb_count(
s, gb);
713 if (current_run >
s->yuv_macroblock_count -
i)
715 memset(
s->superblock_coding +
i, 2 *
bit, current_run);
724 current_run = vp4_get_mb_count(
s, gb);
725 for (
i = 0;
i <
s->yuv_macroblock_count;
i++) {
726 if (!
s->superblock_coding[
i]) {
729 current_run = vp4_get_mb_count(
s, gb);
731 s->superblock_coding[
i] =
bit;
739 next_block_pattern_table = 0;
741 for (plane = 0; plane < 3; plane++) {
743 int sb_width = plane ?
s->c_superblock_width :
s->y_superblock_width;
744 int sb_height = plane ?
s->c_superblock_height :
s->y_superblock_height;
745 int mb_width = plane ?
s->c_macroblock_width :
s->macroblock_width;
746 int mb_height = plane ?
s->c_macroblock_height :
s->macroblock_height;
747 int fragment_width =
s->fragment_width[!!plane];
748 int fragment_height =
s->fragment_height[!!plane];
750 for (sb_y = 0; sb_y < sb_height; sb_y++) {
751 for (sb_x = 0; sb_x < sb_width; sb_x++) {
752 for (j = 0; j < 4; j++) {
753 int mb_x = 2 * sb_x + (j >> 1);
754 int mb_y = 2 * sb_y + (j >> 1) ^ (j & 1);
755 int mb_coded, pattern, coded;
757 if (mb_x >= mb_width || mb_y >= mb_height)
760 mb_coded =
s->superblock_coding[
i++];
765 pattern = vp4_get_block_pattern(
s, gb, &next_block_pattern_table);
769 for (k = 0; k < 4; k++) {
773 coded = pattern & (8 >> k);
792 int i, j, k, sb_x, sb_y;
794 int current_macroblock;
795 int current_fragment;
802 for (
i = 0;
i <
s->fragment_count;
i++)
810 for (
i = 0;
i < 8;
i++)
812 for (
i = 0;
i < 8;
i++)
813 custom_mode_alphabet[
get_bits(gb, 3)] =
i;
814 alphabet = custom_mode_alphabet;
820 for (sb_y = 0; sb_y <
s->y_superblock_height; sb_y++) {
821 for (sb_x = 0; sb_x <
s->y_superblock_width; sb_x++) {
825 for (j = 0; j < 4; j++) {
826 int mb_x = 2 * sb_x + (j >> 1);
827 int mb_y = 2 * sb_y + (((j >> 1) + j) & 1);
828 current_macroblock = mb_y *
s->macroblock_width + mb_x;
830 if (mb_x >=
s->macroblock_width ||
831 mb_y >=
s->macroblock_height)
837 for (k = 0; k < 4; k++) {
840 if (
s->all_fragments[current_fragment].coding_method !=
MODE_COPY)
852 coding_mode = alphabet[
get_vlc2(gb,
s->mode_code_vlc.table, 3, 3)];
854 s->macroblock_coding[current_macroblock] = coding_mode;
855 for (k = 0; k < 4; k++) {
861 #define SET_CHROMA_MODES \
862 if (frag[s->fragment_start[1]].coding_method != MODE_COPY) \
863 frag[s->fragment_start[1]].coding_method = coding_mode; \
864 if (frag[s->fragment_start[2]].coding_method != MODE_COPY) \
865 frag[s->fragment_start[2]].coding_method = coding_mode;
867 if (
s->chroma_y_shift) {
868 frag =
s->all_fragments + mb_y *
869 s->fragment_width[1] + mb_x;
871 }
else if (
s->chroma_x_shift) {
872 frag =
s->all_fragments +
873 2 * mb_y *
s->fragment_width[1] + mb_x;
874 for (k = 0; k < 2; k++) {
876 frag +=
s->fragment_width[1];
879 for (k = 0; k < 4; k++) {
880 frag =
s->all_fragments +
896 return last_motion < 0 ? -v : v;
905 int j, k, sb_x, sb_y;
909 int last_motion_x = 0;
910 int last_motion_y = 0;
911 int prior_last_motion_x = 0;
912 int prior_last_motion_y = 0;
913 int last_gold_motion_x = 0;
914 int last_gold_motion_y = 0;
915 int current_macroblock;
916 int current_fragment;
923 coding_mode =
s->version < 2 ?
get_bits1(gb) : 2;
927 for (sb_y = 0; sb_y <
s->y_superblock_height; sb_y++) {
928 for (sb_x = 0; sb_x <
s->y_superblock_width; sb_x++) {
932 for (j = 0; j < 4; j++) {
933 int mb_x = 2 * sb_x + (j >> 1);
934 int mb_y = 2 * sb_y + (((j >> 1) + j) & 1);
935 current_macroblock = mb_y *
s->macroblock_width + mb_x;
937 if (mb_x >=
s->macroblock_width ||
938 mb_y >=
s->macroblock_height ||
939 s->macroblock_coding[current_macroblock] ==
MODE_COPY)
942 switch (
s->macroblock_coding[current_macroblock]) {
944 if (coding_mode == 2) {
945 last_gold_motion_x = motion_x[0] =
vp4_get_mv(
s, gb, 0, last_gold_motion_x);
946 last_gold_motion_y = motion_y[0] =
vp4_get_mv(
s, gb, 1, last_gold_motion_y);
951 if (coding_mode == 0) {
954 }
else if (coding_mode == 1) {
964 prior_last_motion_x = last_motion_x;
965 prior_last_motion_y = last_motion_y;
966 last_motion_x = motion_x[0];
967 last_motion_y = motion_y[0];
973 prior_last_motion_x = last_motion_x;
974 prior_last_motion_y = last_motion_y;
978 for (k = 0; k < 4; k++) {
980 if (
s->all_fragments[current_fragment].coding_method !=
MODE_COPY) {
981 if (coding_mode == 0) {
984 }
else if (coding_mode == 1) {
988 motion_x[k] =
vp4_get_mv(
s, gb, 0, prior_last_motion_x);
989 motion_y[k] =
vp4_get_mv(
s, gb, 1, prior_last_motion_y);
991 last_motion_x = motion_x[k];
992 last_motion_y = motion_y[k];
1002 motion_x[0] = last_motion_x;
1003 motion_y[0] = last_motion_y;
1012 motion_x[0] = prior_last_motion_x;
1013 motion_y[0] = prior_last_motion_y;
1016 prior_last_motion_x = last_motion_x;
1017 prior_last_motion_y = last_motion_y;
1018 last_motion_x = motion_x[0];
1019 last_motion_y = motion_y[0];
1032 for (k = 0; k < 4; k++) {
1036 s->motion_val[0][current_fragment][0] = motion_x[k];
1037 s->motion_val[0][current_fragment][1] = motion_y[k];
1039 s->motion_val[0][current_fragment][0] = motion_x[0];
1040 s->motion_val[0][current_fragment][1] = motion_y[0];
1044 if (
s->chroma_y_shift) {
1046 motion_x[0] =
RSHIFT(motion_x[0] + motion_x[1] +
1047 motion_x[2] + motion_x[3], 2);
1048 motion_y[0] =
RSHIFT(motion_y[0] + motion_y[1] +
1049 motion_y[2] + motion_y[3], 2);
1051 if (
s->version <= 2) {
1052 motion_x[0] = (motion_x[0] >> 1) | (motion_x[0] & 1);
1053 motion_y[0] = (motion_y[0] >> 1) | (motion_y[0] & 1);
1055 frag = mb_y *
s->fragment_width[1] + mb_x;
1056 s->motion_val[1][frag][0] = motion_x[0];
1057 s->motion_val[1][frag][1] = motion_y[0];
1058 }
else if (
s->chroma_x_shift) {
1060 motion_x[0] =
RSHIFT(motion_x[0] + motion_x[1], 1);
1061 motion_y[0] =
RSHIFT(motion_y[0] + motion_y[1], 1);
1062 motion_x[1] =
RSHIFT(motion_x[2] + motion_x[3], 1);
1063 motion_y[1] =
RSHIFT(motion_y[2] + motion_y[3], 1);
1065 motion_x[1] = motion_x[0];
1066 motion_y[1] = motion_y[0];
1068 if (
s->version <= 2) {
1069 motion_x[0] = (motion_x[0] >> 1) | (motion_x[0] & 1);
1070 motion_x[1] = (motion_x[1] >> 1) | (motion_x[1] & 1);
1072 frag = 2 * mb_y *
s->fragment_width[1] + mb_x;
1073 for (k = 0; k < 2; k++) {
1074 s->motion_val[1][frag][0] = motion_x[k];
1075 s->motion_val[1][frag][1] = motion_y[k];
1076 frag +=
s->fragment_width[1];
1079 for (k = 0; k < 4; k++) {
1082 s->motion_val[1][frag][0] = motion_x[k];
1083 s->motion_val[1][frag][1] = motion_y[k];
1085 s->motion_val[1][frag][0] = motion_x[0];
1086 s->motion_val[1][frag][1] = motion_y[0];
1099 int qpi,
i, j,
bit, run_length, blocks_decoded, num_blocks_at_qpi;
1100 int num_blocks =
s->total_num_coded_frags;
1102 for (qpi = 0; qpi <
s->nqps - 1 && num_blocks > 0; qpi++) {
1103 i = blocks_decoded = num_blocks_at_qpi = 0;
1114 run_length =
get_vlc2(gb,
s->superblock_run_length_vlc.table, 6, 2) + 1;
1115 if (run_length == 34)
1117 blocks_decoded += run_length;
1120 num_blocks_at_qpi += run_length;
1122 for (j = 0; j < run_length;
i++) {
1123 if (
i >=
s->total_num_coded_frags)
1126 if (
s->all_fragments[
s->coded_fragment_list[0][
i]].qpi == qpi) {
1127 s->all_fragments[
s->coded_fragment_list[0][
i]].qpi +=
bit;
1131 }
while (blocks_decoded < num_blocks &&
get_bits_left(gb) > 0);
1133 num_blocks -= num_blocks_at_qpi;
1149 int bits_to_get, zero_run;
1153 bits_to_get =
get_bits(gb, bits_to_get);
1186 int num_coeffs =
s->num_coded_frags[plane][coeff_index];
1187 int16_t *dct_tokens =
s->dct_tokens[plane][coeff_index];
1190 int *coded_fragment_list =
s->coded_fragment_list[plane];
1194 if (num_coeffs < 0) {
1196 "Invalid number of coefficients at level %d\n", coeff_index);
1200 if (eob_run > num_coeffs) {
1202 blocks_ended = num_coeffs;
1203 eob_run -= num_coeffs;
1206 blocks_ended = eob_run;
1212 dct_tokens[j++] = blocks_ended << 2;
1216 token =
get_vlc2(gb, vlc_table, 11, 3);
1218 if ((
unsigned) token <= 6
U) {
1225 if (eob_run > num_coeffs - coeff_i) {
1226 dct_tokens[j++] =
TOKEN_EOB(num_coeffs - coeff_i);
1227 blocks_ended += num_coeffs - coeff_i;
1228 eob_run -= num_coeffs - coeff_i;
1229 coeff_i = num_coeffs;
1232 blocks_ended += eob_run;
1236 }
else if (token >= 0) {
1247 all_fragments[coded_fragment_list[coeff_i]].
dc =
coeff;
1252 if (coeff_index + zero_run > 64) {
1254 "Invalid zero run of %d with %d coeffs left\n",
1255 zero_run, 64 - coeff_index);
1256 zero_run = 64 - coeff_index;
1261 for (
i = coeff_index + 1;
i <= coeff_index + zero_run;
i++)
1262 s->num_coded_frags[plane][
i]--;
1270 if (blocks_ended >
s->num_coded_frags[plane][coeff_index])
1276 for (
i = coeff_index + 1;
i < 64;
i++)
1277 s->num_coded_frags[plane][
i] -= blocks_ended;
1281 s->dct_tokens[plane + 1][coeff_index] = dct_tokens + j;
1282 else if (coeff_index < 63)
1283 s->dct_tokens[0][coeff_index + 1] = dct_tokens + j;
1291 int fragment_height);
1303 int residual_eob_run = 0;
1307 s->dct_tokens[0][0] =
s->dct_tokens_base;
1317 residual_eob_run =
unpack_vlcs(
s, gb, &
s->dc_vlc[dc_y_table], 0,
1318 0, residual_eob_run);
1319 if (residual_eob_run < 0)
1320 return residual_eob_run;
1328 residual_eob_run =
unpack_vlcs(
s, gb, &
s->dc_vlc[dc_c_table], 0,
1329 1, residual_eob_run);
1330 if (residual_eob_run < 0)
1331 return residual_eob_run;
1332 residual_eob_run =
unpack_vlcs(
s, gb, &
s->dc_vlc[dc_c_table], 0,
1333 2, residual_eob_run);
1334 if (residual_eob_run < 0)
1335 return residual_eob_run;
1340 s->fragment_width[1],
s->fragment_height[1]);
1342 s->fragment_width[1],
s->fragment_height[1]);
1352 for (
i = 1;
i <= 5;
i++) {
1353 y_tables[
i] = &
s->ac_vlc_1[ac_y_table];
1354 c_tables[
i] = &
s->ac_vlc_1[ac_c_table];
1356 for (
i = 6;
i <= 14;
i++) {
1357 y_tables[
i] = &
s->ac_vlc_2[ac_y_table];
1358 c_tables[
i] = &
s->ac_vlc_2[ac_c_table];
1360 for (
i = 15;
i <= 27;
i++) {
1361 y_tables[
i] = &
s->ac_vlc_3[ac_y_table];
1362 c_tables[
i] = &
s->ac_vlc_3[ac_c_table];
1364 for (
i = 28;
i <= 63;
i++) {
1365 y_tables[
i] = &
s->ac_vlc_4[ac_y_table];
1366 c_tables[
i] = &
s->ac_vlc_4[ac_c_table];
1370 for (
i = 1;
i <= 63;
i++) {
1372 0, residual_eob_run);
1373 if (residual_eob_run < 0)
1374 return residual_eob_run;
1377 1, residual_eob_run);
1378 if (residual_eob_run < 0)
1379 return residual_eob_run;
1381 2, residual_eob_run);
1382 if (residual_eob_run < 0)
1383 return residual_eob_run;
1389 #if CONFIG_VP4_DECODER
1398 int plane,
int eob_tracker[64],
int fragment)
1406 while (!eob_tracker[coeff_i]) {
1413 if ((
unsigned) token <= 6
U) {
1415 *
s->dct_tokens[plane][coeff_i]++ =
TOKEN_EOB(0);
1416 eob_tracker[coeff_i] = eob_run - 1;
1418 }
else if (token >= 0) {
1422 if (coeff_i + zero_run > 64) {
1424 "Invalid zero run of %d with %d coeffs left\n",
1425 zero_run, 64 - coeff_i);
1426 zero_run = 64 - coeff_i;
1429 coeff_i += zero_run;
1444 *
s->dct_tokens[plane][coeff_i]++ =
TOKEN_EOB(0);
1445 eob_tracker[coeff_i]--;
1459 for (
i = 0;
i < 4;
i++)
1460 dc_pred[0][
i + 1] =
s->dc_pred_row[sb_x * 4 +
i];
1462 for (j = 1; j < 5; j++)
1463 for (
i = 0;
i < 4;
i++)
1464 vp4_dc_predictor_reset(&dc_pred[j][
i + 1]);
1471 for (
i = 0;
i < 4;
i++)
1472 s->dc_pred_row[sb_x * 4 +
i] = dc_pred[4][
i + 1];
1475 dc_pred[
i][0] = dc_pred[
i][4];
1485 dc += dc_pred[-6].
dc;
1490 dc += dc_pred[6].
dc;
1494 if (count != 2 && dc_pred[-1].
type ==
type) {
1495 dc += dc_pred[-1].
dc;
1499 if (count != 2 && dc_pred[1].
type ==
type) {
1500 dc += dc_pred[1].
dc;
1505 return count == 2 ?
dc / 2 : last_dc[
type];
1511 int16_t *
base =
s->dct_tokens_base;
1512 for (plane = 0; plane < 3; plane++) {
1513 for (
i = 0;
i < 64;
i++) {
1514 s->dct_tokens[plane][
i] =
base;
1515 base +=
s->fragment_width[!!plane] *
s->fragment_height[!!plane];
1528 int plane, sb_y, sb_x;
1529 int eob_tracker[64];
1545 tables[0][0] = &
s->dc_vlc[dc_y_table];
1546 tables[1][0] = &
s->dc_vlc[dc_c_table];
1547 for (
i = 1;
i <= 5;
i++) {
1548 tables[0][
i] = &
s->ac_vlc_1[ac_y_table];
1549 tables[1][
i] = &
s->ac_vlc_1[ac_c_table];
1551 for (
i = 6;
i <= 14;
i++) {
1552 tables[0][
i] = &
s->ac_vlc_2[ac_y_table];
1553 tables[1][
i] = &
s->ac_vlc_2[ac_c_table];
1555 for (
i = 15;
i <= 27;
i++) {
1556 tables[0][
i] = &
s->ac_vlc_3[ac_y_table];
1557 tables[1][
i] = &
s->ac_vlc_3[ac_c_table];
1559 for (
i = 28;
i <= 63;
i++) {
1560 tables[0][
i] = &
s->ac_vlc_4[ac_y_table];
1561 tables[1][
i] = &
s->ac_vlc_4[ac_c_table];
1564 vp4_set_tokens_base(
s);
1566 memset(last_dc, 0,
sizeof(last_dc));
1569 memset(eob_tracker, 0,
sizeof(eob_tracker));
1572 for (
i = 0;
i <
s->fragment_width[!!plane];
i++)
1573 vp4_dc_predictor_reset(&
s->dc_pred_row[
i]);
1575 for (j = 0; j < 6; j++)
1576 for (
i = 0;
i < 6;
i++)
1577 vp4_dc_predictor_reset(&dc_pred[j][
i]);
1579 for (sb_y = 0; sb_y * 4 <
s->fragment_height[!!plane]; sb_y++) {
1580 for (sb_x = 0; sb_x *4 <
s->fragment_width[!!plane]; sb_x++) {
1581 vp4_dc_pred_before(
s, dc_pred, sb_x);
1582 for (j = 0; j < 16; j++) {
1585 int x = 4 * sb_x + hx;
1586 int y = 4 * sb_y + hy;
1590 if (x >=
s->fragment_width[!!plane] || y >=
s->fragment_height[!!plane])
1593 fragment =
s->fragment_start[plane] + y *
s->fragment_width[!!plane] + x;
1598 if (vp4_unpack_vlcs(
s, gb,
tables[!!plane], plane, eob_tracker,
fragment) < 0)
1604 vp4_dc_pred(
s, this_dc_pred, last_dc, dc_block_type, plane);
1606 this_dc_pred->
type = dc_block_type,
1607 this_dc_pred->
dc = last_dc[dc_block_type] =
s->all_fragments[
fragment].dc;
1609 vp4_dc_pred_after(
s, dc_pred, sb_x);
1614 vp4_set_tokens_base(
s);
1625 #define COMPATIBLE_FRAME(x) \
1626 (compatible_frame[s->all_fragments[x].coding_method] == current_frame_type)
1627 #define DC_COEFF(u) s->all_fragments[u].dc
1632 int fragment_height)
1640 int i = first_fragment;
1645 int vl, vul, vu, vur;
1657 static const int predictor_transform[16][4] = {
1671 { -104, 116, 0, 116 },
1673 { -104, 116, 0, 116 }
1682 static const unsigned char compatible_frame[9] = {
1693 int current_frame_type;
1709 for (y = 0; y < fragment_height; y++) {
1711 for (x = 0; x < fragment_width; x++,
i++) {
1714 if (
s->all_fragments[
i].coding_method !=
MODE_COPY) {
1715 current_frame_type =
1716 compatible_frame[
s->all_fragments[
i].coding_method];
1726 u =
i - fragment_width;
1731 ul =
i - fragment_width - 1;
1736 if (x + 1 < fragment_width) {
1737 ur =
i - fragment_width + 1;
1747 predicted_dc = last_dc[current_frame_type];
1751 (predictor_transform[
transform][0] * vul) +
1752 (predictor_transform[
transform][1] * vu) +
1753 (predictor_transform[
transform][2] * vur) +
1754 (predictor_transform[
transform][3] * vl);
1756 predicted_dc /= 128;
1761 if (
FFABS(predicted_dc - vu) > 128)
1763 else if (
FFABS(predicted_dc - vl) > 128)
1765 else if (
FFABS(predicted_dc - vul) > 128)
1773 last_dc[current_frame_type] =
DC_COEFF(
i);
1780 int ystart,
int yend)
1783 int *bounding_values =
s->bounding_values_array + 127;
1785 int width =
s->fragment_width[!!plane];
1786 int height =
s->fragment_height[!!plane];
1788 ptrdiff_t
stride =
s->current_frame.f->linesize[plane];
1789 uint8_t *plane_data =
s->current_frame.f->data[plane];
1790 if (!
s->flipped_image)
1792 plane_data +=
s->data_offset[plane] + 8 * ystart *
stride;
1794 for (y = ystart; y < yend; y++) {
1795 for (x = 0; x <
width; x++) {
1803 s->vp3dsp.h_loop_filter(
1805 stride, bounding_values);
1810 s->vp3dsp.v_loop_filter(
1812 stride, bounding_values);
1818 if ((x <
width - 1) &&
1820 s->vp3dsp.h_loop_filter(
1821 plane_data + 8 * x + 8,
1822 stride, bounding_values);
1830 s->vp3dsp.v_loop_filter(
1831 plane_data + 8 * x + 8 *
stride,
1832 stride, bounding_values);
1838 plane_data += 8 *
stride;
1847 int plane,
int inter, int16_t
block[64])
1849 int16_t *dequantizer =
s->qmat[frag->
qpi][inter][plane];
1854 int token = *
s->dct_tokens[plane][
i];
1855 switch (token & 3) {
1858 s->dct_tokens[plane][
i]++;
1860 *
s->dct_tokens[plane][
i] = token & ~3;
1863 s->dct_tokens[plane][
i]++;
1864 i += (token >> 2) & 0x7f;
1874 s->dct_tokens[plane][
i++]++;
1884 block[0] = frag->
dc *
s->qmat[0][inter][plane][0];
1897 int y_flipped =
s->flipped_image ?
s->height - y : y;
1903 y_flipped ==
s->height ? INT_MAX
1908 if (!
s->avctx->draw_horiz_band)
1911 h = y -
s->last_slice_end;
1912 s->last_slice_end = y;
1915 if (!
s->flipped_image)
1916 y =
s->height - y -
h;
1918 cy = y >>
s->chroma_y_shift;
1919 offset[0] =
s->current_frame.f->linesize[0] * y;
1920 offset[1] =
s->current_frame.f->linesize[1] * cy;
1921 offset[2] =
s->current_frame.f->linesize[2] * cy;
1926 s->avctx->draw_horiz_band(
s->avctx,
s->current_frame.f,
offset, y, 3,
h);
1934 int motion_y,
int y)
1938 int border = motion_y & 1;
1942 ref_frame = &
s->golden_frame;
1944 ref_frame = &
s->last_frame;
1946 ref_row = y + (motion_y >> 1);
1947 ref_row =
FFMAX(
FFABS(ref_row), ref_row + 8 + border);
1952 #if CONFIG_VP4_DECODER
1956 static int vp4_mc_loop_filter(
Vp3DecodeContext *
s,
int plane,
int motion_x,
int motion_y,
int bx,
int by,
1959 int motion_shift = plane ? 4 : 2;
1960 int subpel_mask = plane ? 3 : 1;
1961 int *bounding_values =
s->bounding_values_array + 127;
1966 int x_subpel, y_subpel;
1967 int x_offset, y_offset;
1969 int block_width = plane ? 8 : 16;
1970 int plane_width =
s->width >> (plane &&
s->chroma_x_shift);
1971 int plane_height =
s->height >> (plane &&
s->chroma_y_shift);
1973 #define loop_stride 12
1977 x = 8 * bx + motion_x / motion_shift;
1978 y = 8 * by + motion_y / motion_shift;
1980 x_subpel = motion_x & subpel_mask;
1981 y_subpel = motion_y & subpel_mask;
1983 if (x_subpel || y_subpel) {
1993 x2 = x + block_width;
1994 y2 = y + block_width;
1996 if (x2 < 0 || x2 >= plane_width || y2 < 0 || y2 >= plane_height)
1999 x_offset = (-(x + 2) & 7) + 2;
2000 y_offset = (-(y + 2) & 7) + 2;
2002 if (x_offset > 8 + x_subpel && y_offset > 8 + y_subpel)
2005 s->vdsp.emulated_edge_mc(
loop, motion_source -
stride - 1,
2007 12, 12, src_x - 1, src_y - 1,
2011 if (x_offset <= 8 + x_subpel)
2014 if (y_offset <= 8 + y_subpel)
2022 if (!x_offset && !y_offset)
2025 s->vdsp.emulated_edge_mc(
loop, motion_source -
stride - 1,
2027 12, 12, src_x - 1, src_y - 1,
2031 #define safe_loop_filter(name, ptr, stride, bounding_values) \
2032 if ((uintptr_t)(ptr) & 7) \
2033 s->vp3dsp.name##_unaligned(ptr, stride, bounding_values); \
2035 s->vp3dsp.name(ptr, stride, bounding_values);
2038 safe_loop_filter(h_loop_filter,
loop + loop_stride + x_offset + 1, loop_stride, bounding_values);
2041 safe_loop_filter(v_loop_filter,
loop + (y_offset + 1)*loop_stride + 1, loop_stride, bounding_values);
2044 for (
i = 0;
i < 9;
i++)
2058 int16_t *
block =
s->block;
2059 int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef;
2060 int motion_halfpel_index;
2062 int plane, first_pixel;
2064 if (slice >=
s->c_superblock_height)
2067 for (plane = 0; plane < 3; plane++) {
2069 s->data_offset[plane];
2070 uint8_t *last_plane =
s->last_frame.f->data[plane] +
2071 s->data_offset[plane];
2072 uint8_t *golden_plane =
s->golden_frame.f->data[plane] +
2073 s->data_offset[plane];
2074 ptrdiff_t
stride =
s->current_frame.f->linesize[plane];
2075 int plane_width =
s->width >> (plane &&
s->chroma_x_shift);
2076 int plane_height =
s->height >> (plane &&
s->chroma_y_shift);
2077 int8_t(*motion_val)[2] =
s->motion_val[!!plane];
2079 int sb_x, sb_y = slice << (!plane &&
s->chroma_y_shift);
2080 int slice_height = sb_y + 1 + (!plane &&
s->chroma_y_shift);
2081 int slice_width = plane ?
s->c_superblock_width
2082 :
s->y_superblock_width;
2084 int fragment_width =
s->fragment_width[!!plane];
2085 int fragment_height =
s->fragment_height[!!plane];
2086 int fragment_start =
s->fragment_start[plane];
2088 int do_await = !plane && HAVE_THREADS &&
2091 if (!
s->flipped_image)
2097 for (; sb_y < slice_height; sb_y++) {
2099 for (sb_x = 0; sb_x < slice_width; sb_x++) {
2101 for (j = 0; j < 16; j++) {
2109 if (x >= fragment_width || y >= fragment_height)
2112 first_pixel = 8 * y *
stride + 8 * x;
2118 (16 * y) >>
s->chroma_y_shift);
2121 if (
s->all_fragments[
i].coding_method !=
MODE_COPY) {
2124 motion_source = golden_plane;
2126 motion_source = last_plane;
2128 motion_source += first_pixel;
2129 motion_halfpel_index = 0;
2133 if ((
s->all_fragments[
i].coding_method >
MODE_INTRA) &&
2136 int standard_mc = 1;
2137 motion_x = motion_val[
fragment][0];
2138 motion_y = motion_val[
fragment][1];
2139 #if CONFIG_VP4_DECODER
2140 if (plane &&
s->version >= 2) {
2141 motion_x = (motion_x >> 1) | (motion_x & 1);
2142 motion_y = (motion_y >> 1) | (motion_y & 1);
2146 src_x = (motion_x >> 1) + 8 * x;
2147 src_y = (motion_y >> 1) + 8 * y;
2149 motion_halfpel_index = motion_x & 0x01;
2150 motion_source += (motion_x >> 1);
2152 motion_halfpel_index |= (motion_y & 0x01) << 1;
2153 motion_source += ((motion_y >> 1) *
stride);
2155 #if CONFIG_VP4_DECODER
2156 if (
s->version >= 2) {
2160 if (vp4_mc_loop_filter(
s, plane, motion_val[
fragment][0], motion_val[
fragment][1], x, y, motion_source,
stride, src_x, src_y,
temp)) {
2161 motion_source =
temp;
2167 if (standard_mc && (
2168 src_x < 0 || src_y < 0 ||
2169 src_x + 9 >= plane_width ||
2170 src_y + 9 >= plane_height)) {
2175 s->vdsp.emulated_edge_mc(
temp, motion_source,
2180 motion_source =
temp;
2191 if (motion_halfpel_index != 3) {
2192 s->hdsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
2194 motion_source,
stride, 8);
2198 int d = (motion_x ^ motion_y) >> 31;
2201 motion_source +
stride + 1 + d,
2227 s->hdsp.put_pixels_tab[1][0](
2229 last_plane + first_pixel,
2236 if (
s->version < 2 && !
s->skip_loop_filter)
2238 FFMIN(4 * sb_y + 3, fragment_height - 1));
2258 int y_fragment_count, c_fragment_count;
2262 y_fragment_count =
s->fragment_width[0] *
s->fragment_height[0];
2263 c_fragment_count =
s->fragment_width[1] *
s->fragment_height[1];
2266 s->superblock_coding =
av_mallocz(
FFMAX(
s->superblock_count,
s->yuv_macroblock_count));
2271 memset(
s-> num_kf_coded_fragment, -1,
sizeof(
s-> num_kf_coded_fragment));
2274 64 *
sizeof(*
s->dct_tokens_base));
2280 s->macroblock_coding =
av_mallocz(
s->macroblock_count + 1);
2282 s->dc_pred_row =
av_malloc_array(
s->y_superblock_width * 4,
sizeof(*
s->dc_pred_row));
2284 if (!
s->superblock_coding || !
s->all_fragments ||
2285 !
s->dct_tokens_base || !
s->kf_coded_fragment_list ||
2286 !
s->nkf_coded_fragment_list ||
2287 !
s->superblock_fragments || !
s->macroblock_coding ||
2289 !
s->motion_val[0] || !
s->motion_val[1]) {
2304 if (!
s->current_frame.f || !
s->last_frame.f || !
s->golden_frame.f)
2313 int i, inter, plane,
ret;
2316 int y_fragment_count, c_fragment_count;
2317 #if CONFIG_VP4_DECODER
2342 for (
i = 0;
i < 64;
i++) {
2343 #define TRANSPOSE(x) (((x) >> 3) | (((x) & 7) << 3))
2351 for (
i = 0;
i < 3;
i++)
2358 s->y_superblock_width = (
s->width + 31) / 32;
2359 s->y_superblock_height = (
s->height + 31) / 32;
2360 s->y_superblock_count =
s->y_superblock_width *
s->y_superblock_height;
2363 c_width =
s->width >>
s->chroma_x_shift;
2364 c_height =
s->height >>
s->chroma_y_shift;
2365 s->c_superblock_width = (c_width + 31) / 32;
2366 s->c_superblock_height = (c_height + 31) / 32;
2367 s->c_superblock_count =
s->c_superblock_width *
s->c_superblock_height;
2369 s->superblock_count =
s->y_superblock_count + (
s->c_superblock_count * 2);
2370 s->u_superblock_start =
s->y_superblock_count;
2371 s->v_superblock_start =
s->u_superblock_start +
s->c_superblock_count;
2373 s->macroblock_width = (
s->width + 15) / 16;
2374 s->macroblock_height = (
s->height + 15) / 16;
2375 s->macroblock_count =
s->macroblock_width *
s->macroblock_height;
2376 s->c_macroblock_width = (c_width + 15) / 16;
2377 s->c_macroblock_height = (c_height + 15) / 16;
2378 s->c_macroblock_count =
s->c_macroblock_width *
s->c_macroblock_height;
2379 s->yuv_macroblock_count =
s->macroblock_count + 2 *
s->c_macroblock_count;
2383 s->fragment_width[1] =
s->fragment_width[0] >>
s->chroma_x_shift;
2384 s->fragment_height[1] =
s->fragment_height[0] >>
s->chroma_y_shift;
2387 y_fragment_count =
s->fragment_width[0] *
s->fragment_height[0];
2388 c_fragment_count =
s->fragment_width[1] *
s->fragment_height[1];
2389 s->fragment_count = y_fragment_count + 2 * c_fragment_count;
2390 s->fragment_start[1] = y_fragment_count;
2391 s->fragment_start[2] = y_fragment_count + c_fragment_count;
2393 if (!
s->theora_tables) {
2394 for (
i = 0;
i < 64;
i++) {
2404 for (inter = 0; inter < 2; inter++) {
2405 for (plane = 0; plane < 3; plane++) {
2406 s->qr_count[inter][plane] = 1;
2407 s->qr_size[inter][plane][0] = 63;
2408 s->qr_base[inter][plane][0] =
2409 s->qr_base[inter][plane][1] = 2 * inter + (!!plane) * !inter;
2414 if (
s->version < 2) {
2415 for (
i = 0;
i < 16;
i++) {
2446 #if CONFIG_VP4_DECODER
2448 for (
i = 0;
i < 16;
i++) {
2482 for (
i = 0;
i < 16;
i++) {
2485 &
s->huffman_table[
i][0][1], 8, 4,
2486 &
s->huffman_table[
i][0][0], 8, 4, 0) < 0)
2491 &
s->huffman_table[
i + 16][0][1], 8, 4,
2492 &
s->huffman_table[
i + 16][0][0], 8, 4, 0) < 0)
2497 &
s->huffman_table[
i + 16 * 2][0][1], 8, 4,
2498 &
s->huffman_table[
i + 16 * 2][0][0], 8, 4, 0) < 0)
2503 &
s->huffman_table[
i + 16 * 3][0][1], 8, 4,
2504 &
s->huffman_table[
i + 16 * 3][0][0], 8, 4, 0) < 0)
2509 &
s->huffman_table[
i + 16 * 4][0][1], 8, 4,
2510 &
s->huffman_table[
i + 16 * 4][0][0], 8, 4, 0) < 0)
2515 if ((
ret =
init_vlc(&
s->superblock_run_length_vlc, 6, 34,
2520 if ((
ret =
init_vlc(&
s->fragment_run_length_vlc, 5, 30,
2535 #if CONFIG_VP4_DECODER
2536 for (j = 0; j < 2; j++)
2537 for (
i = 0;
i < 7;
i++)
2544 for (
i = 0;
i < 2;
i++)
2584 if (
src->f->data[0])
2602 int qps_changed = 0,
i, err;
2604 if (!
s1->current_frame.f->data[0] ||
2605 s->width !=
s1->width ||
s->height !=
s1->height) {
2613 if ((err = ref_frames(
s,
s1)) < 0)
2616 s->keyframe =
s1->keyframe;
2619 for (
i = 0;
i < 3;
i++) {
2620 if (
s->qps[
i] !=
s1->qps[1]) {
2622 memcpy(&
s->qmat[
i], &
s1->qmat[
i],
sizeof(
s->qmat[
i]));
2626 if (
s->qps[0] !=
s1->qps[0])
2627 memcpy(&
s->bounding_values_array, &
s1->bounding_values_array,
2628 sizeof(
s->bounding_values_array));
2631 memcpy(
s->qps,
s1->qps,
sizeof(
s->qps));
2632 memcpy(
s->last_qps,
s1->last_qps,
sizeof(
s->last_qps));
2642 void *
data,
int *got_frame,
2647 int buf_size = avpkt->
size;
2655 #if CONFIG_THEORA_DECODER
2661 av_log(avctx,
AV_LOG_ERROR,
"midstream reconfiguration with multithreading is unsupported, try -threads 1\n");
2675 }
else if (
type == 2) {
2688 "Header packet passed to frame decoder, skipping\n");
2694 if (!
s->all_fragments) {
2700 for (
i = 0;
i < 3;
i++)
2701 s->last_qps[
i] =
s->qps[
i];
2706 }
while (
s->theora >= 0x030200 &&
s->nqps < 3 &&
get_bits1(&gb));
2707 for (
i =
s->nqps;
i < 3;
i++)
2712 s->keyframe ?
"key" :
"", avctx->frame_number + 1,
s->qps[0]);
2714 s->skip_loop_filter = !
s->filter_limit_values[
s->qps[0]] ||
2718 if (
s->qps[0] !=
s->last_qps[0])
2721 for (
i = 0;
i <
s->nqps;
i++)
2724 if (
s->qps[
i] !=
s->last_qps[
i] ||
s->qps[0] !=
s->last_qps[0])
2732 s->current_frame.f->key_frame =
s->keyframe;
2736 if (!
s->edge_emu_buffer)
2737 s->edge_emu_buffer =
av_malloc(9 *
FFABS(
s->current_frame.f->linesize[0]));
2745 #if !CONFIG_VP4_DECODER
2752 if (avctx->frame_number == 0)
2754 "VP version: %d\n",
s->version);
2757 if (
s->version ||
s->theora) {
2760 "Warning, unsupported keyframe coding type?!\n");
2763 #if CONFIG_VP4_DECODER
2764 if (
s->version >= 2) {
2765 int mb_height, mb_width;
2766 int mb_width_mul, mb_width_div, mb_height_mul, mb_height_div;
2770 if (mb_height !=
s->macroblock_height ||
2771 mb_width !=
s->macroblock_width)
2778 if (mb_width_mul != 1 || mb_width_div != 1 || mb_height_mul != 1 || mb_height_div != 1)
2787 if (!
s->golden_frame.f->data[0]) {
2789 "vp3: first frame not a keyframe\n");
2797 &
s->golden_frame)) < 0)
2803 memset(
s->all_fragments, 0,
s->fragment_count *
sizeof(
Vp3Fragment));
2806 if (
s->version < 2) {
2811 #if CONFIG_VP4_DECODER
2813 if ((
ret = vp4_unpack_macroblocks(
s, &gb)) < 0) {
2832 if (
s->version < 2) {
2837 #if CONFIG_VP4_DECODER
2839 if ((
ret = vp4_unpack_dct_coeffs(
s, &gb)) < 0) {
2846 for (
i = 0;
i < 3;
i++) {
2847 int height =
s->height >> (
i &&
s->chroma_y_shift);
2848 if (
s->flipped_image)
2849 s->data_offset[
i] = 0;
2851 s->data_offset[
i] = (
height - 1) *
s->current_frame.f->linesize[
i];
2854 s->last_slice_end = 0;
2855 for (
i = 0;
i <
s->c_superblock_height;
i++)
2860 for (
i = 0;
i < 3;
i++) {
2861 int row = (
s->height >> (3 + (
i &&
s->chroma_y_shift))) - 1;
2870 frame->crop_left =
s->offset_x;
2871 frame->crop_right = avctx->coded_width - avctx->width -
s->offset_x;
2872 frame->crop_top =
s->offset_y;
2873 frame->crop_bottom = avctx->coded_height - avctx->height -
s->offset_y;
2900 if (
s->entries >= 32) {
2905 ff_dlog(avctx,
"hti %d hbits %x token %d entry : %d size %d\n",
2906 s->hti,
s->hbits, token,
s->entries,
s->huff_code_size);
2907 s->huffman_table[
s->hti][token][0] =
s->hbits;
2908 s->huffman_table[
s->hti][token][1] =
s->huff_code_size;
2911 if (
s->huff_code_size >= 32) {
2915 s->huff_code_size++;
2923 s->huff_code_size--;
2928 #if CONFIG_THEORA_DECODER
2936 int visible_width, visible_height, colorspace;
2937 uint8_t offset_x = 0, offset_y = 0;
2944 s->theora_header = 0;
2954 if (
s->theora < 0x030200) {
2955 s->flipped_image = 1;
2957 "Old (<alpha3) Theora bitstream, flipped image\n");
2965 if (
s->theora >= 0x030200) {
2975 visible_width + offset_x >
s->width ||
2976 visible_height + offset_y >
s->height) {
2978 "Invalid frame dimensions - w:%d h:%d x:%d y:%d (%dx%d).\n",
2979 visible_width, visible_height, offset_x, offset_y,
2980 s->width,
s->height);
2986 if (fps.
num && fps.
den) {
2987 if (fps.
num < 0 || fps.
den < 0) {
2992 fps.
den, fps.
num, 1 << 30);
2997 if (aspect.
num && aspect.
den) {
3000 aspect.
num, aspect.
den, 1 << 30);
3004 if (
s->theora < 0x030200)
3011 if (
s->theora >= 0x030200) {
3026 avctx->
width = visible_width;
3027 avctx->
height = visible_height;
3030 s->offset_x = offset_x;
3031 s->offset_y =
s->height - visible_height - offset_y;
3034 if (colorspace == 1)
3036 else if (colorspace == 2)
3039 if (colorspace == 1 || colorspace == 2) {
3044 s->theora_header = 1;
3051 int i, n, matrices, inter, plane;
3053 if (!
s->theora_header)
3056 if (
s->theora >= 0x030200) {
3060 for (
i = 0;
i < 64;
i++)
3064 if (
s->theora >= 0x030200)
3069 for (
i = 0;
i < 64;
i++)
3070 s->coded_ac_scale_factor[
i] =
get_bits(gb, n);
3072 if (
s->theora >= 0x030200)
3077 for (
i = 0;
i < 64;
i++)
3078 s->coded_dc_scale_factor[0][
i] =
3079 s->coded_dc_scale_factor[1][
i] =
get_bits(gb, n);
3081 if (
s->theora >= 0x030200)
3086 if (matrices > 384) {
3091 for (n = 0; n < matrices; n++)
3092 for (
i = 0;
i < 64;
i++)
3095 for (inter = 0; inter <= 1; inter++) {
3096 for (plane = 0; plane <= 2; plane++) {
3098 if (inter || plane > 0)
3106 qtj = (3 * inter + plane - 1) / 3;
3107 plj = (plane + 2) % 3;
3109 s->qr_count[inter][plane] =
s->qr_count[qtj][plj];
3110 memcpy(
s->qr_size[inter][plane],
s->qr_size[qtj][plj],
3111 sizeof(
s->qr_size[0][0]));
3112 memcpy(
s->qr_base[inter][plane],
s->qr_base[qtj][plj],
3113 sizeof(
s->qr_base[0][0]));
3120 if (
i >= matrices) {
3122 "invalid base matrix index\n");
3125 s->qr_base[inter][plane][qri] =
i;
3129 s->qr_size[inter][plane][qri++] =
i;
3137 s->qr_count[inter][plane] = qri;
3143 for (
s->hti = 0;
s->hti < 80;
s->hti++) {
3145 s->huff_code_size = 1;
3156 s->theora_tables = 1;
3166 const uint8_t *header_start[3];
3181 42, header_start, header_len) < 0) {
3186 for (
i = 0;
i < 3;
i++) {
3187 if (header_len[
i] <= 0)
3195 if (!(ptype & 0x80)) {
3218 "Unknown Theora config packet: %d\n", ptype & ~0x80);
3223 "%d bits left in packet %X\n",
3225 if (
s->theora < 0x030200)
3238 .
init = theora_decode_init,
3266 #if CONFIG_VP4_DECODER