23 #define UNCHECKED_BITSTREAM_READER 1 47 #define SPRITE_TRAJ_VLC_BITS 6 49 #define MB_TYPE_B_VLC_BITS 4 50 #define STUDIO_INTRA_BITS 9 74 int16_t *ac_val, *ac_val1;
86 if (s->
mb_x == 0 || s->
qscale == qscale_table[xy] ||
89 for (i = 1; i < 8; i++)
93 for (i = 1; i < 8; i++)
101 if (s->
mb_y == 0 || s->
qscale == qscale_table[xy] ||
104 for (i = 1; i < 8; i++)
108 for (i = 1; i < 8; i++)
114 for (i = 1; i < 8; i++)
118 for (i = 1; i < 8; i++)
146 v |= 0x7F >> (7 - (bits_count & 7));
159 for (len = 0; len < 32; len++)
186 int min_ab,
i, w2, h2, w3, h3;
187 int sprite_ref[4][2];
188 int virtual_ref[2][2];
189 int64_t sprite_offset[2][2];
190 int64_t sprite_delta[2][2];
193 const int vop_ref[4][2] = { { 0, 0 }, { s->
width, 0 },
195 int d[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
197 if (w <= 0 || h <= 0)
222 while ((1 << alpha) < w)
224 while ((1 << beta) < h)
231 sprite_ref[0][0] = a * vop_ref[0][0] + d[0][0];
232 sprite_ref[0][1] = a * vop_ref[0][1] + d[0][1];
233 sprite_ref[1][0] = a * vop_ref[1][0] + d[0][0] + d[1][0];
234 sprite_ref[1][1] = a * vop_ref[1][1] + d[0][1] + d[1][1];
235 sprite_ref[2][0] = a * vop_ref[2][0] + d[0][0] + d[2][0];
236 sprite_ref[2][1] = a * vop_ref[2][1] + d[0][1] + d[2][1];
238 sprite_ref[0][0] = (a >> 1) * (2 * vop_ref[0][0] + d[0][0]);
239 sprite_ref[0][1] = (a >> 1) * (2 * vop_ref[0][1] + d[0][1]);
240 sprite_ref[1][0] = (a >> 1) * (2 * vop_ref[1][0] + d[0][0] + d[1][0]);
241 sprite_ref[1][1] = (a >> 1) * (2 * vop_ref[1][1] + d[0][1] + d[1][1]);
242 sprite_ref[2][0] = (a >> 1) * (2 * vop_ref[2][0] + d[0][0] + d[2][0]);
243 sprite_ref[2][1] = (a >> 1) * (2 * vop_ref[2][1] + d[0][1] + d[2][1]);
253 virtual_ref[0][0] = 16 * (vop_ref[0][0] + w2) +
255 (r * sprite_ref[0][0] - 16LL * vop_ref[0][0]) +
256 w2 * (r * sprite_ref[1][0] - 16LL * vop_ref[1][0])), w);
257 virtual_ref[0][1] = 16 * vop_ref[0][1] +
259 (r * sprite_ref[0][1] - 16LL * vop_ref[0][1]) +
260 w2 * (r * sprite_ref[1][1] - 16LL * vop_ref[1][1])), w);
261 virtual_ref[1][0] = 16 * vop_ref[0][0] +
262 ROUNDED_DIV(((h - h2) * (r * sprite_ref[0][0] - 16LL * vop_ref[0][0]) +
263 h2 * (r * sprite_ref[2][0] - 16LL * vop_ref[2][0])), h);
264 virtual_ref[1][1] = 16 * (vop_ref[0][1] + h2) +
265 ROUNDED_DIV(((h - h2) * (r * sprite_ref[0][1] - 16LL * vop_ref[0][1]) +
266 h2 * (r * sprite_ref[2][1] - 16LL * vop_ref[2][1])),
h);
270 sprite_offset[0][0] =
271 sprite_offset[0][1] =
272 sprite_offset[1][0] =
273 sprite_offset[1][1] = 0;
274 sprite_delta[0][0] =
a;
276 sprite_delta[1][0] = 0;
277 sprite_delta[1][1] =
a;
282 sprite_offset[0][0] = sprite_ref[0][0] - a * vop_ref[0][0];
283 sprite_offset[0][1] = sprite_ref[0][1] - a * vop_ref[0][1];
284 sprite_offset[1][0] = ((sprite_ref[0][0] >> 1) | (sprite_ref[0][0] & 1)) -
285 a * (vop_ref[0][0] / 2);
286 sprite_offset[1][1] = ((sprite_ref[0][1] >> 1) | (sprite_ref[0][1] & 1)) -
287 a * (vop_ref[0][1] / 2);
288 sprite_delta[0][0] =
a;
290 sprite_delta[1][0] = 0;
291 sprite_delta[1][1] =
a;
296 sprite_offset[0][0] = ((int64_t) sprite_ref[0][0] * (1 << alpha + rho)) +
297 ((int64_t) -r * sprite_ref[0][0] + virtual_ref[0][0]) *
298 ((int64_t) -vop_ref[0][0]) +
299 ((int64_t) r * sprite_ref[0][1] - virtual_ref[0][1]) *
300 ((int64_t) -vop_ref[0][1]) + (1 << (alpha + rho - 1));
301 sprite_offset[0][1] = ((int64_t) sprite_ref[0][1] * (1 << alpha + rho)) +
302 ((int64_t) -r * sprite_ref[0][1] + virtual_ref[0][1]) *
303 ((int64_t) -vop_ref[0][0]) +
304 ((int64_t) -r * sprite_ref[0][0] + virtual_ref[0][0]) *
305 ((int64_t) -vop_ref[0][1]) + (1 << (alpha + rho - 1));
306 sprite_offset[1][0] = (((int64_t)-r * sprite_ref[0][0] + virtual_ref[0][0]) *
307 ((int64_t)-2 * vop_ref[0][0] + 1) +
308 ((int64_t) r * sprite_ref[0][1] - virtual_ref[0][1]) *
309 ((int64_t)-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
310 (int64_t) sprite_ref[0][0] - 16 * w2 + (1 << (alpha + rho + 1)));
311 sprite_offset[1][1] = (((int64_t)-r * sprite_ref[0][1] + virtual_ref[0][1]) *
312 ((int64_t)-2 * vop_ref[0][0] + 1) +
313 ((int64_t)-r * sprite_ref[0][0] + virtual_ref[0][0]) *
314 ((int64_t)-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
315 (int64_t) sprite_ref[0][1] - 16 * w2 + (1 << (alpha + rho + 1)));
316 sprite_delta[0][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]);
317 sprite_delta[0][1] = (+r * sprite_ref[0][1] - virtual_ref[0][1]);
318 sprite_delta[1][0] = (-r * sprite_ref[0][1] + virtual_ref[0][1]);
319 sprite_delta[1][1] = (-r * sprite_ref[0][0] + virtual_ref[0][0]);
325 min_ab =
FFMIN(alpha, beta);
328 sprite_offset[0][0] = ((int64_t)sprite_ref[0][0] * (1 << (alpha + beta + rho - min_ab))) +
329 ((int64_t)-r * sprite_ref[0][0] + virtual_ref[0][0]) * h3 * (-vop_ref[0][0]) +
330 ((int64_t)-r * sprite_ref[0][0] + virtual_ref[1][0]) * w3 * (-vop_ref[0][1]) +
331 ((int64_t)1 << (alpha + beta + rho - min_ab - 1));
332 sprite_offset[0][1] = ((int64_t)sprite_ref[0][1] * (1 << (alpha + beta + rho - min_ab))) +
333 ((int64_t)-r * sprite_ref[0][1] + virtual_ref[0][1]) * h3 * (-vop_ref[0][0]) +
334 ((int64_t)-r * sprite_ref[0][1] + virtual_ref[1][1]) * w3 * (-vop_ref[0][1]) +
335 ((int64_t)1 << (alpha + beta + rho - min_ab - 1));
336 sprite_offset[1][0] = ((int64_t)-r * sprite_ref[0][0] + virtual_ref[0][0]) * h3 * (-2 * vop_ref[0][0] + 1) +
337 ((int64_t)-r * sprite_ref[0][0] + virtual_ref[1][0]) * w3 * (-2 * vop_ref[0][1] + 1) +
338 (int64_t)2 * w2 * h3 * r * sprite_ref[0][0] - 16 * w2 * h3 +
339 ((int64_t)1 << (alpha + beta + rho - min_ab + 1));
340 sprite_offset[1][1] = ((int64_t)-r * sprite_ref[0][1] + virtual_ref[0][1]) * h3 * (-2 * vop_ref[0][0] + 1) +
341 ((int64_t)-r * sprite_ref[0][1] + virtual_ref[1][1]) * w3 * (-2 * vop_ref[0][1] + 1) +
342 (int64_t)2 * w2 * h3 * r * sprite_ref[0][1] - 16 * w2 * h3 +
343 ((int64_t)1 << (alpha + beta + rho - min_ab + 1));
344 sprite_delta[0][0] = (-r * (int64_t)sprite_ref[0][0] + virtual_ref[0][0]) * h3;
345 sprite_delta[0][1] = (-r * (int64_t)sprite_ref[0][0] + virtual_ref[1][0]) * w3;
346 sprite_delta[1][0] = (-r * (int64_t)sprite_ref[0][1] + virtual_ref[0][1]) * h3;
347 sprite_delta[1][1] = (-r * (int64_t)sprite_ref[0][1] + virtual_ref[1][1]) * w3;
355 sprite_delta[0][1] == 0 &&
356 sprite_delta[1][0] == 0 &&
362 sprite_delta[0][0] =
a;
363 sprite_delta[0][1] = 0;
364 sprite_delta[1][0] = 0;
365 sprite_delta[1][1] =
a;
373 for (i = 0; i < 2; i++) {
374 if (shift_c < 0 || shift_y < 0 ||
375 FFABS( sprite_offset[0][i]) >= INT_MAX >> shift_y ||
376 FFABS( sprite_offset[1][i]) >= INT_MAX >> shift_c ||
377 FFABS( sprite_delta[0][i]) >= INT_MAX >> shift_y ||
378 FFABS( sprite_delta[1][i]) >= INT_MAX >> shift_y
385 for (i = 0; i < 2; i++) {
386 sprite_offset[0][
i] *= 1 << shift_y;
387 sprite_offset[1][
i] *= 1 << shift_c;
388 sprite_delta[0][
i] *= 1 << shift_y;
389 sprite_delta[1][
i] *= 1 << shift_y;
393 for (i = 0; i < 2; i++) {
395 sprite_delta[
i][0] - a * (1LL<<16),
396 sprite_delta[i][1] - a * (1LL<<16)
399 if (llabs(sprite_offset[0][i] + sprite_delta[i][0] * (w+16LL)) >= INT_MAX ||
400 llabs(sprite_offset[0][i] + sprite_delta[i][1] * (h+16LL)) >= INT_MAX ||
401 llabs(sprite_offset[0][i] + sprite_delta[i][0] * (w+16LL) + sprite_delta[i][1] * (h+16LL)) >= INT_MAX ||
402 llabs(sprite_delta[i][0] * (w+16LL)) >= INT_MAX ||
403 llabs(sprite_delta[i][1] * (h+16LL)) >= INT_MAX ||
404 llabs(sd[0]) >= INT_MAX ||
405 llabs(sd[1]) >= INT_MAX ||
406 llabs(sprite_offset[0][i] + sd[0] * (w+16LL)) >= INT_MAX ||
407 llabs(sprite_offset[0][i] + sd[1] * (h+16LL)) >= INT_MAX ||
408 llabs(sprite_offset[0][i] + sd[0] * (w+16LL) + sd[1] * (h+16LL)) >= INT_MAX
417 for (i = 0; i < 4; i++) {
450 int header_extension = 0, mb_num,
len;
456 for (len = 0; len < 32; len++)
471 if (mb_num >= s->
mb_num || !mb_num) {
473 "illegal mb_num in video packet (%d %d) \n", mb_num, s->
mb_num);
489 if (header_extension) {
518 "Error, video packet header damaged (f_code=0)\n");
524 "Error, video packet header damaged (b_code=0)\n");
591 int x, y, mb_v, sum, dx, dy,
shift;
608 dy -= 1 << (shift + a + 1);
610 dx -= 1 << (shift + a + 1);
614 for (y = 0; y < 16; y++) {
619 for (x = 0; x < 16; x++) {
650 if (code < 0 || code > 9 ) {
663 level =
get_bits(&s->
gb, code - 1) + (1 << (code - 1));
665 level = -
get_bits(&s->
gb, code - 1) - (1 << (code - 1));
692 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
718 "mcbpc corrupted at %d %d\n", s->
mb_x, s->
mb_y);
733 for (i = 0; i < 6; i++) {
738 "DC corrupted at %d %d\n", s->
mb_x, s->
mb_y);
747 int mx, my, pred_x, pred_y,
bits;
757 if (bits & 0x10000) {
790 "mcbpc corrupted at %d %d\n", s->
mb_x, s->
mb_y);
822 if ((cbpc & 16) == 0) {
856 for (i = 0; i < 4; i++) {
885 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
904 "cbpy corrupted at %d %d\n", s->
mb_x, s->
mb_y);
919 "I cbpy corrupted at %d %d\n", s->
mb_x, s->
mb_y);
927 for (i = 0; i < 6; i++) {
932 "DC corrupted at %d %d\n", s->
mb_x, s->
mb_y);
951 "P cbpy corrupted at %d %d\n", s->
mb_x, s->
mb_y);
964 if (mb_num >= mb_count)
1004 "marker missing after first I partition at %d %d\n",
1013 "marker missing after first P partition at %d %d\n",
1041 int n,
int coded,
int intra,
int rvlc)
1084 if (dc_pred_dir == 0)
1115 qadd = (s->
qscale - 1) | 1;
1132 "1. marker bit missing in rvlc esc\n");
1145 "2. marker bit missing in rvlc esc\n");
1159 level = level * qmul + qadd;
1171 cache ^= 0xC0000000;
1173 if (cache & 0x80000000) {
1174 if (cache & 0x40000000) {
1189 "1. marker bit missing in 3. esc\n");
1200 "2. marker bit missing in 3. esc\n");
1209 if (s->error_recognition >= FF_ER_COMPLIANT) {
1210 const int abs_level=
FFABS(level);
1212 const int run1= run - rl->
max_run[last][abs_level] - 1;
1213 if (abs_level <= rl->max_level[last][run]) {
1217 if (s->error_recognition > FF_ER_COMPLIANT) {
1218 if (abs_level <= rl->max_level[last][run]*2) {
1222 if (run1 >= 0 && abs_level <= rl->max_level[last][run1]) {
1231 level = level * qmul + qadd;
1233 level = level * qmul - qadd;
1235 if ((
unsigned)(level + 2048) > 4095) {
1237 if (level > 2560 || level < -2560) {
1239 "|level| overflow in 3. esc, qp=%d\n",
1244 level = level < 0 ? -2048 : 2047;
1254 i += run + rl->
max_run[run >> 7][level / qmul] + 1;
1263 level = level + rl->
max_level[run >> 7][(run - 1) & 63] * qmul;
1273 ff_tlog(s->
avctx,
"dct[%d][%d] = %- 4d end?:%d\n", scan_table[i&63]&7, scan_table[i&63] >> 3, level, i>62);
1278 "ac-tex damaged at %d %d\n", s->
mb_x, s->
mb_y);
1282 block[scan_table[
i]] =
level;
1286 block[scan_table[
i]] =
level;
1330 for (i = 0; i < 4; i++) {
1338 for (i = 0; i < 6; i++)
1371 for (i = 0; i < 6; i++) {
1374 "texture corrupted at %d %d %d\n",
1401 int cbpc, cbpy,
i, cbp, pred_x, pred_y, mx, my, dquant;
1403 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
1415 for (i = 0; i < 6; i++)
1443 "mcbpc damaged at %d %d\n", s->
mb_x, s->
mb_y);
1446 }
while (cbpc == 20);
1462 "P cbpy damaged at %d %d\n", s->
mb_x, s->
mb_y);
1466 cbp = (cbpc & 3) | (cbpy << 2);
1474 if ((cbpc & 16) == 0) {
1483 s->
mv[0][0][0] = mx;
1484 s->
mv[0][0][1] = my;
1497 for (i = 0; i < 2; i++) {
1506 s->
mv[0][
i][0] = mx;
1507 s->
mv[0][
i][1] = my;
1523 s->
mv[0][0][0] = mx;
1524 s->
mv[0][0][1] = my;
1529 for (i = 0; i < 4; i++) {
1538 s->
mv[0][
i][0] = mx;
1539 s->
mv[0][
i][1] = my;
1553 for (i = 0; i < 2; i++) {
1568 for (i = 0; i < 6; i++)
1638 s->
mv[0][0][0] = mx;
1641 s->
mv[0][0][1] = my;
1651 s->
mv[1][0][0] = mx;
1654 s->
mv[1][0][1] = my;
1662 for (i = 0; i < 2; i++) {
1666 s->
mv[0][
i][0] = mx;
1674 for (i = 0; i < 2; i++) {
1678 s->
mv[1][
i][0] = mx;
1703 "I cbpc damaged at %d %d\n", s->
mb_x, s->
mb_y);
1706 }
while (cbpc == 8);
1721 "I cbpy damaged at %d %d\n", s->
mb_x, s->
mb_y);
1724 cbp = (cbpc & 3) | (cbpy << 2);
1736 for (i = 0; i < 6; i++) {
1745 for (i = 0; i < 6; i++) {
1819 int cc, dct_dc_size, dct_diff,
code, j, idx = 1, group = 0,
run = 0,
1820 additional_code_len, sign, mismatch;
1821 const VLC *cur_vlc = &studio_intra_tab[0];
1823 const uint16_t *quant_matrix;
1831 memset(block, 0, 64 *
sizeof(
int32_t));
1846 if (dct_dc_size == 0) {
1851 if (dct_dc_size > 8) {
1866 block[0] =
av_clip(block[0], min, max);
1867 mismatch ^= block[0];
1884 }
else if (group >= 1 && group <= 6) {
1886 run = 1 << additional_code_len;
1887 if (additional_code_len)
1891 }
else if (group >= 7 && group <= 12) {
1893 code =
get_bits(&s->
gb, additional_code_len);
1896 run = (1 << (additional_code_len - 1)) +
code;
1900 j = scantable[idx++];
1901 block[j] = sign ? 1 : -1;
1902 }
else if (group >= 13 && group <= 20) {
1906 j = scantable[idx++];
1907 block[j] =
get_xbits(&s->
gb, additional_code_len);
1908 }
else if (group == 21) {
1912 j = scantable[idx++];
1915 if (flc >> (additional_code_len-1))
1916 block[j] = -1 * (( flc ^ ((1 << additional_code_len) -1)) + 1);
1920 block[j] = ((block[j] * quant_matrix[j] * s->
qscale) * (1 << shift)) / 16;
1921 block[j] =
av_clip(block[j], min, max);
1922 mismatch ^= block[j];
1925 block[63] ^= mismatch & 1;
1932 int i, j,
w,
h, idx = 0;
1933 int block_mean, rice_parameter, rice_prefix_code, rice_suffix_code,
1934 dpcm_residual,
left, top, topleft, min_left_top, max_left_top, p, p2,
output;
1939 if (block_mean == 0){
1946 if (rice_parameter == 0) {
1951 if (rice_parameter == 15)
1954 if (rice_parameter > 11) {
1959 for (i = 0; i <
h; i++) {
1963 for (j = 0; j <
w; j++) {
1970 if (rice_prefix_code == 11)
1973 if (rice_prefix_code == 12) {
1977 rice_suffix_code =
get_bitsz(&s->
gb, rice_parameter);
1978 dpcm_residual = (rice_prefix_code << rice_parameter) + rice_suffix_code;
1982 if (dpcm_residual & 1)
1983 dpcm_residual = (-1 * dpcm_residual) >> 1;
1985 dpcm_residual = (dpcm_residual >> 1);
1988 top = macroblock[idx-
w];
1990 p = left + top - topleft;
1991 min_left_top =
FFMIN(left, top);
1992 if (p < min_left_top)
1995 max_left_top =
FFMAX(left, top);
1996 if (p > max_left_top)
1999 p2 = (
FFMIN(min_left_top, topleft) +
FFMAX(max_left_top, topleft)) >> 1;
2004 dpcm_residual *= -1;
2038 for (i = 0; i < 3; i++) {
2062 int hours, minutes, seconds;
2074 s->
time_base = seconds + 60*(minutes + 60*hours);
2089 if (*profile == 0 && *level == 8) {
2098 int visual_object_type;
2099 int is_visual_object_identifier =
get_bits1(gb);
2101 if (is_visual_object_identifier) {
2104 visual_object_type =
get_bits(gb, 4);
2109 if (video_signal_type) {
2110 int video_range, color_description;
2117 if (color_description) {
2133 for (i = 0; i < 64; i++) {
2153 for (i = 0; i < 64; i++) {
2165 for (i = 0; i < 64; i++) {
2174 for (i = 0; i < 64; i++) {
2185 for (i = 0; i < 64; i++) {
2215 int bits_per_raw_sample;
2216 int rgb, chroma_format;
2236 bits_per_raw_sample =
get_bits(gb, 4);
2237 if (bits_per_raw_sample == 10) {
2261 if (width && height) {
2337 int chroma_format =
get_bits(gb, 2);
2408 if (width && height &&
2423 "MPEG-4 OBMC not supported (very likely buggy encoder)\n");
2446 "%d sprite_warping_points\n",
2482 for (i = 0; i < 64; i++) {
2499 for (; i < 64; i++) {
2509 for (i = 0; i < 64; i++) {
2526 for (; i < 64; i++) {
2548 int estimation_method =
get_bits(gb, 2);
2549 if (estimation_method < 2) {
2586 if (estimation_method == 1) {
2592 "Invalid Complexity estimation method %d\n",
2608 if (vo_ver_id != 1) {
2617 "reduced resolution VOP not supported\n");
2626 int h_sampling_factor_n;
2627 int h_sampling_factor_m;
2628 int v_sampling_factor_n;
2629 int v_sampling_factor_m;
2634 h_sampling_factor_n =
get_bits(gb, 5);
2635 h_sampling_factor_m =
get_bits(gb, 5);
2636 v_sampling_factor_n =
get_bits(gb, 5);
2637 v_sampling_factor_m =
get_bits(gb, 5);
2640 if (h_sampling_factor_n == 0 || h_sampling_factor_m == 0 ||
2641 v_sampling_factor_n == 0 || v_sampling_factor_m == 0) {
2678 int ver = 0, build = 0, ver2 = 0, ver3 = 0;
2689 e = sscanf(buf,
"DivX%dBuild%d%c", &ver, &build, &last);
2691 e = sscanf(buf,
"DivX%db%d%c", &ver, &build, &last);
2699 e = sscanf(buf,
"FFmpe%*[^b]b%d", &build) + 3;
2701 e = sscanf(buf,
"FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build);
2703 e = sscanf(buf,
"Lavc%d.%d.%d", &ver, &ver2, &ver3) + 1;
2705 if (ver > 0xFFU || ver2 > 0xFFU || ver3 > 0xFFU) {
2707 "Unknown Lavc version string encountered, %d.%d.%d; " 2708 "clamping sub-version values to 8-bits.\n",
2711 build = ((ver & 0xFF) << 16) + ((ver2 & 0xFF) << 8) + (ver3 & 0xFF);
2715 if (strcmp(buf,
"ffmpeg") == 0)
2722 e = sscanf(buf,
"XviD%d", &build);
2778 #define SET_QPEL_FUNC(postfix1, postfix2) \ 2779 s->qdsp.put_ ## postfix1 = ff_put_ ## postfix2; \ 2780 s->qdsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2; \ 2781 s->qdsp.avg_ ## postfix1 = ff_avg_ ## postfix2; 2832 "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
2836 if (CONFIG_MPEG4_DECODER && ctx->
xvid_build >= 0 &&
2850 int time_incr, time_increment;
2876 "time_increment_bits %d is invalid in relation to the current bitstream, this is likely caused by a missing VOL header\n", ctx->
time_increment_bits);
2891 "time_increment_bits set to %d bits, based on bitstream analysis\n", ctx->
time_increment_bits);
3028 "sprite_brightness_change not supported\n");
3041 "Error, header damaged or not MPEG-4 header (qscale=0)\n");
3049 "Error, header damaged or not MPEG-4 header (f_code=0)\n");
3060 "Error, header damaged or not MPEG4 header (b_code=0)\n");
3069 "qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d ce:%d/%d/%d time:%"PRId64
" tincr:%d\n",
3090 int load_backward_shape =
get_bits1(gb);
3091 if (load_backward_shape)
3093 "load backward shape isn't supported\n");
3104 "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
3198 int visual_object_type;
3201 visual_object_type =
get_bits(gb, 4);
3224 unsigned startcode, v;
3258 startcode = ((startcode << 8) | v) & 0xffffffff;
3260 if ((startcode & 0xFFFFFF00) != 0x100)
3265 if (startcode <= 0x11F)
3267 else if (startcode <= 0x12F)
3269 else if (startcode <= 0x13F)
3271 else if (startcode <= 0x15F)
3273 else if (startcode <= 0x1AF)
3275 else if (startcode == 0x1B0)
3277 else if (startcode == 0x1B1)
3279 else if (startcode == 0x1B2)
3281 else if (startcode == 0x1B3)
3283 else if (startcode == 0x1B4)
3285 else if (startcode == 0x1B5)
3287 else if (startcode == 0x1B6)
3289 else if (startcode == 0x1B7)
3291 else if (startcode == 0x1B8)
3293 else if (startcode == 0x1B9)
3295 else if (startcode == 0x1BA)
3297 else if (startcode == 0x1BB)
3299 else if (startcode == 0x1BC)
3301 else if (startcode == 0x1BD)
3303 else if (startcode == 0x1BE)
3305 else if (startcode == 0x1BF)
3307 else if (startcode == 0x1C0)
3309 else if (startcode == 0x1C1)
3311 else if (startcode == 0x1C2)
3313 else if (startcode == 0x1C3)
3315 else if (startcode <= 0x1C5)
3317 else if (startcode <= 0x1FF)
3322 if (startcode >= 0x120 && startcode <= 0x12F) {
3338 (level > 0 && level < 9)) {
3378 static int done = 0;
3395 NULL, 0, 0, 0, 0, 128);
3413 int startcode_found = 0;
3415 if (buf_size - current_pos > 7) {
3418 for (i = current_pos; i < buf_size - 4; i++)
3423 buf[i + 3] == 0xB6) {
3424 startcode_found = !(buf[i + 4] & 0x40);
3429 if (startcode_found) {
3432 "wasteful way to store B-frames ('packed B-frames'). " 3433 "Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.\n");
3438 buf_size - current_pos);
3444 buf_size - current_pos);
3493 if (CONFIG_MPEG4_DECODER && !init && s1->
xvid_build >= 0)
3499 static int mpeg4_update_thread_context_for_user(
AVCodecContext *dst,
3524 for (
unsigned i = 0,
offset = 0;
i < 12;
i++) {
3566 #define OFFSET(x) offsetof(MpegEncContext, x) 3567 #define FLAGS AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY 3603 #if CONFIG_MPEG4_NVDEC_HWACCEL 3606 #if CONFIG_MPEG4_VAAPI_HWACCEL 3609 #if CONFIG_MPEG4_VDPAU_HWACCEL 3612 #if CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL
int bitstream_buffer_size
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
uint16_t sprite_traj[4][2]
sprite trajectory points
#define AV_EF_AGGRESSIVE
consider things that a sane encoder should not do as an error
void ff_init_block_index(MpegEncContext *s)
static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
static int mpeg4_decode_visual_object(MpegEncContext *s, GetBitContext *gb)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define FF_BUG_XVID_ILACE
ScanTable intra_v_scantable
static int shift(int a, int b)
RLTable ff_mpeg4_rl_intra
const uint8_t ff_mpeg4_c_dc_scale_table[32]
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
static const uint8_t ac_state_tab[22][2]
static void decode_smpte_tc(Mpeg4DecContext *ctx, GetBitContext *gb)
int sprite_brightness_change
const uint8_t ff_mpeg4_studio_intra[12][24][2]
#define MV_TYPE_FIELD
2 vectors, one per field
static void flush(AVCodecContext *avctx)
const uint8_t * y_dc_scale_table
qscale -> y_dc_scale table
int sprite_warping_accuracy
int last_mv[2][2][2]
last MV, used for MV prediction in MPEG-1 & B-frame MPEG-4
av_cold void ff_mpeg4videodec_static_init(void)
int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
#define SLICE_NOEND
no end marker or error found but mb count exceeded
static VLC studio_intra_tab[12]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx)
Decode the next video packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define MB_TYPE_B_VLC_BITS
static av_cold int init(AVCodecContext *avctx)
VLC ff_h263_intra_MCBPC_vlc
int resync_marker
could this stream contain resync markers
static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb)
uint16_t chroma_intra_matrix[64]
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
static int mpeg4_decode_gop_header(MpegEncContext *s, GetBitContext *gb)
int16_t(*[3] ac_val)[16]
used for MPEG-4 AC prediction, all 3 arrays must be continuous
#define avpriv_request_sample(...)
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
#define SKIP_COUNTER(name, gb, num)
uint16_t chroma_inter_matrix[64]
enum AVColorRange color_range
MPEG vs JPEG YUV range.
static int check_marker(void *logctx, GetBitContext *s, const char *msg)
#define HWACCEL_NVDEC(codec)
uint8_t * bitstream_buffer
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
#define AV_PIX_FMT_GBRP10
const char * av_default_item_name(void *ptr)
Return the context name.
static int mpeg4_decode_profile_level(MpegEncContext *s, GetBitContext *gb, int *profile, int *level)
#define SIMPLE_STUDIO_VO_TYPE
#define FF_BUG_HPEL_CHROMA
void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir)
Predict the ac.
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 av_cold int decode_init(AVCodecContext *avctx)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define FF_PROFILE_MPEG4_SIMPLE_STUDIO
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
int real_sprite_warping_points
#define AV_EF_BITSTREAM
detect bitstream specification deviations
#define FF_ARRAY_ELEMS(a)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int padding_bug_score
used to detect the VERY common padding bug in MPEG-4
int mb_num
number of MBs of a picture
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 void extension_and_user_data(MpegEncContext *s, GetBitContext *gb, int id)
static int mpeg4_decode_studio_mb(MpegEncContext *s, int16_t block_[12][64])
int time_base
time in seconds of last I,P,S Frame
Undefined Behavior In the C some operations are like signed integer overflow
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
const AVProfile ff_mpeg4_video_profiles[]
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, int header)
Decode MPEG-4 headers.
int cplx_estimation_trash_b
#define STUDIO_INTRA_BITS
void ff_clean_intra_table_entries(MpegEncContext *s)
Clean dc, ac, coded_block for the current non-intra MB.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
const uint8_t ff_sprite_trajectory_lens[15]
int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define USES_LIST(a, list)
#define USER_DATA_STARTCODE
int mb_num_left
number of MBs left in this video packet (for partitioned Slices only)
int64_t time
time of current frame
int8_t * max_run[2]
encoding & decoding
#define MV_DIRECT
bidirectional mode where the difference equals the MV of the last P/S/I-Frame (MPEG-4) ...
The exact code depends on how similar the blocks are and how related they are to the block
#define HWACCEL_VDPAU(codec)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
const uint16_t ff_mpeg4_resync_prefix[8]
#define FF_DEBUG_PICT_INFO
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
uint8_t * pred_dir_table
used to store pred_dir for partitioned decoding
Multithreading support functions.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
#define AV_CODEC_FLAG_LOW_DELAY
Force low delay.
int no_rounding
apply no rounding to motion compensation (MPEG-4, msmpeg4, ...) for B-frames rounding mode is always ...
static void mpeg4_load_default_matrices(MpegEncContext *s)
Picture current_picture
copy of the current picture structure.
const uint8_t ff_mpeg4_DCtab_chrom[13][2]
int cplx_estimation_trash_p
static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb)
Decode the user data stuff in the header.
#define FF_BUG_QPEL_CHROMA2
static int get_bits_count(const GetBitContext *s)
int8_t * max_level[2]
encoding & decoding
uint16_t pp_time
time distance between the last 2 p,s,i frames
#define AV_LOG_VERBOSE
Detailed information.
av_cold void ff_mpv_idct_init(MpegEncContext *s)
int mb_height
number of MBs horizontally & vertically
static const uint8_t header[24]
int codec_tag
internal codec_tag upper case converted from avctx codec_tag
int intra_dc_threshold
QP above which the ac VLC should be used for intra dc.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
static int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int level, int *dir_ptr, int encoding)
Predict the dc.
static void ff_update_block_index(MpegEncContext *s)
#define FF_CODEC_CAP_ALLOCATE_PROGRESS
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
int sprite_offset[2][2]
sprite offset[isChroma][isMVY]
#define ROUNDED_DIV(a, b)
#define FF_BUG_DIRECT_BLOCKSIZE
av_cold void ff_xvid_idct_init(IDCTDSPContext *c, AVCodecContext *avctx)
static int get_bits_left(GetBitContext *gb)
int16_t * dc_val[3]
used for MPEG-4 DC prediction, all 3 arrays must be continuous
#define UPDATE_CACHE(name, gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
#define QUANT_MATRIX_EXT_ID
int last_dc[3]
last DC values for MPEG-1
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
int mb_skipped
MUST BE SET only during DECODING.
int partitioned_frame
is current frame partitioned
int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
Decode the first and second partition.
void(* clear_blocks)(int16_t *blocks)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int get_amv(Mpeg4DecContext *ctx, int n)
Get the average motion vector for a GMC MB.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int flags
AV_CODEC_FLAG_*.
#define INTER_MCBPC_VLC_BITS
#define FF_BUG_NO_PADDING
void ff_mpeg4_init_direct_mv(MpegEncContext *s)
int(* decode_mb)(struct MpegEncContext *s, int16_t block[12][64])
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_YUV444P10
int quarter_sample
1->qpel, 0->half pel ME/MC
int low_delay
no reordering needed / has no B-frames
#define SET_QPEL_FUNC(postfix1, postfix2)
#define CLOSE_READER(name, gb)
#define INIT_VLC_RL(rl, static_size)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define GET_RL_VLC(level, run, name, gb, table, bits,max_depth, need_update)
void ff_mpeg_flush(AVCodecContext *avctx)
#define SKIP_BITS(name, gb, num)
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
int resync_mb_x
x position of last resync marker
#define INIT_FIRST_VLC_RL(rl, static_size)
const uint8_t ff_alternate_horizontal_scan[64]
int dct_precision
number of bits to represent the fractional part of time (encoder only)
int ff_h263_decode_init(AVCodecContext *avctx)
common internal API header
int sprite_delta[2][2]
sprite_delta [isY][isMVY]
#define ADV_SIMPLE_VO_TYPE
const uint8_t ff_mpeg4_DCtab_lum[13][2]
uint8_t ff_mpeg4_static_rl_table_store[3][2][2 *MAX_RUN+MAX_LEVEL+3]
VLC ff_h263_inter_MCBPC_vlc
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *gb)
static const int mb_type_b_map[4]
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
const uint8_t ff_mpeg4_y_dc_scale_table[32]
static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx)
Decode first partition.
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
static int mpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr)
Decode the dc value.
int16_t(*[2] motion_val)[2]
#define FF_PROFILE_UNKNOWN
enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]
unsigned int allocated_bitstream_buffer_size
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define INIT_VLC_STATIC_FROM_LENGTHS(vlc, bits, nb_codes, lens, len_wrap,symbols, symbols_wrap, symbols_size,offset, flags, static_size)
int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
Decode the next video packet.
#define LAST_SKIP_BITS(name, gb, num)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int block_last_index[12]
last non zero coefficient in block
uint8_t idct_permutation[64]
IDCT input permutation.
int vol_control_parameters
does the stream contain the low_delay flag, used to work around buggy encoders.
const int16_t ff_mpeg4_default_non_intra_matrix[64]
#define FRAME_SKIPPED
Return value for header parsers if frame is not coded.
uint8_t * mbintra_table
used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
#define MB_TYPE_INTERLACED
#define FF_BUG_QPEL_CHROMA
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
RL_VLC_ELEM * rl_vlc[32]
decoding only
av_cold void ff_rl_init(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
#define SHOW_UBITS(name, gb, num)
#define SPRITE_TRAJ_VLC_BITS
int block_index[6]
index to current MB in block based arrays with edges
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n)
#define MV_TYPE_16X16
1 vector for the whole mb
int first_slice_line
used in MPEG-4 too to handle resync markers
static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
decode partition C of one MB.
const uint8_t ff_mpeg4_studio_dc_chroma[19][2]
#define AV_LOG_INFO
Standard information.
uint16_t inter_matrix[64]
static av_cold void mpeg4_init_static(void)
#define FF_ASPECT_EXTENDED
static int read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb)
static const int16_t alpha[]
main external API structure.
int cplx_estimation_trash_i
static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
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]
ScanTable intra_scantable
int height
picture size. must be a multiple of 16
static int get_xbits(GetBitContext *s, int n)
Read MPEG-1 dc-style VLC (sign bit + mantissa with no MSB).
#define OPEN_READER(name, gb)
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 left
#define SLICE_END
end marker found
int data_partitioning
data partitioning flag from header
int showed_packed_warning
flag for having shown the warning about invalid Divx B-frames
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
Describe the class of an AVClass context structure.
ScanTable intra_h_scantable
static void skip_bits(GetBitContext *s, int n)
static const AVProfile profiles[]
uint8_t * cbp_table
used to store cbp, ac_pred for partitioned decoding
enum AVColorSpace colorspace
YUV colorspace type.
Rational number (pair of numerator and denominator).
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
static void reset_studio_dc_predictors(MpegEncContext *s)
int ff_init_vlc_from_lengths(VLC *vlc_arg, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
#define VOT_STILL_TEXTURE_ID
#define GET_CACHE(name, gb)
static const SheerTable rgb[2]
#define AV_EF_IGNORE_ERR
ignore errors and continue
const uint8_t ff_zigzag_direct[64]
static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t macroblock[256], int n)
#define SKIP_CACHE(name, gb, num)
const int16_t ff_mpeg4_default_intra_matrix[64]
int f_code
forward MV resolution
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my)
int sprite_shift[2]
sprite shift [isChroma]
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
static enum AVPixelFormat pix_fmts[]
#define AV_CODEC_CAP_TRUNCATED
const uint8_t ff_mpeg4_dc_threshold[8]
#define FF_BUG_AUTODETECT
autodetection
int h263_pred
use MPEG-4/H.263 ac/dc predictions
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s)
#define AV_PIX_FMT_YUV422P10
static VLC studio_luma_dc
uint16_t pb_field_time
like above, just for interlaced
const AVRational ff_h263_pixel_aspect[16]
const uint8_t * c_dc_scale_table
qscale -> c_dc_scale table
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
int b8_stride
2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
Narrow or limited range content.
Picture * next_picture_ptr
pointer to the next picture (for bidir pred)
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
struct AVCodecContext * avctx
static int mpeg4_is_resync(Mpeg4DecContext *ctx)
check if the next stuff is a resync marker or the end.
#define SHOW_SBITS(name, gb, num)
#define VISUAL_OBJ_STARTCODE
static VLC sprite_trajectory
GLint GLenum GLboolean GLsizei stride
int t_frame
time distance of first I -> B, used for interlaced B-frames
static const AVOption mpeg4_options[]
common internal api header.
int32_t(* block32)[12][64]
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count)
decode second partition.
const uint8_t ff_alternate_vertical_scan[64]
static const AVClass mpeg4_class
int ff_h263_decode_end(AVCodecContext *avctx)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
#define FF_DEBUG_STARTCODE
static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
Decode the next studio vop header.
#define HWACCEL_VAAPI(codec)
int resync_mb_y
y position of last resync marker
int16_t(* block)[64]
points to one of the following blocks
#define CORE_STUDIO_VO_TYPE
static int ff_thread_once(char *control, void(*routine)(void))
VLC_TYPE(* table)[2]
code, bits
Picture next_picture
copy of the next picture structure.
static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb)
static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
static const uint8_t * align_get_bits(GetBitContext *s)
const uint8_t ff_mpeg4_studio_dc_luma[19][2]
int chroma_qscale
chroma QP
static const uint8_t mpeg4_block_count[4]
int ff_h263_decode_motion(MpegEncContext *s, int pred, int f_code)
static VLC_TYPE vlc_buf[16716][2]
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static VLC studio_chroma_dc
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
uint32_t * mb_type
types and macros are defined in mpegutils.h
int16_t(* dpcm_macroblock)[3][256]
int time_increment_bits
number of bits to represent the fractional part of time
int workaround_bugs
workaround bugs in encoders which cannot be detected automatically
ScanTable inter_scantable
if inter == intra then intra should be used to reduce the cache usage
static void next_start_code_studio(GetBitContext *gb)
static int mpeg_get_qscale(MpegEncContext *s)
int num_sprite_warping_points
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
#define MV_TYPE_8X8
4 vectors (H.263, MPEG-4 4MV)
int b_code
backward MV resolution for B-frames (MPEG-4)
#define INIT_VLC_STATIC_OVERLONG
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
const uint8_t ff_mb_type_b_tab[4][2]
static int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, int n, int coded, int intra, int rvlc)
Decode a block.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators...
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define INTRA_MCBPC_VLC_BITS
uint16_t pb_time
time distance between the last b and p,s,i frame