CN102281382A - Method and system for converting YUV420 image into RGB565 image - Google Patents

Method and system for converting YUV420 image into RGB565 image Download PDF

Info

Publication number
CN102281382A
CN102281382A CN2011102782921A CN201110278292A CN102281382A CN 102281382 A CN102281382 A CN 102281382A CN 2011102782921 A CN2011102782921 A CN 2011102782921A CN 201110278292 A CN201110278292 A CN 201110278292A CN 102281382 A CN102281382 A CN 102281382A
Authority
CN
China
Prior art keywords
convergent
divergent
yuv420
component
image block
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN2011102782921A
Other languages
Chinese (zh)
Inventor
张磊
邓邹平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Temobi Science and Technology Co Ltd
Original Assignee
Shenzhen Temobi Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Temobi Science and Technology Co Ltd filed Critical Shenzhen Temobi Science and Technology Co Ltd
Priority to CN2011102782921A priority Critical patent/CN102281382A/en
Publication of CN102281382A publication Critical patent/CN102281382A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Image Processing (AREA)

Abstract

The invention discloses a method and a system for converting a YUV420 image into an RGB565 image. The method comprises the following steps of: equally dividing the original YUV420 image into original YUV420 image blocks, performing scaling to acquire U components and V components of the scaled YUV420 image blocks, calculating red, green and blue (rgb) values, determining whether to rotate according to the size of the YUV420 image and the size of a mobile terminal screen, and respectively writing the rgb values into a target address. Therefore, continuous scaling, rgb value calculation, rotation or non-rotation and then output are performed on each original YUV420 image block, the frequency of cycle and the number of accessed memories are reduced, the conversion efficiency is improved, and the output RGB565 image can be displayed at mobile terminals of different pixels; and the original YUV420 image is equally divided into the original YUV420 image blocks of different equal proportions and different scaling proportions, so that the optimal displaying effect is achieved, and the access speed of the memories is quickened.

Description

