Commit 7f5bf70b authored by Robert Sprowson's avatar Robert Sprowson

Fix for CLI processing of very large sprites (>64MB)

When the output sprite is calculated to be too big to fit in the upper limit of dynamic area size, ChangeFSI would attempt to create the output to disc in smaller chunks. However, the size required by the sprite header was not accounted for, eg. a 5000x4000 32bpp image would come out as 80000000 exactly.
Fix this by flushing the sprite header (and palette) before spooling out the image.
Tested with a nobbled dynamic area size of 128k, used 8bpp 2000x1000 sprite as test and processed this to
  S32,90,90
  S16,90,90
  28d
  28
  27
to exercise true colour, 256 palette, and bpp < 8.
Note, the desktop front end isn't helped by this as it requires the image to all be in memory at once for the display step, but the CLI version can now output practically unlimited sprite files.

Deleted call to PROCflushoutput in the JPEG/JPEGMONO code path, since addr% is never incremented it never gets called
and the file that is being written to in o% is set type to FF9 at the end anyway. Tested with
  JPEG75
  JPEGMONO75

Made Wimp version check consistent with 2 other occurences elsewhere in the source for the same template-related feature.

Version 1.54. Tagged as 'ChangeFSI-1_54'
parent 43ad8e7b
/* (1.53)
/* (1.54)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.53
#define Module_MajorVersion_CMHG 1.54
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 13 Jun 2015
#define Module_Date_CMHG 15 Jul 2015
#define Module_MajorVersion "1.53"
#define Module_Version 153
#define Module_MajorVersion "1.54"
#define Module_Version 154
#define Module_MinorVersion ""
#define Module_Date "13 Jun 2015"
#define Module_Date "15 Jul 2015"
#define Module_ApplicationDate "13-Jun-15"
#define Module_ApplicationDate "15-Jul-15"
#define Module_ComponentName "ChangeFSI"
#define Module_ComponentPath "mixed/RiscOS/Sources/Apps/ChangeFSI"
#define Module_FullVersion "1.53"
#define Module_HelpVersion "1.53 (13 Jun 2015)"
#define Module_LibraryVersionInfo "1:53"
#define Module_FullVersion "1.54"
#define Module_HelpVersion "1.54 (15 Jul 2015)"
#define Module_LibraryVersionInfo "1:54"
......@@ -312,7 +312,7 @@ END
REM
DEF PROCdotemplate(a$)
LOCAL A%
IF version%>300 THEN
IF version%>=300 THEN
SYS "Wimp_LoadTemplate",,0,,,,a$+z$,0 TO ,,indsize%
DIM A% indsize%
SYS "Wimp_LoadTemplate",,z%,A%,A%+indsize%,-1,a$+z$,0
......@@ -8719,7 +8719,8 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
!base%=!base%-Y%*xwords%+A%*xwords%
ram%!12=ram%!12-Y%*xwords%+A%*xwords%
base%!(10*4)=5<<27 OR nx<<1 OR ny<<14 OR 1
base%+=base%!(8*4)
base%+=base%!(8*4):REM Base of the sprite pixel array
IF o% SYS 12,2,o%,ram%+4,base%-(ram%+4):REM Flush the sprite header
WHEN -7
REM 24bpp is an alias for 32bpp for now
REM xwords%=xsp%*3+3ANDNOT3:sz%=xwords%*ysp%:Y%=ysp%
......@@ -8745,7 +8746,8 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
!base%=!base%-Y%*xwords%+A%*xwords%
ram%!12=ram%!12-Y%*xwords%+A%*xwords%
base%!(10*4)=6<<27 OR nx<<1 OR ny<<14 OR 1
base%+=base%!(8*4)
base%+=base%!(8*4):REM Base of the sprite pixel array
IF o% SYS 12,2,o%,ram%+4,base%-(ram%+4):REM Flush the sprite header
WHEN -9
xwords%=xsp%+3 AND NOT 3
sz%=(xsp%+7 AND NOT 7)*(ysp%+7 AND NOT 7)
......@@ -8837,6 +8839,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
base%+=2048
!(ram%+12)+=2048
!(pal%-44)+=2048
REM 256 greys
FOR Z%=0 TO 255
B%=Z% OR Z%<<8 OR Z%<<16
B%=B%<<8
......@@ -8849,6 +8852,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
base%+=2048
!(ram%+12)+=2048
!(pal%-44)+=2048
REM 256 colours
FOR Z%=0 TO 255
B%=palette%!(Z%<<2)<<8
pal%!(Z%*8)=B%
......@@ -8900,6 +8904,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
PROCcol(0,0)
PROCcol(1,&F0F0F0)
ENDCASE
IF o% SYS 12,2,o%,ram%+4,base%-(ram%+4):REM Flush the sprite header
ENDCASE
REM put back all possible memory...
IF flex% THEN
......@@ -8991,7 +8996,6 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
I%=step%
FOR yr%=0 TO y%-1
SYS hour%,yr%*100 DIV y%
IF addr%>outlim% PROCflushoutput
W%=EVAL(r$+"(cl%())")
B%=x%
CALL fs%,colstep%,cl%(1,0),I%,addr%,I%,B%,base%
......@@ -9040,7 +9044,6 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
IF order% THEN
FOR yr%=0 TO y%-1
SYS hour%,yr%*100 DIV y%
IF addr%>outlim% PROCflushoutput
IF sy%=y% THEN
PROCsharppixelrow(cl%())
ELSE
......@@ -9088,7 +9091,6 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
ELSE
FOR yr%=0 TO y%-1
SYS hour%,yr%*100 DIV y%
IF addr%>outlim% PROCflushoutput
IF sharpen% THEN
IF yread% yread%-=1:PROCscaledpixelrow(rm%()):IF equal% PROCfit(rm%())
FOR B%=0 TO col
......@@ -9437,7 +9439,6 @@ DEF PROCgetoutput(A%,E%,B%,RETURN C%)
IF A%>max% AND rotate%= FALSE AND vflip%= FALSE THEN
C%=max% DIV B%+1
A%=xwords%*C%+E%
first%= TRUE
o%= OPENOUTf$
ELSE
A%+=E%
......@@ -9519,7 +9520,6 @@ REM
DEF PROCflushoutput
IF spritearea%=-1 AND oksave% THEN
A%=base%
IF first% A%=ram%+4:first%= FALSE
SYS 12,2,o%,A%,addr% DIV size%
ENDIF
addr%=0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment