A method for encoding animation in an image file

Abstract: A method of processing a multi-layer image file (100) comprising a first plurality of image layers (106-108), and a second plurality of control blocks (120-122) is disclosed. The processing produces an animation sequence. The method comprises processing an image layer (eg 106) in accordance with a corresponding control block (eg 120), thereby providing an image for said animation sequence. The method further comprises tagging the image layer (106) for reprocessing, if the image layer (106) is to be used again in the image sequence, said tagging using a relative address referred to one of (i) an address of said corresponding control block (120) and (ii) an address of a control block corresponding to another image layer.

Description: The present invention relates to multi-layer image files which are intended, for example, to be displayed as an animation, or alternatively, as a multi-layer composite image. Background Art Multi-layer (or multi-page) images can be thought of as a set of images, all typically but not necessarily the same size, which are somehow combined for the purpose of displaying on an output display device. Thus multi-layer refers to multiple images in a single file. Each image in the file is referred to as a layer. There are currently two significant applications areas for which multi-layer images are used and they include: image editing and graphic design; and animation, especially animation in web pages on the Internet. In the area of image editing and graphic design, multi-layer images allow a composition of complex scenes as different images are layered over each other. In this case it is usual for each layer to have an opacity (or alpha) channel associated with it. To display the various layers (images) on a display device, a first layer (typically a background image) is rendered and subsequent layer is then composited upon the first layer, for example, according to the following equations. A c = 1 - (1 - A t )(1- A b ) s = A t /A c t = (1 - A t )A b /A c R c = sR t + tR b G c =sG t +tG b B c =sB t +tB b In the above equations: the background image is specified in the RGBA (Red, Green, Blue and Alpha) colour space as (Rb, Gb, Bb Ab); a foreground (or top) image is specified in the RGBA colour space as (Rt, Gt, Bt, At); and the output or composite image is specified in the RGBA colour space as (Rc, Gc, Bc, Ac). Each subsequent (or new) layer is taken to be a foreground image until it is combined (composited) with a previous layer, wherein the combination is then taken to be a (new) background image. In this manner it is possible to combine a number of layers by sequential applications of equations (4-6) to each new layer in turn in order to form a final composite image. Other compositing operations are also possible however the one described herein-before with reference to equations (1) to (6) is the most commonly used. The other noteworthy application of multi-layer images, noted above, is animation. For this purpose, currently, the most widely used file format is the Graphics Interchange Format (GIF). The GIF also contains layers (or multiple images) which are composited in sequence order. Each layer of a GIF file may be of different size and is positioned using offset coordinates in order to improve storage efficiency in cases where only small areas contain changes from one layer to the next. The GIF standard defines a virtual screen upon which each layer is composited. It uses a control block structure to indicate how the layers in the file are to be displayed. Each layer of the file format is preceded by a control block which contains: information about the location of the top left corner in the virtual screen; information on how long the layer should be displayed before proceeding to the next layer in the file; and whether the layer should be removed prior to display of a next layer in the file. This (control block based) structure allows for particularly simple software implementation of the decoder. In fact very little additional coding is required to implement a GIF decoder capable of correctly displaying multi-layer animated GIF images. The animation scheme employed by GIF has been adopted widely in a very short space of time. The primary reason for this is the simple and restricted design. These features make it easy for a large number of independent developers to implement file viewers capable of handling GIF animations. However the simplicity of GIF comes at the price of efficiency in coding. For example, as each layer in an animated GIF file corresponds to a single display frame, animation using sprites and overlays is not coded efficiently. This is because each frame must be present as a separate image layer. Images that are reused through the course of an animation must appear once in the file for each frame they appear in. More recently, the Multiple Image Network Graphics (MNG) file format, which is still being developed, has attempted to address this problem. MNG defines an animation framework based on extensions to the Portable Network Graphics (PNG) file format. However, while MNG permits the reuse of layers, much of the simplicity that characterised the success of GIF is lost. In addition, the methods used by MNG to describe the animation do not lead naturally to an implementation model. This makes the development of viewers for MNG animations notably more difficult to implement. To help address this problem the creators of MNG have proposed low complexity and very low complexity subsets of the full MNG standard. The problem with this however is that the low complexity subsets achieve little more functionality than GIF and have the same coding efficiency problems. "SWF File Format Specification", Concise Guide to the SWF File Format, 6 October 1999, (1999-10-06), pages 1-7, XP002266717 <URL:http://web.archive.org/web/19991006013357/homepages.tig.com.au/ - dkl/swf/SWFfileformat.html> discloses the SWF file format designed to deliver graphics and animation over the Internet. Following the header are a series of tagged data blocks. Definition tags are used to add character information to the dictionary. Definition tags define data that can be reused in a file like shapes, bitmaps, buttons, text, fonts and sounds. Control tags manipulate characters and provide administrative functions. For example, control tags are used to move objects on the screen, show frames, and start sounds. Tags can occur in the file in any order. The order of control tags defines the order of the animation. This ordering of tags is how the SWF file format supports streaming. The rule is that a given tag should only depend on tags that come before it. A tag should never depend on a tag that comes later in the file. Conceptually, the SWF file format can be considered as two interleaved streams of data. The definition stream adds characters to the dictionary and the control stream performs operations on the display list using the characters that have been defined in the dictionary. The model for processing a stream is that all tags are processed in a stream until a ShowFrame tag is encountered. At that point, the display list is copied to the screen and the player is idle until it is time to process the next frame. "SWF File Reference", The Swiff Info Center, 6 October 1999, (1999-10-06), pages 1-46, XP002266718 <URL:http://web.archive.org/web/19991006000759/http://homepages.tig.com.au/ - dkl/swf/SWFfilereference.html> describes the basic data types used to define the more complex data structures that comprise the SWF file format. With reference to the SWF File Tags, there are two categories of tags: definition and control. Definition tags manage a dictionary of resources such as shapes, text, bitmap, and buttons that can be used at any point in the animation. Control tags control the display list and enable actions such as stopping or starting the animation. Definition tags are used to create animation characters such as shapes, text, bitmap, and buttons. The following sections describe the data types and tags associated with each character type. Control tags can be divided into three categories: display list, control, and action. Display list tags control the contents of the display list. Control tags manage some overall aspects of files and frames. The SWF File format defines a simple action model. An action list can be attached to a button state transition or placed in the tags that will be processed for a given frame. When an action is encountered, it is added to a list to be processed. The list is processed on a ShowFrame tag or after a button state has changed. According to the present invention, there is provided a method of processing a sequence of image layers according to a sequence of display instructions as set out in claim 1. The present invention also provides apparatus for processing a sequence of image layers according to a sequence of display instructions as set out in claim 5. The present invention also provides a carrier carrying image data defining a plurality of image layers and a sequence of display instructions as set out in claim 8. The present invention also provides a storage medium storing computer program instructions as set out in claim 9. The present invention further provides a signal carrying computer program instructions as set out in claim 10. Optional features are set out in the other claims. A number of embodiments of the present invention will now be described with reference to the drawings, in which: Fig. 1 is a schematic block diagram of a general-purpose computer with which embodiments of the present invention can be practiced; Fig. 2 shows an image file structure in accordance with an embodiment of the invention; Fig. 3 shows a virtual screen, upon which a segment of a layer is to be rendered; Fig. 4 shows an memory arrangement to support displaying animated image sequences in accordance with an embodiment of the invention; Fig. 5 is a flow diagram of method steps, showing an animation process in accordance with an embodiment of the invention; Fig. 6 is a flow diagram of method steps relating to the step of reading header and animation control block information in Fig. 5; Fig. 7 is a flow diagram of method steps relating to the step of allocation of screen memory and support structures in Fig. 5; Fig. 8 is a flow diagram of method steps relating to the step of initialisation of memory and support structures in Fig. 5; Fig. 9 is a flow diagram of method steps relating to the step of instruction determination in Fig. 5; Fig. 10 is a flow diagram of method steps relating to the step of determination of image layer in Fig. 5; Fig.11 is a flow diagram of method steps relating to the step of rendering of image layers in Fig. 5; Fig. 12 is a flow diagram of method steps relating to the step of flushing of a rendered rectangle to the screen in Fig. 5; Fig. 13 shows an example of an image file structure in accordance with an embodiment, associated with an animation sequence; and Fig. 14 depicts the animation sequence of Fig. 13. Where reference is made in any one or more of the accompanying drawings to steps and/or features, which have the same reference numerals, those steps and/or features have for the purposes of this description the same function(s) or operation(s), unless the contrary intention appears. One embodiment of the invention is preferably practiced using a general-purpose computer, such as the one shown in Fig. 1, wherein the processes of Figs. 5-12 may be implemented as software executing on the computer. In particular, the steps of the encoding, decoding methods are effected by instructions in the software that are carried out by the computer. The coding algorithm for providing signalling of the structure of a code stream representing a digital image may also be implemented by instructions in software carried out by the computer. The software may be stored in a computer readable medium, including the storage devices described below, for example. The software is loaded into the computer from the computer readable medium, and then executed by the computer. A computer readable medium having such software or computer program recorded on it is a computer program product. The use of the computer program product in the computer effects an advantageous apparatus for encoding digital images, decoding or signalling the structure coded representations of digital images in accordance with the embodiments of the invention. The computer system 100 consists of the computer 101, a video display 114, and input devices 102, 103. In addition, the computer system 100 can have any of a number of other output devices 115 including line printers, laser printers, plotters, and other reproduction devices connected to the computer 101. The computer system 100 can be connected to one or more other computers using an appropriate communication channel via a modem 116, a computer network 120, or the like. The computer network may include a local area network (LAN), a wide area network (WAN), an Intranet, and/or the Internet. The computer 101 itself consists of a central processing unit(s) (simply referred to as a processor hereinafter) 105, a memory 106 which may include random access memory (RAM) and read-only memory (ROM), an input/output (IO) interface 108, a video interface 107, and one or more storage devices generally represented by a block 109 in Fig. 1. The storage device(s) 109 can consist of one or more of the following: a floppy disc 111, a hard disc drive 110, a magneto-optical disc drive, CD-ROM, magnetic tape or any other of a number of non-volatile storage devices well known to those skilled in the art. Each of the components 105 to 113 is typically connected to one or more of the other devices via a bus 104 that in turn can consist of data, address, and control buses. The video interface 107 is connected to the video display 114 and provides video signals from the computer 101 for display on the video display 114. User input to operate the computer 101 can be provided by one or more input devices. For example, an operator can use the keyboard 102 and/or a pointing device such as the mouse 103 to provide input to the computer 101. The system 100 is simply provided for illustrative purposes and other configurations can be employed. Exemplary computers on which embodiments can be practiced include IBM-PC/ATs or compatibles, one of the Macintosh (TM) family of PCs, Sun Sparcstation (TM), or the like. The foregoing are merely exemplary of the types of computers with which embodiments of the invention may be practiced. Typically, the processes of the embodiments, described hereinafter, are resident as software or a program recorded on a hard disk drive (generally depicted as block 110 in Fig. 1) as the computer readable medium, and read and controlled using the processor 105. Intermediate storage of the program and pixel data and any data fetched from the network may be accomplished using the semiconductor memory 106, possibly in concert with the hard disk drive 110. In some instances, the program may be supplied to the user encoded on a CD-ROM or a floppy disk (both generally depicted by block 109), or alternatively could be read by the user from the network via a modem device connected to the computer, for example. Still further, the software can also be loaded into the computer system 100 from other computer readable medium including magnetic tape, a ROM or integrated circuit, a magneto-optical disk, a radio or infra-red transmission channel between the computer and another device, a computer readable card such as a PCMCIA card, and the Internet and Intranets including email transmissions and information recorded on websites and the like. The foregoing are merely exemplary of relevant computer readable mediums. Other computer readable mediums may be practiced. Embodiments of the coding method may alternatively be implemented in dedicated hardware such as one or more integrated circuits performing the functions or sub-functions of the encoding, decoding or signalling processes. Such dedicated hardware may include ASICs and associated on-chip memories. Fig. 2 shows an image file structure in an embodiment of the present invention. The file 1000 comprises a number of elements 1002 - 1008 packed sequentially into a binary file. Elements early in the the file contain header information 1002 which may include information identifying the file type as well as information describing parameters of the image data contained in the file 1000. An element may also describe an extension to the basic file syntax that is not necessarily understood by all file readers. In the embodiment, each instruction has identical parameterisation and, as a result, has fixed length. This fact can be used by a file reader to determine the instruction boundaries and, where the length of the instruction set is known, the number of instructions. The animation control block 1004 uses the syntax of the file 1000 in which the block is embedded. Usually this provides a mechanism by which the file reader can determine the starting point and length of the control block 1004 as a whole. Each instruction set, say 1020, (including the leading repeat parameter 1028) is delimited in such a way that the file reader can determine the starting point and length of each set 1020 in a straightforward manner. In the current embodiment, each instruction set is appended to (i) a 32 bit unsigned integer indicating the length of the instruction set and (ii) a 4 byte tag indicating that the ensuing data is a set of animation instructions. This structuring scheme is illustrative, and a different structure, such as a table listing the starting offsets of each instruction set, can equally be used. The file 1000 contains one or more elements containing image data 1006 or references to image data. There may be several distinct still images 1006 - 1008 contained or referenced in a file and each of these is referred to as a layer. Some of these layers may be visually incomplete when viewed separately as they are intended to be overlayed on or otherwise combined with other image layers in the file for display purposes. Each is however a complete codestream or set of codestreams, capable of being independently decoded and are still considered distinct within the scope of this description. Animation can be performed using one or more of the image layers 1006 - 1008, alone or in combination. Each image layer eg 1006 comprises one or more channels which may be present as one or more codestreams contained in the file 1000, or referenced by the file or derived by mapping image elements through a lookup table. Each codestream or reference contained in the file 1000 is present in one or more file elements. Information in header elements is used by the file reader to recover the complete codestreams and decode those to image layers. The channels of each layer comprise arrays of pixel values. These may correspond to samples of colour information specific to a colour space which is defined within header elements 1002 of the file. A single channel may also correspond to intensity samples as in a greyscale image. One or more channels may also contain samples of opacity information for use in rendering other channels in the layer. This channel is commonly referred to as the alpha channel. Alpha channel data may be binary (or bi-level) with each sample taking on only one of two possible values corresponding to fully transparent and fully opaque. Binary alpha data may be encoded with the colour channels by assigning a unique colour to all pixels which are fully transparent. This specification discloses a method for describing the animation, comprising a file or codestream 1000 containing a header 1002 with global parameters including but not limited to (i) the screen area (eg 1532 in Fig 3) required to display the animation contained in the file (ii) a block of animation control information 1004 and (iii) a sequence of image layers 1006 - 1008 encoded using any appropriate method. The animation control information 1004 (also referred to as the animation control block) comprises, as shown in an expanded view 1016, an integer 1014 denoted "tick" defining the duration of a timer tick. The animation control information 1004 also contains an integer 1018 denoted "loop" defining the number of times the animation as a whole should be displayed. The animation control information 1004 further contains one or more sets 1020 - 1022 of frame control instructions. The structure of the animation control block 1004 is described with reference to Table 1. Fields contained in the animation control block with descriptions. Field tag Encoding Description Tick 16 bit unsigned integer The duration in milliseconds of the default timer tick used for interpreting timing instructions. Other temporal measures could be used eg. ticks per second. Loop 16 bit unsigned integer The number of times to repeat the display of this animation in its entirety. A value of 2 16 indicates that the decoder should repeat the animation indefinitely or until stopped by an external signal. Instruction sets See Table 2. Collections of animation instructions A predetermined value of "loop" 1018 can be used to ensure that the animation be repeated an indefinite number of times. Each of the sets 1020 - 1022 of frame control instructions comprises, as shown in an expanded view 1032, a leading integer 1028 denoted "repeat" indicating the number of times the associated set of instructions 1030 - 1036 should be executed, and a set of instructions which are to be executed by the reader in sequential order. A predetermined value of "repeat" is used to ensure that the animation instruction sequence is executed an indefinite number of times. Table 2 encapsulates the form of the instruction sets 1020 - 1022. Fields contained in each of the "Instruction sets" of the animation control block, with descriptions. Field tag Encoding Description Repeat 16 bit unsigned integer The number of times to repeat the execution of the ensuing animation instructions. Instruction m See table 3. Animation instructions Each instruction say 1034 comprises, as shown in an expanded view 1042 (which comprises two sections 1058 and 1064 in tandem, as depicted by dashed arrows 1060, 1062) an integer 1044 denoted "life" defining the number of timer ticks that should (ideally) occur between completion of execution of the current instruction and completion of execution of the next instruction. The instruction further comprises a binary flag 1046 denoted "persist" defining whether the pixels rendered to screen as a result of execution of the current instruction should appear to persist on the display background or appear to be reset to the pre-execution background. Furthermore, an integer 1048 denoted "next" defines the number of instructions to execute before reusing the current layer where a value of zero implies that the layer shall not be reused for any ensuing instructions notwithstanding execution of a global loop as a result of a non-zero "loop" control. The first instruction 1030 acts upon the first layer 1006 in the file 1000, and each subsequent instruction acts on the layer specified for that instruction in the "next" field of a previous instruction, or, in the case that no such specification has taken place, the next layer sequentially in the file. A zero value for "life" (ie 1044) and a false value for "persist" (ie 1046) indicates that the layer being acted upon by that instruction is not rendered in any way by that instruction. A zero value for "life" (ie 1044) and a true value for "persist" (ie 1046) indicates that the layer being acted upon by the current instruction is to be considered as part of a frame definition sequence. Such a sequence is terminated upon execution of the next instruction with a non-zero value for "life". Termination of the frame definition sequence results in the composition and display of all of the layers acted upon by the frame definition sequence in such a way that the "persist" and "life" values for the terminating instruction are applied collectively. From a display perspective, all the instructions in a frame definition sequence should appear to be executed as a single instruction. A predetermined maximum value of "life" (ie 1044) is used to imply that the animation be suspended indefinitely after execution of that instruction. In such cases, execution may be continued as a result of some higher interaction level. Each instruction (1030) can additionally include an integer pair 1050, 1052 denoted "(x,y)" defining the location to place the top left corner within the display area for the whole image of the layer being acted on by this instruction. The instruction 1030 can also include an integer set 1066 - 1072 denoted "(Cx, Cy, Cw, Ch)" defining the top left corner, width and height of a region to crop from the layer being acted on by this instruction. The cropped region is considered to replace the layer being acted upon within the scope of this instruction only. Each instruction can additionally include an integer pair 1054, 1056 denoted "(w,h)" defining the width and height of the region within the display area into which the layer being acted upon by this instruction should be rendered. This step includes resampling of the layer if the width and height of the layer are different to the values specified in the instruction. The form of the instructions 1034 - 1036 is set out in Table 3. Fields contained in the instruction m fields of the animation control block with descriptions. Field tag Preferred encoding Description Persist 1 bit flag Boolean flag indicating whether the pixels rendered to screen as a result of execution of the current instruction should appear to persist or appear to be reset to the pre-execution background after the instruction's life has expired. Life 15 bit unsigned integer The number of timer ticks to aim to place between the completion of this instruction and the completion of the next instruction. Next 32 bit unsigned integer The number of instructions to execute (including the current instruction) before reusing the current image layer. A value of zero implies the layer shall not be reused for any ensuing instructions notwithstanding execution of a global loop as a result of a non-zero "loop" control. x_screen 32 bit unsigned integer Distance in screen pixels from the left edge of the display area to place the left edge of the layer being acted on by this instruction. y_screen 32 bit unsigned integer Distance in screen pixels from the top edge of the display area to place the top edge of the layer being acted on by this instruction. w_screen 32 bit unsigned integer Width of the display area in screen pixels into which to scale and render the layer being acted on by this instruction. h_screen 32 bit unsigned integer Height of the display area in screen pixels into which to scale and render the layer being acted on by this instruction. x_crop 32 bit unsigned integer Distance in image pixels to the left edge of a crop region within the layer being acted on by this instruction. y_crop 32 bit unsigned integer Distance in image pixels to the top edge of a crop region within the layer being acted on by this instruction. w_crop 32 bit unsigned integer Width in image pixels of a crop region within the layer being acted on by this instruction. h_crop 32 bit unsigned integer Height in image pixels of a crop region within the layer being acted on by this instruction. The interpretation of the instruction parameters is further explained with reference to Fig. 3. Fig. 3 shows a virtual screen 1526, upon which a cropped segment 1510 of a layer 1504 is to be rendered, the performance of rendering being depicted by a dashed arrow 1520. The virtual screen 1526 has a width 1524, and a height 1540, these dimensions being referred to an (x,y) origin 1522 depicted by a dark dot. A segment 1532 of the virtual screen 1526, to which a segment 1510 of a layer 1504 is to be rendered, has a width 1530, and a height 1534, denoted respectively by 1054 and 1056 in Fig. 2, these dimensions being referred to an (x,y) origin 1528, denoted 1050, 1052 in Fig. 2. The segment 1510 of the layer 1504 which is to be rendered onto the virtual screen 1526, has a width 1512, and a height 1514, denoted respectively by 1070 and 1072 in Fig. 2, and these dimensions being referred to an (x,y) origin 1508 denoted by 1066, 1068 in Fig. 2. The layer itself 1504 has a width 1506 and a height 1518, these dimensions being referred to an (x,y) origin 1502. Fig. 4 shows a memory arrangement 1100 for displaying animated image sequences. The memory comprises a viewable memory region 1102 having a capacity equal in size to a screen area defined in the file header 1002, and an off-screen working space 1104, at least equal in size to the largest area that is to be rendered to screen at once (resulting from the execution of a single instruction or the final instruction of a frame definition sequence). The memory further comprises an off-screen backing store 1106, which is again at least equal in size to the largest area that is to be rendered to screen at once (resulting from the execution of a single instruction or the final instruction of a frame definition sequence). The memory further comprises storage 1108 for a list of layers referred to as the "layer memory" which can be used to retrieve a decoded version of any layer explicitly placed in that list. The apparatus further comprises storage 1110 for a list of integers corresponding to the entries in layer memory and containing the number of instructions still to be executed before the corresponding layer (in layer memory) is to be acted upon. Fig. 5 shows a top level of execution of an embodiment 372 of the animation process. Execution commences at a step 300. A multi-layer file (1000, see Fig. 2) is opened at a step 305, and header and animation control information is read in a step 310, this being described in greater detail with reference to Fig. 6. The header information is used to allocate display resources and support structures in a step 315, this being described in greater detail with reference to Fig. 7. The memory and support structures are initialised in a step 320, this being described in greater detail with reference to Fig.8. Determination of required instructions is performed in a step 325, which is described in greater detail with reference to Fig. 9. Determination of a required image layer is performed in a step 335, which is described in greater detail with reference to Fig. 10. Rendering a layer in accordance with an instruction is performed in a step 345, which is described in greater detail with reference to Figs 11(a) and 11(b). Flushing of the rendered rectangle to the screen is performed in a step 367, which is described in greater detail with reference to Fig. 12. The main animation loop of the process 372 begins in a step 325. In this step, the player determines the display instruction to use from the sets of instructions provided in the animation control block. The determined instruction is tested in a step 330 to determine if the instruction has a special value indicating that no further instructions are available. This special value is denoted "stop". If an instruction other than "stop" is found, execution of the process 372 moves to a step 335, where the player determines the image layer which is to be acted upon by the instruction. The determined layer is tested in a step 340, to determine if the determined layer has a special value, denoted "empty", indicating that no layer could be found. If there is a layer to use, execution of the process 372 moves to a step 345 where the layer is rendered in accordance with the instruction. In a following step 350, the "next" field of the instruction is tested for a non-zero value which would indicate that the layer is to be used again. If a non-zero value is found then the layer, and the value of the "next" field, are committed to a layer memory at a step 355. The layer memory can take several different, but functionally equivalent forms for the purpose of implementation. In one embodiment, each entry in the layer memory stores the decoded image samples. In another embodiment, the compressed codestream is retained in the layer memory. In a further embodiment, a pointer to the first byte of the layer in the file is stored along with any auxilliary data required in order to read and decode the data. In all cases, the layer memory provides sufficient information to permit the reader to regenerate the pixels of the layer stored therein at some future time. If the "next" field (ie. 1048) of the current instruction is zero, this implying that the layer is not needed after execution of this instruction, then any memory associated with maintaining that layer's pixel data or decoder state can be freed. In either case, execution of the process 372 subsequently returns to a step 325 where the next instruction is determined, then next layer is determined and rendered and so on. If at any stage there is no instruction found (ie the step 330 which tests if "instruction is "stop"" returns a "yes" value), or no layer found (ie the step 340 which tests if "layer is "empty"" returns a "yes" value), then the animation sequence 372 is assumed to have finished, and execution moves to step 360. If the value of the loop field, tested for at step 360, is zero, then execution of the animation process 372 terminates. However, if the last instruction executed had a zero life field, then there may be undisplayed image data waiting to be rendered in the render image. To logically complete the animation (or alternatively, the still composition) the rendered rectangle of the render image is flushed to screen at a step 367, prior to exiting to the step 370. In an alternate embodiment, the flushing step 367 can be performed prior to the decision step 360. If the loop field is non zero at the step 360, then the loop field value is decremented at a step 365 before re-initialising memory and support structures (at the step 320) and restarting the animation loop. Step 310 of Fig. 5 is described in detail with reference to Fig. 6. Execution starts at a step 1610. In a subsequent step 1620, a width and height of the screen area used to render the animation is read, along with other header information important to the recovery of image data from the file. Only the width and hight parameters play an integral role in the animation process however. In a following step 1630, top level animation controls are read, these including "tick" and "loop" parameters, as defined in Table 1. Subsequently, in a step 1640, the animation instruction sets are read. In practice, the instruction sets may be read in full, or a pointer into the file maintained for reading during execution of the main animation loop may be read. The header information 1002 as described in relation to Fig. 2 represents only the required minimum set of header information required to implement the embodiment. Other embodiments may incorporate arbitrary additional header information. Finally, execution exits at a step 1650. Step 315 of Fig. 5 is desribed in detail with reference to Fig. 7. Execution starts at a step 1710, and proceeds based on information read from the file 1000 (see Fig. 2) at the step 310 of Fig 5. At a step 1720, memory is allocated for a backing store. The purpose of the backing store is to store areas of the screen that must be restored after the display of non persistent frames, i.e. where the persist field of the animation instruction has the value "false". The size of the backing store can be calculated by parsing the instructions, to determine the largest area that will require restoring. Alternatively, the backing store can simply be made the same size as the screen area used to display the animation. No instruction parsing is required in this latter case. If the animation contains only persistent frames, then no backing store is required, and the step 1720 has no effect. It is noted that information regarding the backing store size can be stored as part of the file header. At a step 1730, memory is allocated for a render image. The purpose of the render image is to act as an off-screen working space in which frames can be composed prior to being copied to screen memory. In the embodiment, the render image is the same size as the screen area used to display the animation. In practice the render image can be smaller, but will usually be at least the same size as the largest screen area updated at any one instant, this being the size of the largest "rendered rectangle" resulting from execution of the instructions. Alternatively, this can be considered in terms of being at least equal in size to the largest area that is to be rendered to screen at once (resulting from the execution of a single instruction or the final instruction of a frame definition sequence). It is noted that allocation of a background store is not required if the first layer of the file is fully opaque, and covers the entire image display area (which is specified by the width and height fields of the header). In addition, the backing store is not required if all of the instructions in the animation control block have a persist value of "true". At a step 1740, memory is allocated for the layer memory. Layer memory serves a dual purpose, in that it provides a cache for image data that has already been decoded and rendered but is going to be reused in subsequent frame, and it also provides the mechanism for tracking when the layers contained therein are to be re-used. To achieve these aims, each entry in layer memory comprises a handle by which the image data for that layer may be retrieved and a variable labelled "next" which records the number of instructions to be executed before reusing the layer. Finally, at a step 1750, a test is performed to determine if the value of the "loop" field in the animation control block is zero. If this is false (i.e. the step 1750 returns a "no") then the entire animation sequence 372 (see Fig. 5) is to be repeated. In order to support this, an additional background store is allocated at a step 1760 and the initial screen background is copied to this background store in a step 1770. If the value of "loop" is zero (i.e. the step 1750 returns "yes") then there is no need for this background store structure, and execution exits directly to a step 1780. Step 320 of Fig 5 is described in detail with reference to Fig. 8. Execution starts at a 1800, and at a step 1802, a number of variables are initialised. Specifically, "restore" is set to "false". This variable indicates when background should be restored from the backing store. The value of "first frame" is set to true, indicating that the first frame of the animation sequence is about to be processed. The "timer" is initialised with the curent time. This variable is used to determine the time at which individual frames of the animation sequence should appear on screen. Finally a variable labelled "rendered rectangle" is initialised to contain four zeros. The rendered rectangle contains the origin (x and y) and size (width and height) of the region in the rendered image that has changed relative to the on-screen display. This is used during screen updates. At a step 1804, each item in the layer memory is visited, and the items "next" field reset to a value of zero. This value is intended to ensure that the associated image handle will be freed. In a step 1806, a test is performed to determine if a background store is being used, which would imply that the animation sequence 372 (see Fig. 5) is looped at least once. If the step 1806 returns "no", then the screen image can simply be copied to the backing store in a step 1808. If the step 1806 returns a "yes", then the copy of the background contained in the background store must be used, since the screen background may be corrupted with the output from a previous loop execution. This is copied to the backing store at a step 1812. Either way, execution then exits to a step 1810. Step 325 of Fig. 5 is described in detail with reference to Fig. 9. Execution begins at a step 1900. At a following step 1905, a test is performed to determine if the value of the "first frame" variable is true, which indicates that the animation process 372 (see Fix. 5) is at the very beginning of the animation sequence. If step 1905 returns "yes", then a "current set" variable is set to point to the first set of instructions defined in the animation control block at a step 1910, and at a following step 1915, the variable "count" is initialised to the value of the repeat field in the aforementioned current set. At a step 1960, the variable "instruction" is set to point to the first instruction in the current set before execution exits at a step 1965. If the step 1905 returns a "no", indicating that a frame subsequent to the first frame is being animated, then a number of additional tests are required in order to determine which instruction should be used. At a step 1920, a test is performed to determine if "instruction" already points to the last instruction in the current set. If the step 1920 returns a "no", indicating that the end of the current set has not been reached, then "instruction" is incremented, in a step 1940, to point to the next instruction in the current set in sequence order, prior to exiting at the step 1965. If the step 1920 returns a "yes", indicating that the last instruction in the current set has been performed, then the count variable is tested at a step 1925 to determine if the count variable is zero. If the step 1925 returns a "no", indicating that the instructions in this set should be repeated, then the value of "count" is decremented in a step 1945, "instruction" is set to point to the first instruction in the current set in the step 1960, and execution subsequently exits to the step 1965. If the step 1925 returns "yes", indicating that any repeats of this instruction set have been completed and that execution should continue with the first instruction of the next instruction set, then a test is performed at a step 1930 to determine if the current set is the last instruction set defined in the animation control block. If step 1930 returns "yes" - indicating that the current set is the last set - the variable "instruction" is set to a special predetermined value indicating that no further instructions are available. In Fig. 9 this value is denoted "stop". If the step 1930 returns "no", indicating that there are more instruction sets defined by the animation control block still to be processed, then the variable "current set" is set to point to the next instruction set in sequence order at the step 1950, and the variable "count" is initialised to the value of the "repeat" field for that instruction set in a step 1955. Subsequently, the variable "instruction" is set to point to the first instruction in the new current set at the step 1960 before execution exits at the step 1965. Step 335 of Fig. 5 is described in detail with reference to Fig. 10. Execution starts in a step 2000. In a following step 2005, a variable labelled "current layer" is initialised to a special value denoted "empty" and a variable labelled "N" is initialised to the number of entries in the layer memory. This variable (N) is used in subsequent loop instructions to process each entry in the layer memory. The loop execution starts in a following step 2010, where a test is performed to determine if the value of "N" is zero. If the step 2010 returns "yes", then the loop exits, and the process 335 is directed to a step 2015 where a test is performed to determine if the value of "current layer" has been set to something other than the special value of "empty". If the step 2015 returns "yes", then the pixel data associated with the current layer is retrieved in a subsequent step 2020. In either case, execution susequently exits to a step 2060. If the step 2010 returns "no", indicating that not all entries in the layer memory have been visited, then the main body of the loop is executed. At a step 2025, a variable L is set to point to the Nth entry in the layer memory. At a subsequent step 2030, the value of the "next" field in that entry is tested to see if its value is zero. If the step 2030 returns "yes", then the layer is removed from layer memory at step 2035. This is a cleanup step. If the step 2030 returns "no", then a test is performed at a following step 2040 to determine if the value of the "next" field of entry "L" is equal to one and the value of current layer is equal to the special value denoted "empty". If the step 2040 returns "yes", then the current layer is set to the layer contained in the entry "L", and the "next" field in that entry is set to the value of the "next" field in the current instruction. The value of "N" is subsequently decremented in a step 2055, and execution of the process 335 loops back to the step 2010. If the step 2040 returns "no", then the value of the next field in the entry "L" is decremented, in a step 2050, prior to decrementing "N" at the step 2055 and looping back to the step 2010. Step 345 of Fig 5 is described in detail with reference to Figs. 11(a) and 11(b). Execution starts at a step 900 in Fig.11(a). A following step 905 tests for the special case of a non-persistent frame with zero life. If the step 905 returns "yes", indicating that this condition exists, then execution of the process 345 immedately exits to a step 995 (see Fig. 11(b)). If the step 905 returns "no", then the value of the rendered rectangle is updated in a following step 910, to contain the union of the rendered rectangle current value and the screen rectangle defined by the current instruction. At a following step 915, a test is performed to determine if a crop operation is required by the current instruction. If the step 915 returns "yes", indicating that the crop operation is required, then in one embodiment, the current layer is replaced, only for the scope of the current instruction, with the cropped region at a step 920. In either case, execution then moves to a following step 925. At the step 925, a test is performed to determine if a rescaling is required by the current instruction. If the step 925 returns "yes", indicating that a rescaling is required, then the current layer is replaced, only for the scope of the current instruction, with a version of the current layer scaled to a width of w_screen and a height of h_screen as defined in the current instruction at step 930. In either case, execution of the process 345 then moves to a step 935, where the current layer is composited over the render image with the top left corner of the current image at the location (x_screen, y_screen) specified by the current instruction. The steps 920, 930, and 935 can be combined in a more optimised fashion in the scope of the present embodiment. In practice, it is likely that an optimised operation that combines one or more of these tasks will be used. The breakdown into individual unambiguous processing steps used in this description is purely for reasons of clarity. At a following step 940 (see Fig.11(b)), a test is performed to determine if the layer is persistent and has a life of greater than zero timer ticks. If the step 940 returns a "yes" value, this implies that the render image contains enough information to define the next frame in combination with the current display, and execution moves to a test step 955 where a value of the variable "restore" is tested. If a value of "true" is returned, then the process 345 is directed in accordance with a "yes" arrow to a step 965, in which the region specified by the rendered rectangle is copied from the render image to the screen image. If the test step 955 returns a "false" value, then the process 345 is directed in accordance with a "no" arrow to a step 960, in which the current screen is copied to the backing store, and the process 345 is thereafter directed to the step 965. Following the step 965, the process 345 is directed to a step 970, in which the region specified by the rendered rectangle is copied from the backing store to the render image, after which, in a step 975, the rendered rectangle is set to (0,0,0,0), and the variable "restore" is set to "true". The process 345 is then directed to a step 980, which directs the process 345 to wait until the "current time" is greater than a value in the timer. Returning to the step 940, if a value of "false" is returned from the step, then the process 345 is directed in accordance with a "no" arrow to a step 945, in which the region specified by the rendered rectangle is copied from the render image to the screen image. Thereafter, the value of "restore" is set to "false in a step 950, and the process 345 is directed to the step 980. After the step 980, the process 345 is directed to a step 985 in which the screen area specified by the rendered rectangle is updated. Thereafter, in a step 990, the timer is set to a value equal to "current time" plus "life", after which the process 345 terminates at the step 995. Step 367 of Fig 5 is described in detail with reference to Fig. 12. After a commencement step 1300, the process 367 is directed to a step 1310, in which the region specified by the rendered rectangle is copied from the render image to the screen image. Thereafter, in a step 1320, the screen area specified by the rendered rectangle is updated, after which the process 367 terminates in a step 1330. The method of providing an animation may alternatively be implemented in dedicated hardware such as one or more integrated circuits performing the functions or sub functions of providing an animation. Such dedicated hardware may include graphic processors, digital signal processors, or one or more microprocessors and associated memories. Fig. 13 provides an example of an instruction set associated with an animation sequence by which a first image is "slid" onto a second, background image. The figure shows an instruction set 1200 comprising nine columns 1208 - 1224 of integers, and two file designations 1226 and 1228. The uppermost integers 1202 - 1206 of the first three columns 1208 - 1212 provide header information relating respectively to a width and height of the background image, and the number of layers (ie images) used in the animation. The nine columns 1208 - 1224 (with the exception of the first row of 3) refer respectively to the variables x_screen, y_screen, x_crop, y_crop, w_crop, h_crop, "life", "persistence", and "next". Apart from the header information, the columns comprise 11 rows, indicating that the animation is performed in eleven steps. Each row represents an instruction, and the 11 rows represent a single instruction set. Fig. 14 depicts the animation sequence of Fig. 13. The figure shows the background image 1408, of a disk on a blank background (ie file 1228 in Fig. 13). The dimensions of the image 1408 are 675 (ie 1202 in Fig. 13) wide (depicted by an arrow 1410), and 450 (ie 1204 in Fig. 13) high (depicted by an arrow 1406). The figure also shows an image 1404 (ie 1226 in Fig. 13) which is to be slid onto the background image 1408. The image 1404 has a width and height depicted by arrows 1400 and 1402 respectively. Four further views of the background image are provided, with the image 1404 slid successively further onto the background image. A first row 1230 of the instruction set 1200 (see Fig. 13) lays down the background image 1412. The first two integers from the left of the row 1230 which are the x_screen and y_screen values, indicate that the image is to be positioned with it's top left corner at the top left corner of the display area. Since the "next" value of this row 1230, ie the right-most integer, has a value of "0", this indicates that this present image, or layer, will not be re-used, and that the subsequent image, in this case the image 1404, is the next one to process. The next row 1232, consequently processes the image 1404. The first two integers from the left of the row 1232 which are the x_screen and y_screen values, indicate that the image 1404 is to be positioned with it's top left corner at the top left corner of the display area. The third and fifth integers from the left of the row, ie x_crop and w_crop indicate that part of the image 1404 which is to be "preserved" in the x direction for the present instruction. This is performed by moving x_crop (ie 400) along the image 1404 from the left, and preserving the next w_crop (ie 45) of the image. Similarly, the fourth and sixth integers from the left of the row, ie y_crop and h_crop indicate that part of the image 1404 which is to be "preserved" in the y direction for the present instruction. This is performed by moving y_crop (ie 000) down the image 1404 from the top, and preserving the next h_crop, ie 124, which is, in the present case, the entire image. Accordingly, the rightmost "45", running the full height "124" of the image, is to be preserved, and this is positioned at x_screen, y_screen ie at a (0,0) displacement from the top left hand origin. The result of this is depicted by 1414 in the Figure 13, which shows the image 1404 partially slid onto the background image. Still considering the row 1232 the seventh integer from the left, ie "life", has a value of 1, indicating that a single tick should occur between completion of execution of the present instruction, and completion of execution of the next instruction. This value of "life" results in a uniform sliding movement of the image 1404. Still considering the row 1232 the eighth integer from the left, ie "persist", has a value of 0, meaning that the screen value is reset to the pre-execution background prior to the execution of the next instruction. The right-most column of the instruction row 1232 gives the value of "next" to be 1, meaning that the current layer (image 1404) is to be used with the next instruction, where a slightly longer area is cropped and rendered over the top left corner of the background. Progressive stages of the image 1404 being slid onto the image 1408, are shown in 1416 and 1418. It is apparent from the above that embodiments of the invention are applicable to the computer and data processing industries, and in particular to segments of these industries. Furthermore, embodiments of the invention are also applicable to the advertising and entertainment industries. The foregoing describes only some embodiments of the present invention, and modifications and/or changes can be made thereto without departing from the scope of the invention, the embodiments being illustrative and not restrictive.

