46 #define FRAGMENT_PIXELS 8
55 #define SB_NOT_CODED 0
56 #define SB_PARTIALLY_CODED 1
57 #define SB_FULLY_CODED 2
62 #define MAXIMUM_LONG_BIT_RUN 4129
64 #define MODE_INTER_NO_MV 0
66 #define MODE_INTER_PLUS_MV 2
67 #define MODE_INTER_LAST_MV 3
68 #define MODE_INTER_PRIOR_LAST 4
69 #define MODE_USING_GOLDEN 5
70 #define MODE_GOLDEN_MV 6
71 #define MODE_INTER_FOURMV 7
72 #define CODING_MODE_COUNT 8
119 {0,0}, {1,0}, {1,1}, {0,1},
120 {0,2}, {0,3}, {1,3}, {1,2},
121 {2,2}, {2,3}, {3,3}, {3,2},
122 {3,1}, {2,1}, {2,0}, {3,0}
125 #define MIN_DEQUANT_VAL 2
200 #define TOKEN_EOB(eob_run) ((eob_run) << 2)
201 #define TOKEN_ZERO_RUN(coeff, zero_run) (((coeff) << 9) + ((zero_run) << 2) + 1)
202 #define TOKEN_COEFF(coeff) (((coeff) << 2) + 2)
294 for (i = 0; i < 16; i++) {
322 int sb_x, sb_y, plane;
325 for (plane = 0; plane < 3; plane++) {
331 for (sb_y = 0; sb_y < sb_height; sb_y++)
332 for (sb_x = 0; sb_x < sb_width; sb_x++)
333 for (i = 0; i < 16; i++) {
335 y = 4*sb_y + hilbert_offset[i][1];
337 if (x < frag_width && y < frag_height)
355 int i, plane, inter, qri, bmi, bmj, qistart;
357 for(inter=0; inter<2; inter++){
358 for(plane=0; plane<3; plane++){
360 for(qri=0; qri<s->
qr_count[inter][plane]; qri++){
361 sum+= s->
qr_size[inter][plane][qri];
362 if(s->
qps[qpi] <= sum)
365 qistart= sum - s->
qr_size[inter][plane][qri];
366 bmi= s->
qr_base[inter][plane][qri ];
367 bmj= s->
qr_base[inter][plane][qri+1];
371 + s->
qr_size[inter][plane][qri])
372 / (2*s->
qr_size[inter][plane][qri]);
374 int qmin= 8<<(inter + !i);
375 int qscale= i ? ac_scale_factor : dc_scale_factor;
380 s->
qmat[qpi][inter][plane][0] = s->
qmat[0][inter][plane][0];
402 for (x = 0; x < filter_limit; x++) {
403 bounding_values[-x] = -x;
404 bounding_values[x] = x;
406 for (x = value = filter_limit; x < 128 && value; x++, value--) {
407 bounding_values[ x] = value;
408 bounding_values[-x] = -value;
411 bounding_values[128] = value;
412 bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202;
423 int current_superblock = 0;
425 int num_partial_superblocks = 0;
428 int current_fragment;
440 while (current_superblock < s->superblock_count &&
get_bits_left(gb) > 0) {
448 if (current_run == 34)
458 current_superblock += current_run;
460 num_partial_superblocks += current_run;
465 if (num_partial_superblocks < s->superblock_count) {
466 int superblocks_decoded = 0;
468 current_superblock = 0;
472 while (superblocks_decoded < s->superblock_count - num_partial_superblocks
482 if (current_run == 34)
485 for (j = 0; j < current_run; current_superblock++) {
497 superblocks_decoded += current_run;
503 if (num_partial_superblocks) {
518 for (plane = 0; plane < 3; plane++) {
519 int sb_start = superblock_starts[plane];
521 int num_coded_frags = 0;
523 for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
526 for (j = 0; j < 16; j++) {
530 if (current_fragment != -1) {
537 if (current_run-- == 0) {
561 for (i = 0; i < 64; i++)
575 int i, j, k, sb_x, sb_y;
577 int current_macroblock;
578 int current_fragment;
595 for (i = 0; i < 8; i++)
597 for (i = 0; i < 8; i++)
598 custom_mode_alphabet[
get_bits(gb, 3)] = i;
599 alphabet = custom_mode_alphabet;
610 for (j = 0; j < 4; j++) {
611 int mb_x = 2*sb_x + (j>>1);
612 int mb_y = 2*sb_y + (((j>>1)+j)&1);
618 #define BLOCK_X (2*mb_x + (k&1))
619 #define BLOCK_Y (2*mb_y + (k>>1))
622 for (k = 0; k < 4; k++) {
636 coding_mode = alphabet
640 for (k = 0; k < 4; k++) {
646 #define SET_CHROMA_MODES \
647 if (frag[s->fragment_start[1]].coding_method != MODE_COPY) \
648 frag[s->fragment_start[1]].coding_method = coding_mode;\
649 if (frag[s->fragment_start[2]].coding_method != MODE_COPY) \
650 frag[s->fragment_start[2]].coding_method = coding_mode;
657 for (k = 0; k < 2; k++) {
662 for (k = 0; k < 4; k++) {
681 int j, k, sb_x, sb_y;
685 int last_motion_x = 0;
686 int last_motion_y = 0;
687 int prior_last_motion_x = 0;
688 int prior_last_motion_y = 0;
689 int current_macroblock;
690 int current_fragment;
706 for (j = 0; j < 4; j++) {
707 int mb_x = 2*sb_x + (j>>1);
708 int mb_y = 2*sb_y + (((j>>1)+j)&1);
720 if (coding_mode == 0) {
731 prior_last_motion_x = last_motion_x;
732 prior_last_motion_y = last_motion_y;
733 last_motion_x = motion_x[0];
734 last_motion_y = motion_y[0];
740 prior_last_motion_x = last_motion_x;
741 prior_last_motion_y = last_motion_y;
745 for (k = 0; k < 4; k++) {
748 if (coding_mode == 0) {
755 last_motion_x = motion_x[k];
756 last_motion_y = motion_y[k];
766 motion_x[0] = last_motion_x;
767 motion_y[0] = last_motion_y;
776 motion_x[0] = prior_last_motion_x;
777 motion_y[0] = prior_last_motion_y;
780 prior_last_motion_x = last_motion_x;
781 prior_last_motion_y = last_motion_y;
782 last_motion_x = motion_x[0];
783 last_motion_y = motion_y[0];
796 for (k = 0; k < 4; k++) {
800 s->
motion_val[0][current_fragment][0] = motion_x[k];
801 s->
motion_val[0][current_fragment][1] = motion_y[k];
803 s->
motion_val[0][current_fragment][0] = motion_x[0];
804 s->
motion_val[0][current_fragment][1] = motion_y[0];
810 motion_x[0] =
RSHIFT(motion_x[0] + motion_x[1] + motion_x[2] + motion_x[3], 2);
811 motion_y[0] =
RSHIFT(motion_y[0] + motion_y[1] + motion_y[2] + motion_y[3], 2);
813 motion_x[0] = (motion_x[0]>>1) | (motion_x[0]&1);
814 motion_y[0] = (motion_y[0]>>1) | (motion_y[0]&1);
820 motion_x[0] =
RSHIFT(motion_x[0] + motion_x[1], 1);
821 motion_y[0] =
RSHIFT(motion_y[0] + motion_y[1], 1);
822 motion_x[1] =
RSHIFT(motion_x[2] + motion_x[3], 1);
823 motion_y[1] =
RSHIFT(motion_y[2] + motion_y[3], 1);
825 motion_x[1] = motion_x[0];
826 motion_y[1] = motion_y[0];
828 motion_x[0] = (motion_x[0]>>1) | (motion_x[0]&1);
829 motion_x[1] = (motion_x[1]>>1) | (motion_x[1]&1);
832 for (k = 0; k < 2; k++) {
838 for (k = 0; k < 4; k++) {
858 int qpi, i, j, bit, run_length, blocks_decoded, num_blocks_at_qpi;
861 for (qpi = 0; qpi < s->
nqps-1 && num_blocks > 0; qpi++) {
862 i = blocks_decoded = num_blocks_at_qpi = 0;
874 if (run_length == 34)
876 blocks_decoded += run_length;
879 num_blocks_at_qpi += run_length;
881 for (j = 0; j < run_length; i++) {
890 }
while (blocks_decoded < num_blocks &&
get_bits_left(gb) > 0);
892 num_blocks -= num_blocks_at_qpi;
911 VLC *table,
int coeff_index,
923 int16_t *dct_tokens = s->
dct_tokens[plane][coeff_index];
933 if (eob_run > num_coeffs) {
934 coeff_i = blocks_ended = num_coeffs;
935 eob_run -= num_coeffs;
937 coeff_i = blocks_ended = eob_run;
943 dct_tokens[j++] = blocks_ended << 2;
947 token =
get_vlc2(gb, vlc_table, 11, 3);
949 if ((
unsigned) token <= 6
U) {
956 if (eob_run > num_coeffs - coeff_i) {
957 dct_tokens[j++] =
TOKEN_EOB(num_coeffs - coeff_i);
958 blocks_ended += num_coeffs - coeff_i;
959 eob_run -= num_coeffs - coeff_i;
960 coeff_i = num_coeffs;
963 blocks_ended += eob_run;
967 }
else if (token >= 0) {
970 bits_to_get =
get_bits(gb, bits_to_get);
985 all_fragments[coded_fragment_list[coeff_i]].
dc = coeff;
990 if (coeff_index + zero_run > 64) {
992 " %d coeffs left\n", zero_run, 64-coeff_index);
993 zero_run = 64 - coeff_index;
998 for (i = coeff_index+1; i <= coeff_index+zero_run; i++)
1003 "Invalid token %d\n", token);
1014 for (i = coeff_index+1; i < 64; i++)
1019 s->
dct_tokens[plane+1][coeff_index] = dct_tokens + j;
1020 else if (coeff_index < 63)
1021 s->
dct_tokens[0][coeff_index+1] = dct_tokens + j;
1029 int fragment_height);
1041 int residual_eob_run = 0;
1053 0, residual_eob_run);
1054 if (residual_eob_run < 0)
1055 return residual_eob_run;
1062 1, residual_eob_run);
1063 if (residual_eob_run < 0)
1064 return residual_eob_run;
1066 2, residual_eob_run);
1067 if (residual_eob_run < 0)
1068 return residual_eob_run;
1084 for (i = 1; i <= 5; i++) {
1085 y_tables[i] = &s->
ac_vlc_1[ac_y_table];
1086 c_tables[i] = &s->
ac_vlc_1[ac_c_table];
1088 for (i = 6; i <= 14; i++) {
1089 y_tables[i] = &s->
ac_vlc_2[ac_y_table];
1090 c_tables[i] = &s->
ac_vlc_2[ac_c_table];
1092 for (i = 15; i <= 27; i++) {
1093 y_tables[i] = &s->
ac_vlc_3[ac_y_table];
1094 c_tables[i] = &s->
ac_vlc_3[ac_c_table];
1096 for (i = 28; i <= 63; i++) {
1097 y_tables[i] = &s->
ac_vlc_4[ac_y_table];
1098 c_tables[i] = &s->
ac_vlc_4[ac_c_table];
1102 for (i = 1; i <= 63; i++) {
1103 residual_eob_run =
unpack_vlcs(s, gb, y_tables[i], i,
1104 0, residual_eob_run);
1105 if (residual_eob_run < 0)
1106 return residual_eob_run;
1108 residual_eob_run =
unpack_vlcs(s, gb, c_tables[i], i,
1109 1, residual_eob_run);
1110 if (residual_eob_run < 0)
1111 return residual_eob_run;
1112 residual_eob_run =
unpack_vlcs(s, gb, c_tables[i], i,
1113 2, residual_eob_run);
1114 if (residual_eob_run < 0)
1115 return residual_eob_run;
1126 #define COMPATIBLE_FRAME(x) \
1127 (compatible_frame[s->all_fragments[x].coding_method] == current_frame_type)
1128 #define DC_COEFF(u) s->all_fragments[u].dc
1133 int fragment_height)
1142 int i = first_fragment;
1147 int vl, vul, vu, vur;
1159 static const int predictor_transform[16][4] = {
1184 static const unsigned char compatible_frame[9] = {
1195 int current_frame_type;
1202 vul = vu = vur = vl = 0;
1203 last_dc[0] = last_dc[1] = last_dc[2] = 0;
1206 for (y = 0; y < fragment_height; y++) {
1209 for (x = 0; x < fragment_width; x++, i++) {
1214 current_frame_type =
1225 u= i-fragment_width;
1230 ul= i-fragment_width-1;
1235 if(x + 1 < fragment_width){
1236 ur= i-fragment_width+1;
1243 if (transform == 0) {
1247 predicted_dc = last_dc[current_frame_type];
1252 (predictor_transform[transform][0] * vul) +
1253 (predictor_transform[transform][1] * vu) +
1254 (predictor_transform[transform][2] * vur) +
1255 (predictor_transform[transform][3] * vl);
1257 predicted_dc /= 128;
1261 if ((transform == 15) || (transform == 13)) {
1262 if (
FFABS(predicted_dc - vu) > 128)
1264 else if (
FFABS(predicted_dc - vl) > 128)
1266 else if (
FFABS(predicted_dc - vul) > 128)
1274 last_dc[current_frame_type] =
DC_COEFF(i);
1293 for (y = ystart; y < yend; y++) {
1295 for (x = 0; x <
width; x++) {
1306 stride, bounding_values);
1313 stride, bounding_values);
1319 if ((x < width - 1) &&
1322 plane_data + 8*x + 8,
1323 stride, bounding_values);
1329 if ((y < height - 1) &&
1332 plane_data + 8*x + 8*stride,
1333 stride, bounding_values);
1350 int16_t *dequantizer = s->
qmat[frag->
qpi][inter][plane];
1356 switch (token & 3) {
1365 i += (token >> 2) & 0x7f;
1370 block[perm[i]] = (token >> 9) * dequantizer[perm[i]];
1374 block[perm[i]] = (token >> 2) * dequantizer[perm[i]];
1385 block[0] = frag->
dc * s->
qmat[0][inter][plane][0];
1436 int border = motion_y&1;
1444 ref_row = y + (motion_y>>1);
1445 ref_row =
FFMAX(
FFABS(ref_row), ref_row + 8 + border);
1456 int x, y, i, j, fragment;
1458 int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef;
1459 int motion_halfpel_index;
1460 uint8_t *motion_source;
1461 int plane, first_pixel;
1466 for (plane = 0; plane < 3; plane++) {
1468 uint8_t * last_plane = s-> last_frame.data [plane] + s->
data_offset[plane];
1469 uint8_t *golden_plane = s-> golden_frame.data [plane] + s->
data_offset[plane];
1473 int8_t (*motion_val)[2] = s->
motion_val[!!plane];
1489 for (; sb_y < slice_height; sb_y++) {
1492 for (sb_x = 0; sb_x < slice_width; sb_x++) {
1495 for (j = 0; j < 16; j++) {
1497 y = 4*sb_y + hilbert_offset[j][1];
1498 fragment = y*fragment_width + x;
1500 i = fragment_start + fragment;
1503 if (x >= fragment_width || y >= fragment_height)
1506 first_pixel = 8*y*stride + 8*x;
1515 motion_source= golden_plane;
1517 motion_source= last_plane;
1519 motion_source += first_pixel;
1520 motion_halfpel_index = 0;
1527 motion_x = motion_val[fragment][0];
1528 motion_y = motion_val[fragment][1];
1530 src_x= (motion_x>>1) + 8*x;
1531 src_y= (motion_y>>1) + 8*y;
1533 motion_halfpel_index = motion_x & 0x01;
1534 motion_source += (motion_x >> 1);
1536 motion_halfpel_index |= (motion_y & 0x01) << 1;
1537 motion_source += ((motion_y >> 1) * stride);
1539 if(src_x<0 || src_y<0 || src_x + 9 >= plane_width || src_y + 9 >= plane_height){
1541 if(stride<0) temp -= 8*
stride;
1543 s->
dsp.
emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, plane_width, plane_height);
1544 motion_source= temp;
1556 if(motion_halfpel_index != 3){
1558 output_plane + first_pixel,
1559 motion_source,
stride, 8);
1561 int d= (motion_x ^ motion_y)>>31;
1563 output_plane + first_pixel,
1565 motion_source + stride + 1 + d,
1582 output_plane + first_pixel,
1591 output_plane + first_pixel,
1602 output_plane + first_pixel,
1603 last_plane + first_pixel,
1631 int y_fragment_count, c_fragment_count;
1662 int i, inter, plane;
1665 int y_fragment_count, c_fragment_count;
1686 for (i = 0; i < 3; i++)
1724 for (i = 0; i < 64; i++) {
1733 for(inter=0; inter<2; inter++){
1734 for(plane=0; plane<3; plane++){
1736 s->
qr_size [inter][plane][0]= 63;
1738 s->
qr_base [inter][plane][1]= 2*inter + (!!plane)*!inter;
1743 for (i = 0; i < 16; i++) {
1772 for (i = 0; i < 16; i++) {
1821 for (i = 0; i < 3; i++) {
1860 int qps_changed = 0, i, err;
1862 #define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
1864 if (!
s1->current_frame.data[0]
1875 int y_fragment_count, c_fragment_count;
1890 for (i = 0; i < 3; i++) {
1891 if (s->
qps[i] !=
s1->qps[1]) {
1893 memcpy(&s->
qmat[i], &
s1->qmat[i],
sizeof(s->
qmat[i]));
1897 if (s->
qps[0] !=
s1->qps[0])
1911 void *
data,
int *data_size,
1914 const uint8_t *buf = avpkt->
data;
1915 int buf_size = avpkt->
size;
1931 for (i = 0; i < 3; i++)
1937 }
while(s->theora >= 0x030200 && s->nqps<3 &&
get_bits1(&gb));
1938 for (i = s->nqps; i < 3; i++)
1943 s->keyframe?
"key":
"", avctx->frame_number+1, s->qps[0]);
1945 s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
1948 if (s->qps[0] != s->last_qps[0])
1951 for (i = 0; i < s->nqps; i++)
1954 if (s->qps[i] != s->last_qps[i] || s->qps[0] != s->last_qps[0])
1960 s->current_frame.reference = 3;
1967 if (!s->edge_emu_buffer)
1968 s->edge_emu_buffer =
av_malloc(9*
FFABS(s->current_frame.linesize[0]));
1978 if (avctx->frame_number == 0)
1982 if (s->version || s->theora)
1989 if (!s->golden_frame.data[0]) {
1992 s->golden_frame.reference = 3;
1998 s->last_frame = s->golden_frame;
2004 memset(s->all_fragments, 0, s->fragment_count *
sizeof(
Vp3Fragment));
2028 for (i = 0; i < 3; i++) {
2029 int height = s->height >> (i && s->chroma_y_shift);
2030 if (s->flipped_image)
2031 s->data_offset[i] = 0;
2033 s->data_offset[i] = (height-1) * s->current_frame.linesize[i];
2036 s->last_slice_end = 0;
2037 for (i = 0; i < s->c_superblock_height; i++)
2041 for (i = 0; i < 3; i++) {
2042 int row = (s->height >> (3+(i && s->chroma_y_shift))) - 1;
2059 avctx->release_buffer(avctx, &s->current_frame);
2115 #if CONFIG_THEORA_DECODER
2116 static const enum PixelFormat theora_pix_fmts[4] = {
2123 int visible_width, visible_height,
colorspace;
2124 int offset_x = 0, offset_y = 0;
2132 if (s->
theora < 0x030200)
2147 if (s->
theora >= 0x030200) {
2157 if (fps.
num && fps.
den) {
2158 if (fps.
num < 0 || fps.
den < 0) {
2163 fps.
den, fps.
num, 1<<30);
2168 if (aspect.
num && aspect.
den) {
2171 aspect.
num, aspect.
den, 1<<30);
2174 if (s->
theora < 0x030200)
2181 if (s->
theora >= 0x030200)
2190 if ( visible_width <= s->
width && visible_width > s->
width-16
2191 && visible_height <= s->height && visible_height > s->
height-16
2192 && !offset_x && (offset_y == s->
height - visible_height))
2197 if (colorspace == 1) {
2199 }
else if (colorspace == 2) {
2202 if (colorspace == 1 || colorspace == 2) {
2213 int i, n, matrices, inter, plane;
2215 if (s->
theora >= 0x030200) {
2219 for (i = 0; i < 64; i++)
2223 if (s->
theora >= 0x030200)
2228 for (i = 0; i < 64; i++)
2231 if (s->
theora >= 0x030200)
2236 for (i = 0; i < 64; i++)
2239 if (s->
theora >= 0x030200)
2249 for(n=0; n<matrices; n++){
2250 for (i = 0; i < 64; i++)
2254 for (inter = 0; inter <= 1; inter++) {
2255 for (plane = 0; plane <= 2; plane++) {
2257 if (inter || plane > 0)
2265 qtj= (3*inter + plane - 1) / 3;
2266 plj= (plane + 2) % 3;
2276 i=
get_bits(gb, av_log2(matrices-1)+1);
2281 s->
qr_base[inter][plane][qri]= i;
2284 i =
get_bits(gb, av_log2(63-qi)+1) + 1;
2285 s->
qr_size[inter][plane][qri++]= i;
2299 for (s->
hti = 0; s->
hti < 80; s->
hti++) {
2322 uint8_t *header_start[3];
2335 42, header_start, header_len) < 0) {
2345 if (!(ptype & 0x80))
2357 theora_decode_header(avctx, &gb);
2364 if (theora_decode_tables(avctx, &gb))
2373 if (s->
theora < 0x030200)
2385 .
init = theora_decode_init,
static const int16_t vp31_intra_y_dequant[64]
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Motion estimation with emulated edge values.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int16_t qmat[3][2][3][64]
qmat[qpi][is_inter][plane]
static int init_block_mapping(Vp3DecodeContext *s)
const uint8_t ff_zigzag_direct[64]
#define TOKEN_EOB(eob_run)
static void render_slice(Vp3DecodeContext *s, int slice)
int bounding_values_array[256+2]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
uint16_t qr_base[2][3][64]
static void skip_bits_long(GetBitContext *s, int n)
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
static const uint16_t fragment_run_length_vlc_table[30][2]
#define AV_LOG_WARNING
Something somehow does not look correct.
void(* idct_add)(uint8_t *dest, int line_size, DCTELEM *block)
block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
#define MODE_INTER_PLUS_MV
#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)
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)
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]
static const uint16_t dc_bias[16][32][2]
Vp3Fragment * all_fragments
static void init_loop_filter(Vp3DecodeContext *s)
#define COMPATIBLE_FRAME(x)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
#define TOKEN_ZERO_RUN(coeff, zero_run)
#define FF_DEBUG_PICT_INFO
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)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
uint8_t filter_limit_values[64]
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
uint8_t idct_permutation[64]
idct input permutation.
#define LOCAL_ALIGNED_16(t, v,...)
static const uint8_t mode_code_vlc_table[8][2]
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
av_cold void dsputil_init(DSPContext *c, AVCodecContext *avctx)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
static int init(AVCodecParserContext *s)
static const int16_t vp31_inter_dequant[64]
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int vp3_dequant(Vp3DecodeContext *s, Vp3Fragment *frag, int plane, int inter, DCTELEM block[64])
Pull DCT tokens from the 64 levels to decode and dequant the coefficients for the next block in codin...
static const uint16_t ac_bias_1[16][32][2]
static int get_bits_left(GetBitContext *gb)
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...
static const uint8_t motion_vector_vlc_table[63][2]
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Multithreading support functions.
struct Vp3DecodeContext Vp3DecodeContext
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it...
#define CODING_MODE_COUNT
void(* idct_put)(uint8_t *dest, int line_size, DCTELEM *block)
block -> idct -> clip to unsigned 8 bit -> dest.
static const int zero_run_base[32]
#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]
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
op_pixels_func put_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
#define AV_NUM_DATA_POINTERS
void(* clear_block)(DCTELEM *block)
static const int ModeAlphabet[6][CODING_MODE_COUNT]
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const int16_t vp31_intra_c_dequant[64]
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
static av_always_inline void emms_c(void)
Empty mmx state.
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]
void(* vp3_v_loop_filter)(uint8_t *src, int stride, int *bounding_values)
unsigned char * macroblock_coding
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...
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...
#define FF_THREAD_FRAME
Decode more than one frame at once.
VLC fragment_run_length_vlc
int width
picture width / height.
struct AVFrame AVFrame
Audio Video Frame.
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
int type
type of the buffer (to keep track of who has to deallocate data[*])
#define SB_PARTIALLY_CODED
static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb, VLC *table, int coeff_index, int plane, int eob_run)
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
static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int yend)
void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift)
static void update_frames(AVCodecContext *avctx)
Release and shuffle frames after decode finishes.
void ff_thread_await_progress(AVFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
static const uint16_t ac_bias_0[16][32][2]
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
int16_t * dct_tokens[3][64]
This is a list of all tokens in bitstream order.
#define FF_BUFFER_TYPE_COPY
Just a (modified) copy of some other buffer, don't deallocate anything.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
uint8_t qr_size[2][3][64]
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
static av_cold int allocate_tables(AVCodecContext *avctx)
Allocate tables for per-frame data in Vp3DecodeContext.
static unsigned int get_bits1(GetBitContext *s)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static void skip_bits(GetBitContext *s, int n)
#define CODEC_CAP_DRAW_HORIZ_BAND
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.
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)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int read_huffman_tree(AVCodecContext *avctx, GetBitContext *gb)
static const uint16_t superblock_run_length_vlc_table[34][2]
#define MODE_USING_GOLDEN
uint32_t huffman_table[80][32][2]
static int vp3_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
#define MODE_INTER_FOURMV
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void(* put_no_rnd_pixels_l2[2])(uint8_t *block, const uint8_t *a, const uint8_t *b, int line_size, int h)
#define copy_fields(to, from, start_field, end_field)
int * coded_fragment_list[3]
unsigned char * superblock_coding
common internal api header.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int16_t * dct_tokens_base
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
struct Vp3Fragment Vp3Fragment
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]
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.
void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
struct AVCodecInternal * internal
Private context used for internal data.
VLC_TYPE(* table)[2]
code, bits
static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst, int dst_pitch)
Convert and output the current plane.
#define MODE_INTER_PRIOR_LAST
static const int eob_run_base[7]
static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
#define MODE_INTER_LAST_MV
void ff_thread_report_progress(AVFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
Wrapper around get_buffer() for frame-multithreaded codecs.
discard all frames except keyframes
enum AVColorSpace colorspace
static const int zero_run_get_bits[32]
static const uint8_t vp31_filter_limit_values[64]
#define MKTAG(a, b, c, d)
void(* vp3_idct_dc_add)(uint8_t *dest, int line_size, const DCTELEM *block)
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)
void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
uint32_t coded_ac_scale_factor[64]
void(* vp3_h_loop_filter)(uint8_t *src, int stride, int *bounding_values)
int8_t(*[2] motion_val)[2]