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));
371 memset(dst + h*linesize, 128, 16);
377 memset(dst + h*linesize, 128, 8);
392 for (i=0; i<4; i++) {
412 if (HAVE_INTRINSICS_NEON)
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);\
1029 (
char *) &
s1->pb_field_time +
sizeof(
s1->pb_field_time) -
1030 (
char *) &
s1->last_time_base);
1040 if (
s1->bitstream_buffer) {
1041 if (
s1->bitstream_buffer_size +
1045 s1->allocated_bitstream_buffer_size);
1048 s1->bitstream_buffer_size);
1058 "scratch buffers.\n");
1063 "be allocated due to unknown size.\n");
1068 (
char *) &
s1->rtp_mode - (
char *) &
s1->progressive_sequence);
1070 if (!
s1->first_field) {
1072 if (
s1->current_picture_ptr)
1171 int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x,
y;
1195 yc_size = y_size + 2 * c_size;
1228 mb_array_size *
sizeof(
float), fail);
1230 mb_array_size *
sizeof(
float), fail);
1237 for (i = 0; i < 2; i++) {
1239 for (j = 0; j < 2; j++) {
1240 for (k = 0; k < 2; k++) {
1243 mv_table_size * 2 *
sizeof(int16_t),
1272 for (i = 0; i < yc_size; i++)
1296 int nb_slices = (HAVE_THREADS &&
1310 "decoding to AV_PIX_FMT_NONE is not supported.\n");
1321 " reducing to %d\n", nb_slices, max_slices);
1322 nb_slices = max_slices;
1373 if (nb_slices > 1) {
1374 for (i = 1; i < nb_slices; i++) {
1379 for (i = 0; i < nb_slices; i++) {
1383 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1385 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1424 for (i = 0; i < 2; i++) {
1425 for (j = 0; j < 2; j++) {
1426 for (k = 0; k < 2; k++) {
1501 if (nb_slices > 1) {
1502 for (i = 1; i < nb_slices; i++) {
1507 for (i = 0; i < nb_slices; i++) {
1511 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1513 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1594 for (last = 0; last < 2; last++) {
1603 memset(max_level, 0,
MAX_RUN + 1);
1605 memset(index_run, rl->
n,
MAX_RUN + 1);
1606 for (i = start; i <
end; i++) {
1609 if (index_run[run] == rl->
n)
1611 if (level > max_level[run])
1613 if (run > max_run[level])
1617 rl->
max_level[last] = static_store[last];
1630 memcpy(rl->
index_run[last], index_run, MAX_RUN + 1);
1638 VLC vlc = { .
table =
table, .table_allocated = static_size };
1642 for (q = 0; q < 32; q++) {
1644 int qadd = (q - 1) | 1;
1651 int code = vlc.
table[i][0];
1658 }
else if (len < 0) {
1662 if (code == rl->
n) {
1668 if (code >= rl->
last) run += 192;
1693 if (!pic->
f->
buf[0])
1717 "Internal error, picture buffer overflow\n");
1749 int i, h_chroma_shift, v_chroma_shift;
1753 for(i=0; i<frame->
height; i++)
1757 0x80, FF_CEIL_RSHIFT(frame->
width, h_chroma_shift));
1759 0x80, FF_CEIL_RSHIFT(frame->
width, h_chroma_shift));
1793 "releasing zombie picture\n");
1853 av_dlog(s->
avctx,
"L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
1863 int h_chroma_shift, v_chroma_shift;
1865 &h_chroma_shift, &v_chroma_shift);
1868 "allocating dummy last picture for B frame\n");
1871 "warning: first frame is no keyframe\n");
1874 "allocate dummy last picture for field based first keyframe\n");
1894 for(i=0; i<avctx->
height; i++)
1896 0x80, avctx->
width);
1899 0x80, FF_CEIL_RSHIFT(avctx->
width, h_chroma_shift));
1901 0x80, FF_CEIL_RSHIFT(avctx->
width, h_chroma_shift));
1905 for(i=0; i<avctx->
height; i++)
1935 #if 0 // BUFREF-FIXME
1959 for (i = 0; i < 4; i++) {
2004 static int clip_line(
int *sx,
int *sy,
int *ex,
int *ey,
int maxx)
2012 *sy = *ey + (*sy - *ey) * (int64_t)*ex / (*ex - *sx);
2019 *ey = *sy + (*ey - *sy) * (int64_t)(maxx - *sx) / (*ex - *sx);
2038 if (
clip_line(&sx, &sy, &ex, &ey, w - 1))
2040 if (
clip_line(&sy, &sx, &ey, &ex, h - 1))
2043 sx = av_clip(sx, 0, w - 1);
2044 sy = av_clip(sy, 0, h - 1);
2045 ex = av_clip(ex, 0, w - 1);
2046 ey = av_clip(ey, 0, h - 1);
2048 buf[sy * stride + sx] +=
color;
2055 buf += sx + sy * stride;
2057 f = ((ey - sy) << 16) / ex;
2058 for (x = 0; x <= ex; x++) {
2060 fr = (x * f) & 0xFFFF;
2061 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
2062 if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16;
2069 buf += sx + sy * stride;
2072 f = ((ex - sx) << 16) / ey;
2075 for(y= 0; y <= ey; y++){
2077 fr = (y*f) & 0xFFFF;
2078 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
2079 if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16;
2092 int ey,
int w,
int h,
int stride,
int color,
int tail,
int direction)
2101 sx = av_clip(sx, -100, w + 100);
2102 sy = av_clip(sy, -100, h + 100);
2103 ex = av_clip(ex, -100, w + 100);
2104 ey = av_clip(ey, -100, h + 100);
2109 if (dx * dx + dy * dy > 3 * 3) {
2123 draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
2124 draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
2126 draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
2131 int dst_x,
int dst_y,
2132 int src_x,
int src_y,
2135 if (dst_x == src_x && dst_y == src_y)
2143 mb->
source = direction ? 1 : -1;
2152 uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2],
2154 int mb_width,
int mb_height,
int mb_stride,
int quarter_sample)
2157 const int shift = 1 + quarter_sample;
2159 const int mv_stride = (mb_width << mv_sample_log2) +
2161 int mb_x, mb_y, mbcount = 0;
2169 for (mb_y = 0; mb_y < mb_height; mb_y++) {
2170 for (mb_x = 0; mb_x < mb_width; mb_x++) {
2171 int i, direction, mb_type = mbtype_table[mb_x + mb_y * mb_stride];
2172 for (direction = 0; direction < 2; direction++) {
2176 for (i = 0; i < 4; i++) {
2177 int sx = mb_x * 16 + 4 + 8 * (i & 1);
2178 int sy = mb_y * 16 + 4 + 8 * (i >> 1);
2179 int xy = (mb_x * 2 + (i & 1) +
2180 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2181 int mx = (motion_val[direction][xy][0] >>
shift) + sx;
2182 int my = (motion_val[direction][xy][1] >>
shift) + sy;
2183 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, direction);
2185 }
else if (
IS_16X8(mb_type)) {
2186 for (i = 0; i < 2; i++) {
2187 int sx = mb_x * 16 + 8;
2188 int sy = mb_y * 16 + 4 + 8 * i;
2189 int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
2190 int mx = (motion_val[direction][xy][0] >>
shift);
2191 int my = (motion_val[direction][xy][1] >>
shift);
2196 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy, mx + sx, my + sy, direction);
2198 }
else if (
IS_8X16(mb_type)) {
2199 for (i = 0; i < 2; i++) {
2200 int sx = mb_x * 16 + 4 + 8 * i;
2201 int sy = mb_y * 16 + 8;
2202 int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
2203 int mx = motion_val[direction][xy][0] >>
shift;
2204 int my = motion_val[direction][xy][1] >>
shift;
2209 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy, mx + sx, my + sy, direction);
2212 int sx = mb_x * 16 + 8;
2213 int sy = mb_y * 16 + 8;
2214 int xy = (mb_x + mb_y * mv_stride) << mv_sample_log2;
2215 int mx = (motion_val[direction][xy][0]>>
shift) + sx;
2216 int my = (motion_val[direction][xy][1]>>
shift) + sy;
2217 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, direction);
2237 if (avctx->
hwaccel || !mbtype_table
2247 for (y = 0; y < mb_height; y++) {
2248 for (x = 0; x < mb_width; x++) {
2250 int count = mbskip_table[x + y * mb_stride];
2257 qscale_table[x + y * mb_stride]);
2260 int mb_type = mbtype_table[x + y * mb_stride];
2276 else if (
IS_GMC(mb_type))
2316 int h_chroma_shift, v_chroma_shift, block_height;
2318 const int shift = 1 + quarter_sample;
2324 const int mv_stride = (mb_width << mv_sample_log2) +
2335 ptr = pict->
data[0];
2337 block_height = 16 >> v_chroma_shift;
2339 for (mb_y = 0; mb_y < mb_height; mb_y++) {
2341 for (mb_x = 0; mb_x < mb_width; mb_x++) {
2342 const int mb_index = mb_x + mb_y * mb_stride;
2344 if ((avctx->
debug_mv) && motion_val[0]) {
2346 for (type = 0; type < 3; type++) {
2368 if (!
USES_LIST(mbtype_table[mb_index], direction))
2371 if (
IS_8X8(mbtype_table[mb_index])) {
2373 for (i = 0; i < 4; i++) {
2374 int sx = mb_x * 16 + 4 + 8 * (i & 1);
2375 int sy = mb_y * 16 + 4 + 8 * (i >> 1);
2376 int xy = (mb_x * 2 + (i & 1) +
2377 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2378 int mx = (motion_val[direction][xy][0] >>
shift) + sx;
2379 int my = (motion_val[direction][xy][1] >>
shift) + sy;
2381 height, pict->
linesize[0], 100, 0, direction);
2383 }
else if (
IS_16X8(mbtype_table[mb_index])) {
2385 for (i = 0; i < 2; i++) {
2386 int sx = mb_x * 16 + 8;
2387 int sy = mb_y * 16 + 4 + 8 * i;
2388 int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
2389 int mx = (motion_val[direction][xy][0] >>
shift);
2390 int my = (motion_val[direction][xy][1] >>
shift);
2395 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2396 height, pict->
linesize[0], 100, 0, direction);
2398 }
else if (
IS_8X16(mbtype_table[mb_index])) {
2400 for (i = 0; i < 2; i++) {
2401 int sx = mb_x * 16 + 4 + 8 * i;
2402 int sy = mb_y * 16 + 8;
2403 int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
2404 int mx = motion_val[direction][xy][0] >>
shift;
2405 int my = motion_val[direction][xy][1] >>
shift;
2410 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2411 height, pict->
linesize[0], 100, 0, direction);
2414 int sx= mb_x * 16 + 8;
2415 int sy= mb_y * 16 + 8;
2416 int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
2417 int mx= (motion_val[direction][xy][0]>>
shift) + sx;
2418 int my= (motion_val[direction][xy][1]>>
shift) + sy;
2419 draw_arrow(ptr, sx, sy, mx, my, width, height, pict->
linesize[0], 100, 0, direction);
2425 uint64_t
c = (qscale_table[mb_index] * 128 / 31) *
2426 0x0101010101010101ULL;
2428 for (y = 0; y < block_height; y++) {
2429 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2430 (block_height * mb_y + y) *
2432 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2433 (block_height * mb_y + y) *
2439 int mb_type = mbtype_table[mb_index];
2442 #define COLOR(theta, r) \
2443 u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
2444 v = (int)(128 + r * sin(theta * 3.141592 / 180));
2461 }
else if (
IS_GMC(mb_type)) {
2463 }
else if (
IS_SKIP(mb_type)) {
2474 u *= 0x0101010101010101ULL;
2475 v *= 0x0101010101010101ULL;
2476 for (y = 0; y < block_height; y++) {
2477 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2478 (block_height * mb_y + y) * pict->
linesize[1]) = u;
2479 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2480 (block_height * mb_y + y) * pict->
linesize[2]) = v;
2485 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 0 +
2486 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2487 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 8 +
2488 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2491 for (y = 0; y < 16; y++)
2492 pict->
data[0][16 * mb_x + 8 + (16 * mb_y + y) *
2495 if (
IS_8X8(mb_type) && mv_sample_log2 >= 2) {
2496 int dm = 1 << (mv_sample_log2 - 2);
2497 for (i = 0; i < 4; i++) {
2498 int sx = mb_x * 16 + 8 * (i & 1);
2499 int sy = mb_y * 16 + 8 * (i >> 1);
2500 int xy = (mb_x * 2 + (i & 1) +
2501 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2504 if (mv[0] != mv[dm] ||
2505 mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
2506 for (y = 0; y < 8; y++)
2507 pict->
data[0][sx + 4 + (sy + y) * pict->
linesize[0]] ^= 0x80;
2508 if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
2509 *(uint64_t *)(pict->
data[0] + sx + (sy + 4) *
2510 pict->
linesize[0]) ^= 0x8080808080808080ULL;
2519 mbskip_table[mb_index] = 0;
2546 int field_based,
int field_select,
2547 int src_x,
int src_y,
2549 int h_edge_pos,
int v_edge_pos,
2551 int motion_x,
int motion_y)
2554 const int op_index =
FFMIN(lowres, 3);
2555 const int s_mask = (2 <<
lowres) - 1;
2564 sx = motion_x & s_mask;
2565 sy = motion_y & s_mask;
2566 src_x += motion_x >> lowres + 1;
2567 src_y += motion_y >> lowres + 1;
2569 src += src_y * stride + src_x;
2571 if ((
unsigned)src_x >
FFMAX( h_edge_pos - (!!sx) - w, 0) ||
2572 (unsigned)src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2575 w + 1, (h + 1) << field_based,
2576 src_x, src_y << field_based,
2577 h_edge_pos, v_edge_pos);
2582 sx = (sx << 2) >>
lowres;
2583 sy = (sy << 2) >>
lowres;
2586 pix_op[op_index](dest,
src, stride, h, sx, sy);
2600 int motion_x,
int motion_y,
2603 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
2604 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy;
2605 ptrdiff_t uvlinesize, linesize;
2608 const int block_s = 8>>
lowres;
2609 const int s_mask = (2 <<
lowres) - 1;
2622 motion_y += (bottom_field - field_select)*((1 << lowres)-1);
2625 sx = motion_x & s_mask;
2626 sy = motion_y & s_mask;
2627 src_x = s->
mb_x * 2 * block_s + (motion_x >> lowres + 1);
2628 src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >> lowres + 1);
2631 uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
2632 uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
2633 uvsrc_x = src_x >> 1;
2634 uvsrc_y = src_y >> 1;
2639 uvsx = (2 * mx) & s_mask;
2640 uvsy = (2 * my) & s_mask;
2641 uvsrc_x = s->
mb_x * block_s + (mx >>
lowres);
2642 uvsrc_y = mb_y * block_s + (my >>
lowres);
2649 uvsrc_x = s->
mb_x * block_s + (mx >> lowres + 1);
2650 uvsrc_y = (mb_y * block_s >> field_based) + (my >> lowres + 1);
2656 uvsy = motion_y & s_mask;
2658 uvsrc_x = s->
mb_x*block_s + (mx >> (lowres+1));
2661 uvsx = motion_x & s_mask;
2662 uvsy = motion_y & s_mask;
2669 ptr_y = ref_picture[0] + src_y * linesize + src_x;
2670 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
2671 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
2673 if ((
unsigned) src_x >
FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
2674 (
unsigned) src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2676 linesize >> field_based, linesize >> field_based,
2677 17, 17 + field_based,
2678 src_x, src_y << field_based, h_edge_pos,
2685 uvlinesize >> field_based, uvlinesize >> field_based,
2687 uvsrc_x, uvsrc_y << field_based,
2688 h_edge_pos >> 1, v_edge_pos >> 1);
2690 uvlinesize >> field_based,uvlinesize >> field_based,
2692 uvsrc_x, uvsrc_y << field_based,
2693 h_edge_pos >> 1, v_edge_pos >> 1);
2712 sx = (sx << 2) >>
lowres;
2713 sy = (sy << 2) >>
lowres;
2714 pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
2718 uvsx = (uvsx << 2) >>
lowres;
2719 uvsy = (uvsy << 2) >>
lowres;
2721 pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy);
2722 pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy);
2735 const int op_index =
FFMIN(lowres, 3);
2736 const int block_s = 8 >>
lowres;
2737 const int s_mask = (2 <<
lowres) - 1;
2738 const int h_edge_pos = s->
h_edge_pos >> lowres + 1;
2739 const int v_edge_pos = s->
v_edge_pos >> lowres + 1;
2740 int emu = 0, src_x, src_y, sx, sy;
2756 src_x = s->
mb_x * block_s + (mx >> lowres + 1);
2757 src_y = s->
mb_y * block_s + (my >> lowres + 1);
2760 ptr = ref_picture[1] +
offset;
2761 if ((
unsigned) src_x >
FFMAX(h_edge_pos - (!!sx) - block_s, 0) ||
2762 (unsigned) src_y >
FFMAX(v_edge_pos - (!!sy) - block_s, 0)) {
2766 src_x, src_y, h_edge_pos, v_edge_pos);
2770 sx = (sx << 2) >>
lowres;
2771 sy = (sy << 2) >>
lowres;
2772 pix_op[op_index](dest_cb, ptr, s->
uvlinesize, block_s, sx, sy);
2774 ptr = ref_picture[2] +
offset;
2779 src_x, src_y, h_edge_pos, v_edge_pos);
2782 pix_op[op_index](dest_cr, ptr, s->
uvlinesize, block_s, sx, sy);
2799 int dir,
uint8_t **ref_picture,
2805 const int block_s = 8 >>
lowres;
2814 ref_picture, pix_op,
2815 s->
mv[dir][0][0], s->
mv[dir][0][1],
2821 for (i = 0; i < 4; i++) {
2824 ref_picture[0], 0, 0,
2825 (2 * mb_x + (i & 1)) * block_s,
2826 (2 * mb_y + (i >> 1)) * block_s,
2829 block_s, block_s, pix_op,
2830 s->
mv[dir][i][0], s->
mv[dir][i][1]);
2832 mx += s->
mv[dir][i][0];
2833 my += s->
mv[dir][i][1];
2845 ref_picture, pix_op,
2846 s->
mv[dir][0][0], s->
mv[dir][0][1],
2851 ref_picture, pix_op,
2852 s->
mv[dir][1][0], s->
mv[dir][1][1],
2862 ref_picture, pix_op,
2864 s->
mv[dir][0][1], 2 * block_s, mb_y >> 1);
2868 for (i = 0; i < 2; i++) {
2873 ref2picture = ref_picture;
2880 ref2picture, pix_op,
2881 s->
mv[dir][i][0], s->
mv[dir][i][1] +
2882 2 * block_s * i, block_s, mb_y >> 1);
2884 dest_y += 2 * block_s * s->
linesize;
2891 for (i = 0; i < 2; i++) {
2893 for (j = 0; j < 2; j++) {
2896 ref_picture, pix_op,
2897 s->
mv[dir][2 * i + j][0],
2898 s->
mv[dir][2 * i + j][1],
2904 for (i = 0; i < 2; i++) {
2907 ref_picture, pix_op,
2908 s->
mv[dir][2 * i][0],s->
mv[dir][2 * i][1],
2909 2 * block_s, mb_y >> 1);
2932 int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->
quarter_sample;
2933 int my, off, i, mvs;
2952 for (i = 0; i < mvs; i++) {
2953 my = s->
mv[dir][i][1]<<qpel_shift;
2954 my_max =
FFMAX(my_max, my);
2955 my_min =
FFMIN(my_min, my);
2958 off = (
FFMAX(-my_min, my_max) + 63) >> 6;
2967 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
2983 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
3005 memset(s->
ac_val[0][xy ], 0, 32 *
sizeof(int16_t));
3006 memset(s->
ac_val[0][xy + wrap], 0, 32 *
sizeof(int16_t));
3019 memset(s->
ac_val[1][xy], 0, 16 *
sizeof(int16_t));
3020 memset(s->
ac_val[2][xy], 0, 16 *
sizeof(int16_t));
3037 int lowres_flag,
int is_mpeg12)
3052 for(j=0; j<64; j++){
3079 uint8_t *dest_y, *dest_cb, *dest_cr;
3080 int dct_linesize, dct_offset;
3086 const int block_size= lowres_flag ? 8>>s->
avctx->
lowres : 8;
3105 dct_offset = s->
interlaced_dct ? linesize : linesize * block_size;
3109 dest_cb= s->
dest[1];
3110 dest_cr= s->
dest[2];
3193 add_dct(s, block[0], 0, dest_y , dct_linesize);
3194 add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
3195 add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
3196 add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
3200 add_dct(s, block[4], 4, dest_cb, uvlinesize);
3201 add_dct(s, block[5], 5, dest_cr, uvlinesize);
3205 dct_offset = s->
interlaced_dct ? uvlinesize : uvlinesize*block_size;
3207 add_dct(s, block[4], 4, dest_cb, dct_linesize);
3208 add_dct(s, block[5], 5, dest_cr, dct_linesize);
3209 add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
3210 add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
3212 add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
3213 add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
3214 add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
3215 add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
3220 else if (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) {
3227 put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->
qscale);
3228 put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->
qscale);
3229 put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->
qscale);
3246 s->
idsp.
idct_put(dest_y + block_size, dct_linesize, block[1]);
3247 s->
idsp.
idct_put(dest_y + dct_offset, dct_linesize, block[2]);
3248 s->
idsp.
idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
3257 dct_offset = s->
interlaced_dct ? uvlinesize : uvlinesize*block_size;
3261 s->
idsp.
idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
3262 s->
idsp.
idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
3264 s->
idsp.
idct_put(dest_cb + block_size, dct_linesize, block[8]);
3265 s->
idsp.
idct_put(dest_cr + block_size, dct_linesize, block[9]);
3266 s->
idsp.
idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
3267 s->
idsp.
idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
3321 s->
dest[0] += s->
mb_y * linesize << mb_size;
3325 s->
dest[0] += (s->
mb_y>>1) * linesize << mb_size;
3349 for(i=0; i<=last; i++){
3350 const int j= scantable[i];
3355 for(i=0; i<=last; i++){
3356 const int j= scantable[i];
3357 const int perm_j= permutation[j];
3358 block[perm_j]= temp[j];
3397 else if (qscale > 31)