76 0, 1818, 3622, 4144, 4698, 5234, 5804, 5868, 5900, 5932,
77 5996, 6252, 6316, 6348, 6380, 7674, 8944, 10274, 11668, 12250,
78 14060, 15846, 16372, 16962, 17512, 18148, 18180, 18212, 18244, 18308,
79 18564, 18628, 18660, 18692, 20036, 21314, 22648, 23968, 24614, 26384,
80 28190, 28736, 29366, 29938, 30608, 30640, 30672, 30704, 30768, 31024,
81 31088, 31120, 31184, 32570, 33898, 35236, 36644, 37286, 39020, 40802,
82 41368, 42052, 42692, 43348, 43380, 43412, 43444, 43476, 43604, 43668,
83 43700, 43732, 45100, 46430, 47778, 49160, 49802, 51550, 53340, 53972,
84 54648, 55348, 55994, 56122, 56154, 56186, 56218, 56346, 56410, 56442,
85 56474, 57878, 59290, 60636, 62036, 62682, 64460, 64524, 64588, 64716,
86 64844, 66076, 67466, 67978, 68542, 69064, 69648, 70296, 72010, 72074,
87 72138, 72202, 72330, 73572, 74936, 75454, 76030, 76566, 77176, 77822,
88 79582, 79646, 79678, 79742, 79870, 81180, 82536, 83064, 83672, 84242,
89 84934, 85576, 87384, 87448, 87480, 87544, 87672, 88982, 90340, 90902,
90 91598, 92182, 92846, 93488, 95246, 95278, 95310, 95374, 95502, 96878,
91 98266, 98848, 99542, 100234, 100884, 101524, 103320, 103352, 103384, 103416,
92 103480, 104874, 106222, 106910, 107584, 108258, 108902, 109544, 111366, 111398,
93 111430, 111462, 111494, 112878, 114320, 114988, 115660, 116310, 116950, 117592
110 int counts[17] = {0}, codes[17];
113 int maxbits = 0, realsize = 0;
115 for(i = 0; i <
size; i++){
117 bits2[realsize] = bits[i];
118 syms[realsize] = insyms ? insyms[i] : i;
120 maxbits =
FFMAX(maxbits, bits[i]);
126 for(i = 0; i < 16; i++)
127 codes[i+1] = (codes[i] + counts[i]) << 1;
128 for(i = 0; i < realsize; i++)
129 cw[i] = codes[bits2[i]]++;
147 for(j = 0; j < 2; j++){
151 for(k = 0; k < 4; k++){
155 for(j = 0; j < 4; j++){
163 for(j = 0; j < 4; j++){
166 for(j = 0; j < 2; j++){
187 int pattern, code, cbp=0;
189 static const int cbp_masks[3] = {0x100000, 0x010000, 0x110000};
190 static const int shifts[4] = { 0, 2, 8, 10 };
191 const int *curshift = shifts;
195 pattern = code & 0xF;
200 for(mask = 8;
mask; mask >>= 1, curshift++){
205 for(i = 0; i < 4; i++){
210 cbp |= cbp_masks[2] << i;
225 coef = 22 + ((1 << coef) |
get_bits(gb, coef));
231 *dst = (coef*q + 8) >> 4;
244 decode_coeff(dst+1*4+0, (flags >> 4) & 3, 2, gb, vlc, q);
245 decode_coeff(dst+0*4+1, (flags >> 2) & 3, 2, gb, vlc, q);
247 decode_coeff(dst+0*4+1, (flags >> 4) & 3, 2, gb, vlc, q);
248 decode_coeff(dst+1*4+0, (flags >> 2) & 3, 2, gb, vlc, q);
250 decode_coeff( dst+1*4+1, (flags >> 0) & 3, 2, gb, vlc, q);
263 int q_dc,
int q_ac1,
int q_ac2)
267 decode_coeff(dst+0*4+0, (flags >> 6) , 3, gb, vlc, q_dc);
268 decode_coeff(dst+0*4+1, (flags >> 4) & 3, 2, gb, vlc, q_ac1);
269 decode_coeff(dst+1*4+0, (flags >> 2) & 3, 2, gb, vlc, q_ac1);
270 decode_coeff(dst+1*4+1, (flags >> 0) & 3, 2, gb, vlc, q_ac2);
286 int code, pattern, has_ac = 1;
290 pattern = code & 0x7;
315 return has_ac | pattern;
330 for(i = 0; i < 5; i++)
341 if(mod == 2 && quant < 19) quant += 10;
342 else if(mod && quant < 26) quant += 5;
425 for(i = 0; i < 16; i++)
447 static const uint8_t part_sizes_w[
RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2 };
450 static const uint8_t part_sizes_h[
RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2 };
466 int A[2] = {0},
B[2],
C[2];
472 mv_pos += (subblock_no & 1) + (subblock_no >> 1)*s->
b8_stride;
488 if(avail[-4] && (avail[-1] || r->
rv30)){
501 mx += r->
dmv[dmv_no][0];
502 my += r->
dmv[dmv_no][1];
511 #define GET_PTS_DIFF(a, b) ((a - b + 8192) & 0x1FFF)
520 return (val * mul + 0x2000) >> 14;
527 int A_avail,
int B_avail,
int C_avail,
530 if(A_avail + B_avail + C_avail != 3){
531 *mx = A[0] + B[0] + C[0];
532 *my = A[1] + B[1] + C[1];
533 if(A_avail + B_avail + C_avail == 2){
551 int A[2] = { 0 },
B[2] = { 0 },
C[2] = { 0 };
552 int has_A = 0, has_B = 0, has_C = 0;
560 A[0] = cur_pic->
motion_val[dir][mv_pos - 1][0];
561 A[1] = cur_pic->
motion_val[dir][mv_pos - 1][1];
581 mx += r->
dmv[dir][0];
582 my += r->
dmv[dir][1];
584 for(j = 0; j < 2; j++){
585 for(i = 0; i < 2; i++){
602 int A[2] = {0},
B[2],
C[2];
619 if(avail[-4] && (avail[-1])){
634 for(j = 0; j < 2; j++){
635 for(i = 0; i < 2; i++){
636 for(k = 0; k < 2; k++){
662 const int xoff,
const int yoff,
int mv_off,
664 const int thirdpel,
int weighted,
670 int dxy, mx, my, umx, umy, lx, ly, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
675 int chroma_mx, chroma_my;
682 umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24);
683 umy = (chroma_my + (3 << 24)) / 3 - (1 << 24);
696 uvmx = (cx & 3) << 1;
697 uvmy = (cy & 3) << 1;
699 if(uvmx == 6 && uvmy == 6)
705 int mb_row = s->
mb_y + ((yoff + my + 5 + 8 *
height) >> 4);
714 src_x = s->
mb_x * 16 + xoff + mx;
715 src_y = s->
mb_y * 16 + yoff + my;
716 uvsrc_x = s->
mb_x * 8 + (xoff >> 1) + umx;
717 uvsrc_y = s->
mb_y * 8 + (yoff >> 1) + umy;
718 srcY += src_y * s->
linesize + src_x;
722 (
unsigned)(src_x - !!lx*2) > s->
h_edge_pos - !!lx*2 - (width <<3) - 4 ||
723 (unsigned)(src_y - !!ly*2) > s->
v_edge_pos - !!ly*2 - (height<<3) - 4) {
728 (width<<3)+6, (height<<3)+6, src_x - 2, src_y - 2,
732 (width<<2)+1, (height<<2)+1, uvsrc_x, uvsrc_y,
735 (width<<2)+1, (height<<2)+1, uvsrc_x, uvsrc_y,
760 qpel_mc[!is16x16][dxy](
Y, srcY, s->
linesize);
766 const int xoff,
const int yoff,
int mv_off,
767 const int width,
const int height,
int dir)
769 rv34_mc(r, block_type, xoff, yoff, mv_off, width, height, dir, r->
rv30, 0,
800 rv34_mc(r, block_type, 0, 0, 0, 2, 2, 0, r->
rv30, weighted,
804 rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->
rv30, 0,
808 rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->
rv30, 1,
820 for(j = 0; j < 2; j++)
821 for(i = 0; i < 2; i++){
836 static const int num_mvs[
RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 };
850 memset(r->
dmv, 0,
sizeof(r->
dmv));
851 for(i = 0; i < num_mvs[block_type]; i++){
877 for(j = 0; j < 2; j++)
878 for(i = 0; i < 2; i++)
879 for(k = 0; k < 2; k++)
880 for(l = 0; l < 2; l++)
895 r->
dmv[1][0] = r->
dmv[0][0];
896 r->
dmv[1][1] = r->
dmv[0][1];
953 uint8_t *prev = dst - stride + 4;
972 topleft = dst[-stride + 3] * 0x01010101
u;
996 int fc,
int sc,
int q_dc,
int q_ac)
999 int16_t *ptr = s->
block[0];
1001 fc, sc, q_dc, q_ac, q_ac);
1018 int16_t *ptr = s->
block[0];
1019 int i, j, itype, has_ac;
1021 memset(block16, 0, 16 *
sizeof(*block16));
1029 itype = ittrans16[intra_types[0]];
1033 for(j = 0; j < 4; j++){
1034 for(i = 0; i < 4; i++, cbp >>= 1){
1035 int dc = block16[i + j*4];
1052 itype = ittrans16[intra_types[0]];
1059 for(j = 1; j < 3; j++){
1062 for(i = 0; i < 4; i++, cbp >>= 1){
1064 if(!(cbp & 1))
continue;
1065 pdst = dst + (i&1)*4 + (i&2)*2*s->
uvlinesize;
1077 int avail[6*8] = {0};
1079 int idx, q_ac, q_dc;
1085 avail[1] = avail[2] = 1;
1087 avail[3] = avail[4] = 1;
1091 avail[8] = avail[16] = 1;
1093 avail[24] = avail[32] = 1;
1096 for(j = 0; j < 4; j++){
1098 for(i = 0; i < 4; i++, cbp >>= 1, dst += 4, idx++){
1101 if(!(cbp & 1))
continue;
1115 for(k = 0; k < 2; k++){
1119 for(j = 0; j < 2; j++){
1121 for(i = 0; i < 2; i++, cbp >>= 1, acache++){
1126 if(!(cbp&1))
continue;
1140 d = motion_val[0][0] - motion_val[-step][0];
1143 d = motion_val[0][1] - motion_val[-step][1];
1152 int hmvmask = 0, vmvmask = 0, i, j;
1155 for(j = 0; j < 16; j += 8){
1156 for(i = 0; i < 2; i++){
1158 vmvmask |= 0x11 << (j + i*2);
1160 hmvmask |= 0x03 << (j + i*2);
1169 vmvmask |= (vmvmask & 0x4444) >> 1;
1170 hmvmask |= (hmvmask & 0x0F00) >> 4;
1176 return hmvmask | vmvmask;
1184 int16_t *ptr = s->
block[0];
1187 int q_dc, q_ac, has_ac;
1225 memset(block16, 0, 16 *
sizeof(*block16));
1235 for(j = 0; j < 4; j++){
1236 for(i = 0; i < 4; i++, cbp >>= 1){
1237 int dc = block16[i + j*4];
1258 for(j = 0; j < 4; j++){
1259 for(i = 0; i < 4; i++, cbp >>= 1){
1260 if(!(cbp & 1))
continue;
1272 for(j = 1; j < 3; j++){
1274 for(i = 0; i < 4; i++, cbp >>= 1){
1276 if(!(cbp & 1))
continue;
1277 pdst = dst + (i&1)*4 + (i&2)*2*s->
uvlinesize;
1337 if(bits <= 0 || (bits < 8 && !
show_bits(&s->
gb, bits)))
1393 int mb_pos, slice_type;
1497 #if CONFIG_RV30_DECODER
1501 #if CONFIG_RV40_DECODER
1511 if(!intra_vlcs[0].cbppattern[0].
bits)
1545 if (dst == src || !
s1->context_initialized)
1564 memset(&r->
si, 0,
sizeof(r->
si));
1579 int got_picture = 0,
ret;
1616 void *
data,
int *got_picture_ptr,
1620 int buf_size = avpkt->
size;
1627 const uint8_t *slices_hdr = NULL;
1631 if (buf_size == 0) {
1638 *got_picture_ptr = 1;
1644 slice_count = (*buf++) + 1;
1645 slices_hdr = buf + 4;
1646 buf += 8 * slice_count;
1647 buf_size -= 1 + 8 * slice_count;
1665 "reference data.\n");
1674 if (si.
start == 0) {
1710 for (i = 0; i < 2; i++)
1713 for (i = 0; i < 4; i++)
1746 }
else if (HAVE_THREADS &&
1749 "multithreading mode (start MB is %d).\n", si.
start);
1753 for(i = 0; i < slice_count; i++){
1756 if(i+1 == slice_count)
1757 size = buf_size -
offset;
1761 if(offset < 0 || offset > buf_size){
1769 if(i+1 < slice_count){
1777 if(i+2 < slice_count)
1780 size = buf_size -
offset;
1784 if (size < 0 || size > buf_size - offset) {
1801 *got_picture_ptr =
ret;
1802 }
else if (HAVE_THREADS &&