52 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
53 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
58 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
59 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
60 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
61 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
62 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
63 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
64 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
65 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
70 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
71 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
72 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
73 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
74 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
75 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
76 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
77 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
82 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
83 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
85 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
86 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
87 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
89 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
95 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
96 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
97 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
98 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
99 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
100 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
101 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
112 0, 1, 2, 3, 8, 9, 16, 17,
113 10, 11, 4, 5, 6, 7, 15, 14,
114 13, 12, 19, 18, 24, 25, 32, 33,
115 26, 27, 20, 21, 22, 23, 28, 29,
116 30, 31, 34, 35, 40, 41, 48, 49,
117 42, 43, 36, 37, 38, 39, 44, 45,
118 46, 47, 50, 51, 56, 57, 58, 59,
119 52, 53, 54, 55, 60, 61, 62, 63,
123 0, 8, 16, 24, 1, 9, 2, 10,
124 17, 25, 32, 40, 48, 56, 57, 49,
125 41, 33, 26, 18, 3, 11, 4, 12,
126 19, 27, 34, 42, 50, 58, 35, 43,
127 51, 59, 20, 28, 5, 13, 6, 14,
128 21, 29, 36, 44, 52, 60, 37, 45,
129 53, 61, 22, 30, 7, 15, 23, 31,
130 38, 46, 54, 62, 39, 47, 55, 63,
134 int16_t *
block,
int n,
int qscale)
136 int i,
level, nCoeffs;
137 const uint16_t *quant_matrix;
144 for(i=1;i<=nCoeffs;i++) {
150 level = (int)(level * qscale * quant_matrix[j]) >> 3;
151 level = (level - 1) | 1;
154 level = (int)(level * qscale * quant_matrix[j]) >> 3;
155 level = (level - 1) | 1;
163 int16_t *
block,
int n,
int qscale)
165 int i,
level, nCoeffs;
166 const uint16_t *quant_matrix;
171 for(i=0; i<=nCoeffs; i++) {
177 level = (((level << 1) + 1) * qscale *
178 ((int) (quant_matrix[j]))) >> 4;
179 level = (level - 1) | 1;
182 level = (((level << 1) + 1) * qscale *
183 ((int) (quant_matrix[j]))) >> 4;
184 level = (level - 1) | 1;
192 int16_t *
block,
int n,
int qscale)
194 int i,
level, nCoeffs;
195 const uint16_t *quant_matrix;
202 for(i=1;i<=nCoeffs;i++) {
208 level = (int)(level * qscale * quant_matrix[j]) >> 3;
211 level = (int)(level * qscale * quant_matrix[j]) >> 3;
219 int16_t *
block,
int n,
int qscale)
221 int i,
level, nCoeffs;
222 const uint16_t *quant_matrix;
231 for(i=1;i<=nCoeffs;i++) {
237 level = (int)(level * qscale * quant_matrix[j]) >> 3;
240 level = (int)(level * qscale * quant_matrix[j]) >> 3;
250 int16_t *
block,
int n,
int qscale)
252 int i,
level, nCoeffs;
253 const uint16_t *quant_matrix;
260 for(i=0; i<=nCoeffs; i++) {
266 level = (((level << 1) + 1) * qscale *
267 ((int) (quant_matrix[j]))) >> 4;
270 level = (((level << 1) + 1) * qscale *
271 ((int) (quant_matrix[j]))) >> 4;
281 int16_t *
block,
int n,
int qscale)
283 int i,
level, qmul, qadd;
292 qadd = (qscale - 1) | 1;
301 for(i=1; i<=nCoeffs; i++) {
305 level = level * qmul - qadd;
307 level = level * qmul + qadd;
315 int16_t *
block,
int n,
int qscale)
317 int i,
level, qmul, qadd;
322 qadd = (qscale - 1) | 1;
327 for(i=0; i<=nCoeffs; i++) {
331 level = level * qmul - qadd;
333 level = level * qmul + qadd;
342 int mb_x,
int mb_y,
int mb_intra,
int mb_skipped)
352 memcpy(s->
mv,
mv,
sizeof(*
mv));
365 "Interlaced error concealment is not fully implemented\n");
372 memset(dst + h*linesize, 128, 16);
378 memset(dst + h*linesize, 128, 8);
392 for (i=0; i<4; i++) {
505 if (r < 0 || !pic->f->buf[0]) {
513 for (i = 0; pic->
f->
data[i]; i++) {
538 "get_buffer() failed (stride changed)\n");
545 "get_buffer() failed (uv stride mismatch)\n");
553 "get_buffer() failed to allocate context scratch buffers.\n");
575 for (i = 0; i < 2; i++) {
606 int mv_size = 2 * (b8_array_size + 4) *
sizeof(int16_t);
607 int ref_index_size = 4 * mb_array_size;
609 for (i = 0; mv_size && i < 2; i++) {
626 #define MAKE_WRITABLE(table) \
629 (ret = av_buffer_make_writable(&pic->table)) < 0)\
640 for (i = 0; i < 2; i++) {
692 for (i = 0; i < 2; i++) {
728 memset((
uint8_t*)pic + off, 0,
sizeof(*pic) - off);
735 #define UPDATE_TABLE(table)\
738 (!dst->table || dst->table->buffer != src->table->buffer)) {\
739 av_buffer_unref(&dst->table);\
740 dst->table = av_buffer_ref(src->table);\
742 ff_free_picture_tables(dst);\
743 return AVERROR(ENOMEM);\
754 for (i = 0; i < 2; i++) {
765 for (i = 0; i < 2; i++) {
827 int yc_size = y_size + 2 * c_size;
847 2 * 64 *
sizeof(
int), fail)
853 for (i = 0; i < 12; i++) {
862 yc_size *
sizeof(int16_t) * 16, fail);
895 #define COPY(a) bak->a = src->a
896 COPY(edge_emu_buffer);
901 COPY(obmc_scratchpad);
929 for (i = 0; i < 12; i++) {
937 "scratch buffers.\n");
966 if (
s1->context_initialized){
998 if (
s1->picture[i].f->buf[0] &&
1003 #define UPDATE_PICTURE(pic)\
1005 ff_mpeg_unref_picture(s, &s->pic);\
1006 if (s1->pic.f && s1->pic.f->buf[0])\
1007 ret = ff_mpeg_ref_picture(s, &s->pic, &s1->pic);\
1009 ret = update_picture_tables(&s->pic, &s1->pic);\
1018 #define REBASE_PICTURE(pic, new_ctx, old_ctx) \
1019 ((pic && pic >= old_ctx->picture && \
1020 pic < old_ctx->picture + MAX_PICTURE_COUNT) ? \
1021 &new_ctx->picture[pic - old_ctx->picture] : NULL)
1034 (
char *) &
s1->pb_field_time +
sizeof(
s1->pb_field_time) -
1035 (
char *) &
s1->last_time_base);
1045 if (
s1->bitstream_buffer) {
1046 if (
s1->bitstream_buffer_size +
1050 s1->allocated_bitstream_buffer_size);
1053 s1->bitstream_buffer_size);
1063 "scratch buffers.\n");
1068 "be allocated due to unknown size.\n");
1073 (
char *) &
s1->rtp_mode - (
char *) &
s1->progressive_sequence);
1075 if (!
s1->first_field) {
1077 if (
s1->current_picture_ptr)
1173 int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x,
y;
1197 yc_size = y_size + 2 * c_size;
1230 mb_array_size *
sizeof(
float), fail);
1232 mb_array_size *
sizeof(
float), fail);
1239 for (i = 0; i < 2; i++) {
1241 for (j = 0; j < 2; j++) {
1242 for (k = 0; k < 2; k++) {
1245 mv_table_size * 2 *
sizeof(int16_t),
1274 for (i = 0; i < yc_size; i++)
1338 for (i = 0; i < 2; i++) {
1339 for (j = 0; j < 2; j++) {
1340 for (k = 0; k < 2; k++) {
1391 "decoding to AV_PIX_FMT_NONE is not supported.\n");
1402 " reducing to %d\n", nb_slices, max_slices);
1403 nb_slices = max_slices;
1450 if (nb_slices > 1) {
1451 for (i = 1; i < nb_slices; i++) {
1456 for (i = 0; i < nb_slices; i++) {
1460 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1462 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1501 for (i = 0; i < 2; i++) {
1502 for (j = 0; j < 2; j++) {
1503 for (k = 0; k < 2; k++) {
1578 if (nb_slices > 1) {
1579 for (i = 1; i < nb_slices; i++) {
1584 for (i = 0; i < nb_slices; i++) {
1588 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1590 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1671 for (last = 0; last < 2; last++) {
1680 memset(max_level, 0,
MAX_RUN + 1);
1682 memset(index_run, rl->
n,
MAX_RUN + 1);
1683 for (i = start; i <
end; i++) {
1686 if (index_run[run] == rl->
n)
1688 if (level > max_level[run])
1690 if (run > max_run[level])
1694 rl->
max_level[last] = static_store[last];
1707 memcpy(rl->
index_run[last], index_run, MAX_RUN + 1);
1715 VLC vlc = { .
table =
table, .table_allocated = static_size };
1719 for (q = 0; q < 32; q++) {
1721 int qadd = (q - 1) | 1;
1728 int code = vlc.
table[i][0];
1735 }
else if (len < 0) {
1739 if (code == rl->
n) {
1745 if (code >= rl->
last) run += 192;
1770 if (!pic->
f->
buf[0])
1794 "Internal error, picture buffer overflow\n");
1826 int i, h_chroma_shift, v_chroma_shift;
1830 for(i=0; i<frame->
height; i++)
1834 0x80, FF_CEIL_RSHIFT(frame->
width, h_chroma_shift));
1836 0x80, FF_CEIL_RSHIFT(frame->
width, h_chroma_shift));
1870 "releasing zombie picture\n");
1930 av_dlog(s->
avctx,
"L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
1940 int h_chroma_shift, v_chroma_shift;
1942 &h_chroma_shift, &v_chroma_shift);
1945 "allocating dummy last picture for B frame\n");
1948 "warning: first frame is no keyframe\n");
1951 "allocate dummy last picture for field based first keyframe\n");
1971 for(i=0; i<avctx->
height; i++)
1973 0x80, avctx->
width);
1976 0x80, FF_CEIL_RSHIFT(avctx->
width, h_chroma_shift));
1978 0x80, FF_CEIL_RSHIFT(avctx->
width, h_chroma_shift));
1982 for(i=0; i<avctx->
height; i++)
2012 #if 0 // BUFREF-FIXME
2036 for (i = 0; i < 4; i++) {
2081 static int clip_line(
int *sx,
int *sy,
int *ex,
int *ey,
int maxx)
2089 *sy = *ey + (*sy - *ey) * (int64_t)*ex / (*ex - *sx);
2096 *ey = *sy + (*ey - *sy) * (int64_t)(maxx - *sx) / (*ex - *sx);
2115 if (
clip_line(&sx, &sy, &ex, &ey, w - 1))
2117 if (
clip_line(&sy, &sx, &ey, &ex, h - 1))
2120 sx = av_clip(sx, 0, w - 1);
2121 sy = av_clip(sy, 0, h - 1);
2122 ex = av_clip(ex, 0, w - 1);
2123 ey = av_clip(ey, 0, h - 1);
2125 buf[sy * stride + sx] +=
color;
2134 f = ((ey - sy) << 16) / ex;
2135 for (x = 0; x <= ex; x++) {
2137 fr = (x * f) & 0xFFFF;
2138 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
2139 if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16;
2149 f = ((ex - sx) << 16) / ey;
2152 for(y= 0; y <= ey; y++){
2154 fr = (y*f) & 0xFFFF;
2155 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
2156 if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16;
2169 int ey,
int w,
int h,
int stride,
int color,
int tail,
int direction)
2178 sx = av_clip(sx, -100, w + 100);
2179 sy = av_clip(sy, -100, h + 100);
2180 ex = av_clip(ex, -100, w + 100);
2181 ey = av_clip(ey, -100, h + 100);
2186 if (dx * dx + dy * dy > 3 * 3) {
2200 draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
2201 draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
2203 draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
2208 int dst_x,
int dst_y,
2209 int src_x,
int src_y,
2218 mb->
source = direction ? 1 : -1;
2227 uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2],
2229 int mb_width,
int mb_height,
int mb_stride,
int quarter_sample)
2232 const int shift = 1 + quarter_sample;
2234 const int mv_stride = (mb_width << mv_sample_log2) +
2236 int mb_x, mb_y, mbcount = 0;
2244 for (mb_y = 0; mb_y < mb_height; mb_y++) {
2245 for (mb_x = 0; mb_x < mb_width; mb_x++) {
2246 int i, direction, mb_type = mbtype_table[mb_x + mb_y * mb_stride];
2247 for (direction = 0; direction < 2; direction++) {
2251 for (i = 0; i < 4; i++) {
2252 int sx = mb_x * 16 + 4 + 8 * (i & 1);
2253 int sy = mb_y * 16 + 4 + 8 * (i >> 1);
2254 int xy = (mb_x * 2 + (i & 1) +
2255 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2256 int mx = (motion_val[direction][xy][0] >>
shift) + sx;
2257 int my = (motion_val[direction][xy][1] >>
shift) + sy;
2258 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, direction);
2260 }
else if (
IS_16X8(mb_type)) {
2261 for (i = 0; i < 2; i++) {
2262 int sx = mb_x * 16 + 8;
2263 int sy = mb_y * 16 + 4 + 8 * i;
2264 int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
2265 int mx = (motion_val[direction][xy][0] >>
shift);
2266 int my = (motion_val[direction][xy][1] >>
shift);
2271 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy, mx + sx, my + sy, direction);
2273 }
else if (
IS_8X16(mb_type)) {
2274 for (i = 0; i < 2; i++) {
2275 int sx = mb_x * 16 + 4 + 8 * i;
2276 int sy = mb_y * 16 + 8;
2277 int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
2278 int mx = motion_val[direction][xy][0] >>
shift;
2279 int my = motion_val[direction][xy][1] >>
shift;
2284 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy, mx + sx, my + sy, direction);
2287 int sx = mb_x * 16 + 8;
2288 int sy = mb_y * 16 + 8;
2289 int xy = (mb_x + mb_y * mv_stride) << mv_sample_log2;
2290 int mx = (motion_val[direction][xy][0]>>
shift) + sx;
2291 int my = (motion_val[direction][xy][1]>>
shift) + sy;
2292 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, direction);
2314 if (avctx->
hwaccel || !mbtype_table
2324 for (y = 0; y < mb_height; y++) {
2325 for (x = 0; x < mb_width; x++) {
2327 int count = mbskip_table[x + y * mb_stride];
2334 qscale_table[x + y * mb_stride]);
2337 int mb_type = mbtype_table[x + y * mb_stride];
2353 else if (
IS_GMC(mb_type))
2393 int h_chroma_shift, v_chroma_shift, block_height;
2395 const int shift = 1 + quarter_sample;
2401 const int mv_stride = (mb_width << mv_sample_log2) +
2412 ptr = pict->
data[0];
2414 block_height = 16 >> v_chroma_shift;
2416 for (mb_y = 0; mb_y < mb_height; mb_y++) {
2418 for (mb_x = 0; mb_x < mb_width; mb_x++) {
2419 const int mb_index = mb_x + mb_y * mb_stride;
2421 if ((avctx->
debug_mv) && motion_val[0]) {
2423 for (type = 0; type < 3; type++) {
2445 if (!
USES_LIST(mbtype_table[mb_index], direction))
2448 if (
IS_8X8(mbtype_table[mb_index])) {
2450 for (i = 0; i < 4; i++) {
2451 int sx = mb_x * 16 + 4 + 8 * (i & 1);
2452 int sy = mb_y * 16 + 4 + 8 * (i >> 1);
2453 int xy = (mb_x * 2 + (i & 1) +
2454 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2455 int mx = (motion_val[direction][xy][0] >>
shift) + sx;
2456 int my = (motion_val[direction][xy][1] >>
shift) + sy;
2458 height, pict->
linesize[0], 100, 0, direction);
2460 }
else if (
IS_16X8(mbtype_table[mb_index])) {
2462 for (i = 0; i < 2; i++) {
2463 int sx = mb_x * 16 + 8;
2464 int sy = mb_y * 16 + 4 + 8 * i;
2465 int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
2466 int mx = (motion_val[direction][xy][0] >>
shift);
2467 int my = (motion_val[direction][xy][1] >>
shift);
2472 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2473 height, pict->
linesize[0], 100, 0, direction);
2475 }
else if (
IS_8X16(mbtype_table[mb_index])) {
2477 for (i = 0; i < 2; i++) {
2478 int sx = mb_x * 16 + 4 + 8 * i;
2479 int sy = mb_y * 16 + 8;
2480 int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
2481 int mx = motion_val[direction][xy][0] >>
shift;
2482 int my = motion_val[direction][xy][1] >>
shift;
2487 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2488 height, pict->
linesize[0], 100, 0, direction);
2491 int sx= mb_x * 16 + 8;
2492 int sy= mb_y * 16 + 8;
2493 int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
2494 int mx= (motion_val[direction][xy][0]>>
shift) + sx;
2495 int my= (motion_val[direction][xy][1]>>
shift) + sy;
2496 draw_arrow(ptr, sx, sy, mx, my, width, height, pict->
linesize[0], 100, 0, direction);
2502 uint64_t
c = (qscale_table[mb_index] * 128 / 31) *
2503 0x0101010101010101ULL;
2505 for (y = 0; y < block_height; y++) {
2506 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2507 (block_height * mb_y + y) *
2509 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2510 (block_height * mb_y + y) *
2516 int mb_type = mbtype_table[mb_index];
2519 #define COLOR(theta, r) \
2520 u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
2521 v = (int)(128 + r * sin(theta * 3.141592 / 180));
2538 }
else if (
IS_GMC(mb_type)) {
2540 }
else if (
IS_SKIP(mb_type)) {
2551 u *= 0x0101010101010101ULL;
2552 v *= 0x0101010101010101ULL;
2553 for (y = 0; y < block_height; y++) {
2554 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2555 (block_height * mb_y + y) * pict->
linesize[1]) = u;
2556 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2557 (block_height * mb_y + y) * pict->
linesize[2]) = v;
2562 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 0 +
2563 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2564 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 8 +
2565 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2568 for (y = 0; y < 16; y++)
2569 pict->
data[0][16 * mb_x + 8 + (16 * mb_y + y) *
2572 if (
IS_8X8(mb_type) && mv_sample_log2 >= 2) {
2573 int dm = 1 << (mv_sample_log2 - 2);
2574 for (i = 0; i < 4; i++) {
2575 int sx = mb_x * 16 + 8 * (i & 1);
2576 int sy = mb_y * 16 + 8 * (i >> 1);
2577 int xy = (mb_x * 2 + (i & 1) +
2578 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2581 if (mv[0] != mv[dm] ||
2582 mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
2583 for (y = 0; y < 8; y++)
2584 pict->
data[0][sx + 4 + (sy + y) * pict->
linesize[0]] ^= 0x80;
2585 if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
2586 *(uint64_t *)(pict->
data[0] + sx + (sy + 4) *
2587 pict->
linesize[0]) ^= 0x8080808080808080ULL;
2596 mbskip_table[mb_index] = 0;
2623 int field_based,
int field_select,
2624 int src_x,
int src_y,
2626 int h_edge_pos,
int v_edge_pos,
2628 int motion_x,
int motion_y)
2631 const int op_index =
FFMIN(lowres, 3);
2632 const int s_mask = (2 <<
lowres) - 1;
2641 sx = motion_x & s_mask;
2642 sy = motion_y & s_mask;
2643 src_x += motion_x >> lowres + 1;
2644 src_y += motion_y >> lowres + 1;
2646 src += src_y * stride + src_x;
2648 if ((
unsigned)src_x >
FFMAX( h_edge_pos - (!!sx) - w, 0) ||
2649 (unsigned)src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2652 w + 1, (h + 1) << field_based,
2653 src_x, src_y << field_based,
2654 h_edge_pos, v_edge_pos);
2659 sx = (sx << 2) >>
lowres;
2660 sy = (sy << 2) >>
lowres;
2663 pix_op[op_index](dest,
src,
stride, h, sx, sy);
2677 int motion_x,
int motion_y,
2680 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
2681 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy;
2682 ptrdiff_t uvlinesize, linesize;
2685 const int block_s = 8>>
lowres;
2686 const int s_mask = (2 <<
lowres) - 1;
2699 motion_y += (bottom_field - field_select)*((1 << lowres)-1);
2702 sx = motion_x & s_mask;
2703 sy = motion_y & s_mask;
2704 src_x = s->
mb_x * 2 * block_s + (motion_x >> lowres + 1);
2705 src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >> lowres + 1);
2708 uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
2709 uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
2710 uvsrc_x = src_x >> 1;
2711 uvsrc_y = src_y >> 1;
2716 uvsx = (2 * mx) & s_mask;
2717 uvsy = (2 * my) & s_mask;
2718 uvsrc_x = s->
mb_x * block_s + (mx >>
lowres);
2719 uvsrc_y = mb_y * block_s + (my >>
lowres);
2726 uvsrc_x = s->
mb_x * block_s + (mx >> lowres + 1);
2727 uvsrc_y = (mb_y * block_s >> field_based) + (my >> lowres + 1);
2733 uvsy = motion_y & s_mask;
2735 uvsrc_x = s->
mb_x*block_s + (mx >> (lowres+1));
2738 uvsx = motion_x & s_mask;
2739 uvsy = motion_y & s_mask;
2746 ptr_y = ref_picture[0] + src_y * linesize + src_x;
2747 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
2748 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
2750 if ((
unsigned) src_x >
FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
2751 (
unsigned) src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2753 linesize >> field_based, linesize >> field_based,
2754 17, 17 + field_based,
2755 src_x, src_y << field_based, h_edge_pos,
2762 uvlinesize >> field_based, uvlinesize >> field_based,
2764 uvsrc_x, uvsrc_y << field_based,
2765 h_edge_pos >> 1, v_edge_pos >> 1);
2767 uvlinesize >> field_based,uvlinesize >> field_based,
2769 uvsrc_x, uvsrc_y << field_based,
2770 h_edge_pos >> 1, v_edge_pos >> 1);
2789 sx = (sx << 2) >>
lowres;
2790 sy = (sy << 2) >>
lowres;
2791 pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
2795 uvsx = (uvsx << 2) >>
lowres;
2796 uvsy = (uvsy << 2) >>
lowres;
2798 pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy);
2799 pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy);
2812 const int op_index =
FFMIN(lowres, 3);
2813 const int block_s = 8 >>
lowres;
2814 const int s_mask = (2 <<
lowres) - 1;
2815 const int h_edge_pos = s->
h_edge_pos >> lowres + 1;
2816 const int v_edge_pos = s->
v_edge_pos >> lowres + 1;
2817 int emu = 0, src_x, src_y, sx, sy;
2833 src_x = s->
mb_x * block_s + (mx >> lowres + 1);
2834 src_y = s->
mb_y * block_s + (my >> lowres + 1);
2837 ptr = ref_picture[1] +
offset;
2838 if ((
unsigned) src_x >
FFMAX(h_edge_pos - (!!sx) - block_s, 0) ||
2839 (unsigned) src_y >
FFMAX(v_edge_pos - (!!sy) - block_s, 0)) {
2843 src_x, src_y, h_edge_pos, v_edge_pos);
2847 sx = (sx << 2) >>
lowres;
2848 sy = (sy << 2) >>
lowres;
2849 pix_op[op_index](dest_cb, ptr, s->
uvlinesize, block_s, sx, sy);
2851 ptr = ref_picture[2] +
offset;
2856 src_x, src_y, h_edge_pos, v_edge_pos);
2859 pix_op[op_index](dest_cr, ptr, s->
uvlinesize, block_s, sx, sy);
2876 int dir,
uint8_t **ref_picture,
2882 const int block_s = 8 >>
lowres;
2891 ref_picture, pix_op,
2892 s->
mv[dir][0][0], s->
mv[dir][0][1],
2898 for (i = 0; i < 4; i++) {
2901 ref_picture[0], 0, 0,
2902 (2 * mb_x + (i & 1)) * block_s,
2903 (2 * mb_y + (i >> 1)) * block_s,
2906 block_s, block_s, pix_op,
2907 s->
mv[dir][i][0], s->
mv[dir][i][1]);
2909 mx += s->
mv[dir][i][0];
2910 my += s->
mv[dir][i][1];
2922 ref_picture, pix_op,
2923 s->
mv[dir][0][0], s->
mv[dir][0][1],
2928 ref_picture, pix_op,
2929 s->
mv[dir][1][0], s->
mv[dir][1][1],
2939 ref_picture, pix_op,
2941 s->
mv[dir][0][1], 2 * block_s, mb_y >> 1);
2945 for (i = 0; i < 2; i++) {
2950 ref2picture = ref_picture;
2957 ref2picture, pix_op,
2958 s->
mv[dir][i][0], s->
mv[dir][i][1] +
2959 2 * block_s * i, block_s, mb_y >> 1);
2961 dest_y += 2 * block_s * s->
linesize;
2968 for (i = 0; i < 2; i++) {
2970 for (j = 0; j < 2; j++) {
2973 ref_picture, pix_op,
2974 s->
mv[dir][2 * i + j][0],
2975 s->
mv[dir][2 * i + j][1],
2981 for (i = 0; i < 2; i++) {
2984 ref_picture, pix_op,
2985 s->
mv[dir][2 * i][0],s->
mv[dir][2 * i][1],
2986 2 * block_s, mb_y >> 1);
3009 int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->
quarter_sample;
3010 int my, off, i, mvs;
3029 for (i = 0; i < mvs; i++) {
3030 my = s->
mv[dir][i][1]<<qpel_shift;
3031 my_max =
FFMAX(my_max, my);
3032 my_min =
FFMIN(my_min, my);
3035 off = (
FFMAX(-my_min, my_max) + 63) >> 6;
3044 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
3060 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
3082 memset(s->
ac_val[0][xy ], 0, 32 *
sizeof(int16_t));
3083 memset(s->
ac_val[0][xy + wrap], 0, 32 *
sizeof(int16_t));
3096 memset(s->
ac_val[1][xy], 0, 16 *
sizeof(int16_t));
3097 memset(s->
ac_val[2][xy], 0, 16 *
sizeof(int16_t));
3114 int lowres_flag,
int is_mpeg12)
3129 for(j=0; j<64; j++){
3156 uint8_t *dest_y, *dest_cb, *dest_cr;
3157 int dct_linesize, dct_offset;
3163 const int block_size= lowres_flag ? 8>>s->
avctx->
lowres : 8;
3182 dct_offset = s->
interlaced_dct ? linesize : linesize * block_size;
3186 dest_cb= s->
dest[1];
3187 dest_cr= s->
dest[2];
3270 add_dct(s, block[0], 0, dest_y , dct_linesize);
3271 add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
3272 add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
3273 add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
3277 add_dct(s, block[4], 4, dest_cb, uvlinesize);
3278 add_dct(s, block[5], 5, dest_cr, uvlinesize);
3282 dct_offset = s->
interlaced_dct ? uvlinesize : uvlinesize*block_size;
3284 add_dct(s, block[4], 4, dest_cb, dct_linesize);
3285 add_dct(s, block[5], 5, dest_cr, dct_linesize);
3286 add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
3287 add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
3289 add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
3290 add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
3291 add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
3292 add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
3304 put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->
qscale);
3305 put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->
qscale);
3306 put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->
qscale);
3323 s->
idsp.
idct_put(dest_y + block_size, dct_linesize, block[1]);
3324 s->
idsp.
idct_put(dest_y + dct_offset, dct_linesize, block[2]);
3325 s->
idsp.
idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
3334 dct_offset = s->
interlaced_dct ? uvlinesize : uvlinesize*block_size;
3338 s->
idsp.
idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
3339 s->
idsp.
idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
3341 s->
idsp.
idct_put(dest_cb + block_size, dct_linesize, block[8]);
3342 s->
idsp.
idct_put(dest_cr + block_size, dct_linesize, block[9]);
3343 s->
idsp.
idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
3344 s->
idsp.
idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
3398 s->
dest[0] += s->
mb_y * linesize << mb_size;
3402 s->
dest[0] += (s->
mb_y>>1) * linesize << mb_size;
3426 for(i=0; i<=last; i++){
3427 const int j= scantable[i];
3432 for(i=0; i<=last; i++){
3433 const int j= scantable[i];
3434 const int perm_j= permutation[j];
3435 block[perm_j]= temp[j];
3474 else if (qscale > 31)
int bitstream_buffer_size
uint8_t * scratchpad
data area for the ME algo, so that the ME does not need to malloc/free
int last
number of values for last = 0
#define FF_DEBUG_DCT_COEFF
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)
const struct AVCodec * codec
int16_t(* b_bidir_back_mv_table_base)[2]
av_cold void ff_mpv_common_init_arm(MpegEncContext *s)
discard all frames except keyframes
void ff_init_block_index(MpegEncContext *s)
#define MAX_PICTURE_COUNT
av_cold void ff_mpv_common_init_neon(MpegEncContext *s)
ScanTable intra_v_scantable
av_cold void ff_mpegvideodsp_init(MpegVideoDSPContext *c)
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...
This structure describes decoded (raw) audio or video data.
#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)
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
#define FF_DEBUG_VIS_QP
only access through AVOptions from outside libavcodec
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
uint8_t * mb_mean
Table for MB luminance.
int coded_width
Bitstream width / height, may be different from width/height e.g.
static int clip_line(int *sx, int *sy, int *ex, int *ey, int maxx)
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.
int16_t src_x
Absolute source position.
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)
const uint8_t ff_alternate_horizontal_scan[64]
uint8_t * coded_block_base
static int update_picture_tables(Picture *dst, Picture *src)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
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.
void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last)
Permute an 8x8 block.
int16_t(*[3] ac_val)[16]
used for mpeg4 AC prediction, all 3 arrays must be continuous
av_cold void ff_init_vlc_rl(RLTable *rl, unsigned static_size)
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
h264_chroma_mc_func put_h264_chroma_pixels_tab[4]
void * opaque
for some private data of the user
static void gray8(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h)
static void gray_frame(AVFrame *frame)
int msmpeg4_version
0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
static const uint8_t mpeg2_dc_scale_table3[128]
int needs_realloc
Picture needs to be reallocated (eg due to a frame size change)
#define HAVE_INTRINSICS_NEON
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(* clear_blocks)(int16_t *blocks)
int field_picture
whether or not the picture was encoded in separate fields
int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int qp_type)
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)
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
uint32_t * score_map
map to store the scores
#define FF_ARRAY_ELEMS(a)
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)
#define FF_DEBUG_VIS_MV_B_BACK
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.
#define FF_DEBUG_VIS_MB_TYPE
only access through AVOptions from outside libavcodec
int padding_bug_score
used to detect the VERY common padding bug in MPEG4
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
int mb_num
number of MBs of a picture
void ff_draw_horiz_band(AVCodecContext *avctx, AVFrame *cur, AVFrame *last, int y, int h, int picture_structure, int first_field, int low_delay)
Draw a horizontal band if supported.
int h263_aic
Advanded INTRA Coding (AIC)
int16_t(* b_back_mv_table)[2]
MV table (1MV per MB) backward mode b-frame encoding.
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)
static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s, int16_t *block, int n, int qscale)
Macro definitions for various function/variable attributes.
int16_t(* b_back_mv_table_base)[2]
#define REBASE_PICTURE(pic, new_ctx, old_ctx)
static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src)
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)
int av_codec_is_encoder(const AVCodec *codec)
int alloc_mb_width
mb_width used to allocate tables
#define CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
struct AVHWAccel * hwaccel
Hardware accelerator in use.
#define USES_LIST(a, list)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_linesize, ptrdiff_t src_linesize, 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...
int8_t * max_run[2]
encoding & decoding
av_cold void ff_mpv_common_init_axp(MpegEncContext *s)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
enum OutputFormat out_format
output format
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
int ff_mpv_common_frame_size_change(MpegEncContext *s)
static av_cold int end(AVCodecContext *avctx)
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])
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]
int16_t dst_x
Absolute destination position.
static void release_unused_pictures(MpegEncContext *s)
int no_rounding
apply no rounding to motion compensation (MPEG4, msmpeg4, ...) for b-frames rounding mode is always 0...
void ff_mpv_decode_mb(MpegEncContext *s, int16_t block[12][64])
Picture current_picture
copy of the current picture structure.
static int pic_is_unused(MpegEncContext *s, Picture *pic)
void ff_mpv_common_init_ppc(MpegEncContext *s)
static int alloc_picture_tables(MpegEncContext *s, Picture *pic)
#define PICT_BOTTOM_FIELD
int16_t(* b_bidir_forw_mv_table)[2]
MV table (1MV per MB) bidir mode b-frame encoding.
int32_t source
Where the current macroblock comes from; negative value when it comes from the past, positive value when it comes from the future.
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.
void(* decode_mb)(struct MpegEncContext *s)
Called for every Macroblock in a slice.
uint16_t pp_time
time distance between the last 2 p,s,i frames
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.
int interlaced_frame
The content of the picture is interlaced.
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
av_cold void ff_mpv_idct_init(MpegEncContext *s)
int mb_height
number of MBs horizontally & vertically
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
static av_always_inline void mpv_decode_mb_internal(MpegEncContext *s, int16_t block[12][64], int lowres_flag, int is_mpeg12)
int codec_tag
internal codec_tag upper case converted from avctx codec_tag
high precision timer, useful to profile code
int16_t(*[2][2] p_field_mv_table_base)[2]
static void ff_update_block_index(MpegEncContext *s)
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
#define ROUNDED_DIV(a, b)
AVBufferRef * mb_mean_buf
static void gray16(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h)
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
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int last_dc[3]
last DC values for MPEG1
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
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
int frame_skip_threshold
frame skip threshold
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define CODEC_FLAG2_EXPORT_MVS
Export motion vectors through frame side data.
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.
static const struct endianess table[]
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
uint8_t w
Width and height of the block.
#define FF_DEBUG_VIS_MV_B_FOR
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)
static void put_dct(MpegEncContext *s, int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
simple assert() macros that are a bit more flexible than ISO C assert().
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 (defines in mpegutils.h)
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_mpeg_unref_picture(MpegEncContext *s, Picture *pic)
Deallocate a picture.
uint8_t *[2][2] b_field_select_table
static const uint8_t offset[127][2]
void ff_mpv_common_end(MpegEncContext *s)
Libavcodec external API header.
av_cold void ff_mpv_common_init_x86(MpegEncContext *s)
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
common internal API header
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color, int tail, int direction)
Draw an arrow from (ex, ey) -> (sx, sy).
const uint8_t ff_alternate_vertical_scan[64]
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)
enum AVPictureType pict_type
Picture type of the frame.
#define UPDATE_PICTURE(pic)
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int overread
the number of bytes which where irreversibly read from the next frame
int next_p_frame_damaged
set if the next p frame is damaged, to avoid showing trashed b frames
const uint16_t(* table_vlc)[2]
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...
int16_t(*[2] motion_val)[2]
Picture * current_picture_ptr
pointer to the current picture
#define FF_CEIL_RSHIFT(a, b)
unsigned int allocated_bitstream_buffer_size
void * hwaccel_picture_private
hardware accelerator private data
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
int16_t(* ac_val_base)[16]
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int16_t(*[2][2][2] b_field_mv_table_base)[2]
int16_t(* b_forw_mv_table_base)[2]
int16_t(*[12] pblocks)[64]
int block_last_index[12]
last non zero coefficient in block
uint8_t idct_permutation[64]
IDCT input permutation.
int mb_decision
macroblock decision mode
void(* idct_add)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
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 INIT_VLC_USE_NEW_STATIC
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
void ff_mpv_decode_defaults(MpegEncContext *s)
Set the given MpegEncContext to defaults for decoding.
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 * mb_index2xy
mb_index -> mb_x + mb_y*mb_stride
int first_field
is 1 for the first field of a field picture 0 otherwise
int ff_mpv_lowest_referenced_row(MpegEncContext *s, int dir)
find the lowest MB row referenced in the MVs
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
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...
void(* idct_put)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
#define MV_TYPE_16X16
1 vector for the whole mb
int frame_skip_factor
frame skip factor
static void clear_context(MpegEncContext *s)
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]
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().
void ff_free_picture_tables(Picture *pic)
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
ptrdiff_t linesize
line size, in bytes, may be different from width
static av_const unsigned int ff_sqrt(unsigned int a)
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
enum AVDiscard skip_idct
Skip IDCT/dequantization for selected frames.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
ScanTable intra_scantable
uint8_t * data
The data buffer.
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').
static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, int16_t *block, int n, int qscale)
const uint8_t ff_mpeg1_dc_scale_table[128]
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
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)
void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table, uint32_t *mbtype_table, int8_t *qscale_table, int16_t(*motion_val[2])[2], int *low_delay, int mb_width, int mb_height, int mb_stride, int quarter_sample)
Print debugging info for the given picture.
uint32_t state
contains the last few bytes in MSB order
Picture * picture
main picture buffer
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
BYTE int const BYTE int int int height
#define FF_THREAD_FRAME
Decode more than one frame at once.
ScanTable intra_h_scantable
op_pixels_func put_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
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
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
int closed_gop
MPEG1/2 GOP is closed.
int64_t mc_mb_var_sum
motion compensated MB variance for current frame
#define UPDATE_TABLE(table)
unsigned int avpriv_toupper4(unsigned int x)
uint8_t * index_run[2]
encoding only
const uint8_t ff_zigzag_direct[64]
ptrdiff_t uvlinesize
line size, for chroma in bytes, may be different from width
int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
generic function called after decoding the header and before a frame is decoded.
static int add_mb(AVMotionVector *mb, uint32_t mb_type, int dst_x, int dst_y, int src_x, int src_y, int direction)
int f_code
forward MV resolution
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, ...
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.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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)
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.
discard all non reference
GLint GLenum GLboolean GLsizei stride
static void exchange_uv(MpegEncContext *s)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
uint64_t flags
Extra flag information.
#define FF_MB_DECISION_RD
rate distortion
common internal api header.
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
AVBufferRef * mbskip_table_buf
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
static av_cold int dct_init(MpegEncContext *s)
static void dct_unquantize_h263_inter_c(MpegEncContext *s, int16_t *block, int n, int qscale)
Picture last_picture
copy of the previous picture structure.
uint8_t * obmc_scratchpad
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
Allocate a frame buffer.
Picture * last_picture_ptr
pointer to the previous picture.
int workaround_bugs
Work around bugs in encoders which sometimes cannot be detected automatically.
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.
av_cold int ff_mpv_common_init(MpegEncContext *s)
init common structure for both encoder and decoder.
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
int top_field_first
If the content is interlaced, is top field displayed first.
void ff_mpv_frame_end(MpegEncContext *s)
#define MV_TYPE_DMV
2 vectors, special mpeg2 Dual Prime Vectors
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
av_cold void ff_init_rl(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
int16_t(* block)[64]
points to one of the following blocks
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)
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 frame_number
Frame counter, set by libavcodec.
void ff_mpv_common_defaults(MpegEncContext *s)
Set the given MpegEncContext to common defaults (same for encoding and decoding). ...
static void free_context_frame(MpegEncContext *s)
Frees and resets MpegEncContext fields depending on the resolution.
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)
int flags
AVCodecContext.flags (HQ, MV4, ...)
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
uint32_t * mb_type
types and macros are defined in mpegutils.h
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_malloc_array(a, b)
#define FFSWAP(type, a, b)
int debug_mv
debug Code outside libavcodec should access this field using AVOptions
int ff_find_unused_picture(MpegEncContext *s, int shared)
#define MV_TYPE_8X8
4 vectors (h263, mpeg4 4MV)
#define FF_DEBUG_VIS_MV_P_FOR
int16_t(* b_direct_mv_table_base)[2]
int b_code
backward MV resolution for B Frames (mpeg4)
int64_t mb_var_sum
sum of MB variance for current frame
void ff_mpv_report_decode_progress(MpegEncContext *s)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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
static int frame_size_alloc(MpegEncContext *s, int linesize)
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
AVBufferRef * ref_index_buf[2]