Mercurial > libavcodec.hg
comparison snow.c @ 2596:3e90a8cfddc6 libavcodec
10% faster unpack_coeffs
author | michael |
---|---|
date | Tue, 05 Apr 2005 17:59:05 +0000 |
parents | 6b385f3e07a3 |
children | 2bcea6618a87 |
comparison
equal
deleted
inserted
replaced
2595:6b385f3e07a3 | 2596:3e90a8cfddc6 |
---|---|
68 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, | 68 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
69 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, | 69 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
70 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, | 70 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
71 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, | 71 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
72 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, | 72 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
73 }; | |
74 static const int8_t quant3bA[256]={ | |
75 0, 0, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
76 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
77 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
78 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
79 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
80 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
81 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
82 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
83 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
84 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
85 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
86 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
87 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
88 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
89 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
90 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, | |
73 }; | 91 }; |
74 static const int8_t quant5[256]={ | 92 static const int8_t quant5[256]={ |
75 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 93 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
76 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, |
77 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, |
371 #define LOG2_MB_SIZE 4 | 389 #define LOG2_MB_SIZE 4 |
372 #define MB_SIZE (1<<LOG2_MB_SIZE) | 390 #define MB_SIZE (1<<LOG2_MB_SIZE) |
373 | 391 |
374 typedef struct x_and_coeff{ | 392 typedef struct x_and_coeff{ |
375 int16_t x; | 393 int16_t x; |
376 int16_t coeff; | 394 uint16_t coeff; |
377 } x_and_coeff; | 395 } x_and_coeff; |
378 | 396 |
379 typedef struct SubBand{ | 397 typedef struct SubBand{ |
380 int level; | 398 int level; |
381 int stride; | 399 int stride; |
1700 assert(!v); | 1718 assert(!v); |
1701 } | 1719 } |
1702 } | 1720 } |
1703 if(v){ | 1721 if(v){ |
1704 int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); | 1722 int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); |
1723 int l2= 2*ABS(l) + (l<0); | |
1724 int t2= 2*ABS(t) + (t<0); | |
1705 | 1725 |
1706 put_symbol2(&s->c, b->state[context + 2], ABS(v)-1, context-4); | 1726 put_symbol2(&s->c, b->state[context + 2], ABS(v)-1, context-4); |
1707 put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]], v<0); | 1727 put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l2&0xFF] + 3*quant3bA[t2&0xFF]], v<0); |
1708 } | 1728 } |
1709 } | 1729 } |
1710 } | 1730 } |
1711 } | 1731 } |
1712 return 0; | 1732 return 0; |
1761 if(x>>1 == parent->x_coeff[parent_index].x){ | 1781 if(x>>1 == parent->x_coeff[parent_index].x){ |
1762 p= parent->x_coeff[parent_index].coeff; | 1782 p= parent->x_coeff[parent_index].coeff; |
1763 } | 1783 } |
1764 } | 1784 } |
1765 if(/*ll|*/l|lt|t|rt|p){ | 1785 if(/*ll|*/l|lt|t|rt|p){ |
1766 int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); | 1786 int context= av_log2(/*ABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); |
1767 | 1787 |
1768 v=get_rac(&s->c, &b->state[0][context]); | 1788 v=get_rac(&s->c, &b->state[0][context]); |
1769 }else{ | 1789 }else{ |
1770 if(!run){ | 1790 if(!run){ |
1771 run= get_symbol2(&s->c, b->state[1], 3); | 1791 run= get_symbol2(&s->c, b->state[1], 3); |
1783 run-= max_run; | 1803 run-= max_run; |
1784 } | 1804 } |
1785 } | 1805 } |
1786 } | 1806 } |
1787 if(v){ | 1807 if(v){ |
1788 int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); | 1808 int context= av_log2(/*ABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); |
1789 v= get_symbol2(&s->c, b->state[context + 2], context-4) + 1; | 1809 v= 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1); |
1790 if(get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]])) | 1810 v+=get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l&0xFF] + 3*quant3bA[t&0xFF]]); |
1791 v *= -1; | 1811 |
1792 b->x_coeff[index].x=x; | 1812 b->x_coeff[index].x=x; |
1793 b->x_coeff[index++].coeff= v; | 1813 b->x_coeff[index++].coeff= v; |
1794 } | 1814 } |
1795 } | 1815 } |
1796 b->x_coeff[index++].x= w+1; //end marker | 1816 b->x_coeff[index++].x= w+1; //end marker |
1840 memset(line, 0, b->width*sizeof(DWTELEM)); | 1860 memset(line, 0, b->width*sizeof(DWTELEM)); |
1841 v = b->x_coeff[new_index].coeff; | 1861 v = b->x_coeff[new_index].coeff; |
1842 x = b->x_coeff[new_index++].x; | 1862 x = b->x_coeff[new_index++].x; |
1843 while(x < w) | 1863 while(x < w) |
1844 { | 1864 { |
1845 if (v < 0) | 1865 register int t= ( (v>>1)*qmul + qadd)>>QEXPSHIFT; |
1846 line[x] = -(( -v*qmul + qadd)>>(QEXPSHIFT)); | 1866 register int u= -(v&1); |
1847 else | 1867 line[x] = (t^u) - u; |
1848 line[x] = (( v*qmul + qadd)>>(QEXPSHIFT)); | 1868 |
1849 v = b->x_coeff[new_index].coeff; | 1869 v = b->x_coeff[new_index].coeff; |
1850 x = b->x_coeff[new_index++].x; | 1870 x = b->x_coeff[new_index++].x; |
1851 } | 1871 } |
1852 } | 1872 } |
1853 if(w > 200 && start_y != 0/*level+1 == s->spatial_decomposition_count*/){ | 1873 if(w > 200 && start_y != 0/*level+1 == s->spatial_decomposition_count*/){ |