comparison snow.c @ 2241:c26038875ebc libavcodec

consistent use of types patch by (D Richard Felker III <dalias at aerifal dot cx>)
author michael
date Sun, 19 Sep 2004 14:43:09 +0000
parents c46fed9b7575
children 3414ac0b8c55
comparison
equal deleted inserted replaced
2240:c46fed9b7575 2241:c26038875ebc
616 dst[w*dst_step] = LIFT(src[w*src_step], ((r+add)>>shift), inverse); 616 dst[w*dst_step] = LIFT(src[w*src_step], ((r+add)>>shift), inverse);
617 } 617 }
618 } 618 }
619 619
620 620
621 static void inplace_lift(int *dst, int width, int *coeffs, int n, int shift, int start, int inverse){ 621 static void inplace_lift(DWTELEM *dst, int width, int *coeffs, int n, int shift, int start, int inverse){
622 int x, i; 622 int x, i;
623 623
624 for(x=start; x<width; x+=2){ 624 for(x=start; x<width; x+=2){
625 int64_t sum=0; 625 int64_t sum=0;
626 626
633 if(inverse) dst[x] -= (sum + (1<<shift)/2)>>shift; 633 if(inverse) dst[x] -= (sum + (1<<shift)/2)>>shift;
634 else dst[x] += (sum + (1<<shift)/2)>>shift; 634 else dst[x] += (sum + (1<<shift)/2)>>shift;
635 } 635 }
636 } 636 }
637 637
638 static void inplace_liftV(int *dst, int width, int height, int stride, int *coeffs, int n, int shift, int start, int inverse){ 638 static void inplace_liftV(DWTELEM *dst, int width, int height, int stride, int *coeffs, int n, int shift, int start, int inverse){
639 int x, y, i; 639 int x, y, i;
640 for(y=start; y<height; y+=2){ 640 for(y=start; y<height; y+=2){
641 for(x=0; x<width; x++){ 641 for(x=0; x<width; x++){
642 int64_t sum=0; 642 int64_t sum=0;
643 643
765 #define COEFFS3 NULL 765 #define COEFFS3 NULL
766 #define N4 0 766 #define N4 0
767 #define SHIFT4 1 767 #define SHIFT4 1
768 #define COEFFS4 NULL 768 #define COEFFS4 NULL
769 #endif 769 #endif
770 static void horizontal_decomposeX(int *b, int width){ 770 static void horizontal_decomposeX(DWTELEM *b, int width){
771 int temp[width]; 771 DWTELEM temp[width];
772 const int width2= width>>1; 772 const int width2= width>>1;
773 const int w2= (width+1)>>1; 773 const int w2= (width+1)>>1;
774 int A1,A2,A3,A4, x; 774 int A1,A2,A3,A4, x;
775 775
776 inplace_lift(b, width, COEFFS1, N1, SHIFT1, LX1, 0); 776 inplace_lift(b, width, COEFFS1, N1, SHIFT1, LX1, 0);
785 if(width&1) 785 if(width&1)
786 temp[x ]= b[2*x ]; 786 temp[x ]= b[2*x ];
787 memcpy(b, temp, width*sizeof(int)); 787 memcpy(b, temp, width*sizeof(int));
788 } 788 }
789 789
790 static void horizontal_composeX(int *b, int width){ 790 static void horizontal_composeX(DWTELEM *b, int width){
791 int temp[width]; 791 DWTELEM temp[width];
792 const int width2= width>>1; 792 const int width2= width>>1;
793 int A1,A2,A3,A4, x; 793 int A1,A2,A3,A4, x;
794 const int w2= (width+1)>>1; 794 const int w2= (width+1)>>1;
795 795
796 memcpy(temp, b, width*sizeof(int)); 796 memcpy(temp, b, width*sizeof(int));
805 inplace_lift(b, width, COEFFS3, N3, SHIFT3, LX1, 1); 805 inplace_lift(b, width, COEFFS3, N3, SHIFT3, LX1, 1);
806 inplace_lift(b, width, COEFFS2, N2, SHIFT2, LX0, 1); 806 inplace_lift(b, width, COEFFS2, N2, SHIFT2, LX0, 1);
807 inplace_lift(b, width, COEFFS1, N1, SHIFT1, LX1, 1); 807 inplace_lift(b, width, COEFFS1, N1, SHIFT1, LX1, 1);
808 } 808 }
809 809
810 static void spatial_decomposeX(int *buffer, int width, int height, int stride){ 810 static void spatial_decomposeX(DWTELEM *buffer, int width, int height, int stride){
811 int x, y; 811 int x, y;
812 812
813 for(y=0; y<height; y++){ 813 for(y=0; y<height; y++){
814 for(x=0; x<width; x++){ 814 for(x=0; x<width; x++){
815 buffer[y*stride + x] *= SCALEX; 815 buffer[y*stride + x] *= SCALEX;
824 inplace_liftV(buffer, width, height, stride, COEFFS2, N2, SHIFT2, LX0, 0); 824 inplace_liftV(buffer, width, height, stride, COEFFS2, N2, SHIFT2, LX0, 0);
825 inplace_liftV(buffer, width, height, stride, COEFFS3, N3, SHIFT3, LX1, 0); 825 inplace_liftV(buffer, width, height, stride, COEFFS3, N3, SHIFT3, LX1, 0);
826 inplace_liftV(buffer, width, height, stride, COEFFS4, N4, SHIFT4, LX0, 0); 826 inplace_liftV(buffer, width, height, stride, COEFFS4, N4, SHIFT4, LX0, 0);
827 } 827 }
828 828
829 static void spatial_composeX(int *buffer, int width, int height, int stride){ 829 static void spatial_composeX(DWTELEM *buffer, int width, int height, int stride){
830 int x, y; 830 int x, y;
831 831
832 inplace_liftV(buffer, width, height, stride, COEFFS4, N4, SHIFT4, LX0, 1); 832 inplace_liftV(buffer, width, height, stride, COEFFS4, N4, SHIFT4, LX0, 1);
833 inplace_liftV(buffer, width, height, stride, COEFFS3, N3, SHIFT3, LX1, 1); 833 inplace_liftV(buffer, width, height, stride, COEFFS3, N3, SHIFT3, LX1, 1);
834 inplace_liftV(buffer, width, height, stride, COEFFS2, N2, SHIFT2, LX0, 1); 834 inplace_liftV(buffer, width, height, stride, COEFFS2, N2, SHIFT2, LX0, 1);
843 buffer[y*stride + x] /= SCALEX; 843 buffer[y*stride + x] /= SCALEX;
844 } 844 }
845 } 845 }
846 } 846 }
847 847
848 static void horizontal_decompose53i(int *b, int width){ 848 static void horizontal_decompose53i(DWTELEM *b, int width){
849 int temp[width]; 849 DWTELEM temp[width];
850 const int width2= width>>1; 850 const int width2= width>>1;
851 int A1,A2,A3,A4, x; 851 int A1,A2,A3,A4, x;
852 const int w2= (width+1)>>1; 852 const int w2= (width+1)>>1;
853 853
854 for(x=0; x<width2; x++){ 854 for(x=0; x<width2; x++){
889 lift(b+w2, temp+w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 0); 889 lift(b+w2, temp+w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 0);
890 lift(b , temp , b+w2, 1, 1, 1, width, 1, 2, 2, 0, 0); 890 lift(b , temp , b+w2, 1, 1, 1, width, 1, 2, 2, 0, 0);
891 #endif 891 #endif
892 } 892 }
893 893
894 static void vertical_decompose53iH0(int *b0, int *b1, int *b2, int width){ 894 static void vertical_decompose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
895 int i; 895 int i;
896 896
897 for(i=0; i<width; i++){ 897 for(i=0; i<width; i++){
898 b1[i] -= (b0[i] + b2[i])>>1; 898 b1[i] -= (b0[i] + b2[i])>>1;
899 } 899 }
900 } 900 }
901 901
902 static void vertical_decompose53iL0(int *b0, int *b1, int *b2, int width){ 902 static void vertical_decompose53iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
903 int i; 903 int i;
904 904
905 for(i=0; i<width; i++){ 905 for(i=0; i<width; i++){
906 b1[i] += (b0[i] + b2[i] + 2)>>2; 906 b1[i] += (b0[i] + b2[i] + 2)>>2;
907 } 907 }
908 } 908 }
909 909
910 static void spatial_decompose53i(int *buffer, int width, int height, int stride){ 910 static void spatial_decompose53i(DWTELEM *buffer, int width, int height, int stride){
911 int y; 911 int y;
912 DWTELEM *b0= buffer + mirror(-2-1, height-1)*stride; 912 DWTELEM *b0= buffer + mirror(-2-1, height-1)*stride;
913 DWTELEM *b1= buffer + mirror(-2 , height-1)*stride; 913 DWTELEM *b1= buffer + mirror(-2 , height-1)*stride;
914 914
915 for(y=-2; y<height; y+=2){ 915 for(y=-2; y<height; y+=2){
998 998
999 #define W_DM 227 999 #define W_DM 227
1000 #define W_DO 128 1000 #define W_DO 128
1001 #define W_DS 9 1001 #define W_DS 9
1002 #endif 1002 #endif
1003 static void horizontal_decompose97i(int *b, int width){ 1003 static void horizontal_decompose97i(DWTELEM *b, int width){
1004 int temp[width]; 1004 DWTELEM temp[width];
1005 const int w2= (width+1)>>1; 1005 const int w2= (width+1)>>1;
1006 1006
1007 lift (temp+w2, b +1, b , 1, 2, 2, width, -W_AM, W_AO, W_AS, 1, 0); 1007 lift (temp+w2, b +1, b , 1, 2, 2, width, -W_AM, W_AO, W_AS, 1, 0);
1008 lift (temp , b , temp+w2, 1, 2, 1, width, -W_BM, W_BO, W_BS, 0, 0); 1008 lift (temp , b , temp+w2, 1, 2, 1, width, -W_BM, W_BO, W_BS, 0, 0);
1009 lift5(b +w2, temp+w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 0); 1009 lift5(b +w2, temp+w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 0);
1010 lift (b , temp , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 0); 1010 lift (b , temp , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 0);
1011 } 1011 }
1012 1012
1013 1013
1014 static void vertical_decompose97iH0(int *b0, int *b1, int *b2, int width){ 1014 static void vertical_decompose97iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1015 int i; 1015 int i;
1016 1016
1017 for(i=0; i<width; i++){ 1017 for(i=0; i<width; i++){
1018 b1[i] -= (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS; 1018 b1[i] -= (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
1019 } 1019 }
1020 } 1020 }
1021 1021
1022 static void vertical_decompose97iH1(int *b0, int *b1, int *b2, int width){ 1022 static void vertical_decompose97iH1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1023 int i; 1023 int i;
1024 1024
1025 for(i=0; i<width; i++){ 1025 for(i=0; i<width; i++){
1026 #ifdef lift5 1026 #ifdef lift5
1027 b1[i] += (W_CM*(b0[i] + b2[i])+W_CO)>>W_CS; 1027 b1[i] += (W_CM*(b0[i] + b2[i])+W_CO)>>W_CS;
1032 b1[i] += (r+W_CO)>>W_CS; 1032 b1[i] += (r+W_CO)>>W_CS;
1033 #endif 1033 #endif
1034 } 1034 }
1035 } 1035 }
1036 1036
1037 static void vertical_decompose97iL0(int *b0, int *b1, int *b2, int width){ 1037 static void vertical_decompose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1038 int i; 1038 int i;
1039 1039
1040 for(i=0; i<width; i++){ 1040 for(i=0; i<width; i++){
1041 b1[i] -= (W_BM*(b0[i] + b2[i])+W_BO)>>W_BS; 1041 b1[i] -= (W_BM*(b0[i] + b2[i])+W_BO)>>W_BS;
1042 } 1042 }
1043 } 1043 }
1044 1044
1045 static void vertical_decompose97iL1(int *b0, int *b1, int *b2, int width){ 1045 static void vertical_decompose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1046 int i; 1046 int i;
1047 1047
1048 for(i=0; i<width; i++){ 1048 for(i=0; i<width; i++){
1049 b1[i] += (W_DM*(b0[i] + b2[i])+W_DO)>>W_DS; 1049 b1[i] += (W_DM*(b0[i] + b2[i])+W_DO)>>W_DS;
1050 } 1050 }
1051 } 1051 }
1052 1052
1053 static void spatial_decompose97i(int *buffer, int width, int height, int stride){ 1053 static void spatial_decompose97i(DWTELEM *buffer, int width, int height, int stride){
1054 int y; 1054 int y;
1055 DWTELEM *b0= buffer + mirror(-4-1, height-1)*stride; 1055 DWTELEM *b0= buffer + mirror(-4-1, height-1)*stride;
1056 DWTELEM *b1= buffer + mirror(-4 , height-1)*stride; 1056 DWTELEM *b1= buffer + mirror(-4 , height-1)*stride;
1057 DWTELEM *b2= buffer + mirror(-4+1, height-1)*stride; 1057 DWTELEM *b2= buffer + mirror(-4+1, height-1)*stride;
1058 DWTELEM *b3= buffer + mirror(-4+2, height-1)*stride; 1058 DWTELEM *b3= buffer + mirror(-4+2, height-1)*stride;
1083 b2=b4; 1083 b2=b4;
1084 b3=b5; 1084 b3=b5;
1085 } 1085 }
1086 } 1086 }
1087 1087
1088 void ff_spatial_dwt(int *buffer, int width, int height, int stride, int type, int decomposition_count){ 1088 void ff_spatial_dwt(DWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count){
1089 int level; 1089 int level;
1090 1090
1091 for(level=0; level<decomposition_count; level++){ 1091 for(level=0; level<decomposition_count; level++){
1092 switch(type){ 1092 switch(type){
1093 case 0: spatial_decompose97i(buffer, width>>level, height>>level, stride<<level); break; 1093 case 0: spatial_decompose97i(buffer, width>>level, height>>level, stride<<level); break;
1095 case 2: spatial_decomposeX (buffer, width>>level, height>>level, stride<<level); break; 1095 case 2: spatial_decomposeX (buffer, width>>level, height>>level, stride<<level); break;
1096 } 1096 }
1097 } 1097 }
1098 } 1098 }
1099 1099
1100 static void horizontal_compose53i(int *b, int width){ 1100 static void horizontal_compose53i(DWTELEM *b, int width){
1101 int temp[width]; 1101 DWTELEM temp[width];
1102 const int width2= width>>1; 1102 const int width2= width>>1;
1103 const int w2= (width+1)>>1; 1103 const int w2= (width+1)>>1;
1104 int A1,A2,A3,A4, x; 1104 int A1,A2,A3,A4, x;
1105 1105
1106 #if 0 1106 #if 0
1141 } 1141 }
1142 if(width&1) 1142 if(width&1)
1143 b[2*x ]= temp[x ]; 1143 b[2*x ]= temp[x ];
1144 } 1144 }
1145 1145
1146 static void vertical_compose53iH0(int *b0, int *b1, int *b2, int width){ 1146 static void vertical_compose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1147 int i; 1147 int i;
1148 1148
1149 for(i=0; i<width; i++){ 1149 for(i=0; i<width; i++){
1150 b1[i] += (b0[i] + b2[i])>>1; 1150 b1[i] += (b0[i] + b2[i])>>1;
1151 } 1151 }
1152 } 1152 }
1153 1153
1154 static void vertical_compose53iL0(int *b0, int *b1, int *b2, int width){ 1154 static void vertical_compose53iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1155 int i; 1155 int i;
1156 1156
1157 for(i=0; i<width; i++){ 1157 for(i=0; i<width; i++){
1158 b1[i] -= (b0[i] + b2[i] + 2)>>2; 1158 b1[i] -= (b0[i] + b2[i] + 2)>>2;
1159 } 1159 }
1160 } 1160 }
1161 1161
1162 static void spatial_compose53i(int *buffer, int width, int height, int stride){ 1162 static void spatial_compose53i(DWTELEM *buffer, int width, int height, int stride){
1163 int y; 1163 int y;
1164 DWTELEM *b0= buffer + mirror(-1-1, height-1)*stride; 1164 DWTELEM *b0= buffer + mirror(-1-1, height-1)*stride;
1165 DWTELEM *b1= buffer + mirror(-1 , height-1)*stride; 1165 DWTELEM *b1= buffer + mirror(-1 , height-1)*stride;
1166 1166
1167 for(y=-1; y<=height; y+=2){ 1167 for(y=-1; y<=height; y+=2){
1182 b1=b3; 1182 b1=b3;
1183 } 1183 }
1184 } 1184 }
1185 1185
1186 1186
1187 static void horizontal_compose97i(int *b, int width){ 1187 static void horizontal_compose97i(DWTELEM *b, int width){
1188 int temp[width]; 1188 DWTELEM temp[width];
1189 const int w2= (width+1)>>1; 1189 const int w2= (width+1)>>1;
1190 1190
1191 lift (temp , b , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 1); 1191 lift (temp , b , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 1);
1192 lift5(temp+w2, b +w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 1); 1192 lift5(temp+w2, b +w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 1);
1193 lift (b , temp , temp+w2, 2, 1, 1, width, -W_BM, W_BO, W_BS, 0, 1); 1193 lift (b , temp , temp+w2, 2, 1, 1, width, -W_BM, W_BO, W_BS, 0, 1);
1194 lift (b+1 , temp+w2, b , 2, 1, 2, width, -W_AM, W_AO, W_AS, 1, 1); 1194 lift (b+1 , temp+w2, b , 2, 1, 2, width, -W_AM, W_AO, W_AS, 1, 1);
1195 } 1195 }
1196 1196
1197 static void vertical_compose97iH0(int *b0, int *b1, int *b2, int width){ 1197 static void vertical_compose97iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1198 int i; 1198 int i;
1199 1199
1200 for(i=0; i<width; i++){ 1200 for(i=0; i<width; i++){
1201 b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS; 1201 b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
1202 } 1202 }
1203 } 1203 }
1204 1204
1205 static void vertical_compose97iH1(int *b0, int *b1, int *b2, int width){ 1205 static void vertical_compose97iH1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1206 int i; 1206 int i;
1207 1207
1208 for(i=0; i<width; i++){ 1208 for(i=0; i<width; i++){
1209 #ifdef lift5 1209 #ifdef lift5
1210 b1[i] -= (W_CM*(b0[i] + b2[i])+W_CO)>>W_CS; 1210 b1[i] -= (W_CM*(b0[i] + b2[i])+W_CO)>>W_CS;
1215 b1[i] -= (r+W_CO)>>W_CS; 1215 b1[i] -= (r+W_CO)>>W_CS;
1216 #endif 1216 #endif
1217 } 1217 }
1218 } 1218 }
1219 1219
1220 static void vertical_compose97iL0(int *b0, int *b1, int *b2, int width){ 1220 static void vertical_compose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1221 int i; 1221 int i;
1222 1222
1223 for(i=0; i<width; i++){ 1223 for(i=0; i<width; i++){
1224 b1[i] += (W_BM*(b0[i] + b2[i])+W_BO)>>W_BS; 1224 b1[i] += (W_BM*(b0[i] + b2[i])+W_BO)>>W_BS;
1225 } 1225 }
1226 } 1226 }
1227 1227
1228 static void vertical_compose97iL1(int *b0, int *b1, int *b2, int width){ 1228 static void vertical_compose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
1229 int i; 1229 int i;
1230 1230
1231 for(i=0; i<width; i++){ 1231 for(i=0; i<width; i++){
1232 b1[i] -= (W_DM*(b0[i] + b2[i])+W_DO)>>W_DS; 1232 b1[i] -= (W_DM*(b0[i] + b2[i])+W_DO)>>W_DS;
1233 } 1233 }
1234 } 1234 }
1235 1235
1236 static void spatial_compose97i(int *buffer, int width, int height, int stride){ 1236 static void spatial_compose97i(DWTELEM *buffer, int width, int height, int stride){
1237 int y; 1237 int y;
1238 DWTELEM *b0= buffer + mirror(-3-1, height-1)*stride; 1238 DWTELEM *b0= buffer + mirror(-3-1, height-1)*stride;
1239 DWTELEM *b1= buffer + mirror(-3 , height-1)*stride; 1239 DWTELEM *b1= buffer + mirror(-3 , height-1)*stride;
1240 DWTELEM *b2= buffer + mirror(-3+1, height-1)*stride; 1240 DWTELEM *b2= buffer + mirror(-3+1, height-1)*stride;
1241 DWTELEM *b3= buffer + mirror(-3+2, height-1)*stride; 1241 DWTELEM *b3= buffer + mirror(-3+2, height-1)*stride;
1271 b2=b4; 1271 b2=b4;
1272 b3=b5; 1272 b3=b5;
1273 } 1273 }
1274 } 1274 }
1275 1275
1276 void ff_spatial_idwt(int *buffer, int width, int height, int stride, int type, int decomposition_count){ 1276 void ff_spatial_idwt(DWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count){
1277 int level; 1277 int level;
1278 1278
1279 for(level=decomposition_count-1; level>=0; level--){ 1279 for(level=decomposition_count-1; level>=0; level--){
1280 switch(type){ 1280 switch(type){
1281 case 0: spatial_compose97i(buffer, width>>level, height>>level, stride<<level); break; 1281 case 0: spatial_compose97i(buffer, width>>level, height>>level, stride<<level); break;