Claims: A method of processing a sequence of image layers (Fig. 2: 1006, 1008) according to a sequence of display instructions (Fig. 2: 1030, 1034, 1036) to generate image data for display, the method comprising the steps of: (a) applying a current display instruction of the sequence of display instructions to a current image layer of the sequence of image layers (Fig. 5: 325-345); characterised in that : each display instruction includes an image layer reuse parameter (next) defining whether and when a current image layer to which the display instruction is applied is to be re-processed; and the method further comprises the steps of (Fig. 5: 350, 355 and Fig. 10 with loop to 325 in Fig. 5): (b) reading the image layer reuse parameter of the current display instruction and determining therefrom whether the current image layer is to be re-processed; (c) if the current image layer is not to be re-processed (next = 0), applying a subsequent display instruction of the sequence of display instructions to a subsequent image layer of the sequence of image layers; (d) if the current image layer is to be re-processed (next ≠ 0): (i) successively applying a number of display instructions from the sequence of display instructions to image layers from the sequence of image layers, the number being determined from the image layer reuse parameter read in step (b); and thereafter (ii) applying a display instruction to the image layer previously processed in step (a). A method according to claim 1, wherein the method steps are repeated a number of times. A method according to claim 1 or claim 2, wherein the generated image data is displayed as an animation. A method according to claim 1 or claim 2, wherein the generated image data is displayed as a composite image. Apparatus (101) for processing a sequence of image layers (Fig. 2: 1006, 1008) according to a sequence of display instructions (Fig. 2: 1030, 1034, 1036) accompanying the image layers to generate image data for display, the apparatus comprising: display instruction processing means (105, 109) for applying a display instruction of the sequence of display instructions to an image layer of the sequence of image layers; characterised in that : each display instruction includes an image layer reuse parameter (next) defining whether and when a current image layer to which the display instruction is applied is to be re-processed; the apparatus further comprises image layer reuse parameter processing means (105, 109) for reading the image layer reuse parameter of the current display instruction and determining therefrom whether the current image layer is to be re-processed; and the display instruction processing means (105, 109) is arranged to process the image layers in accordance with the result of the processing by the image layer reuse parameter processing means such that: if the current image layer is not to be re-processed (next = 0), a subsequent display instruction of the sequence of display instructions is applied to a subsequent image layer of the sequence of image layers; if the current image layer is to be re-processed (next ≠ 0) : (i) a number of display instructions from the sequence of display instructions are successively applied to image layers from the sequence of image layers, the number being determined from the image layer reuse parameter read by the image layer reuse parameter processing means; and thereafter (ii) a display instruction is applied to the current image layer to be re-processed. Apparatus according to claim 5, wherein the apparatus is operable to display the generated image data as an animation. Apparatus according to claim 5, wherein the apparatus is operable to display the generated image data as a composite image. A carrier carrying image data defining a plurality of image layers (Fig 2: 1006, 1008) and a sequence of display instructions (Fig 2: 1030, 1034, 1036) for processing by an apparatus as set out in any of claims 5 to 7, characterised in that each display instruction includes an image layer reuse parameter (next) for use by the apparatus defining whether and when an image layer to which the display instruction is applied is to be re-processed. A storage medium storing computer program instructions to program a programmable processing apparatus to become operable to perform a method as set out in at least one of claims 1 to 4. A signal carrying computer program instructions to program a programmable processing apparatus to become operable to perform a method as set out in at least one of claims 1 to 4.

Inventors: DORRELL ANDREW JAMES, DORRELL, ANDREW JAMES
Applicants: CANON KK, CANON KABUSHIKI KAISHA
Application year: 2000
Main classification: H04N7
IPC codes: G06T13, H04N7