49 #define FRAGMENT_PIXELS 8 58 #define SB_NOT_CODED 0 59 #define SB_PARTIALLY_CODED 1 60 #define SB_FULLY_CODED 2 65 #define MAXIMUM_LONG_BIT_RUN 4129 67 #define MODE_INTER_NO_MV 0 69 #define MODE_INTER_PLUS_MV 2 70 #define MODE_INTER_LAST_MV 3 71 #define MODE_INTER_PRIOR_LAST 4 72 #define MODE_USING_GOLDEN 5 73 #define MODE_GOLDEN_MV 6 74 #define MODE_INTER_FOURMV 7 75 #define CODING_MODE_COUNT 8 120 { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 },
121 { 0, 2 }, { 0, 3 }, { 1, 3 }, { 1, 2 },
122 { 2, 2 }, { 2, 3 }, { 3, 3 }, { 3, 2 },
123 { 3, 1 }, { 2, 1 }, { 2, 0 }, { 3, 0 }
126 #define MIN_DEQUANT_VAL 2 168 int fragment_width[2];
169 int fragment_height[2];
172 int fragment_start[3];
177 int8_t (*motion_val[2])[2];
180 uint16_t coded_dc_scale_factor[64];
181 uint32_t coded_ac_scale_factor[64];
185 uint16_t qr_base[2][3][64];
204 int16_t *dct_tokens[3][64];
206 #define TOKEN_EOB(eob_run) ((eob_run) << 2) 207 #define TOKEN_ZERO_RUN(coeff, zero_run) (((coeff) << 9) + ((zero_run) << 2) + 1) 208 #define TOKEN_COEFF(coeff) (((coeff) << 2) + 2) 214 int num_coded_frags[3][64];
219 int *coded_fragment_list[3];
253 uint32_t huffman_table[80][32][2];
299 for (i = 0; i < 16; i++) {
324 int sb_x, sb_y, plane;
327 for (plane = 0; plane < 3; plane++) {
335 for (sb_y = 0; sb_y < sb_height; sb_y++)
336 for (sb_x = 0; sb_x < sb_width; sb_x++)
337 for (i = 0; i < 16; i++) {
339 y = 4 * sb_y + hilbert_offset[i][1];
341 if (x < frag_width && y < frag_height)
360 int i, plane, inter, qri, bmi, bmj, qistart;
362 for (inter = 0; inter < 2; inter++) {
363 for (plane = 0; plane < 3; plane++) {
365 for (qri = 0; qri < s->
qr_count[inter][plane]; qri++) {
366 sum += s->
qr_size[inter][plane][qri];
367 if (s->
qps[qpi] <= sum)
370 qistart = sum - s->
qr_size[inter][plane][qri];
371 bmi = s->
qr_base[inter][plane][qri];
372 bmj = s->
qr_base[inter][plane][qri + 1];
373 for (i = 0; i < 64; i++) {
376 s->
qr_size[inter][plane][qri]) /
377 (2 * s->
qr_size[inter][plane][qri]);
379 int qmin = 8 << (inter + !i);
380 int qscale = i ? ac_scale_factor : dc_scale_factor;
383 av_clip((qscale * coeff) / 100 * 4, qmin, 4096);
387 s->
qmat[
qpi][inter][plane][0] = s->
qmat[0][inter][plane][0];
406 assert(filter_limit < 128);
410 for (x = 0; x < filter_limit; x++) {
411 bounding_values[-x] = -x;
412 bounding_values[x] = x;
414 for (x = value = filter_limit; x < 128 && value; x++, value--) {
415 bounding_values[ x] = value;
416 bounding_values[-x] = -value;
419 bounding_values[128] = value;
420 bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202;
429 int superblock_starts[3] = {
433 int current_superblock = 0;
435 int num_partial_superblocks = 0;
438 int current_fragment;
448 while (current_superblock < s->superblock_count &&
get_bits_left(gb) > 0) {
456 if (current_run == 34)
461 "Invalid partially coded superblock run length\n");
467 current_superblock += current_run;
469 num_partial_superblocks += current_run;
474 if (num_partial_superblocks < s->superblock_count) {
475 int superblocks_decoded = 0;
477 current_superblock = 0;
481 while (superblocks_decoded < s->superblock_count - num_partial_superblocks &&
490 if (current_run == 34)
493 for (j = 0; j < current_run; current_superblock++) {
496 "Invalid fully coded superblock run length\n");
506 superblocks_decoded += current_run;
512 if (num_partial_superblocks) {
526 for (plane = 0; plane < 3; plane++) {
527 int sb_start = superblock_starts[plane];
530 int num_coded_frags = 0;
532 for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
534 for (j = 0; j < 16; j++) {
537 if (current_fragment != -1) {
543 if (current_run-- == 0) {
566 for (i = 0; i < 64; i++)
581 int i, j, k, sb_x, sb_y;
583 int current_macroblock;
584 int current_fragment;
599 for (i = 0; i < 8; i++)
601 for (i = 0; i < 8; i++)
602 custom_mode_alphabet[
get_bits(gb, 3)] = i;
603 alphabet = custom_mode_alphabet;
614 for (j = 0; j < 4; j++) {
615 int mb_x = 2 * sb_x + (j >> 1);
616 int mb_y = 2 * sb_y + (((j >> 1) + j) & 1);
623 #define BLOCK_X (2 * mb_x + (k & 1)) 624 #define BLOCK_Y (2 * mb_y + (k >> 1)) 628 for (k = 0; k < 4; k++) {
646 for (k = 0; k < 4; k++) {
652 #define SET_CHROMA_MODES \ 653 if (frag[s->fragment_start[1]].coding_method != MODE_COPY) \ 654 frag[s->fragment_start[1]].coding_method = coding_mode; \ 655 if (frag[s->fragment_start[2]].coding_method != MODE_COPY) \ 656 frag[s->fragment_start[2]].coding_method = coding_mode; 665 for (k = 0; k < 2; k++) {
670 for (k = 0; k < 4; k++) {
690 int j, k, sb_x, sb_y;
694 int last_motion_x = 0;
695 int last_motion_y = 0;
696 int prior_last_motion_x = 0;
697 int prior_last_motion_y = 0;
698 int current_macroblock;
699 int current_fragment;
715 for (j = 0; j < 4; j++) {
716 int mb_x = 2 * sb_x + (j >> 1);
717 int mb_y = 2 * sb_y + (((j >> 1) + j) & 1);
729 if (coding_mode == 0) {
739 prior_last_motion_x = last_motion_x;
740 prior_last_motion_y = last_motion_y;
741 last_motion_x = motion_x[0];
742 last_motion_y = motion_y[0];
748 prior_last_motion_x = last_motion_x;
749 prior_last_motion_y = last_motion_y;
753 for (k = 0; k < 4; k++) {
756 if (coding_mode == 0) {
763 last_motion_x = motion_x[k];
764 last_motion_y = motion_y[k];
774 motion_x[0] = last_motion_x;
775 motion_y[0] = last_motion_y;
784 motion_x[0] = prior_last_motion_x;
785 motion_y[0] = prior_last_motion_y;
788 prior_last_motion_x = last_motion_x;
789 prior_last_motion_y = last_motion_y;
790 last_motion_x = motion_x[0];
791 last_motion_y = motion_y[0];
804 for (k = 0; k < 4; k++) {
808 s->
motion_val[0][current_fragment][0] = motion_x[k];
809 s->
motion_val[0][current_fragment][1] = motion_y[k];
811 s->
motion_val[0][current_fragment][0] = motion_x[0];
812 s->
motion_val[0][current_fragment][1] = motion_y[0];
818 motion_x[0] =
RSHIFT(motion_x[0] + motion_x[1] +
819 motion_x[2] + motion_x[3], 2);
820 motion_y[0] =
RSHIFT(motion_y[0] + motion_y[1] +
821 motion_y[2] + motion_y[3], 2);
823 motion_x[0] = (motion_x[0] >> 1) | (motion_x[0] & 1);
824 motion_y[0] = (motion_y[0] >> 1) | (motion_y[0] & 1);
830 motion_x[0] =
RSHIFT(motion_x[0] + motion_x[1], 1);
831 motion_y[0] =
RSHIFT(motion_y[0] + motion_y[1], 1);
832 motion_x[1] =
RSHIFT(motion_x[2] + motion_x[3], 1);
833 motion_y[1] =
RSHIFT(motion_y[2] + motion_y[3], 1);
835 motion_x[1] = motion_x[0];
836 motion_y[1] = motion_y[0];
838 motion_x[0] = (motion_x[0] >> 1) | (motion_x[0] & 1);
839 motion_x[1] = (motion_x[1] >> 1) | (motion_x[1] & 1);
842 for (k = 0; k < 2; k++) {
848 for (k = 0; k < 4; k++) {
868 int qpi, i, j, bit, run_length, blocks_decoded, num_blocks_at_qpi;
871 for (qpi = 0; qpi < s->
nqps - 1 && num_blocks > 0; qpi++) {
872 i = blocks_decoded = num_blocks_at_qpi = 0;
884 if (run_length == 34)
886 blocks_decoded += run_length;
889 num_blocks_at_qpi += run_length;
891 for (j = 0; j < run_length; i++) {
900 }
while (blocks_decoded < num_blocks &&
get_bits_left(gb) > 0);
902 num_blocks -= num_blocks_at_qpi;
921 VLC *table,
int coeff_index,
933 int16_t *dct_tokens = s->
dct_tokens[plane][coeff_index];
942 "Invalid number of coefficients at level %d\n", coeff_index);
944 if (eob_run > num_coeffs) {
946 blocks_ended = num_coeffs;
947 eob_run -= num_coeffs;
950 blocks_ended = eob_run;
956 dct_tokens[j++] = blocks_ended << 2;
960 token =
get_vlc2(gb, vlc_table, 11, 3);
962 if ((
unsigned) token <= 6
U) {
969 if (eob_run > num_coeffs - coeff_i) {
970 dct_tokens[j++] =
TOKEN_EOB(num_coeffs - coeff_i);
971 blocks_ended += num_coeffs - coeff_i;
972 eob_run -= num_coeffs - coeff_i;
973 coeff_i = num_coeffs;
976 blocks_ended += eob_run;
980 }
else if (token >= 0) {
983 bits_to_get =
get_bits(gb, bits_to_get);
998 all_fragments[coded_fragment_list[coeff_i]].
dc = coeff;
1003 if (coeff_index + zero_run > 64) {
1005 "Invalid zero run of %d with %d coeffs left\n",
1006 zero_run, 64 - coeff_index);
1007 zero_run = 64 - coeff_index;
1012 for (i = coeff_index + 1; i <= coeff_index + zero_run; i++)
1027 for (i = coeff_index + 1; i < 64; i++)
1032 s->
dct_tokens[plane + 1][coeff_index] = dct_tokens + j;
1033 else if (coeff_index < 63)
1034 s->
dct_tokens[0][coeff_index + 1] = dct_tokens + j;
1042 int fragment_height);
1054 int residual_eob_run = 0;
1066 0, residual_eob_run);
1067 if (residual_eob_run < 0)
1068 return residual_eob_run;
1075 1, residual_eob_run);
1076 if (residual_eob_run < 0)
1077 return residual_eob_run;
1079 2, residual_eob_run);
1080 if (residual_eob_run < 0)
1081 return residual_eob_run;
1096 for (i = 1; i <= 5; i++) {
1097 y_tables[i] = &s->
ac_vlc_1[ac_y_table];
1098 c_tables[i] = &s->
ac_vlc_1[ac_c_table];
1100 for (i = 6; i <= 14; i++) {
1101 y_tables[i] = &s->
ac_vlc_2[ac_y_table];
1102 c_tables[i] = &s->
ac_vlc_2[ac_c_table];
1104 for (i = 15; i <= 27; i++) {
1105 y_tables[i] = &s->
ac_vlc_3[ac_y_table];
1106 c_tables[i] = &s->
ac_vlc_3[ac_c_table];
1108 for (i = 28; i <= 63; i++) {
1109 y_tables[i] = &s->
ac_vlc_4[ac_y_table];
1110 c_tables[i] = &s->
ac_vlc_4[ac_c_table];
1114 for (i = 1; i <= 63; i++) {
1115 residual_eob_run =
unpack_vlcs(s, gb, y_tables[i], i,
1116 0, residual_eob_run);
1117 if (residual_eob_run < 0)
1118 return residual_eob_run;
1120 residual_eob_run =
unpack_vlcs(s, gb, c_tables[i], i,
1121 1, residual_eob_run);
1122 if (residual_eob_run < 0)
1123 return residual_eob_run;
1124 residual_eob_run =
unpack_vlcs(s, gb, c_tables[i], i,
1125 2, residual_eob_run);
1126 if (residual_eob_run < 0)
1127 return residual_eob_run;
1138 #define COMPATIBLE_FRAME(x) \ 1139 (compatible_frame[s->all_fragments[x].coding_method] == current_frame_type) 1140 #define DC_COEFF(u) s->all_fragments[u].dc 1145 int fragment_height)
1153 int i = first_fragment;
1158 int vl, vul, vu, vur;
1170 static const int predictor_transform[16][4] = {
1184 { -104, 116, 0, 116 },
1186 { -104, 116, 0, 116 }
1195 static const unsigned char compatible_frame[9] = {
1206 int current_frame_type;
1222 for (y = 0; y < fragment_height; y++) {
1224 for (x = 0; x < fragment_width; x++, i++) {
1228 current_frame_type =
1239 u = i - fragment_width;
1244 ul = i - fragment_width - 1;
1249 if (x + 1 < fragment_width) {
1250 ur = i - fragment_width + 1;
1257 if (transform == 0) {
1260 predicted_dc = last_dc[current_frame_type];
1264 (predictor_transform[
transform][0] * vul) +
1265 (predictor_transform[transform][1] * vu) +
1266 (predictor_transform[
transform][2] * vur) +
1267 (predictor_transform[transform][3] * vl);
1269 predicted_dc /= 128;
1273 if ((transform == 15) || (transform == 13)) {
1274 if (
FFABS(predicted_dc - vu) > 128)
1276 else if (
FFABS(predicted_dc - vl) > 128)
1278 else if (
FFABS(predicted_dc - vul) > 128)
1286 last_dc[current_frame_type] =
DC_COEFF(i);
1293 int ystart,
int yend)
1307 for (y = ystart; y < yend; y++) {
1308 for (x = 0; x <
width; x++) {
1318 stride, bounding_values);
1325 stride, bounding_values);
1331 if ((x < width - 1) &&
1334 plane_data + 8 * x + 8,
1335 stride, bounding_values);
1341 if ((y < height - 1) &&
1344 plane_data + 8 * x + 8 * stride,
1345 stride, bounding_values);
1351 plane_data += 8 *
stride;
1360 int plane,
int inter, int16_t
block[64])
1362 int16_t *dequantizer = s->
qmat[frag->
qpi][inter][plane];
1368 switch (token & 3) {
1377 i += (token >> 2) & 0x7f;
1382 block[perm[i]] = (token >> 9) * dequantizer[perm[i]];
1386 block[perm[i]] = (token >> 2) * dequantizer[perm[i]];
1397 block[0] = frag->
dc * s->
qmat[0][inter][plane][0];
1416 y_flipped == s->
height ? INT_MAX
1447 int motion_y,
int y)
1451 int border = motion_y & 1;
1459 ref_row = y + (motion_y >> 1);
1460 ref_row =
FFMAX(
FFABS(ref_row), ref_row + 8 + border);
1471 int x, y, i, j, fragment;
1473 int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef;
1474 int motion_halfpel_index;
1476 int plane, first_pixel;
1481 for (plane = 0; plane < 3; plane++) {
1491 int8_t(*motion_val)[2] = s->
motion_val[!!plane];
1511 for (; sb_y < slice_height; sb_y++) {
1513 for (sb_x = 0; sb_x < slice_width; sb_x++) {
1515 for (j = 0; j < 16; j++) {
1517 y = 4 * sb_y + hilbert_offset[j][1];
1518 fragment = y * fragment_width + x;
1520 i = fragment_start + fragment;
1523 if (x >= fragment_width || y >= fragment_height)
1526 first_pixel = 8 * y * stride + 8 * x;
1531 motion_val[fragment][1],
1538 motion_source = golden_plane;
1540 motion_source = last_plane;
1542 motion_source += first_pixel;
1543 motion_halfpel_index = 0;
1550 motion_x = motion_val[fragment][0];
1551 motion_y = motion_val[fragment][1];
1553 src_x = (motion_x >> 1) + 8 * x;
1554 src_y = (motion_y >> 1) + 8 * y;
1556 motion_halfpel_index = motion_x & 0x01;
1557 motion_source += (motion_x >> 1);
1559 motion_halfpel_index |= (motion_y & 0x01) << 1;
1560 motion_source += ((motion_y >> 1) * stride);
1562 if (src_x < 0 || src_y < 0 ||
1563 src_x + 9 >= plane_width ||
1564 src_y + 9 >= plane_height) {
1574 motion_source = temp;
1585 if (motion_halfpel_index != 3) {
1587 output_plane + first_pixel,
1588 motion_source,
stride, 8);
1592 int d = (motion_x ^ motion_y) >> 31;
1595 motion_source + stride + 1 + d,
1628 output_plane + first_pixel,
1629 last_plane + first_pixel,
1638 FFMIN(4 * sb_y + 3, fragment_height - 1));
1658 int y_fragment_count, c_fragment_count;
1709 int i, inter, plane, ret;
1712 int y_fragment_count, c_fragment_count;
1735 for (i = 0; i < 64; i++) {
1736 #define TRANSPOSE(x) (x >> 3) | ((x & 7) << 3) 1744 for (i = 0; i < 3; i++)
1782 for (i = 0; i < 64; i++) {
1791 for (inter = 0; inter < 2; inter++) {
1792 for (plane = 0; plane < 3; plane++) {
1794 s->
qr_size[inter][plane][0] = 63;
1796 s->
qr_base[inter][plane][1] = 2 * inter + (!!plane) * !inter;
1801 for (i = 0; i < 16; i++) {
1828 for (i = 0; i < 16; i++) {
1909 if (src->
f->
data[0])
1927 int qps_changed = 0, i, err;
1929 #define copy_fields(to, from, start_field, end_field) \ 1930 memcpy(&to->start_field, &from->start_field, \ 1931 (char *) &to->end_field - (char *) &to->start_field) 1933 if (!s1->current_frame.f->data[0] ||
1934 s->
width != s1->width || s->
height != s1->height) {
1943 int y_fragment_count, c_fragment_count;
1951 y_fragment_count *
sizeof(*s->
motion_val[0]));
1953 c_fragment_count *
sizeof(*s->
motion_val[1]));
1963 for (i = 0; i < 3; i++) {
1964 if (s->
qps[i] != s1->qps[1]) {
1966 memcpy(&s->
qmat[i], &s1->qmat[i],
sizeof(s->
qmat[i]));
1970 if (s->
qps[0] != s1->qps[0])
1983 void *
data,
int *got_frame,
1987 int buf_size = avpkt->
size;
1996 "Header packet passed to frame decoder, skipping\n");
2003 for (i = 0; i < 3; i++)
2010 for (i = s->
nqps; i < 3; i++)
2015 s->
keyframe ?
"key" :
"", avctx->frame_number + 1, s->
qps[0]);
2024 for (i = 0; i < s->
nqps; i++)
2049 if (avctx->frame_number == 0)
2051 "VP version: %d\n", s->
version);
2057 "Warning, unsupported keyframe coding type?!\n");
2063 "vp3: first frame not a keyframe\n");
2103 for (i = 0; i < 3; i++) {
2116 for (i = 0; i < 3; i++) {
2125 for (i = 0; i < 3; i++) {
2129 dst->
data[i] += off;
2161 ff_dlog(avctx,
"hti %d hbits %x token %d entry : %d size %d\n",
2201 #if CONFIG_THEORA_DECODER 2209 int visible_width, visible_height, colorspace;
2210 uint8_t offset_x = 0, offset_y = 0;
2219 if (s->
theora < 0x030200) {
2222 "Old (<alpha3) Theora bitstream, flipped image\n");
2230 if (s->
theora >= 0x030200) {
2240 visible_width + offset_x > s->
width ||
2241 visible_height + offset_y > s->
height) {
2243 "Invalid frame dimensions - w:%d h:%d x:%d y:%d (%dx%d).\n",
2244 visible_width, visible_height, offset_x, offset_y,
2251 if (fps.
num && fps.
den) {
2252 if (fps.
num < 0 || fps.
den < 0) {
2257 fps.
den, fps.
num, 1 << 30);
2262 if (aspect.
num && aspect.
den) {
2265 aspect.
num, aspect.
den, 1 << 30);
2269 if (s->
theora < 0x030200)
2276 if (s->
theora >= 0x030200) {
2286 (visible_width != s->
width || visible_height != s->
height)) {
2287 avctx->
width = visible_width;
2288 avctx->
height = visible_height;
2297 "chroma samples to preserve alignment.\n",
2302 if (colorspace == 1)
2304 else if (colorspace == 2)
2307 if (colorspace == 1 || colorspace == 2) {
2318 int i, n, matrices, inter, plane;
2320 if (s->
theora >= 0x030200) {
2324 for (i = 0; i < 64; i++)
2328 if (s->
theora >= 0x030200)
2333 for (i = 0; i < 64; i++)
2336 if (s->
theora >= 0x030200)
2341 for (i = 0; i < 64; i++)
2344 if (s->
theora >= 0x030200)
2349 if (matrices > 384) {
2354 for (n = 0; n < matrices; n++)
2355 for (i = 0; i < 64; i++)
2358 for (inter = 0; inter <= 1; inter++) {
2359 for (plane = 0; plane <= 2; plane++) {
2361 if (inter || plane > 0)
2369 qtj = (3 * inter + plane - 1) / 3;
2370 plj = (plane + 2) % 3;
2383 if (i >= matrices) {
2385 "invalid base matrix index\n");
2388 s->
qr_base[inter][plane][qri] = i;
2392 s->
qr_size[inter][plane][qri++] = i;
2406 for (s->
hti = 0; s->
hti < 80; s->
hti++) {
2441 42, header_start, header_len) < 0) {
2446 for (i = 0; i < 3; i++) {
2447 if (header_len[i] <= 0)
2453 if (!(ptype & 0x80)) {
2463 theora_decode_header(avctx, &gb);
2470 if (theora_decode_tables(avctx, &gb))
2475 "Unknown Theora config packet: %d\n", ptype & ~0x80);
2480 "%d bits left in packet %X\n",
2482 if (s->
theora < 0x030200)
2495 .
init = theora_decode_init,
static const int16_t vp31_intra_y_dequant[64]
uint8_t idct_scantable[64]
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
discard all frames except keyframes
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_NUM_DATA_POINTERS
int16_t qmat[3][2][3][64]
qmat[qpi][is_inter][plane]
static int init_block_mapping(Vp3DecodeContext *s)
This structure describes decoded (raw) audio or video data.
#define TOKEN_EOB(eob_run)
static void render_slice(Vp3DecodeContext *s, int slice)
int bounding_values_array[256+2]
int coded_width
Bitstream width / height, may be different from width/height e.g.
void(* put_no_rnd_pixels_l2)(uint8_t *dst, const uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h)
Copy 8xH pixels from source to destination buffer using a bilinear filter with no rounding (i...
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint16_t qr_base[2][3][64]
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.
static void skip_bits_long(GetBitContext *s, int n)
static const uint16_t fragment_run_length_vlc_table[30][2]
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
#define MODE_INTER_PLUS_MV
static av_cold int init_frames(Vp3DecodeContext *s)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
#define DECLARE_ALIGNED(n, t, v)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)
void(* v_loop_filter)(uint8_t *src, ptrdiff_t stride, int *bounding_values)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_cold int vp3_decode_init(AVCodecContext *avctx)
static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
static void reverse_dc_prediction(Vp3DecodeContext *s, int first_fragment, int fragment_width, int fragment_height)
static av_cold int vp3_decode_end(AVCodecContext *avctx)
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
int * superblock_fragments
VLC superblock_run_length_vlc
static const uint32_t vp31_ac_scale_factor[64]
#define MAXIMUM_LONG_BIT_RUN
static const int motion_vector_table[63]
static const uint16_t ac_bias_3[16][32][2]
void(* draw_horiz_band)(struct AVCodecContext *s, const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], int y, int type, int height)
If non NULL, 'draw_horiz_band' is called by the libavcodec decoder to draw a horizontal band...
static const uint16_t dc_bias[16][32][2]
Vp3Fragment * all_fragments
static void init_loop_filter(Vp3DecodeContext *s)
#define COMPATIBLE_FRAME(x)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define TOKEN_ZERO_RUN(coeff, zero_run)
#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_FLAG_UNALIGNED
Allow decoders to produce frames with data planes that are not aligned to CPU requirements (e...
Multithreading support functions.
uint8_t idct_permutation[64]
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static void init_dequantizer(Vp3DecodeContext *s, int qpi)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static void vp3_decode_flush(AVCodecContext *avctx)
uint8_t filter_limit_values[64]
static int get_bits_count(const GetBitContext *s)
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
bitstream reader API header.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
static const uint8_t mode_code_vlc_table[8][2]
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
static const int16_t vp31_inter_dequant[64]
static const uint16_t ac_bias_1[16][32][2]
static int ref_frames(Vp3DecodeContext *dst, Vp3DecodeContext *src)
static int get_bits_left(GetBitContext *gb)
static int vp3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static const uint8_t motion_vector_vlc_table[63][2]
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_CODEC_FLAG2_IGNORE_CROP
Discard cropping information from SPS.
static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst, int dst_pitch, int dst_height)
Convert and output the current plane.
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define CODING_MODE_COUNT
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.
static const int zero_run_base[32]
void(* idct_add)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int active_thread_type
Which multithreading methods are in use by the codec.
static const int8_t fixed_motion_vector_table[64]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int flags
AV_CODEC_FLAG_*.
void(* h_loop_filter)(uint8_t *src, ptrdiff_t stride, int *bounding_values)
const char * name
Name of the codec implementation.
static const int ModeAlphabet[6][CODING_MODE_COUNT]
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
static const int16_t vp31_intra_c_dequant[64]
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
static const int coeff_get_bits[32]
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static const int16_t *const coeff_tables[32]
unsigned char * macroblock_coding
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
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...
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
enum AVPictureType pict_type
Picture type of the frame.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define FF_THREAD_FRAME
Decode more than one frame at once.
VLC fragment_run_length_vlc
int width
picture width / height.
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
#define SB_PARTIALLY_CODED
static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb, VLC *table, int coeff_index, int plane, int eob_run)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
uint8_t * edge_emu_buffer
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static const uint16_t ac_bias_2[16][32][2]
static const uint8_t hilbert_offset[16][2]
int total_num_coded_frags
void(* idct_dc_add)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
if(ac->has_optimized_func)
static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int yend)
static const int8_t transform[32][32]
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
static const uint16_t ac_bias_0[16][32][2]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int16_t * dct_tokens[3][64]
This is a list of all tokens in bitstream order.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
ThreadFrame current_frame
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
uint8_t qr_size[2][3][64]
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
static av_cold int allocate_tables(AVCodecContext *avctx)
Allocate tables for per-frame data in Vp3DecodeContext.
static unsigned int get_bits1(GetBitContext *s)
op_pixels_func put_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
static void skip_bits(GetBitContext *s, int n)
enum AVColorSpace colorspace
YUV colorspace type.
rational number numerator/denominator
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
const uint8_t ff_zigzag_direct[64]
int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size, int first_header_size, uint8_t *header_start[3], int header_len[3])
Split a single extradata buffer into the three headers that most Xiph codecs use. ...
int num_coded_frags[3][64]
number of blocks that contain DCT coefficients at the given level or higher
#define TOKEN_COEFF(coeff)
int allocate_progress
Whether to allocate progress for frame threading.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int read_huffman_tree(AVCodecContext *avctx, GetBitContext *gb)
static int update_frames(AVCodecContext *avctx)
Release and shuffle frames after decode finishes.
static const uint16_t superblock_run_length_vlc_table[34][2]
#define MODE_USING_GOLDEN
uint32_t huffman_table[80][32][2]
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define MODE_INTER_FOURMV
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define copy_fields(to, from, start_field, end_field)
int * coded_fragment_list[3]
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
unsigned char * superblock_coding
common internal api header.
int16_t * dct_tokens_base
static int ref_frame(Vp3DecodeContext *s, ThreadFrame *dst, ThreadFrame *src)
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
static const int eob_run_get_bits[7]
static int vp3_init_thread_copy(AVCodecContext *avctx)
static const int16_t vp31_dc_scale_factor[64]
uint16_t coded_dc_scale_factor[64]
static av_cold int init(AVCodecParserContext *s)
Core video DSP helper functions.
uint8_t base_matrix[384][64]
static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb)
static void await_reference_row(Vp3DecodeContext *s, Vp3Fragment *fragment, int motion_y, int y)
Wait for the reference frame of the current fragment.
struct AVCodecInternal * internal
Private context used for internal data.
VLC_TYPE(* table)[2]
code, bits
int flags2
AV_CODEC_FLAG2_*.
#define MODE_INTER_PRIOR_LAST
static const int eob_run_base[7]
static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define MODE_INTER_LAST_MV
void(* idct_put)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
static const int zero_run_get_bits[32]
av_cold void ff_vp3dsp_init(VP3DSPContext *c, int flags)
static const uint8_t vp31_filter_limit_values[64]
#define MKTAG(a, b, c, d)
AVPixelFormat
Pixel format.
This structure stores compressed data.
static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
called when all pixels up to row y are complete
void ff_free_vlc(VLC *vlc)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
uint32_t coded_ac_scale_factor[64]
int8_t(*[2] motion_val)[2]