Go to the documentation of this file.
23 #define UNCHECKED_BITSTREAM_READER 1
25 #include "config_components.h"
55 #define SPRITE_TRAJ_VLC_BITS 6
57 #define MB_TYPE_B_VLC_BITS 4
58 #define STUDIO_INTRA_BITS 9
77 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
78 uint8_t *
const *ref_picture)
81 int src_x, src_y, motion_x, motion_y;
82 ptrdiff_t
offset, linesize, uvlinesize;
85 motion_x =
ctx->sprite_offset[0][0];
86 motion_y =
ctx->sprite_offset[0][1];
87 src_x =
s->mb_x * 16 + (motion_x >> (
ctx->sprite_warping_accuracy + 1));
88 src_y =
s->mb_y * 16 + (motion_y >> (
ctx->sprite_warping_accuracy + 1));
89 motion_x *= 1 << (3 -
ctx->sprite_warping_accuracy);
90 motion_y *= 1 << (3 -
ctx->sprite_warping_accuracy);
91 src_x =
av_clip(src_x, -16,
s->width);
92 if (src_x ==
s->width)
94 src_y =
av_clip(src_y, -16,
s->height);
95 if (src_y ==
s->height)
98 linesize =
s->linesize;
99 uvlinesize =
s->uvlinesize;
101 ptr = ref_picture[0] + src_y * linesize + src_x;
103 if ((
unsigned)src_x >=
FFMAX(
s->h_edge_pos - 17, 0) ||
104 (
unsigned)src_y >=
FFMAX(
s->v_edge_pos - 17, 0)) {
105 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
109 s->h_edge_pos,
s->v_edge_pos);
110 ptr =
s->sc.edge_emu_buffer;
113 if ((motion_x | motion_y) & 7) {
114 ctx->mdsp.gmc1(dest_y, ptr, linesize, 16,
115 motion_x & 15, motion_y & 15, 128 -
s->no_rounding);
116 ctx->mdsp.gmc1(dest_y + 8, ptr + 8, linesize, 16,
117 motion_x & 15, motion_y & 15, 128 -
s->no_rounding);
121 dxy = ((motion_x >> 3) & 1) | ((motion_y >> 2) & 2);
122 if (
s->no_rounding) {
123 s->hdsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
125 s->hdsp.put_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
132 motion_x =
ctx->sprite_offset[1][0];
133 motion_y =
ctx->sprite_offset[1][1];
134 src_x =
s->mb_x * 8 + (motion_x >> (
ctx->sprite_warping_accuracy + 1));
135 src_y =
s->mb_y * 8 + (motion_y >> (
ctx->sprite_warping_accuracy + 1));
136 motion_x *= 1 << (3 -
ctx->sprite_warping_accuracy);
137 motion_y *= 1 << (3 -
ctx->sprite_warping_accuracy);
138 src_x =
av_clip(src_x, -8,
s->width >> 1);
139 if (src_x ==
s->width >> 1)
141 src_y =
av_clip(src_y, -8,
s->height >> 1);
142 if (src_y ==
s->height >> 1)
145 offset = (src_y * uvlinesize) + src_x;
146 ptr = ref_picture[1] +
offset;
147 if ((
unsigned)src_x >=
FFMAX((
s->h_edge_pos >> 1) - 9, 0) ||
148 (unsigned)src_y >=
FFMAX((
s->v_edge_pos >> 1) - 9, 0)) {
149 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
150 uvlinesize, uvlinesize,
153 s->h_edge_pos >> 1,
s->v_edge_pos >> 1);
154 ptr =
s->sc.edge_emu_buffer;
157 ctx->mdsp.gmc1(dest_cb, ptr, uvlinesize, 8,
158 motion_x & 15, motion_y & 15, 128 -
s->no_rounding);
160 ptr = ref_picture[2] +
offset;
162 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
163 uvlinesize, uvlinesize,
166 s->h_edge_pos >> 1,
s->v_edge_pos >> 1);
167 ptr =
s->sc.edge_emu_buffer;
169 ctx->mdsp.gmc1(dest_cr, ptr, uvlinesize, 8,
170 motion_x & 15, motion_y & 15, 128 -
s->no_rounding);
174 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
175 uint8_t *
const *ref_picture)
178 int linesize, uvlinesize;
179 const int a =
ctx->sprite_warping_accuracy;
182 linesize =
s->linesize;
183 uvlinesize =
s->uvlinesize;
185 ptr = ref_picture[0];
187 ox =
ctx->sprite_offset[0][0] +
ctx->sprite_delta[0][0] *
s->mb_x * 16 +
188 ctx->sprite_delta[0][1] *
s->mb_y * 16;
189 oy =
ctx->sprite_offset[0][1] +
ctx->sprite_delta[1][0] *
s->mb_x * 16 +
190 ctx->sprite_delta[1][1] *
s->mb_y * 16;
192 ctx->mdsp.gmc(dest_y, ptr, linesize, 16,
194 ctx->sprite_delta[0][0],
ctx->sprite_delta[0][1],
195 ctx->sprite_delta[1][0],
ctx->sprite_delta[1][1],
196 a + 1, (1 << (2 *
a + 1)) -
s->no_rounding,
197 s->h_edge_pos,
s->v_edge_pos);
198 ctx->mdsp.gmc(dest_y + 8, ptr, linesize, 16,
199 ox +
ctx->sprite_delta[0][0] * 8,
200 oy +
ctx->sprite_delta[1][0] * 8,
201 ctx->sprite_delta[0][0],
ctx->sprite_delta[0][1],
202 ctx->sprite_delta[1][0],
ctx->sprite_delta[1][1],
203 a + 1, (1 << (2 *
a + 1)) -
s->no_rounding,
204 s->h_edge_pos,
s->v_edge_pos);
209 ox =
ctx->sprite_offset[1][0] +
ctx->sprite_delta[0][0] *
s->mb_x * 8 +
210 ctx->sprite_delta[0][1] *
s->mb_y * 8;
211 oy =
ctx->sprite_offset[1][1] +
ctx->sprite_delta[1][0] *
s->mb_x * 8 +
212 ctx->sprite_delta[1][1] *
s->mb_y * 8;
214 ptr = ref_picture[1];
215 ctx->mdsp.gmc(dest_cb, ptr, uvlinesize, 8,
217 ctx->sprite_delta[0][0],
ctx->sprite_delta[0][1],
218 ctx->sprite_delta[1][0],
ctx->sprite_delta[1][1],
219 a + 1, (1 << (2 *
a + 1)) -
s->no_rounding,
220 (
s->h_edge_pos + 1) >> 1, (
s->v_edge_pos + 1) >> 1);
222 ptr = ref_picture[2];
223 ctx->mdsp.gmc(dest_cr, ptr, uvlinesize, 8,
225 ctx->sprite_delta[0][0],
ctx->sprite_delta[0][1],
226 ctx->sprite_delta[1][0],
ctx->sprite_delta[1][1],
227 a + 1, (1 << (2 *
a + 1)) -
s->no_rounding,
228 (
s->h_edge_pos + 1) >> 1, (
s->v_edge_pos + 1) >> 1);
232 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
233 uint8_t *
const *ref_picture)
237 if (
ctx->real_sprite_warping_points == 1) {
247 uint8_t *dest_cr,
int block_size,
int uvlinesize,
248 int dct_linesize,
int dct_offset)
251 const int act_block_size = block_size * 2;
253 if (
ctx->dpcm_direction == 0) {
254 s->idsp.idct_put(dest_y, dct_linesize, (int16_t*)
ctx->block32[0]);
255 s->idsp.idct_put(dest_y + act_block_size, dct_linesize, (int16_t*)
ctx->block32[1]);
256 s->idsp.idct_put(dest_y + dct_offset, dct_linesize, (int16_t*)
ctx->block32[2]);
257 s->idsp.idct_put(dest_y + dct_offset + act_block_size, dct_linesize, (int16_t*)
ctx->block32[3]);
259 dct_linesize = uvlinesize <<
s->interlaced_dct;
260 dct_offset =
s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
262 s->idsp.idct_put(dest_cb, dct_linesize, (int16_t*)
ctx->block32[4]);
263 s->idsp.idct_put(dest_cr, dct_linesize, (int16_t*)
ctx->block32[5]);
264 s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, (int16_t*)
ctx->block32[6]);
265 s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, (int16_t*)
ctx->block32[7]);
266 if (!
s->chroma_x_shift){
267 s->idsp.idct_put(dest_cb + act_block_size, dct_linesize, (int16_t*)
ctx->block32[8]);
268 s->idsp.idct_put(dest_cr + act_block_size, dct_linesize, (int16_t*)
ctx->block32[9]);
269 s->idsp.idct_put(dest_cb + act_block_size + dct_offset, dct_linesize, (int16_t*)
ctx->block32[10]);
270 s->idsp.idct_put(dest_cr + act_block_size + dct_offset, dct_linesize, (int16_t*)
ctx->block32[11]);
272 }
else if (
ctx->dpcm_direction == 1) {
273 uint16_t *dest_pcm[3] = {(uint16_t*)dest_y, (uint16_t*)dest_cb, (uint16_t*)dest_cr};
274 int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
275 for (
int i = 0;
i < 3;
i++) {
276 const uint16_t *
src =
ctx->dpcm_macroblock[
i];
277 int vsub =
i ?
s->chroma_y_shift : 0;
278 int hsub =
i ?
s->chroma_x_shift : 0;
281 for (
int h = 0;
h < (16 >> (vsub +
lowres));
h++){
283 dest_pcm[
i][
w] =
src[idx];
284 dest_pcm[
i] += linesize[
i] / 2;
289 uint16_t *dest_pcm[3] = {(uint16_t*)dest_y, (uint16_t*)dest_cb, (uint16_t*)dest_cr};
290 int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
292 for (
int i = 0;
i < 3;
i++) {
293 const uint16_t *
src =
ctx->dpcm_macroblock[
i];
294 int vsub =
i ?
s->chroma_y_shift : 0;
295 int hsub =
i ?
s->chroma_x_shift : 0;
298 dest_pcm[
i] += (linesize[
i] / 2) * ((16 >> vsub) - 1);
299 for (
int h = (16 >> (vsub +
lowres)) - 1;
h >= 0;
h--){
301 dest_pcm[
i][
w] =
src[idx];
303 dest_pcm[
i] -= linesize[
i] / 2;
317 int16_t *ac_val, *ac_val1;
318 int8_t *
const qscale_table =
s->current_picture.qscale_table;
321 ac_val = &
s->ac_val[0][0][0] +
s->block_index[n] * 16;
325 const int xy =
s->mb_x - 1 +
s->mb_y *
s->mb_stride;
329 if (
s->mb_x == 0 ||
s->qscale == qscale_table[xy] ||
332 for (
i = 1;
i < 8;
i++)
333 block[
s->idsp.idct_permutation[
i << 3]] += ac_val[
i];
336 for (
i = 1;
i < 8;
i++)
337 block[
s->idsp.idct_permutation[
i << 3]] +=
ROUNDED_DIV(ac_val[
i] * qscale_table[xy],
s->qscale);
340 const int xy =
s->mb_x +
s->mb_y *
s->mb_stride -
s->mb_stride;
342 ac_val -= 16 *
s->block_wrap[n];
344 if (
s->mb_y == 0 ||
s->qscale == qscale_table[xy] ||
347 for (
i = 1;
i < 8;
i++)
348 block[
s->idsp.idct_permutation[
i]] += ac_val[
i + 8];
351 for (
i = 1;
i < 8;
i++)
357 for (
i = 1;
i < 8;
i++)
358 ac_val1[
i] =
block[
s->idsp.idct_permutation[
i << 3]];
362 ac_val1[8 +
i] =
block[
s->idsp.idct_permutation[
i]];
380 (v >> (8 -
s->pict_type) != 1) ||
s->partitioned_frame)
383 bits_count += 8 +
s->pict_type;
387 if (bits_count + 8 >=
s->gb.size_in_bits) {
389 v |= 0x7F >> (7 - (bits_count & 7));
394 static const uint16_t mpeg4_resync_prefix[8] = {
395 0x7F00, 0x7E00, 0x7C00, 0x7800, 0x7000, 0x6000, 0x4000, 0x0000
398 if (v == mpeg4_resync_prefix[bits_count & 7]) {
400 int mb_num_bits =
av_log2(
s->mb_num - 1) + 1;
411 if (!mb_num || mb_num >
s->mb_num ||
get_bits_count(&
s->gb)+6 >
s->gb.size_in_bits)
426 int a = 2 <<
ctx->sprite_warping_accuracy;
427 int rho = 3 -
ctx->sprite_warping_accuracy;
433 int min_ab,
i, w2, h2, w3, h3;
434 int sprite_ref[4][2];
435 int virtual_ref[2][2];
436 int64_t sprite_offset[2][2];
437 int64_t sprite_delta[2][2];
440 const int vop_ref[4][2] = { { 0, 0 }, {
s->width, 0 },
441 { 0,
s->height }, {
s->width,
s->height } };
442 int d[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
444 if (
w <= 0 ||
h <= 0)
447 for (
i = 0;
i <
ctx->num_sprite_warping_points;
i++) {
455 if (!(
ctx->divx_version == 500 &&
ctx->divx_build == 413))
463 ctx->sprite_traj[
i][0] =
d[
i][0] = x;
464 ctx->sprite_traj[
i][1] =
d[
i][1] = y;
467 ctx->sprite_traj[
i][0] =
ctx->sprite_traj[
i][1] = 0;
471 while ((1 << beta) <
h)
477 if (
ctx->divx_version == 500 &&
ctx->divx_build == 413) {
478 sprite_ref[0][0] =
a * vop_ref[0][0] +
d[0][0];
479 sprite_ref[0][1] =
a * vop_ref[0][1] +
d[0][1];
480 sprite_ref[1][0] =
a * vop_ref[1][0] +
d[0][0] +
d[1][0];
481 sprite_ref[1][1] =
a * vop_ref[1][1] +
d[0][1] +
d[1][1];
482 sprite_ref[2][0] =
a * vop_ref[2][0] +
d[0][0] +
d[2][0];
483 sprite_ref[2][1] =
a * vop_ref[2][1] +
d[0][1] +
d[2][1];
485 sprite_ref[0][0] = (
a >> 1) * (2 * vop_ref[0][0] +
d[0][0]);
486 sprite_ref[0][1] = (
a >> 1) * (2 * vop_ref[0][1] +
d[0][1]);
487 sprite_ref[1][0] = (
a >> 1) * (2 * vop_ref[1][0] +
d[0][0] +
d[1][0]);
488 sprite_ref[1][1] = (
a >> 1) * (2 * vop_ref[1][1] +
d[0][1] +
d[1][1]);
489 sprite_ref[2][0] = (
a >> 1) * (2 * vop_ref[2][0] +
d[0][0] +
d[2][0]);
490 sprite_ref[2][1] = (
a >> 1) * (2 * vop_ref[2][1] +
d[0][1] +
d[2][1]);
500 virtual_ref[0][0] = 16 * (vop_ref[0][0] + w2) +
502 (
r * sprite_ref[0][0] - 16LL * vop_ref[0][0]) +
503 w2 * (
r * sprite_ref[1][0] - 16LL * vop_ref[1][0])),
w);
504 virtual_ref[0][1] = 16 * vop_ref[0][1] +
506 (
r * sprite_ref[0][1] - 16LL * vop_ref[0][1]) +
507 w2 * (
r * sprite_ref[1][1] - 16LL * vop_ref[1][1])),
w);
508 virtual_ref[1][0] = 16 * vop_ref[0][0] +
509 ROUNDED_DIV(((
h - h2) * (
r * sprite_ref[0][0] - 16LL * vop_ref[0][0]) +
510 h2 * (
r * sprite_ref[2][0] - 16LL * vop_ref[2][0])),
h);
511 virtual_ref[1][1] = 16 * (vop_ref[0][1] + h2) +
512 ROUNDED_DIV(((
h - h2) * (
r * sprite_ref[0][1] - 16LL * vop_ref[0][1]) +
513 h2 * (
r * sprite_ref[2][1] - 16LL * vop_ref[2][1])),
h);
515 switch (
ctx->num_sprite_warping_points) {
517 sprite_offset[0][0] =
518 sprite_offset[0][1] =
519 sprite_offset[1][0] =
520 sprite_offset[1][1] = 0;
521 sprite_delta[0][0] =
a;
523 sprite_delta[1][0] = 0;
524 sprite_delta[1][1] =
a;
525 ctx->sprite_shift[0] =
526 ctx->sprite_shift[1] = 0;
529 sprite_offset[0][0] = sprite_ref[0][0] -
a * vop_ref[0][0];
530 sprite_offset[0][1] = sprite_ref[0][1] -
a * vop_ref[0][1];
531 sprite_offset[1][0] = ((sprite_ref[0][0] >> 1) | (sprite_ref[0][0] & 1)) -
532 a * (vop_ref[0][0] / 2);
533 sprite_offset[1][1] = ((sprite_ref[0][1] >> 1) | (sprite_ref[0][1] & 1)) -
534 a * (vop_ref[0][1] / 2);
535 sprite_delta[0][0] =
a;
537 sprite_delta[1][0] = 0;
538 sprite_delta[1][1] =
a;
539 ctx->sprite_shift[0] =
540 ctx->sprite_shift[1] = 0;
543 sprite_offset[0][0] = ((int64_t) sprite_ref[0][0] * (1 <<
alpha + rho)) +
544 ((int64_t) -
r * sprite_ref[0][0] + virtual_ref[0][0]) *
545 ((int64_t) -vop_ref[0][0]) +
546 ((int64_t)
r * sprite_ref[0][1] - virtual_ref[0][1]) *
547 ((int64_t) -vop_ref[0][1]) + (1 << (
alpha + rho - 1));
548 sprite_offset[0][1] = ((int64_t) sprite_ref[0][1] * (1 <<
alpha + rho)) +
549 ((int64_t) -
r * sprite_ref[0][1] + virtual_ref[0][1]) *
550 ((int64_t) -vop_ref[0][0]) +
551 ((int64_t) -
r * sprite_ref[0][0] + virtual_ref[0][0]) *
552 ((int64_t) -vop_ref[0][1]) + (1 << (
alpha + rho - 1));
553 sprite_offset[1][0] = (((int64_t)-
r * sprite_ref[0][0] + virtual_ref[0][0]) *
554 ((int64_t)-2 * vop_ref[0][0] + 1) +
555 ((int64_t)
r * sprite_ref[0][1] - virtual_ref[0][1]) *
556 ((int64_t)-2 * vop_ref[0][1] + 1) + 2 * w2 *
r *
557 (int64_t) sprite_ref[0][0] - 16 * w2 + (1 << (
alpha + rho + 1)));
558 sprite_offset[1][1] = (((int64_t)-
r * sprite_ref[0][1] + virtual_ref[0][1]) *
559 ((int64_t)-2 * vop_ref[0][0] + 1) +
560 ((int64_t)-
r * sprite_ref[0][0] + virtual_ref[0][0]) *
561 ((int64_t)-2 * vop_ref[0][1] + 1) + 2 * w2 *
r *
562 (int64_t) sprite_ref[0][1] - 16 * w2 + (1 << (
alpha + rho + 1)));
563 sprite_delta[0][0] = (-
r * sprite_ref[0][0] + virtual_ref[0][0]);
564 sprite_delta[0][1] = (+
r * sprite_ref[0][1] - virtual_ref[0][1]);
565 sprite_delta[1][0] = (-
r * sprite_ref[0][1] + virtual_ref[0][1]);
566 sprite_delta[1][1] = (-
r * sprite_ref[0][0] + virtual_ref[0][0]);
569 ctx->sprite_shift[1] =
alpha + rho + 2;
575 sprite_offset[0][0] = ((int64_t)sprite_ref[0][0] * (1 << (
alpha + beta + rho - min_ab))) +
576 ((int64_t)-
r * sprite_ref[0][0] + virtual_ref[0][0]) * h3 * (-vop_ref[0][0]) +
577 ((int64_t)-
r * sprite_ref[0][0] + virtual_ref[1][0]) * w3 * (-vop_ref[0][1]) +
578 ((int64_t)1 << (
alpha + beta + rho - min_ab - 1));
579 sprite_offset[0][1] = ((int64_t)sprite_ref[0][1] * (1 << (
alpha + beta + rho - min_ab))) +
580 ((int64_t)-
r * sprite_ref[0][1] + virtual_ref[0][1]) * h3 * (-vop_ref[0][0]) +
581 ((int64_t)-
r * sprite_ref[0][1] + virtual_ref[1][1]) * w3 * (-vop_ref[0][1]) +
582 ((int64_t)1 << (
alpha + beta + rho - min_ab - 1));
583 sprite_offset[1][0] = ((int64_t)-
r * sprite_ref[0][0] + virtual_ref[0][0]) * h3 * (-2 * vop_ref[0][0] + 1) +
584 ((int64_t)-
r * sprite_ref[0][0] + virtual_ref[1][0]) * w3 * (-2 * vop_ref[0][1] + 1) +
585 (int64_t)2 * w2 * h3 *
r * sprite_ref[0][0] - 16 * w2 * h3 +
586 ((int64_t)1 << (
alpha + beta + rho - min_ab + 1));
587 sprite_offset[1][1] = ((int64_t)-
r * sprite_ref[0][1] + virtual_ref[0][1]) * h3 * (-2 * vop_ref[0][0] + 1) +
588 ((int64_t)-
r * sprite_ref[0][1] + virtual_ref[1][1]) * w3 * (-2 * vop_ref[0][1] + 1) +
589 (int64_t)2 * w2 * h3 *
r * sprite_ref[0][1] - 16 * w2 * h3 +
590 ((int64_t)1 << (
alpha + beta + rho - min_ab + 1));
591 sprite_delta[0][0] = (-
r * (int64_t)sprite_ref[0][0] + virtual_ref[0][0]) * h3;
592 sprite_delta[0][1] = (-
r * (int64_t)sprite_ref[0][0] + virtual_ref[1][0]) * w3;
593 sprite_delta[1][0] = (-
r * (int64_t)sprite_ref[0][1] + virtual_ref[0][1]) * h3;
594 sprite_delta[1][1] = (-
r * (int64_t)sprite_ref[0][1] + virtual_ref[1][1]) * w3;
596 ctx->sprite_shift[0] =
alpha + beta + rho - min_ab;
597 ctx->sprite_shift[1] =
alpha + beta + rho - min_ab + 2;
601 if (sprite_delta[0][0] ==
a <<
ctx->sprite_shift[0] &&
602 sprite_delta[0][1] == 0 &&
603 sprite_delta[1][0] == 0 &&
604 sprite_delta[1][1] ==
a <<
ctx->sprite_shift[0]) {
605 sprite_offset[0][0] >>=
ctx->sprite_shift[0];
606 sprite_offset[0][1] >>=
ctx->sprite_shift[0];
607 sprite_offset[1][0] >>=
ctx->sprite_shift[1];
608 sprite_offset[1][1] >>=
ctx->sprite_shift[1];
609 sprite_delta[0][0] =
a;
610 sprite_delta[0][1] = 0;
611 sprite_delta[1][0] = 0;
612 sprite_delta[1][1] =
a;
613 ctx->sprite_shift[0] = 0;
614 ctx->sprite_shift[1] = 0;
615 ctx->real_sprite_warping_points = 1;
617 int shift_y = 16 -
ctx->sprite_shift[0];
618 int shift_c = 16 -
ctx->sprite_shift[1];
620 for (
i = 0;
i < 2;
i++) {
621 if (shift_c < 0 || shift_y < 0 ||
622 FFABS( sprite_offset[0][
i]) >= INT_MAX >> shift_y ||
623 FFABS( sprite_offset[1][
i]) >= INT_MAX >> shift_c ||
624 FFABS( sprite_delta[0][
i]) >= INT_MAX >> shift_y ||
625 FFABS( sprite_delta[1][
i]) >= INT_MAX >> shift_y
632 for (
i = 0;
i < 2;
i++) {
633 sprite_offset[0][
i] *= 1 << shift_y;
634 sprite_offset[1][
i] *= 1 << shift_c;
635 sprite_delta[0][
i] *= 1 << shift_y;
636 sprite_delta[1][
i] *= 1 << shift_y;
637 ctx->sprite_shift[
i] = 16;
640 for (
i = 0;
i < 2;
i++) {
642 sprite_delta[
i][0] -
a * (1LL<<16),
643 sprite_delta[
i][1] -
a * (1LL<<16)
646 if (llabs(sprite_offset[0][
i] + sprite_delta[
i][0] * (
w+16LL)) >= INT_MAX ||
647 llabs(sprite_offset[0][
i] + sprite_delta[
i][1] * (
h+16LL)) >= INT_MAX ||
648 llabs(sprite_offset[0][
i] + sprite_delta[
i][0] * (
w+16LL) + sprite_delta[
i][1] * (
h+16LL)) >= INT_MAX ||
649 llabs(sprite_delta[
i][0] * (
w+16LL)) >= INT_MAX ||
650 llabs(sprite_delta[
i][1] * (
h+16LL)) >= INT_MAX ||
651 llabs(sd[0]) >= INT_MAX ||
652 llabs(sd[1]) >= INT_MAX ||
653 llabs(sprite_offset[0][
i] + sd[0] * (
w+16LL)) >= INT_MAX ||
654 llabs(sprite_offset[0][
i] + sd[1] * (
h+16LL)) >= INT_MAX ||
655 llabs(sprite_offset[0][
i] + sd[0] * (
w+16LL) + sd[1] * (
h+16LL)) >= INT_MAX
661 ctx->real_sprite_warping_points =
ctx->num_sprite_warping_points;
664 for (
i = 0;
i < 4;
i++) {
665 ctx->sprite_offset[
i&1][
i>>1] = sprite_offset[
i&1][
i>>1];
666 ctx->sprite_delta [
i&1][
i>>1] = sprite_delta [
i&1][
i>>1];
671 memset(
ctx->sprite_offset, 0,
sizeof(
ctx->sprite_offset));
672 memset(
ctx->sprite_delta, 0,
sizeof(
ctx->sprite_delta));
696 int mb_num_bits =
av_log2(
s->mb_num - 1) + 1;
697 int header_extension = 0, mb_num,
len;
718 if (mb_num >=
s->mb_num || !mb_num) {
720 "illegal mb_num in video packet (%d %d) \n", mb_num,
s->mb_num);
724 s->mb_x = mb_num %
s->mb_width;
725 s->mb_y = mb_num /
s->mb_width;
728 int qscale =
get_bits(&
s->gb,
s->quant_precision);
730 s->chroma_qscale =
s->qscale = qscale;
736 if (header_extension) {
742 check_marker(
s->avctx, &
s->gb,
"before time_increment in video packed header");
744 check_marker(
s->avctx, &
s->gb,
"before vop_coding_type in video packed header");
765 "Error, video packet header damaged (f_code=0)\n");
771 "Error, video packet header damaged (b_code=0)\n");
786 s->last_dc[2] = 1 << (
s->avctx->bits_per_raw_sample +
s->dct_precision +
s->intra_dc_precision - 1);
801 vlc_len =
av_log2(
s->mb_width *
s->mb_height) + 1;
804 if (mb_num >=
s->mb_num)
807 s->mb_x = mb_num %
s->mb_width;
808 s->mb_y = mb_num /
s->mb_width;
838 int x, y, mb_v, sum, dx, dy,
shift;
839 int len = 1 << (
s->f_code + 4);
840 const int a =
ctx->sprite_warping_accuracy;
843 len >>=
s->quarter_sample;
845 if (
ctx->real_sprite_warping_points == 1) {
846 if (
ctx->divx_version == 500 &&
ctx->divx_build == 413 &&
a >=
s->quarter_sample)
847 sum =
ctx->sprite_offset[0][n] / (1 << (
a -
s->quarter_sample));
849 sum =
RSHIFT(
ctx->sprite_offset[0][n] * (1 <<
s->quarter_sample),
a);
851 dx =
ctx->sprite_delta[n][0];
852 dy =
ctx->sprite_delta[n][1];
855 dy -= 1 << (
shift +
a + 1);
857 dx -= 1 << (
shift +
a + 1);
858 mb_v =
ctx->sprite_offset[0][n] + dx *
s->mb_x * 16
U + dy *
s->mb_y * 16
U;
861 for (y = 0; y < 16; y++) {
866 for (x = 0; x < 16; x++) {
871 sum =
RSHIFT(sum,
a + 8 -
s->quarter_sample);
897 if (code < 0 || code > 9 ) {
939 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
942 s->first_slice_line = 1;
943 for (;
s->mb_y <
s->mb_height;
s->mb_y++) {
945 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
946 const int xy =
s->mb_x +
s->mb_y *
s->mb_stride;
952 s->avctx->lowres,
s->chroma_x_shift);
953 if (
s->mb_x ==
s->resync_mb_x &&
s->mb_y ==
s->resync_mb_y + 1)
954 s->first_slice_line = 0;
966 "mcbpc corrupted at %d %d\n",
s->mb_x,
s->mb_y);
971 s->cbp_table[xy] = cbpc & 3;
978 s->current_picture.qscale_table[xy] =
s->qscale;
980 s->mbintra_table[xy] = 1;
981 for (
i = 0;
i < 6;
i++) {
986 "DC corrupted at %d %d\n",
s->mb_x,
s->mb_y);
993 s->pred_dir_table[xy] = dir;
995 int mx, my, pred_x, pred_y,
bits;
996 int16_t *
const mot_val =
s->current_picture.motion_val[0][
s->block_index[0]];
997 const int stride =
s->b8_stride * 2;
1005 if (
bits & 0x10000) {
1024 mot_val[2 +
stride] = mx;
1028 mot_val[3 +
stride] = my;
1030 if (
s->mbintra_table[xy])
1038 "mcbpc corrupted at %d %d\n",
s->mb_x,
s->mb_y);
1044 s->cbp_table[xy] = cbpc & (8 + 3);
1046 s->mb_intra = ((cbpc & 4) != 0);
1050 s->mbintra_table[xy] = 1;
1060 if (
s->mbintra_table[xy])
1070 if ((cbpc & 16) == 0) {
1095 mot_val[2 +
stride] = mx;
1099 mot_val[3 +
stride] = my;
1104 for (
i = 0;
i < 4;
i++) {
1133 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
1135 s->mb_x =
s->resync_mb_x;
1136 s->first_slice_line = 1;
1137 for (
s->mb_y =
s->resync_mb_y; mb_num < mb_count; s->mb_y++) {
1139 for (; mb_num < mb_count &&
s->mb_x <
s->mb_width;
s->mb_x++) {
1140 const int xy =
s->mb_x +
s->mb_y *
s->mb_stride;
1144 s->avctx->lowres,
s->chroma_x_shift);
1145 if (
s->mb_x ==
s->resync_mb_x &&
s->mb_y ==
s->resync_mb_y + 1)
1146 s->first_slice_line = 0;
1153 "cbpy corrupted at %d %d\n",
s->mb_x,
s->mb_y);
1157 s->cbp_table[xy] |= cbpy << 2;
1160 if (
IS_INTRA(
s->current_picture.mb_type[xy])) {
1168 "I cbpy corrupted at %d %d\n",
s->mb_x,
s->mb_y);
1172 if (
s->cbp_table[xy] & 8)
1174 s->current_picture.qscale_table[xy] =
s->qscale;
1176 for (
i = 0;
i < 6;
i++) {
1181 "DC corrupted at %d %d\n",
s->mb_x,
s->mb_y);
1188 s->cbp_table[xy] &= 3;
1189 s->cbp_table[xy] |= cbpy << 2;
1191 s->pred_dir_table[xy] = dir;
1192 }
else if (
IS_SKIP(
s->current_picture.mb_type[xy])) {
1193 s->current_picture.qscale_table[xy] =
s->qscale;
1194 s->cbp_table[xy] = 0;
1200 "P cbpy corrupted at %d %d\n",
s->mb_x,
s->mb_y);
1204 if (
s->cbp_table[xy] & 8)
1206 s->current_picture.qscale_table[xy] =
s->qscale;
1208 s->cbp_table[xy] &= 3;
1209 s->cbp_table[xy] |= (cbpy ^ 0xf) << 2;
1213 if (mb_num >= mb_count)
1235 s->mb_x,
s->mb_y, part_a_error);
1239 if (
s->resync_mb_x +
s->resync_mb_y *
s->mb_width + mb_num >
s->mb_num) {
1242 s->mb_x,
s->mb_y, part_a_error);
1246 s->mb_num_left = mb_num;
1253 "marker missing after first I partition at %d %d\n",
1262 "marker missing after first P partition at %d %d\n",
1268 s->mb_x - 1,
s->mb_y, part_a_end);
1290 int n,
int coded,
int intra,
1291 int use_intra_dc_vlc,
int rvlc)
1298 const uint8_t *scan_table;
1303 if (use_intra_dc_vlc) {
1305 if (
s->partitioned_frame) {
1306 level =
s->dc_val[0][
s->block_index[n]];
1311 dc_pred_dir = (
s->pred_dir_table[
s->mb_x +
s->mb_y *
s->mb_stride] << n) & 32;
1334 if (dc_pred_dir == 0)
1335 scan_table =
s->permutated_intra_v_scantable;
1337 scan_table =
s->permutated_intra_h_scantable;
1339 scan_table =
s->intra_scantable.permutated;
1346 s->block_last_index[n] =
i;
1354 scan_table =
s->intra_scantable.permutated;
1356 if (
s->mpeg_quant) {
1364 qmul =
s->qscale << 1;
1365 qadd = (
s->qscale - 1) | 1;
1382 "1. marker bit missing in rvlc esc\n");
1395 "2. marker bit missing in rvlc esc\n");
1421 cache ^= 0xC0000000;
1423 if (cache & 0x80000000) {
1424 if (cache & 0x40000000) {
1439 "1. marker bit missing in 3. esc\n");
1450 "2. marker bit missing in 3. esc\n");
1459 if (
s->error_recognition >= FF_ER_COMPLIANT) {
1462 const int run1=
run - rl->
max_run[last][abs_level] - 1;
1463 if (abs_level <= rl->max_level[last][
run]) {
1467 if (
s->error_recognition > FF_ER_COMPLIANT) {
1468 if (abs_level <= rl->max_level[last][
run]*2) {
1472 if (run1 >= 0 && abs_level <= rl->max_level[last][run1]) {
1485 if ((
unsigned)(
level + 2048) > 4095) {
1489 "|level| overflow in 3. esc, qp=%d\n",
1523 ff_tlog(
s->avctx,
"dct[%d][%d] = %- 4d end?:%d\n", scan_table[
i&63]&7, scan_table[
i&63] >> 3,
level,
i>62);
1528 "ac-tex damaged at %d %d\n",
s->mb_x,
s->mb_y);
1543 if (!use_intra_dc_vlc) {
1553 s->block_last_index[n] =
i;
1564 int cbp, mb_type, use_intra_dc_vlc;
1565 const int xy =
s->mb_x +
s->mb_y *
s->mb_stride;
1569 mb_type =
s->current_picture.mb_type[xy];
1570 cbp =
s->cbp_table[xy];
1572 use_intra_dc_vlc =
s->qscale <
ctx->intra_dc_threshold;
1574 if (
s->current_picture.qscale_table[xy] !=
s->qscale)
1580 for (
i = 0;
i < 4;
i++) {
1581 s->mv[0][
i][0] =
s->current_picture.motion_val[0][
s->block_index[
i]][0];
1582 s->mv[0][
i][1] =
s->current_picture.motion_val[0][
s->block_index[
i]][1];
1588 for (
i = 0;
i < 6;
i++)
1589 s->block_last_index[
i] = -1;
1600 }
else if (
s->mb_intra) {
1601 s->ac_pred =
IS_ACPRED(
s->current_picture.mb_type[xy]);
1602 }
else if (!
s->mb_intra) {
1614 s->ac_pred =
IS_ACPRED(
s->current_picture.mb_type[xy]);
1619 s->bdsp.clear_blocks(
s->block[0]);
1621 for (
i = 0;
i < 6;
i++) {
1623 use_intra_dc_vlc,
ctx->rvlc) < 0) {
1625 "texture corrupted at %d %d %d\n",
1626 s->mb_x,
s->mb_y,
s->mb_intra);
1634 if (--
s->mb_num_left <= 0) {
1641 const int delta =
s->mb_x + 1 ==
s->mb_width ? 2 : 1;
1642 if (
s->cbp_table[xy +
delta])
1652 int cbpc, cbpy,
i, cbp, pred_x, pred_y, mx, my, dquant;
1654 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
1655 const int xy =
s->mb_x +
s->mb_y *
s->mb_stride;
1667 for (
i = 0;
i < 6;
i++)
1668 s->block_last_index[
i] = -1;
1695 "mcbpc damaged at %d %d\n",
s->mb_x,
s->mb_y);
1698 }
while (cbpc == 20);
1700 s->bdsp.clear_blocks(
s->block[0]);
1702 s->mb_intra = ((cbpc & 4) != 0);
1714 "P cbpy damaged at %d %d\n",
s->mb_x,
s->mb_y);
1718 cbp = (cbpc & 3) | (cbpy << 2);
1721 if ((!
s->progressive_sequence) &&
1726 if ((cbpc & 16) == 0) {
1735 s->mv[0][0][0] = mx;
1736 s->mv[0][0][1] = my;
1737 }
else if ((!
s->progressive_sequence) &&
get_bits1(&
s->gb)) {
1749 for (
i = 0;
i < 2;
i++) {
1758 s->mv[0][
i][0] = mx;
1759 s->mv[0][
i][1] = my;
1775 s->mv[0][0][0] = mx;
1776 s->mv[0][0][1] = my;
1781 for (
i = 0;
i < 4;
i++) {
1790 s->mv[0][
i][0] = mx;
1791 s->mv[0][
i][1] = my;
1805 for (
i = 0;
i < 2;
i++) {
1806 s->last_mv[
i][0][0] =
1807 s->last_mv[
i][0][1] =
1808 s->last_mv[
i][1][0] =
1809 s->last_mv[
i][1][1] = 0;
1816 s->mb_skipped =
s->next_picture.mbskip_table[
s->mb_y *
s->mb_stride +
s->mb_x];
1818 if (
s->mb_skipped) {
1820 for (
i = 0;
i < 6;
i++)
1821 s->block_last_index[
i] = -1;
1851 s->bdsp.clear_blocks(
s->block[0]);
1860 if (!
s->progressive_sequence) {
1888 s->last_mv[0][1][0] =
1889 s->last_mv[0][0][0] =
1890 s->mv[0][0][0] = mx;
1891 s->last_mv[0][1][1] =
1892 s->last_mv[0][0][1] =
1893 s->mv[0][0][1] = my;
1901 s->last_mv[1][1][0] =
1902 s->last_mv[1][0][0] =
1903 s->mv[1][0][0] = mx;
1904 s->last_mv[1][1][1] =
1905 s->last_mv[1][0][1] =
1906 s->mv[1][0][1] = my;
1914 for (
i = 0;
i < 2;
i++) {
1917 s->last_mv[0][
i][0] =
1918 s->mv[0][
i][0] = mx;
1919 s->last_mv[0][
i][1] = (
s->mv[0][
i][1] = my) * 2;
1926 for (
i = 0;
i < 2;
i++) {
1929 s->last_mv[1][
i][0] =
1930 s->mv[1][
i][0] = mx;
1931 s->last_mv[1][
i][1] = (
s->mv[1][
i][1] = my) * 2;
1949 s->current_picture.mb_type[xy] = mb_type;
1951 int use_intra_dc_vlc;
1957 "I cbpc damaged at %d %d\n",
s->mb_x,
s->mb_y);
1960 }
while (cbpc == 8);
1975 "I cbpy damaged at %d %d\n",
s->mb_x,
s->mb_y);
1978 cbp = (cbpc & 3) | (cbpy << 2);
1980 use_intra_dc_vlc =
s->qscale <
ctx->intra_dc_threshold;
1985 if (!
s->progressive_sequence)
1988 s->bdsp.clear_blocks(
s->block[0]);
1990 for (
i = 0;
i < 6;
i++) {
1992 1, use_intra_dc_vlc, 0) < 0)
2000 for (
i = 0;
i < 6;
i++) {
2010 if (
s->mb_x +
s->mb_y*
s->mb_width + 1 > next && (
s->avctx->err_recognition &
AV_EF_AGGRESSIVE)) {
2012 }
else if (
s->mb_x +
s->mb_y*
s->mb_width + 1 >= next)
2016 const int delta =
s->mb_x + 1 ==
s->mb_width ? 2 : 1;
2018 (
s->mb_x +
delta >=
s->mb_width)
2019 ?
FFMIN(
s->mb_y + 1,
s->mb_height - 1)
2021 if (
s->next_picture.mbskip_table[xy +
delta])
2072 int cc, dct_dc_size, dct_diff,
code, j, idx = 1, group = 0,
run = 0,
2073 additional_code_len, sign, mismatch;
2075 uint8_t *
const scantable =
s->intra_scantable.permutated;
2076 const uint16_t *quant_matrix;
2078 const int min = -1 * (1 << (
s->avctx->bits_per_raw_sample + 6));
2079 const int max = ((1 << (
s->avctx->bits_per_raw_sample + 6)) - 1);
2080 int shift = 3 -
s->dct_precision;
2089 quant_matrix =
s->intra_matrix;
2096 quant_matrix =
s->chroma_intra_matrix;
2099 if (dct_dc_size == 0) {
2104 if (dct_dc_size > 8) {
2111 s->last_dc[cc] += dct_diff;
2114 block[0] =
s->last_dc[cc] * (8 >>
s->intra_dc_precision);
2116 block[0] =
s->last_dc[cc] * (8 >>
s->intra_dc_precision) * (8 >>
s->dct_precision);
2120 mismatch ^=
block[0];
2137 }
else if (group >= 1 && group <= 6) {
2139 run = 1 << additional_code_len;
2140 if (additional_code_len)
2144 }
else if (group >= 7 && group <= 12) {
2149 run = (1 << (additional_code_len - 1)) +
code;
2153 j = scantable[idx++];
2154 block[j] = sign ? 1 : -1;
2155 }
else if (group >= 13 && group <= 20) {
2159 j = scantable[idx++];
2161 }
else if (group == 21) {
2165 j = scantable[idx++];
2166 additional_code_len =
s->avctx->bits_per_raw_sample +
s->dct_precision + 4;
2167 flc =
get_bits(&
s->gb, additional_code_len);
2168 if (flc >> (additional_code_len-1))
2169 block[j] = -1 * (( flc ^ ((1 << additional_code_len) -1)) + 1);
2175 mismatch ^=
block[j];
2178 block[63] ^= mismatch & 1;
2185 int i, j,
w,
h, idx = 0;
2186 int block_mean, rice_parameter, rice_prefix_code, rice_suffix_code,
2187 dpcm_residual,
left, top, topleft, min_left_top, max_left_top, p, p2,
output;
2188 h = 16 >> (n ?
s->chroma_y_shift : 0);
2189 w = 16 >> (n ?
s->chroma_x_shift : 0);
2191 block_mean =
get_bits(&
s->gb,
s->avctx->bits_per_raw_sample);
2192 if (block_mean == 0){
2196 s->last_dc[n] = block_mean * (1 << (
s->dct_precision +
s->intra_dc_precision));
2199 if (rice_parameter == 0) {
2204 if (rice_parameter == 15)
2207 if (rice_parameter > 11) {
2212 for (
i = 0;
i <
h;
i++) {
2213 output = 1 << (
s->avctx->bits_per_raw_sample - 1);
2214 top = 1 << (
s->avctx->bits_per_raw_sample - 1);
2216 for (j = 0; j <
w; j++) {
2223 if (rice_prefix_code == 11)
2224 dpcm_residual =
get_bits(&
s->gb,
s->avctx->bits_per_raw_sample);
2226 if (rice_prefix_code == 12) {
2230 rice_suffix_code =
get_bitsz(&
s->gb, rice_parameter);
2231 dpcm_residual = (rice_prefix_code << rice_parameter) + rice_suffix_code;
2235 if (dpcm_residual & 1)
2236 dpcm_residual = (-1 * dpcm_residual) >> 1;
2238 dpcm_residual = (dpcm_residual >> 1);
2241 top = macroblock[idx-
w];
2243 p =
left + top - topleft;
2245 if (p < min_left_top)
2249 if (p > max_left_top)
2252 p2 = (
FFMIN(min_left_top, topleft) +
FFMAX(max_left_top, topleft)) >> 1;
2257 dpcm_residual *= -1;
2259 macroblock[idx++] =
output = (dpcm_residual + p) & ((1 <<
s->avctx->bits_per_raw_sample) - 1);
2271 ctx->dpcm_direction = 0;
2292 for (
i = 0;
i < 3;
i++) {
2316 int hours, minutes, seconds;
2328 s->time_base = seconds + 60*(minutes + 60*hours);
2352 int visual_object_type;
2353 int is_visual_object_identifier =
get_bits1(gb);
2355 if (is_visual_object_identifier) {
2358 visual_object_type =
get_bits(gb, 4);
2363 if (video_signal_type) {
2364 int video_range, color_description;
2371 if (color_description) {
2372 s->avctx->color_primaries =
get_bits(gb, 8);
2387 for (
i = 0;
i < 64;
i++) {
2388 int j =
s->idsp.idct_permutation[
i];
2390 s->intra_matrix[j] = v;
2391 s->chroma_intra_matrix[j] = v;
2394 s->inter_matrix[j] = v;
2395 s->chroma_inter_matrix[j] = v;
2407 for (
i = 0;
i < 64;
i++) {
2410 s->intra_matrix[j] = v;
2411 s->chroma_intra_matrix[j] = v;
2419 for (
i = 0;
i < 64;
i++) {
2428 for (
i = 0;
i < 64;
i++) {
2431 s->chroma_intra_matrix[j] = v;
2439 for (
i = 0;
i < 64;
i++) {
2451 uint8_t extension_type;
2469 int bits_per_raw_sample;
2470 int rgb, chroma_format;
2490 bits_per_raw_sample =
get_bits(gb, 4);
2491 if (bits_per_raw_sample == 10) {
2501 if (
rgb !=
ctx->rgb ||
s->chroma_format != chroma_format)
2502 s->context_reinit = 1;
2503 s->avctx->bits_per_raw_sample = bits_per_raw_sample;
2505 s->chroma_format = chroma_format;
2508 check_marker(
s->avctx, gb,
"before video_object_layer_width");
2510 check_marker(
s->avctx, gb,
"before video_object_layer_height");
2512 check_marker(
s->avctx, gb,
"after video_object_layer_height");
2516 if (
s->width &&
s->height &&
2518 s->context_reinit = 1;
2523 aspect_ratio_info =
get_bits(gb, 4);
2525 s->avctx->sample_aspect_ratio.num =
get_bits(gb, 8);
2526 s->avctx->sample_aspect_ratio.den =
get_bits(gb, 8);
2536 check_marker(
s->avctx, gb,
"after first_half_vbv_buffer_size");
2539 check_marker(
s->avctx, gb,
"after first_half_vbv_buffer_size");
2541 check_marker(
s->avctx, gb,
"after latter_half_vbv_occupancy");
2569 s->studio_profile = 1;
2572 }
else if (
s->studio_profile) {
2582 aspect_ratio_info =
get_bits(gb, 4);
2584 s->avctx->sample_aspect_ratio.num =
get_bits(gb, 8);
2585 s->avctx->sample_aspect_ratio.den =
get_bits(gb, 8);
2591 int chroma_format =
get_bits(gb, 2);
2602 check_marker(
s->avctx, gb,
"after first_half_vbv_buffer_size");
2605 check_marker(
s->avctx, gb,
"after first_half_vbv_occupancy");
2607 check_marker(
s->avctx, gb,
"after latter_half_vbv_occupancy");
2612 if (
s->picture_number == 0) {
2613 switch (
ctx->vo_type) {
2632 check_marker(
s->avctx, gb,
"before time_increment_resolution");
2634 s->avctx->framerate.num =
get_bits(gb, 16);
2635 if (!
s->avctx->framerate.num) {
2640 ctx->time_increment_bits =
av_log2(
s->avctx->framerate.num - 1) + 1;
2641 if (
ctx->time_increment_bits < 1)
2642 ctx->time_increment_bits = 1;
2647 s->avctx->framerate.den =
get_bits(gb,
ctx->time_increment_bits);
2649 s->avctx->framerate.den = 1;
2661 !(
s->width &&
s->codec_tag ==
AV_RL32(
"MP4S"))) {
2662 if (
s->width &&
s->height &&
2664 s->context_reinit = 1;
2670 s->progressive_sequence =
2672 s->interlaced_dct = 0;
2675 "MPEG-4 OBMC not supported (very likely buggy encoder)\n");
2696 if (
ctx->num_sprite_warping_points > 3) {
2698 "%d sprite_warping_points\n",
2699 ctx->num_sprite_warping_points);
2700 ctx->num_sprite_warping_points = 0;
2714 if (
s->quant_precision != 5)
2716 "quant precision %d\n",
s->quant_precision);
2717 if (
s->quant_precision<3 ||
s->quant_precision>9) {
2718 s->quant_precision = 5;
2721 s->quant_precision = 5;
2734 for (
i = 0;
i < 64;
i++) {
2746 s->intra_matrix[j] = last;
2747 s->chroma_intra_matrix[j] = last;
2751 for (;
i < 64;
i++) {
2753 s->intra_matrix[j] = last;
2754 s->chroma_intra_matrix[j] = last;
2761 for (
i = 0;
i < 64;
i++) {
2773 s->inter_matrix[j] = v;
2774 s->chroma_inter_matrix[j] = v;
2778 for (;
i < 64;
i++) {
2780 s->inter_matrix[j] = last;
2781 s->chroma_inter_matrix[j] = last;
2791 s->quarter_sample = 0;
2800 int estimation_method =
get_bits(gb, 2);
2801 if (estimation_method < 2) {
2816 if (!
check_marker(
s->avctx, gb,
"in complexity estimation part 1")) {
2834 if (!
check_marker(
s->avctx, gb,
"in complexity estimation part 2")) {
2838 if (estimation_method == 1) {
2844 "Invalid Complexity estimation method %d\n",
2849 ctx->cplx_estimation_trash_i =
2850 ctx->cplx_estimation_trash_p =
2851 ctx->cplx_estimation_trash_b = 0;
2857 if (
s->data_partitioning)
2860 if (vo_ver_id != 1) {
2862 if (
ctx->new_pred) {
2869 "reduced resolution VOP not supported\n");
2876 if (
ctx->scalability) {
2878 int h_sampling_factor_n;
2879 int h_sampling_factor_m;
2880 int v_sampling_factor_n;
2881 int v_sampling_factor_m;
2886 h_sampling_factor_n =
get_bits(gb, 5);
2887 h_sampling_factor_m =
get_bits(gb, 5);
2888 v_sampling_factor_n =
get_bits(gb, 5);
2889 v_sampling_factor_m =
get_bits(gb, 5);
2892 if (h_sampling_factor_n == 0 || h_sampling_factor_m == 0 ||
2893 v_sampling_factor_n == 0 || v_sampling_factor_m == 0) {
2896 ctx->scalability = 0;
2906 av_log(
s->avctx,
AV_LOG_DEBUG,
"tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, low_delay:%d %s%s%s%s\n",
2907 s->avctx->framerate.den,
s->avctx->framerate.num,
2908 ctx->time_increment_bits,
2910 s->progressive_sequence,
2912 ctx->scalability ?
"scalability " :
"" ,
s->quarter_sample ?
"qpel " :
"",
2913 s->data_partitioning ?
"partition " :
"",
ctx->rvlc ?
"rvlc " :
""
2930 int ver = 0, build = 0, ver2 = 0, ver3 = 0;
2941 e = sscanf(buf,
"DivX%dBuild%d%c", &ver, &build, &last);
2943 e = sscanf(buf,
"DivX%db%d%c", &ver, &build, &last);
2945 ctx->divx_version = ver;
2946 ctx->divx_build = build;
2947 s->divx_packed = e == 3 && last ==
'p';
2951 e = sscanf(buf,
"FFmpe%*[^b]b%d", &build) + 3;
2953 e = sscanf(buf,
"FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build);
2955 e = sscanf(buf,
"Lavc%d.%d.%d", &ver, &ver2, &ver3) + 1;
2957 if (ver > 0xFFU || ver2 > 0xFFU || ver3 > 0xFFU) {
2959 "Unknown Lavc version string encountered, %d.%d.%d; "
2960 "clamping sub-version values to 8-bits.\n",
2963 build = ((ver & 0xFF) << 16) + ((ver2 & 0xFF) << 8) + (ver3 & 0xFF);
2967 if (strcmp(buf,
"ffmpeg") == 0)
2968 ctx->lavc_build = 4600;
2971 ctx->lavc_build = build;
2974 e = sscanf(buf,
"XviD%d", &build);
2976 ctx->xvid_build = build;
2986 if (
ctx->xvid_build == -1 &&
ctx->divx_version == -1 &&
ctx->lavc_build == -1) {
2987 if (
s->codec_tag ==
AV_RL32(
"XVID") ||
2992 ctx->xvid_build = 0;
2995 if (
ctx->xvid_build == -1 &&
ctx->divx_version == -1 &&
ctx->lavc_build == -1)
2996 if (
s->codec_tag ==
AV_RL32(
"DIVX") &&
ctx->vo_type == 0 &&
2997 ctx->vol_control_parameters == 0)
2998 ctx->divx_version = 400;
3000 if (
ctx->xvid_build >= 0 &&
ctx->divx_version >= 0) {
3002 ctx->divx_build = -1;
3006 if (
s->codec_tag ==
AV_RL32(
"XVIX"))
3009 if (
s->codec_tag ==
AV_RL32(
"UMP4"))
3012 if (
ctx->divx_version >= 500 &&
ctx->divx_build < 1814)
3015 if (
ctx->divx_version > 502 &&
ctx->divx_build < 1814)
3018 if (
ctx->xvid_build <= 3
U)
3019 s->padding_bug_score = 256 * 256 * 256 * 64;
3021 if (
ctx->xvid_build <= 1
U)
3024 if (
ctx->xvid_build <= 12
U)
3027 if (
ctx->xvid_build <= 32
U)
3030 #define SET_QPEL_FUNC(postfix1, postfix2) \
3031 s->qdsp.put_ ## postfix1 = ff_put_ ## postfix2; \
3032 s->qdsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2; \
3033 s->qdsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
3035 if (
ctx->lavc_build < 4653
U)
3038 if (
ctx->lavc_build < 4655
U)
3041 if (
ctx->lavc_build < 4670
U)
3044 if (
ctx->lavc_build <= 4712
U)
3047 if ((
ctx->lavc_build&0xFF) >= 100) {
3048 if (
ctx->lavc_build > 3621476 &&
ctx->lavc_build < 3752552 &&
3049 (
ctx->lavc_build < 3752037 ||
ctx->lavc_build > 3752191)
3054 if (
ctx->divx_version >= 0)
3056 if (
ctx->divx_version == 501 &&
ctx->divx_build == 20020416)
3057 s->padding_bug_score = 256 * 256 * 256 * 64;
3059 if (
ctx->divx_version < 500
U)
3062 if (
ctx->divx_version >= 0)
3084 "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
3085 s->workaround_bugs,
ctx->lavc_build,
ctx->xvid_build,
3086 ctx->divx_version,
ctx->divx_build,
s->divx_packed ?
"p" :
"");
3088 if (CONFIG_MPEG4_DECODER &&
ctx->xvid_build >= 0 &&
3102 int time_incr, time_increment;
3114 if (
s->partitioned_frame)
3125 if (
ctx->time_increment_bits == 0 ||
3128 "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);
3130 for (
ctx->time_increment_bits = 1;
3131 ctx->time_increment_bits < 16;
3132 ctx->time_increment_bits++) {
3136 if ((
show_bits(gb,
ctx->time_increment_bits + 6) & 0x37) == 0x30)
3138 }
else if ((
show_bits(gb,
ctx->time_increment_bits + 5) & 0x1F) == 0x18)
3143 "time_increment_bits set to %d bits, based on bitstream analysis\n",
ctx->time_increment_bits);
3144 if (
s->avctx->framerate.num && 4*
s->avctx->framerate.num < 1<<
ctx->time_increment_bits) {
3145 s->avctx->framerate.num = 1<<
ctx->time_increment_bits;
3152 time_increment =
get_bits(gb,
ctx->time_increment_bits);
3155 s->last_time_base =
s->time_base;
3156 s->time_base += time_incr;
3157 s->time =
s->time_base * (int64_t)
s->avctx->framerate.num + time_increment;
3159 if (
s->time <
s->last_non_b_time) {
3163 s->time +=
s->avctx->framerate.num;
3166 s->pp_time =
s->time -
s->last_non_b_time;
3167 s->last_non_b_time =
s->time;
3169 s->time = (
s->last_time_base + time_incr) * (int64_t)
s->avctx->framerate.num + time_increment;
3170 s->pb_time =
s->pp_time - (
s->last_non_b_time -
s->time);
3171 if (
s->pp_time <=
s->pb_time ||
3172 s->pp_time <=
s->pp_time -
s->pb_time ||
3179 if (
ctx->t_frame == 0)
3180 ctx->t_frame =
s->pb_time;
3181 if (
ctx->t_frame == 0)
3187 if (
s->pp_field_time <=
s->pb_field_time ||
s->pb_field_time <= 1) {
3188 s->pb_field_time = 2;
3189 s->pp_field_time = 4;
3190 if (!
s->progressive_sequence)
3195 if (
s->avctx->framerate.den)
3253 if (!
s->progressive_sequence) {
3257 s->alternate_scan = 0;
3260 if (
s->alternate_scan) {
3264 s->idsp.idct_permutation);
3266 s->idsp.idct_permutation);
3271 s->idsp.idct_permutation);
3273 s->idsp.idct_permutation);
3287 if (
ctx->sprite_brightness_change)
3289 "sprite_brightness_change not supported\n");
3293 memset(
ctx->sprite_offset, 0,
sizeof(
ctx->sprite_offset));
3294 memset(
ctx->sprite_delta, 0,
sizeof(
ctx->sprite_delta));
3299 s->chroma_qscale =
s->qscale =
get_bits(gb,
s->quant_precision);
3300 if (
s->qscale == 0) {
3302 "Error, header damaged or not MPEG-4 header (qscale=0)\n");
3308 if (
s->f_code == 0) {
3310 "Error, header damaged or not MPEG-4 header (f_code=0)\n");
3319 if (
s->b_code == 0) {
3321 "Error, header damaged or not MPEG4 header (b_code=0)\n");
3330 "qp:%d fc:%d,%d %c size:%d pro:%d alt:%d top:%d %cpel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d ce:%d/%d/%d time:%"PRId64
" tincr:%d\n",
3331 s->qscale,
s->f_code,
s->b_code,
3334 s->top_field_first,
s->quarter_sample ?
'q' :
'h',
3335 s->data_partitioning,
ctx->resync_marker,
3336 ctx->num_sprite_warping_points,
ctx->sprite_warping_accuracy,
3337 1 -
s->no_rounding,
ctx->vo_type,
3338 ctx->vol_control_parameters ?
" VOLC" :
" ",
ctx->intra_dc_threshold,
3339 ctx->cplx_estimation_trash_i,
ctx->cplx_estimation_trash_p,
3340 ctx->cplx_estimation_trash_b,
3346 if (!
ctx->scalability) {
3350 if (
ctx->enhancement_type) {
3351 int load_backward_shape =
get_bits1(gb);
3352 if (load_backward_shape)
3354 "load backward shape isn't supported\n");
3364 if (
ctx->vo_type == 0 &&
ctx->vol_control_parameters == 0 &&
3365 ctx->divx_version == -1 &&
s->picture_number == 0) {
3367 "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
3371 s->picture_number++;
3378 s->h_edge_pos =
s->width;
3379 s->v_edge_pos =
s->height;
3410 s->partitioned_frame = 0;
3411 s->interlaced_dct = 0;
3434 s->intra_dc_precision =
get_bits(gb, 2);
3438 if (
s->alternate_scan) {
3442 s->idsp.idct_permutation);
3444 s->idsp.idct_permutation);
3449 s->idsp.idct_permutation);
3451 s->idsp.idct_permutation);
3465 int visual_object_type;
3468 visual_object_type =
get_bits(gb, 4);
3491 int header,
int parse_only)
3494 unsigned startcode, v;
3504 if (!
s->studio_profile &&
s->avctx->bits_per_raw_sample != 8)
3505 s->avctx->bits_per_raw_sample = 0;
3517 (
ctx->divx_version >= 0 ||
ctx->xvid_build >= 0) ||
s->codec_tag ==
AV_RL32(
"QMP4")) {
3528 startcode = ((startcode << 8) | v) & 0xffffffff;
3530 if ((startcode & 0xFFFFFF00) != 0x100)
3535 if (startcode <= 0x11F)
3536 name =
"Video Object Start";
3537 else if (startcode <= 0x12F)
3538 name =
"Video Object Layer Start";
3539 else if (startcode <= 0x13F)
3541 else if (startcode <= 0x15F)
3542 name =
"FGS bp start";
3543 else if (startcode <= 0x1AF)
3545 else if (startcode == 0x1B0)
3546 name =
"Visual Object Seq Start";
3547 else if (startcode == 0x1B1)
3548 name =
"Visual Object Seq End";
3549 else if (startcode == 0x1B2)
3551 else if (startcode == 0x1B3)
3552 name =
"Group of VOP start";
3553 else if (startcode == 0x1B4)
3554 name =
"Video Session Error";
3555 else if (startcode == 0x1B5)
3556 name =
"Visual Object Start";
3557 else if (startcode == 0x1B6)
3558 name =
"Video Object Plane start";
3559 else if (startcode == 0x1B7)
3560 name =
"slice start";
3561 else if (startcode == 0x1B8)
3562 name =
"extension start";
3563 else if (startcode == 0x1B9)
3565 else if (startcode == 0x1BA)
3566 name =
"FBA Object start";
3567 else if (startcode == 0x1BB)
3568 name =
"FBA Object Plane start";
3569 else if (startcode == 0x1BC)
3570 name =
"Mesh Object start";
3571 else if (startcode == 0x1BD)
3572 name =
"Mesh Object Plane start";
3573 else if (startcode == 0x1BE)
3574 name =
"Still Texture Object start";
3575 else if (startcode == 0x1BF)
3576 name =
"Texture Spatial Layer start";
3577 else if (startcode == 0x1C0)
3578 name =
"Texture SNR Layer start";
3579 else if (startcode == 0x1C1)
3580 name =
"Texture Tile start";
3581 else if (startcode == 0x1C2)
3582 name =
"Texture Shape Layer start";
3583 else if (startcode == 0x1C3)
3584 name =
"stuffing start";
3585 else if (startcode <= 0x1C5)
3587 else if (startcode <= 0x1FF)
3588 name =
"System start";
3593 if (startcode >= 0x120 && startcode <= 0x12F) {
3610 s->studio_profile = 1;
3613 }
else if (
s->studio_profile) {
3620 if (
s->studio_profile) {
3636 s->avctx->has_b_frames = !
s->low_delay;
3638 if (
s->studio_profile) {
3639 if (!
s->avctx->bits_per_raw_sample) {
3656 if (
s->divx_packed) {
3657 int current_pos =
s->gb.buffer ==
s->bitstream_buffer ? 0 : (
get_bits_count(&
s->gb) >> 3);
3658 int startcode_found = 0;
3660 if (buf_size - current_pos > 7) {
3663 for (
i = current_pos;
i < buf_size - 4;
i++)
3668 buf[
i + 3] == 0xB6) {
3669 startcode_found = !(buf[
i + 4] & 0x40);
3674 if (startcode_found) {
3675 if (!
ctx->showed_packed_warning) {
3677 "wasteful way to store B-frames ('packed B-frames'). "
3678 "Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.\n");
3679 ctx->showed_packed_warning = 1;
3682 &
s->allocated_bitstream_buffer_size,
3683 buf_size - current_pos);
3684 if (!
s->bitstream_buffer) {
3685 s->bitstream_buffer_size = 0;
3688 memcpy(
s->bitstream_buffer, buf + current_pos,
3689 buf_size - current_pos);
3690 s->bitstream_buffer_size = buf_size - current_pos;
3697 #if CONFIG_MPEG4_DECODER
3704 int init =
s->m.context_initialized;
3712 s->time_increment_bits =
s1->time_increment_bits;
3713 s->shape =
s1->shape;
3714 s->vol_sprite_usage =
s1->vol_sprite_usage;
3715 s->sprite_brightness_change =
s1->sprite_brightness_change;
3716 s->sprite_warping_accuracy =
s1->sprite_warping_accuracy;
3717 s->num_sprite_warping_points =
s1->num_sprite_warping_points;
3718 s->m.data_partitioning =
s1->m.data_partitioning;
3720 s->resync_marker =
s1->resync_marker;
3721 s->t_frame =
s1->t_frame;
3722 s->new_pred =
s1->new_pred;
3723 s->enhancement_type =
s1->enhancement_type;
3724 s->scalability =
s1->scalability;
3725 s->intra_dc_threshold =
s1->intra_dc_threshold;
3726 s->divx_version =
s1->divx_version;
3727 s->divx_build =
s1->divx_build;
3728 s->xvid_build =
s1->xvid_build;
3729 s->lavc_build =
s1->lavc_build;
3730 s->vo_type =
s1->vo_type;
3731 s->showed_packed_warning =
s1->showed_packed_warning;
3732 s->vol_control_parameters =
s1->vol_control_parameters;
3733 s->cplx_estimation_trash_i =
s1->cplx_estimation_trash_i;
3734 s->cplx_estimation_trash_p =
s1->cplx_estimation_trash_p;
3735 s->cplx_estimation_trash_b =
s1->cplx_estimation_trash_b;
3738 memcpy(
s->sprite_shift,
s1->sprite_shift,
sizeof(
s1->sprite_shift));
3739 memcpy(
s->sprite_traj,
s1->sprite_traj,
sizeof(
s1->sprite_traj));
3741 if (!
init &&
s1->xvid_build >= 0)
3747 static int mpeg4_update_thread_context_for_user(
AVCodecContext *dst,
3760 static av_cold void mpeg4_init_static(
void)
3774 for (
unsigned i = 0,
offset = 0;
i < 12;
i++) {
3801 NULL, 0, 0, 0, 0, 128);
3817 ctx->lavc_build = -1;
3825 ctx->time_increment_bits = 4;
3837 #define OFFSET(x) offsetof(MpegEncContext, x)
3838 #define FLAGS AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY
3845 static const AVClass mpeg4_class = {
3871 .p.priv_class = &mpeg4_class,
3873 #if CONFIG_MPEG4_NVDEC_HWACCEL
3876 #if CONFIG_MPEG4_VAAPI_HWACCEL
3879 #if CONFIG_MPEG4_VDPAU_HWACCEL
3882 #if CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL
const AVProfile ff_mpeg4_video_profiles[]
#define MV_TYPE_16X16
1 vector for the whole mb
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define FF_ASPECT_EXTENDED
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 default minimum maximum flags name is the option name
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
av_cold void ff_xvid_idct_init(IDCTDSPContext *c, AVCodecContext *avctx)
static const uint8_t mpeg4_block_count[4]
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
const uint8_t ff_sprite_trajectory_lens[15]
static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, int parse_only)
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static VLC studio_chroma_dc
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
av_cold void ff_qpeldsp_init(QpelDSPContext *c)
static int get_bits_count(const GetBitContext *s)
static const uint8_t ac_state_tab[22][2]
#define MV_DIRECT
bidirectional mode where the difference equals the MV of the last P/S/I-Frame (MPEG-4)
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
@ AVCOL_RANGE_JPEG
Full range content.
static int mpeg4_decode_studio_mb(MpegEncContext *s, int16_t block_[12][64])
int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx)
Decode the next video packet.
static int mpeg4_decode_gop_header(MpegEncContext *s, GetBitContext *gb)
#define CORE_STUDIO_VO_TYPE
static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb)
#define AV_LOG_VERBOSE
Detailed information.
void ff_clean_intra_table_entries(MpegEncContext *s)
Clean dc, ac, coded_block for the current non-intra MB.
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
void ff_init_block_index(MpegEncContext *s)
#define UPDATE_CACHE(name, gb)
const FFCodec ff_mpeg4_decoder
#define FF_BUG_HPEL_CHROMA
static void decode_smpte_tc(Mpeg4DecContext *ctx, GetBitContext *gb)
#define FF_PROFILE_MPEG4_SIMPLE_STUDIO
static int mpeg4_decode_visual_object(MpegEncContext *s, GetBitContext *gb)
av_cold void ff_mpeg4_init_rl_intra(void)
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
#define FF_DEBUG_PICT_INFO
#define GET_CACHE(name, gb)
static void skip_bits(GetBitContext *s, int n)
int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
av_cold void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64], const uint8_t permutation[64])
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static VLC studio_intra_tab[12]
const uint8_t ff_mpeg4_DCtab_chrom[13][2]
static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb)
Decode the user data stuff in the header.
#define SKIP_CACHE(name, gb, num)
AVCodec p
The public AVCodec.
static int get_amv(Mpeg4DecContext *ctx, int n)
Get the average motion vector for a GMC MB.
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
#define MB_TYPE_B_VLC_BITS
#define STUDIO_INTRA_BITS
#define FF_BUG_QPEL_CHROMA2
#define AV_PIX_FMT_GBRP10
void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir)
Predict the ac.
const AVRational ff_h263_pixel_aspect[16]
int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s)
#define AV_EF_BITSTREAM
detect bitstream specification deviations
#define USES_LIST(a, list)
static int mpeg4_decode_profile_level(MpegEncContext *s, GetBitContext *gb, int *profile, int *level)
#define HWACCEL_VDPAU(codec)
#define AV_CODEC_FLAG_LOW_DELAY
Force low delay.
#define VOT_STILL_TEXTURE_ID
#define SLICE_END
end marker found
#define AV_PIX_FMT_YUV444P10
int ff_h263_decode_motion(MpegEncContext *s, int pred, int f_code)
static int ff_thread_once(char *control, void(*routine)(void))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define INIT_FIRST_VLC_RL(rl, static_size)
#define FF_ARRAY_ELEMS(a)
int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
Decode the first and second partition.
static void extension_and_user_data(MpegEncContext *s, GetBitContext *gb, int id)
int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my)
#define CLOSE_READER(name, gb)
#define FF_CODEC_DECODE_CB(func)
int8_t * max_level[2]
encoding & decoding
#define SHOW_SBITS(name, gb, num)
VLC ff_h263_inter_MCBPC_vlc
int(* init)(AVBSFContext *ctx)
#define FF_BUG_NO_PADDING
RLTable ff_mpeg4_rl_intra
static VLCElem vlc_buf[16716]
#define AV_EF_IGNORE_ERR
ignore errors and continue
#define FF_PROFILE_UNKNOWN
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
#define SKIP_BITS(name, gb, num)
#define FF_BUG_DIRECT_BLOCKSIZE
av_cold void ff_rl_init(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
Initialize index_run, max_level and max_run from n, last, table_vlc, table_run and table_level.
#define CODEC_LONG_NAME(str)
static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *gb)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
const uint8_t ff_mpeg4_DCtab_lum[13][2]
#define FRAME_SKIPPED
Return value for header parsers if frame is not coded.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
static const int mb_type_b_map[4]
#define LIBAVUTIL_VERSION_INT
static void mpeg4_load_default_matrices(MpegEncContext *s)
Describe the class of an AVClass context structure.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
av_cold void ff_mpv_idct_init(MpegEncContext *s)
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
#define INIT_VLC_STATIC_FROM_LENGTHS(vlc, bits, nb_codes, lens, len_wrap, symbols, symbols_wrap, symbols_size, offset, flags, static_size)
static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
decode partition C of one MB.
static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n)
#define SLICE_NOEND
no end marker or error found but mb count exceeded
#define ROUNDED_DIV(a, b)
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
int ff_init_vlc_from_lengths(VLC *vlc, 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()
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, int *got_frame, AVPacket *avpkt)
#define LAST_SKIP_BITS(name, gb, num)
#define SET_QPEL_FUNC(postfix1, postfix2)
#define UPDATE_THREAD_CONTEXT(func)
const uint8_t ff_alternate_horizontal_scan[64]
#define AV_PIX_FMT_YUV422P10
static const AVOption mpeg4_options[]
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
#define VISUAL_OBJ_STARTCODE
const uint8_t ff_mpeg4_dc_threshold[8]
av_cold int ff_h263_decode_end(AVCodecContext *avctx)
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
#define MV_TYPE_8X8
4 vectors (H.263, MPEG-4 4MV)
#define ADV_SIMPLE_VO_TYPE
static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx)
Decode first partition.
static int check_marker(void *logctx, GetBitContext *s, const char *msg)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled top and top right vectors is used as motion vector prediction the used motion vector is the sum of the predictor and(mvx_diff, mvy_diff) *mv_scale Intra DC Prediction block[y][x] dc[1]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
const uint8_t ff_mpeg4_y_dc_scale_table[32]
static int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int level, int *dir_ptr, int encoding)
Predict the dc.
static int shift(int a, int b)
static void ff_update_block_index(MpegEncContext *s, int bits_per_raw_sample, int lowres, int chroma_x_shift)
static int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, int n, int coded, int intra, int use_intra_dc_vlc, int rvlc)
Decode a block.
const int16_t ff_mpeg4_default_intra_matrix[64]
#define FF_CODEC_CAP_ALLOCATE_PROGRESS
static int read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb)
#define AV_NOPTS_VALUE
Undefined timestamp value.
#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...
int quarter_sample
1->qpel, 0->half pel ME/MC
static const uint8_t header[24]
#define MB_TYPE_INTERLACED
#define OPEN_READER(name, gb)
void ff_mpeg_flush(AVCodecContext *avctx)
av_cold void ff_mpeg4videodsp_init(Mpeg4VideoDSPContext *c)
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
const int16_t ff_mpeg4_default_non_intra_matrix[64]
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
#define MV_TYPE_FIELD
2 vectors, one per field
static int get_xbits(GetBitContext *s, int n)
Read MPEG-1 dc-style VLC (sign bit + mantissa with no MSB).
static void skip_bits1(GetBitContext *s)
#define HWACCEL_NVDEC(codec)
#define AV_LOG_INFO
Standard information.
static void gmc_motion(MpegEncContext *s, const Mpeg4DecContext *ctx, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t *const *ref_picture)
av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static int mpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr)
Decode the dc value.
#define SKIP_COUNTER(name, gb, num)
void ff_mpeg4_mcsel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t *const *ref_picture)
#define i(width, name, range_min, range_max)
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
enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]
const uint8_t ff_alternate_vertical_scan[64]
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, int header, int parse_only)
Decode MPEG-4 headers.
int8_t * max_run[2]
encoding & decoding
static VLC studio_luma_dc
int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
Decode the next video packet.
VLC ff_h263_intra_MCBPC_vlc
#define INTRA_MCBPC_VLC_BITS
#define FF_BUG_AUTODETECT
autodetection
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...
#define FF_DEBUG_STARTCODE
static av_cold int decode_init(AVCodecContext *avctx)
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
const char * name
Name of the codec implementation.
av_cold int ff_h263_decode_init(AVCodecContext *avctx)
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
#define FF_BUG_QPEL_CHROMA
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
#define HWACCEL_VIDEOTOOLBOX(codec)
#define SPRITE_TRAJ_VLC_BITS
const uint8_t ff_mpeg4_studio_dc_luma[19][2]
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
const uint8_t ff_zigzag_direct[64]
#define AV_EF_AGGRESSIVE
consider things that a sane encoder/muxer should not do as an error
#define INIT_VLC_STATIC_OVERLONG
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
const uint8_t ff_mpeg4_studio_dc_chroma[19][2]
static const uint8_t * align_get_bits(GetBitContext *s)
void ff_mpeg4_init_direct_mv(MpegEncContext *s)
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
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
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 default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your see the OFFSET() macro
void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int block_size, int uvlinesize, int dct_linesize, int dct_offset)
main external API structure.
static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count)
decode second partition.
#define SHOW_UBITS(name, gb, num)
const uint8_t ff_mb_type_b_tab[4][2]
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
#define USER_DATA_STARTCODE
static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
static int mpeg4_is_resync(Mpeg4DecContext *ctx)
check if the next stuff is a resync marker or the end.
#define INIT_VLC_RL(rl, static_size)
static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t macroblock[256], int n)
@ AV_PICTURE_TYPE_P
Predicted.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
Undefined Behavior In the C some operations are like signed integer overflow
#define FF_BUG_XVID_ILACE
#define avpriv_request_sample(...)
static void reset_studio_dc_predictors(MpegEncContext *s)
const uint8_t ff_mpeg4_c_dc_scale_table[32]
static void next_start_code_studio(GetBitContext *gb)
static const int16_t alpha[]
static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
Decode the next studio vop header.
static int mpeg_get_qscale(MpegEncContext *s)
#define HWACCEL_VAAPI(codec)
static void gmc1_motion(MpegEncContext *s, const Mpeg4DecContext *ctx, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t *const *ref_picture)
static const SheerTable rgb[2]
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
The exact code depends on how similar the blocks are and how related they are to the block
#define UPDATE_THREAD_CONTEXT_FOR_USER(func)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb)
#define QUANT_MATRIX_EXT_ID
static VLC sprite_trajectory
@ AV_PICTURE_TYPE_S
S(GMC)-VOP MPEG-4.
RL_VLC_ELEM * rl_vlc[32]
decoding only
#define INTER_MCBPC_VLC_BITS
#define SIMPLE_STUDIO_VO_TYPE
const uint8_t ff_mpeg4_studio_intra[12][24][2]