30 #include "libavutil/attributes.h"
31 #include "libavutil/avassert.h"
32 #include "libavutil/imgutils.h"
46 int16_t *
block,
int n,
int qscale);
48 int16_t *
block,
int n,
int qscale);
50 int16_t *
block,
int n,
int qscale);
52 int16_t *
block,
int n,
int qscale);
54 int16_t *
block,
int n,
int qscale);
56 int16_t *
block,
int n,
int qscale);
58 int16_t *
block,
int n,
int qscale);
62 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
63 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
68 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
69 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
70 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
71 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
72 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
73 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
74 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
75 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
80 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
81 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
82 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
83 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
84 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
85 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
86 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
87 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
92 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
93 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
95 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
96 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
97 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
98 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
99 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
104 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
105 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
106 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
107 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
108 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
109 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
110 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
111 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
128 int mb_x,
int mb_y,
int mb_intra,
int mb_skipped)
138 memcpy(s->
mv,
mv,
sizeof(*
mv));
243 if (r < 0 || !pic->f.data[0]) {
264 "get_buffer() failed (stride changed)\n");
271 "get_buffer() failed (uv stride mismatch)\n");
279 "get_buffer() failed to allocate context scratch buffers.\n");
301 for (i = 0; i < 2; i++) {
332 int mv_size = 2 * (b8_array_size + 4) *
sizeof(int16_t);
333 int ref_index_size = 4 * mb_array_size;
335 for (i = 0; mv_size && i < 2; i++) {
352 #define MAKE_WRITABLE(table) \
355 (ret = av_buffer_make_writable(&pic->table)) < 0)\
366 for (i = 0; i < 2; i++) {
418 for (i = 0; i < 2; i++) {
454 memset((
uint8_t*)pic + off, 0,
sizeof(*pic) - off);
461 #define UPDATE_TABLE(table)\
464 (!dst->table || dst->table->buffer != src->table->buffer)) {\
465 av_buffer_unref(&dst->table);\
466 dst->table = av_buffer_ref(src->table);\
468 free_picture_tables(dst);\
469 return AVERROR(ENOMEM);\
480 for (i = 0; i < 2; i++) {
491 for (i = 0; i < 2; i++) {
553 int yc_size = y_size + 2 * c_size;
570 2 * 64 *
sizeof(
int),
fail)
576 for (i = 0; i < 12; i++) {
585 yc_size *
sizeof(int16_t) * 16,
fail);
618 #define COPY(a) bak->a = src->a
619 COPY(edge_emu_buffer);
624 COPY(obmc_scratchpad);
652 for (i = 0; i < 12; i++) {
660 "scratch buffers.\n");
688 if (
s1->context_initialized){
720 if (
s1->picture[i].f.data[0] &&
725 #define UPDATE_PICTURE(pic)\
727 ff_mpeg_unref_picture(s, &s->pic);\
728 if (s1->pic.f.data[0])\
729 ret = ff_mpeg_ref_picture(s, &s->pic, &s1->pic);\
731 ret = update_picture_tables(&s->pic, &s1->pic);\
751 (
char *) &
s1->shape - (
char *) &
s1->time_increment_bits);
761 if (
s1->bitstream_buffer) {
762 if (
s1->bitstream_buffer_size +
766 s1->allocated_bitstream_buffer_size);
769 s1->bitstream_buffer_size);
779 "scratch buffers.\n");
784 "be allocated due to unknown size.\n");
789 (
char *) &
s1->rtp_mode - (
char *) &
s1->progressive_sequence);
791 if (!
s1->first_field) {
793 if (
s1->current_picture_ptr)
883 int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x,
y;
908 yc_size = y_size + 2 * c_size;
938 mb_array_size *
sizeof(
float),
fail);
940 mb_array_size *
sizeof(
float),
fail);
947 for (i = 0; i < 2; i++) {
949 for (j = 0; j < 2; j++) {
950 for (k = 0; k < 2; k++) {
953 mv_table_size * 2 *
sizeof(int16_t),
982 for (i = 0; i < yc_size; i++)
1020 "decoding to AV_PIX_FMT_NONE is not supported.\n");
1031 " reducing to %d\n", nb_slices, max_slices);
1032 nb_slices = max_slices;
1098 if (nb_slices > 1) {
1099 for (i = 1; i < nb_slices; i++) {
1104 for (i = 0; i < nb_slices; i++) {
1108 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1110 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1149 for (i = 0; i < 2; i++) {
1150 for (j = 0; j < 2; j++) {
1151 for (k = 0; k < 2; k++) {
1226 if (nb_slices > 1) {
1227 for (i = 1; i < nb_slices; i++) {
1232 for (i = 0; i < nb_slices; i++) {
1236 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1238 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1329 for (last = 0; last < 2; last++) {
1338 memset(max_level, 0,
MAX_RUN + 1);
1340 memset(index_run, rl->
n,
MAX_RUN + 1);
1341 for (i = start; i <
end; i++) {
1344 if (index_run[run] == rl->
n)
1346 if (level > max_level[run])
1348 if (run > max_run[level])
1352 rl->
max_level[last] = static_store[last];
1365 memcpy(rl->
index_run[last], index_run, MAX_RUN + 1);
1373 for (q = 0; q < 32; q++) {
1375 int qadd = (q - 1) | 1;
1389 }
else if (len < 0) {
1393 if (code == rl->
n) {
1399 if (code >= rl->
last) run += 192;
1426 if (pic->
f.
data[0] == NULL)
1450 "Internal error, picture buffer overflow\n");
1485 for (intra = 0; intra < 2; intra++) {
1487 for (i = 0; i < 64; i++) {
1493 for (i = 0; i < 64; i++) {
1533 "releasing zombie picture\n");
1597 av_dlog(s->
avctx,
"L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
1608 int h_chroma_shift, v_chroma_shift;
1610 &h_chroma_shift, &v_chroma_shift);
1613 "allocating dummy last picture for B frame\n");
1616 "warning: first frame is no keyframe\n");
1619 "allocate dummy last picture for field based first keyframe\n");
1637 (avctx->
height >> v_chroma_shift) *
1640 (avctx->
height >> v_chroma_shift) *
1644 for(i=0; i<avctx->
height; i++)
1670 #if 0 // BUFREF-FIXME
1694 for (i = 0; i < 4; i++) {
1808 sx = av_clip(sx, 0, w - 1);
1809 sy = av_clip(sy, 0, h - 1);
1810 ex = av_clip(ex, 0, w - 1);
1811 ey = av_clip(ey, 0, h - 1);
1813 buf[sy * stride + sx] +=
color;
1822 f = ((ey - sy) << 16) / ex;
1823 for (x = 0; x <= ex; x++) {
1825 fr = (x * f) & 0xFFFF;
1826 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
1827 if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16;
1837 f = ((ex - sx) << 16) / ey;
1840 for(y= 0; y <= ey; y++){
1842 fr = (y*f) & 0xFFFF;
1843 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
1844 if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16;
1861 sx = av_clip(sx, -100, w + 100);
1862 sy = av_clip(sy, -100, h + 100);
1863 ex = av_clip(ex, -100, w + 100);
1864 ey = av_clip(ey, -100, h + 100);
1869 if (dx * dx + dy * dy > 3 * 3) {
1878 draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
1879 draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
1881 draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
1889 int mb_width,
int mb_height,
int mb_stride,
int quarter_sample)
1901 for (y = 0; y < mb_height; y++) {
1902 for (x = 0; x < mb_width; x++) {
1904 int count = mbskip_table[x + y * mb_stride];
1914 int mb_type = p->
mb_type[x + y * mb_stride];
1930 else if (
IS_GMC(mb_type))
1968 const int shift = 1 + quarter_sample;
1972 int h_chroma_shift, v_chroma_shift, block_height;
1976 const int mv_stride = (mb_width << mv_sample_log2) +
1986 ptr = pict->
data[0];
1987 block_height = 16 >> v_chroma_shift;
1989 for (mb_y = 0; mb_y < mb_height; mb_y++) {
1991 for (mb_x = 0; mb_x < mb_width; mb_x++) {
1992 const int mb_index = mb_x + mb_y * mb_stride;
1995 for (type = 0; type < 3; type++) {
2022 for (i = 0; i < 4; i++) {
2023 int sx = mb_x * 16 + 4 + 8 * (i & 1);
2024 int sy = mb_y * 16 + 4 + 8 * (i >> 1);
2025 int xy = (mb_x * 2 + (i & 1) +
2026 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2034 for (i = 0; i < 2; i++) {
2035 int sx = mb_x * 16 + 8;
2036 int sy = mb_y * 16 + 4 + 8 * i;
2037 int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
2044 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2049 for (i = 0; i < 2; i++) {
2050 int sx = mb_x * 16 + 4 + 8 * i;
2051 int sy = mb_y * 16 + 8;
2052 int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
2059 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2063 int sx= mb_x * 16 + 8;
2064 int sy= mb_y * 16 + 8;
2065 int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
2074 0x0101010101010101ULL;
2076 for (y = 0; y < block_height; y++) {
2077 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2078 (block_height * mb_y + y) *
2080 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2081 (block_height * mb_y + y) *
2087 int mb_type = p->
mb_type[mb_index];
2090 #define COLOR(theta, r) \
2091 u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
2092 v = (int)(128 + r * sin(theta * 3.141592 / 180));
2109 }
else if (
IS_GMC(mb_type)) {
2111 }
else if (
IS_SKIP(mb_type)) {
2122 u *= 0x0101010101010101ULL;
2123 v *= 0x0101010101010101ULL;
2124 for (y = 0; y < block_height; y++) {
2125 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2126 (block_height * mb_y + y) * pict->
linesize[1]) = u;
2127 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2128 (block_height * mb_y + y) * pict->
linesize[2]) = v;
2133 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 0 +
2134 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2135 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 8 +
2136 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2139 for (y = 0; y < 16; y++)
2140 pict->
data[0][16 * mb_x + 8 + (16 * mb_y + y) *
2143 if (
IS_8X8(mb_type) && mv_sample_log2 >= 2) {
2144 int dm = 1 << (mv_sample_log2 - 2);
2145 for (i = 0; i < 4; i++) {
2146 int sx = mb_x * 16 + 8 * (i & 1);
2147 int sy = mb_y * 16 + 8 * (i >> 1);
2148 int xy = (mb_x * 2 + (i & 1) +
2149 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2152 if (mv[0] != mv[dm] ||
2153 mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
2154 for (y = 0; y < 8; y++)
2155 pict->
data[0][sx + 4 + (sy + y) * pict->
linesize[0]] ^= 0x80;
2156 if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
2157 *(uint64_t *)(pict->
data[0] + sx + (sy + 4) *
2158 pict->
linesize[0]) ^= 0x8080808080808080ULL;
2167 mbskip_table[mb_index] = 0;
2193 int field_based,
int field_select,
2194 int src_x,
int src_y,
2196 int h_edge_pos,
int v_edge_pos,
2198 int motion_x,
int motion_y)
2201 const int op_index =
FFMIN(lowres, 3);
2202 const int s_mask = (2 <<
lowres) - 1;
2211 sx = motion_x & s_mask;
2212 sy = motion_y & s_mask;
2213 src_x += motion_x >> lowres + 1;
2214 src_y += motion_y >> lowres + 1;
2216 src += src_y * stride + src_x;
2218 if ((
unsigned)src_x >
FFMAX( h_edge_pos - (!!sx) - w, 0) ||
2219 (unsigned)src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2222 (h + 1) << field_based, src_x,
2223 src_y << field_based,
2230 sx = (sx << 2) >>
lowres;
2231 sy = (sy << 2) >>
lowres;
2234 pix_op[op_index](dest,
src,
stride, h, sx, sy);
2248 int motion_x,
int motion_y,
2251 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
2252 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy;
2253 ptrdiff_t uvlinesize, linesize;
2256 const int block_s = 8>>
lowres;
2257 const int s_mask = (2 <<
lowres) - 1;
2270 motion_y += (bottom_field - field_select)*((1 << lowres)-1);
2273 sx = motion_x & s_mask;
2274 sy = motion_y & s_mask;
2275 src_x = s->
mb_x * 2 * block_s + (motion_x >> lowres + 1);
2276 src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >> lowres + 1);
2279 uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
2280 uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
2281 uvsrc_x = src_x >> 1;
2282 uvsrc_y = src_y >> 1;
2287 uvsx = (2 * mx) & s_mask;
2288 uvsy = (2 * my) & s_mask;
2289 uvsrc_x = s->
mb_x * block_s + (mx >>
lowres);
2290 uvsrc_y = mb_y * block_s + (my >>
lowres);
2297 uvsrc_x = s->
mb_x * block_s + (mx >> lowres + 1);
2298 uvsrc_y = (mb_y * block_s >> field_based) + (my >> lowres + 1);
2304 uvsy = motion_y & s_mask;
2306 uvsrc_x = s->
mb_x*block_s + (mx >> (lowres+1));
2309 uvsx = motion_x & s_mask;
2310 uvsy = motion_y & s_mask;
2317 ptr_y = ref_picture[0] + src_y * linesize + src_x;
2318 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
2319 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
2321 if ((
unsigned) src_x >
FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
2322 (
unsigned) src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2324 linesize >> field_based, 17, 17 + field_based,
2325 src_x, src_y << field_based, h_edge_pos,
2331 ptr_cb, uvlinesize >> field_based, 9,
2333 uvsrc_x, uvsrc_y << field_based,
2334 h_edge_pos >> 1, v_edge_pos >> 1);
2336 ptr_cr, uvlinesize >> field_based, 9,
2338 uvsrc_x, uvsrc_y << field_based,
2339 h_edge_pos >> 1, v_edge_pos >> 1);
2341 ptr_cr = uvbuf + 16;
2358 sx = (sx << 2) >>
lowres;
2359 sy = (sy << 2) >>
lowres;
2360 pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
2364 uvsx = (uvsx << 2) >>
lowres;
2365 uvsy = (uvsy << 2) >>
lowres;
2367 pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy);
2368 pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy);
2381 const int op_index =
FFMIN(lowres, 3);
2382 const int block_s = 8 >>
lowres;
2383 const int s_mask = (2 <<
lowres) - 1;
2384 const int h_edge_pos = s->
h_edge_pos >> lowres + 1;
2385 const int v_edge_pos = s->
v_edge_pos >> lowres + 1;
2386 int emu = 0, src_x, src_y, sx, sy;
2402 src_x = s->
mb_x * block_s + (mx >> lowres + 1);
2403 src_y = s->
mb_y * block_s + (my >> lowres + 1);
2406 ptr = ref_picture[1] +
offset;
2407 if ((
unsigned) src_x >
FFMAX(h_edge_pos - (!!sx) - block_s, 0) ||
2408 (unsigned) src_y >
FFMAX(v_edge_pos - (!!sy) - block_s, 0)) {
2410 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
2414 sx = (sx << 2) >>
lowres;
2415 sy = (sy << 2) >>
lowres;
2416 pix_op[op_index](dest_cb, ptr, s->
uvlinesize, block_s, sx, sy);
2418 ptr = ref_picture[2] +
offset;
2422 src_x, src_y, h_edge_pos, v_edge_pos);
2425 pix_op[op_index](dest_cr, ptr, s->
uvlinesize, block_s, sx, sy);
2448 const int block_s = 8 >>
lowres;
2457 ref_picture, pix_op,
2458 s->
mv[dir][0][0], s->
mv[dir][0][1],
2464 for (i = 0; i < 4; i++) {
2467 ref_picture[0], 0, 0,
2468 (2 * mb_x + (i & 1)) * block_s,
2469 (2 * mb_y + (i >> 1)) * block_s,
2472 block_s, block_s, pix_op,
2473 s->
mv[dir][i][0], s->
mv[dir][i][1]);
2475 mx += s->
mv[dir][i][0];
2476 my += s->
mv[dir][i][1];
2488 ref_picture, pix_op,
2489 s->
mv[dir][0][0], s->
mv[dir][0][1],
2494 ref_picture, pix_op,
2495 s->
mv[dir][1][0], s->
mv[dir][1][1],
2505 ref_picture, pix_op,
2507 s->
mv[dir][0][1], 2 * block_s, mb_y >> 1);
2511 for (i = 0; i < 2; i++) {
2523 ref2picture, pix_op,
2524 s->
mv[dir][i][0], s->
mv[dir][i][1] +
2525 2 * block_s * i, block_s, mb_y >> 1);
2527 dest_y += 2 * block_s * s->
linesize;
2534 for (i = 0; i < 2; i++) {
2536 for (j = 0; j < 2; j++) {
2539 ref_picture, pix_op,
2540 s->
mv[dir][2 * i + j][0],
2541 s->
mv[dir][2 * i + j][1],
2547 for (i = 0; i < 2; i++) {
2550 ref_picture, pix_op,
2551 s->
mv[dir][2 * i][0],s->
mv[dir][2 * i][1],
2552 2 * block_s, mb_y >> 1);
2575 int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->
quarter_sample;
2576 int my,
off, i, mvs;
2595 for (i = 0; i < mvs; i++) {
2596 my = s->
mv[dir][i][1]<<qpel_shift;
2597 my_max =
FFMAX(my_max, my);
2598 my_min =
FFMIN(my_min, my);
2601 off = (
FFMAX(-my_min, my_max) + 63) >> 6;
2610 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
2626 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
2648 memset(s->
ac_val[0][xy ], 0, 32 *
sizeof(int16_t));
2649 memset(s->
ac_val[0][xy + wrap], 0, 32 *
sizeof(int16_t));
2662 memset(s->
ac_val[1][xy], 0, 16 *
sizeof(int16_t));
2663 memset(s->
ac_val[2][xy], 0, 16 *
sizeof(int16_t));
2680 int lowres_flag,
int is_mpeg12)
2693 for(j=0; j<64; j++){
2717 uint8_t *dest_y, *dest_cb, *dest_cr;
2718 int dct_linesize, dct_offset;
2724 const int block_size= lowres_flag ? 8>>s->
avctx->
lowres : 8;
2743 dct_offset = s->
interlaced_dct ? linesize : linesize * block_size;
2747 dest_cb= s->
dest[1];
2748 dest_cr= s->
dest[2];
2831 add_dct(s, block[0], 0, dest_y , dct_linesize);
2832 add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
2833 add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
2834 add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
2838 add_dct(s, block[4], 4, dest_cb, uvlinesize);
2839 add_dct(s, block[5], 5, dest_cr, uvlinesize);
2843 dct_offset = s->
interlaced_dct ? uvlinesize : uvlinesize*block_size;
2845 add_dct(s, block[4], 4, dest_cb, dct_linesize);
2846 add_dct(s, block[5], 5, dest_cr, dct_linesize);
2847 add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
2848 add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
2850 add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
2851 add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
2852 add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
2853 add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
2865 put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->
qscale);
2866 put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->
qscale);
2867 put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->
qscale);
2884 s->
dsp.
idct_put(dest_y + block_size, dct_linesize, block[1]);
2885 s->
dsp.
idct_put(dest_y + dct_offset , dct_linesize, block[2]);
2886 s->
dsp.
idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
2895 dct_offset = s->
interlaced_dct? uvlinesize : uvlinesize*block_size;
2899 s->
dsp.
idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
2900 s->
dsp.
idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
2902 s->
dsp.
idct_put(dest_cb + block_size, dct_linesize, block[8]);
2903 s->
dsp.
idct_put(dest_cr + block_size, dct_linesize, block[9]);
2904 s->
dsp.
idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
2905 s->
dsp.
idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
2935 Picture *last,
int y,
int h,
int picture_structure,
2937 int v_edge_pos,
int h_edge_pos)
2942 const int field_pic = picture_structure !=
PICT_FRAME;
2954 int sides = 0, edge_h;
2956 if (y + h >= v_edge_pos)
2959 edge_h=
FFMIN(h, v_edge_pos - y);
2962 linesize[0], h_edge_pos, edge_h,
2965 linesize[1], h_edge_pos >> hshift, edge_h >> vshift,
2968 linesize[2], h_edge_pos >> hshift, edge_h >> vshift,
2997 offset[2]= (y >> vshift) * src->
linesize[1];
3005 y, picture_structure, h);
3038 s->
dest[0] += s->
mb_y * linesize << mb_size;
3042 s->
dest[0] += (s->
mb_y>>1) * linesize << mb_size;
3066 for(i=0; i<=last; i++){
3067 const int j= scantable[i];
3072 for(i=0; i<=last; i++){
3073 const int j= scantable[i];
3074 const int perm_j= permutation[j];
3075 block[perm_j]= temp[j];
3083 if(s==NULL || s->
picture==NULL)
3108 int16_t *
block,
int n,
int qscale)
3110 int i,
level, nCoeffs;
3111 const uint16_t *quant_matrix;
3118 for(i=1;i<=nCoeffs;i++) {
3124 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3125 level = (level - 1) | 1;
3128 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3129 level = (level - 1) | 1;
3137 int16_t *
block,
int n,
int qscale)
3139 int i,
level, nCoeffs;
3140 const uint16_t *quant_matrix;
3145 for(i=0; i<=nCoeffs; i++) {
3151 level = (((level << 1) + 1) * qscale *
3152 ((int) (quant_matrix[j]))) >> 4;
3153 level = (level - 1) | 1;
3156 level = (((level << 1) + 1) * qscale *
3157 ((int) (quant_matrix[j]))) >> 4;
3158 level = (level - 1) | 1;
3166 int16_t *
block,
int n,
int qscale)
3168 int i,
level, nCoeffs;
3169 const uint16_t *quant_matrix;
3176 for(i=1;i<=nCoeffs;i++) {
3182 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3185 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3193 int16_t *
block,
int n,
int qscale)
3195 int i,
level, nCoeffs;
3196 const uint16_t *quant_matrix;
3205 for(i=1;i<=nCoeffs;i++) {
3211 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3214 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3224 int16_t *
block,
int n,
int qscale)
3226 int i,
level, nCoeffs;
3227 const uint16_t *quant_matrix;
3234 for(i=0; i<=nCoeffs; i++) {
3240 level = (((level << 1) + 1) * qscale *
3241 ((int) (quant_matrix[j]))) >> 4;
3244 level = (((level << 1) + 1) * qscale *
3245 ((int) (quant_matrix[j]))) >> 4;
3255 int16_t *
block,
int n,
int qscale)
3257 int i,
level, qmul, qadd;
3266 qadd = (qscale - 1) | 1;
3275 for(i=1; i<=nCoeffs; i++) {
3279 level = level * qmul - qadd;
3281 level = level * qmul + qadd;
3289 int16_t *
block,
int n,
int qscale)
3291 int i,
level, qmul, qadd;
3296 qadd = (qscale - 1) | 1;
3301 for(i=0; i<=nCoeffs; i++) {
3305 level = level * qmul - qadd;
3307 level = level * qmul + qadd;
3321 else if (qscale > 31)
3337 #if CONFIG_ERROR_RESILIENCE
int bitstream_buffer_size
uint8_t * scratchpad
data area for the ME algo, so that the ME does not need to malloc/free
#define PICT_BOTTOM_FIELD
int last
number of values for last = 0
int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src)
static int init_duplicate_context(MpegEncContext *s)
int ff_thread_can_start_frame(AVCodecContext *avctx)
int16_t(* b_bidir_back_mv_table_base)[2]
discard all frames except keyframes
void ff_init_block_index(MpegEncContext *s)
unsigned int stream_codec_tag
fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + ...
av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
#define MAX_PICTURE_COUNT
#define CONFIG_MPEG_XVMC_DECODER
ScanTable intra_v_scantable
static int shift(int a, int b)
#define CONFIG_WMV2_ENCODER
void(* dct_unquantize_inter)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
void ff_release_unused_pictures(MpegEncContext *s, int remove_current)
int time_increment_bits
number of bits to represent the fractional part of time
This structure describes decoded (raw) audio or video data.
int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
Allocate a Picture.
int16_t(* p_mv_table)[2]
MV table (1MV per MB) p-frame encoding.
uint8_t * rd_scratchpad
scratchpad for rate distortion mb decision
int start_mb_y
start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) ...
#define MV_TYPE_FIELD
2 vectors, one per field
#define MAKE_WRITABLE(table)
const uint8_t * y_dc_scale_table
qscale -> y_dc_scale table
void(* emulated_edge_mc)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
uint8_t * mb_mean
Table for MB luminance.
int coded_width
Bitstream width / height, may be different from width/height e.g.
av_cold int ff_dct_common_init(MpegEncContext *s)
av_cold int ff_MPV_common_init(MpegEncContext *s)
init common structure for both encoder and decoder.
op_pixels_func avg_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
#define AV_LOG_WARNING
Something somehow does not look correct.
void ff_MPV_report_decode_progress(MpegEncContext *s)
static void chroma_4mv_motion_lowres(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, h264_chroma_mc_func *pix_op, int mx, int my)
uint8_t * coded_block_base
static int update_picture_tables(Picture *dst, Picture *src)
int end_mb_y
end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) ...
uint16_t * mb_var
Table for MB variances.
uint16_t(* q_chroma_intra_matrix16)[2][64]
void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last)
Permute an 8x8 block.
void ff_MPV_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, op_pixels_func(*pix_op)[4], qpel_mc_func(*qpix_op)[16])
int16_t(*[3] ac_val)[16]
used for mpeg4 AC prediction, all 3 arrays must be continuous
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
h264_chroma_mc_func put_h264_chroma_pixels_tab[4]
int msmpeg4_version
0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
void(* draw_edges)(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides)
static const uint8_t mpeg2_dc_scale_table3[128]
void ff_xvmc_field_end(MpegEncContext *s)
Complete frame/field rendering by passing any remaining blocks.
int needs_realloc
Picture needs to be reallocated (eg due to a frame size change)
uint8_t * bitstream_buffer
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output...
void ff_MPV_common_init_ppc(MpegEncContext *s)
int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type)
int field_picture
whether or not the picture was encoded in separate fields
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int16_t(*[2][2] p_field_mv_table)[2]
MV table (2MV per MB) interlaced p-frame encoding.
int16_t(* p_mv_table_base)[2]
static int make_tables_writable(Picture *pic)
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
uint32_t * score_map
map to store the scores
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
const int8_t * table_level
static void free_duplicate_context(MpegEncContext *s)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int padding_bug_score
used to detect the VERY common padding bug in MPEG4
int mb_num
number of MBs of a picture
int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
Find and store the surfaces that are used as reference frames.
void(* idct_add)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
int h263_aic
Advanded INTRA Coding (AIC)
int16_t(* b_back_mv_table)[2]
MV table (1MV per MB) backward mode b-frame encoding.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
int encoding
true if we are encoding (vs decoding)
void(* dct_unquantize_h263_intra)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
void(* dct_unquantize_intra)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
av_cold void ff_MPV_common_init_axp(MpegEncContext *s)
static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s, int16_t *block, int n, int qscale)
int16_t(* b_back_mv_table_base)[2]
static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src)
#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.
void(* dct_unquantize_h263_inter)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
#define FF_MB_DECISION_RD
rate distortion
int alloc_mb_width
mb_width used to allocate tables
#define CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
int picture_in_gop_number
0-> first pic in gop, ...
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
int8_t * max_run[2]
encoding & decoding
const uint8_t ff_alternate_vertical_scan[64]
static av_always_inline void MPV_decode_mb_internal(MpegEncContext *s, int16_t block[12][64], int lowres_flag, int is_mpeg12)
void(* idct_put)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
int ff_MPV_common_frame_size_change(MpegEncContext *s)
Picture ** input_picture
next pictures on display order for encoding
enum OutputFormat out_format
output format
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
static int first_field(const struct video_data *s, int fd)
static const uint8_t offset[511][2]
uint16_t(* dct_offset)[64]
static av_cold int end(AVCodecContext *avctx)
uint8_t * pred_dir_table
used to store pred_dir for partitioned decoding
Multithreading support functions.
#define CODEC_CAP_HWACCEL_VDPAU
Codec can export data for HW decoding (VDPAU).
qpel_mc_func(* qpel_put)[16]
int no_rounding
apply no rounding to motion compensation (MPEG4, msmpeg4, ...) for b-frames rounding mode is always 0...
int(* q_chroma_intra_matrix)[64]
Picture current_picture
copy of the current picture structure.
static int pic_is_unused(MpegEncContext *s, Picture *pic)
static int alloc_picture_tables(MpegEncContext *s, Picture *pic)
int16_t(* b_bidir_forw_mv_table)[2]
MV table (1MV per MB) bidir mode b-frame encoding.
#define FF_DEBUG_VIS_MV_B_BACK
int8_t * max_level[2]
encoding & decoding
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
uint16_t pp_time
time distance between the last 2 p,s,i frames
uint8_t idct_permutation[64]
idct input permutation.
AVBufferRef * mb_type_buf
uint8_t * b_scratchpad
scratchpad used for writing into write only buffers
static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
int flags2
AVCodecContext.flags2.
#define SLICE_FLAG_CODED_ORDER
draw_horiz_band() is called in coded order instead of display
int interlaced_frame
The content of the picture is interlaced.
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int mb_height
number of MBs horizontally & vertically
#define AV_NUM_DATA_POINTERS
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
enum AVPixelFormat ff_pixfmt_list_420[]
void ff_MPV_frame_end(MpegEncContext *s)
int codec_tag
internal codec_tag upper case converted from avctx codec_tag
#define FFSWAP(type, a, b)
int16_t(*[2][2] p_field_mv_table_base)[2]
static int free_context_frame(MpegEncContext *s)
Frees and resets MpegEncContext fields depending on the resolution.
static void update_noise_reduction(MpegEncContext *s)
static void ff_update_block_index(MpegEncContext *s)
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
AVBufferRef * mb_mean_buf
int(* q_inter_matrix)[64]
void ff_xvmc_decode_mb(MpegEncContext *s)
Synthesize the data needed by XvMC to render one macroblock of data.
int(* q_intra_matrix)[64]
precomputed matrix (combine qscale and DCT renorm)
int intra_only
if true, only intra pictures are generated
int16_t * dc_val[3]
used for mpeg4 DC prediction, all 3 arrays must be continuous
int h263_plus
h263 plus headers
int slice_context_count
number of used thread_contexts
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
int last_non_b_pict_type
used for mpeg4 gmc b-frames & ratecontrol
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int stream_codec_tag
internal stream_codec_tag upper case converted from avctx stream_codec_tag
int last_dc[3]
last DC values for MPEG1
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void * opaque
for some private data of the user
static void add_dct(MpegEncContext *s, int16_t *block, int i, uint8_t *dest, int line_size)
static int ff_h263_round_chroma(int x)
#define CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
int mb_skipped
MUST BE SET only during DECODING.
static int find_unused_picture(MpegEncContext *s, int shared)
int partitioned_frame
is current frame partitioned
av_cold void ff_init_vlc_rl(RLTable *rl)
const uint8_t ff_alternate_horizontal_scan[64]
int unrestricted_mv
mv can point outside of the coded picture
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
int active_thread_type
Which multithreading methods are in use by the codec.
int last_lambda_for[5]
last lambda for a specific pict type
int capabilities
Codec capabilities.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s, int16_t *block, int n, int qscale)
void(* dct_unquantize_mpeg2_inter)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
void(* decode_mb)(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
void(* dct_unquantize_mpeg1_intra)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
struct Picture * next_pic
static void put_dct(MpegEncContext *s, int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
int overread_index
the index into ParseContext.buffer of the overread bytes
static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s, int16_t *block, int n, int qscale)
int quarter_sample
1->qpel, 0->half pel ME/MC
uint16_t * mb_type
Table for candidate MB types for encoding.
static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color)
Draw a line from (ex, ey) -> (sx, sy).
int low_delay
no reordering needed / has no b-frames
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic)
Deallocate a picture.
VLC vlc
decoding only deprecated FIXME remove
uint8_t *[2][2] b_field_select_table
Libavcodec external API header.
AVPixelFormat
Pixel format.
int priv_data_size
Size of HW accelerator private data.
static const uint8_t ff_default_chroma_qscale_table[32]
void ff_mpeg_flush(AVCodecContext *avctx)
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
int coded_picture_number
used to set pic->coded_picture_number, should not be used for/by anything else
uint8_t * error_status_table
AVBufferRef * hwaccel_priv_buf
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
#define FF_ARRAY_ELEMS(a)
int n
number of entries of table_vlc minus 1
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
AVBufferRef * motion_val_buf[2]
void(* op_pixels_func)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void(* draw_horiz_band)(struct AVCodecContext *s, const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], int y, int type, int height)
If non NULL, 'draw_horiz_band' is called by the libavcodec decoder to draw a horizontal band...
int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type)
void ff_mpeg_er_frame_start(MpegEncContext *s)
enum AVPictureType pict_type
Picture type of the frame.
struct Picture * last_pic
#define UPDATE_PICTURE(pic)
uint8_t * data
The data buffer.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
int overread
the number of bytes which where irreversibly read from the next frame
uint16_t(* q_inter_matrix16)[2][64]
int next_p_frame_damaged
set if the next p frame is damaged, to avoid showing trashed b frames
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, int16_t *block, int n, int qscale)
Picture new_picture
copy of the source picture structure for encoding.
int width
picture width / height.
uint8_t * mbskip_table
used to avoid copy if macroblock skipped (for black regions for example) and used for b-frame encodin...
void(* clear_blocks)(int16_t *blocks)
int16_t(*[2] motion_val)[2]
Picture * current_picture_ptr
pointer to the current picture
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
unsigned int allocated_bitstream_buffer_size
void * hwaccel_picture_private
hardware accelerator private data
#define FF_DEBUG_DCT_COEFF
int16_t(* ac_val_base)[16]
uint16_t(* q_intra_matrix16)[2][64]
identical to the above but for MMX & these are not permutated, second 64 entries are bias ...
int16_t(*[2][2][2] b_field_mv_table_base)[2]
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
int(* ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2]
[mb_intra][isChroma][level][run][last]
int16_t(* b_forw_mv_table_base)[2]
int16_t(*[12] pblocks)[64]
int block_last_index[12]
last non zero coefficient in block
int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize)
int mb_decision
macroblock decision mode
char * stats_out
pass1 encoding statistics output buffer
uint8_t * mbintra_table
used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
#define FF_DEBUG_VIS_MV_P_FOR
int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
generic function for encode/decode called after coding/decoding the header and before a frame is code...
void ff_draw_horiz_band(AVCodecContext *avctx, DSPContext *dsp, Picture *cur, Picture *last, int y, int h, int picture_structure, int first_field, int draw_edges, int low_delay, int v_edge_pos, int h_edge_pos)
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
RL_VLC_ELEM * rl_vlc[32]
decoding only
preferred ID for MPEG-1/2 video decoding
#define FF_DEBUG_VIS_MB_TYPE
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
int block_index[6]
index to current MB in block based arrays with edges
int xvmc_acceleration
XVideo Motion Acceleration.
int * mb_index2xy
mb_index -> mb_x + mb_y*mb_stride
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int first_field
is 1 for the first field of a field picture 0 otherwise
static const int8_t mv[256][2]
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
#define MV_TYPE_16X16
1 vector for the whole mb
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
void ff_wmv2_add_mb(MpegEncContext *s, int16_t block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr)
uint16_t * mc_mb_var
Table for motion compensated MB variances.
AVBufferRef * qscale_table_buf
int16_t(* b_bidir_forw_mv_table_base)[2]
void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint8_t *mbskip_table, int *low_delay, int mb_width, int mb_height, int mb_stride, int quarter_sample)
Print debugging info for the given picture.
const uint8_t *const ff_mpeg2_dc_scale_table[4]
int coded_picture_number
picture number in bitstream order
uint16_t inter_matrix[64]
int alloc_mb_height
mb_height used to allocate tables
struct MpegEncContext * thread_context[MAX_THREADS]
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
ptrdiff_t linesize
line size, in bytes, may be different from width
static av_const unsigned int ff_sqrt(unsigned int a)
enum AVDiscard skip_idct
Skip IDCT/dequantization for selected frames.
void ff_MPV_common_init_x86(MpegEncContext *s)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
#define FF_THREAD_FRAME
Decode more than one frame at once.
ScanTable intra_scantable
void(* qpel_mc_func)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
uint8_t * coded_block
used for coded block pattern prediction (msmpeg4v3, wmv1)
int height
picture size. must be a multiple of 16
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
const uint8_t ff_mpeg1_dc_scale_table[128]
static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, int16_t *block, int n, int qscale)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
#define MV_TYPE_16X8
2 vectors, one per 16x8 block
void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict)
uint32_t state
contains the last few bytes in MSB order
Picture * picture
main picture buffer
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
BYTE int const BYTE int int int height
int slice_flags
slice flags
void ff_MPV_decode_mb(MpegEncContext *s, int16_t block[12][64])
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
ScanTable intra_h_scantable
op_pixels_func put_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
int16_t(*[2][2][2] b_field_mv_table)[2]
MV table (4MV per MB) interlaced b-frame encoding.
uint8_t * cbp_table
used to store cbp, ac_pred for partitioned decoding
int closed_gop
MPEG1/2 GOP is closed.
#define UPDATE_TABLE(table)
unsigned int avpriv_toupper4(unsigned int x)
AVFrame * coded_frame
the picture in the bitstream
uint8_t * index_run[2]
encoding only
int input_picture_number
used to set pic->display_picture_number, should not be used for/by anything else
ptrdiff_t uvlinesize
line size, for chroma in bytes, may be different from width
DSPContext dsp
pointers for accelerated dsp functions
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int f_code
forward MV resolution
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
int max_b_frames
max number of b-frames for encoding
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
#define ROUNDED_DIV(a, b)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int size
Size of data in bytes.
int h263_pred
use mpeg4/h263 ac/dc predictions
int16_t(* b_bidir_back_mv_table)[2]
MV table (1MV per MB) bidir mode b-frame encoding.
static int init_context_frame(MpegEncContext *s)
Initialize and allocates MpegEncContext fields dependent on the resolution.
uint8_t *[2] p_field_select_table
int16_t(* b_direct_mv_table)[2]
MV table (1MV per MB) direct mode b-frame encoding.
const uint8_t * c_dc_scale_table
qscale -> c_dc_scale table
qpel_mc_func(* qpel_avg)[16]
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
int16_t(* b_forw_mv_table)[2]
MV table (1MV per MB) forward mode b-frame encoding.
int b8_stride
2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
int noise_reduction
noise reduction strength
void(* h264_chroma_mc_func)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x, int y)
#define FF_DEBUG_VIS_MV_B_FOR
static void dct_unquantize_h263_intra_c(MpegEncContext *s, int16_t *block, int n, int qscale)
Picture * next_picture_ptr
pointer to the next picture (for bidir pred)
struct AVCodecContext * avctx
A reference to a data buffer.
static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color)
Draw an arrow from (ex, ey) -> (sx, sy).
discard all non reference
av_cold void ff_MPV_common_init_bfin(MpegEncContext *s)
#define CODEC_FLAG_EMU_EDGE
Don't draw edges.
static void exchange_uv(MpegEncContext *s)
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
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 ...
AVBufferRef * mbskip_table_buf
void ff_MPV_common_defaults(MpegEncContext *s)
Set the given MpegEncContext to common defaults (same for encoding and decoding). ...
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
static void dct_unquantize_h263_inter_c(MpegEncContext *s, int16_t *block, int n, int qscale)
int b4_stride
4*mb_width+1 used for some 4x4 block arrays to allow simple addressing
Picture last_picture
copy of the previous picture structure.
uint8_t * obmc_scratchpad
#define SLICE_FLAG_ALLOW_FIELD
allow draw_horiz_band() with field slices (MPEG2 field pics)
static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
Allocate a frame buffer.
Picture * last_picture_ptr
pointer to the previous picture.
const uint8_t * chroma_qscale_table
qscale -> chroma_qscale (h263)
uint32_t * map
map to avoid duplicate evaluations
int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src)
void(* dct_unquantize_mpeg1_inter)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
H264ChromaContext h264chroma
int16_t(* blocks)[12][64]
h264_chroma_mc_func avg_h264_chroma_pixels_tab[4]
int slices
Number of slices.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_INVALIDDATA
int top_field_first
If the content is interlaced, is top field displayed first.
void ff_MPV_common_end(MpegEncContext *s)
#define MV_TYPE_DMV
2 vectors, special mpeg2 Dual Prime Vectors
struct AVHWAccel * hwaccel
Hardware accelerator in use.
av_cold void ff_init_rl(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
int ff_MPV_lowest_referenced_row(MpegEncContext *s, int dir)
find the lowest MB row referenced in the MVs
int16_t(* block)[64]
points to one of the following blocks
ParseContext parse_context
VLC_TYPE(* table)[2]
code, bits
static void add_dequant_dct(MpegEncContext *s, int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
Picture next_picture
copy of the next picture structure.
AVBufferRef * mc_mb_var_buf
int key_frame
1 -> keyframe, 0-> not
static const uint8_t mpeg2_dc_scale_table1[128]
#define CONFIG_WMV2_DECODER
static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_based, int bottom_field, int field_select, uint8_t **ref_picture, h264_chroma_mc_func *pix_op, int motion_x, int motion_y, int h, int mb_y)
Picture ** reordered_input_picture
pointer to the next pictures in codedorder for encoding
static void free_picture_tables(Picture *pic)
static int init_er(MpegEncContext *s)
static const uint8_t mpeg2_dc_scale_table2[128]
int chroma_qscale
chroma QP
void(* dct_unquantize_mpeg2_intra)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
int mb_var_sum
sum of MB variance for current frame
#define REBASE_PICTURE(pic, new_ctx, old_ctx)
static int hpel_motion_lowres(MpegEncContext *s, uint8_t *dest, uint8_t *src, int field_based, int field_select, int src_x, int src_y, int width, int height, ptrdiff_t stride, int h_edge_pos, int v_edge_pos, int w, int h, h264_chroma_mc_func *pix_op, int motion_x, int motion_y)
void ff_er_frame_start(ERContext *s)
int flags
AVCodecContext.flags (HQ, MV4, ...)
int mc_mb_var_sum
motion compensated MB variance for current frame
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 AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int ref_picture(H264Context *h, Picture *dst, Picture *src)
av_cold void ff_MPV_common_init_arm(MpegEncContext *s)
int ff_find_unused_picture(MpegEncContext *s, int shared)
#define MV_TYPE_8X8
4 vectors (h263, mpeg4 4MV)
int16_t(* b_direct_mv_table_base)[2]
int b_code
backward MV resolution for B Frames (mpeg4)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void MPV_motion_lowres(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, h264_chroma_mc_func *pix_op)
motion compensation of a single macroblock
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void ff_MPV_decode_defaults(MpegEncContext *s)
Set the given MpegEncContext to defaults for decoding.
uint16_t pb_time
time distance between the last b and p,s,i frame
AVBufferRef * ref_index_buf[2]
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.