@@ -228,98 +228,103 @@ public static void DumpFile(string filename, XRITHeader fileHeader, string newEx
228
228
}
229
229
230
230
public static string Decompressor ( string filename , int pixels ) {
231
+ /**
232
+ * Temporary Workarround. Needs to change directly on Demuxer
233
+ */
234
+ string outputFile = String . Format ( "{0}_decomp.lrit" , filename ) ;
235
+ byte [ ] outputData = new byte [ pixels ] ;
236
+
237
+ for ( int i = 0 ; i < pixels ; i ++ ) {
238
+ outputData [ i ] = 0x00 ;
239
+ }
240
+
231
241
try {
232
- Process decompressor = new Process ( ) ;
233
- ProcessStartInfo startInfo = new ProcessStartInfo ( ) ;
234
- startInfo . WindowStyle = ProcessWindowStyle . Hidden ;
235
-
236
- if ( LLTools . IsLinux ) {
237
- startInfo . FileName = "wine" ;
238
- startInfo . Arguments = String . Format ( "Decompress.exe {0} {1} a" , pixels , filename ) ;
239
- startInfo . EnvironmentVariables . Add ( "WINEDEBUG" , "fixme-all,err-winediag" ) ;
242
+ byte [ ] inputData = File . ReadAllBytes ( filename ) ;
243
+ AEC . LritRiceDecompress ( ref outputData , inputData , 8 , 16 , pixels , AEC . ALLOW_K13_OPTION_MASK | AEC . MSB_OPTION_MASK | AEC . NN_OPTION_MASK ) ;
244
+ } catch ( Exception e ) {
245
+ if ( e is AECException ) {
246
+ AECException aece = ( AECException ) e ;
247
+ UIConsole . GlobalConsole . Error ( string . Format ( "AEC Decompress Error: {0}" , aece . status . ToString ( ) ) ) ;
240
248
} else {
241
- startInfo . FileName = "Decompress.exe" ;
242
- startInfo . Arguments = String . Format ( "{0} {1} a" , pixels , filename ) ;
249
+ UIConsole . GlobalConsole . Error ( string . Format ( "Decompress error: {0}" , e . ToString ( ) ) ) ;
243
250
}
251
+ }
244
252
245
- startInfo . RedirectStandardError = true ;
246
- startInfo . RedirectStandardOutput = true ;
247
- startInfo . CreateNoWindow = true ;
248
- startInfo . UseShellExecute = false ;
249
-
250
- decompressor . StartInfo = startInfo ;
253
+ File . WriteAllBytes ( outputFile , outputData ) ;
254
+ return outputFile ;
255
+ }
251
256
252
- UIConsole . GlobalConsole . Debug ( String . Format ( "Calling {0}" , startInfo . Arguments ) ) ;
253
- decompressor . Start ( ) ;
254
- decompressor . WaitForExit ( ) ;
255
257
256
- if ( decompressor . ExitCode != 0 ) {
257
- string stderr = decompressor . StandardError . ReadToEnd ( ) ;
258
- UIConsole . GlobalConsole . Error ( String . Format ( "Error Decompressing: {0}" , stderr ) ) ;
259
- } else {
260
- UIConsole . GlobalConsole . Debug ( String . Format ( "Decompress sucessful to {0}" , String . Format ( "{0}_decomp.lrit" , filename ) ) ) ;
261
- try {
262
- File . Delete ( filename ) ;
263
- } catch ( Exception e ) {
264
- Console . WriteLine ( "Cannot delete file {0}: {1}" , filename , e ) ;
265
- }
266
- }
258
+ public static string Decompressor ( string prefix , int pixels , int startnum , int endnum ) {
259
+ /**
260
+ * Temporary Workarround. Needs to change directly on Demuxer
261
+ */
267
262
268
- } catch ( Exception e ) {
269
- UIConsole . GlobalConsole . Error ( String . Format ( "Error running decompressor: {0}" , e ) ) ;
270
- }
263
+ string outputFile = String . Format ( "{0}_decomp{1}.lrit" , prefix , startnum ) ;
271
264
265
+ try {
266
+ byte [ ] input = File . ReadAllBytes ( string . Format ( "{0}{1}.lrit" , prefix , startnum ) ) ;
267
+ byte [ ] outputData = new byte [ pixels ] ;
272
268
273
- return String . Format ( "{0}_decomp.lrit" , filename ) ;
274
- }
269
+ FileStream f = File . OpenWrite ( outputFile ) ;
270
+ startnum ++ ;
271
+ // First file only contains header
272
+ f . Write ( input , 0 , input . Length ) ;
275
273
274
+ int overflowCaseLast = - 1 ;
276
275
277
- public static string Decompressor ( string prefix , int pixels , int startnum , int endnum ) {
278
- try {
279
- Process decompressor = new Process ( ) ;
280
- ProcessStartInfo startInfo = new ProcessStartInfo ( ) ;
281
- startInfo . WindowStyle = ProcessWindowStyle . Hidden ;
282
- if ( LLTools . IsLinux ) {
283
- startInfo . FileName = "wine" ;
284
- startInfo . Arguments = String . Format ( "Decompress.exe {0} {1} {2} {3} a" , prefix , pixels , startnum + 1 , endnum ) ;
285
- startInfo . EnvironmentVariables . Add ( "WINEDEBUG" , "fixme-all,err-winediag" ) ;
286
- } else {
287
- startInfo . FileName = "Decompress.exe" ;
288
- startInfo . Arguments = String . Format ( "{0} {1} {2} {3} a" , prefix , pixels , startnum + 1 , endnum ) ;
276
+ // Check for overflow in file number
277
+ if ( endnum < startnum ) {
278
+ overflowCaseLast = endnum ;
279
+ endnum = 16383 ;
289
280
}
290
281
291
- startInfo . RedirectStandardError = true ;
292
- startInfo . RedirectStandardOutput = true ;
293
- startInfo . CreateNoWindow = true ;
294
- startInfo . UseShellExecute = false ;
282
+ for ( int i = startnum ; i <= endnum ; i ++ ) {
283
+ string ifile = string . Format ( "{0}{1}.lrit" , prefix , i ) ;
284
+ input = File . ReadAllBytes ( ifile ) ;
295
285
296
- decompressor . StartInfo = startInfo ;
286
+ for ( int z = 0 ; z < outputData . Length ; z ++ ) {
287
+ outputData [ z ] = 0x00 ;
288
+ }
297
289
298
- UIConsole . GlobalConsole . Debug ( String . Format ( "Calling {0}" , startInfo . Arguments ) ) ;
299
- decompressor . Start ( ) ;
300
- decompressor . WaitForExit ( ) ;
290
+ try {
291
+ AEC . LritRiceDecompress ( ref outputData , input , 8 , 16 , pixels , AEC . ALLOW_K13_OPTION_MASK | AEC . MSB_OPTION_MASK | AEC . NN_OPTION_MASK ) ;
292
+ } catch ( AECException e ) {
293
+ Console . WriteLine ( "AEC Decompress problem decompressing file {0}: {1}" , ifile , e . status . ToString ( ) ) ;
294
+ Console . WriteLine ( "AEC Params: {0} - {1} - {2}" , 8 , 16 , pixels ) ;
295
+ }
296
+
297
+ f . Write ( outputData , 0 , outputData . Length ) ;
298
+ }
299
+
300
+ if ( overflowCaseLast != - 1 ) {
301
+ for ( int i = 0 ; i < overflowCaseLast ; i ++ ) {
302
+ string ifile = string . Format ( "{0}{1}.lrit" , prefix , i ) ;
303
+ input = File . ReadAllBytes ( ifile ) ;
304
+ for ( int z = 0 ; z < outputData . Length ; z ++ ) {
305
+ outputData [ z ] = 0x00 ;
306
+ }
301
307
302
- if ( decompressor . ExitCode != 0 ) {
303
- string stderr = decompressor . StandardError . ReadToEnd ( ) ;
304
- UIConsole . GlobalConsole . Error ( String . Format ( "Error Decompressing: {0}" , stderr ) ) ;
305
- } else {
306
- UIConsole . GlobalConsole . Debug ( String . Format ( "Decompress sucessful to {0}" , String . Format ( "{0}_decomp{1}.lrit" , prefix , startnum ) ) ) ;
307
- for ( int i = startnum ; i < endnum + 1 ; i ++ ) {
308
- string f = string . Format ( "{0}{1}.lrit" , prefix , i ) ;
309
308
try {
310
- File . Delete ( f ) ;
311
- } catch ( Exception e ) {
312
- Console . WriteLine ( "Error deleting file {0}: {1}" , f , e ) ;
309
+ AEC . LritRiceDecompress ( ref outputData , input , 8 , 16 , pixels , AEC . ALLOW_K13_OPTION_MASK | AEC . MSB_OPTION_MASK | AEC . NN_OPTION_MASK ) ;
310
+ File . Delete ( ifile ) ;
311
+ } catch ( AECException e ) {
312
+ Console . WriteLine ( "AEC Decompress problem decompressing file {0}" , ifile ) ;
313
+ } catch ( IOException e ) {
314
+ Console . WriteLine ( "Error deleting file {0}: {1}" , ifile , e ) ;
313
315
}
316
+
317
+ f . Write ( outputData , 0 , outputData . Length ) ;
314
318
}
315
319
}
316
320
321
+ f . Close ( ) ;
322
+
317
323
} catch ( Exception e ) {
318
- UIConsole . GlobalConsole . Error ( String . Format ( "Error running decompressor : {0}" , e ) ) ;
324
+ UIConsole . GlobalConsole . Error ( string . Format ( "There was an error decompressing data : {0}" , e ) ) ;
319
325
}
320
326
321
-
322
- return String . Format ( "{0}_decomp{1}.lrit" , prefix , startnum ) ;
327
+ return outputFile ;
323
328
}
324
329
}
325
330
}
0 commit comments