34 #define SPRITE_TRAJ_VLC_BITS 6
36 #define MB_TYPE_B_VLC_BITS 4
57 int16_t *ac_val, *ac_val1;
69 if (s->
mb_x == 0 || s->
qscale == qscale_table[xy] ||
72 for (i = 1; i < 8; i++)
76 for (i = 1; i < 8; i++)
84 if (s->
mb_y == 0 || s->
qscale == qscale_table[xy] ||
87 for (i = 1; i < 8; i++)
91 for (i = 1; i < 8; i++)
97 for (i = 1; i < 8; i++)
101 for (i = 1; i < 8; i++)
128 v |= 0x7F >> (7 - (bits_count & 7));
140 for (len = 0; len < 32; len++)
163 int min_ab, i, w2, h2, w3, h3;
164 int sprite_ref[4][2];
165 int virtual_ref[2][2];
168 const int vop_ref[4][2] = { { 0, 0 }, { s->
width, 0 },
170 int d[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
172 if (w <= 0 || h <= 0)
197 while ((1 << alpha) < w)
199 while ((1 << beta) < h)
206 sprite_ref[0][0] = a * vop_ref[0][0] + d[0][0];
207 sprite_ref[0][1] = a * vop_ref[0][1] + d[0][1];
208 sprite_ref[1][0] = a * vop_ref[1][0] + d[0][0] + d[1][0];
209 sprite_ref[1][1] = a * vop_ref[1][1] + d[0][1] + d[1][1];
210 sprite_ref[2][0] = a * vop_ref[2][0] + d[0][0] + d[2][0];
211 sprite_ref[2][1] = a * vop_ref[2][1] + d[0][1] + d[2][1];
213 sprite_ref[0][0] = (a >> 1) * (2 * vop_ref[0][0] + d[0][0]);
214 sprite_ref[0][1] = (a >> 1) * (2 * vop_ref[0][1] + d[0][1]);
215 sprite_ref[1][0] = (a >> 1) * (2 * vop_ref[1][0] + d[0][0] + d[1][0]);
216 sprite_ref[1][1] = (a >> 1) * (2 * vop_ref[1][1] + d[0][1] + d[1][1]);
217 sprite_ref[2][0] = (a >> 1) * (2 * vop_ref[2][0] + d[0][0] + d[2][0]);
218 sprite_ref[2][1] = (a >> 1) * (2 * vop_ref[2][1] + d[0][1] + d[2][1]);
228 virtual_ref[0][0] = 16 * (vop_ref[0][0] + w2) +
230 (r * sprite_ref[0][0] - 16 * vop_ref[0][0]) +
231 w2 * (r * sprite_ref[1][0] - 16 * vop_ref[1][0])), w);
232 virtual_ref[0][1] = 16 * vop_ref[0][1] +
234 (r * sprite_ref[0][1] - 16 * vop_ref[0][1]) +
235 w2 * (r * sprite_ref[1][1] - 16 * vop_ref[1][1])), w);
236 virtual_ref[1][0] = 16 * vop_ref[0][0] +
237 ROUNDED_DIV(((h - h2) * (r * sprite_ref[0][0] - 16 * vop_ref[0][0]) +
238 h2 * (r * sprite_ref[2][0] - 16 * vop_ref[2][0])), h);
239 virtual_ref[1][1] = 16 * (vop_ref[0][1] + h2) +
240 ROUNDED_DIV(((h - h2) * (r * sprite_ref[0][1] - 16 * vop_ref[0][1]) +
241 h2 * (r * sprite_ref[2][1] - 16 * vop_ref[2][1])), h);
257 s->
sprite_offset[0][0] = sprite_ref[0][0] - a * vop_ref[0][0];
258 s->
sprite_offset[0][1] = sprite_ref[0][1] - a * vop_ref[0][1];
259 s->
sprite_offset[1][0] = ((sprite_ref[0][0] >> 1) | (sprite_ref[0][0] & 1)) -
260 a * (vop_ref[0][0] / 2);
261 s->
sprite_offset[1][1] = ((sprite_ref[0][1] >> 1) | (sprite_ref[0][1] & 1)) -
262 a * (vop_ref[0][1] / 2);
271 s->
sprite_offset[0][0] = (sprite_ref[0][0] << (alpha + rho)) +
272 (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
274 (r * sprite_ref[0][1] - virtual_ref[0][1]) *
275 (-vop_ref[0][1]) + (1 << (alpha + rho - 1));
276 s->
sprite_offset[0][1] = (sprite_ref[0][1] << (alpha + rho)) +
277 (-r * sprite_ref[0][1] + virtual_ref[0][1]) *
279 (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
280 (-vop_ref[0][1]) + (1 << (alpha + rho - 1));
281 s->
sprite_offset[1][0] = ((-r * sprite_ref[0][0] + virtual_ref[0][0]) *
282 (-2 * vop_ref[0][0] + 1) +
283 (r * sprite_ref[0][1] - virtual_ref[0][1]) *
284 (-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
285 sprite_ref[0][0] - 16 * w2 + (1 << (alpha + rho + 1)));
286 s->
sprite_offset[1][1] = ((-r * sprite_ref[0][1] + virtual_ref[0][1]) *
287 (-2 * vop_ref[0][0] + 1) +
288 (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
289 (-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
290 sprite_ref[0][1] - 16 * w2 + (1 << (alpha + rho + 1)));
291 s->
sprite_delta[0][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]);
292 s->
sprite_delta[0][1] = (+r * sprite_ref[0][1] - virtual_ref[0][1]);
293 s->
sprite_delta[1][0] = (-r * sprite_ref[0][1] + virtual_ref[0][1]);
294 s->
sprite_delta[1][1] = (-r * sprite_ref[0][0] + virtual_ref[0][0]);
300 min_ab =
FFMIN(alpha, beta);
303 s->
sprite_offset[0][0] = (sprite_ref[0][0] << (alpha + beta + rho - min_ab)) +
304 (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
305 h3 * (-vop_ref[0][0]) +
306 (-r * sprite_ref[0][0] + virtual_ref[1][0]) *
307 w3 * (-vop_ref[0][1]) +
308 (1 << (alpha + beta + rho - min_ab - 1));
309 s->
sprite_offset[0][1] = (sprite_ref[0][1] << (alpha + beta + rho - min_ab)) +
310 (-r * sprite_ref[0][1] + virtual_ref[0][1]) *
311 h3 * (-vop_ref[0][0]) +
312 (-r * sprite_ref[0][1] + virtual_ref[1][1]) *
313 w3 * (-vop_ref[0][1]) +
314 (1 << (alpha + beta + rho - min_ab - 1));
315 s->
sprite_offset[1][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
316 h3 * (-2 * vop_ref[0][0] + 1) +
317 (-r * sprite_ref[0][0] + virtual_ref[1][0]) *
318 w3 * (-2 * vop_ref[0][1] + 1) + 2 * w2 * h3 *
319 r * sprite_ref[0][0] - 16 * w2 * h3 +
320 (1 << (alpha + beta + rho - min_ab + 1));
321 s->
sprite_offset[1][1] = (-r * sprite_ref[0][1] + virtual_ref[0][1]) *
322 h3 * (-2 * vop_ref[0][0] + 1) +
323 (-r * sprite_ref[0][1] + virtual_ref[1][1]) *
324 w3 * (-2 * vop_ref[0][1] + 1) + 2 * w2 * h3 *
325 r * sprite_ref[0][1] - 16 * w2 * h3 +
326 (1 << (alpha + beta + rho - min_ab + 1));
327 s->
sprite_delta[0][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]) * h3;
328 s->
sprite_delta[0][1] = (-r * sprite_ref[0][0] + virtual_ref[1][0]) * w3;
329 s->
sprite_delta[1][0] = (-r * sprite_ref[0][1] + virtual_ref[0][1]) * h3;
330 s->
sprite_delta[1][1] = (-r * sprite_ref[0][1] + virtual_ref[1][1]) * w3;
355 for (i = 0; i < 2; i++) {
377 int header_extension = 0, mb_num,
len;
383 for (len = 0; len < 32; len++)
398 if (mb_num >= s->
mb_num) {
400 "illegal mb_num in video packet (%d %d) \n", mb_num, s->
mb_num);
404 int mb_x = 0, mb_y = 0;
429 if (header_extension) {
435 check_marker(&s->
gb,
"before time_increment in video packed header");
437 check_marker(&s->
gb,
"before vop_coding_type in video packed header");
458 "Error, video packet header damaged (f_code=0)\n");
464 "Error, video packet header damaged (b_code=0)\n");
481 int x, y, mb_v, sum, dx, dy, shift;
498 dy -= 1 << (shift + a + 1);
500 dx -= 1 << (shift + a + 1);
504 for (y = 0; y < 16; y++) {
509 for (x = 0; x < 16; x++) {
540 if (code < 0 || code > 9 ) {
553 level =
get_bits(&s->
gb, code - 1) + (1 << (code - 1));
555 level = -
get_bits(&s->
gb, code - 1) - (1 << (code - 1));
582 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
608 "cbpc corrupted at %d %d\n", s->
mb_x, s->
mb_y);
623 for (i = 0; i < 6; i++) {
628 "DC corrupted at %d %d\n", s->
mb_x, s->
mb_y);
637 int mx, my, pred_x, pred_y,
bits;
647 if (bits & 0x10000) {
680 "cbpc corrupted at %d %d\n", s->
mb_x, s->
mb_y);
712 if ((cbpc & 16) == 0) {
746 for (i = 0; i < 4; i++) {
775 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
794 "cbpy corrupted at %d %d\n", s->
mb_x, s->
mb_y);
809 "I cbpy corrupted at %d %d\n", s->
mb_x, s->
mb_y);
817 for (i = 0; i < 6; i++) {
822 "DC corrupted at %d %d\n", s->
mb_x, s->
mb_y);
841 "P cbpy corrupted at %d %d\n", s->
mb_x, s->
mb_y);
854 if (mb_num >= mb_count)
893 "marker missing after first I partition at %d %d\n",
902 "marker missing after first P partition at %d %d\n",
929 int n,
int coded,
int intra,
int rvlc)
932 int level, i, last,
run, qmul, qadd, dc_pred_dir;
971 if (dc_pred_dir == 0)
1002 qadd = (s->
qscale - 1) | 1;
1019 "1. marker bit missing in rvlc esc\n");
1032 "2. marker bit missing in rvlc esc\n");
1046 level = level * qmul + qadd;
1058 cache ^= 0xC0000000;
1060 if (cache & 0x80000000) {
1061 if (cache & 0x40000000) {
1076 "1. marker bit missing in 3. esc\n");
1086 "2. marker bit missing in 3. esc\n");
1094 level = level * qmul + qadd;
1096 level = level * qmul - qadd;
1098 if ((
unsigned)(level + 2048) > 4095) {
1100 if (level > 2560 || level < -2560) {
1102 "|level| overflow in 3. esc, qp=%d\n",
1107 level = level < 0 ? -2048 : 2047;
1117 i += run + rl->
max_run[run >> 7][level / qmul] + 1;
1126 level = level + rl->
max_level[run >> 7][(run - 1) & 63] * qmul;
1140 "ac-tex damaged at %d %d\n", s->
mb_x, s->
mb_y);
1144 block[scan_table[i]] =
level;
1148 block[scan_table[i]] =
level;
1190 for (i = 0; i < 4; i++) {
1198 for (i = 0; i < 6; i++)
1231 for (i = 0; i < 6; i++) {
1234 "texture corrupted at %d %d %d\n",
1261 int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
1263 static int8_t quant_tab[4] = { -1, -2, 1, 2 };
1274 for (i = 0; i < 6; i++)
1302 "cbpc damaged at %d %d\n", s->
mb_x, s->
mb_y);
1305 }
while (cbpc == 20);
1320 cbp = (cbpc & 3) | (cbpy << 2);
1328 if ((cbpc & 16) == 0) {
1337 s->
mv[0][0][0] = mx;
1338 s->
mv[0][0][1] = my;
1351 for (i = 0; i < 2; i++) {
1360 s->
mv[0][i][0] = mx;
1361 s->
mv[0][i][1] = my;
1377 s->
mv[0][0][0] = mx;
1378 s->
mv[0][0][1] = my;
1383 for (i = 0; i < 4; i++) {
1392 s->
mv[0][i][0] = mx;
1393 s->
mv[0][i][1] = my;
1407 for (i = 0; i < 2; i++) {
1422 for (i = 0; i < 6; i++)
1492 s->
mv[0][0][0] = mx;
1495 s->
mv[0][0][1] = my;
1505 s->
mv[1][0][0] = mx;
1508 s->
mv[1][0][1] = my;
1516 for (i = 0; i < 2; i++) {
1520 s->
mv[0][i][0] = mx;
1521 s->
last_mv[0][i][1] = (s->
mv[0][i][1] = my) * 2;
1528 for (i = 0; i < 2; i++) {
1532 s->
mv[1][i][0] = mx;
1533 s->
last_mv[1][i][1] = (s->
mv[1][i][1] = my) * 2;
1557 "I cbpc damaged at %d %d\n", s->
mb_x, s->
mb_y);
1560 }
while (cbpc == 8);
1575 "I cbpy damaged at %d %d\n", s->
mb_x, s->
mb_y);
1578 cbp = (cbpc & 3) | (cbpy << 2);
1590 for (i = 0; i < 6; i++) {
1599 for (i = 0; i < 6; i++) {
1631 int hours, minutes, seconds;
1634 if (time_code & 0x40) {
1635 hours = time_code >> 13;
1636 minutes = time_code >> 7 & 0x3f;
1637 seconds = time_code & 0x3f;
1638 s->
time_base = seconds + 60 * (minutes + 60 * hours);
1649 int profile_and_level_indication;
1651 profile_and_level_indication =
get_bits(gb, 8);
1653 s->
avctx->
profile = (profile_and_level_indication & 0xf0) >> 4;
1654 s->
avctx->
level = (profile_and_level_indication & 0x0f);
1687 int chroma_format =
get_bits(gb, 2);
1749 if (width && height &&
1764 "MPEG4 OBMC not supported (very likely buggy encoder)\n");
1787 "%d sprite_warping_points\n",
1816 for (i = 0; i < 64; i++) {
1830 for (i = 0; i < 64; i++) {
1843 for (; i < 64; i++) {
1853 for (i = 0; i < 64; i++) {
1866 for (; i < 64; i++) {
1883 int estimation_method =
get_bits(gb, 2);
1884 if (estimation_method < 2) {
1899 if (!
check_marker(gb,
"in complexity estimation part 1")) {
1917 if (!
check_marker(gb,
"in complexity estimation part 2")) {
1921 if (estimation_method == 1) {
1927 "Invalid Complexity estimation method %d\n",
1943 if (vo_ver_id != 1) {
1952 "reduced resolution VOP not supported\n");
1961 int h_sampling_factor_n;
1962 int h_sampling_factor_m;
1963 int v_sampling_factor_n;
1964 int v_sampling_factor_m;
1969 h_sampling_factor_n =
get_bits(gb, 5);
1970 h_sampling_factor_m =
get_bits(gb, 5);
1971 v_sampling_factor_n =
get_bits(gb, 5);
1972 v_sampling_factor_m =
get_bits(gb, 5);
1975 if (h_sampling_factor_n == 0 || h_sampling_factor_m == 0 ||
1976 v_sampling_factor_n == 0 || v_sampling_factor_m == 0) {
2001 int ver = 0, build = 0, ver2 = 0, ver3 = 0;
2012 e = sscanf(buf,
"DivX%dBuild%d%c", &ver, &build, &last);
2014 e = sscanf(buf,
"DivX%db%d%c", &ver, &build, &last);
2021 "Invalid and inefficient vfw-avi packed B frames detected\n");
2027 e = sscanf(buf,
"FFmpe%*[^b]b%d", &build) + 3;
2029 e = sscanf(buf,
"FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build);
2031 e = sscanf(buf,
"Lavc%d.%d.%d", &ver, &ver2, &ver3) + 1;
2033 build = (ver << 16) + (ver2 << 8) + ver3;
2036 if (strcmp(buf,
"ffmpeg") == 0)
2043 e = sscanf(buf,
"XviD%d", &build);
2082 int time_incr, time_increment;
2106 "hmm, seems the headers are not complete, trying to guess time_increment_bits\n");
2239 "sprite_brightness_change not supported\n");
2248 "Error, header damaged or not MPEG4 header (qscale=0)\n");
2256 "Error, header damaged or not MPEG4 header (f_code=0)\n");
2269 "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\n",
2287 int load_backward_shape =
get_bits1(gb);
2288 if (load_backward_shape)
2290 "load backward shape isn't supported\n");
2301 "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
2327 unsigned startcode, v;
2351 startcode = ((startcode << 8) | v) & 0xffffffff;
2353 if ((startcode & 0xFFFFFF00) != 0x100)
2358 if (startcode <= 0x11F)
2360 else if (startcode <= 0x12F)
2362 else if (startcode <= 0x13F)
2364 else if (startcode <= 0x15F)
2366 else if (startcode <= 0x1AF)
2368 else if (startcode == 0x1B0)
2370 else if (startcode == 0x1B1)
2372 else if (startcode == 0x1B2)
2374 else if (startcode == 0x1B3)
2376 else if (startcode == 0x1B4)
2378 else if (startcode == 0x1B5)
2380 else if (startcode == 0x1B6)
2382 else if (startcode == 0x1B7)
2384 else if (startcode == 0x1B8)
2386 else if (startcode == 0x1B9)
2388 else if (startcode == 0x1BA)
2390 else if (startcode == 0x1BB)
2392 else if (startcode == 0x1BC)
2394 else if (startcode == 0x1BD)
2396 else if (startcode == 0x1BE)
2398 else if (startcode == 0x1BF)
2400 else if (startcode == 0x1C0)
2402 else if (startcode == 0x1C1)
2404 else if (startcode == 0x1C2)
2406 else if (startcode == 0x1C3)
2408 else if (startcode <= 0x1C5)
2410 else if (startcode <= 0x1FF)
2415 if (startcode >= 0x120 && startcode <= 0x12F) {
2490 "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
2505 int startcode_found = 0;
2507 if (buf_size - current_pos > 5) {
2509 for (i = current_pos; i < buf_size - 3; i++)
2513 buf[i + 3] == 0xB6) {
2514 startcode_found = 1;
2520 startcode_found = 1;
2524 if (startcode_found) {
2527 buf_size - current_pos +
2532 buf_size - current_pos);
2562 static int done = 0;
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 shift [isChroma]
#define FF_PROFILE_MPEG4_SIMPLE
void ff_init_block_index(MpegEncContext *s)
static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define FF_BUG_XVID_ILACE
ScanTable intra_v_scantable
RLTable ff_mpeg4_rl_intra
const uint8_t ff_mpeg4_c_dc_scale_table[32]
int sprite_brightness_change
#define MV_TYPE_FIELD
2 vectors, one per field
const uint8_t * y_dc_scale_table
qscale -> y_dc_scale table
int vol_control_parameters
does the stream contain the low_delay flag, used to workaround buggy encoders
static const AVProfile profiles[]
int sprite_warping_accuracy
int last_mv[2][2][2]
last MV, used for MV prediction in MPEG1 & B-frame MPEG4
av_cold int ff_dct_common_init(MpegEncContext *s)
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 unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static void skip_bits_long(GetBitContext *s, int n)
#define MB_TYPE_B_VLC_BITS
VLC ff_h263_intra_MCBPC_vlc
int resync_marker
time distance of first I -> B, used for interlaced b frames
static int mpeg4_is_resync(MpegEncContext *s)
check if the next stuff is a resync marker or the end.
#define CODEC_CAP_TRUNCATED
uint16_t chroma_intra_matrix[64]
static int mpeg4_decode_gop_header(MpegEncContext *s, GetBitContext *gb)
int16_t(*[3] ac_val)[16]
used for for mpeg4 AC prediction, all 3 arrays must be continuous
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]
int lavc_build
flag for having shown the warning about divxs invalid b frames
uint8_t * bitstream_buffer
#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)
#define FF_PROFILE_MPEG4_SIMPLE_STUDIO
int real_sprite_warping_points
#define FF_ASPECT_EXTENDED
#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE
int padding_bug_score
used to detect the VERY common padding bug in MPEG4
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
int mb_num
number of MBs of a picture
int time_base
time in seconds of last I,P,S Frame
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
#define FF_PROFILE_MPEG4_CORE_SCALABLE
int cplx_estimation_trash_b
#define USES_LIST(a, list)
does this mb use listX, note does not work if subMBs
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...
#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
const uint8_t ff_alternate_vertical_scan[64]
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
#define MV_DIRECT
bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4) ...
#define FF_PROFILE_MPEG4_CORE
static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
#define FF_PROFILE_MPEG4_MAIN
const uint16_t ff_mpeg4_resync_prefix[8]
#define FF_DEBUG_PICT_INFO
const uint16_t ff_sprite_trajectory_tab[15][2]
uint8_t * pred_dir_table
used to store pred_dir for partitioned decoding
Multithreading support functions.
int no_rounding
apply no rounding to motion compensation (MPEG4, msmpeg4, ...) for b-frames rounding mode is always 0...
Picture current_picture
copy of the current picture structure.
#define FF_PROFILE_MPEG4_N_BIT
const uint8_t ff_mpeg4_DCtab_chrom[13][2]
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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
uint8_t idct_permutation[64]
idct input permutation.
int mb_height
number of MBs horizontally & vertically
int codec_tag
internal codec_tag upper case converted from avctx codec_tag
const AVRational ff_h263_pixel_aspect[16]
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)
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
MpegEncContext m
number of bits to represent the fractional part of time
int sprite_offset[2][2]
sprite offset[isChroma][isMVY]
#define ROUNDED_DIV(a, b)
#define FF_BUG_DIRECT_BLOCKSIZE
int16_t * dc_val[3]
used for mpeg4 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.
int stream_codec_tag
internal stream_codec_tag upper case converted from avctx stream_codec_tag
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.
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
int partitioned_frame
is current frame partitioned
int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
Decode the first and second partition.
const uint8_t ff_alternate_horizontal_scan[64]
#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 FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define INTER_MCBPC_VLC_BITS
#define FF_BUG_NO_PADDING
void av_log(void *avcl, int level, const char *fmt,...)
void ff_mpeg4_init_direct_mv(MpegEncContext *s)
const char * name
Name of the codec implementation.
int quarter_sample
1->qpel, 0->half pel ME/MC
int low_delay
no reordering needed / has no b-frames
int(* decode_mb)(struct MpegEncContext *s, int16_t block[6][64])
#define CLOSE_READER(name, gb)
#define INIT_VLC_RL(rl, static_size)
#define CODEC_FLAG_LOW_DELAY
Force low delay.
static int check_marker(GetBitContext *s, const char *msg)
#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.
#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE
int resync_mb_x
x position of last resync marker
int ff_h263_decode_init(AVCodecContext *avctx)
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int sprite_delta[2][2]
sprite_delta [isY][isMVY]
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)
static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *gb)
static const int mb_type_b_map[4]
#define CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
const uint8_t ff_mpeg4_y_dc_scale_table[32]
static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx)
Decode first partition.
void(* clear_blocks)(int16_t *blocks)
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.
#define MB_TYPE_INTERLACED
int16_t(*[2] motion_val)[2]
#define FF_PROFILE_MPEG4_ADVANCED_CORE
enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]
unsigned int allocated_bitstream_buffer_size
int use_intra_dc_vlc
QP above whch the ac VLC should be used for intra dc.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
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
const int16_t ff_mpeg4_default_non_intra_matrix[64]
uint8_t * mbintra_table
used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
#define FF_PROFILE_MPEG4_HYBRID
#define FF_BUG_QPEL_CHROMA
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
RL_VLC_ELEM * rl_vlc[32]
decoding only
#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
if(ac->has_optimized_func)
int * mb_index2xy
mb_index -> mb_x + mb_y*mb_stride
#define MV_TYPE_16X16
1 vector for the whole mb
int first_slice_line
used in mpeg4 too to handle resync markers
static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
decode partition C of one MB.
#define AV_LOG_INFO
Standard information.
uint16_t inter_matrix[64]
main external API structure.
int cplx_estimation_trash_i
#define AV_CPU_FLAG_MMX
standard MMX
static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE
static void close(AVCodecParserContext *s)
ScanTable intra_scantable
int height
picture size. must be a multiple of 16
static int get_xbits(GetBitContext *s, int n)
read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
#define OPEN_READER(name, gb)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
#define SLICE_END
end marker found
int data_partitioning
data partitioning flag from header
int showed_packed_warning
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
static int mpeg4_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
ScanTable intra_h_scantable
static void skip_bits(GetBitContext *s, int n)
static const AVProfile mpeg4_video_profiles[]
uint8_t * cbp_table
used to store cbp, ac_pred for partitioned decoding
int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb)
Decode mpeg4 headers.
#define GET_CACHE(name, gb)
DSPContext dsp
pointers for accelerated dsp functions
#define FF_PROFILE_MPEG4_ADVANCED_CODING
#define SKIP_CACHE(name, gb, num)
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
const int16_t ff_mpeg4_default_intra_matrix[64]
int allocate_progress
Whether to allocate progress for frame threading.
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)
#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
const uint8_t ff_mpeg4_dc_threshold[8]
#define FF_BUG_AUTODETECT
autodetection
int h263_pred
use mpeg4/h263 ac/dc predictions
int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s)
uint16_t pb_field_time
like above, just for interlaced
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
Picture * next_picture_ptr
pointer to the next picture (for bidir pred)
struct AVCodecContext * avctx
#define SHOW_SBITS(name, gb, num)
static VLC sprite_trajectory
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
common internal api header.
const uint8_t ff_zigzag_direct[64]
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count)
decode second partition.
static av_cold int init(AVCodecParserContext *s)
int ff_h263_decode_end(AVCodecContext *avctx)
#define FF_DEBUG_STARTCODE
int rvlc
could this stream contain resync markers
struct AVCodecInternal * internal
Private context used for internal data.
int resync_mb_y
y position of last resync marker
av_cold void ff_init_rl(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
int16_t(* block)[64]
points to one of the following blocks
VLC_TYPE(* table)[2]
code, bits
Picture next_picture
copy of the next picture structure.
static const uint8_t * align_get_bits(GetBitContext *s)
static int mpeg4_decode_profile_level(MpegEncContext *s, GetBitContext *gb)
int chroma_qscale
chroma QP
int ff_h263_decode_motion(MpegEncContext *s, int pred, int f_code)
int flags
AVCodecContext.flags (HQ, MV4, ...)
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
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 tha cache usage
#define FRAME_SKIPPED
return value for header parsers if frame is not coded
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
int num_sprite_warping_points
sprite trajectory points
#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE
#define MV_TYPE_8X8
4 vectors (h263, mpeg4 4MV)
int b_code
backward MV resolution for B Frames (mpeg4)
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 FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE
#define INTRA_MCBPC_VLC_BITS
uint16_t pb_time
time distance between the last b and p,s,i frame