comparison snow.c @ 2607:fde7b6fe2aaf libavcodec

replace complicated pointer dereference + index stuff by pointers in unpack_coeffs()
author michael
date Thu, 14 Apr 2005 20:54:03 +0000
parents 2649aeaadc44
children 4fb7fa34050b
comparison
equal deleted inserted replaced
2606:2649aeaadc44 2607:fde7b6fe2aaf
1775 const int h= b->height; 1775 const int h= b->height;
1776 int x,y; 1776 int x,y;
1777 1777
1778 if(1){ 1778 if(1){
1779 int run; 1779 int run;
1780 int index=0; 1780 x_and_coeff *xc= b->x_coeff;
1781 int prev_index=-1; 1781 x_and_coeff *prev_xc= NULL;
1782 int prev2_index=0; 1782 x_and_coeff *prev2_xc= xc;
1783 int parent_index= 0; 1783 x_and_coeff *parent_xc= parent ? parent->x_coeff : NULL;
1784 int prev_parent_index= 0; 1784 x_and_coeff *prev_parent_xc= parent_xc;
1785 1785
1786 run= get_symbol2(&s->c, b->state[1], 3); 1786 run= get_symbol2(&s->c, b->state[1], 3);
1787 for(y=0; y<h; y++){ 1787 for(y=0; y<h; y++){
1788 int v=0; 1788 int v=0;
1789 int lt=0, t=0, rt=0; 1789 int lt=0, t=0, rt=0;
1790 1790
1791 if(y && b->x_coeff[prev_index].x == 0){ 1791 if(y && prev_xc->x == 0){
1792 rt= b->x_coeff[prev_index].coeff; 1792 rt= prev_xc->coeff;
1793 } 1793 }
1794 for(x=0; x<w; x++){ 1794 for(x=0; x<w; x++){
1795 int p=0; 1795 int p=0;
1796 const int l= v; 1796 const int l= v;
1797 1797
1798 lt= t; t= rt; 1798 lt= t; t= rt;
1799 1799
1800 if(y){ 1800 if(y){
1801 if(b->x_coeff[prev_index].x <= x) 1801 if(prev_xc->x <= x)
1802 prev_index++; 1802 prev_xc++;
1803 if(b->x_coeff[prev_index].x == x + 1) 1803 if(prev_xc->x == x + 1)
1804 rt= b->x_coeff[prev_index].coeff; 1804 rt= prev_xc->coeff;
1805 else 1805 else
1806 rt=0; 1806 rt=0;
1807 } 1807 }
1808 if(parent){ 1808 if(parent_xc){
1809 if(x>>1 > parent->x_coeff[parent_index].x){ 1809 if(x>>1 > parent_xc->x){
1810 parent_index++; 1810 parent_xc++;
1811 } 1811 }
1812 if(x>>1 == parent->x_coeff[parent_index].x){ 1812 if(x>>1 == parent_xc->x){
1813 p= parent->x_coeff[parent_index].coeff; 1813 p= parent_xc->coeff;
1814 } 1814 }
1815 } 1815 }
1816 if(/*ll|*/l|lt|t|rt|p){ 1816 if(/*ll|*/l|lt|t|rt|p){
1817 int context= av_log2(/*ABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); 1817 int context= av_log2(/*ABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1));
1818 1818
1819 v=get_rac(&s->c, &b->state[0][context]); 1819 v=get_rac(&s->c, &b->state[0][context]);
1820 if(v){ 1820 if(v){
1821 v= 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1); 1821 v= 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1);
1822 v+=get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l&0xFF] + 3*quant3bA[t&0xFF]]); 1822 v+=get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l&0xFF] + 3*quant3bA[t&0xFF]]);
1823 1823
1824 b->x_coeff[index].x=x; 1824 xc->x=x;
1825 b->x_coeff[index++].coeff= v; 1825 (xc++)->coeff= v;
1826 } 1826 }
1827 }else{ 1827 }else{
1828 if(!run){ 1828 if(!run){
1829 run= get_symbol2(&s->c, b->state[1], 3); 1829 run= get_symbol2(&s->c, b->state[1], 3);
1830 v= 2*(get_symbol2(&s->c, b->state[0 + 2], 0-4) + 1); 1830 v= 2*(get_symbol2(&s->c, b->state[0 + 2], 0-4) + 1);
1831 v+=get_rac(&s->c, &b->state[0][16 + 1 + 3]); 1831 v+=get_rac(&s->c, &b->state[0][16 + 1 + 3]);
1832 1832
1833 b->x_coeff[index].x=x; 1833 xc->x=x;
1834 b->x_coeff[index++].coeff= v; 1834 (xc++)->coeff= v;
1835 }else{ 1835 }else{
1836 int max_run; 1836 int max_run;
1837 run--; 1837 run--;
1838 v=0; 1838 v=0;
1839 1839
1840 if(y) max_run= FFMIN(run, b->x_coeff[prev_index].x - x - 2); 1840 if(y) max_run= FFMIN(run, prev_xc->x - x - 2);
1841 else max_run= FFMIN(run, w-x-1); 1841 else max_run= FFMIN(run, w-x-1);
1842 if(parent) 1842 if(parent_xc)
1843 max_run= FFMIN(max_run, 2*parent->x_coeff[parent_index].x - x - 1); 1843 max_run= FFMIN(max_run, 2*parent_xc->x - x - 1);
1844 x+= max_run; 1844 x+= max_run;
1845 run-= max_run; 1845 run-= max_run;
1846 } 1846 }
1847 } 1847 }
1848 } 1848 }
1849 b->x_coeff[index++].x= w+1; //end marker 1849 (xc++)->x= w+1; //end marker
1850 prev_index= prev2_index; 1850 prev_xc= prev2_xc;
1851 prev2_index= index; 1851 prev2_xc= xc;
1852 1852
1853 if(parent){ 1853 if(parent_xc){
1854 if(y&1){ 1854 if(y&1){
1855 while(parent->x_coeff[parent_index].x != parent->width+1) 1855 while(parent_xc->x != parent->width+1)
1856 parent_index++; 1856 parent_xc++;
1857 parent_index++; 1857 parent_xc++;
1858 prev_parent_index= parent_index; 1858 prev_parent_xc= parent_xc;
1859 }else{ 1859 }else{
1860 parent_index= prev_parent_index; 1860 parent_xc= prev_parent_xc;
1861 } 1861 }
1862 } 1862 }
1863 } 1863 }
1864 1864
1865 b->x_coeff[index++].x= w+1; //end marker 1865 (xc++)->x= w+1; //end marker
1866 } 1866 }
1867 } 1867 }
1868 1868
1869 static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, slice_buffer * sb, int start_y, int h, int save_state[1]){ 1869 static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, slice_buffer * sb, int start_y, int h, int save_state[1]){
1870 const int w= b->width; 1870 const int w= b->width;