This application claims priority to Chinese Patent Application No. 201210126351.8, filed on Apr. 26, 2012, which is hereby incorporated by reference in its entirety.
The present invention relates to the field of image processing technologies, and in particular, to an image rotation control method and device.
When playing a video or performing game application, an existing mobile terminal may utilize gravity sensing to rotate a display screen in real time according to a direction in which the terminal is held, so as to obtain application experience of different angles. For performing a real-time rotation operation on a display screen, a terminal is required to have high DDR (Double Data Rate, double data rate synchronous dynamic random access memory) bandwidth.
An existing display rotation process includes: A GPU (Graphic Processing Unit, graphic processing unit) in a terminal converts an image originally of a Tile format in a DDR into an image of a Linear format, and rotates the image of the Linear format in the DDR by a corresponding angle, and then sends the rotated image to an LCD (Liquid Crystal Display, liquid crystal display) for display. In a process of studying the prior art, the inventor finds that, in a process of performing format conversion on an image, rotating the image by an angle, and sending the image to the LCD, because read/write operations are performed on the DDR in multiple times and system bandwidth needs to be occupied in each read/write operation, a large demand for the system bandwidth in a terminal exists in the existing display rotation process, and correspondingly, effective bandwidth that can be obtained by other functional modules in the terminal are occupied, and if the system bandwidth is increased to satisfy the bandwidth demand for display rotation, not only the costs of the terminal are increased, but also the system power consumption of the terminal is increased.
Embodiments of the present invention provide an image rotation control method and device, so as to solve the problem of occupying system bandwidth in an image rotation control process in the prior art.
To solve the foregoing technical problem, the embodiments of the present invention disclose the following technical solutions:
An image rotation control method is provided, where the method includes:
An image rotation control device is provided, where the device includes:
In the embodiments of the present invention, the image blocks of the first image in the first image format are read from the first buffer according to the rotation angle, the read image blocks are written into the preset second buffer, and the image data is read from the second buffer according to the second image format, so as to obtain the rotated second image. According to the embodiments of the present invention, in a process of performing rotation control on an image, a read operation needs to be performed on the first buffer only once, so that the image data of the first image format is rotated to generate the image data of the second image format; therefore, compared with the prior art, in the rotation control process, the occupancy of system bandwidth in a terminal is reduced, other functional modules can obtain effective bandwidth in a situation that the bandwidth of the terminal is limited, and meanwhile the system power consumption is not wasted for increasing the system bandwidth.
To describe the technical solutions in the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings required for describing the embodiments. Apparently, persons of ordinary skill in the art may still derive other drawings from these accompanying drawings without any creative efforts.
The following embodiments of the present invention provide an image rotation control method and device.
To make the technical solutions in the embodiments of the present invention more comprehensible for persons skilled in the art, and make the foregoing objectives, features, and advantages of the embodiments of the present invention more clearly, the following further describes the technical solutions in the embodiments of the present invention in detail with reference to the accompanying drawings.
Referring to
Step 101: Read image blocks of a first image from a first buffer according to a rotation angle, where the first image is in a first image format.
According to different rotation angles, in the embodiment of the present invention, image rotation control generally refers to rotating an image by 90 degrees, 270 degrees, or 180 degrees.
When the first image format specifically is a Tile format, Tile image blocks of the first image may be read from the first buffer in a Burst (burst transmission) manner in sequence according to a rotation angle, where the Burst manner refers to a manner for reading an image having pixel addresses being continuous, and because pixel addresses of each Tile image block are continuous, the Tile image blocks may be read in a Burst manner.
In this step, at least one column of image blocks or one row of image blocks of the first image may be read from the first buffer each time. Correspondingly, a corresponding space size of a second buffer is set according to different numbers of columns or rows of image blocks of the first image which are read each time.
Step 102: Write the read image blocks into a preset second buffer.
When the first image format specifically is the Tile format, the read Tile image blocks are written into the second buffer in sequence from left to right. The second buffer may be formed of at least one pair of ping-pong buffers, and each buffer in each pair of ping-pong buffers is configured to store one column of Tile image blocks or one row of Tile image blocks of the first image. Besides adopting a ping-pong buffer as a specific form of the second buffer, in an image rotation control process that does not have high requirements on real-time performance, the second buffer may also adopt a form of a single buffer, and in an image rotation control process that has high requirements on real-time performance, the second buffer may also adopt more than three buffers.
Step 103: Read image data from the second buffer according to a second image format, so as to obtain a rotated second image.
When the first image format specifically is the Tile format and the second image format specifically is a Linear format, image data is read row by row in sequence from left to right from the second buffer according to the Linear format.
When the set second buffer in step 102 is formed of at least one pair of ping-pong buffers after one buffer in each pair of ping-pong buffers stores one column of Tile image blocks or one row of Tile image blocks of the first image, image data is read row by row in sequence from left to right from one buffer according to the Linear format. Furthermore, after the image data is read row by row in sequence from left to right from one buffer according to the Linear format, the buffer space of one buffer is released.
It can be seen from the foregoing embodiment that, through this embodiment, in a process of performing rotation control on an image, a read operation needs to be performed on the first buffer only once, so that the image data of the first image format is rotated to generate the image data of the second image format; therefore, compared with the prior art, in the rotation control process, the occupancy of system bandwidth in a terminal is reduced, other functional modules can obtain effective bandwidth in a situation that the bandwidth of the terminal is limited, and meanwhile the system power consumption is not wasted for increasing the system bandwidth.
An example of a process of rotating a Tile format image into a Linear format image is taken in the following to describe the embodiment of the image rotation control method of the present invention in detail, and to conveniently illustrate the Tile format and Linear format images, it is assumed that pixels of an image are 8*8.
Referring to
Referring to
In the embodiment of the present invention, a Tile format image may be written into a rotation Buffer acting as the second buffer, and then a Linear format image is directly read from the rotation Buffer, that is, the image rotation is completed in one read/write process, and compared with an existing solution in which multiple read/write operations are performed multiple times to complete image rotation, the occupancy of system bandwidth can be reduced. The embodiment of the present invention is described in detail in the following by describing display rotation control processes in different rotation angles.
Referring to
Step 301: Preset that a rotation Buffer acting as a second buffer is formed of one pair of ping-pong buffers, where each buffer of the ping-pong buffers is configured to store one column of Tile image blocks of a first image.
Step 302: Read one column of Tile image blocks of the first image in sequence from right to left from a DDR acting as a first buffer, and for each column of Tile image blocks, read each Tile image block in a Burst manner in sequence from top to bottom.
Step 303: Write the read Tile image blocks into one buffer of the ping-pong buffers in sequence from left to right; for each Tile image block, write each pixel column in sequence from left to right; and for each pixel column, write each pixel datum in sequence from bottom to top or from top to bottom.
Step 304: Determine whether one buffer of the ping-pong buffers is fully filled; if yes, execute step 305; otherwise, return to step 302.
Step 305: Read each pixel row row by row from top to bottom or from bottom to top from one buffer according to a Linear format, and for each pixel row, read image data in sequence from left to right.
When each pixel datum is written in sequence from bottom to top in step 303, in this step, each pixel row is read row by row from top to bottom, and for each pixel row, image data is read in sequence from left to right. When each pixel datum is written in sequence from top to bottom in step 303, in this step, each pixel row is read row by row from bottom to top, and for each pixel row, image data is read in sequence from left to right.
Step 306: Determine whether image data in one buffer is completely read; if yes, execute step 307; otherwise, return to step 305.
Step 307: Release a buffer space of one buffer of the completely read image data.
Step 308: Determine whether all Tile image block columns of the first image are completely read; if yes, end the current procedure; otherwise, return to step 302.
Referring to
As shown in
In
After the first column of Tile image blocks is read, the read Tile image blocks are written into one buffer of the ping-pong buffers in sequence from left to right. A write process of the first column of Tile image blocks is described in detail with reference to
Similarly, in
Referring to
With reference to
Referring to
Step 401: Preset that a rotation Buffer acting as a second buffer is formed of one pair of ping-pong buffers, where each buffer of the ping-pong buffers is configured to store one column of Tile image blocks of a first image.
Step 402: Read one column of Tile image blocks of the first image in sequence from left to right from a DDR acting as a first buffer, and for each column of Tile image blocks, read each Tile image block in a Burst manner in sequence from bottom to top.
Step 403: Write the read Tile image blocks into one buffer of the ping-pong buffers in sequence from left to right; for each Tile image block, write each pixel column in sequence from right to left; and for each pixel column, write each pixel datum in sequence from top to bottom or from bottom to top.
Step 404: Determine whether one buffer of the ping-pong buffers is fully filled; if yes, execute step 405; otherwise, return to step 402.
Step 405: Read each pixel row row by row from top to bottom or from bottom to top from one buffer according to a Linear format, and for each pixel row, read image data in sequence from left to right.
When each pixel datum is written in sequence from top to bottom in step 403, in this step, each pixel row is read row by row from top to bottom, and for each pixel row, image data is read in sequence from left to right. When each pixel datum is written in sequence from bottom to top in step 403, in this step, each pixel row is read row by row from bottom to top, and for each pixel row, image data is read in sequence from left to right.
Step 406: Determine whether image data in one buffer is completely read; if yes, execute step 407; otherwise, return to step 405.
Step 407: Release a buffer space of one buffer of the completely read image data.
Step 408: Determine whether all Tile image block columns of the first image are completely read; if yes, end the procedure; otherwise, return to step 402.
Referring to
As shown in
In
After the first column of Tile image blocks is read, the read Tile image blocks are written into one buffer of the ping-pong buffers in sequence from left to right. A write process of the first column of Tile image blocks is described in detail with reference to
Similarly, in
A process of reading a Linear format image from the rotation Buffer in
In the embodiment of the present invention, the image is rotated in the process of writing the Tile image blocks into the rotation Buffer and reading the Linear image from the rotation Buffer. For a first ping-pong buffer in the rotation Buffer in
Referring to
Step 501: Preset that a rotation Buffer acting as a second buffer is formed of one pair of ping-pong buffers, where each buffer of the ping-pong buffers is configured to store one column of Tile image blocks of a first image.
Step 502: Read one row of Tile image blocks of the first image in sequence from bottom to top from a DDR acting as a first buffer, and for each row of Tile image blocks, read each Tile image block in a Burst manner in sequence from right to left.
Step 503: Write the read Tile image blocks into one buffer of the ping-pong buffers in sequence from left to right; for each Tile image block, write each pixel row in sequence from bottom to top or from top to bottom; and for each pixel row, write each pixel datum in sequence from right to left.
Step 504: Determine whether one buffer of the ping-pong buffers is fully filled; if yes, execute step 505; otherwise, return to step 502.
Step 505: Read each pixel row row by row from top to bottom or from bottom to top from one buffer according to a Linear format, and for each pixel row, read image data in sequence from left to right.
When each pixel row is written in sequence from bottom to top in step 503, in this step, each pixel row is read row by row from top to bottom, and for each pixel row, image data is read in sequence from left to right. When each pixel row is written in sequence from top to bottom in step 503, in this step, each pixel row is read row by row from bottom to top, and for each pixel row, image data is read in sequence from left to right.
Step 506: Determine whether image data in one buffer is completely read; if yes, execute step 507; otherwise, return to step 505.
Step 507: Release a buffer space of one buffer of the completely read image data.
Step 508: Determine whether all Tile image block rows of the first image are completely read, if yes, end the procedure; otherwise, return to step 502.
Referring to
As shown in
In
After the first row of Tile image blocks is read, the read Tile image blocks are written into one buffer of the ping-pong buffers in sequence from left to right. A write process of the first row of Tile image blocks is described in detail with reference to
Similarly, in
A process of reading a Linear format image from the rotation Buffer in
In the embodiment of the present invention, the image is rotated in the process of writing the Tile image blocks into the rotation Buffer and reading the Linear image from the rotation Buffer. For a first ping-pong buffer in the rotation Buffer in
Corresponding to the embodiments of the image rotation control method of the present invention, the present invention further provides an embodiment of an image rotation control device.
Referring to
The image rotation control device includes: a first read unit 610, a write unit 620, and a second read unit 630.
The first read unit 610 is configured to read image blocks of a first image from a first buffer according to a rotation angle, where the first image is in a first image format; and the first read unit 610 may be further specifically configured to: according to the rotation angle, read at least one column of image blocks or one row of image blocks of the first image from the first buffer each time.
The write unit 620 is configured to write the read image blocks into a preset second buffer.
The second read unit 630 is configured to read image data from the second buffer according to a second image format, so as to obtain a rotated second image.
When the first image format is a Tile format and the second image format is a Linear format, the first read unit 610 is specifically configured to read Tile image blocks of the first image from the first buffer in a burst transmission Burst manner in sequence according to the rotation angle; the write unit 620 is specifically configured to write the read Tile image blocks into the second buffer in sequence from left to right; and the second read unit 630 is specifically configured to read image data row by row in sequence from left to right from the second buffer according to the Linear format.
Specifically, the first read unit 610 may include (not shown in
Correspondingly, the write unit 620 may include (not shown in
Referring to
The image rotation control device includes: a setting unit 710, a first read unit 720, a write unit 730, a second read unit 740, and a release unit 750.
The setting unit 710 is configured to preset that a second buffer is formed of at least one pair of ping-pong buffers, where each buffer of each pair of ping-pong buffers is configured to store one column of Tile image blocks or one row of Tile image blocks of the first image.
The first read unit 720 is configured to read Tile image blocks of the first image from the first buffer in a burst transmission Burst manner in sequence according to a rotation angle.
The write unit 730 is configured to write the read Tile image blocks into one buffer of the pair of ping-pong buffers in sequence from left to right.
The second read unit 740 is configured to: after one buffer of the each pair of ping-pong buffers stores one column of Tile image blocks or one row of Tile image blocks of the first image, read each pixel row row by row from top to bottom or from bottom to top from the buffer according to a Linear format, and for each pixel row, read image data in sequence from left to right.
The release unit 750 is configured to: after the second read unit 740 reads each pixel row row by row from top to bottom or from bottom to top from the buffer according to the Linear format, and for pixel row, reads image data in sequence from left to right, release a buffer space of the buffer.
It should be noted that, in the embodiment of the present invention, the image rotation control device may be one part of a terminal display device, and may also be integrated in other devices of the terminal. After obtaining the rotated second image, the image rotation control device may input the second image to a display screen for output display after performing other processing on the second image.
It can be known from the foregoing embodiments that, in the embodiments of the present invention, the image blocks of the first image in the first image format are read from the first buffer according to a rotation angle, the read image blocks are written into the preset second buffer, and the image data is read from the second buffer according to the second image format, so as to obtain the rotated second image. According to the embodiments of the present invention, in a process of performing rotation control on an image, a read operation needs to be performed on the first buffer only once, so that the image data of the first image format is rotated to generate the image data of the second image format; therefore, compared with the prior art, in the rotation control process, the occupancy of system bandwidth in a terminal is reduced, other functional modules can obtain effective bandwidth in a situation that the bandwidth of the terminal is limited, and meanwhile the system power consumption is not wasted for increasing the system bandwidth.
Persons skilled in the art may clearly understand that, the technique in the embodiments of the present invention may be implemented through software and a necessary general hardware platform. Based on such an understanding, the technical solutions in the embodiments of the present invention essentially, or the part contributing to the prior art may be implemented in the form of a software product. The computer software product is stored in a storage medium, such as an ROM/RAM, a magnetic disk, or an optical disk, and includes several instructions for instructing a computer device (which may be personal computer, a server, or a network device) to perform the methods described in the embodiments of the present invention or in some parts of the embodiments of the present invention.
Each embodiment in the specification is described in a progressive manner. The same or similar parts in the embodiments are just references to each other. Every embodiment illustrates in emphasis what is different from the other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the apparatus embodiment is described simply, and the relevant part may be obtained with reference to the part of the description of the method embodiment.
The foregoing descriptions are the embodiments of the present invention, but are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.
Number | Date | Country | Kind |
---|---|---|---|
201210126351.8 | Apr 2012 | CN | national |