51 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
52 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
57 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
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,
69 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
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,
81 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
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,
93 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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,
111 0, 1, 2, 3, 8, 9, 16, 17,
112 10, 11, 4, 5, 6, 7, 15, 14,
113 13, 12, 19, 18, 24, 25, 32, 33,
114 26, 27, 20, 21, 22, 23, 28, 29,
115 30, 31, 34, 35, 40, 41, 48, 49,
116 42, 43, 36, 37, 38, 39, 44, 45,
117 46, 47, 50, 51, 56, 57, 58, 59,
118 52, 53, 54, 55, 60, 61, 62, 63,
122 0, 8, 16, 24, 1, 9, 2, 10,
123 17, 25, 32, 40, 48, 56, 57, 49,
124 41, 33, 26, 18, 3, 11, 4, 12,
125 19, 27, 34, 42, 50, 58, 35, 43,
126 51, 59, 20, 28, 5, 13, 6, 14,
127 21, 29, 36, 44, 52, 60, 37, 45,
128 53, 61, 22, 30, 7, 15, 23, 31,
129 38, 46, 54, 62, 39, 47, 55, 63,
133 int16_t *
block,
int n,
int qscale)
135 int i,
level, nCoeffs;
136 const uint16_t *quant_matrix;
143 for(i=1;i<=nCoeffs;i++) {
149 level = (int)(level * qscale * quant_matrix[j]) >> 3;
150 level = (level - 1) | 1;
153 level = (int)(level * qscale * quant_matrix[j]) >> 3;
154 level = (level - 1) | 1;
162 int16_t *
block,
int n,
int qscale)
164 int i,
level, nCoeffs;
165 const uint16_t *quant_matrix;
170 for(i=0; i<=nCoeffs; i++) {
176 level = (((level << 1) + 1) * qscale *
177 ((int) (quant_matrix[j]))) >> 4;
178 level = (level - 1) | 1;
181 level = (((level << 1) + 1) * qscale *
182 ((int) (quant_matrix[j]))) >> 4;
183 level = (level - 1) | 1;
191 int16_t *
block,
int n,
int qscale)
193 int i,
level, nCoeffs;
194 const uint16_t *quant_matrix;
201 for(i=1;i<=nCoeffs;i++) {
207 level = (int)(level * qscale * quant_matrix[j]) >> 3;
210 level = (int)(level * qscale * quant_matrix[j]) >> 3;
218 int16_t *
block,
int n,
int qscale)
220 int i,
level, nCoeffs;
221 const uint16_t *quant_matrix;
230 for(i=1;i<=nCoeffs;i++) {
236 level = (int)(level * qscale * quant_matrix[j]) >> 3;
239 level = (int)(level * qscale * quant_matrix[j]) >> 3;
249 int16_t *
block,
int n,
int qscale)
251 int i,
level, nCoeffs;
252 const uint16_t *quant_matrix;
259 for(i=0; i<=nCoeffs; i++) {
265 level = (((level << 1) + 1) * qscale *
266 ((int) (quant_matrix[j]))) >> 4;
269 level = (((level << 1) + 1) * qscale *
270 ((int) (quant_matrix[j]))) >> 4;
280 int16_t *
block,
int n,
int qscale)
282 int i,
level, qmul, qadd;
291 qadd = (qscale - 1) | 1;
300 for(i=1; i<=nCoeffs; i++) {
304 level = level * qmul - qadd;
306 level = level * qmul + qadd;
314 int16_t *
block,
int n,
int qscale)
316 int i,
level, qmul, qadd;
321 qadd = (qscale - 1) | 1;
326 for(i=0; i<=nCoeffs; i++) {
330 level = level * qmul - qadd;
332 level = level * qmul + qadd;
341 int mb_x,
int mb_y,
int mb_intra,
int mb_skipped)
351 memcpy(s->
mv,
mv,
sizeof(*
mv));
370 memset(dst + h*linesize, 128, 16);
376 memset(dst + h*linesize, 128, 8);
392 for (i=0; i<4; i++) {
497 if (r < 0 || !pic->f->buf[0]) {
505 for (i = 0; pic->
f->
data[i]; i++) {
530 "get_buffer() failed (stride changed)\n");
537 "get_buffer() failed (uv stride mismatch)\n");
545 "get_buffer() failed to allocate context scratch buffers.\n");
567 for (i = 0; i < 2; i++) {
597 int mv_size = 2 * (b8_array_size + 4) *
sizeof(int16_t);
598 int ref_index_size = 4 * mb_array_size;
600 for (i = 0; mv_size && i < 2; i++) {
617 #define MAKE_WRITABLE(table) \
620 (ret = av_buffer_make_writable(&pic->table)) < 0)\
631 for (i = 0; i < 2; i++) {
683 for (i = 0; i < 2; i++) {
719 memset((
uint8_t*)pic + off, 0,
sizeof(*pic) - off);
726 #define UPDATE_TABLE(table)\
729 (!dst->table || dst->table->buffer != src->table->buffer)) {\
730 av_buffer_unref(&dst->table);\
731 dst->table = av_buffer_ref(src->table);\
733 ff_free_picture_tables(dst);\
734 return AVERROR(ENOMEM);\
745 for (i = 0; i < 2; i++) {
756 for (i = 0; i < 2; i++) {
818 int yc_size = y_size + 2 * c_size;
838 2 * 64 *
sizeof(
int), fail)
844 for (i = 0; i < 12; i++) {
853 yc_size *
sizeof(int16_t) * 16, fail);
886 #define COPY(a) bak->a = src->a
887 COPY(edge_emu_buffer);
892 COPY(obmc_scratchpad);
920 for (i = 0; i < 12; i++) {
928 "scratch buffers.\n");
956 if (
s1->context_initialized){
987 if (
s1->picture[i].f->buf[0] &&
992 #define UPDATE_PICTURE(pic)\
994 ff_mpeg_unref_picture(s, &s->pic);\
995 if (s1->pic.f && s1->pic.f->buf[0])\
996 ret = ff_mpeg_ref_picture(s, &s->pic, &s1->pic);\
998 ret = update_picture_tables(&s->pic, &s1->pic);\
1018 (
char *) &
s1->pb_field_time +
sizeof(
s1->pb_field_time) -
1019 (
char *) &
s1->last_time_base);
1029 if (
s1->bitstream_buffer) {
1030 if (
s1->bitstream_buffer_size +
1034 s1->allocated_bitstream_buffer_size);
1037 s1->bitstream_buffer_size);
1047 "scratch buffers.\n");
1052 "be allocated due to unknown size.\n");
1057 (
char *) &
s1->rtp_mode - (
char *) &
s1->progressive_sequence);
1059 if (!
s1->first_field) {
1061 if (
s1->current_picture_ptr)
1144 int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x,
y;
1168 yc_size = y_size + 2 * c_size;
1201 mb_array_size *
sizeof(
float), fail);
1203 mb_array_size *
sizeof(
float), fail);
1210 for (i = 0; i < 2; i++) {
1212 for (j = 0; j < 2; j++) {
1213 for (k = 0; k < 2; k++) {
1216 mv_table_size * 2 *
sizeof(int16_t),
1245 for (i = 0; i < yc_size; i++)
1269 int nb_slices = (HAVE_THREADS &&
1283 "decoding to AV_PIX_FMT_NONE is not supported.\n");
1294 " reducing to %d\n", nb_slices, max_slices);
1295 nb_slices = max_slices;
1350 if (nb_slices > 1) {
1351 for (i = 1; i < nb_slices; i++) {
1356 for (i = 0; i < nb_slices; i++) {
1360 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1362 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1401 for (i = 0; i < 2; i++) {
1402 for (j = 0; j < 2; j++) {
1403 for (k = 0; k < 2; k++) {
1478 if (nb_slices > 1) {
1479 for (i = 1; i < nb_slices; i++) {
1484 for (i = 0; i < nb_slices; i++) {
1488 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1490 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1571 for (last = 0; last < 2; last++) {
1580 memset(max_level, 0,
MAX_RUN + 1);
1582 memset(index_run, rl->
n,
MAX_RUN + 1);
1583 for (i = start; i <
end; i++) {
1586 if (index_run[run] == rl->
n)
1588 if (level > max_level[run])
1590 if (run > max_run[level])
1594 rl->
max_level[last] = static_store[last];
1607 memcpy(rl->
index_run[last], index_run, MAX_RUN + 1);
1615 for (q = 0; q < 32; q++) {
1617 int qadd = (q - 1) | 1;
1631 }
else if (len < 0) {
1635 if (code == rl->
n) {
1641 if (code >= rl->
last) run += 192;
1666 if (pic->
f->
buf[0] == NULL)
1690 "Internal error, picture buffer overflow\n");
1722 int i, h_chroma_shift, v_chroma_shift;
1726 for(i=0; i<frame->
height; i++)
1730 0x80, FF_CEIL_RSHIFT(frame->
width, h_chroma_shift));
1732 0x80, FF_CEIL_RSHIFT(frame->
width, h_chroma_shift));
1766 "releasing zombie picture\n");
1827 av_dlog(s->
avctx,
"L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
1838 int h_chroma_shift, v_chroma_shift;
1840 &h_chroma_shift, &v_chroma_shift);
1843 "allocating dummy last picture for B frame\n");
1846 "warning: first frame is no keyframe\n");
1849 "allocate dummy last picture for field based first keyframe\n");
1869 for(i=0; i<avctx->
height; i++)
1871 0x80, avctx->
width);
1874 0x80, FF_CEIL_RSHIFT(avctx->
width, h_chroma_shift));
1876 0x80, FF_CEIL_RSHIFT(avctx->
width, h_chroma_shift));
1880 for(i=0; i<avctx->
height; i++)
1911 #if 0 // BUFREF-FIXME
1935 for (i = 0; i < 4; i++) {
1979 static int clip_line(
int *sx,
int *sy,
int *ex,
int *ey,
int maxx)
1987 *sy = *ey + (*sy - *ey) * (int64_t)*ex / (*ex - *sx);
1994 *ey = *sy + (*ey - *sy) * (int64_t)(maxx - *sx) / (*ex - *sx);
2013 if (
clip_line(&sx, &sy, &ex, &ey, w - 1))
2015 if (
clip_line(&sy, &sx, &ey, &ex, h - 1))
2018 sx = av_clip(sx, 0, w - 1);
2019 sy = av_clip(sy, 0, h - 1);
2020 ex = av_clip(ex, 0, w - 1);
2021 ey = av_clip(ey, 0, h - 1);
2023 buf[sy * stride + sx] +=
color;
2030 buf += sx + sy * stride;
2032 f = ((ey - sy) << 16) / ex;
2033 for (x = 0; x <= ex; x++) {
2035 fr = (x * f) & 0xFFFF;
2036 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
2037 if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16;
2044 buf += sx + sy * stride;
2047 f = ((ex - sx) << 16) / ey;
2050 for(y= 0; y <= ey; y++){
2052 fr = (y*f) & 0xFFFF;
2053 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
2054 if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16;
2067 int ey,
int w,
int h,
int stride,
int color,
int tail,
int direction)
2076 sx = av_clip(sx, -100, w + 100);
2077 sy = av_clip(sy, -100, h + 100);
2078 ex = av_clip(ex, -100, w + 100);
2079 ey = av_clip(ey, -100, h + 100);
2084 if (dx * dx + dy * dy > 3 * 3) {
2098 draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
2099 draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
2101 draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
2108 uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2],
2110 int mb_width,
int mb_height,
int mb_stride,
int quarter_sample)
2112 if (avctx->
hwaccel || !mbtype_table
2122 for (y = 0; y < mb_height; y++) {
2123 for (x = 0; x < mb_width; x++) {
2125 int count = mbskip_table[x + y * mb_stride];
2132 qscale_table[x + y * mb_stride]);
2135 int mb_type = mbtype_table[x + y * mb_stride];
2151 else if (
IS_GMC(mb_type))
2189 const int shift = 1 + quarter_sample;
2193 int h_chroma_shift, v_chroma_shift, block_height;
2197 const int mv_stride = (mb_width << mv_sample_log2) +
2207 ptr = pict->
data[0];
2208 block_height = 16 >> v_chroma_shift;
2210 for (mb_y = 0; mb_y < mb_height; mb_y++) {
2212 for (mb_x = 0; mb_x < mb_width; mb_x++) {
2213 const int mb_index = mb_x + mb_y * mb_stride;
2214 if ((avctx->
debug_mv) && motion_val[0]) {
2216 for (type = 0; type < 3; type++) {
2238 if (!
USES_LIST(mbtype_table[mb_index], direction))
2241 if (
IS_8X8(mbtype_table[mb_index])) {
2243 for (i = 0; i < 4; i++) {
2244 int sx = mb_x * 16 + 4 + 8 * (i & 1);
2245 int sy = mb_y * 16 + 4 + 8 * (i >> 1);
2246 int xy = (mb_x * 2 + (i & 1) +
2247 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2248 int mx = (motion_val[direction][xy][0] >>
shift) + sx;
2249 int my = (motion_val[direction][xy][1] >>
shift) + sy;
2251 height, pict->
linesize[0], 100, 0, direction);
2253 }
else if (
IS_16X8(mbtype_table[mb_index])) {
2255 for (i = 0; i < 2; i++) {
2256 int sx = mb_x * 16 + 8;
2257 int sy = mb_y * 16 + 4 + 8 * i;
2258 int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
2259 int mx = (motion_val[direction][xy][0] >>
shift);
2260 int my = (motion_val[direction][xy][1] >>
shift);
2265 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2266 height, pict->
linesize[0], 100, 0, direction);
2268 }
else if (
IS_8X16(mbtype_table[mb_index])) {
2270 for (i = 0; i < 2; i++) {
2271 int sx = mb_x * 16 + 4 + 8 * i;
2272 int sy = mb_y * 16 + 8;
2273 int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
2274 int mx = motion_val[direction][xy][0] >>
shift;
2275 int my = motion_val[direction][xy][1] >>
shift;
2280 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2281 height, pict->
linesize[0], 100, 0, direction);
2284 int sx= mb_x * 16 + 8;
2285 int sy= mb_y * 16 + 8;
2286 int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
2287 int mx= (motion_val[direction][xy][0]>>
shift) + sx;
2288 int my= (motion_val[direction][xy][1]>>
shift) + sy;
2289 draw_arrow(ptr, sx, sy, mx, my, width, height, pict->
linesize[0], 100, 0, direction);
2294 uint64_t
c = (qscale_table[mb_index] * 128 / 31) *
2295 0x0101010101010101ULL;
2297 for (y = 0; y < block_height; y++) {
2298 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2299 (block_height * mb_y + y) *
2301 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2302 (block_height * mb_y + y) *
2308 int mb_type = mbtype_table[mb_index];
2311 #define COLOR(theta, r) \
2312 u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
2313 v = (int)(128 + r * sin(theta * 3.141592 / 180));
2330 }
else if (
IS_GMC(mb_type)) {
2332 }
else if (
IS_SKIP(mb_type)) {
2343 u *= 0x0101010101010101ULL;
2344 v *= 0x0101010101010101ULL;
2345 for (y = 0; y < block_height; y++) {
2346 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2347 (block_height * mb_y + y) * pict->
linesize[1]) = u;
2348 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2349 (block_height * mb_y + y) * pict->
linesize[2]) = v;
2354 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 0 +
2355 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2356 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 8 +
2357 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2360 for (y = 0; y < 16; y++)
2361 pict->
data[0][16 * mb_x + 8 + (16 * mb_y + y) *
2364 if (
IS_8X8(mb_type) && mv_sample_log2 >= 2) {
2365 int dm = 1 << (mv_sample_log2 - 2);
2366 for (i = 0; i < 4; i++) {
2367 int sx = mb_x * 16 + 8 * (i & 1);
2368 int sy = mb_y * 16 + 8 * (i >> 1);
2369 int xy = (mb_x * 2 + (i & 1) +
2370 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2373 if (mv[0] != mv[dm] ||
2374 mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
2375 for (y = 0; y < 8; y++)
2376 pict->
data[0][sx + 4 + (sy + y) * pict->
linesize[0]] ^= 0x80;
2377 if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
2378 *(uint64_t *)(pict->
data[0] + sx + (sy + 4) *
2379 pict->
linesize[0]) ^= 0x8080808080808080ULL;
2388 mbskip_table[mb_index] = 0;
2415 int field_based,
int field_select,
2416 int src_x,
int src_y,
2418 int h_edge_pos,
int v_edge_pos,
2420 int motion_x,
int motion_y)
2423 const int op_index =
FFMIN(lowres, 3);
2424 const int s_mask = (2 <<
lowres) - 1;
2433 sx = motion_x & s_mask;
2434 sy = motion_y & s_mask;
2435 src_x += motion_x >> lowres + 1;
2436 src_y += motion_y >> lowres + 1;
2438 src += src_y * stride + src_x;
2440 if ((
unsigned)src_x >
FFMAX( h_edge_pos - (!!sx) - w, 0) ||
2441 (unsigned)src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2444 w + 1, (h + 1) << field_based,
2445 src_x, src_y << field_based,
2446 h_edge_pos, v_edge_pos);
2451 sx = (sx << 2) >>
lowres;
2452 sy = (sy << 2) >>
lowres;
2455 pix_op[op_index](dest,
src, stride, h, sx, sy);
2469 int motion_x,
int motion_y,
2472 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
2473 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy;
2474 ptrdiff_t uvlinesize, linesize;
2477 const int block_s = 8>>
lowres;
2478 const int s_mask = (2 <<
lowres) - 1;
2491 motion_y += (bottom_field - field_select)*((1 << lowres)-1);
2494 sx = motion_x & s_mask;
2495 sy = motion_y & s_mask;
2496 src_x = s->
mb_x * 2 * block_s + (motion_x >> lowres + 1);
2497 src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >> lowres + 1);
2500 uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
2501 uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
2502 uvsrc_x = src_x >> 1;
2503 uvsrc_y = src_y >> 1;
2508 uvsx = (2 * mx) & s_mask;
2509 uvsy = (2 * my) & s_mask;
2510 uvsrc_x = s->
mb_x * block_s + (mx >>
lowres);
2511 uvsrc_y = mb_y * block_s + (my >>
lowres);
2518 uvsrc_x = s->
mb_x * block_s + (mx >> lowres + 1);
2519 uvsrc_y = (mb_y * block_s >> field_based) + (my >> lowres + 1);
2525 uvsy = motion_y & s_mask;
2527 uvsrc_x = s->
mb_x*block_s + (mx >> (lowres+1));
2530 uvsx = motion_x & s_mask;
2531 uvsy = motion_y & s_mask;
2538 ptr_y = ref_picture[0] + src_y * linesize + src_x;
2539 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
2540 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
2542 if ((
unsigned) src_x >
FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
2543 (
unsigned) src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2545 linesize >> field_based, linesize >> field_based,
2546 17, 17 + field_based,
2547 src_x, src_y << field_based, h_edge_pos,
2554 uvlinesize >> field_based, uvlinesize >> field_based,
2556 uvsrc_x, uvsrc_y << field_based,
2557 h_edge_pos >> 1, v_edge_pos >> 1);
2559 uvlinesize >> field_based,uvlinesize >> field_based,
2561 uvsrc_x, uvsrc_y << field_based,
2562 h_edge_pos >> 1, v_edge_pos >> 1);
2581 sx = (sx << 2) >>
lowres;
2582 sy = (sy << 2) >>
lowres;
2583 pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
2587 uvsx = (uvsx << 2) >>
lowres;
2588 uvsy = (uvsy << 2) >>
lowres;
2590 pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy);
2591 pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy);
2604 const int op_index =
FFMIN(lowres, 3);
2605 const int block_s = 8 >>
lowres;
2606 const int s_mask = (2 <<
lowres) - 1;
2607 const int h_edge_pos = s->
h_edge_pos >> lowres + 1;
2608 const int v_edge_pos = s->
v_edge_pos >> lowres + 1;
2609 int emu = 0, src_x, src_y, sx, sy;
2625 src_x = s->
mb_x * block_s + (mx >> lowres + 1);
2626 src_y = s->
mb_y * block_s + (my >> lowres + 1);
2629 ptr = ref_picture[1] +
offset;
2630 if ((
unsigned) src_x >
FFMAX(h_edge_pos - (!!sx) - block_s, 0) ||
2631 (unsigned) src_y >
FFMAX(v_edge_pos - (!!sy) - block_s, 0)) {
2635 src_x, src_y, h_edge_pos, v_edge_pos);
2639 sx = (sx << 2) >>
lowres;
2640 sy = (sy << 2) >>
lowres;
2641 pix_op[op_index](dest_cb, ptr, s->
uvlinesize, block_s, sx, sy);
2643 ptr = ref_picture[2] +
offset;
2648 src_x, src_y, h_edge_pos, v_edge_pos);
2651 pix_op[op_index](dest_cr, ptr, s->
uvlinesize, block_s, sx, sy);
2668 int dir,
uint8_t **ref_picture,
2674 const int block_s = 8 >>
lowres;
2683 ref_picture, pix_op,
2684 s->
mv[dir][0][0], s->
mv[dir][0][1],
2690 for (i = 0; i < 4; i++) {
2693 ref_picture[0], 0, 0,
2694 (2 * mb_x + (i & 1)) * block_s,
2695 (2 * mb_y + (i >> 1)) * block_s,
2698 block_s, block_s, pix_op,
2699 s->
mv[dir][i][0], s->
mv[dir][i][1]);
2701 mx += s->
mv[dir][i][0];
2702 my += s->
mv[dir][i][1];
2714 ref_picture, pix_op,
2715 s->
mv[dir][0][0], s->
mv[dir][0][1],
2720 ref_picture, pix_op,
2721 s->
mv[dir][1][0], s->
mv[dir][1][1],
2731 ref_picture, pix_op,
2733 s->
mv[dir][0][1], 2 * block_s, mb_y >> 1);
2737 for (i = 0; i < 2; i++) {
2742 ref2picture = ref_picture;
2749 ref2picture, pix_op,
2750 s->
mv[dir][i][0], s->
mv[dir][i][1] +
2751 2 * block_s * i, block_s, mb_y >> 1);
2753 dest_y += 2 * block_s * s->
linesize;
2760 for (i = 0; i < 2; i++) {
2762 for (j = 0; j < 2; j++) {
2765 ref_picture, pix_op,
2766 s->
mv[dir][2 * i + j][0],
2767 s->
mv[dir][2 * i + j][1],
2773 for (i = 0; i < 2; i++) {
2776 ref_picture, pix_op,
2777 s->
mv[dir][2 * i][0],s->
mv[dir][2 * i][1],
2778 2 * block_s, mb_y >> 1);
2801 int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->
quarter_sample;
2802 int my, off, i, mvs;
2821 for (i = 0; i < mvs; i++) {
2822 my = s->
mv[dir][i][1]<<qpel_shift;
2823 my_max =
FFMAX(my_max, my);
2824 my_min =
FFMIN(my_min, my);
2827 off = (
FFMAX(-my_min, my_max) + 63) >> 6;
2836 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
2852 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
2874 memset(s->
ac_val[0][xy ], 0, 32 *
sizeof(int16_t));
2875 memset(s->
ac_val[0][xy + wrap], 0, 32 *
sizeof(int16_t));
2888 memset(s->
ac_val[1][xy], 0, 16 *
sizeof(int16_t));
2889 memset(s->
ac_val[2][xy], 0, 16 *
sizeof(int16_t));
2906 int lowres_flag,
int is_mpeg12)
2921 for(j=0; j<64; j++){
2948 uint8_t *dest_y, *dest_cb, *dest_cr;
2949 int dct_linesize, dct_offset;
2955 const int block_size= lowres_flag ? 8>>s->
avctx->
lowres : 8;
2974 dct_offset = s->
interlaced_dct ? linesize : linesize * block_size;
2978 dest_cb= s->
dest[1];
2979 dest_cr= s->
dest[2];
3062 add_dct(s, block[0], 0, dest_y , dct_linesize);
3063 add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
3064 add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
3065 add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
3069 add_dct(s, block[4], 4, dest_cb, uvlinesize);
3070 add_dct(s, block[5], 5, dest_cr, uvlinesize);
3074 dct_offset = s->
interlaced_dct ? uvlinesize : uvlinesize*block_size;
3076 add_dct(s, block[4], 4, dest_cb, dct_linesize);
3077 add_dct(s, block[5], 5, dest_cr, dct_linesize);
3078 add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
3079 add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
3081 add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
3082 add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
3083 add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
3084 add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
3089 else if (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) {
3096 put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->
qscale);
3097 put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->
qscale);
3098 put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->
qscale);
3115 s->
idsp.
idct_put(dest_y + block_size, dct_linesize, block[1]);
3116 s->
idsp.
idct_put(dest_y + dct_offset, dct_linesize, block[2]);
3117 s->
idsp.
idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
3126 dct_offset = s->
interlaced_dct ? uvlinesize : uvlinesize*block_size;
3130 s->
idsp.
idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
3131 s->
idsp.
idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
3133 s->
idsp.
idct_put(dest_cb + block_size, dct_linesize, block[8]);
3134 s->
idsp.
idct_put(dest_cr + block_size, dct_linesize, block[9]);
3135 s->
idsp.
idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
3136 s->
idsp.
idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
3189 s->
dest[0] += s->
mb_y * linesize << mb_size;
3193 s->
dest[0] += (s->
mb_y>>1) * linesize << mb_size;
3217 for(i=0; i<=last; i++){
3218 const int j= scantable[i];
3223 for(i=0; i<=last; i++){
3224 const int j= scantable[i];
3225 const int perm_j= permutation[j];
3226 block[perm_j]= temp[j];
3234 if(s==NULL || s->
picture==NULL)
3265 else if (qscale > 31)