@@ -60,40 +60,67 @@ procedure Main is
6060
6161 procedure Free is new Ada.Unchecked_Deallocation (G.Image, G.Image_Access);
6262
63- begin
63+ procedure Read_Cmd_Parameters is
64+ begin
65+ GLP.Parse_Command_Line (Parameters => Descriptors, Result => Param);
66+ end ;
67+
68+ procedure Load_QOI_image is
69+ begin
70+ Start_Time := Clock;
71+ Original_Img := Importer.Load_QOI (+Param.Input_Image);
72+ Elapsed_Time := Clock - Start_Time;
73+ AIO.Put_Line (" Load QOI image time: " & Duration'Image (To_Duration (Elapsed_Time)) & " seconds" );
74+ Filtered_Img := new G.Image (1 .. Original_Img'Length (1 ), 1 .. Original_Img'Length (2 ));
75+ end ;
76+
77+ procedure Filter_Image is
78+ begin
79+ Start_Time := Clock;
80+
81+ case Param.Device is
82+ when P.Cpu =>
83+ BH.Bilateral_Cpu (Host_Img => Original_Img.all ,
84+ Host_Filtered_Img => Filtered_Img.all ,
85+ Width => Original_Img'Length (1 ),
86+ Height => Original_Img'Length (2 ),
87+ Spatial_Stdev => Param.Spatial_Stdev,
88+ Color_Dist_Stdev => Param.Color_Dist_Stdev);
89+ when P.Gpu =>
90+ BH.Bilateral_CUDA (Host_Img => Original_Img.all ,
91+ Host_Filtered_Img => Filtered_Img.all ,
92+ Width => Original_Img'Length (1 ),
93+ Height => Original_Img'Length (2 ),
94+ Spatial_Stdev => Param.Spatial_Stdev,
95+ Color_Dist_Stdev => Param.Color_Dist_Stdev);
96+ end case ;
97+
98+ Elapsed_Time := Clock - Start_Time;
99+ AIO.Put_Line (" Filtering time (" & Param.Device'Image & " ): " & Duration'Image (To_Duration (Elapsed_Time)) & " seconds" );
100+ end ;
101+
102+ procedure Dump_QOI_image is
103+ begin
104+ Start_Time := Clock;
105+ Exporter.Dump_QOI (+Param.Output_Image, Filtered_Img);
106+ Elapsed_Time := Clock - Start_Time;
107+ AIO.Put_Line (" Dump QOI image time: " & Duration'Image (To_Duration (Elapsed_Time)) & " seconds" );
108+ end ;
109+
110+ procedure Free_Ressources is
111+ begin
112+ Free (Original_Img);
113+ Free (Filtered_Img);
114+ end ;
64115
65- GLP.Parse_Command_Line (Parameters => Descriptors, Result => Param);
66- Original_Img := Importer.Load_QOI (+Param.Input_Image);
67- Filtered_Img := new G.Image (1 .. Original_Img'Length (1 ), 1 .. Original_Img'Length (2 ));
68-
69- Start_Time := Clock;
70-
71- case Param.Device is
72- when P.Cpu =>
73- BH.Bilateral_Cpu (Host_Img => Original_Img.all ,
74- Host_Filtered_Img => Filtered_Img.all ,
75- Width => Original_Img'Length (1 ),
76- Height => Original_Img'Length (2 ),
77- Spatial_Stdev => Param.Spatial_Stdev,
78- Color_Dist_Stdev => Param.Color_Dist_Stdev);
79- when P.Gpu =>
80- BH.Bilateral_CUDA (Host_Img => Original_Img.all ,
81- Host_Filtered_Img => Filtered_Img.all ,
82- Width => Original_Img'Length (1 ),
83- Height => Original_Img'Length (2 ),
84- Spatial_Stdev => Param.Spatial_Stdev,
85- Color_Dist_Stdev => Param.Color_Dist_Stdev);
86- end case ;
87-
88- Elapsed_Time := Clock - Start_Time;
89- AIO.Put_Line (" Filtering time (" & Param.Device'Image & " ): " & Duration'Image (To_Duration (Elapsed_Time)) & " seconds" );
90-
91- Exporter.Dump_QOI (+Param.Output_Image, Filtered_Img);
116+ begin
92117
118+ Read_Cmd_Parameters;
119+ Load_QOI_image;
120+ Filter_Image;
121+ Dump_QOI_image;
93122 AIO.Put_Line (" Result found in " & Param.Output_Image'Image);
94-
95- Free (Original_Img);
96- Free (Filtered_Img);
123+ Free_Ressources;
97124
98125exception
99126 when Msg : GLP.Bad_Command =>
0 commit comments