47 int16_t *
block,
int n,
int qscale);
49 int16_t *
block,
int n,
int qscale);
51 int16_t *
block,
int n,
int qscale);
53 int16_t *
block,
int n,
int qscale);
55 int16_t *
block,
int n,
int qscale);
57 int16_t *
block,
int n,
int qscale);
59 int16_t *
block,
int n,
int qscale);
67 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
68 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
73 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
74 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
75 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
76 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
77 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
78 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
79 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
80 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
85 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
86 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
87 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
88 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
89 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
90 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
91 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
92 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
97 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
98 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
99 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
100 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
102 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
103 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
104 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
109 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
110 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
111 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
112 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
113 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
114 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
115 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
116 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
133 int mb_x,
int mb_y,
int mb_intra,
int mb_skipped)
143 memcpy(s->
mv,
mv,
sizeof(*
mv));
168 for (i = 0; i < 3; i++) {
169 uint32_t tmp = *state << 8;
170 *state = tmp + *(p++);
171 if (tmp == 0x100 || p == end)
176 if (p[-1] > 1 ) p += 3;
177 else if (p[-2] ) p += 2;
178 else if (p[-3]|(p[-1]-1)) p++;
185 p =
FFMIN(p, end) - 4;
308 if (r < 0 || !pic->f.type || !pic->
f.
data[0]) {
318 "get_buffer() failed (stride changed)\n");
325 "get_buffer() failed (uv stride mismatch)\n");
333 "get_buffer() failed to allocate context scratch buffers.\n");
358 assert(pic->
f.
data[0]);
362 assert(!pic->
f.
data[0]);
374 mb_array_size *
sizeof(int16_t), fail)
376 mb_array_size *
sizeof(int16_t), fail)
378 mb_array_size *
sizeof(int8_t ), fail)
382 mb_array_size *
sizeof(
uint8_t) + 2, fail)
387 (big_mb_num + s->
mb_stride) *
sizeof(uint32_t),
392 for (i = 0; i < 2; i++) {
394 2 * (b4_array_size + 4) *
sizeof(int16_t),
398 4 * mb_array_size *
sizeof(
uint8_t), fail)
403 for (i = 0; i < 2; i++) {
405 2 * (b8_array_size + 4) *
sizeof(int16_t),
409 4 * mb_array_size *
sizeof(
uint8_t), fail)
415 64 * mb_array_size *
sizeof(int16_t) * 6, fail)
453 for (i = 0; i < 2; i++) {
460 for (i = 0; i < 4; i++) {
472 int yc_size = y_size + 2 * c_size;
489 2 * 64 *
sizeof(
int), fail)
495 for (i = 0; i < 12; i++) {
502 yc_size *
sizeof(int16_t) * 16, fail);
535 #define COPY(a) bak->a = src->a
536 COPY(edge_emu_buffer);
541 COPY(obmc_scratchpad);
569 for (i = 0; i < 12; i++) {
575 "scratch buffers.\n");
604 if (
s1->context_initialized){
635 (
char *) &
s1->last_picture_ptr - (
char *) &
s1->last_picture);
654 (
char *) &
s1->shape - (
char *) &
s1->time_increment_bits);
664 if (
s1->bitstream_buffer) {
665 if (
s1->bitstream_buffer_size +
669 s1->allocated_bitstream_buffer_size);
672 s1->bitstream_buffer_size);
682 "scratch buffers.\n");
687 "be allocated due to unknown size.\n");
692 (
char *) &
s1->rtp_mode - (
char *) &
s1->progressive_sequence);
694 if (!
s1->first_field) {
696 if (
s1->current_picture_ptr)
789 int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x,
y;
814 yc_size = y_size + 2 * c_size;
844 mb_array_size *
sizeof(
float), fail);
846 mb_array_size *
sizeof(
float), fail);
853 for (i = 0; i < 2; i++) {
855 for (j = 0; j < 2; j++) {
856 for (k = 0; k < 2; k++) {
859 mv_table_size * 2 *
sizeof(int16_t),
888 for (i = 0; i < yc_size; i++)
912 int nb_slices = (HAVE_THREADS &&
926 "decoding to AV_PIX_FMT_NONE is not supported.\n");
937 " reducing to %d\n", nb_slices, max_slices);
938 nb_slices = max_slices;
963 (
MAX_RUN + 1) * 2 *
sizeof(
int), fail);
998 for (i = 1; i < nb_slices; i++) {
1003 for (i = 0; i < nb_slices; i++) {
1007 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1009 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1048 for (i = 0; i < 2; i++) {
1049 for (j = 0; j < 2; j++) {
1050 for (k = 0; k < 2; k++) {
1079 for (i = 0; i < 3; i++)
1127 if (nb_slices > 1) {
1128 for (i = 1; i < nb_slices; i++) {
1133 for (i = 0; i < nb_slices; i++) {
1137 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1139 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1223 for (last = 0; last < 2; last++) {
1232 memset(max_level, 0,
MAX_RUN + 1);
1234 memset(index_run, rl->
n,
MAX_RUN + 1);
1235 for (i = start; i <
end; i++) {
1238 if (index_run[run] == rl->
n)
1240 if (level > max_level[run])
1242 if (run > max_run[level])
1246 rl->
max_level[last] = static_store[last];
1259 memcpy(rl->
index_run[last], index_run, MAX_RUN + 1);
1267 for (q = 0; q < 32; q++) {
1269 int qadd = (q - 1) | 1;
1283 }
else if (len < 0) {
1287 if (code == rl->
n) {
1293 if (code >= rl->
last) run += 192;
1353 "Internal error, picture buffer overflow\n");
1373 if (ret >= 0 && ret < s->picture_range_end) {
1387 for (intra = 0; intra < 2; intra++) {
1389 for (i = 0; i < 64; i++) {
1395 for (i = 0; i < 64; i++) {
1438 "releasing zombie picture\n");
1501 av_dlog(s->
avctx,
"L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
1513 int h_chroma_shift, v_chroma_shift;
1515 &h_chroma_shift, &v_chroma_shift);
1518 "warning: first frame is no keyframe\n");
1521 "allocate dummy last picture for field based first keyframe\n");
1539 (avctx->
height >> v_chroma_shift) *
1542 (avctx->
height >> v_chroma_shift) *
1546 for(i=0; i<avctx->
height; i++)
1594 for (i = 0; i < 4; i++) {
1682 assert(i < MAX_PICTURE_COUNT);
1719 sx = av_clip(sx, 0, w - 1);
1720 sy = av_clip(sy, 0, h - 1);
1721 ex = av_clip(ex, 0, w - 1);
1722 ey = av_clip(ey, 0, h - 1);
1724 buf[sy * stride + sx] +=
color;
1733 f = ((ey - sy) << 16) / ex;
1734 for (x = 0; x <= ex; x++) {
1736 fr = (x * f) & 0xFFFF;
1737 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
1738 if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16;
1748 f = ((ex - sx) << 16) / ey;
1751 for(y= 0; y <= ey; y++){
1753 fr = (y*f) & 0xFFFF;
1754 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
1755 if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16;
1772 sx = av_clip(sx, -100, w + 100);
1773 sy = av_clip(sy, -100, h + 100);
1774 ex = av_clip(ex, -100, w + 100);
1775 ey = av_clip(ey, -100, h + 100);
1780 if (dx * dx + dy * dy > 3 * 3) {
1783 int length =
ff_sqrt((rx * rx + ry * ry) << 8);
1789 draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
1790 draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
1792 draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
1799 uint8_t *visualization_buffer[3],
int *low_delay,
1800 int mb_width,
int mb_height,
int mb_stride,
int quarter_sample)
1812 for (y = 0; y < mb_height; y++) {
1813 for (x = 0; x < mb_width; x++) {
1815 int count = mbskip_table[x + y * mb_stride];
1825 int mb_type = pict->
mb_type[x + y * mb_stride];
1841 else if (
IS_GMC(mb_type))
1879 const int shift = 1 + quarter_sample;
1883 int h_chroma_shift, v_chroma_shift, block_height;
1887 const int mv_stride = (mb_width << mv_sample_log2) +
1893 for (i = 0; i < 3; i++) {
1896 visualization_buffer[i]=
av_realloc(visualization_buffer[i], size);
1897 memcpy(visualization_buffer[i], pict->
data[i], size);
1898 pict->
data[i] = visualization_buffer[i];
1902 ptr = pict->
data[0];
1903 block_height = 16 >> v_chroma_shift;
1905 for (mb_y = 0; mb_y < mb_height; mb_y++) {
1907 for (mb_x = 0; mb_x < mb_width; mb_x++) {
1908 const int mb_index = mb_x + mb_y * mb_stride;
1911 for (type = 0; type < 3; type++) {
1938 for (i = 0; i < 4; i++) {
1939 int sx = mb_x * 16 + 4 + 8 * (i & 1);
1940 int sy = mb_y * 16 + 4 + 8 * (i >> 1);
1941 int xy = (mb_x * 2 + (i & 1) +
1942 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
1950 for (i = 0; i < 2; i++) {
1951 int sx = mb_x * 16 + 8;
1952 int sy = mb_y * 16 + 4 + 8 * i;
1953 int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
1960 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
1965 for (i = 0; i < 2; i++) {
1966 int sx = mb_x * 16 + 4 + 8 * i;
1967 int sy = mb_y * 16 + 8;
1968 int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
1975 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
1979 int sx= mb_x * 16 + 8;
1980 int sy= mb_y * 16 + 8;
1981 int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
1990 0x0101010101010101ULL;
1992 for (y = 0; y < block_height; y++) {
1993 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
1994 (block_height * mb_y + y) *
1996 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
1997 (block_height * mb_y + y) *
2003 int mb_type = pict->
mb_type[mb_index];
2006 #define COLOR(theta, r) \
2007 u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
2008 v = (int)(128 + r * sin(theta * 3.141592 / 180));
2025 }
else if (
IS_GMC(mb_type)) {
2027 }
else if (
IS_SKIP(mb_type)) {
2038 u *= 0x0101010101010101ULL;
2039 v *= 0x0101010101010101ULL;
2040 for (y = 0; y < block_height; y++) {
2041 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2042 (block_height * mb_y + y) * pict->
linesize[1]) = u;
2043 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2044 (block_height * mb_y + y) * pict->
linesize[2]) = v;
2049 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 0 +
2050 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2051 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 8 +
2052 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2055 for (y = 0; y < 16; y++)
2056 pict->
data[0][16 * mb_x + 8 + (16 * mb_y + y) *
2059 if (
IS_8X8(mb_type) && mv_sample_log2 >= 2) {
2060 int dm = 1 << (mv_sample_log2 - 2);
2061 for (i = 0; i < 4; i++) {
2062 int sx = mb_x * 16 + 8 * (i & 1);
2063 int sy = mb_y * 16 + 8 * (i >> 1);
2064 int xy = (mb_x * 2 + (i & 1) +
2065 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2068 if (mv[0] != mv[dm] ||
2069 mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
2070 for (y = 0; y < 8; y++)
2071 pict->
data[0][sx + 4 + (sy + y) * pict->
linesize[0]] ^= 0x80;
2072 if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
2073 *(uint64_t *)(pict->
data[0] + sx + (sy + 4) *
2074 pict->
linesize[0]) ^= 0x8080808080808080ULL;
2083 mbskip_table[mb_index] = 0;
2097 int field_based,
int field_select,
2098 int src_x,
int src_y,
2100 int h_edge_pos,
int v_edge_pos,
2102 int motion_x,
int motion_y)
2105 const int op_index =
FFMIN(lowres, 2);
2106 const int s_mask = (2 <<
lowres) - 1;
2115 sx = motion_x & s_mask;
2116 sy = motion_y & s_mask;
2117 src_x += motion_x >> lowres + 1;
2118 src_y += motion_y >> lowres + 1;
2120 src += src_y * stride + src_x;
2122 if ((
unsigned)src_x >
FFMAX( h_edge_pos - (!!sx) - w, 0) ||
2123 (unsigned)src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2125 (h + 1) << field_based, src_x,
2126 src_y << field_based,
2133 sx = (sx << 2) >>
lowres;
2134 sy = (sy << 2) >>
lowres;
2137 pix_op[op_index](dest, src,
stride, h, sx, sy);
2151 int motion_x,
int motion_y,
2154 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
2155 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, uvlinesize, linesize, sx, sy,
2159 const int block_s = 8>>
lowres;
2160 const int s_mask = (2 <<
lowres) - 1;
2173 motion_y += (bottom_field - field_select)*((1 << lowres)-1);
2176 sx = motion_x & s_mask;
2177 sy = motion_y & s_mask;
2178 src_x = s->
mb_x * 2 * block_s + (motion_x >> lowres + 1);
2179 src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >> lowres + 1);
2182 uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
2183 uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
2184 uvsrc_x = src_x >> 1;
2185 uvsrc_y = src_y >> 1;
2190 uvsx = (2 * mx) & s_mask;
2191 uvsy = (2 * my) & s_mask;
2192 uvsrc_x = s->
mb_x * block_s + (mx >>
lowres);
2193 uvsrc_y = mb_y * block_s + (my >>
lowres);
2200 uvsrc_x = s->
mb_x * block_s + (mx >> lowres + 1);
2201 uvsrc_y = (mb_y * block_s >> field_based) + (my >> lowres + 1);
2207 uvsy = motion_y & s_mask;
2209 uvsrc_x = s->
mb_x*block_s + (mx >> (lowres+1));
2212 uvsx = motion_x & s_mask;
2213 uvsy = motion_y & s_mask;
2220 ptr_y = ref_picture[0] + src_y * linesize + src_x;
2221 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
2222 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
2224 if ((
unsigned) src_x >
FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
2225 (
unsigned) src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2227 linesize >> field_based, 17, 17 + field_based,
2228 src_x, src_y << field_based, h_edge_pos,
2235 uvsrc_x, uvsrc_y << field_based,
2236 h_edge_pos >> 1, v_edge_pos >> 1);
2239 uvsrc_x, uvsrc_y << field_based,
2240 h_edge_pos >> 1, v_edge_pos >> 1);
2242 ptr_cr = uvbuf + 16;
2259 sx = (sx << 2) >>
lowres;
2260 sy = (sy << 2) >>
lowres;
2261 pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
2265 uvsx = (uvsx << 2) >>
lowres;
2266 uvsy = (uvsy << 2) >>
lowres;
2268 pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy);
2269 pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy);
2282 const int op_index =
FFMIN(lowres, 2);
2283 const int block_s = 8 >>
lowres;
2284 const int s_mask = (2 <<
lowres) - 1;
2285 const int h_edge_pos = s->
h_edge_pos >> lowres + 1;
2286 const int v_edge_pos = s->
v_edge_pos >> lowres + 1;
2287 int emu = 0, src_x, src_y,
offset, sx, sy;
2302 src_x = s->
mb_x * block_s + (mx >> lowres + 1);
2303 src_y = s->
mb_y * block_s + (my >> lowres + 1);
2306 ptr = ref_picture[1] +
offset;
2308 if ((
unsigned) src_x >
FFMAX(h_edge_pos - (!!sx) - block_s, 0) ||
2309 (unsigned) src_y >
FFMAX(v_edge_pos - (!!sy) - block_s, 0)) {
2311 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
2316 sx = (sx << 2) >>
lowres;
2317 sy = (sy << 2) >>
lowres;
2318 pix_op[op_index](dest_cb, ptr, s->
uvlinesize, block_s, sx, sy);
2320 ptr = ref_picture[2] +
offset;
2323 src_x, src_y, h_edge_pos, v_edge_pos);
2326 pix_op[op_index](dest_cr, ptr, s->
uvlinesize, block_s, sx, sy);
2343 int dir,
uint8_t **ref_picture,
2349 const int block_s = 8 >>
lowres;
2358 ref_picture, pix_op,
2359 s->
mv[dir][0][0], s->
mv[dir][0][1],
2365 for (i = 0; i < 4; i++) {
2368 ref_picture[0], 0, 0,
2369 (2 * mb_x + (i & 1)) * block_s,
2370 (2 * mb_y + (i >> 1)) * block_s,
2373 block_s, block_s, pix_op,
2374 s->
mv[dir][i][0], s->
mv[dir][i][1]);
2376 mx += s->
mv[dir][i][0];
2377 my += s->
mv[dir][i][1];
2389 ref_picture, pix_op,
2390 s->
mv[dir][0][0], s->
mv[dir][0][1],
2395 ref_picture, pix_op,
2396 s->
mv[dir][1][0], s->
mv[dir][1][1],
2406 ref_picture, pix_op,
2408 s->
mv[dir][0][1], 2 * block_s, mb_y >> 1);
2412 for (i = 0; i < 2; i++) {
2417 ref2picture = ref_picture;
2424 ref2picture, pix_op,
2425 s->
mv[dir][i][0], s->
mv[dir][i][1] +
2426 2 * block_s * i, block_s, mb_y >> 1);
2428 dest_y += 2 * block_s * s->
linesize;
2435 for (i = 0; i < 2; i++) {
2437 for (j = 0; j < 2; j++) {
2440 ref_picture, pix_op,
2441 s->
mv[dir][2 * i + j][0],
2442 s->
mv[dir][2 * i + j][1],
2448 for (i = 0; i < 2; i++) {
2451 ref_picture, pix_op,
2452 s->
mv[dir][2 * i][0],s->
mv[dir][2 * i][1],
2453 2 * block_s, mb_y >> 1);
2476 int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->
quarter_sample;
2477 int my,
off, i, mvs;
2496 for (i = 0; i < mvs; i++) {
2497 my = s->
mv[dir][i][1]<<qpel_shift;
2498 my_max =
FFMAX(my_max, my);
2499 my_min =
FFMIN(my_min, my);
2502 off = (
FFMAX(-my_min, my_max) + 63) >> 6;
2511 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
2527 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
2549 memset(s->
ac_val[0][xy ], 0, 32 *
sizeof(int16_t));
2550 memset(s->
ac_val[0][xy + wrap], 0, 32 *
sizeof(int16_t));
2563 memset(s->
ac_val[1][xy], 0, 16 *
sizeof(int16_t));
2564 memset(s->
ac_val[2][xy], 0, 16 *
sizeof(int16_t));
2581 int lowres_flag,
int is_mpeg12)
2595 for(j=0; j<64; j++){
2620 uint8_t *dest_y, *dest_cb, *dest_cr;
2621 int dct_linesize, dct_offset;
2627 const int block_size= lowres_flag ? 8>>s->
avctx->
lowres : 8;
2646 dct_offset = s->
interlaced_dct ? linesize : linesize * block_size;
2650 dest_cb= s->
dest[1];
2651 dest_cr= s->
dest[2];
2734 add_dct(s, block[0], 0, dest_y , dct_linesize);
2735 add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
2736 add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
2737 add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
2741 add_dct(s, block[4], 4, dest_cb, uvlinesize);
2742 add_dct(s, block[5], 5, dest_cr, uvlinesize);
2746 dct_offset = s->
interlaced_dct ? uvlinesize : uvlinesize*block_size;
2748 add_dct(s, block[4], 4, dest_cb, dct_linesize);
2749 add_dct(s, block[5], 5, dest_cr, dct_linesize);
2750 add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
2751 add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
2753 add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
2754 add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
2755 add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
2756 add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
2761 else if (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) {
2768 put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->
qscale);
2769 put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->
qscale);
2770 put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->
qscale);
2787 s->
dsp.
idct_put(dest_y + block_size, dct_linesize, block[1]);
2788 s->
dsp.
idct_put(dest_y + dct_offset , dct_linesize, block[2]);
2789 s->
dsp.
idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
2798 dct_offset = s->
interlaced_dct? uvlinesize : uvlinesize*block_size;
2802 s->
dsp.
idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
2803 s->
dsp.
idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
2805 s->
dsp.
idct_put(dest_cb + block_size, dct_linesize, block[8]);
2806 s->
dsp.
idct_put(dest_cr + block_size, dct_linesize, block[9]);
2807 s->
dsp.
idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
2808 s->
dsp.
idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
2838 Picture *last,
int y,
int h,
int picture_structure,
2840 int v_edge_pos,
int h_edge_pos)
2845 const int field_pic = picture_structure !=
PICT_FRAME;
2857 int sides = 0, edge_h;
2859 if (y + h >= v_edge_pos)
2862 edge_h=
FFMIN(h, v_edge_pos - y);
2865 linesize[0], h_edge_pos, edge_h,
2868 linesize[1], h_edge_pos >> hshift, edge_h >> vshift,
2871 linesize[2], h_edge_pos >> hshift, edge_h >> vshift,
2901 offset[2]= (y >> vshift) * src->
linesize[1];
2909 y, picture_structure, h);
2942 s->
dest[0] += s->
mb_y * linesize << mb_size;
2946 s->
dest[0] += (s->
mb_y>>1) * linesize << mb_size;
2970 for(i=0; i<=last; i++){
2971 const int j= scantable[i];
2976 for(i=0; i<=last; i++){
2977 const int j= scantable[i];
2978 const int perm_j= permutation[j];
2979 block[perm_j]= temp[j];
3012 int16_t *
block,
int n,
int qscale)
3014 int i,
level, nCoeffs;
3015 const uint16_t *quant_matrix;
3022 for(i=1;i<=nCoeffs;i++) {
3028 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3029 level = (level - 1) | 1;
3032 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3033 level = (level - 1) | 1;
3041 int16_t *
block,
int n,
int qscale)
3043 int i,
level, nCoeffs;
3044 const uint16_t *quant_matrix;
3049 for(i=0; i<=nCoeffs; i++) {
3055 level = (((level << 1) + 1) * qscale *
3056 ((int) (quant_matrix[j]))) >> 4;
3057 level = (level - 1) | 1;
3060 level = (((level << 1) + 1) * qscale *
3061 ((int) (quant_matrix[j]))) >> 4;
3062 level = (level - 1) | 1;
3070 int16_t *
block,
int n,
int qscale)
3072 int i,
level, nCoeffs;
3073 const uint16_t *quant_matrix;
3080 for(i=1;i<=nCoeffs;i++) {
3086 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3089 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3097 int16_t *
block,
int n,
int qscale)
3099 int i,
level, nCoeffs;
3100 const uint16_t *quant_matrix;
3109 for(i=1;i<=nCoeffs;i++) {
3115 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3118 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3128 int16_t *
block,
int n,
int qscale)
3130 int i,
level, nCoeffs;
3131 const uint16_t *quant_matrix;
3138 for(i=0; i<=nCoeffs; i++) {
3144 level = (((level << 1) + 1) * qscale *
3145 ((int) (quant_matrix[j]))) >> 4;
3148 level = (((level << 1) + 1) * qscale *
3149 ((int) (quant_matrix[j]))) >> 4;
3159 int16_t *
block,
int n,
int qscale)
3161 int i,
level, qmul, qadd;
3170 qadd = (qscale - 1) | 1;
3179 for(i=1; i<=nCoeffs; i++) {
3183 level = level * qmul - qadd;
3185 level = level * qmul + qadd;
3193 int16_t *
block,
int n,
int qscale)
3195 int i,
level, qmul, qadd;
3200 qadd = (qscale - 1) | 1;
3205 for(i=0; i<=nCoeffs; i++) {
3209 level = level * qmul - qadd;
3211 level = level * qmul + qadd;
3225 else if (qscale > 31)