comparison postproc/postprocess_template.c @ 2185:c5162871cf2b

small changes for mplayer integration: - getModeForQuality -> getPpModeForQuality renamed - #define POSTPROCESS_H -> NEWPOSTPROCESS_H (to avoid conflicts) - added #ifdef'ed code for calling old postprocess (for testing/comparison) - #ifdef'ed some asm code to allow compilation on non-x86 platforms (untested)
author arpi
date Sat, 13 Oct 2001 15:36:04 +0000
parents d90f8fc7ead6
children 82556b3a1228
comparison
equal deleted inserted replaced
2184:966ec115c87f 2185:c5162871cf2b
135 135
136 int maxAllowedY=255; 136 int maxAllowedY=255;
137 //FIXME can never make a movieŽs black brighter (anyone needs that?) 137 //FIXME can never make a movieŽs black brighter (anyone needs that?)
138 int minAllowedY=0; 138 int minAllowedY=0;
139 139
140 140 #ifdef TIMEING
141 static inline long long rdtsc() 141 static inline long long rdtsc()
142 { 142 {
143 long long l; 143 long long l;
144 asm volatile( "rdtsc\n\t" 144 asm volatile( "rdtsc\n\t"
145 : "=A" (l) 145 : "=A" (l)
146 ); 146 );
147 // printf("%d\n", int(l/1000)); 147 // printf("%d\n", int(l/1000));
148 return l; 148 return l;
149 } 149 }
150 150 #endif
151
152 #ifdef HAVE_MMX2
151 static inline void prefetchnta(void *p) 153 static inline void prefetchnta(void *p)
152 { 154 {
153 asm volatile( "prefetchnta (%0)\n\t" 155 asm volatile( "prefetchnta (%0)\n\t"
154 : : "r" (p) 156 : : "r" (p)
155 ); 157 );
173 { 175 {
174 asm volatile( "prefetcht2 (%0)\n\t" 176 asm volatile( "prefetcht2 (%0)\n\t"
175 : : "r" (p) 177 : : "r" (p)
176 ); 178 );
177 } 179 }
180 #endif
178 181
179 //FIXME? |255-0| = 1 (shouldnt be a problem ...) 182 //FIXME? |255-0| = 1 (shouldnt be a problem ...)
180 /** 183 /**
181 * Check if the middle 8x8 Block in the given 8x10 block is flat 184 * Check if the middle 8x8 Block in the given 8x10 block is flat
182 */ 185 */
1812 1815
1813 //FIXME 1816 //FIXME
1814 #endif 1817 #endif
1815 } 1818 }
1816 1819
1817 1820 #ifdef HAVE_ODIVX_POSTPROCESS
1818 1821 #include "../opendivx/postprocess.h"
1822 int use_old_pp=0;
1823 #endif
1824
1825 static void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
1826 QP_STORE_T QPs[], int QPStride, int isColor, int mode);
1819 1827
1820 /** 1828 /**
1821 * ... 1829 * ...
1822 * the mode value is interpreted as a quality value if its negative, its range is then (-1 ... -63) 1830 * the mode value is interpreted as a quality value if its negative, its range is then (-1 ... -63)
1823 * -63 is best quality -1 is worst 1831 * -63 is best quality -1 is worst
1828 int horizontal_size, int vertical_size, 1836 int horizontal_size, int vertical_size,
1829 QP_STORE_T *QP_store, int QP_stride, 1837 QP_STORE_T *QP_store, int QP_stride,
1830 int mode) 1838 int mode)
1831 { 1839 {
1832 1840
1833 if(mode<0) mode= getModeForQuality(-mode); 1841 #ifdef HAVE_ODIVX_POSTPROCESS
1842 // Note: I could make this shit outside of this file, but it would mean one
1843 // more function call...
1844 if(use_old_pp){
1845 odivx_postprocess(src,src_stride,dst,dst_stride,horizontal_size,vertical_size,QP_store,QP_stride,mode);
1846 return;
1847 }
1848 #endif
1849
1850 // I'm calling this from dec_video.c:video_set_postprocess()
1851 // if(mode<0) mode= getModeForQuality(-mode);
1834 1852
1835 /* 1853 /*
1836 long long T= rdtsc(); 1854 long long T= rdtsc();
1837 for(int y=vertical_size-1; y>=0 ; y--) 1855 for(int y=vertical_size-1; y>=0 ; y--)
1838 memcpy(dst[0] + y*src_stride, src[0] + y*src_stride,src_stride); 1856 memcpy(dst[0] + y*src_stride, src[0] + y*src_stride,src_stride);
1867 { 1885 {
1868 memcpy(dst[1], src[1], src_stride*horizontal_size); 1886 memcpy(dst[1], src[1], src_stride*horizontal_size);
1869 memcpy(dst[2], src[2], src_stride*horizontal_size); 1887 memcpy(dst[2], src[2], src_stride*horizontal_size);
1870 } 1888 }
1871 } 1889 }
1890
1872 /** 1891 /**
1873 * gets the mode flags for a given quality (larger values mean slower but better postprocessing) 1892 * gets the mode flags for a given quality (larger values mean slower but better postprocessing)
1874 * 0 <= quality < 64 1893 * 0 <= quality <= 6
1875 */ 1894 */
1876 int getModeForQuality(int quality){ 1895 int getPpModeForQuality(int quality){
1877 int modes[6]= { 1896 int modes[1+GET_PP_QUALITY_MAX]= {
1897 0,
1898 #if 1
1899 // horizontal filters first
1900 LUM_H_DEBLOCK,
1901 LUM_H_DEBLOCK | LUM_V_DEBLOCK,
1902 LUM_H_DEBLOCK | LUM_V_DEBLOCK | CHROM_H_DEBLOCK,
1903 LUM_H_DEBLOCK | LUM_V_DEBLOCK | CHROM_H_DEBLOCK | CHROM_V_DEBLOCK,
1904 LUM_H_DEBLOCK | LUM_V_DEBLOCK | CHROM_H_DEBLOCK | CHROM_V_DEBLOCK | LUM_DERING,
1905 LUM_H_DEBLOCK | LUM_V_DEBLOCK | CHROM_H_DEBLOCK | CHROM_V_DEBLOCK | LUM_DERING | CHROM_DERING
1906 #else
1907 // vertical filters first
1878 LUM_V_DEBLOCK, 1908 LUM_V_DEBLOCK,
1879 LUM_V_DEBLOCK | LUM_H_DEBLOCK, 1909 LUM_V_DEBLOCK | LUM_H_DEBLOCK,
1880 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK, 1910 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK,
1881 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK, 1911 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK,
1882 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING, 1912 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING,
1883 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING | CHROM_DERING 1913 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING | CHROM_DERING
1884 }; 1914 #endif
1885 1915 };
1886 return modes[ (quality*6) >>6 ]; 1916
1917 #ifdef HAVE_ODIVX_POSTPROCESS
1918 int odivx_modes[1+GET_PP_QUALITY_MAX]= {
1919 0,
1920 PP_DEBLOCK_Y_H,
1921 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V,
1922 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H,
1923 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V,
1924 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V|PP_DERING_Y,
1925 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V|PP_DERING_Y|PP_DERING_C
1926 };
1927 if(use_old_pp) return odivx_modes[quality];
1928 #endif
1929 return modes[quality];
1887 } 1930 }
1888 1931
1889 //} // extern "C" 1932 //} // extern "C"
1890 1933
1891 /** 1934 /**
2008 2051
2009 2052
2010 /** 2053 /**
2011 * Filters array of bytes (Y or U or V values) 2054 * Filters array of bytes (Y or U or V values)
2012 */ 2055 */
2013 void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, 2056 static void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
2014 QP_STORE_T QPs[], int QPStride, int isColor, int mode) 2057 QP_STORE_T QPs[], int QPStride, int isColor, int mode)
2015 { 2058 {
2016 int x,y; 2059 int x,y;
2017 /* we need 64bit here otherwise weŽll going to have a problem 2060 /* we need 64bit here otherwise weŽll going to have a problem
2018 after watching a black picture for 5 hours*/ 2061 after watching a black picture for 5 hours*/