A kind of YUV420 image transitions becomes the method and system of RGB565 image
Technical field
The present invention relates to the video playback field, relate in particular to the method and system that a kind of YUV420 image transitions becomes the RGB565 image.
Background technology
The YUV420 image file that the Video Decoder direct decoding generates in the prior art can not directly show in many portable terminals, must convert RGB565 to through YUV420 could show, in addition, the many mobile terminal screen pixels and the size of video image are inconsistent, cause portable terminal when showing RGB565, a lot of white spaces can occur, reduced user's experience effect, for example the pixel of the size of video image is 240x180, and mobile terminal screen is 240x320, cause the portable terminal can be when showing the video file of RGB565 form so last, a lot of white spaces appear in following two ends, this just need do convergent-divergent before the portable terminal display video, rotation, the operating procedure of color conversion (promptly calculating the rgb value), because of the YUV420 image is being done convergent-divergent, when rotation and color conversion, each operating procedure all needs through 2 circulations, the cycle-index that adds up like this is many, and the circulation in per step all needs access memory again, efficient is low, for the 240x180YUV420 image transitions becomes pixel for the 320x240RGB565 image is an example, need the 320*240*5/4=115200 byte of memory with the pixel usually.
Summary of the invention
The purpose of the embodiment of the invention is to propose the method that a kind of YUV420 image transitions becomes the RGB565 image, being intended to solve the YUV420 image file that the Video Decoder direct decoding generates in the prior art can not directly show in many portable terminals, must become the RGB565 image through the YUV420 image transitions, and when showing, portable terminal has white space after being directly changed into the RGB565 image, reduced user's experience effect, must before becoming the RGB565 image, the YUV420 image transitions do convergent-divergent, rotation, the operating procedure of color conversion (promptly calculating the rgb value), because of the YUV420 image is being done convergent-divergent, when rotation and color conversion, each operating procedure all needs through 2 circulations, the cycle-index that adds up like this is more, the access memory amount increases, the wasting of resources, and efficient is low.
The embodiment of the invention is achieved in that a kind of YUV420 image transitions becomes the method for RGB565 image, may further comprise the steps:
Original YUV420 image is divided at least one original YUV420 image block; And preset the convergent-divergent multiple of the horizontal direction and the vertical direction of described original YUV420 image;
According to the convergent-divergent multiple of the horizontal direction and the vertical direction of described original YUV420 image, filtering interpolation generates the YUV420 image block behind the convergent-divergent;
According to Y component, U component and the V component of the YUV420 image block behind the described convergent-divergent, calculate the rgb value, according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size, determine whether rotation and respectively described rgb value is write destination address.
Another purpose of the embodiment of the invention is to propose the system that a kind of YUV420 image transitions becomes the RGB565 image, and described system comprises:
Described initial module links to each other with described Zoom module, is used for original YUV420 image is divided at least one original YUV420 image block, and presets the convergent-divergent multiple of the horizontal direction and the vertical direction of described original YUV420 image;
Described Zoom module links to each other with described output module with described initial module respectively, is used for the convergent-divergent multiple according to the horizontal direction and the vertical direction of described original YUV420 image, and filtering interpolation generates the YUV420 image block behind the convergent-divergent;
Described output module links to each other with described Zoom module, be used for Y component, U component and V component according to the YUV420 image block behind the described convergent-divergent, calculate the rgb value, according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size, determine whether rotation and respectively described rgb value is write destination address.
Beneficial effect of the present invention:
By original YUV420 image is divided into original YUV420 image block, original YUV420 image block is carried out convergent-divergent, obtain the Y component of YUV420 image block, U component and V component, calculate rgb value (being color conversion), determine whether that according to YUV420 size of images and mobile terminal screen size rotation writes destination address to the rgb value respectively, thereby realize each original YUV420 image block is done convergent-divergent continuously, calculate rgb value and output, the number of times of circulation and the quantity of access memory have been reduced, improved conversion efficiency, the RGB565 image of output can show at the portable terminal of different pixels, by original YUV420 image being divided into the original YUV420 image block and different scalings of branch ratios such as difference, reach best display effect, reduce the internal memory use amount, the locality that keeps data simultaneously, the rapid memory access speed.
Description of drawings
Fig. 1 becomes the structure chart of original YUV420 image in the preferred embodiment of method of RGB565 image for YUV420 image transitions of the present invention;
Fig. 2 is the structure chart of the YUV420 image block behind the original YUV420 image block A convergent-divergent among Fig. 1;
The structure chart of 4 Y components, 1 U component and 1 V component that preceding two pixels of the YUV420 image block of Fig. 3 after for convergent-divergent among Fig. 2 comprise;
Fig. 4 is that the RGB565 image block of YUV420 correspondence among Fig. 3 rotates the structure chart of the target location of output;
Fig. 5 is the structure chart of target location of the non-rotating output of RGB565 image block of YUV420 correspondence among Fig. 3;
Fig. 6 becomes the flow chart of first preferred embodiment of RGB565 image method for YUV420 image transitions of the present invention;
Fig. 7 becomes the flow chart of second preferred embodiment of RGB565 image method for YUV420 image transitions of the present invention;
Fig. 8 becomes the structural representation of first preferred embodiment of RGB565 picture system for YUV420 image transitions of the present invention;
Fig. 9 becomes the structural representation of second preferred embodiment of RGB565 picture system for YUV420 image transitions of the present invention.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated, for convenience of explanation, only show the part relevant with the embodiment of the invention.Should be appreciated that the specific embodiment that this place is described, only be used to explain the present invention, not in order to restriction the present invention.
The present invention is by being divided into original YUV420 image block to original YUV420 image, original YUV420 image block is carried out convergent-divergent, obtain the Y component of YUV420 image block, U component and V component, calculate rgb value (being color conversion), determine whether rotation and respectively the rgb value is write destination address according to YUV420 size of images and mobile terminal screen size, thereby realize each original YUV420 image block is done convergent-divergent continuously, calculate rgb value and output (comprising rotation), the number of times of circulation and the quantity of access memory have been reduced, improved conversion efficiency, the RGB565 image of output can show at the portable terminal of different pixels, by original YUV420 image being divided into the original YUV420 image block and different scalings of branch ratios such as difference, reach best display effect, reduce the internal memory use amount, the locality that keeps data simultaneously, the rapid memory access speed.
Embodiment one
Fig. 6 becomes the flow chart of first preferred embodiment of RGB565 image method for YUV420 image transitions of the present invention.Said method comprising the steps of:
S601 is divided at least one original YUV420 image block with original YUV420 image; And preset the convergent-divergent multiple Fx of image level direction of original YUV420 and the convergent-divergent multiple Fy of vertical direction;
The horizontal direction convergent-divergent multiple Fx=Ns_x/Ds_x of described original YUV420 image, the vertical direction convergent-divergent multiple Fy=Ns_y/Ds_y of described original YUV420 image;
Wherein Ns_x, Ds_x, Ns_y and Ds_y are that positive integer and value satisfy condition: become convergent-divergent multiple relation, and be positive integer, simultaneously, (2*Ds_x) * (Ns_x/Ds_x) equals the width tx of the YUV420 image block behind the convergent-divergent, and (2*Ds_y) * (Ns_y/Ds_y) equals the height t y of the YUV420 image block behind the convergent-divergent; Based on convergent-divergent multiple and the effect that needs convergent-divergent to present the YUV420 image is divided at least one YUV420 image block, each YUV420 image block is made up of pixel;
For ease of understanding, to amplify 2 times is the example explanation, be illustrated in figure 1 as the structure chart of original YUV420 image, the height of original YUV420 image and width are respectively H, W, original YUV420 image is divided at least one original YUV420 image block, and as original YUV420 image block A, B, C among Fig. 1, the pixel that presets each original YUV420 image block is 4x4, the height t y and the width tx that are original YUV420 image block are 4,4 corresponding 1 U components of Y component and a V component in each image block; Preset Ns_x=4, Ds_x=2, Ns_y=4, Ds_y=2, Fx and Fy person are 2;
S602, according to the described convergent-divergent multiple that presets original YUV420 image level and vertical direction, filtering interpolation generates the YUV420 image block behind the convergent-divergent;
Described filtering interpolation for example becomes the image of 4 somes the image of 8 points, and each puts how value becomes the process of 8 some best results filtering interpolation so;
For ease of understanding, to amplify 2 times is the example explanation, Figure 2 shows that the structure chart of the YUV420 image block behind the original YUV420 image block A convergent-divergent, pixel was 8x8 after original YUV420 image block A amplified 2 times, as shown in Figure 2, comprise Y component 1-64, wherein the width of scaled images piece is tx, the height t y of scaled images piece;
S603 obtains Y component, U component and the V component of the YUV420 image block behind the convergent-divergent, calculates rgb value, according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size, determines whether to rotate and respectively the rgb value is write destination address;
If rotation, then the width of RGB565 image equals the height of original YUV420 image block, and the height of the YUV420 image behind the convergent-divergent becomes the width of RGB565 image;
Described rgb value can be done the value of color conversion by external function, and described external function is get_rgb16_value_clip_rgb ().
In the present embodiment by original YUV420 image being divided at least one original YUV420 image block, original YUV420 image block is carried out convergent-divergent, obtain the Y component of YUV420 image block, U component and V component, calculate the rgb value, determine whether that according to YUV420 size of images and mobile terminal screen size rotation writes destination address with the rgb value respectively, thereby realize each original YUV420 image block is done convergent-divergent continuously, calculate rgb value and output (comprising rotation), the number of times of circulation and the quantity of access memory have been reduced, improved conversion efficiency, the RGB565 image of output can show at the portable terminal of different pixels, by original YUV420 image being divided into the original YUV420 image block and different scalings of branch ratios such as difference, reach best display effect, reduce the internal memory use amount, the locality that keeps data simultaneously, the rapid memory access speed.
Embodiment two
Fig. 7 becomes the flow chart of second preferred embodiment of RGB565 image method for YUV420 image transitions of the present invention.Said method comprising the steps of:
S701 presets Y, U, the V component of original YUV420 image, and original YUV420 image is divided into the YUV420 image block of at least one; Preset the horizontal direction convergent-divergent multiple Fx and the vertical direction convergent-divergent multiple Fy of YUV420 image; Preset the convergent-divergent buffering area, be used to deposit Y component, U component and the V component of the YUV420 image block behind the convergent-divergent, quote by variable Y t, Ut and Vt respectively; Preset cyclic variable x, y, x1, y1, i, j, be initially 0;
Preset the first address pointer rgb of destination address of RGB565 image and the pointer p of the destination address that current RGB565 image block is deposited, all be defined as the short* type; Preset output coordinate variable x2, the y2 of RGB565 image block;
The horizontal direction convergent-divergent multiple Fx=Ns_x/Ds_x of described YUV420 image, the vertical direction convergent-divergent multiple Fy=Ns_y/Ds_y of described YUV420 image;
Wherein Ns_x, Ds_x, Ns_y and Ds_y are that positive integer and value satisfy condition: become convergent-divergent multiple relation, and be positive integer, simultaneously, (2*Ds_x) * (Ns_x/Ds_x) equals the width tx of the YUV420 image block behind the convergent-divergent, and (2*Ds_y) * (Ns_y/Ds_y) equals the height t y of the YUV420 image block behind the convergent-divergent; Based on convergent-divergent multiple and the effect that needs convergent-divergent to present the YUV420 image is divided at least one YUV420 image block, each YUV420 image block is made up of pixel;
The first address of the destination address that described first address pointer rgb record RGB565 image block need be deposited, the pointer p of the destination address that described current RGB565 image block is deposited writes down the destination address that current RGB565 image block is deposited;
For ease of understanding, to amplify 2 times is the example explanation, be illustrated in figure 1 as the structure chart of original YUV420 image, the height and the width of original YUV420 image are respectively H, W, original YUV420 image is divided into more than one original YUV420 image block, as the original YUV420 image block A among Fig. 1, B, C, the pixel that presets each original YUV420 image block is 4x4, the height and the width that are original YUV420 image block all are 4, and 4 corresponding 1 U components of Y component and a V component preset Ns_x=4 here in each image block, Ds_x=2, Ns_y=4, Ds_y=2, Fx and Fy are 2; Figure 2 shows that the structure chart of the YUV420 image block behind the original YUV420 image block A convergent-divergent, pixel was 8x8 after original YUV420 image block A amplified 2 times, as shown in Figure 2, comprised Y component 1-64, wherein the width of scaled images piece is tx, the height t y of scaled images piece; Described preset the convergent-divergent buffering area be:
char_YUV420_zoom_tmp[3][(2*Ns_x)*(2*Ns_y)];
Described cyclic variable x, y represent the coordinate of the horizontal direction and the vertical direction of original image, and in cyclic process, x, y are the step value stepping with 2*Ds_x, 2*Ds_y respectively; Described cyclic variable x1, y1 represent the level and the vertical direction coordinate of the YUV420 image behind the convergent-divergent, and in cyclic process, x1, y1 are the step value stepping with 2*Ns_x, 2*Ns_y respectively;
Described RGB565 image block output coordinate variable x2, y2, expression be the horizontal coordinate and the vertical coordinate of RGB565 image block output;
For ease of understanding, to amplify 2 times is the example explanation, x, y is respectively with 2*Ds_x=2*2=4, the 2*Ds_y=2*2=4 stepping, promptly each Y component of handling 4 pixels, the U component of 1 pixel and the V component of 1 pixel, as shown in Figure 2, handle preceding 2 pixels earlier, corresponding Y component is 1,2,9,10 (wherein comprising the U component of 1 pixel and the V component of 1 pixel), handle back 2 pixels again, corresponding Y component is 3,4,11,12 (wherein comprising the U component of 1 pixel and the V component of 1 pixel), still handle for the second time 4 pixels, promptly at first handle preceding 2 pixels, corresponding Y component is 5,6,13,14 (wherein comprising the U component of 1 pixel and the V component of 1 pixel) and handle back 2 pixels again, corresponding Y component is 7,8,15,16 (wherein comprising the U component of 1 pixel and the V component of 1 pixel), the piecemeal of 4*4 size is entered convergent-divergent, the rgb conversion, rotation output is up to disposing;
Further also need to calculate height t y and width tx, Y component line-spacing stride_t, U component line-spacing and the V component line-spacing of the YUV420 image block after the width W 1, height H 1, convergent-divergent of the YUV420 image behind the convergent-divergent; Calculate the width W 2 of RGB565 image and the first address pointer rgb of destination address; Calculate line-spacing stride_d, the side-play amount offset of RGB565 image block and the pointer p of the destination address that current RGB565 image block writes;
The width W 1 of the YUV420 image behind the described convergent-divergent and height H 1 are: W1=W*Fx, H1=H*Fy;
For ease of understanding, be the example explanation to amplify 2 times, after original YUV420 image amplified 2 times described in the structure chart of original YUV420 image as shown in Figure 1, the height and the width of the YUV420 image behind the convergent-divergent were respectively 2H and 2W;
The Y component line-spacing stride_t of the YUV420 image behind the described convergent-divergent determines according to concrete convergent-divergent multiple, i.e. the number of every capable pixel of the YUV420 image behind the convergent-divergent; The U component line-spacing of the YUV420 image behind the described convergent-divergent and V component line-spacing are 1/2nd of stride_t; To amplify 2 times is the example explanation, Y component line-spacing stride_t=8, and U component line-spacing and V component line-spacing are 1/2nd of stride_t, promptly all are 4;
The method of the width W 2 of described calculating RGB565 image is:
If rotation, W2=H1 then, the width of RGB565 image equals the height of original YUV420 image block, and the height of the YUV420 image behind the convergent-divergent becomes the width of RGB565 image;
If do not rotate, W2=W1 then;
The computational methods of the line-spacing stride_d of described RGB565 image block are: stride_d=W2;
The height t y of the YUV420 image block behind the described convergent-divergent and width tx are the vertical direction of the YUV420 image block behind the convergent-divergent and the number of horizontal direction pixel;
The current goal address of described calculating RGB565 image is specially with respect to the side-play amount offset of image first address:
If rotation, offset=0*W2+ (W2-1);
If do not rotate, then: offset=0;
Described offset is the side-play amount of current goal address with respect to the image first address;
The first address rgb of the destination address of described RGB565 image is offset*2 (each pixel accounts for 2 bytes);
The pointer p+=offset*2 of the destination address that described current RGB565 image block is deposited;
This three's of pointer p of the destination address that the first address rgb of the destination address of described RGB565 image, RGB565 image block address offset amount offset and current RGB565 image block are deposited relation is: rgb is the first address of the RGB565 image of output, only need to calculate once, offset is to be that skew is done by unit with the pixel, and it is the OPADD p of current RGB565 image block of skew with the byte that rgb+offset*2 has just obtained.RGB565 image block of every output, the pointer p of the destination address that current RGB565 image block is deposited needs to be skew, i.e. rgb+offset*2;
S702 judges whether y<H, if, then enter step S703, if not, then enter step S719;
S703 judges whether x<W, if, then enter step S705, if not, then enter step S704;
S704, cyclic variable y and y1 do stepping, and x resets to 0, enters step S702;
Described cyclic variable y and y1 do stepping, are specially: y+=(2*Ds_y), y1+=(2*Ns_y);
S705, according to the described convergent-divergent multiple that presets original YUV420 image level and vertical direction, filtering interpolation generates the YUV420 image block behind the convergent-divergent, and deposits the convergent-divergent buffering area;
Wherein the width of the YUV420 image block behind the convergent-divergent is tx, and the height of the YUV420 image block behind the convergent-divergent is ty;
For ease of understanding, to amplify 2 times is the example explanation, as Fig. 1, original YUV420 image block A pixel is 4x4, as shown in Figure 2, pixel is 8x8 after amplifying 2 times, y and y1 are with step value y+=4, the y1+=8 stepping, YUV420 image block behind the convergent-divergent is stored in convergent-divergent buffering area YUV420_zoom_tmp[3] in, Yt=YUV420_zoom_tmp[0], Ut=YUV420_zoom_tmp[1], Vt=YUV420_zoom_tmp[2], quote Y component, U component, V component in the convergent-divergent buffering area respectively with Yt, Ut and Vt respectively; Tx and the ty of this moment are respectively 8, preset the row span that t_stride represents the convergent-divergent buffering area, and t_stride is tx in this example;
S706, calculating i are each redirect 2 row of the YUV420 image block vertical direction behind the convergent-divergent number of times of redirect altogether, and calculating j is the number of times of 4 the pixel coprocessing of the each processing of YUV420 image block horizontal direction behind the convergent-divergent;
Be i=ty/2, j=tx/4, described i=ty/2, a redirect of expression vertical direction 2 row, so ty divided by 2, is the example explanation to amplify 2 times, i=4;
Described j=tx/4,4 pixels of expression horizontal direction single treatment, so tx divided by 4, is the example explanation to amplify 2 times, j=2;
S707 judges whether rotation, if, then enter step S708, if not, then enter step S713;
Described judgement is to determine whether that according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size rotation writes the rgb value;
S708, the coordinate of RGB565 image block output and the coordinate of the YUV420 image block behind the convergent-divergent exchange, and with the pointer p definite object address of destination address, are specially:
x2=-y1,y2=x1,p=&rgb[(y2*stride_d+x2)*2];
Because rotate, the YUV420 image block of the horizontal direction behind the convergent-divergent calculates rgb value back and exports according to order from right to left, so need exchange x1, y1;
For ease of understanding, be the example explanation to amplify 2 times, coordinate exchange process as shown in Figure 3 and Figure 4;
S709 obtains the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculates rgb value, writes the pointer p of destination address respectively according to order from right to left, and the while, j subtracted 1, was specially:
Obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing, and calculate the rgb value, write the pointer p of destination address according to order from right to left respectively; Obtain the U component and the V component of latter two pixel in 4 pixels of described each processing, and calculate rgb value, write the pointer p of destination address respectively according to order from right to left, the while, j subtracted 1;
When writing the pointer p of destination address here, the pointer p and the Yt of described destination address will do skew at every turn, i.e. p+=2*stride_d, Yt+=2;
For ease of understanding, to amplify 2 times is the example explanation, as shown in Figure 3, here U component that obtains and V component are Y component Y1, Y2, Y9, the pairing U1 component of Y10 and V1 component, write destination address R1 and R2 after, pointer p, the Yt of destination address will do skew, after writing destination address R9 and R10, pointer p, the Yt of destination address also will do skew, i.e. p+=2*stride_d, Yt+=2;
Described U component and the V component that obtains preceding two pixels in 4 pixels of described each processing, and calculate the rgb value, the process that writes the pointer p of destination address according to from right to left order respectively is specially:
p[0]=get_rgb16_value_clip_rgb(u,v,Yt[0]);
p[stride_d]=get_rgb16_value_clip_rgb(u,v,Yt[1]);
p[-1]=get_rgb16_value_clip_rgb(u,v,Yt[t_stride+0]);
p[-1+stride_d]=get_rgb16_value_clip_rgb(u,v,Yt[t_stride+1]);
Described get_rgb16_value_clip_rgb () is an external function, and this external function is finished the conversion of YUV420 to rgb565;
For ease of understanding, to amplify 2 times is the example explanation, the target location of R1, R2, R9, R10 output as shown in Figure 4, rotate the target location of output for the RGB565 image block of YUV420 correspondence among Fig. 3, that is described p[0 ,]=get_rgb16_value_clip_rgb (u, v, Yt[0]) expression obtains the rgb value of first Y component Y1 correspondence, writes the position of R1;
Described p[stride_d]=get_rgb16_value_clip_rgb (u, v, Yt[1]) expression obtains the rgb value of second Y component Y2 correspondence, writes the position of R2;
Described p[-1]=get_rgb16_value_clip_rgb (u, v, Yt[t_stride+0]) expression obtains the rgb value of the 3rd Y component Y9 correspondence, writes the position of R9;
Described p[-1+stride_d]=get_rgb16_value_clip_rgb (u, v, Yt[t_stride+1]) expression obtains the rgb value of the 4th Y component Y10 correspondence, writes the position of R10;
Described U component and the V component that obtains latter two pixel in 4 pixels of described each processing, and calculate the rgb value, the process that writes the pointer p of destination address according to from right to left order respectively is:
p[0]=get_rgb16_value_clip_rgb(u,v,Yt[0]);
p[stride_d]=get_rgb16_value_clip_rgb(u,v,Yt[1]);
p[-1]=get_rgb16_value_clip_rgb(u,v,Yt[t_stride+0]);
p[-1+stride_d]=get_rgb16_value_clip_rgb(u,v,Yt[t_stride+1]);
For ease of understanding, be the example explanation to amplify 2 times, R3, R4, R11, R12 write the position of destination address as shown in Figure 4, be described p[0]=get_rgb16_value_clip_rgb (u, v, Yt[0]) expression obtains the rgb value of first Y component Y3 correspondence, writes the position of R3;
Described p[stride_d]=get_rgb16_value_clip_rgb (u, v, Yt[1]) expression obtains the rgb value of second Y component Y4 correspondence, writes the position of R2;
Described p[-1]=get_rgb16_value_clip_rgb (u, v, Yt[t_stride+0]) expression obtains the rgb value of the 3rd Y component Y11 correspondence, writes the position of R11;
Described p[-1+stride_d]=get_rgb16_value_clip_rgb (u, v, Yt[t_stride+1]) expression obtains the rgb value of the 4th Y component Y12 correspondence, writes the position of R12;
Described U component and the V component that obtains preceding two pixels in 4 pixels of described each processing is to obtain from the convergent-divergent buffering area with the U component and the V component that obtain latter two pixel in 4 pixels of described each processing;
S710 judges whether j equals 0, if, then enter step S711, if not, then enter step S709;
S711 continues to obtain the next Y component of the YUV image block behind the convergent-divergent, and the pointer p of destination address is pointed to the destination address that described Y component will write, and i subtracts 1, calculates j and be the each number of times of handling 4 pixel coprocessing of YUV image block horizontal direction behind the convergent-divergent;
The described next Y component that continues to obtain the YUV image block behind the convergent-divergent is to obtain from the convergent-divergent buffering area, that is: Yt+=-tx+2*t_stride, p+=-2-tx*stride_d, i=i--, j=tx/4;
S712 judges whether i equals 0, if, then enter step S718, if not, then enter step S709;
S713, the coordinate of the YUV420 image block behind the coordinate of described RGB565 image block output and the convergent-divergent is consistent, and with p definite object address, be specially: x2=x1, y2=y1, p=﹠amp; Rgb[(y2*stride_d+x2) * 2];
Because do not need rotation, the YUV420 image block behind the convergent-divergent calculates rgb value back and exports according to order from left to right, so do not need to exchange x1, y1;
S714 obtains the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculates rgb value, writes the pointer p of destination address respectively according to order from left to right, and the while, j subtracted 1, was specially:
Obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing, and calculate the rgb value, write the pointer p of destination address according to order from left to right respectively; Obtain the U component and the V component of latter two pixel in 4 pixels of described each processing, and calculate rgb value, write the pointer p of destination address respectively according to order from left to right, the while, j subtracted 1;
When writing the pointer p of destination address here, the pointer p and the Yt of described destination address will do skew at every turn, i.e. p+=2, Yt+=2;
For ease of understanding, be the example explanation to amplify 2 times, as shown in Figure 2, U component that obtains here and V component are Y component Y1, Y2, Y9, the pairing U1 component of Y10 and V1 component, calculate the rgb value, write p respectively; Fig. 5 is the non-rotating structure chart that writes the destination address position of RGB565 image block of YUV420 correspondence among Fig. 3;
Described U component and the V component that obtains preceding two pixels in 4 pixels of described each processing, and calculate the rgb value writes the process of the pointer p of destination address respectively according to order from left to right, is specially:
p[0]=get_rgb16_value_clip_rgb(u,v,Yt[0]);
p[1]=get_rgb16_value_clip_rgb(u,v,Yt[1]);
p[stride_d]=get_rgb16_value_clip_rgb(u,v,Yt[t_stride+0]);
p[stride_d+1]=get_rgb16_value_clip_rgb(u,v,Yt[t_stride+1]);
For ease of understanding, to amplify 2 times is the example explanation, as RGB565 image block R1, R2, R9, the R10 non-rotating position that write destination address of Fig. 5 for YUV420 correspondence among Fig. 3, be described p[0]=get_rgb16_value_clip_rgb (u, v, Yt[0]) expression obtains the rgb value of first Y component Y1 correspondence, writes the position of R1;
Described p[1]=get_rgb16_value_clip_rgb (u, v, Yt[1]) expression obtains the rgb value of second Y component Y2 correspondence, writes the position of R2;
Described p[stride_d]=get_rgb16_value_clip_rgb (u, v, Yt[t_stride+0]) expression obtains the rgb value of the 3rd Y component Y9 correspondence, writes the position of R9;
Described p[stride_d+1]=get_rgb16_value_clip_rgb (u, v, Yt[t_stride+1]) expression obtains the rgb value of the 4th Y component Y10 correspondence, writes the position of R10;
Described U component and the V component that obtains latter two pixel in 4 pixels of described each processing, and calculate the rgb value writes the process of the pointer p of destination address respectively according to order from right to left, is specially:
p[0]=get_rgb16_value_clip_rgb(u,v,Yt[0]);
p[1]=get_rgb16_value_clip_rgb(u,v,Yt[1]);
p[stride_d]=get_rgb16_value_clip_rgb(u,v,Yt[t_stride+0]);
p[stride_d+1]=get_rgb16_value_clip_rgb(u,v,Yt[t_stride+1]);
For ease of understanding, to amplify 2 times is the example explanation, described U component and the V component that obtains latter two pixel in 4 pixels of described each processing, as shown in Figure 2, U component and the V component that obtain this moment are Y component Y3, Y4, Y11, the pairing U2 component of Y12 and V2 component, as RGB565 image block R3, R4, R11, the R12 non-rotating position that write destination address of Fig. 5, promptly for YUV420 correspondence among Fig. 3
Described p[0]=get_rgb16_va1ue_clip_rgb (u, v, Yt[0]) expression obtains the rgb value of first Y component Y3 correspondence, writes the position of R3;
Described p[1]=get_rgb16_value_clip_rgb (u, v, Yt[1]) expression obtains the rgb value of second Y component Y4 correspondence, writes the position of R4;
Described p[stride_d]=get_rgb16_value_clip_rgb (u, v, Yt[t_stride+0]) expression obtains the rgb value of the 3rd Y component Y11 correspondence, writes the position of R11;
Described p[stride d+1]=get_rgb16_value_clip_rgb (u, v, Yt[t_stride+1]) expression obtains the rgb value of the 4th Y component Y12 correspondence, writes the position of R12;
Does S715 judge j=0? if, then enter step S716, if not, then enter step S714;
S716 continues to obtain the next Y component of the YUV image block behind the convergent-divergent, and the pointer p of destination address is pointed to the destination address that described Y component will write, and i subtracts 1, calculates j and be the each number of times of handling 4 pixel coprocessing of YUV image block horizontal direction behind the convergent-divergent;
The described next Y component that continues to obtain the YUV image block behind the convergent-divergent is to obtain from the convergent-divergent buffering area, that is: Yt+=-tx+2*t_stride, p+=-tx+2*stride_d, i=i--, j=tx/4;
S717 judges whether i equals 0, if, then enter step S718, if not, then enter step S714;
S718, cyclic variable x and x1 do stepping, enter step S703;
Described cyclic variable x and x1 do stepping and are specially: x=x+ (2*Ds_x), x1=x1+ (2*Ns_x);
S719, RGB565 image end of output.
In the present embodiment by presetting six cyclic variables and calculated step value, finish the process that whole original YUV420 image transitions becomes the RGB565 image at an identical cycle period, wherein be by earlier original YUV420 image being divided into original YUV420 image block in transfer process, each original YUV420 image block is carried out convergent-divergent, color conversion (promptly calculating the rgb value), write destination address (comprising rotation) respectively, the number of times of circulation and the quantity of access memory have been reduced, improved conversion efficiency, the RGB565 image of output can show at the portable terminal of different pixels, by original YUV420 image being divided into the original YUV420 image block and different scalings of branch ratios such as difference, reach best display effect, reduce the internal memory use amount, the locality that keeps data simultaneously, the rapid memory access speed.
Embodiment three
Fig. 8 becomes the structural representation of first preferred embodiment of RGB565 picture system for YUV420 image transitions of the present invention.
Described system comprises: initial module, Zoom module and output module;
Initial module links to each other with Zoom module, is used for original YUV420 image is divided into the original YUV420 image block of at least one; And preset the convergent-divergent multiple of the horizontal direction and the vertical direction of original YUV420 image;
The horizontal direction convergent-divergent multiple Fx=Ns_x/Ds_x of described original YUV420 image, the vertical direction convergent-divergent multiple Fy=Ns_y/Ds_y of described original YUV420 image, wherein Ns_x satisfies condition with the value of Ds_x, Ns_y and Ds_y: become convergent-divergent multiple relation, and be positive integer, simultaneously, (2*Ds_x) * (Ns_x/Ds_x) equals the width tx of the YUV420 image block behind the convergent-divergent, and (2*Ds_y) * (Ns y/Ds_y) equals the height t y of the YUV420 image block behind the convergent-divergent; Based on convergent-divergent multiple and the effect that needs convergent-divergent to present the YUV420 image is divided into one or more YUV420 image block, each YUV420 image block is made up of pixel;
For ease of understanding, to amplify 2 times is the example explanation, be illustrated in figure 1 as the structure chart of original YUV420 image, the height of original YUV420 image and width are respectively H, W, original YUV420 image is divided into more than one original YUV420 image block, and as original YUV420 image block A, B, C among Fig. 1, the pixel of each original YUV420 image block is 4x4, the height and the width that are original YUV420 image block all are 4,4 corresponding 1 U components of Y component and a V component in each image block; Preset Ns_x=4, Ds_x=2, Ns_y=4, Ds_y=2, Fx and Fy person are 2;
Zoom module links to each other with output module with initial module, is used for the convergent-divergent multiple that presets original YUV420 image level and vertical direction according to described, and filtering interpolation generates the YUV420 image block behind the convergent-divergent;
For ease of understanding, to amplify 2 times is the example explanation, Figure 2 shows that the structure chart of the YUV420 image block behind the original YUV420 image block A convergent-divergent, pixel was 8x8 after original YUV420 image block A amplified 2 times, as shown in Figure 2, comprise Y component 1-64, wherein the width of scaled images piece is tx, the height t y of scaled images piece;
Output module, link to each other with Zoom module, be used to obtain Y component, U component and the V component of the YUV420 image block behind the convergent-divergent, calculate the rgb value, according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size, determine whether rotation and respectively the rgb value is write destination address;
Described whether the rotation is to determine whether that according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size the needs rotation writes the rgb value, be the height that the width of RGB565 image equals original YUV420 image block, the height of the YUV420 image behind the convergent-divergent becomes the width of RGB565 image;
Described rgb value is to do the value of color conversion by external function, and described external function is get_rgb16_value_clip_rgb ();
By initial module original YUV420 image is divided into original YUV420 image block in the present embodiment, Zoom module carries out convergent-divergent to original YUV420 image block, YUV420 image block behind the output convergent-divergent, output module elder generation color conversion (promptly calculating the rgb value), determine whether that according to YUV420 size of images and mobile terminal screen size rotation writes destination address with the rgb value respectively then, thereby realize each original YUV420 image block is done convergent-divergent continuously, calculate rgb value and output (comprising rotation), the number of times of circulation and the quantity of access memory have been reduced, improved conversion efficiency, the RGB565 image of output can show at various pixel portable terminals, by original YUV420 image being divided into the original YUV420 image block and different scalings of branch ratios such as difference, reach best display effect, reduce the internal memory use amount, the locality that keeps data simultaneously, the rapid memory access speed.
Embodiment four
Fig. 9 is the structural representation that YUV420 image transitions of the present invention becomes second preferred embodiment of RGB565 picture system, and the needs in the present embodiment are done rotary manipulation.
Described system comprises: initial module, first judge module, second judge module, Zoom module, output module, the 3rd judge module, the 4th judge module and stepping module;
Initial module links to each other with first judge module, is used for original YUV420 image is divided into the original YUV420 image block of at least one; And preset the convergent-divergent multiple of the horizontal direction and the vertical direction of original YUV420 image; Also be used to preset the width W and the height H of described original YUV420 image; Also be used to preset the pointer p of the destination address that current RGB565 image block deposits; Also be used to preset the convergent-divergent buffering area, deposit Y component, U component and the V component of the YUV420 image behind the described convergent-divergent, quote by variable Y t, Ut and Vt respectively; Also be used to preset cyclic variable x, y, x1, y1, i, j, be initially 0.
Described initial module links to each other with described first judge module, also is used to preset the first address pointer rgb of destination address of RGB565 image and the pointer p of the destination address that current RGB565 image block is deposited, and all is defined as the short* type; Preset RGB565 image block output coordinate variable x2, y2; Height t y and width tx, Y component line-spacing stride_t, U component line-spacing and the V component line-spacing of the YUV420 image block behind the width W 1 of the YUV420 image behind the calculating convergent-divergent, height H 1, the convergent-divergent; Calculate the width W 2 of RGB565 image and the first address rgb of destination address; Calculate line-spacing stride_d, the side-play amount offset of RGB565 image block and the destination address p that current RGB565 image block writes;
The horizontal direction convergent-divergent multiple Fx=Ns_x/Ds_x of described YUV420 image, the vertical direction convergent-divergent multiple Fy=Ns_y/Ds_y of described YUV420 image, wherein Ns_x satisfies condition with the value of Ds_x, Ns_y and Ds_y: become convergent-divergent multiple relation, and be positive integer, simultaneously, (2*Ds_x) * (Ns_x/Ds_x) equals the width tx of the YUV420 image block behind the convergent-divergent, and (2*Ds_y) * (Ns_y/Ds_y) equals the height t y of the YUV420 image block behind the convergent-divergent.Based on convergent-divergent multiple and the effect that needs convergent-divergent to present the YUV420 image is divided at least one YUV420 image block, each YUV420 image block is made up of pixel;
The first address of the destination address that described first address pointer rgb record RGB565 image block need be deposited, the pointer p of the destination address that described current RGB565 image block is deposited writes down the destination address that current RGB565 image block is deposited;
Described cyclic variable x, y represent the coordinate of the level and the vertical direction of original image, and in cyclic process, x, y are the step value stepping with 2*Ds_x, 2*Ds_y respectively; Described cyclic variable x1, y1 represent the level and the vertical direction coordinate of the YUV420 image behind the convergent-divergent, and in cyclic process, x1, y1 are the step value stepping with 2*Ns_x, 2*Ns_y respectively;
Described RGB565 image block output coordinate variable x2, y2, expression be the horizontal coordinate and the vertical coordinate of RGB565 image block output;
The width W 1 of the YUV420 image behind the described convergent-divergent and height H 1 are: W1=W*Fx, H1=H*Fy;
The Y component line-spacing stride_t of the YUV420 image behind the described convergent-divergent comes according to concrete convergent-divergent multiple, i.e. the number of every capable pixel; The U component line-spacing of the YUV420 image behind the described convergent-divergent and V component line-spacing are 1/2nd of stride_t; To amplify 2 times is the example explanation, Y component line-spacing stride_t=8, and U component line-spacing and V component line-spacing are 1/2nd of stridet, promptly all are 4;
The width W 2=H1 of described RGB565 image, the width of RGB565 image equals the height of original YUV420 image block, and the height of the YUV420 image behind the convergent-divergent becomes the width of RGB565 image;
The height t y of the YUV420 image block behind the described convergent-divergent and width tx are the vertical direction of the YUV420 image block behind the convergent-divergent and the number of horizontal direction pixel;
The current goal address of described RGB565 image block is with respect to the side-play amount offset=0*W2+ (W2-1) of RGB565 image first address;
Described offset is the side-play amount of current goal address with respect to RGB565 image first address;
The first address rgb of the destination address of described RGB565 image is offset*2;
The pointer p+=offset*2 of the destination address that described current RGB565 image block is deposited;
This three's of pointer p of the destination address that the first address rgb of the destination address of described RGB565 image, the address offset amount offset of RGB565 image block and current RGB image block are deposited relation is: rgb is the first address of the RGB565 image of output, only need to calculate once, offset is to be that skew is done by unit with the pixel, and it is the OPADD p of current RGB565 image block of skew with the byte that rgb+offset*2 has just obtained.RGB565 image block of every output, the pointer p of the destination address that current RGB565 image block is deposited needs to be skew, i.e. rgb+offset*2;
First judge module links to each other with described initial module, described second judge module and described stepping module respectively, is used to judge whether y<H, if, then notify second judge module, if not, RGB565 image end of output then;
Described and described first judge module of second judge module, described stepping module link to each other with described Zoom module, are used to judge whether x<W, if, then notify Zoom module to carry out convergent-divergent, if not, then notify the stepping module;
Zoom module links to each other with described output module with described second judge module respectively, is used for the convergent-divergent multiple that presets original YUV420 image level and vertical direction according to described, and filtering interpolation generates the YUV420 image block behind the convergent-divergent, and deposits the convergent-divergent buffering area; Also be used to calculate i and be each redirect 2 row of the YUV420 image block vertical direction number of times of redirect altogether behind the convergent-divergent, calculate j and be the each number of times of handling 4 pixel coprocessing of YUV420 image block horizontal direction behind the convergent-divergent; Also be used for the coordinate of RGB565 image block output is exchanged with the coordinate of the YUV420 image block behind the convergent-divergent, and with the pointer p definite object address of destination address, and notify output module;
Wherein the width of the YUV420 image block behind the convergent-divergent is tx, and the height of the YUV420 image block behind the convergent-divergent is ty;
Output module links to each other with described Zoom module, described the 3rd judge module and described the 4th judge module respectively, be used to receive notice, the notice of the 3rd judge module transmission and the notice that the 4th judge module sends that Zoom module sends, if also be used for rotation, then obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculating rgb value, write the pointer p of destination address respectively according to order from right to left, j subtracts 1 simultaneously;
The described pointer p that writes destination address according to order from right to left respectively, be that the coordinate of RGB565 image block output and the coordinate of the YUV420 image block behind the convergent-divergent exchange, i.e. x2=-y1, y2=x1, simultaneously with the pointer p definite object address of destination address, i.e. p=﹠amp; Rgb[(y2*stride_d+x2) * 2];
Because rotate, the YUV420 image block of the horizontal direction behind the convergent-divergent calculates rgb value back and exports according to order from right to left, so need exchange x1, y1;
For ease of understanding, be the example explanation to amplify 2 times, coordinate exchange process as shown in Figure 3 and Figure 4;
The 3rd judge module links to each other with described the 4th judge module with described output module respectively, be used to judge whether j equals 0, if, then continue to obtain the next Y component of the YUV image block behind the convergent-divergent, the pointer p of destination address is pointed to the destination address that described Y component will write, i subtracts 1, and calculating j is the number of times of 4 the pixel coprocessing of the each processing of YUV image block horizontal direction behind the convergent-divergent; And notify the 4th judge module; If not, then notify output module;
The 4th judge module links to each other with described the 3rd judge module, described output module and described stepping module respectively, is used to judge whether i equals 0, if then notify described stepping module, and notify described second judge module; If not, then notify described output module;
The stepping module links to each other with described first judge module, described second judge module and described the 4th judge module respectively, be used to receive the notice of second judge module, and cyclic variable y, y1 done stepping, cyclic variable x resets to 0, and notifies described first judge module; Also be used to receive the notice that described the 4th judge module sends, and cyclic variable x and x1 are done stepping.
By the judged result of second judge module and the 4th judge module, notice stepping module is carried out stepping to cyclic variable x, x1, y, y1, thereby obtains next original YUV420 image block in the present embodiment; By the judged result of the 3rd judge module and the 4th judge module, the notice output module calculates the rgb value and the output (comprising rotation) of the RGB image block of current two row; Realized under the situation of needs rotation, in same cycle period, finish of the conversion of whole YUV420 image to the RGB565 image, the number of times of circulation and the quantity of access memory have been reduced, improved conversion efficiency, the RGB565 image of output can show at the portable terminal of different pixels, by original YUV420 image being divided into the original YUV420 image block and different scalings of branch ratios such as difference, reach best display effect, reduce the internal memory use amount, the locality that keeps data simultaneously, the rapid memory access speed.
Embodiment five
Fig. 9 becomes the structural representation of second preferred embodiment of RGB565 picture system for YUV420 image transitions of the present invention, does not need to do rotary manipulation in the present embodiment.
Described system comprises: initial module, first judge module, second judge module, Zoom module, output module, the 3rd judge module, the 4th judge module and stepping module;
Initial module links to each other with described first judge module, also is used to preset the width W and the height H of described original YUV420 image; Also be used to preset the pointer p of the destination address that current RGB565 image block deposits; Also be used to preset the convergent-divergent buffering area, deposit Y component, U component and the V component of the YUV420 image behind the described convergent-divergent, quote by variable Y t, Ut and Vt respectively; Also be used to preset cyclic variable x, y, x1, y1, i, j, be initially 0;
Described initial module also presets the first address pointer rgb of destination address of RGB565 image and the pointer p of the destination address that current RGB565 image block is deposited, and all is defined as the short* type; Preset RGB565 image block output coordinate variable x2, y2; Height t y and width tx, Y component line-spacing stride_t, U component line-spacing and the V component line-spacing of the YUV420 image block behind the width W 1 of the YUV420 image behind the calculating convergent-divergent, height H 1, the convergent-divergent; Calculate the width W 2 of RGB565 image and the first address rgb of destination address; Calculate line-spacing stride_d, the side-play amount offset of RGB565 image block and the destination address p that current RGB565 image block writes;
The width W 1 of the YUV420 image behind the described convergent-divergent and height H 1 are: W1=W*Fx, H1=H*Fy;
The Y component line-spacing stride_t of the YUV420 image behind the described convergent-divergent is definite according to concrete convergent-divergent multiple, i.e. the number of every capable pixel; The U component line-spacing of the YUV420 image behind the described convergent-divergent and V component line-spacing are 1/2nd of stride_t;
The width W 2=W1 of described RGB565 image;
The first address rgb of the destination address of described RGB565 image is offset*2;
The line-spacing stride_d=W2 of described RGB565 image block;
The height t y of the YUV420 image block behind the described convergent-divergent and width tx are the vertical direction of the YUV420 image block behind the convergent-divergent and the number of horizontal direction pixel;
The current goal address of described RGB565 image block is with respect to the side-play amount offset=0 of image first address;
The pointer p+=offset*2 of the destination address that described current RGB565 image block is deposited;
Described first judge module links to each other with initial module, described second judge module and described stepping module respectively, is used to judge whether y<H, if, then notify second judge module, if not, RGB565 image end of output then;
Described second judge module links to each other with described Zoom module with described first judge module, described stepping module respectively, is used to judge whether x<W, if, then notify Zoom module to carry out convergent-divergent, if not, then notify the stepping module;
Described Zoom module links to each other with described output module with described second judge module respectively, also be used to calculate i and be each redirect 2 row of the YUV420 image block vertical direction number of times of redirect altogether behind the convergent-divergent, calculate j and be the each number of times of handling 4 pixel coprocessing of YUV420 image block horizontal direction behind the convergent-divergent; Also be used for the coordinate of RGB565 image block output is exchanged with the coordinate of the YUV420 image block behind the convergent-divergent, and with the pointer p definite object address of destination address, and notify output module;
Described output module links to each other with described Zoom module, described the 3rd judge module and described the 4th judge module respectively, be used to receive notice, the notice of described the 3rd judge module transmission and the notice that described the 4th judge module sends that described Zoom module sends, do not rotate if also be used for, then obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculating rgb value, write the pointer p of destination address respectively according to order from left to right, j subtracts 1 simultaneously, and notifies the 3rd judge module to judge;
Because do not need rotation, the YUV420 image block behind the convergent-divergent calculates rgb value back and exports according to order from left to right, so do not need to exchange x1, y1;
Described the 3rd judge module links to each other with described the 4th judge module with described output module respectively, be used to judge whether j equals 0, if, then continue to obtain the next Y component of the YUV image block behind the convergent-divergent, the pointer p of destination address is pointed to the destination address that described Y component will write, i subtracts 1, and calculating j is the number of times of 4 the pixel coprocessing of the each processing of YUV image block horizontal direction behind the convergent-divergent; And notify the 4th judge module; If not, then notify output module;
Described the 4th judge module links to each other with described the 3rd judge module, described output module and described stepping module respectively, is used to judge whether i equals 0, if then notify described stepping module, and notify described second judge module; If not, then notify described output module;
Described stepping module links to each other with described first judge module, described second judge module and described the 4th judge module respectively, be used to receive the notice and the y+=(2*Ds_y) of described second judge module, and cyclic variable y, y1 done stepping, cyclic variable x resets to 0, and notifies described first judge module; Also be used to receive the notice that described the 4th judge module sends, and cyclic variable x and x1 are done stepping.
By the judged result of second judge module and the 4th judge module, notice stepping module is carried out stepping to cyclic variable x, x1, y, y1, thereby obtains next original YUV420 image block in the present embodiment; By the judged result of the 3rd judge module and the 4th judge module, the notice output module calculates the rgb value and the output of the RGB image block of current two row; Realized under the situation that does not need to rotate, in same cycle period, finish of the conversion of whole YUV420 image to the RGB565 image, the number of times of circulation and the quantity of access memory have been reduced, improved conversion efficiency, the RGB565 image of output can show at the portable terminal of different pixels, by original YUV420 image being divided into the original YUV420 image block and different scalings of branch ratios such as difference, reach best display effect, reduce the internal memory use amount, the locality that keeps data simultaneously, the rapid memory access speed.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.

