Go to the documentation of this file.
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;
353 for (
i = 0;
i < 16;
i++) {
366 for (j = 0; j < 2; j++)
367 for (
i = 0;
i < 7;
i++)
370 for (
i = 0;
i < 2;
i++)
384 int sb_x, sb_y,
plane;
388 int sb_width =
plane ?
s->c_superblock_width
389 :
s->y_superblock_width;
390 int sb_height =
plane ?
s->c_superblock_height
391 :
s->y_superblock_height;
392 int frag_width =
s->fragment_width[!!
plane];
393 int frag_height =
s->fragment_height[!!
plane];
395 for (sb_y = 0; sb_y < sb_height; sb_y++)
396 for (sb_x = 0; sb_x < sb_width; sb_x++)
397 for (
i = 0;
i < 16;
i++) {
401 if (x < frag_width && y < frag_height)
402 s->superblock_fragments[j++] =
s->fragment_start[
plane] +
405 s->superblock_fragments[j++] = -1;
418 int ac_scale_factor =
s->coded_ac_scale_factor[
s->qps[qpi]];
419 int i,
plane, inter, qri, bmi, bmj, qistart;
421 for (inter = 0; inter < 2; inter++) {
423 int dc_scale_factor =
s->coded_dc_scale_factor[!!
plane][
s->qps[qpi]];
425 for (qri = 0; qri <
s->qr_count[inter][
plane]; qri++) {
426 sum +=
s->qr_size[inter][
plane][qri];
427 if (
s->qps[qpi] <= sum)
430 qistart = sum -
s->qr_size[inter][
plane][qri];
431 bmi =
s->qr_base[inter][
plane][qri];
432 bmj =
s->qr_base[inter][
plane][qri + 1];
433 for (
i = 0;
i < 64;
i++) {
434 int coeff = (2 * (sum -
s->qps[qpi]) *
s->base_matrix[bmi][
i] -
435 2 * (qistart -
s->qps[qpi]) *
s->base_matrix[bmj][
i] +
436 s->qr_size[inter][
plane][qri]) /
437 (2 *
s->qr_size[inter][
plane][qri]);
439 int qmin = 8 << (inter + !
i);
440 int qscale =
i ? ac_scale_factor : dc_scale_factor;
441 int qbias = (1 + inter) * 3;
442 s->qmat[qpi][inter][
plane][
s->idct_permutation[
i]] =
443 (
i == 0 ||
s->version < 2) ? av_clip((qscale *
coeff) / 100 * 4, qmin, 4096)
444 : (qscale * (
coeff - qbias) / 100 + qbias) * 4;
448 s->qmat[qpi][inter][
plane][0] =
s->qmat[0][inter][
plane][0];
470 int superblock_starts[3] = {
471 0,
s->u_superblock_start,
s->v_superblock_start
474 int current_superblock = 0;
476 int num_partial_superblocks = 0;
479 int current_fragment;
481 int plane0_num_coded_frags = 0;
490 while (current_superblock < s->superblock_count &&
get_bits_left(gb) > 0) {
496 current_run =
get_vlc2(gb,
s->superblock_run_length_vlc.table,
498 if (current_run == 34)
501 if (current_run >
s->superblock_count - current_superblock) {
503 "Invalid partially coded superblock run length\n");
507 memset(
s->superblock_coding + current_superblock,
bit, current_run);
509 current_superblock += current_run;
511 num_partial_superblocks += current_run;
516 if (num_partial_superblocks < s->superblock_count) {
517 int superblocks_decoded = 0;
519 current_superblock = 0;
523 while (superblocks_decoded < s->superblock_count - num_partial_superblocks &&
530 current_run =
get_vlc2(gb,
s->superblock_run_length_vlc.table,
532 if (current_run == 34)
535 for (j = 0; j < current_run; current_superblock++) {
536 if (current_superblock >=
s->superblock_count) {
538 "Invalid fully coded superblock run length\n");
543 if (
s->superblock_coding[current_superblock] ==
SB_NOT_CODED) {
544 s->superblock_coding[current_superblock] = 2 *
bit;
548 superblocks_decoded += current_run;
554 if (num_partial_superblocks) {
565 s->total_num_coded_frags = 0;
566 memset(
s->macroblock_coding,
MODE_COPY,
s->macroblock_count);
568 s->coded_fragment_list[0] =
s->keyframe ?
s->kf_coded_fragment_list
569 :
s->nkf_coded_fragment_list;
572 int sb_start = superblock_starts[
plane];
573 int sb_end = sb_start + (
plane ?
s->c_superblock_count
574 :
s->y_superblock_count);
575 int num_coded_frags = 0;
578 if (
s->num_kf_coded_fragment[
plane] == -1) {
579 for (
i = sb_start;
i < sb_end;
i++) {
581 for (j = 0; j < 16; j++) {
583 current_fragment =
s->superblock_fragments[
i * 16 + j];
584 if (current_fragment != -1) {
585 s->coded_fragment_list[
plane][num_coded_frags++] =
590 s->num_kf_coded_fragment[
plane] = num_coded_frags;
592 num_coded_frags =
s->num_kf_coded_fragment[
plane];
599 for (j = 0; j < 16; j++) {
601 current_fragment =
s->superblock_fragments[
i * 16 + j];
602 if (current_fragment != -1) {
603 int coded =
s->superblock_coding[
i];
608 if (current_run-- == 0) {
610 current_run =
get_vlc2(gb,
s->fragment_run_length_vlc.table, 5, 2);
618 s->all_fragments[current_fragment].coding_method =
620 s->coded_fragment_list[
plane][num_coded_frags++] =
624 s->all_fragments[current_fragment].coding_method =
632 plane0_num_coded_frags = num_coded_frags;
633 s->total_num_coded_frags += num_coded_frags;
634 for (
i = 0;
i < 64;
i++)
635 s->num_coded_frags[
plane][
i] = num_coded_frags;
637 s->coded_fragment_list[
plane + 1] =
s->coded_fragment_list[
plane] +
643 #define BLOCK_X (2 * mb_x + (k & 1))
644 #define BLOCK_Y (2 * mb_y + (k >> 1))
646 #if CONFIG_VP4_DECODER
658 if (v >
s->yuv_macroblock_count) {
664 skip_bits(gb, 2 + n); \
665 v += (1 << n) + get_bits(gb, n); }
666 #define thresh(n) (0x200 - (0x80 >> n))
667 #define else_if(n) else if (bits < thresh(n)) body(n)
670 }
else if (
bits < thresh(0)) {
689 int v =
get_vlc2(gb,
s->block_pattern_vlc[*next_block_pattern_table].table, 3, 2);
692 *next_block_pattern_table = 0;
702 int next_block_pattern_table;
703 int bit, current_run, has_partial;
705 memset(
s->macroblock_coding,
MODE_COPY,
s->macroblock_count);
712 for (
i = 0;
i <
s->yuv_macroblock_count;
i += current_run) {
715 current_run = vp4_get_mb_count(
s, gb);
716 if (current_run >
s->yuv_macroblock_count -
i)
718 memset(
s->superblock_coding +
i, 2 *
bit, current_run);
727 current_run = vp4_get_mb_count(
s, gb);
728 for (
i = 0;
i <
s->yuv_macroblock_count;
i++) {
729 if (!
s->superblock_coding[
i]) {
732 current_run = vp4_get_mb_count(
s, gb);
734 s->superblock_coding[
i] =
bit;
742 next_block_pattern_table = 0;
746 int sb_width =
plane ?
s->c_superblock_width :
s->y_superblock_width;
747 int sb_height =
plane ?
s->c_superblock_height :
s->y_superblock_height;
748 int mb_width =
plane ?
s->c_macroblock_width :
s->macroblock_width;
749 int mb_height =
plane ?
s->c_macroblock_height :
s->macroblock_height;
750 int fragment_width =
s->fragment_width[!!
plane];
751 int fragment_height =
s->fragment_height[!!
plane];
753 for (sb_y = 0; sb_y < sb_height; sb_y++) {
754 for (sb_x = 0; sb_x < sb_width; sb_x++) {
755 for (j = 0; j < 4; j++) {
756 int mb_x = 2 * sb_x + (j >> 1);
757 int mb_y = 2 * sb_y + (j >> 1) ^ (j & 1);
758 int mb_coded, pattern, coded;
760 if (mb_x >= mb_width || mb_y >= mb_height)
763 mb_coded =
s->superblock_coding[
i++];
768 pattern = vp4_get_block_pattern(
s, gb, &next_block_pattern_table);
772 for (k = 0; k < 4; k++) {
776 coded = pattern & (8 >> k);
795 int i, j, k, sb_x, sb_y;
797 int current_macroblock;
798 int current_fragment;
805 for (
i = 0;
i <
s->fragment_count;
i++)
813 for (
i = 0;
i < 8;
i++)
815 for (
i = 0;
i < 8;
i++)
816 custom_mode_alphabet[
get_bits(gb, 3)] =
i;
817 alphabet = custom_mode_alphabet;
823 for (sb_y = 0; sb_y <
s->y_superblock_height; sb_y++) {
824 for (sb_x = 0; sb_x <
s->y_superblock_width; sb_x++) {
828 for (j = 0; j < 4; j++) {
829 int mb_x = 2 * sb_x + (j >> 1);
830 int mb_y = 2 * sb_y + (((j >> 1) + j) & 1);
831 current_macroblock = mb_y *
s->macroblock_width + mb_x;
833 if (mb_x >=
s->macroblock_width ||
834 mb_y >=
s->macroblock_height)
840 for (k = 0; k < 4; k++) {
843 if (
s->all_fragments[current_fragment].coding_method !=
MODE_COPY)
855 coding_mode = alphabet[
get_vlc2(gb,
s->mode_code_vlc.table, 3, 3)];
857 s->macroblock_coding[current_macroblock] = coding_mode;
858 for (k = 0; k < 4; k++) {
864 #define SET_CHROMA_MODES \
865 if (frag[s->fragment_start[1]].coding_method != MODE_COPY) \
866 frag[s->fragment_start[1]].coding_method = coding_mode; \
867 if (frag[s->fragment_start[2]].coding_method != MODE_COPY) \
868 frag[s->fragment_start[2]].coding_method = coding_mode;
870 if (
s->chroma_y_shift) {
871 frag =
s->all_fragments + mb_y *
872 s->fragment_width[1] + mb_x;
874 }
else if (
s->chroma_x_shift) {
875 frag =
s->all_fragments +
876 2 * mb_y *
s->fragment_width[1] + mb_x;
877 for (k = 0; k < 2; k++) {
879 frag +=
s->fragment_width[1];
882 for (k = 0; k < 4; k++) {
883 frag =
s->all_fragments +
899 return last_motion < 0 ? -v : v;
908 int j, k, sb_x, sb_y;
912 int last_motion_x = 0;
913 int last_motion_y = 0;
914 int prior_last_motion_x = 0;
915 int prior_last_motion_y = 0;
916 int last_gold_motion_x = 0;
917 int last_gold_motion_y = 0;
918 int current_macroblock;
919 int current_fragment;
926 coding_mode =
s->version < 2 ?
get_bits1(gb) : 2;
930 for (sb_y = 0; sb_y <
s->y_superblock_height; sb_y++) {
931 for (sb_x = 0; sb_x <
s->y_superblock_width; sb_x++) {
935 for (j = 0; j < 4; j++) {
936 int mb_x = 2 * sb_x + (j >> 1);
937 int mb_y = 2 * sb_y + (((j >> 1) + j) & 1);
938 current_macroblock = mb_y *
s->macroblock_width + mb_x;
940 if (mb_x >=
s->macroblock_width ||
941 mb_y >=
s->macroblock_height ||
942 s->macroblock_coding[current_macroblock] ==
MODE_COPY)
945 switch (
s->macroblock_coding[current_macroblock]) {
947 if (coding_mode == 2) {
948 last_gold_motion_x = motion_x[0] =
vp4_get_mv(
s, gb, 0, last_gold_motion_x);
949 last_gold_motion_y = motion_y[0] =
vp4_get_mv(
s, gb, 1, last_gold_motion_y);
954 if (coding_mode == 0) {
957 }
else if (coding_mode == 1) {
967 prior_last_motion_x = last_motion_x;
968 prior_last_motion_y = last_motion_y;
969 last_motion_x = motion_x[0];
970 last_motion_y = motion_y[0];
976 prior_last_motion_x = last_motion_x;
977 prior_last_motion_y = last_motion_y;
981 for (k = 0; k < 4; k++) {
983 if (
s->all_fragments[current_fragment].coding_method !=
MODE_COPY) {
984 if (coding_mode == 0) {
987 }
else if (coding_mode == 1) {
991 motion_x[k] =
vp4_get_mv(
s, gb, 0, prior_last_motion_x);
992 motion_y[k] =
vp4_get_mv(
s, gb, 1, prior_last_motion_y);
994 last_motion_x = motion_x[k];
995 last_motion_y = motion_y[k];
1005 motion_x[0] = last_motion_x;
1006 motion_y[0] = last_motion_y;
1015 motion_x[0] = prior_last_motion_x;
1016 motion_y[0] = prior_last_motion_y;
1019 prior_last_motion_x = last_motion_x;
1020 prior_last_motion_y = last_motion_y;
1021 last_motion_x = motion_x[0];
1022 last_motion_y = motion_y[0];
1035 for (k = 0; k < 4; k++) {
1039 s->motion_val[0][current_fragment][0] = motion_x[k];
1040 s->motion_val[0][current_fragment][1] = motion_y[k];
1042 s->motion_val[0][current_fragment][0] = motion_x[0];
1043 s->motion_val[0][current_fragment][1] = motion_y[0];
1047 if (
s->chroma_y_shift) {
1049 motion_x[0] =
RSHIFT(motion_x[0] + motion_x[1] +
1050 motion_x[2] + motion_x[3], 2);
1051 motion_y[0] =
RSHIFT(motion_y[0] + motion_y[1] +
1052 motion_y[2] + motion_y[3], 2);
1054 if (
s->version <= 2) {
1055 motion_x[0] = (motion_x[0] >> 1) | (motion_x[0] & 1);
1056 motion_y[0] = (motion_y[0] >> 1) | (motion_y[0] & 1);
1058 frag = mb_y *
s->fragment_width[1] + mb_x;
1059 s->motion_val[1][frag][0] = motion_x[0];
1060 s->motion_val[1][frag][1] = motion_y[0];
1061 }
else if (
s->chroma_x_shift) {
1063 motion_x[0] =
RSHIFT(motion_x[0] + motion_x[1], 1);
1064 motion_y[0] =
RSHIFT(motion_y[0] + motion_y[1], 1);
1065 motion_x[1] =
RSHIFT(motion_x[2] + motion_x[3], 1);
1066 motion_y[1] =
RSHIFT(motion_y[2] + motion_y[3], 1);
1068 motion_x[1] = motion_x[0];
1069 motion_y[1] = motion_y[0];
1071 if (
s->version <= 2) {
1072 motion_x[0] = (motion_x[0] >> 1) | (motion_x[0] & 1);
1073 motion_x[1] = (motion_x[1] >> 1) | (motion_x[1] & 1);
1075 frag = 2 * mb_y *
s->fragment_width[1] + mb_x;
1076 for (k = 0; k < 2; k++) {
1077 s->motion_val[1][frag][0] = motion_x[k];
1078 s->motion_val[1][frag][1] = motion_y[k];
1079 frag +=
s->fragment_width[1];
1082 for (k = 0; k < 4; k++) {
1085 s->motion_val[1][frag][0] = motion_x[k];
1086 s->motion_val[1][frag][1] = motion_y[k];
1088 s->motion_val[1][frag][0] = motion_x[0];
1089 s->motion_val[1][frag][1] = motion_y[0];
1102 int qpi,
i, j,
bit, run_length, blocks_decoded, num_blocks_at_qpi;
1103 int num_blocks =
s->total_num_coded_frags;
1105 for (qpi = 0; qpi <
s->nqps - 1 && num_blocks > 0; qpi++) {
1106 i = blocks_decoded = num_blocks_at_qpi = 0;
1117 run_length =
get_vlc2(gb,
s->superblock_run_length_vlc.table, 6, 2) + 1;
1118 if (run_length == 34)
1120 blocks_decoded += run_length;
1123 num_blocks_at_qpi += run_length;
1125 for (j = 0; j < run_length;
i++) {
1126 if (
i >=
s->total_num_coded_frags)
1129 if (
s->all_fragments[
s->coded_fragment_list[0][
i]].qpi == qpi) {
1130 s->all_fragments[
s->coded_fragment_list[0][
i]].qpi +=
bit;
1134 }
while (blocks_decoded < num_blocks &&
get_bits_left(gb) > 0);
1136 num_blocks -= num_blocks_at_qpi;
1152 int bits_to_get, zero_run;
1156 bits_to_get =
get_bits(gb, bits_to_get);
1189 int num_coeffs =
s->num_coded_frags[
plane][coeff_index];
1190 int16_t *dct_tokens =
s->dct_tokens[
plane][coeff_index];
1193 int *coded_fragment_list =
s->coded_fragment_list[
plane];
1197 if (num_coeffs < 0) {
1199 "Invalid number of coefficients at level %d\n", coeff_index);
1203 if (eob_run > num_coeffs) {
1205 blocks_ended = num_coeffs;
1206 eob_run -= num_coeffs;
1209 blocks_ended = eob_run;
1215 dct_tokens[j++] = blocks_ended << 2;
1219 token =
get_vlc2(gb, vlc_table, 11, 3);
1221 if ((
unsigned) token <= 6
U) {
1228 if (eob_run > num_coeffs - coeff_i) {
1229 dct_tokens[j++] =
TOKEN_EOB(num_coeffs - coeff_i);
1230 blocks_ended += num_coeffs - coeff_i;
1231 eob_run -= num_coeffs - coeff_i;
1232 coeff_i = num_coeffs;
1235 blocks_ended += eob_run;
1239 }
else if (token >= 0) {
1250 all_fragments[coded_fragment_list[coeff_i]].
dc =
coeff;
1255 if (coeff_index + zero_run > 64) {
1257 "Invalid zero run of %d with %d coeffs left\n",
1258 zero_run, 64 - coeff_index);
1259 zero_run = 64 - coeff_index;
1264 for (
i = coeff_index + 1;
i <= coeff_index + zero_run;
i++)
1265 s->num_coded_frags[
plane][
i]--;
1273 if (blocks_ended >
s->num_coded_frags[
plane][coeff_index])
1279 for (
i = coeff_index + 1;
i < 64;
i++)
1280 s->num_coded_frags[
plane][
i] -= blocks_ended;
1284 s->dct_tokens[
plane + 1][coeff_index] = dct_tokens + j;
1285 else if (coeff_index < 63)
1286 s->dct_tokens[0][coeff_index + 1] = dct_tokens + j;
1294 int fragment_height);
1306 int residual_eob_run = 0;
1310 s->dct_tokens[0][0] =
s->dct_tokens_base;
1320 residual_eob_run =
unpack_vlcs(
s, gb, &
s->dc_vlc[dc_y_table], 0,
1321 0, residual_eob_run);
1322 if (residual_eob_run < 0)
1323 return residual_eob_run;
1331 residual_eob_run =
unpack_vlcs(
s, gb, &
s->dc_vlc[dc_c_table], 0,
1332 1, residual_eob_run);
1333 if (residual_eob_run < 0)
1334 return residual_eob_run;
1335 residual_eob_run =
unpack_vlcs(
s, gb, &
s->dc_vlc[dc_c_table], 0,
1336 2, residual_eob_run);
1337 if (residual_eob_run < 0)
1338 return residual_eob_run;
1343 s->fragment_width[1],
s->fragment_height[1]);
1345 s->fragment_width[1],
s->fragment_height[1]);
1355 for (
i = 1;
i <= 5;
i++) {
1356 y_tables[
i] = &
s->ac_vlc_1[ac_y_table];
1357 c_tables[
i] = &
s->ac_vlc_1[ac_c_table];
1359 for (
i = 6;
i <= 14;
i++) {
1360 y_tables[
i] = &
s->ac_vlc_2[ac_y_table];
1361 c_tables[
i] = &
s->ac_vlc_2[ac_c_table];
1363 for (
i = 15;
i <= 27;
i++) {
1364 y_tables[
i] = &
s->ac_vlc_3[ac_y_table];
1365 c_tables[
i] = &
s->ac_vlc_3[ac_c_table];
1367 for (
i = 28;
i <= 63;
i++) {
1368 y_tables[
i] = &
s->ac_vlc_4[ac_y_table];
1369 c_tables[
i] = &
s->ac_vlc_4[ac_c_table];
1373 for (
i = 1;
i <= 63;
i++) {
1375 0, residual_eob_run);
1376 if (residual_eob_run < 0)
1377 return residual_eob_run;
1380 1, residual_eob_run);
1381 if (residual_eob_run < 0)
1382 return residual_eob_run;
1384 2, residual_eob_run);
1385 if (residual_eob_run < 0)
1386 return residual_eob_run;
1392 #if CONFIG_VP4_DECODER
1409 while (!eob_tracker[coeff_i]) {
1416 if ((
unsigned) token <= 6
U) {
1419 eob_tracker[coeff_i] = eob_run - 1;
1421 }
else if (token >= 0) {
1425 if (coeff_i + zero_run > 64) {
1427 "Invalid zero run of %d with %d coeffs left\n",
1428 zero_run, 64 - coeff_i);
1429 zero_run = 64 - coeff_i;
1432 coeff_i += zero_run;
1448 eob_tracker[coeff_i]--;
1462 for (
i = 0;
i < 4;
i++)
1463 dc_pred[0][
i + 1] =
s->dc_pred_row[sb_x * 4 +
i];
1465 for (j = 1; j < 5; j++)
1466 for (
i = 0;
i < 4;
i++)
1467 vp4_dc_predictor_reset(&dc_pred[j][
i + 1]);
1474 for (
i = 0;
i < 4;
i++)
1475 s->dc_pred_row[sb_x * 4 +
i] = dc_pred[4][
i + 1];
1478 dc_pred[
i][0] = dc_pred[
i][4];
1488 dc += dc_pred[-6].
dc;
1493 dc += dc_pred[6].
dc;
1498 dc += dc_pred[-1].
dc;
1503 dc += dc_pred[1].
dc;
1514 int16_t *
base =
s->dct_tokens_base;
1516 for (
i = 0;
i < 64;
i++) {
1531 int plane, sb_y, sb_x;
1532 int eob_tracker[64];
1548 tables[0][0] = &
s->dc_vlc[dc_y_table];
1549 tables[1][0] = &
s->dc_vlc[dc_c_table];
1550 for (
i = 1;
i <= 5;
i++) {
1551 tables[0][
i] = &
s->ac_vlc_1[ac_y_table];
1552 tables[1][
i] = &
s->ac_vlc_1[ac_c_table];
1554 for (
i = 6;
i <= 14;
i++) {
1555 tables[0][
i] = &
s->ac_vlc_2[ac_y_table];
1556 tables[1][
i] = &
s->ac_vlc_2[ac_c_table];
1558 for (
i = 15;
i <= 27;
i++) {
1559 tables[0][
i] = &
s->ac_vlc_3[ac_y_table];
1560 tables[1][
i] = &
s->ac_vlc_3[ac_c_table];
1562 for (
i = 28;
i <= 63;
i++) {
1563 tables[0][
i] = &
s->ac_vlc_4[ac_y_table];
1564 tables[1][
i] = &
s->ac_vlc_4[ac_c_table];
1567 vp4_set_tokens_base(
s);
1569 memset(last_dc, 0,
sizeof(last_dc));
1572 memset(eob_tracker, 0,
sizeof(eob_tracker));
1575 for (
i = 0;
i <
s->fragment_width[!!
plane];
i++)
1576 vp4_dc_predictor_reset(&
s->dc_pred_row[
i]);
1578 for (j = 0; j < 6; j++)
1579 for (
i = 0;
i < 6;
i++)
1580 vp4_dc_predictor_reset(&dc_pred[j][
i]);
1582 for (sb_y = 0; sb_y * 4 <
s->fragment_height[!!
plane]; sb_y++) {
1583 for (sb_x = 0; sb_x *4 <
s->fragment_width[!!
plane]; sb_x++) {
1584 vp4_dc_pred_before(
s, dc_pred, sb_x);
1585 for (j = 0; j < 16; j++) {
1588 int x = 4 * sb_x + hx;
1589 int y = 4 * sb_y + hy;
1593 if (x >=
s->fragment_width[!!
plane] || y >=
s->fragment_height[!!
plane])
1607 vp4_dc_pred(
s, this_dc_pred, last_dc, dc_block_type,
plane);
1609 this_dc_pred->
type = dc_block_type,
1610 this_dc_pred->
dc = last_dc[dc_block_type] =
s->all_fragments[
fragment].dc;
1612 vp4_dc_pred_after(
s, dc_pred, sb_x);
1617 vp4_set_tokens_base(
s);
1628 #define COMPATIBLE_FRAME(x) \
1629 (compatible_frame[s->all_fragments[x].coding_method] == current_frame_type)
1630 #define DC_COEFF(u) s->all_fragments[u].dc
1635 int fragment_height)
1643 int i = first_fragment;
1648 int vl, vul, vu, vur;
1660 static const int predictor_transform[16][4] = {
1674 { -104, 116, 0, 116 },
1676 { -104, 116, 0, 116 }
1685 static const unsigned char compatible_frame[9] = {
1696 int current_frame_type;
1712 for (y = 0; y < fragment_height; y++) {
1714 for (x = 0; x < fragment_width; x++,
i++) {
1717 if (
s->all_fragments[
i].coding_method !=
MODE_COPY) {
1718 current_frame_type =
1719 compatible_frame[
s->all_fragments[
i].coding_method];
1729 u =
i - fragment_width;
1734 ul =
i - fragment_width - 1;
1739 if (x + 1 < fragment_width) {
1740 ur =
i - fragment_width + 1;
1750 predicted_dc = last_dc[current_frame_type];
1754 (predictor_transform[
transform][0] * vul) +
1755 (predictor_transform[
transform][1] * vu) +
1756 (predictor_transform[
transform][2] * vur) +
1757 (predictor_transform[
transform][3] * vl);
1759 predicted_dc /= 128;
1764 if (
FFABS(predicted_dc - vu) > 128)
1766 else if (
FFABS(predicted_dc - vl) > 128)
1768 else if (
FFABS(predicted_dc - vul) > 128)
1776 last_dc[current_frame_type] =
DC_COEFF(
i);
1783 int ystart,
int yend)
1786 int *bounding_values =
s->bounding_values_array + 127;
1791 ptrdiff_t
stride =
s->current_frame.f->linesize[
plane];
1793 if (!
s->flipped_image)
1795 plane_data +=
s->data_offset[
plane] + 8 * ystart *
stride;
1797 for (y = ystart; y < yend; y++) {
1798 for (x = 0; x <
width; x++) {
1806 s->vp3dsp.h_loop_filter(
1808 stride, bounding_values);
1813 s->vp3dsp.v_loop_filter(
1815 stride, bounding_values);
1821 if ((x <
width - 1) &&
1823 s->vp3dsp.h_loop_filter(
1824 plane_data + 8 * x + 8,
1825 stride, bounding_values);
1833 s->vp3dsp.v_loop_filter(
1834 plane_data + 8 * x + 8 *
stride,
1835 stride, bounding_values);
1841 plane_data += 8 *
stride;
1852 int16_t *dequantizer =
s->qmat[frag->
qpi][inter][
plane];
1857 int token = *
s->dct_tokens[
plane][
i];
1858 switch (token & 3) {
1863 *
s->dct_tokens[
plane][
i] = token & ~3;
1867 i += (token >> 2) & 0x7f;
1900 int y_flipped =
s->flipped_image ?
s->height - y : y;
1906 y_flipped ==
s->height ? INT_MAX
1911 if (!
s->avctx->draw_horiz_band)
1914 h = y -
s->last_slice_end;
1915 s->last_slice_end = y;
1918 if (!
s->flipped_image)
1919 y =
s->height - y -
h;
1921 cy = y >>
s->chroma_y_shift;
1922 offset[0] =
s->current_frame.f->linesize[0] * y;
1923 offset[1] =
s->current_frame.f->linesize[1] * cy;
1924 offset[2] =
s->current_frame.f->linesize[2] * cy;
1929 s->avctx->draw_horiz_band(
s->avctx,
s->current_frame.f,
offset, y, 3,
h);
1937 int motion_y,
int y)
1941 int border = motion_y & 1;
1945 ref_frame = &
s->golden_frame;
1947 ref_frame = &
s->last_frame;
1949 ref_row = y + (motion_y >> 1);
1950 ref_row =
FFMAX(
FFABS(ref_row), ref_row + 8 + border);
1955 #if CONFIG_VP4_DECODER
1959 static int vp4_mc_loop_filter(
Vp3DecodeContext *
s,
int plane,
int motion_x,
int motion_y,
int bx,
int by,
1962 int motion_shift =
plane ? 4 : 2;
1963 int subpel_mask =
plane ? 3 : 1;
1964 int *bounding_values =
s->bounding_values_array + 127;
1969 int x_subpel, y_subpel;
1970 int x_offset, y_offset;
1972 int block_width =
plane ? 8 : 16;
1973 int plane_width =
s->width >> (
plane &&
s->chroma_x_shift);
1974 int plane_height =
s->height >> (
plane &&
s->chroma_y_shift);
1976 #define loop_stride 12
1980 x = 8 * bx + motion_x / motion_shift;
1981 y = 8 * by + motion_y / motion_shift;
1983 x_subpel = motion_x & subpel_mask;
1984 y_subpel = motion_y & subpel_mask;
1986 if (x_subpel || y_subpel) {
1996 x2 = x + block_width;
1997 y2 = y + block_width;
1999 if (x2 < 0 || x2 >= plane_width || y2 < 0 || y2 >= plane_height)
2002 x_offset = (-(x + 2) & 7) + 2;
2003 y_offset = (-(y + 2) & 7) + 2;
2005 if (x_offset > 8 + x_subpel && y_offset > 8 + y_subpel)
2008 s->vdsp.emulated_edge_mc(
loop, motion_source -
stride - 1,
2010 12, 12, src_x - 1, src_y - 1,
2014 if (x_offset <= 8 + x_subpel)
2017 if (y_offset <= 8 + y_subpel)
2025 if (!x_offset && !y_offset)
2028 s->vdsp.emulated_edge_mc(
loop, motion_source -
stride - 1,
2030 12, 12, src_x - 1, src_y - 1,
2035 s->vp3dsp.h_loop_filter(
loop + loop_stride + x_offset + 1, loop_stride, bounding_values);
2038 s->vp3dsp.v_loop_filter(
loop + (y_offset + 1)*loop_stride + 1, loop_stride, bounding_values);
2041 for (
i = 0;
i < 9;
i++)
2055 int16_t *
block =
s->block;
2056 int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef;
2057 int motion_halfpel_index;
2059 int plane, first_pixel;
2061 if (slice >=
s->c_superblock_height)
2071 ptrdiff_t
stride =
s->current_frame.f->linesize[
plane];
2072 int plane_width =
s->width >> (
plane &&
s->chroma_x_shift);
2073 int plane_height =
s->height >> (
plane &&
s->chroma_y_shift);
2074 int8_t(*motion_val)[2] =
s->motion_val[!!
plane];
2076 int sb_x, sb_y = slice << (!
plane &&
s->chroma_y_shift);
2077 int slice_height = sb_y + 1 + (!
plane &&
s->chroma_y_shift);
2078 int slice_width =
plane ?
s->c_superblock_width
2079 :
s->y_superblock_width;
2081 int fragment_width =
s->fragment_width[!!
plane];
2082 int fragment_height =
s->fragment_height[!!
plane];
2083 int fragment_start =
s->fragment_start[
plane];
2085 int do_await = !
plane && HAVE_THREADS &&
2088 if (!
s->flipped_image)
2094 for (; sb_y < slice_height; sb_y++) {
2096 for (sb_x = 0; sb_x < slice_width; sb_x++) {
2098 for (j = 0; j < 16; j++) {
2106 if (x >= fragment_width || y >= fragment_height)
2109 first_pixel = 8 * y *
stride + 8 * x;
2115 (16 * y) >>
s->chroma_y_shift);
2118 if (
s->all_fragments[
i].coding_method !=
MODE_COPY) {
2121 motion_source = golden_plane;
2123 motion_source = last_plane;
2125 motion_source += first_pixel;
2126 motion_halfpel_index = 0;
2130 if ((
s->all_fragments[
i].coding_method >
MODE_INTRA) &&
2133 int standard_mc = 1;
2134 motion_x = motion_val[
fragment][0];
2135 motion_y = motion_val[
fragment][1];
2136 #if CONFIG_VP4_DECODER
2137 if (
plane &&
s->version >= 2) {
2138 motion_x = (motion_x >> 1) | (motion_x & 1);
2139 motion_y = (motion_y >> 1) | (motion_y & 1);
2143 src_x = (motion_x >> 1) + 8 * x;
2144 src_y = (motion_y >> 1) + 8 * y;
2146 motion_halfpel_index = motion_x & 0x01;
2147 motion_source += (motion_x >> 1);
2149 motion_halfpel_index |= (motion_y & 0x01) << 1;
2150 motion_source += ((motion_y >> 1) *
stride);
2152 #if CONFIG_VP4_DECODER
2153 if (
s->version >= 2) {
2157 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)) {
2158 motion_source =
temp;
2164 if (standard_mc && (
2165 src_x < 0 || src_y < 0 ||
2166 src_x + 9 >= plane_width ||
2167 src_y + 9 >= plane_height)) {
2172 s->vdsp.emulated_edge_mc(
temp, motion_source,
2177 motion_source =
temp;
2188 if (motion_halfpel_index != 3) {
2189 s->hdsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
2191 motion_source,
stride, 8);
2195 int d = (motion_x ^ motion_y) >> 31;
2198 motion_source +
stride + 1 + d,
2224 s->hdsp.put_pixels_tab[1][0](
2226 last_plane + first_pixel,
2233 if (
s->version < 2 && !
s->skip_loop_filter)
2235 FFMIN(4 * sb_y + 3, fragment_height - 1));
2255 int y_fragment_count, c_fragment_count;
2259 y_fragment_count =
s->fragment_width[0] *
s->fragment_height[0];
2260 c_fragment_count =
s->fragment_width[1] *
s->fragment_height[1];
2263 s->superblock_coding =
av_mallocz(
FFMAX(
s->superblock_count,
s->yuv_macroblock_count));
2268 memset(
s-> num_kf_coded_fragment, -1,
sizeof(
s-> num_kf_coded_fragment));
2271 64 *
sizeof(*
s->dct_tokens_base));
2277 s->macroblock_coding =
av_mallocz(
s->macroblock_count + 1);
2279 s->dc_pred_row =
av_malloc_array(
s->y_superblock_width * 4,
sizeof(*
s->dc_pred_row));
2281 if (!
s->superblock_coding || !
s->all_fragments ||
2282 !
s->dct_tokens_base || !
s->kf_coded_fragment_list ||
2283 !
s->nkf_coded_fragment_list ||
2284 !
s->superblock_fragments || !
s->macroblock_coding ||
2286 !
s->motion_val[0] || !
s->motion_val[1]) {
2302 if (!
s->current_frame.f || !
s->last_frame.f || !
s->golden_frame.f) {
2318 int y_fragment_count, c_fragment_count;
2319 #if CONFIG_VP4_DECODER
2346 for (
i = 0;
i < 64;
i++) {
2347 #define TRANSPOSE(x) (((x) >> 3) | (((x) & 7) << 3))
2355 for (
i = 0;
i < 3;
i++)
2362 s->y_superblock_width = (
s->width + 31) / 32;
2363 s->y_superblock_height = (
s->height + 31) / 32;
2364 s->y_superblock_count =
s->y_superblock_width *
s->y_superblock_height;
2367 c_width =
s->width >>
s->chroma_x_shift;
2368 c_height =
s->height >>
s->chroma_y_shift;
2369 s->c_superblock_width = (c_width + 31) / 32;
2370 s->c_superblock_height = (c_height + 31) / 32;
2371 s->c_superblock_count =
s->c_superblock_width *
s->c_superblock_height;
2373 s->superblock_count =
s->y_superblock_count + (
s->c_superblock_count * 2);
2374 s->u_superblock_start =
s->y_superblock_count;
2375 s->v_superblock_start =
s->u_superblock_start +
s->c_superblock_count;
2377 s->macroblock_width = (
s->width + 15) / 16;
2378 s->macroblock_height = (
s->height + 15) / 16;
2379 s->macroblock_count =
s->macroblock_width *
s->macroblock_height;
2380 s->c_macroblock_width = (c_width + 15) / 16;
2381 s->c_macroblock_height = (c_height + 15) / 16;
2382 s->c_macroblock_count =
s->c_macroblock_width *
s->c_macroblock_height;
2383 s->yuv_macroblock_count =
s->macroblock_count + 2 *
s->c_macroblock_count;
2387 s->fragment_width[1] =
s->fragment_width[0] >>
s->chroma_x_shift;
2388 s->fragment_height[1] =
s->fragment_height[0] >>
s->chroma_y_shift;
2391 y_fragment_count =
s->fragment_width[0] *
s->fragment_height[0];
2392 c_fragment_count =
s->fragment_width[1] *
s->fragment_height[1];
2393 s->fragment_count = y_fragment_count + 2 * c_fragment_count;
2394 s->fragment_start[1] = y_fragment_count;
2395 s->fragment_start[2] = y_fragment_count + c_fragment_count;
2397 if (!
s->theora_tables) {
2398 for (
i = 0;
i < 64;
i++) {
2408 for (inter = 0; inter < 2; inter++) {
2410 s->qr_count[inter][
plane] = 1;
2411 s->qr_size[inter][
plane][0] = 63;
2412 s->qr_base[inter][
plane][0] =
2413 s->qr_base[inter][
plane][1] = 2 * inter + (!!
plane) * !inter;
2418 if (
s->version < 2) {
2419 for (
i = 0;
i < 16;
i++) {
2445 #if CONFIG_VP4_DECODER
2447 for (
i = 0;
i < 16;
i++) {
2476 for (
i = 0;
i < 16;
i++) {
2479 &
s->huffman_table[
i][0][1], 8, 4,
2480 &
s->huffman_table[
i][0][0], 8, 4, 0) < 0)
2485 &
s->huffman_table[
i + 16][0][1], 8, 4,
2486 &
s->huffman_table[
i + 16][0][0], 8, 4, 0) < 0)
2491 &
s->huffman_table[
i + 16 * 2][0][1], 8, 4,
2492 &
s->huffman_table[
i + 16 * 2][0][0], 8, 4, 0) < 0)
2497 &
s->huffman_table[
i + 16 * 3][0][1], 8, 4,
2498 &
s->huffman_table[
i + 16 * 3][0][0], 8, 4, 0) < 0)
2503 &
s->huffman_table[
i + 16 * 4][0][1], 8, 4,
2504 &
s->huffman_table[
i + 16 * 4][0][0], 8, 4, 0) < 0)
2509 init_vlc(&
s->superblock_run_length_vlc, 6, 34,
2513 init_vlc(&
s->fragment_run_length_vlc, 5, 30,
2525 #if CONFIG_VP4_DECODER
2526 for (j = 0; j < 2; j++)
2527 for (
i = 0;
i < 7;
i++)
2533 for (
i = 0;
i < 2;
i++)
2572 if (
src->f->data[0])
2590 int qps_changed = 0,
i, err;
2592 #define copy_fields(to, from, start_field, end_field) \
2593 memcpy(&to->start_field, &from->start_field, \
2594 (char *) &to->end_field - (char *) &to->start_field)
2596 if (!
s1->current_frame.f->data[0] ||
2597 s->width !=
s1->width ||
s->height !=
s1->height) {
2604 if (!
s->current_frame.f)
2607 if (!
s->current_frame.f->data[0]) {
2608 int y_fragment_count, c_fragment_count;
2613 y_fragment_count =
s->fragment_width[0] *
s->fragment_height[0];
2614 c_fragment_count =
s->fragment_width[1] *
s->fragment_height[1];
2615 memcpy(
s->motion_val[0],
s1->motion_val[0],
2616 y_fragment_count *
sizeof(*
s->motion_val[0]));
2617 memcpy(
s->motion_val[1],
s1->motion_val[1],
2618 c_fragment_count *
sizeof(*
s->motion_val[1]));
2622 if ((err = ref_frames(
s,
s1)) < 0)
2625 s->keyframe =
s1->keyframe;
2628 for (
i = 0;
i < 3;
i++) {
2629 if (
s->qps[
i] !=
s1->qps[1]) {
2631 memcpy(&
s->qmat[
i], &
s1->qmat[
i],
sizeof(
s->qmat[
i]));
2635 if (
s->qps[0] !=
s1->qps[0])
2636 memcpy(&
s->bounding_values_array, &
s1->bounding_values_array,
2637 sizeof(
s->bounding_values_array));
2649 void *
data,
int *got_frame,
2654 int buf_size = avpkt->
size;
2662 #if CONFIG_THEORA_DECODER
2668 av_log(avctx,
AV_LOG_ERROR,
"midstream reconfiguration with multithreading is unsupported, try -threads 1\n");
2682 }
else if (
type == 2) {
2695 "Header packet passed to frame decoder, skipping\n");
2701 if (!
s->all_fragments) {
2707 for (
i = 0;
i < 3;
i++)
2708 s->last_qps[
i] =
s->qps[
i];
2713 }
while (
s->theora >= 0x030200 &&
s->nqps < 3 &&
get_bits1(&gb));
2714 for (
i =
s->nqps;
i < 3;
i++)
2719 s->keyframe ?
"key" :
"", avctx->frame_number + 1,
s->qps[0]);
2721 s->skip_loop_filter = !
s->filter_limit_values[
s->qps[0]] ||
2725 if (
s->qps[0] !=
s->last_qps[0])
2728 for (
i = 0;
i <
s->nqps;
i++)
2731 if (
s->qps[
i] !=
s->last_qps[
i] ||
s->qps[0] !=
s->last_qps[0])
2739 s->current_frame.f->key_frame =
s->keyframe;
2743 if (!
s->edge_emu_buffer)
2744 s->edge_emu_buffer =
av_malloc(9 *
FFABS(
s->current_frame.f->linesize[0]));
2752 #if !CONFIG_VP4_DECODER
2759 if (avctx->frame_number == 0)
2761 "VP version: %d\n",
s->version);
2764 if (
s->version ||
s->theora) {
2767 "Warning, unsupported keyframe coding type?!\n");
2770 #if CONFIG_VP4_DECODER
2771 if (
s->version >= 2) {
2772 int mb_height, mb_width;
2773 int mb_width_mul, mb_width_div, mb_height_mul, mb_height_div;
2777 if (mb_height !=
s->macroblock_height ||
2778 mb_width !=
s->macroblock_width)
2785 if (mb_width_mul != 1 || mb_width_div != 1 || mb_height_mul != 1 || mb_height_div != 1)
2794 if (!
s->golden_frame.f->data[0]) {
2796 "vp3: first frame not a keyframe\n");
2804 &
s->golden_frame)) < 0)
2810 memset(
s->all_fragments, 0,
s->fragment_count *
sizeof(
Vp3Fragment));
2813 if (
s->version < 2) {
2818 #if CONFIG_VP4_DECODER
2820 if (vp4_unpack_macroblocks(
s, &gb)) {
2839 if (
s->version < 2) {
2844 #if CONFIG_VP4_DECODER
2846 if (vp4_unpack_dct_coeffs(
s, &gb)) {
2853 for (
i = 0;
i < 3;
i++) {
2854 int height =
s->height >> (
i &&
s->chroma_y_shift);
2855 if (
s->flipped_image)
2856 s->data_offset[
i] = 0;
2858 s->data_offset[
i] = (
height - 1) *
s->current_frame.f->linesize[
i];
2861 s->last_slice_end = 0;
2862 for (
i = 0;
i <
s->c_superblock_height;
i++)
2867 for (
i = 0;
i < 3;
i++) {
2868 int row = (
s->height >> (3 + (
i &&
s->chroma_y_shift))) - 1;
2877 frame->crop_left =
s->offset_x;
2878 frame->crop_right = avctx->coded_width - avctx->width -
s->offset_x;
2879 frame->crop_top =
s->offset_y;
2880 frame->crop_bottom = avctx->coded_height - avctx->height -
s->offset_y;
2907 if (
s->entries >= 32) {
2912 ff_dlog(avctx,
"hti %d hbits %x token %d entry : %d size %d\n",
2913 s->hti,
s->hbits, token,
s->entries,
s->huff_code_size);
2914 s->huffman_table[
s->hti][token][0] =
s->hbits;
2915 s->huffman_table[
s->hti][token][1] =
s->huff_code_size;
2918 if (
s->huff_code_size >= 32) {
2922 s->huff_code_size++;
2930 s->huff_code_size--;
2940 s->superblock_coding =
NULL;
2941 s->all_fragments =
NULL;
2942 s->coded_fragment_list[0] =
NULL;
2943 s-> kf_coded_fragment_list=
NULL;
2944 s->nkf_coded_fragment_list=
NULL;
2945 s->dct_tokens_base =
NULL;
2946 s->superblock_fragments =
NULL;
2947 s->macroblock_coding =
NULL;
2948 s->motion_val[0] =
NULL;
2949 s->motion_val[1] =
NULL;
2950 s->edge_emu_buffer =
NULL;
2951 s->dc_pred_row =
NULL;
2957 #if CONFIG_THEORA_DECODER
2965 int visible_width, visible_height, colorspace;
2966 uint8_t offset_x = 0, offset_y = 0;
2973 s->theora_header = 0;
2983 if (
s->theora < 0x030200) {
2984 s->flipped_image = 1;
2986 "Old (<alpha3) Theora bitstream, flipped image\n");
2994 if (
s->theora >= 0x030200) {
3004 visible_width + offset_x >
s->width ||
3005 visible_height + offset_y >
s->height) {
3007 "Invalid frame dimensions - w:%d h:%d x:%d y:%d (%dx%d).\n",
3008 visible_width, visible_height, offset_x, offset_y,
3009 s->width,
s->height);
3015 if (fps.
num && fps.
den) {
3016 if (fps.
num < 0 || fps.
den < 0) {
3021 fps.
den, fps.
num, 1 << 30);
3026 if (aspect.
num && aspect.
den) {
3029 aspect.
num, aspect.
den, 1 << 30);
3033 if (
s->theora < 0x030200)
3040 if (
s->theora >= 0x030200) {
3055 avctx->
width = visible_width;
3056 avctx->
height = visible_height;
3059 s->offset_x = offset_x;
3060 s->offset_y =
s->height - visible_height - offset_y;
3063 if (colorspace == 1)
3065 else if (colorspace == 2)
3068 if (colorspace == 1 || colorspace == 2) {
3073 s->theora_header = 1;
3080 int i,
n, matrices, inter,
plane;
3082 if (!
s->theora_header)
3085 if (
s->theora >= 0x030200) {
3089 for (
i = 0;
i < 64;
i++)
3093 if (
s->theora >= 0x030200)
3098 for (
i = 0;
i < 64;
i++)
3101 if (
s->theora >= 0x030200)
3106 for (
i = 0;
i < 64;
i++)
3107 s->coded_dc_scale_factor[0][
i] =
3110 if (
s->theora >= 0x030200)
3115 if (matrices > 384) {
3120 for (
n = 0;
n < matrices;
n++)
3121 for (
i = 0;
i < 64;
i++)
3124 for (inter = 0; inter <= 1; inter++) {
3127 if (inter ||
plane > 0)
3135 qtj = (3 * inter +
plane - 1) / 3;
3136 plj = (
plane + 2) % 3;
3138 s->qr_count[inter][
plane] =
s->qr_count[qtj][plj];
3139 memcpy(
s->qr_size[inter][
plane],
s->qr_size[qtj][plj],
3140 sizeof(
s->qr_size[0][0]));
3141 memcpy(
s->qr_base[inter][
plane],
s->qr_base[qtj][plj],
3142 sizeof(
s->qr_base[0][0]));
3149 if (
i >= matrices) {
3151 "invalid base matrix index\n");
3154 s->qr_base[inter][
plane][qri] =
i;
3158 s->qr_size[inter][
plane][qri++] =
i;
3166 s->qr_count[inter][
plane] = qri;
3172 for (
s->hti = 0;
s->hti < 80;
s->hti++) {
3174 s->huff_code_size = 1;
3185 s->theora_tables = 1;
3195 const uint8_t *header_start[3];
3210 42, header_start, header_len) < 0) {
3215 for (
i = 0;
i < 3;
i++) {
3216 if (header_len[
i] <= 0)
3224 if (!(ptype & 0x80)) {
3247 "Unknown Theora config packet: %d\n", ptype & ~0x80);
3252 "%d bits left in packet %X\n",
3254 if (
s->theora < 0x030200)
3267 .
init = theora_decode_init,
3295 #if CONFIG_VP4_DECODER
static const uint16_t vp4_ac_scale_factor[64]
static av_cold int allocate_tables(AVCodecContext *avctx)
Allocate tables for per-frame data in Vp3DecodeContext.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
static av_cold int init(AVCodecContext *avctx)
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static void vp3_decode_flush(AVCodecContext *avctx)
enum AVColorSpace colorspace
YUV colorspace type.
static const uint16_t ac_bias_3[16][32][2]
static const uint8_t zero_run_base[32]
#define MODE_INTER_PRIOR_LAST
#define u(width, name, range_min, range_max)
uint8_t idct_scantable[64]
#define MKTAG(a, b, c, d)
static const int8_t vp31_intra_y_dequant[64]
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_count(const GetBitContext *s)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int end(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
static const int8_t vp31_intra_c_dequant[64]
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
VLC superblock_run_length_vlc
void ff_vp3dsp_set_bounding_values(int *bounding_values_array, int filter_limit)
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static const uint16_t table[]
Vp3Fragment * all_fragments
static const uint16_t vp4_ac_bias_0[16][32][2]
static const uint16_t fragment_run_length_vlc_table[30][2]
uint8_t filter_limit_values[64]
void * av_mallocz_array(size_t nmemb, size_t size)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static void body(uint32_t ABCD[4], const uint8_t *src, int nblocks)
static const uint16_t vp4_dc_bias[16][32][2]
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before ff_thread_await_progress() has been called on them. reget_buffer() and buffer age optimizations no longer work. *The contents of buffers must not be written to after ff_thread_report_progress() has been called on them. This includes draw_edges(). Porting codecs to frame threading
static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
static void render_slice(Vp3DecodeContext *s, int slice)
#define FF_DEBUG_PICT_INFO
static int vp3_dequant(Vp3DecodeContext *s, Vp3Fragment *frag, int plane, int inter, int16_t block[64])
Pull DCT tokens from the 64 levels to decode and dequant the coefficients for the next block in codin...
#define AV_CODEC_FLAG2_IGNORE_CROP
Discard cropping information from SPS.
#define bit(string, value)
int bounding_values_array[256+2]
static void skip_bits(GetBitContext *s, int n)
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it.
int * superblock_fragments
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int get_coeff(GetBitContext *gb, int token, int16_t *coeff)
#define CODING_MODE_COUNT
#define copy_fields(s, e)
static const uint16_t dc_bias[16][32][2]
Writing a table generator This documentation is preliminary Parts of the API are not good and should be changed Basic concepts A table generator consists of two *_tablegen c and *_tablegen h The h file will provide the variable declarations and initialization code for the tables
int flags
AV_CODEC_FLAG_*.
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
#define MODE_INTER_LAST_MV
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int num_kf_coded_fragment[3]
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define TOKEN_ZERO_RUN(coeff, zero_run)
static const uint8_t vp4_pred_block_type_map[8]
static int vp3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
static const uint8_t motion_vector_vlc_table[63][2]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb)
static const uint8_t hilbert_offset[16][2]
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static void init_loop_filter(Vp3DecodeContext *s)
VLC fragment_run_length_vlc
static const uint8_t vp4_mv_table_selector[32]
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
static int init_block_mapping(Vp3DecodeContext *s)
This function sets up all of the various blocks mappings: superblocks <-> fragments,...
#define SB_PARTIALLY_CODED
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static void reverse_dc_prediction(Vp3DecodeContext *s, int first_fragment, int fragment_width, int fragment_height)
static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
static const int ModeAlphabet[6][CODING_MODE_COUNT]
void ff_free_vlc(VLC *vlc)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
#define MODE_USING_GOLDEN
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
uint8_t idct_permutation[64]
static const uint16_t ac_bias_1[16][32][2]
static void init_dequantizer(Vp3DecodeContext *s, int qpi)
#define MODE_INTER_FOURMV
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
@ AVDISCARD_ALL
discard all
static const int16_t *const coeff_tables[32]
static void flush(AVCodecContext *avctx)
static av_cold int init_frames(Vp3DecodeContext *s)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static const uint8_t mode_code_vlc_table[8][2]
static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)
static const int8_t transform[32][32]
Rational number (pair of numerator and denominator).
struct AVCodecInternal * internal
Private context used for internal data.
static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb, VLC *table, int coeff_index, int plane, int eob_run)
void ff_vp3dsp_h_loop_filter_12(uint8_t *first_pixel, ptrdiff_t stride, int *bounding_values)
static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
#define TOKEN_COEFF(coeff)
static const uint8_t vp4_y_dc_scale_factor[64]
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
static int update_frames(AVCodecContext *avctx)
Release and shuffle frames after decode finishes.
static const int8_t motion_vector_table[63]
#define FF_CODEC_CAP_EXPORTS_CROPPING
The decoder sets the cropping fields in the output frames manually.
static const uint16_t vp31_ac_scale_factor[64]
uint8_t qr_size[2][3][64]
static void error(const char *err)
void ff_vp3dsp_v_loop_filter_12(uint8_t *first_pixel, ptrdiff_t stride, int *bounding_values)
int total_num_coded_frags
@ AVDISCARD_NONKEY
discard all frames except keyframes
int flags2
AV_CODEC_FLAG2_*.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
static const int8_t fixed_motion_vector_table[64]
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled top and top right vectors is used as motion vector prediction the used motion vector is the sum of the predictor and(mvx_diff, mvy_diff) *mv_scale Intra DC Prediction block[y][x] dc[1]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static const uint16_t vp4_ac_bias_3[16][32][2]
int allocate_progress
Whether to allocate progress for frame threading.
static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
static int vp4_get_mv(Vp3DecodeContext *s, GetBitContext *gb, int axis, int last_motion)
static VLC_TYPE vlc_tables[VLC_TABLES_SIZE][2]
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have add an init_thread_copy() which re-allocates them for other threads. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. If there are inter-frame dependencies
#define AV_NUM_DATA_POINTERS
int16_t * dct_tokens[3][64]
This is a list of all tokens in bitstream order.
uint16_t coded_dc_scale_factor[2][64]
ThreadFrame current_frame
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
unsigned char * macroblock_coding
#define AV_LOG_INFO
Standard information.
@ AVCOL_TRC_BT709
also ITU-R BT1361
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define DECLARE_ALIGNED(n, t, v)
static const int8_t vp31_inter_dequant[64]
int * nkf_coded_fragment_list
static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int yend)
av_cold void ff_vp3dsp_init(VP3DSPContext *c, int flags)
#define i(width, name, range_min, range_max)
uint8_t * edge_emu_buffer
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define av_malloc_array(a, b)
static const uint16_t superblock_run_length_vlc_table[34][2]
static const uint16_t ac_bias_2[16][32][2]
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVCodec ff_theora_decoder
int * coded_fragment_list[3]
const uint8_t ff_zigzag_direct[64]
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
static av_cold void free_tables(AVCodecContext *avctx)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define MODE_INTER_PLUS_MV
int num_coded_frags[3][64]
number of blocks that contain DCT coefficients at the given level or higher
static const uint8_t vp4_block_pattern_table_selector[14]
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call ff_thread_finish_setup() afterwards. If some code can 't be moved
static const uint8_t vp4_filter_limit_values[64]
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
main external API structure.
static const uint16_t ac_bias_0[16][32][2]
uint32_t huffman_table[80][32][2]
static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
called when all pixels up to row y are complete
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
static const uint8_t vp4_generic_dequant[64]
static const uint8_t zero_run_get_bits[32]
static void await_reference_row(Vp3DecodeContext *s, Vp3Fragment *fragment, int motion_y, int y)
Wait for the reference frame of the current fragment.
uint32_t coded_ac_scale_factor[64]
static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst, ptrdiff_t dst_pitch, int dst_height)
Convert and output the current plane.
static const uint8_t vp4_block_pattern_vlc[2][14][2]
int avpriv_split_xiph_headers(const uint8_t *extradata, int extradata_size, int first_header_size, const uint8_t *header_start[3], int header_len[3])
Split a single extradata buffer into the three headers that most Xiph codecs use.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const uint16_t vp4_ac_bias_2[16][32][2]
unsigned char * superblock_coding
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
#define COMPATIBLE_FRAME(x)
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
int coded_width
Bitstream width / height, may be different from width/height e.g.
@ AV_PICTURE_TYPE_P
Predicted.
static const uint16_t vp4_ac_bias_1[16][32][2]
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static const struct @180 eob_run_table[7]
#define avpriv_request_sample(...)
static int get_eob_run(GetBitContext *gb, int token)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static const uint8_t vp31_filter_limit_values[64]
This structure stores compressed data.
static int read_huffman_tree(AVCodecContext *avctx, GetBitContext *gb)
static av_cold int vp3_decode_init(AVCodecContext *avctx)
uint8_t base_matrix[384][64]
static const uint8_t vp31_dc_scale_factor[64]
int width
picture width / height.
int * kf_coded_fragment_list
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb)
uint16_t qr_base[2][3][64]
static av_cold int vp3_decode_end(AVCodecContext *avctx)
The exact code depends on how similar the blocks are and how related they are to the block
static const double coeff[2][5]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const uint8_t vp4_uv_dc_scale_factor[64]
#define MAXIMUM_LONG_BIT_RUN
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int8_t(*[2] motion_val)[2]
VP4Predictor * dc_pred_row
static const uint8_t coeff_get_bits[32]
int16_t * dct_tokens_base
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
int16_t qmat[3][2][3][64]
qmat[qpi][is_inter][plane]
static const uint16_t vp4_mv_vlc[2][7][63][2]
#define TOKEN_EOB(eob_run)
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have add an so the codec calls ff_thread_report set AVCodecInternal allocate_progress The frames must then be freed with ff_thread_release_buffer(). Otherwise leave it at zero and decode directly into the user-supplied frames. Call ff_thread_report_progress() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere