Method for alpha blending images utilizing a visual instruction set

Abstract: An image alpha blending method utilizing a parallel processor is provided. The computer-implemented method includes the steps of loading unaligned multiple word components into a processor in one machine instruction, each word component associated with a pixel of an image; alpha blending the multiple word components of different source images and a control image in parallel; and storing the alpha blended multiple word components of a destination image into memory in parallel.

Description: RELATED APPLICATIONS The present invention is related to U.S. Patent No. 5,734,874 by Van Hook et al., filed April 29, 1994, entitled "A Central Processing Unit with Integrated Graphics Functions," as well as U.S. Patent No. 5,798,753 by Chang-Guo Zhou et al., filed March 3, 1995, entitled "Color Format Conversion in a Parallel Processor." APPENDIX The appendix is a copy of the "Visual Instruction Set User's Guide." BACKGROUND OF THE INVENTION 1. Field of the Invention. The present invention relates generally to image processing and more particularly to blending two images to form a destination image. 2. Description of the Relevant Art. One of the first uses of computers was the repetitious calculations of mathematical equations. Even the earliest of computers surpassed their creators in their ability to accurately and quickly process data. It is this processing power that make computers very well suited for tasks such as digital image processing. A digital image is an image where the pixels are expressed in digital values. These images may be generated from any number of sources including scanners, medical equipment, graphics programs, and the like. Additionally, a digital image may be generated from an analog image. Typically, a digital image is composed of rows and columns of pixels. In the simplest gray-scale images, each pixel is represented by a luminance (or intensity) value. For example, each pixel may be represented by a single unsigned byte with a range of 0-255, where 0 specifies the darkest pixel, 255 specifies the brightest pixel and the other values specify an intermediate luminance. However, images may also be more complex with each pixel being an almost infinite number of chrominances (or colors) and luminances. For example, each pixel may be represented by four bands corresponding to R, G, B, and α. As is readily apparent, the increase in the number of bands has a proportional impact on the number of operations necessary to manipulate each pixel, and therefore the image. Blending two images to form a resulting image is a function provided by many image processing libraries, for example the XIL imaging library developed by SunSoft division of Sun Microsystems, Inc. and included in Solaris operating system. An example of image blending will now be described with reference to Figs. 1A-D. In the simplest example, the two source images (src1 and src2) are blended to form a destination image (d). The blending is controlled by a control image (a) the function of which is described below. All images are 1000 x 600 pixels and src1, src2, and d are one banded grey-scale images. Referring to Figs. 8A-D, the src2, src1, destination, and control images are respectively depicted where src1 is a car on a road, src2 is a mountain scene, and d is the car superimposed on the mountain scene. Each pixel in the d image is computed from corresponding pixels in the src1, src2, dst images according to the following formula: dst = a*src1 + (1-a)*src2 where a is either 0, 1, or a fraction. The a values are derived from pixels in the control image which correspond to pixels in src1 and src2. Thus, the calculations of Eq. 2 must be performed for each pixel in the destination image. Thus, referring to Figs. 8A-D, the values of all pixels in the control image corresponding to the pixels in src1 representing the car is "1" and the value of all pixels in the control image outside the car is "0". Thus, according to Eq. 1, the pixels' values in the destination image corresponding to the "1" pixels in the control image would be represent the car and the pixels in the destination image corresponding to the "0" pixels in the control image would represent the mountain scene. In practice, the pixel values near the edge of the car would have fractional values to make the edge formed by the car and the mountain scene appear realistic. While the alpha blending function is provided by existing image libraries, typically the function is executed on a processor having integer and floating point units and utilizes generalized instructions for performing operations utilizing those processors. However, certain problems associated with alpha blending operations can cause the blending to be slow and inefficient when performed utilizing generalized instructions. In particular, most processors have a memory interface designed to access words aligned along word boundaries. For example, if the word is a byte (8 bits) then bytes are transferred between memory and the processor beginning at address 0 so that all addresses must be divisible by 8. However, image data tends to be misaligned, i.e., does not begin or end on aligned byte addresses, due to many factors including multiple bands. Further, words containing multiple bytes are usually transferred between memory and the processor and standard methods do not take advantage of the inherent parallelism due to the presence of multiple pixels in the registers. Known image blending techniques basically loop through the image and process each pixel in sequence. This is a very simple process but for a moderately complex 3000x4000 pixel image, the computer may have to perform 192 million instructions or more. This estimation assumes an image of 3000x4000 pixels, each pixel being represented by four bands and four instructions to process each value or band. This calculation shows that what appears to be a simple process quickly becomes very computationally expensive and time consuming. An example of a known image rendering system is provided by GB 2278524 A. This document relates to a system that performs image blending and which employs data parallelism in its image rendering pipeline. As the resolution and size of images increases, improved systems and methods are needed that increase the speed with which computers may blend images. The present invention fulfils this and other needs. SUMMARY OF THE INVENTION The present invention, as claimed in independent claims 1, 7 and 12, provides innovative systems and methods of blending digital images. The present invention utilizes two levels of concurrency to increase the efficiency of image alpha blending. At a first level, machine instructions that are able to process multiple data values in parallel are utilized. At another level, the machine instructions are performed within the microprocessor concurrently. The present invention provides substantial performance increases in image alpha blending technology. According to one aspect of the invention, an image alpha blending method of the present operates in a computer system and includes the steps of loading multiple word components of an unaligned image into a microprocessor in parallel, each word component associated with a pixel of an image; alpha blending the multiple word components in parallel; and storing the unaligned multiple word components of a destination image into memory in parallel. According to another aspect of the invention, a computer program product included a computer usable medium having computer readable code embodied therein for causing loading multiple word components of an unaligned image into a microprocessor in parallel, each word component associated with a pixel of an image; alpha blending the multiple word components in parallel; and storing the unaligned multiple word components of a destination image into memory in parallel Other features and advantages of the present invention will become apparent upon a perusal of the remaining portions of the specification and drawings. BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 illustrates an example of a computer system used to execute the software of the present invention; Fig. 2 shows a system block diagram of a typical computer system used to execute the software of the present invention; Fig. 3 is a block diagram of the major functional units in the UltraSPARC-I microprocessor; Fig. 4 shows a block diagram of the Floating Point/Graphics Unit; Fig. 5 is a flow diagram of a partitioned multiply instruction; Fig. 6 is a flow diagram of a partitioned add instruction; Figs. 7A-C are a flow diagrams of a partitioned pack instruction; Figs. 8A-D are depictions of source, destination, and control images; Fig. 9 is flow chart depicting a preferred embodiment of a method of alpha blending two images, and Fig. 10 is depiction of the modification of word components effected by the steps in a routine for calculating the destination image. DESCRIPTION OF THE PREFERRED EMBODIMENT The following are definitions of some of the terms used herein. Pixel (picture element) - a small section or spot in an image where the image is on a computer screen, paper, film, memory, or the like. Byte - a unit of information having 8 bits. Word - a unit of information that is typically a 16, 32 or 64-bit quantity. Machine instructions (or code) - binary sequences that are loaded and executed by a microprocessor. In the description that follows, the present invention will be described with reference to a Sun workstation incorporating an UltraSPARC-I microprocessor and running under the Solaris operating system. The UltraSPARC-I is a highly integrated superscaler 64-bit processor and includes the ability to perform multiple partitioned integer arithmetic operations concurrently. The UltraSPARC-I microprocessor will be described below but is also described in U.S. Patent No. 5,734,874 by Van Hook et al, filed April 29, 1994, entitled "A Central Processing Unit with Integrated Graphics Functions." The present invention, however, is not limited to any particular computer architecture or operating system. Therefore, the description the embodiments that follow is for purposes of illustration and not limitation. Fig. 1 illustrates an example of a computer system used to execute the software of the present invention. Fig. 1 shows a computer system 1 which includes a monitor 3, screen 5, cabinet 7, keyboard 9, and mouse 11. Mouse 11 may have one or more buttons such as mouse buttons 13. Cabinet 7 houses a CD-ROM drive 15 or a hard drive (not shown) which may be utilized to store and retrieve software programs incorporating the present invention, digital images for use with the present invention, and the like. Although a CD-ROM 17 is shown as the removable media, other removable tangible media including floppy disks, tape, and flash memory may be utilized. Cabinet 7 also houses familiar computer components (not shown) such as a processor, memory, and the like. Fig. 2 shows a system block diagram of computer system 1 used to execute the software of the present invention. As in Fig. 1, computer system 1 includes monitor 3 and keyboard 9. Computer system 1 further includes subsystems such as a central processor 102, system memory 104, I/O controller 106, display adapter 108, removable disk 112, fixed disk 116, network interface 118, and speaker 120. Other computer systems suitable for use with the present invention may include additional or fewer subsystems. For example, another computer system could include more than one processor 102 (i.e., a multi-processor system) or a cache memory. Arrows such as 122 represent the system bus architecture of computer system 1. However, these arrows are illustrative of any interconnection scheme serving to link the subsystems. For example, a local bus could be utilized to connect the central processor to the system memory and display adapter. Computer system 1 shown in Fig. 2 is but an example of a computer system suitable for use with the present invention. Other configurations of subsystems suitable for use with the present invention will be readily apparent to one of ordinary skill in the art. Fig. 3 is a block diagram of the major functional units in the UltraSPARC-I microprocessor. A microprocessor 140 includes a front end Prefetch and Dispatch Unit (PDU) 142. The PDU prefetches instructions based upon a dynamic branch prediction mechanism and a next field address which allows single cycle branch following. Typically, branch prediction is better than 90% accurate which allows the PDU to supply four instructions per cycle to a core execution block 144. The core execution block includes a Branch Unit 145, an Integer Execution Unit (IEU) 146, a Load/Store Unit (LSU) 148, and a Floating Point/Graphics Unit (FGU) 150. The units that make up the core execution block may operate in parallel (up to four instructions per cycle) which substantially enhances the throughput of the microprocessor. The IEU performs the integer arithmetic or logical operations. The LSU executes the instructions that transfer data between the memory hierarchy and register files in the IEU and FGU. The FGU performs floating point and graphics operations. Fig. 4 shows a block diagram of the Floating Point/Graphics Unit. FGU 150 includes a Register File 152 and five functional units which may operate in parallel. The Register File incorporates 32 64-bit registers. Three of the functional units are a floating point divider 154, a floating point multiplier 156, and a floating point adder 158. The floating point units perform all the floating point operations. The remaining two functional units are a graphics multiplier (GRM) 160 and a graphics adder (GRA) 162. The graphical units perform all the graphics operations of the Visual Instruction Set (VIS) instructions. The VIS instructions are machine code extensions that allow for enhanced graphics capabilities. The VIS instructions typically operate on partitioned data formats. In a partitioned data format, 32 and 64-bit words include multiple word components. For example, a 32-bit word may be composed of four unsigned bytes and each byte may represent a pixel intensity value of an image. As another example, a 64-bit word may be composed of four signed 16-bit words and each 16-bit word may represent the result of a partitioned multiplication. The VIS instructions allow the microprocessor to operate on multiple pixels or bands in parallel. The GRA performs single cycle partitioned add and subtract, data alignment, merge, expand and logical operations. The GRM performs three cycle partitioned multiplication, compare, pack and pixel distance operations. The following is a description of some these operations that may be utilized with the present invention. Fig. 5 is a flow diagram of a partitioned multiply operation. Each unsigned 8-bit component (i.e., a pixel) 202A-D held in a first register 202 is multiplied by a corresponding (signed) 16-bit fixed point integer component 204A-D held in a second register 204 to generate a 24-bit product. The upper 16 bits of the resulting product are stored as corresponding 16-bit result components 205A-D in a result register 206. Fig. 6 is a flow diagram of a partitioned add/subtract operation. Each 16-bit signed component 202A-D held in the first register 202 is added/subtracted to a corresponding 16-bit signed component 204A-D held in the second register to form a resulting 16-bit sum/difference component which is stored as. a corresponding result component 205A-D in a result register 205. Fig. 7 is a flow diagram of a partitioned pack operation. Each 16-bit fixed value component 202A-D held in a first register 202 is scaled, truncated and clipped into an 8-bit unsigned integer component which is stored as a corresponding result component 205A-D in a result register 205. This operation is depicted in greater detail in Figs. 7B-C. Referring to Fig. 7B, a 16-bit fixed value component 202A is left shifted by the bits specified by a GSR scale factor held in GSR register 400 (in this example the GSR scale factor 10) while maintaining clipping information. Next, the shifted component is truncated and clipped to an 8-bit unsigned integer starting at the bit immediately to the left of the implicit binary point (i.e., between bits 7 and 6 for each 16-bit word). Truncation is performed to convert the scaled value into a signed integer (i.e., round to negative infinity). Fig. 7C depicts an example with the GSR scale factor equal to 8. ALPHA BLENDING Fig. 9 is a flow chart depicting a preferred embodiment of a method of alpha blending two images. In Fig. 9, multi-component words, with each component associated with a pixel value, are loaded from unaligned areas of memory holding the src1, src2, and control images. The components of these multi-component words are processed in parallel to generate components of a multi-component word holding pixel values of the destination image. The components of a destination word are stored in parallel to an unaligned area of memory. Accordingly, except for doing different arithmetic as dictated by specified precision values and definitions of partitioned operations, each of the routines described below, for each line of pixels, loops through the data by doing, load data, align data, perform arithmetic in parallel, before and after the loop, deal with edges. Loading Misaligned Image Data The use of the visual instruction set to load the src1, src2, and alpha images into the registers of the GPU will now be described. For purpose of illustration it is assumed that the src1 image data begins at Address 16005, src2 begins at Address 24003, and dst begins at 8001. Accordingly, neither src1, src2, or dst begins on an aligned byte address. In this example, all images are assumed to comprise 8-bit pixels and have only a single band. For purposes of explanation the VIS assembly instructions are used in function call notation. This implies that memory locations instead of registers are referenced, hence aligned loads will implied rather than explicitly stated. This notation is routinely used by those skilled in the art and is not ambiguous. The special visual instructions utilized to load the misaligned data are alignaddr(addr, offset) and falingndata(data_hi,data_lo) . The function and syntax of these instructions is fully described in Appendix B. The use of these instructions in an exemplary subroutine for loading misaligned data will be described below. The function of the alignaddr() instruction is to return an aligned address equal to the nearest aligned address occurring before the address of misaligned address and write the offset of the misaligned address from the returned address to the GSR. The integer in the offset argument is added to the offset of the misaligned address prior to writing the offset to the GSR. For example, as stated above, if the starting Address for src1 is 16005, the alignaddr(16005,0) returns the aligned address of 16000 and writes 5 to the GSR. The function of faligndata() is to load an 8-byte doubleword beginning at a misaligned address. This is accomplished by loading two consecutive double words having aligned addresses equal to data_hi and data_lo and using the offset written to the GSR to fetch 8 consecutive bytes with the first byte offset from the aligned boundary by the number written to the GSR. If s1 is the address of the first byte of the first 64 bit word of the misaligned src1 data then the routine: s1_aligned = alignaddr(s1, 0) u_s1_0 = s1_aligned[1] u-s1-1 = s1_aligned[2] dbl_s1 = faligndata(u_s1_0, u_s1_1) sets s1_aligned to the aligned address preceding the beginning to the first 64 bit word, i.e., 16000, sets u_s1_0 equal to the first word aligned address and u_s1_1 equal to the second word aligned address, i.e., 160000 and 16008, and returns the first misaligned word of src1 as dbl_s1 . This routine can be modified to return the misaligned pixels from src1, dbl_s2 , and from the control image, quad_a , and included in a loop to load all the pixels of src1, src2, and the control image. Calculating the Destination Image 1. Pixel Length of Src1, Src2, and Control Image is 1 Byte (8 bits) In this example the pixels, α, in the control image are 8-bit unsigned integers having values between 0-255. Thus, Eq. 1 is transformed into: dst = α/256*src1 + (1-α/256)*src2 or the destination image can be calculated from: dst = src2 + (src1 - src2)*α/256 The following routine utilizes visual instructions that provide for parallel processing of 4 pixel values per operation with each pixel comprising 8 bits. Additionally, as will become apparent, the routine eliminates the requirement of explicitly dividing by 256 thereby reducing the processing time and resources required to calculate the pixel values in the destination image. ROUTINE 2 dbl_s1_e = fexpand(read_hi(dbl_s1)); dbl_s2_e = fexpand(read_hi(dbl_s2)); dbl_tmp2 = fsub16(dble_s2_e, dbl_s1_e); dbl_tmp1 = fmu18x16(read_hi(quad_a), dbl_tmp_2); dbl_sum1 = fpadd16(dbl_s1_e, dbl_tmp1); dbl_s1_e = fexpand(read_lo(dbl_s1)); dbl_s2_e = fexpand(read_lo(dbl_s2)); dbl_tmp2 = fsub16(dble_s2_e, dbl_s1_e); dbl_tmp1 = fmu18x16(read_lo(quad_a), dbl_tmp_2); dbl_sum2 = fpadd16(dbl_s1_e, dbl_tmp1); dbl_d = freg_pair(fpack16(dbl_sum1, dbl_sum2) The functions of the various instructions in routine 2 to calculate the pixel values in the destination image will now be described. The variables dbl_s1 , dbl_s2 , and quad_a are all 8-byte words including 8 pixel values. As will be described more fully above, each byte may be a complete pixel value or a band in a multiple band pixel. Fig. 10 depicts the modifications to the word components for each operation in the routine. As depicted in Fig. 10, the function of fexpand(read_hi(dbl_s1) is to expand the upper 4-bytes of dbl_s1 into a 64 bit word having 4 16-bit partitions to form dbl_s1_e . Each 16-bit partition includes 4 leading 0's, the a corresponding byte from dbl_s1 and 4 trailing 0's. The variable dbl_s2_e used to calculate dbl- sum1 is similarly formed and the variables dbl_s1_e and dbl_s2_e used to calculate dbl_sum2 are formed by expanding the lower 4 bytes of the corresponding variables. The function of fsub16(dbl_s2_, dbl_s1_e) is to calculate the value (src2 - src1). This instruction performs partitioned subtraction on the 4 16-bit components of dbl_s2 and dbl_s1 to form dbl_tmp2. The function of fmu18x16(read_hi(quad_a, dbl_tmp2)) is to calculate the value α/256*(src2 - srcl). This instruction performs partitioned multiplication of the upper 4 bytes of quad_a and the 4 16-bit components of dbl_tmp2 to form a 24-bit result and truncates the lower 8 bits to form a 16 bit result. Note that the upper 4 bits of each 16 bit component of dbl-tmp2 are 0's, because of the fexpand operation, the lower 4 bits of the 24 bit product are also 0's. The middle 16 bits are the result of multiplying the byte expanded from dbl-s1 and the corresponding byte from quad_a to form the product of α*(src2 - srcl). Thus, the truncation of the lower 8 bits removes the lower 4 0's, resulting from the previous expansion, and the lower 4 bits of the product to effect division by 256 to form dbl_tmp1 equal to α/256*(src2 - srcl). The function of fpadd16(dbl_s1_e, dbl_tmp1) is to calculate α/256*(src2 - src1) + src2. This instruction performs partitioned addition on the 16-bit components of its arguments. The function of freg_pair(pack16(dbl_sum1, pack 16(dbl_sum2) is to return an 8-byte (64 bits) including 8 pixel values of the destination image. The instruction fpack16 packs each 16-bit component into a corresponding 8-bit component by left-shifting the 16-bit component by an amount specified in the GSR register and truncating to an 8-bit value. Thus, the left shift removes the 4 leading 0's and the lower bits are truncated to return the 8 significant bits of the destination in each of the 4 components. The function of freg-pair is to join the two packed 32 bit variables into a 64-bit variable. 2. Pixel Length of Src1, Src2, and Control Image is 16 bits. For 16 bits a second routine is utilized which takes into account different requirements of precision. ROUTINE 2A dbl_halfshort = 0x80008000 dbl_mask_255 = 0x00ff00ff compute (1 -r)*s1 dbl_a = fsub16(dbl_a, dbl_halfshort); (void) alignaddr(d_aligned, seven); dbl_tmp1 = faligndat(dbl_mask_255, dbl_a); dbl_tmp2 = fand(dbl_tmp1, dbl_mask_255); flt_hi = fpack16(dbl_tmp2); dbl_tmp2 = fmul8ulx16(dbl_a, dbl_s1); dbl_tmp1 = fmul8x16(flt_hi, dbl_s1); dbl_sum2 = fpadd16(dbl_tmp1, dbl_tmp2); dbl_sum1 = fpsub16(sbl_s1, dbl_sum2); compute r*s2 dbl_tmp2 = fmul8ulx16(dbl_a, dbl_s2); dbl_tmp1 = fmul8x16(flt_hi_a, dbl_s2); dbl_sum2 = fpadd(dbl_tmp1, dbl_tmp2); dbl_d = fpadd16(dbl_sum1, dbl_sum2); Except for fmu18ulx16 and fand the operations in routine 2A are the same as in routine 2 modified to operate on 16 bit components. The description of the functions of those operations will not be repeated. The function of fmul18ulx16(dbl_a, dbl_s2) is to perform it to perform a partitioned multiplication the unsigned lower 8 bits of each 16-bit component in the arguments and return the upper 16 bits of the result for each component as 16-bit components of dbl-tmp2. The function of fand(dbl_tmp1, dbl_mask_255) is to perform a logical AND operation on the variables defined by the arguments. Storing the Misaligned Destination Image Data 1. Loading Utilizing an Edge Mask and Partial Instruction. The following routine calculates an edge mask and utilizes a partial store operation to store the destination image data where d is a pointer to the destination location, d_aligned is the aligned address which immediately precedes d , and width is the width of a destination word. ROUTINE 3 d_end = d + width - 1; emask = edge_8(d, d_end); pst_8(dbl_d, (void *)d_aligned, emask); ++d_aligned; emask = edge8(d_aligned, d_end); The function of emask is to generate a mask for storing unaligned data. For example, if the destination data is to be written to address 0x10003, and the previous aligned address in 0x10000, then the emask will be [00011111] and the pst instruction will start writing at address 0x10000 and emask will disable writes to 0x10000, 0x10001, and 0x10002 and enable writes to 0x10003-0x10007. Similarly, after emask is incremented the last part of dbl_d is written to the 0x10008, 0x10009, and 0x1000A and the addresses 0x1000B-0x1000F will be masked.

Claims: A method of alpha blending images to generate a destination image, using a computer (1), comprising the steps of: loading a first word, comprising a plurality of first word components into a processor (140) in parallel, each first word component associated with a source I pixel of a first source image; loading a second word, comprising a plurality of second word components into a processor in parallel, each second word component associated with a source 2 pixel of a second source image; loading a third word, comprising a plurality of third word components into a processor in parallel, each third word component associated with a control pixel of a control image and having a fixed number of control bits; alpha blending the first, second, and third components of said first, second, and third words in parallel to generate fourth word components of a fourth word, with the fourth word components of said fourth word associated with a destination pixel of an alpha blended destination word; and storing the fourth word components of said fourth word to an unaligned area of a memory in parallel, wherein said step of alpha blending utilizes predefined partitioned add, multiply, and subtract operations to operate on the first, second, and third components of said first, second, and third words in parallel. The method of claim 1 wherein: said step of alpha blending, further comprises arithmetically combining said source 1, source 2, and control pixels, according to a predetermined formula, to generate the destination pixel. The method of claim 2, further comprising: specifying a number of bits for each of said source 1, source 2, control, and destination pixels; and reordering operations and terms of said predetermined formula, when said operations use a number of bits less than a number of bits of one of said pixels, to achieve the specified number of bits for the destination pixel and increase efficiency of said alpha blending step. The method of claim 1 wherein any one of said words is stored in a memory (104) at a boundary that is unaligned with the addresses of said memory. The method of claim 4, further comprising, for each unaligned word, the steps of: generating an aligned address for said unaligned address; calculating an offset being the difference between said aligned address and said unaligned address; utilizing said unaligned address and said offset to load the word from the memory identified by the unaligned address; expanding each component of said plurality of first word components of said first word into a corresponding first plurality of expanded pixels, each expanded pixel of said first plurality of expanded pixels having equal numbers of leading and trailing zeros, said first plurality of expanded pixels comprising a first expanded word; expanding each component of said plurality of second word components of said second word into a corresponding second plurality of expanded pixels, each expanded pixel of said second plurality of expanded pixels having equal numbers of leading and trailing zeros, said second plurality of expanded pixels comprising a second expanded word; performing a partitioned subtraction operation by a subtracting expanded pixels of the first plurality of expanded pixels from corresponding expanded pixels of the second plurality of expanded pixels in parallel, to form an expanded difference word having expanded difference components; performing a partitioned multiplication function by multiplying said expanded difference components by corresponding third word components of said third word to form an expanded product word comprised of expanded product components having the same number of leading zeros as said expanded pixels and having said fixed number of least significant control bits truncated to effect division by 2 raised to the power of said fixed number; performing a partitioned sum of said expanded product word and said first expanded word to form a first expanded halfword of said destination image comprising expanded destination components; and packing said expanded destination components of said expanded halfword to form a subset of the pixels of said destination word. The method of claim 4, further comprising, for each unaligned word, the steps of: generating an aligned address for said unaligned address; calculating an offset being the difference between said aligned address and said unaligned address; utilizing said unaligned address and said offset to load a word from said unaligned image; defining first and second constants equal to 0x80008000 and 0x00ff00ff respectively; performing a partitioned subtraction operation to subtract corresponding components of said first constant from said components in said third word of said control image in parallel to form a first difference word; returning an aligned data word comprising components of said second constant and components of said first difference word; performing a logical AND operation of corresponding components of said aligned data word and said second constant to generate a logical result word; performing a partitioned packing operation of said logical result word to form a packed logical result word; performing a partitioned multiplication of said third word of said control image and said first word of said first source image to form a first resulting product word; performing a partitioned multiplication of said packed logical result word and said first word of said first source image to form a second resulting product word; performing a partitioned add operation on said first and second resulting product words to form a first sum word; performing a partitioned multiplication of said third word of said control image and said second word of said second source image to form a third resulting product word; performing a partitioned multiplication of said packed logical result word and said second word of said second source image to form a fourth resulting product word; performing a partitioned add operation on said third and fourth resulting product words to form a second sum word; performing a partitioned add operation of said first and second sum words to form said first destination word; computing an edge mask to store said destination word to said unaligned destination image; and utilizing said edge mask to perform a partial store of said destination word to said unaligned destination image. An apparatus for forming a composite image by alpha blending two digital images, the apparatus comprising: means (148) for loading a first word into a data processor, the first word comprising a plurality of first word components, each first word component associated with a source 1 pixel of a first source image; means (148) for loading a second word into the data processor, the second word comprising a plurality of second word components, each second word component associated with a source 2 pixel of a second source image; means (148) for loading a third word into the data processor, the third word comprising plurality of third word components, each third word component associated with a control pixel of a control image; means (160, 162) for alpha blending the first, second and third components of said first, second, and third words in parallel to generate fourth word components of a fourth word, with the fourth word components of said fourth word associated with a destination pixel of a blended destination word; and means (148) for storing the fourth word components of said fourth word to an unaligned area of a memory (104) in parallel, wherein said means for blending utilizes predefined partitioned add, multiply, and subtract operations to operate on the first, second and third components of said first, second, and third words in parallel. The apparatus as claimed in claim 7, characterised in that the composite image is a destination image and any one of said images is an unaligned image stored in a memory (104) having boundaries unaligned with the addresses of said memory and where said images comprise words including multiple pixels, and with each pixel in said control image comprising a control pixel number of bits, and wherein if one of said images is an unaligned image the apparatus is further arranged to generate an aligned address immediately preceding an unaligned address of a first word in said unaligned image to calculate an offset being the difference between said aligned address and said unaligned address; and to utilize said unaligned address and said offset to load a word from said unaligned image. The apparatus as claimed in claim 8, characterised by being further arranged: to expand a subset of the pixels in the first word of said first and second source images into expanded pixels having equal numbers of leading and trailing zeros to form an expanded first word including said expanded pixels; to perform a partitioned subtraction operation to subtract corresponding expanded pixels in said first expanded words of said first and second source images to form an expanded difference word including expanded difference components; to perform a partitioned multiplication of corresponding pixels in said first word of said control image and said corresponding expanded difference components to form an expanded product word comprising expanded product components, with each expanded product component including the same number of leading zeros as said expanded pixel and having said control pixel number of least significant bits truncated to effect division by 2 raised to the power of said control pixel number; to perform a partitioned sum of said expanded product word and said first expanded word of said first source image to form a first expanded halfword of said destination image comprising expanded destination components; and to pack said destination components of said expanded halfword to form a subset of the pixels of said destination word. The apparatus as claimed in claim 7, characterised in that any one of said images is an unaligned image stored in a memory having boundaries unaligned with the addresses of said memory and where said images comprise words including multiple pixels, and with each pixel in said control image comprising a control pixel number of bits, the apparatus being arranged if one of said images is an unaligned image: to generate an aligned address immediately preceding an unaligned address of a first word in said unaligned image; to calculate an offset being the difference between said aligned address and said unaligned address; and to utilize said unaligned address and said offset to load a word from said unaligned image. An apparatus as claimed in claims 7 or 10, characterised in being arranged to: define first and second constants equal to 0x80008000 and 0x00ff00ff respectively; to perform a partitioned subtraction operation to subtract corresponding components of said first constant from said components in said third word of said control image in parallel to form a first difference word; to return an aligned data word comprising components of said second constant and components of said first difference word; to perform a logical AND operation of corresponding components of said aligned data word and said second constant to generate a logical result word; to perform a partitioned packing operation of said logical result word to form a packed logical result word; to perform a partitioned multiplication of said first word of said control image and said first word of said first source image to form a first resulting product word; to perform a partitioned multiplication of said packed logical result word said first word of said first source image to form a second resulting product word; to perform a partitioned add operation on said first and second resulting product words to form a first sum word; to perform a partitioned multiplication of said first word of said control image and said first word of said second source image to form a third resulting product word; to perform a partitioned multiplication of said packed logical result word and said first word of said second source image to form a fourth resulting product word; to perform a partitioned add operation on said third and fourth resulting product words to form a second sum word; to perform a partitioned add operation of said first and second sum words to form said first destination word; to compute an edge mask to store said destination word to said unaligned destination image; and to utilize said edge mask to perform a partial store of said destination word to said unaligned destination image. A computer program product comprising: a computer usable medium having computer readable code therein for: alpha blending images to generate a destination image, using a computer (1), comprising computer readable code devices configured to effect: loading a first word, comprising a plurality of first word components into a processor (140) in parallel, each first word component associated with a source 1 pixel of a first source image; loading a second word, comprising a plurality of second word components into a processor in parallel, each second word component associated with a source 2 pixel of a second source image; loading a third word, comprising a plurality of third word components into a processor in parallel, each third word component associated with a control pixel of a control image and having a fixed number of control bits; alpha blending the first, second, and third components of said first, second, and third words in parallel to generate fourth word components of a fourth word, with the fourth word components of said fourth word associated with a destination pixel of an alpha blended destination word; and storing the fourth word components of said fourth word to an unaligned area of a memory in parallel, wherein said step of alpha blending utilizes predefined partitioned add, multiply, and subtract operations to operate on the first, second, and third components of said first, second, and third words in parallel. The computer program product of claim 12 where any one of said images is an unaligned image stored in a memory (104) having boundaries unaligned with the addresses of said memory, the computer program product further comprising computer readable code devices configured to effect: generating an aligned address immediately preceding an unaligned address of a first word in said unaligned image; calculating an offset being the difference between said aligned address and said unaligned address; utilizing said unaligned address and said offset to load a word from said unaligned image; expanding a subset of the pixels in each pixel word component of a loaded first word of said first and second source images into expanded pixel word components having equal numbers of leading and trailing zeros to form an expanded first word including said fixed number of pixels; performing a partitioned subtraction operation to subtract corresponding expanded pixel word components in said first expanded words of said first and second source images to form an expanded difference word including expanded difference components; performing a partitioned multiplication of each corresponding pixel word component in said first word of said control image and each corresponding expanded difference pixel word component of said expanded difference word to form expanded product word components of an expanded product word, with each expanded product word component including the same number of leading zeros as said expanded pixel and having said fixed number of least significant bits truncated to effect division by 2 raised to the power of said fixed number, performing a partitioned sum of said expanded product word and said first expanded word of first source image to form a first expanded halfword of said destination image comprising expanded destination components; and packing said destination components of said expanded halfword to form a subset of the pixel word components of said destination word.

Inventors: HU XIAO PING, HU, XIAO PING
Applicants: SUN MICROSYSTEMS INC, SUN MICROSYSTEMS, INC.
Application year: 1996
Main classification: G06T15
IPC codes: G06T13, G06F9, G06T3, G06T1, G06T15, H04N1