Claims (11)

1. a YUV420 image transitions becomes the method for RGB565 image, it is characterized in that, said method comprising the steps of:
Original YUV420 image is divided at least one original YUV420 image block; And preset the convergent-divergent multiple of the horizontal direction and the vertical direction of described original YUV420 image;
According to the convergent-divergent multiple of the horizontal direction and the vertical direction of described original YUV420 image, filtering interpolation generates the YUV420 image block behind the convergent-divergent;
According to Y component, U component and the V component of the YUV420 image block behind the described convergent-divergent, calculate the rgb value, according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size, determine whether rotation and respectively described rgb value is write destination address.
2. YUV420 image transitions as claimed in claim 1 becomes the method for RGB565 image, it is characterized in that,
Described step " according to the convergent-divergent multiple of the horizontal direction and the vertical direction of described original YUV420 image, filtering interpolation generates the YUV420 image block behind the convergent-divergent " also comprises step before:
Preset the width W and the height H of described original YUV420 image;
Preset the pointer p of the destination address that current RGB565 image block deposits;
Preset the convergent-divergent buffering area, be used to deposit Y component, U component and the V component of the YUV420 image behind the described convergent-divergent;
Preset cyclic variable x, y, x1, y1, i, j, be initially 0;
If y<H and x<W then enter step " according to the convergent-divergent multiple of the horizontal direction and the vertical direction of described original YUV420 image, filtering interpolation generates the YUV420 image block behind the convergent-divergent ";
The process that writes destination address when rotating during described step " according to Y component, U component and the V component of the YUV420 image block behind the described convergent-divergent; calculate the rgb value; according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size, determines whether rotation and respectively described rgb value write destination address " comprises step:
Calculating i is each redirect 2 row of the YUV420 image block vertical direction behind the convergent-divergent number of times of redirect altogether, and calculating j is the number of times of 4 the pixel coprocessing of the each processing of YUV420 image block horizontal direction behind the convergent-divergent;
The coordinate of RGB565 image block output and the coordinate of the YUV420 image block behind the convergent-divergent are exchanged, and with the pointer p definite object address of destination address;
Obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, write the pointer p of destination address respectively according to order from right to left, the while, j subtracted 1.
3. YUV420 image transitions as claimed in claim 2 becomes the method for RGB565 image, it is characterized in that,
Described step " obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, write the pointer p of destination address respectively according to order from right to left, the while, j subtracted 1 " also comprises afterwards:
If j equals 0, then continue to obtain the next Y component of the YUV image block behind the convergent-divergent, the pointer p of destination address is pointed to the destination address that described Y component will write, and i subtracts 1, and calculating j is the number of times of 4 the pixel coprocessing of the each processing of YUV image block horizontal direction behind the convergent-divergent;
If i equals 0, then cyclic variable x and x1 do stepping;
If x is not less than W, then cyclic variable y and y1 do stepping, and x resets to 0;
If y is not less than H, RGB565 image end of output then.
4. YUV420 image transitions as claimed in claim 3 becomes the method for RGB565 image, it is characterized in that,
Described step " if j equals 0; then continue to obtain the next Y component of the YUV image block behind the convergent-divergent; the pointer p of destination address is pointed to the destination address that described Y component will write; i subtracts 1, is calculated j and is the each number of times of handling 4 pixel coprocessing of YUV image block horizontal direction behind the convergent-divergent " and also comprises step afterwards:
If j is not equal to 0, then enter step " obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, write the pointer p of destination address respectively according to order from right to left, the while, j subtracted 1 ";
Described step " if i equals 0, then cyclic variable x and x1 do stepping " also comprises step:
If i is not equal to 0, then enter step " obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, write the pointer p of destination address respectively according to order from right to left, the while, j subtracted 1 ".
5. YUV420 image transitions as claimed in claim 2 becomes the method for RGB565 image, it is characterized in that,
The process that writes destination address when not needing to rotate during described step " according to Y component, U component and the V component of the YUV420 image block behind the described convergent-divergent; calculate the rgb value; according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size, determines whether rotation and respectively described rgb value write destination address " comprises step:
Calculating i is each redirect 2 row of the YUV420 image block vertical direction behind the convergent-divergent number of times of redirect altogether, and calculating j is the number of times of 4 the pixel coprocessing of the each processing of YUV420 image block horizontal direction behind the convergent-divergent;
The coordinate of described RGB565 image block output is equaled the coordinate of the YUV420 image block behind the described convergent-divergent, and with the pointer p definite object address of destination address;
Obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, write the pointer p of destination address respectively according to order from left to right, the while, j subtracted 1.
6. YUV420 image transitions as claimed in claim 5 becomes the method for RGB565 image, it is characterized in that,
Described step " obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, write the pointer p of destination address respectively according to order from left to right, the while, j subtracted 1 " also comprises afterwards:
If j equals 0, then continue to obtain the next Y component of the YUV image block behind the convergent-divergent, the pointer p of destination address is pointed to the destination address that described Y component will write, and i subtracts 1, and calculating j is the number of times of 4 the pixel coprocessing of the each processing of YUV image block horizontal direction behind the convergent-divergent;
If i equals 0, then cyclic variable x and x1 do stepping;
If x is not less than W, then cyclic variable y and y1 do stepping, and x resets to 0;
If y is not less than H, RGB565 image end of output then.
7. YUV420 image transitions as claimed in claim 6 becomes the method for RGB565 image, it is characterized in that,
Described step " if j equals 0; then continue to obtain the next Y component of the YUV image block behind the convergent-divergent; the pointer p of destination address is pointed to the destination address that described Y component will write; i subtracts 1, is calculated j and is the each number of times of handling 4 pixel coprocessing of YUV image block horizontal direction behind the convergent-divergent " and also comprises step afterwards:
If j is not equal to 0, then enter step " obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, write the pointer p of destination address respectively according to order from left to right, the while, j subtracted 1 ";
Described step " if i equals 0, then x and x1 do stepping " also comprises step:
If i is not equal to 0, then enter step " obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, write the pointer p of destination address respectively according to order from left to right, the while, j subtracted 1 ".
8. become the method for RGB565 image as claim 2 or 5 described YUV420 image transitions, it is characterized in that,
The horizontal direction convergent-divergent multiple of described original YUV420 image equals the ratio of Ns_x and Ds_x, and the vertical direction convergent-divergent multiple of described original YUV420 image equals the ratio of Ns_y and Ds_y;
Wherein said Ns_x, described Ds_x, described Ns_y and described Ds_y are that positive integer and value satisfy condition: the convergent-divergent multiple relation that becomes positive integer, simultaneously, (2*Ds_x) * (Ns_x/Ds_x) equals the width of the YUV420 image block behind the described convergent-divergent, and (2*Ds_y) * (Ns_y/Ds_y) equals the height of the YUV420 image block behind the described convergent-divergent.
9. become the method for RGB565 image as claim 3 or 6 described YUV420 image transitions, it is characterized in that,
Described cyclic variable x and x1 do stepping, are specially: in cyclic process, x, x1 are the step value stepping with 2*Ds_x, 2*Ns_x respectively;
Described cyclic variable y and y1 do stepping, are specially: in cyclic process, y, y1 are the step value stepping with 2*Ds_y, 2*Ns_y respectively;
Wherein said Ns_x, described Ds_x, described Ns_y and described Ds_y are that positive integer and value satisfy condition: the convergent-divergent multiple relation that becomes positive integer, simultaneously, (2*Ds_x) * (Ns_x/Ds_x) equals the width of the YUV420 image block behind the described convergent-divergent, and (2*Ds_y) * (Ns y/Ds_y) equals the height of the YUV420 image block behind the described convergent-divergent.
10. a YUV420 image transitions becomes the system of RGB565 image, it is characterized in that described system comprises: initial module, Zoom module and output module;
Described initial module links to each other with described Zoom module, is used for original YUV420 image is divided at least one original YUV420 image block, and presets the convergent-divergent multiple of the horizontal direction and the vertical direction of described original YUV420 image;
Described Zoom module links to each other with described output module with described initial module respectively, is used for the convergent-divergent multiple according to the horizontal direction and the vertical direction of described original YUV420 image, and filtering interpolation generates the YUV420 image block behind the convergent-divergent;
Described output module links to each other with described Zoom module, be used for Y component, U component and V component according to the YUV420 image block behind the described convergent-divergent, calculate the rgb value, according to YUV420 size of images behind the convergent-divergent and mobile terminal screen size, determine whether rotation and respectively described rgb value is write destination address.
11. YUV420 image transitions as claimed in claim 10 becomes the system of RGB565 image, it is characterized in that, described system also comprises first judge module, second judge module, the 3rd judge module, the 4th judge module and stepping module;
Described initial module links to each other with described first judge module, also is used to preset the width W and the height H of described original YUV420 image; Also be used to preset the pointer p of the destination address that current RGB565 image block deposits; Also be used to preset the convergent-divergent buffering area, deposit Y component, U component and the V component of the YUV420 image behind the described convergent-divergent; Also be used to preset cyclic variable x, y, x1, y1, i, j, be initially 0;
Described first judge module links to each other with described initial module, described second judge module and described stepping module respectively, is used to judge whether y<H, if, then notify second judge module, if not, RGB565 image end of output then;
Described second judge module links to each other with described Zoom module with described first judge module, described stepping module respectively, is used to judge whether x<W, if, then notify Zoom module to carry out convergent-divergent, if not, then notify the stepping module;
Described Zoom module links to each other with described output module with described second judge module respectively, also be used to calculate i and be each redirect 2 row of the YUV420 image block vertical direction number of times of redirect altogether behind the convergent-divergent, calculate j and be the each number of times of handling 4 pixel coprocessing of YUV420 image block horizontal direction behind the convergent-divergent; Also be used for when needs rotate, then the coordinate with RGB565 image block output exchanges with the coordinate of the YUV420 image block behind the convergent-divergent, and with the pointer p definite object address of destination address, and notify output module; When also being used for not needing to rotate, then the coordinate of described RGB565 image block output is equaled the coordinate of the YUV420 image block behind the described convergent-divergent, and with the pointer p definite object address of destination address, and the notice output module;
Described output module links to each other with described Zoom module, described the 3rd judge module and described the 4th judge module respectively, is used to receive notice, the notice of described the 3rd judge module transmission and the notice that described the 4th judge module sends that described Zoom module sends; If also be used for rotation, then obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, write the pointer p of destination address respectively according to order from right to left, the while, j subtracted 1;
If described output module also is used for not rotating, then obtain the U component and the V component of preceding two pixels in 4 pixels of described each processing and latter two pixel, and calculate rgb value, and writing the pointer p of destination address respectively according to order from left to right, the while, j subtracted 1;
Described the 3rd judge module links to each other with described the 4th judge module with described output module respectively, be used to judge whether j equals 0, if, then continue to obtain the next Y component of the YUV image block behind the convergent-divergent, the pointer p of destination address is pointed to the destination address that described Y component will write, i subtracts 1, and calculating j is the number of times of 4 the pixel coprocessing of the each processing of YUV image block horizontal direction behind the convergent-divergent; And notify described the 4th judge module; If not, then notify described output module;
Described the 4th judge module links to each other with described the 3rd judge module, described output module and described stepping module respectively, is used to judge whether i equals 0, if then notify described stepping module, and notify described second judge module; If not, then notify described output module;
Described stepping module links to each other with described first judge module, described second judge module and described the 4th judge module respectively, be used to receive the notice of described second judge module, and cyclic variable y, y1 done stepping, cyclic variable x resets to 0, and notifies described first judge module; Also be used to receive the notice that described the 4th judge module sends, and cyclic variable x and x1 are done stepping.
CN2011102782921A 2010-12-30 2011-09-19 Method and system for converting YUV420 image into RGB565 image Pending CN102281382A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011102782921A CN102281382A (en) 2010-12-30 2011-09-19 Method and system for converting YUV420 image into RGB565 image

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
CN201010616187XA CN102073987A (en) 2010-12-30 2010-12-30 Method and system for converting YUV420 image into RGB565 image
CN201010616187.X 2010-12-30
CN2011102782921A CN102281382A (en) 2010-12-30 2011-09-19 Method and system for converting YUV420 image into RGB565 image

