46 int16_t *
block,
int n,
int qscale);
48 int16_t *
block,
int n,
int qscale);
50 int16_t *
block,
int n,
int qscale);
52 int16_t *
block,
int n,
int qscale);
54 int16_t *
block,
int n,
int qscale);
56 int16_t *
block,
int n,
int qscale);
58 int16_t *
block,
int n,
int qscale);
62 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
63 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
68 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
69 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
70 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
71 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
72 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
73 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
74 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
75 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
80 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
81 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
82 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
83 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
84 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
85 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
86 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
87 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
92 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
93 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
95 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
96 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
97 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
98 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
99 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
104 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
105 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
106 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
107 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
108 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
109 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
110 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
111 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
128 int mb_x,
int mb_y,
int mb_intra,
int mb_skipped)
138 memcpy(s->
mv,
mv,
sizeof(*
mv));
243 if (r < 0 || !pic->f.data[0]) {
264 "get_buffer() failed (stride changed)\n");
271 "get_buffer() failed (uv stride mismatch)\n");
279 "get_buffer() failed to allocate context scratch buffers.\n");
301 for (i = 0; i < 2; i++) {
332 int mv_size = 2 * (b8_array_size + 4) *
sizeof(int16_t);
333 int ref_index_size = 4 * mb_array_size;
335 for (i = 0; mv_size && i < 2; i++) {
352 #define MAKE_WRITABLE(table) \
355 (ret = av_buffer_make_writable(&pic->table)) < 0)\
366 for (i = 0; i < 2; i++) {
418 for (i = 0; i < 2; i++) {
454 memset((
uint8_t*)pic + off, 0,
sizeof(*pic) - off);
461 #define UPDATE_TABLE(table)\
464 (!dst->table || dst->table->buffer != src->table->buffer)) {\
465 av_buffer_unref(&dst->table);\
466 dst->table = av_buffer_ref(src->table);\
468 free_picture_tables(dst);\
469 return AVERROR(ENOMEM);\
480 for (i = 0; i < 2; i++) {
491 for (i = 0; i < 2; i++) {
553 int yc_size = y_size + 2 * c_size;
570 2 * 64 *
sizeof(
int), fail)
576 for (i = 0; i < 12; i++) {
585 yc_size *
sizeof(int16_t) * 16, fail);
618 #define COPY(a) bak->a = src->a
619 COPY(edge_emu_buffer);
624 COPY(obmc_scratchpad);
652 for (i = 0; i < 12; i++) {
660 "scratch buffers.\n");
688 if (
s1->context_initialized){
720 if (
s1->picture[i].f.data[0] &&
725 #define UPDATE_PICTURE(pic)\
727 ff_mpeg_unref_picture(s, &s->pic);\
728 if (s1->pic.f.data[0])\
729 ret = ff_mpeg_ref_picture(s, &s->pic, &s1->pic);\
731 ret = update_picture_tables(&s->pic, &s1->pic);\
751 (
char *) &
s1->shape - (
char *) &
s1->time_increment_bits);
761 if (
s1->bitstream_buffer) {
762 if (
s1->bitstream_buffer_size +
766 s1->allocated_bitstream_buffer_size);
769 s1->bitstream_buffer_size);
779 "scratch buffers.\n");
784 "be allocated due to unknown size.\n");
789 (
char *) &
s1->rtp_mode - (
char *) &
s1->progressive_sequence);
791 if (!
s1->first_field) {
793 if (
s1->current_picture_ptr)
883 int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x,
y;
908 yc_size = y_size + 2 * c_size;
938 mb_array_size *
sizeof(
float), fail);
940 mb_array_size *
sizeof(
float), fail);
947 for (i = 0; i < 2; i++) {
949 for (j = 0; j < 2; j++) {
950 for (k = 0; k < 2; k++) {
953 mv_table_size * 2 *
sizeof(int16_t),
982 for (i = 0; i < yc_size; i++)
1006 int nb_slices = (HAVE_THREADS &&
1020 "decoding to AV_PIX_FMT_NONE is not supported.\n");
1031 " reducing to %d\n", nb_slices, max_slices);
1032 nb_slices = max_slices;
1059 (
MAX_RUN + 1) * 2 *
sizeof(
int), fail);
1098 if (nb_slices > 1) {
1099 for (i = 1; i < nb_slices; i++) {
1104 for (i = 0; i < nb_slices; i++) {
1108 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1110 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1149 for (i = 0; i < 2; i++) {
1150 for (j = 0; j < 2; j++) {
1151 for (k = 0; k < 2; k++) {
1226 if (nb_slices > 1) {
1227 for (i = 1; i < nb_slices; i++) {
1232 for (i = 0; i < nb_slices; i++) {
1236 (s->
mb_height * (i) + nb_slices / 2) / nb_slices;
1238 (s->
mb_height * (i + 1) + nb_slices / 2) / nb_slices;
1329 for (last = 0; last < 2; last++) {
1338 memset(max_level, 0,
MAX_RUN + 1);
1340 memset(index_run, rl->
n,
MAX_RUN + 1);
1341 for (i = start; i <
end; i++) {
1344 if (index_run[run] == rl->
n)
1346 if (level > max_level[run])
1348 if (run > max_run[level])
1352 rl->
max_level[last] = static_store[last];
1365 memcpy(rl->
index_run[last], index_run, MAX_RUN + 1);
1373 for (q = 0; q < 32; q++) {
1375 int qadd = (q - 1) | 1;
1389 }
else if (len < 0) {
1393 if (code == rl->
n) {
1399 if (code >= rl->
last) run += 192;
1426 if (pic->
f.
data[0] == NULL)
1450 "Internal error, picture buffer overflow\n");
1485 for (intra = 0; intra < 2; intra++) {
1487 for (i = 0; i < 64; i++) {
1493 for (i = 0; i < 64; i++) {
1533 "releasing zombie picture\n");
1597 av_dlog(s->
avctx,
"L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
1608 int h_chroma_shift, v_chroma_shift;
1610 &h_chroma_shift, &v_chroma_shift);
1613 "allocating dummy last picture for B frame\n");
1616 "warning: first frame is no keyframe\n");
1619 "allocate dummy last picture for field based first keyframe\n");
1637 (avctx->
height >> v_chroma_shift) *
1640 (avctx->
height >> v_chroma_shift) *
1644 for(i=0; i<avctx->
height; i++)
1670 #if 0 // BUFREF-FIXME
1694 for (i = 0; i < 4; i++) {
1808 sx = av_clip(sx, 0, w - 1);
1809 sy = av_clip(sy, 0, h - 1);
1810 ex = av_clip(ex, 0, w - 1);
1811 ey = av_clip(ey, 0, h - 1);
1813 buf[sy * stride + sx] +=
color;
1822 f = ((ey - sy) << 16) / ex;
1823 for (x = 0; x <= ex; x++) {
1825 fr = (x * f) & 0xFFFF;
1826 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
1827 if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16;
1837 f = ((ex - sx) << 16) / ey;
1840 for(y= 0; y <= ey; y++){
1842 fr = (y*f) & 0xFFFF;
1843 buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
1844 if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16;
1861 sx = av_clip(sx, -100, w + 100);
1862 sy = av_clip(sy, -100, h + 100);
1863 ex = av_clip(ex, -100, w + 100);
1864 ey = av_clip(ey, -100, h + 100);
1869 if (dx * dx + dy * dy > 3 * 3) {
1878 draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
1879 draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
1881 draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
1889 int mb_width,
int mb_height,
int mb_stride,
int quarter_sample)
1901 for (y = 0; y < mb_height; y++) {
1902 for (x = 0; x < mb_width; x++) {
1904 int count = mbskip_table[x + y * mb_stride];
1914 int mb_type = p->
mb_type[x + y * mb_stride];
1930 else if (
IS_GMC(mb_type))
1968 const int shift = 1 + quarter_sample;
1972 int h_chroma_shift, v_chroma_shift, block_height;
1976 const int mv_stride = (mb_width << mv_sample_log2) +
1986 ptr = pict->
data[0];
1987 block_height = 16 >> v_chroma_shift;
1989 for (mb_y = 0; mb_y < mb_height; mb_y++) {
1991 for (mb_x = 0; mb_x < mb_width; mb_x++) {
1992 const int mb_index = mb_x + mb_y * mb_stride;
1995 for (type = 0; type < 3; type++) {
2022 for (i = 0; i < 4; i++) {
2023 int sx = mb_x * 16 + 4 + 8 * (i & 1);
2024 int sy = mb_y * 16 + 4 + 8 * (i >> 1);
2025 int xy = (mb_x * 2 + (i & 1) +
2026 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2034 for (i = 0; i < 2; i++) {
2035 int sx = mb_x * 16 + 8;
2036 int sy = mb_y * 16 + 4 + 8 * i;
2037 int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
2044 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2049 for (i = 0; i < 2; i++) {
2050 int sx = mb_x * 16 + 4 + 8 * i;
2051 int sy = mb_y * 16 + 8;
2052 int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
2059 draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
2063 int sx= mb_x * 16 + 8;
2064 int sy= mb_y * 16 + 8;
2065 int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
2074 0x0101010101010101ULL;
2076 for (y = 0; y < block_height; y++) {
2077 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2078 (block_height * mb_y + y) *
2080 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2081 (block_height * mb_y + y) *
2087 int mb_type = p->
mb_type[mb_index];
2090 #define COLOR(theta, r) \
2091 u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
2092 v = (int)(128 + r * sin(theta * 3.141592 / 180));
2109 }
else if (
IS_GMC(mb_type)) {
2111 }
else if (
IS_SKIP(mb_type)) {
2122 u *= 0x0101010101010101ULL;
2123 v *= 0x0101010101010101ULL;
2124 for (y = 0; y < block_height; y++) {
2125 *(uint64_t *)(pict->
data[1] + 8 * mb_x +
2126 (block_height * mb_y + y) * pict->
linesize[1]) = u;
2127 *(uint64_t *)(pict->
data[2] + 8 * mb_x +
2128 (block_height * mb_y + y) * pict->
linesize[2]) = v;
2133 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 0 +
2134 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2135 *(uint64_t *)(pict->
data[0] + 16 * mb_x + 8 +
2136 (16 * mb_y + 8) * pict->
linesize[0]) ^= 0x8080808080808080ULL;
2139 for (y = 0; y < 16; y++)
2140 pict->
data[0][16 * mb_x + 8 + (16 * mb_y + y) *
2143 if (
IS_8X8(mb_type) && mv_sample_log2 >= 2) {
2144 int dm = 1 << (mv_sample_log2 - 2);
2145 for (i = 0; i < 4; i++) {
2146 int sx = mb_x * 16 + 8 * (i & 1);
2147 int sy = mb_y * 16 + 8 * (i >> 1);
2148 int xy = (mb_x * 2 + (i & 1) +
2149 (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
2152 if (mv[0] != mv[dm] ||
2153 mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
2154 for (y = 0; y < 8; y++)
2155 pict->
data[0][sx + 4 + (sy + y) * pict->
linesize[0]] ^= 0x80;
2156 if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
2157 *(uint64_t *)(pict->
data[0] + sx + (sy + 4) *
2158 pict->
linesize[0]) ^= 0x8080808080808080ULL;
2167 mbskip_table[mb_index] = 0;
2193 int field_based,
int field_select,
2194 int src_x,
int src_y,
2196 int h_edge_pos,
int v_edge_pos,
2198 int motion_x,
int motion_y)
2201 const int op_index =
FFMIN(lowres, 3);
2202 const int s_mask = (2 <<
lowres) - 1;
2211 sx = motion_x & s_mask;
2212 sy = motion_y & s_mask;
2213 src_x += motion_x >> lowres + 1;
2214 src_y += motion_y >> lowres + 1;
2216 src += src_y * stride + src_x;
2218 if ((
unsigned)src_x >
FFMAX( h_edge_pos - (!!sx) - w, 0) ||
2219 (unsigned)src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2222 (h + 1) << field_based, src_x,
2223 src_y << field_based,
2230 sx = (sx << 2) >>
lowres;
2231 sy = (sy << 2) >>
lowres;
2234 pix_op[op_index](dest,
src,
stride, h, sx, sy);
2248 int motion_x,
int motion_y,
2251 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
2252 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy;
2253 ptrdiff_t uvlinesize, linesize;
2256 const int block_s = 8>>
lowres;
2257 const int s_mask = (2 <<
lowres) - 1;
2270 motion_y += (bottom_field - field_select)*((1 << lowres)-1);
2273 sx = motion_x & s_mask;
2274 sy = motion_y & s_mask;
2275 src_x = s->
mb_x * 2 * block_s + (motion_x >> lowres + 1);
2276 src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >> lowres + 1);
2279 uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
2280 uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
2281 uvsrc_x = src_x >> 1;
2282 uvsrc_y = src_y >> 1;
2287 uvsx = (2 * mx) & s_mask;
2288 uvsy = (2 * my) & s_mask;
2289 uvsrc_x = s->
mb_x * block_s + (mx >>
lowres);
2290 uvsrc_y = mb_y * block_s + (my >>
lowres);
2297 uvsrc_x = s->
mb_x * block_s + (mx >> lowres + 1);
2298 uvsrc_y = (mb_y * block_s >> field_based) + (my >> lowres + 1);
2304 uvsy = motion_y & s_mask;
2306 uvsrc_x = s->
mb_x*block_s + (mx >> (lowres+1));
2309 uvsx = motion_x & s_mask;
2310 uvsy = motion_y & s_mask;
2317 ptr_y = ref_picture[0] + src_y * linesize + src_x;
2318 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
2319 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
2321 if ((
unsigned) src_x >
FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
2322 (
unsigned) src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
2324 linesize >> field_based, 17, 17 + field_based,
2325 src_x, src_y << field_based, h_edge_pos,
2331 ptr_cb, uvlinesize >> field_based, 9,
2333 uvsrc_x, uvsrc_y << field_based,
2334 h_edge_pos >> 1, v_edge_pos >> 1);
2336 ptr_cr, uvlinesize >> field_based, 9,
2338 uvsrc_x, uvsrc_y << field_based,
2339 h_edge_pos >> 1, v_edge_pos >> 1);
2341 ptr_cr = uvbuf + 16;
2358 sx = (sx << 2) >>
lowres;
2359 sy = (sy << 2) >>
lowres;
2360 pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
2364 uvsx = (uvsx << 2) >>
lowres;
2365 uvsy = (uvsy << 2) >>
lowres;
2367 pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy);
2368 pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy);
2381 const int op_index =
FFMIN(lowres, 3);
2382 const int block_s = 8 >>
lowres;
2383 const int s_mask = (2 <<
lowres) - 1;
2384 const int h_edge_pos = s->
h_edge_pos >> lowres + 1;
2385 const int v_edge_pos = s->
v_edge_pos >> lowres + 1;
2386 int emu = 0, src_x, src_y, sx, sy;
2402 src_x = s->
mb_x * block_s + (mx >> lowres + 1);
2403 src_y = s->
mb_y * block_s + (my >> lowres + 1);
2406 ptr = ref_picture[1] +
offset;
2407 if ((
unsigned) src_x >
FFMAX(h_edge_pos - (!!sx) - block_s, 0) ||
2408 (unsigned) src_y >
FFMAX(v_edge_pos - (!!sy) - block_s, 0)) {
2410 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
2414 sx = (sx << 2) >>
lowres;
2415 sy = (sy << 2) >>
lowres;
2416 pix_op[op_index](dest_cb, ptr, s->
uvlinesize, block_s, sx, sy);
2418 ptr = ref_picture[2] +
offset;
2422 src_x, src_y, h_edge_pos, v_edge_pos);
2425 pix_op[op_index](dest_cr, ptr, s->
uvlinesize, block_s, sx, sy);
2448 const int block_s = 8 >>
lowres;
2457 ref_picture, pix_op,
2458 s->
mv[dir][0][0], s->
mv[dir][0][1],
2464 for (i = 0; i < 4; i++) {
2467 ref_picture[0], 0, 0,
2468 (2 * mb_x + (i & 1)) * block_s,
2469 (2 * mb_y + (i >> 1)) * block_s,
2472 block_s, block_s, pix_op,
2473 s->
mv[dir][i][0], s->
mv[dir][i][1]);
2475 mx += s->
mv[dir][i][0];
2476 my += s->
mv[dir][i][1];
2488 ref_picture, pix_op,
2489 s->
mv[dir][0][0], s->
mv[dir][0][1],
2494 ref_picture, pix_op,
2495 s->
mv[dir][1][0], s->
mv[dir][1][1],
2505 ref_picture, pix_op,
2507 s->
mv[dir][0][1], 2 * block_s, mb_y >> 1);
2511 for (i = 0; i < 2; i++) {
2523 ref2picture, pix_op,
2524 s->
mv[dir][i][0], s->
mv[dir][i][1] +
2525 2 * block_s * i, block_s, mb_y >> 1);
2527 dest_y += 2 * block_s * s->
linesize;
2534 for (i = 0; i < 2; i++) {
2536 for (j = 0; j < 2; j++) {
2539 ref_picture, pix_op,
2540 s->
mv[dir][2 * i + j][0],
2541 s->
mv[dir][2 * i + j][1],
2547 for (i = 0; i < 2; i++) {
2550 ref_picture, pix_op,
2551 s->
mv[dir][2 * i][0],s->
mv[dir][2 * i][1],
2552 2 * block_s, mb_y >> 1);
2575 int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->
quarter_sample;
2576 int my,
off, i, mvs;
2595 for (i = 0; i < mvs; i++) {
2596 my = s->
mv[dir][i][1]<<qpel_shift;
2597 my_max =
FFMAX(my_max, my);
2598 my_min =
FFMIN(my_min, my);
2601 off = (
FFMAX(-my_min, my_max) + 63) >> 6;
2610 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
2626 int16_t *
block,
int i,
uint8_t *dest,
int line_size,
int qscale)
2648 memset(s->
ac_val[0][xy ], 0, 32 *
sizeof(int16_t));
2649 memset(s->
ac_val[0][xy + wrap], 0, 32 *
sizeof(int16_t));
2662 memset(s->
ac_val[1][xy], 0, 16 *
sizeof(int16_t));
2663 memset(s->
ac_val[2][xy], 0, 16 *
sizeof(int16_t));
2680 int lowres_flag,
int is_mpeg12)
2693 for(j=0; j<64; j++){
2717 uint8_t *dest_y, *dest_cb, *dest_cr;
2718 int dct_linesize, dct_offset;
2724 const int block_size= lowres_flag ? 8>>s->
avctx->
lowres : 8;
2743 dct_offset = s->
interlaced_dct ? linesize : linesize * block_size;
2747 dest_cb= s->
dest[1];
2748 dest_cr= s->
dest[2];
2831 add_dct(s, block[0], 0, dest_y , dct_linesize);
2832 add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
2833 add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
2834 add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
2838 add_dct(s, block[4], 4, dest_cb, uvlinesize);
2839 add_dct(s, block[5], 5, dest_cr, uvlinesize);
2843 dct_offset = s->
interlaced_dct ? uvlinesize : uvlinesize*block_size;
2845 add_dct(s, block[4], 4, dest_cb, dct_linesize);
2846 add_dct(s, block[5], 5, dest_cr, dct_linesize);
2847 add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
2848 add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
2850 add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
2851 add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
2852 add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
2853 add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
2858 else if (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) {
2865 put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->
qscale);
2866 put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->
qscale);
2867 put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->
qscale);
2884 s->
dsp.
idct_put(dest_y + block_size, dct_linesize, block[1]);
2885 s->
dsp.
idct_put(dest_y + dct_offset , dct_linesize, block[2]);
2886 s->
dsp.
idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
2895 dct_offset = s->
interlaced_dct? uvlinesize : uvlinesize*block_size;
2899 s->
dsp.
idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
2900 s->
dsp.
idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
2902 s->
dsp.
idct_put(dest_cb + block_size, dct_linesize, block[8]);
2903 s->
dsp.
idct_put(dest_cr + block_size, dct_linesize, block[9]);
2904 s->
dsp.
idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
2905 s->
dsp.
idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
2935 Picture *last,
int y,
int h,
int picture_structure,
2937 int v_edge_pos,
int h_edge_pos)
2942 const int field_pic = picture_structure !=
PICT_FRAME;
2954 int sides = 0, edge_h;
2956 if (y + h >= v_edge_pos)
2959 edge_h=
FFMIN(h, v_edge_pos - y);
2962 linesize[0], h_edge_pos, edge_h,
2965 linesize[1], h_edge_pos >> hshift, edge_h >> vshift,
2968 linesize[2], h_edge_pos >> hshift, edge_h >> vshift,
2997 offset[2]= (y >> vshift) * src->
linesize[1];
3005 y, picture_structure, h);
3038 s->
dest[0] += s->
mb_y * linesize << mb_size;
3042 s->
dest[0] += (s->
mb_y>>1) * linesize << mb_size;
3066 for(i=0; i<=last; i++){
3067 const int j= scantable[i];
3072 for(i=0; i<=last; i++){
3073 const int j= scantable[i];
3074 const int perm_j= permutation[j];
3075 block[perm_j]= temp[j];
3083 if(s==NULL || s->
picture==NULL)
3108 int16_t *
block,
int n,
int qscale)
3110 int i,
level, nCoeffs;
3111 const uint16_t *quant_matrix;
3118 for(i=1;i<=nCoeffs;i++) {
3124 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3125 level = (level - 1) | 1;
3128 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3129 level = (level - 1) | 1;
3137 int16_t *
block,
int n,
int qscale)
3139 int i,
level, nCoeffs;
3140 const uint16_t *quant_matrix;
3145 for(i=0; i<=nCoeffs; i++) {
3151 level = (((level << 1) + 1) * qscale *
3152 ((int) (quant_matrix[j]))) >> 4;
3153 level = (level - 1) | 1;
3156 level = (((level << 1) + 1) * qscale *
3157 ((int) (quant_matrix[j]))) >> 4;
3158 level = (level - 1) | 1;
3166 int16_t *
block,
int n,
int qscale)
3168 int i,
level, nCoeffs;
3169 const uint16_t *quant_matrix;
3176 for(i=1;i<=nCoeffs;i++) {
3182 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3185 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3193 int16_t *
block,
int n,
int qscale)
3195 int i,
level, nCoeffs;
3196 const uint16_t *quant_matrix;
3205 for(i=1;i<=nCoeffs;i++) {
3211 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3214 level = (int)(level * qscale * quant_matrix[j]) >> 3;
3224 int16_t *
block,
int n,
int qscale)
3226 int i,
level, nCoeffs;
3227 const uint16_t *quant_matrix;
3234 for(i=0; i<=nCoeffs; i++) {
3240 level = (((level << 1) + 1) * qscale *
3241 ((int) (quant_matrix[j]))) >> 4;
3244 level = (((level << 1) + 1) * qscale *
3245 ((int) (quant_matrix[j]))) >> 4;
3255 int16_t *
block,
int n,
int qscale)
3257 int i,
level, qmul, qadd;
3266 qadd = (qscale - 1) | 1;
3275 for(i=1; i<=nCoeffs; i++) {
3279 level = level * qmul - qadd;
3281 level = level * qmul + qadd;
3289 int16_t *
block,
int n,
int qscale)
3291 int i,
level, qmul, qadd;
3296 qadd = (qscale - 1) | 1;
3301 for(i=0; i<=nCoeffs; i++) {
3305 level = level * qmul - qadd;
3307 level = level * qmul + qadd;
3321 else if (qscale > 31)
3337 #if CONFIG_ERROR_RESILIENCE