Publications (1)

Publication Number Publication Date
CN102281382A true CN102281382A (en) 2011-12-14

Family

ID=44032518

Family Applications (2)

Application Number Title Priority Date Filing Date
CN201010616187XA Pending CN102073987A (en) 2010-12-30 2010-12-30 Method and system for converting YUV420 image into RGB565 image
CN2011102782921A Pending CN102281382A (en) 2010-12-30 2011-09-19 Method and system for converting YUV420 image into RGB565 image

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN201010616187XA Pending CN102073987A (en) 2010-12-30 2010-12-30 Method and system for converting YUV420 image into RGB565 image

Country Status (1)

Country Link
CN (2) CN102073987A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013107334A1 (en) * 2012-01-18 2013-07-25 Tencent Technology (Shenzhen) Company Limited Image rotation method and system for video player
US11930307B2 (en) 2020-04-17 2024-03-12 Beijing Baidu Netcom Science Technology Co., Ltd. Image processing method and apparatus, electronic device and computer-readable storage medium

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105681800B (en) * 2016-01-27 2019-02-05 桂林长海发展有限责任公司 A kind of device and method that YUV420 quickly changes into rgb format
CN108076336A (en) * 2016-11-14 2018-05-25 北京航天长峰科技工业集团有限公司 A kind of rapid color space conversion method based on AVX technologies
CN113538607B (en) * 2021-09-15 2021-12-24 北京小鸟科技股份有限公司 YUV image conversion method and system based on invariance of Y component of artificial image

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013107334A1 (en) * 2012-01-18 2013-07-25 Tencent Technology (Shenzhen) Company Limited Image rotation method and system for video player
US11930307B2 (en) 2020-04-17 2024-03-12 Beijing Baidu Netcom Science Technology Co., Ltd. Image processing method and apparatus, electronic device and computer-readable storage medium

Also Published As

Publication number Publication date
CN102073987A (en) 2011-05-25

Similar Documents

Publication Publication Date Title
US6456329B1 (en) De-interlacing of video signals
CN102281382A (en) Method and system for converting YUV420 image into RGB565 image
JP4850689B2 (en) Image processing apparatus, image processing method, image processing program, and storage medium
CN107465939B (en) Method and device for processing video image data stream
CN102118624A (en) Method for converting an image from an RGB color space to a YUV color space
EP0886436A3 (en) Compression of mosaiced images
OA10382A (en) Apparatus and method for decoding video images
CN101546527B (en) Liquid crystal display controller and image scaling method
CN101778280B (en) Circuit and method based on AVS motion compensation interpolation
CN107564084B (en) Method and device for synthesizing motion picture and storage equipment
CN117768774A (en) Image processor, image processing method, photographing device and electronic device
US20050047502A1 (en) Method and apparatus for the efficient representation of interpolated video frames for motion-compensated coding
JPH08181984A (en) Image compressor and image compression method
US20090110332A1 (en) Increasing resolution of video images
US8577185B2 (en) Apparatus and method for interpolating and rendering image on mobile devices
CN100535939C (en) Electronic device and a method in an electronic device for processing image data
CN114788280A (en) Video coding and decoding method and device
US20050285813A1 (en) Display controller, electronic equipment, and image data supplying method
CN102215318A (en) Processing method for mobile video display
CN112165631B (en) Media resource processing method and device, storage medium and electronic equipment
CN114078078A (en) Image format conversion method, device and storage medium
CN102263924A (en) Image processing method based on bicubic interpolation and image display method
JP2004112579A (en) Resolution converting circuit, digital still camera using it, and digital video camera
CN111105356A (en) Image processing method, image processing apparatus, and computer-readable storage medium
JP3748446B2 (en) Image processing circuit of image input device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20111214