Image processing method based on system cache, and related apparatus
By reading the image data from the external memory and converting it into a second data format that takes up less space, the problem of low image data transmission efficiency is solved, and the system cache is directly used to transmit image data in electronic devices, avoiding the need for CPU and GPU Conversion between data formats improves the efficiency of image processing and display.
Patent Information
- Application Number
- PCT/CN2024/084276
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-30
- Filing Date
- 2024-03-28
- Publication Date
- 2024-10-03
AI Technical Summary
When electronic devices display images, due to the large amount of image data, the transmission efficiency between hardware modules is low and the transmission time is long, and the CPU and GPU need to perform data format conversion, which increases the processing time.
By reading compressed image data from external memory, decompressing and decoding it, and converting it into a second data format, it takes up little storage space, supports system cache transmission, avoids data format conversion, and improves transmission efficiency.
It reduces the amount of image data, improves transmission efficiency, reduces the number of data copies between hardware modules, and shortens image processing and display time.
Smart Images

Figure CN2024084276_03102024_PF_FP_ABST
Abstract
Description
Image processing method and related device based on system cache
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 30, 2023, with application number 202310378858.0 and application name “An image processing method and related device based on system cache”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of terminals, and in particular to an image processing method based on system cache and related devices. Background Art
[0003] When an electronic device receives user input and displays an image, multiple hardware modules within the device must collaborate to process the image data before it can be displayed on the display. Because image data is large in size and occupies a significant amount of storage space, image data must be transferred between hardware modules through memory, resulting in low image data transmission efficiency and long transmission times.
[0004] Summary of the Invention
[0005] The present application provides an image processing method and related device based on system cache, which enables the electronic device to read the compressed image data of the specified image from the external memory after receiving the input for displaying the specified image, and decompress and decode the compressed image data of the specified image to obtain the image data of the specified image in the first data format. The electronic device processes the image data of the specified image in the first data format to obtain the image data of the specified image in the second data format. The storage space occupied by the image data in the second data format is smaller than the storage space occupied by the image data in the first data format. In this way, since the storage space occupied by the image data in the second data format is small, the electronic device can directly use the system cache to transmit the image data of the specified image, thereby improving the efficiency of the electronic device in transmitting image data. In addition, since each hardware module of the electronic device supports processing image data in the second data format, there is no need to convert the image data into a data format between the CPU and the GPU.
[0006] In a first aspect, the present application provides a system cache-based image processing method, applied to an electronic device, the electronic device including a central processing unit (CPU), a graphics processing unit (GPU), and a system cache (SC). The method comprises: the electronic device receives an input requesting display of a first image. In response to the input requesting display of the first image, the electronic device obtains first data of the first image in a first data format. The electronic device, via the CPU, divides the first data into multiple data slices, each data slice comprising data for x*y pixels in the first data. The electronic device compresses the multiple data slices to obtain second data in a second data format. The electronic device transmits the second data from the CPU to the GPU via the SC. The electronic device, via the GPU, renders the first image based on the second data. The electronic device displays the first image. In this way, the electronic device represents image data of a specified image in the second data format, reducing the amount of image data. This allows the electronic device to directly transmit the image data of the specified image using the system cache, thereby improving the efficiency of image data transmission by the electronic device. Furthermore, because each hardware module of the electronic device supports processing image data in the second data format, data format conversion of the image data between the CPU and GPU is not required.
[0007] In one possible implementation, the electronic device acquires first data in a first data format, specifically including: in response to a first input, the electronic device acquires, via a CPU, raw data from a read-only memory (ROM) of the electronic device, where the raw data is compressed data of the first image. The electronic device decompresses and decodes the raw data via the CPU to obtain the first data.
[0008] In one possible implementation, obtaining the raw data from the ROM by the CPU specifically includes: the electronic device, through the CPU, reading the raw data from the ROM into an internal memory of the electronic device, where the internal memory is also used to store the first data. Thus, the electronic device reads the raw data from the ROM into the internal memory, facilitating the electronic device to process the raw data and obtain the first data.
[0009] In one possible implementation, the electronic device transmits the second data from the CPU to the GPU via the SC, specifically including: determining whether the amount of the second data is less than or equal to a data amount threshold for SC transmission. In response to the amount of the second data being less than or equal to the data amount threshold for SC transmission, the SC transmits the second data to the GPU. In this way, the electronic device can determine whether the system cache supports transmission of the second data based on the amount of the second data and the data amount threshold for system cache transmission. The electronic device only transmits the second data via the system cache if the system cache supports transmission of the second data, thereby avoiding data overflow.
[0010] In one possible implementation, the data slice includes a first data block and a second data block. The first data block includes the Y component value of the pixel, and the second data block includes the U component value and the V component value of the pixel. In this way, the electronic device stores different components separately, which facilitates the electronic device to reduce the amount of data of the U component and the V component.
[0011] In one possible implementation, the electronic device uses a CPU to divide the first data into multiple data slices, specifically including: the electronic device obtains a U value based on the value of the U component of each of four adjacent pixels in the first data, and uses the U value as the value of the U component of the four pixels. The electronic device obtains a V value based on the value of the V component of each of four adjacent pixels in the first image, and uses the V value as the value of the V component of the four pixels. The electronic device divides the data of each x*y pixel in the first data into a data slice. In this way, the electronic device reduces the data volume of both the U component and the V component to 1 / 4 of the original, reducing the storage space occupied by the image data.
[0012] In one possible implementation, the size of the first image corresponding to the original data is a first size, and the method further includes: before the electronic device transmits the second data from the CPU to the GPU via the SC, the electronic device processes the second data and adjusts the size of the first image from the first size to the second size. The electronic device displays the first image, specifically including: the electronic device displays the first image of the second size. In this way, when the electronic device displays the image of the original size of the first size at the second size, the image processing method based on the system cache can quickly decode and render the image after the size change, without the need to cache the first image of the second size, thereby reducing the time it takes for the electronic device to display the first image.
[0013] In a possible implementation, the encoding format of the first data is YUV, and the encoding format of the multiple data slices is YUV420. Thus, the data volume of the multiple data slices is smaller than the data volume of the first data.
[0014] In a possible implementation, x is greater than 100, and y is greater than 100.
[0015] In one possible implementation, x equals 512, and y equals 512. Because the values of x and y are relatively large, the electronic device can convert the first data into a smaller, more accurate second data. The second data can be a frame buffer, or texture data recognizable by the GPU. The GPU can directly render a surface based on the second data and display it on the display.
[0016] In a second aspect, the present application provides an electronic device comprising a processor and a memory. The memory is coupled to the processor and is configured to store computer program code, the computer program code comprising computer instructions. When the processor executes the computer instructions, the electronic device executes the system cache-based image processing method according to any possible implementation of the first aspect.
[0017] In a third aspect, an embodiment of the present application provides a computer storage medium comprising computer instructions, which, when executed on an electronic device, enables the electronic device to execute the system cache-based image processing method in any possible implementation of the first aspect.
[0018] In a fourth aspect, an embodiment of the present application provides a computer program product, which, when running on a computer, enables the computer to execute the system cache-based image processing method in any possible implementation of the first aspect.
[0019] In the fifth aspect, an embodiment of the present application provides a chip, including a processing circuit and an interface circuit, the interface circuit is used to receive code instructions and transmit them to the processing circuit, and the processing circuit is used to execute the code instructions to execute the system cache-based image processing method in any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] FIG1 is a schematic diagram of a process for transmitting image data by various hardware modules of an electronic device provided by an embodiment of the present application;
[0021] FIG2 is a flow chart of an image processing method based on system cache provided in an embodiment of the present application;
[0022] FIG3 is a schematic diagram of image compression provided by an embodiment of the present application;
[0023] FIG4 is a schematic diagram of a process for an electronic device to process image data according to an embodiment of the present application;
[0024] FIG5 is a schematic diagram of a process for transmitting image data by various hardware modules of another electronic device provided by an embodiment of the present application;
[0025] FIG6 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The following is a detailed description of the technical solutions in the embodiments of the present application, with reference to the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " represents "or." For example, A / B can represent A or B. "And / or" in the text is merely a description of the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, or B exists alone.
[0027] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of the technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.
[0028] In one possible implementation, after receiving a user input requesting that a specified image be displayed, the electronic device may read the image data of the specified image from a non-volatile memory such as a read-only memory (ROM) into an internal memory. The internal memory may be a random access memory (RAM), for example, a double data rate synchronous dynamic random access memory (DDR SDRAM / DDR). Subsequently, the central processing unit (CPU) of the electronic device may read the data of the specified image from the memory and process the data of the specified image. The electronic device may transmit the processed data of the specified image to a graphics processing unit (GPU). The GPU may render the specified image based on the processed data of the specified image. The data of the specified image stored in the read-only memory of the electronic device is data of the specified image compressed using an image compression algorithm (e.g., a JPEG compression algorithm). The electronic device processing the image data may include, but is not limited to, decompressing the image, decoding the image, and changing the image size.
[0029] Exemplarily, the process of transferring data for a specified image between the various hardware modules of an electronic device is shown in Figure 1. The CPU of the electronic device reads compressed image data of the specified image from a read-only memory (ROM) into an internal memory. The CPU of the electronic device may include modules for processing image data, such as an image processing module and an image scaling module. The image processing module may be configured to decompress compressed image data. The image scaling module may be configured to adjust the size of an image. The CPU of the electronic device may transmit the compressed image data of the specified image to the image processing module via the system cache (SC) and DDR. The image processing module may decompress and decode the compressed image data of the specified image to obtain decompressed and decoded image data of the specified image. The image scaling module may obtain resized image data of the specified image based on the decompressed and decoded image data provided by the image processing module. In some examples, the image processing module may be a Joint Photographic Experts Group (JPG) IP core. The image scaling module may be a scaler IP core (SCALER IP). It should be noted that the electronic device including the image processing module and the image scaling module is only an example, and the electronic device may include more or fewer modules to implement the function of processing image data.
[0030] The CPU of the electronic device can then send the processed image data of the designated image to the GPU via the memory. The GPU can render the designated image based on the processed image data. After rendering the designated image, the electronic device can display the designated image on the display screen.
[0031] In some examples, the electronic device typically represents the decompressed and decoded image data in RGBA data format. The image data in RGBA data format may include information about all pixels constituting the image. The values of the RGB channels of the pixels are used to represent the information of the pixels in the RGB color space, and the values of the alpha channels of the pixels are used to represent the transparency of the pixels. The image data of the above-mentioned specified image includes RGBA information of all pixels constituting the specified image. The electronic device may store the image data of the specified image in a linear storage manner. For example, the data of the specified image stored by the electronic device may refer to the table shown in Table 1.
[0032] Table 1: Image data in RGBA encoding format
[0033] As shown in Table 1 above, each cell in Table 1 represents a pixel of a specified image. Each table includes the values of the four RGBA channels obtained for each pixel. Thus, an electronic device can generate and display a specified image based on the information of each pixel in Table 1.
[0034] In summary, electronic devices use the RGBA data format to represent image data, which causes the image data to occupy excessive storage space. Image processing also generates new data, requiring more storage space to store this data. Consequently, when image data is transmitted between the various hardware modules of the electronic device, due to the large amount of image data, each module must copy the resulting data to memory, which consumes additional time. Taking the scenario shown in Figure 1 as an example, when an electronic device processes image data for a specific image, the image data begins at the CPU, passes through the DDR and SC, and reaches the image processing module. It then passes through the DDR to the image scaling module, and then through the DDR to the GPU. Throughout this entire process, each IP core copies the image data to its own storage space, generating multiple redundant copies of data, resulting in at least three copies of the same image data. Furthermore, because the image data representation formats of the CPU and GPU differ, the GPU must convert the image data format after receiving it from the CPU before processing it. For example, loading a 2048x2048 image takes approximately 270ms and occupies approximately 32MB of storage space. Of this, 44ms are required for image decoding, 17ms for image resizing, 28ms for GPU processing, and 181ms for data format conversion.
[0035] Based on the above-described example, an embodiment of the present application provides an image processing method based on a system cache. After receiving an input to display a specified image, the electronic device can read compressed image data of the specified image from an external memory. The electronic device can decompress and decode the compressed image data of the specified image to obtain image data of the specified image in a first data format. The electronic device can then process the image data of the specified image in the first data format to obtain image data of the specified image in a second data format. The second data format is different from the first data format, and the image data in the second data format occupies less storage space than the image data in the first data format. The electronic device can directly transmit the image data in the second data format through the system cache. Each hardware module of the electronic device supports processing image data in the second data format. In this way, the electronic device represents the image data of the specified image in the second data format, reducing the amount of image data. This allows the electronic device to directly use the system cache to transmit the image data of the specified image, thereby improving the efficiency of image data transmission by the electronic device. Furthermore, since each hardware module of the electronic device supports processing image data in the second data format, there is no need to convert the image data format between the CPU and the GPU.
[0036] Specifically, as shown in FIG2 , the specific steps of the image processing method based on the system cache are as follows:
[0037] S201. The electronic device receives an input to open a first image.
[0038] The input may include but is not limited to single-click, double-click, long-press, slide, voice command input, and the like.
[0039] S202. The CPU of the electronic device reads original data from the read-only memory, where the original data is compressed data of the first image.
[0040] The CPU of the electronic device can read the original data from a read-only memory (eg, a hard disk), wherein the electronic device can read the original data into an internal memory (eg, a DDR).
[0041] In some examples, the electronic device can read a portion (e.g., 70%) of the original data into the system cache and read another portion (e.g., 30%) of the original data into the internal memory. In this way, when the electronic device transfers the original data to the image processing module, 70% of the original data can be transferred to the image processing module through the system cache and 30% of the original data can be transferred to the image processing module through the internal memory, thereby improving the data transmission rate.
[0042] S203. The electronic device decompresses and decodes the original data to obtain first data, where the first data is the decompressed and decoded original data, and the data format of the first data is the first data format.
[0043] The electronic device may use an image processing module (eg, JPEG IP) to decompress and decode the original data to obtain the first data.
[0044] S204. The electronic device processes the first data to obtain second data in a second data format, where the second data format is different from the first data format, and the second data is stored in a system cache.
[0045] Specifically, the electronic device first slices the first data, and then compresses the sliced first data to obtain second data in a second data format.
[0046] In which, the electronic device performs a slicing operation on the first data, dividing the first data into one or more data slices (tiles) of a specified size. Each of the one or more data slices includes information about a specified number of pixels of the first image. The specified size can be used to indicate the number of pixels included in each data slice, that is, the specified number. In an embodiment of the present application, the data slice of the specified size can be referred to as a large slice. In some examples, the specified number is x*y, where x is greater than 100 and y is greater than 100.
[0047] The specified size is larger than the size of a data slice in the RGBA encoding format. For example, a data slice in the RGBA encoding format has a size of 16px*16px or 32px*8px, etc. The data slice in the RGBA encoding format can be referred to as a small slice. For example, the specified size can be 512px*512px. Because the specified size of the data slice of the first data is larger, it includes information about more pixels and has more redundant information, making it easier for the electronic device to compress the large slice.
[0048] Optionally, before or after slicing the first data, the electronic device may also compress partial information of pixel points. For example, if the first data represents the information of each pixel point using the YUV data encoding format. Among them, the value of Y is used to represent the brightness of the pixel point, and the values of U and V are used to represent the chrominance of the pixel point. During the slicing process, the electronic device may retain the Y component of each pixel point and perform compression processing on the U and V components of every 4 adjacent pixel points. Among them, the electronic device may obtain a U value based on the U component values of every adjacent 4 pixel points and use this U value as the U component value of these 4 pixel points. Similarly, the electronic device may obtain a V value based on the V component values of every adjacent 4 pixel points and use this V value as the V component value of these 4 pixel points. It should be noted that the calculated value (such as the U value, V value) may be an average value, a maximum value, a minimum value, a median value, etc., and the embodiments of this application do not limit this.
[0049] It should also be noted that the 4 adjacent pixel points may be 4 pixel points arranged horizontally, or 4 pixel points arranged vertically, or 4 pixel points arranged in a "field" shape, and the embodiments of this application do not limit this. In this way, 1 pixel point in the first data corresponds to 1 Y component, the U component values of every 4 adjacent pixel points in the first data are the same, and the V component values are also the same. The electronic device only needs to retain the U component value of one pixel point among these 4 pixel points and the V component value of one pixel point among these 4 pixel points. This makes it such that every 4 pixel points in the first data jointly correspond to 1 U component, and every 4 pixel points in the first data jointly correspond to 1 V component. The Y component of each pixel point occupies 1 channel, the UV components jointly occupy 0.5 channels, and the Y component:U component:V component in the first data = 4:1:1, reducing the data volume of the first data of the electronic device to 1 / 2 of the original.
[0050] After that, the electronic device may perform compression processing on the sliced first data to obtain the second data in the second data format. For example, the electronic device may process the sliced first data through data compression technology to obtain the second data. For example, the data compression technology may be the ARM frame buffer compression technology (arm frame buffer compression, AFBC). Among them, the electronic device may use the image processing module to process the first data to obtain the second data.
[0051] For example, using a specified size of 512*512 as an example, the steps of an electronic device processing first data to obtain second data in a second data format are described. The first data format is a YUV data format. The first data in the first data format includes YUV information for all pixels of the first image. The electronic device can slice the first data. The sliced first data is shown in Table 2.
[0052] Table 2: First data after slicing
[0053] As shown in Table 2, the first data after slicing includes two data blocks, plane0 and plane1. Among them, plane0 is used to store the Y component, and plane1 is used to store the U component and the V component. The electronic device includes multiple tiles, and each tile in the multiple tiles may include tile1 and tile2. Among them, each tile includes information of 512*512 pixels. It should be noted that Table 2 above is only an example, and the first data after slicing actually obtained by the electronic device can be represented by other forms (for example, arrays), and the embodiments of the present application do not limit this.
[0054] Afterwards, the electronic device can compress the sliced first data to obtain second data in a second data format. Exemplarily, (a) in Figure 3 can represent plane0 in the sliced first data, and the gray box therein can represent the Y component data. After the electronic device compresses the data shown in (a) in Figure 3, it can obtain the data shown in (b) in Figure 3. (b) in Figure 3 can represent plane0 in the second data. Among them, the striped box can represent valid data, and the white box can represent invalid data. As can be seen from Figure 3, after the electronic device compresses the sliced first data, it can bring together the valid data in the Y component, U component and V component, thereby further reducing the data volume of the image data of the first image.
[0055] In some examples, valid data is a non-zero value, and invalid data is a zero value. It is understandable that only plane 0 is used as an example here, and the electronic device will also compress the data in plane 1.
[0056] In this way, because the electronic device compresses the sliced first data, the valid data of the Y component, U component, and V component in the first data are concentrated together, and the invalid data are also concentrated together. When transmitting image data, the electronic device can only transmit the valid data portion, reducing the amount of image data and improving image processing efficiency.
[0057] Moreover, compared to the processing method of dividing the first data into small slices and performing compression processing based on the small slices, the embodiment of the present application uses large slices for compression, and there is less identical information between different large slices, so that there is less redundant information in the compressed image data, the compressed image data occupies less storage space, and the compression rate is high.
[0058] The compressed image data generated by electronic devices based on large slices not only improves the image compression rate and reduces storage space while ensuring relative information integrity, but also makes processing easier because both the CPU and GPU can directly process the image data of large slices. When the electronic device displays the image corresponding to this compressed image data, due to the smaller amount of compressed image data, the CPU can directly transfer it to the image processing module through the system cache, speeding up the image transmission rate.
[0059] It should be noted that the size of the data slice determines the amount of storage space occupied by the compressed data and the image processing time required by the GPU to process the image. Specifically, the smaller the data slice, the lower the compression ratio, the more storage space the compressed data occupies, the longer the data transmission time, and the shorter the image processing time required by the GPU to process the image. The larger the data slice, the higher the compression ratio, the smaller the storage space occupied by the compressed data, the shorter the data transmission time, and the longer the image processing time required by the GPU to process the image. Therefore, the optimal size of the data slice can be determined based on the image processing time and data transmission time. When the data slice is the optimal size, the sum of the image processing time and data transmission time is minimized.
[0060] In some examples, experiments show that the specified size is 512px*512px, which shortens both the image processing time and the data transmission time, and 512px*512px is used as the size of the large slice.
[0061] In other examples, the size of the large slice may also be 256px*256px, or 1024px*1024px.
[0062] In this way, since the data format of the second data is the second data format, the data volume of the first image is reduced, and the electronic device no longer needs to transmit data through DDR copy. In addition, since the data volume of the second data is relatively small, when the second data is transmitted between different hardware modules of the electronic device (for example, between different IP cores, between IP core / CPU and GPU), the system cache can be used to transmit the second data, thereby shortening the time consumed in transmitting data. For example, the electronic device uses the second data format to represent the second data, which can make the data volume of the second data less than the data volume threshold, wherein the data volume threshold can be queried by the processor model. In some application scenarios, the data volume threshold can be 8MB.
[0063] In some examples, due to the universality of the second data format, each IP core, GPU, and system on chip (SoC) unit can recognize (or read) image data in the second data format, and these hardware modules directly process the image data after receiving the image data in the second data format.
[0064] In some examples, because the various hardware modules of the electronic device can process data in the second data format, the electronic device can perform hardware-accelerated decoding (referred to as hard decoding) on the image data, and implement image processing operations through dedicated decoding circuits embedded in the hardware (e.g., JPG IP, SCALER IP). In this way, compared to software-accelerated decoding (i.e., CPU decoding of images through software programming), processing efficiency is improved, and scenarios such as cross-IP transmission of image data and transmission of video frames are optimized.
[0065] In some examples, after obtaining the second data, the electronic device may further process the second data to change the size, resolution, etc. of the first image. For example, the electronic device may change the size of the first image using an image scaling module. The electronic device then transmits the processed second data to the GPU.
[0066] Optionally, when processing the first data, the electronic device may also improve the first data in other dimensions (for example, data storage format, etc.) to reduce the amount of the second data.
[0067] S205. The GPU of the electronic device reads the second data from the system cache and renders the first image based on the second data.
[0068] The electronic device's CPU / image processing module / image scaling module can transmit the second data to the GPU. During this process, because the second data is relatively small, it can reach the GPU directly through the system cache, bypassing the DDR. After receiving the second data, the GPU can render the first image based on the second data.
[0069] It should be noted that, under the premise of large-slice compression, the electronic device can convert the first data into a smaller and more accurate second data. The second data can be a framebuffer; or the second data can be texture data that can be recognized by the GPU. The GPU can directly render the surface based on the second data and display it on the display.
[0070] Because the second data consists of large slices, the electronic device uses these slices to synchronize information between the various hardware modules. After the CPU processes a tile, the GPU can continue processing it. The CPU and GPU can perform calculations simultaneously. This creates an efficient pipeline, saving the electronic device time in processing image data and eliminating the need for the CPU and GPU to wait for each other, improving chip efficiency.
[0071] In one possible implementation, before the CPU / image processing module / image scaling module of the electronic device transmits the second data to the GPU, the electronic device may determine whether the data volume of the second data is less than the data volume threshold for system cache transmission (for example, 8MB). When the electronic device determines that the data volume of the second data is less than or equal to the data volume threshold for system cache transmission, the electronic device CPU / image processing module / image scaling module may transmit the second data to the GPU through the system cache. When the electronic device determines that the data volume of the second data is greater than the data volume threshold for system cache transmission, the electronic device CPU / image processing module / image scaling module transmits the second data to the GPU through the internal memory. In this way, the electronic device can determine whether the system cache supports the transmission of the second data based on the data volume of the second data and the data volume threshold for system cache transmission. The electronic device will only transmit the second data through the system cache when the system cache supports the transmission of the second data, thereby avoiding data overflow.
[0072] S206. The electronic device displays the first image.
[0073] After the GPU generates the first image, it can transmit the first image to the display screen for display.
[0074] It should be noted that the second data format and / or image processing method provided in the embodiment of the present application can be used to improve the processing efficiency of electronic devices in scenarios involving images or videos, such as video encoding and decoding, video frame transmission, image sharing, image downloading, and image saving, etc., not limited to the scenario of displaying the first image.
[0075] For example, as shown in FIG4 , the electronic device stores a first image in the form of a Joint Photographic Experts Group (JPG / JPEG) file. The first image has a size of 1920*1080 and is compressed using JPEG. When displaying the first image, the electronic device may first read compressed data, i.e., raw data, of the first image from an external memory in a file named pic1.jpg. The image processing module of the electronic device may decompress and decode the raw data to obtain first data in a first data format. The electronic device may then process the first data to obtain second data in a second data format.
[0076] Among them, if the first data format is RGBA8888 data format, then the size of the first data obtained by the electronic device is 1920*1080*4byte=8.2944MB. The electronic device can perform large-slice compression on the first data to obtain second data. After large-slice compression, the second data can be compressed to 1 / 4 to 1 / 8 of the first data. In the embodiment of the present application, the second data format can be referred to as the -RGB data format.
[0077] If the first data format is a YUV data format, the size of the first data obtained by the electronic device is 1920*1080*3 bytes = 6.22 MB. The electronic device can slice the first data to obtain the sliced first data. The size of the sliced first data is 3.11 MB. The electronic device then compresses the sliced first data to obtain the second data. After the compression process, the second data can be compressed to 1 / 4 to 1 / 8 of the sliced first data.
[0078] Afterwards, the electronic device may transmit the second data to the GPU via the system cache. The GPU may render the first image based on the second data. The electronic device may display the first image on a display screen.
[0079] Next, the image processing method based on system cache provided by the embodiment of the present application is introduced in conjunction with specific scenarios.
[0080] Exemplarily, the process of transferring data of a first image between various hardware modules of an electronic device is shown in FIG5 . The electronic device includes hardware modules such as a CPU, a GPU, a system cache (SC), and a DDR. The CPU includes one or more modules, such as an image processing module and an image scaling module. For a description of each of these hardware modules, please refer to the embodiment shown in FIG1 and will not be repeated here. The CPU of the electronic device reads the compressed image data of a specified image from a read-only memory into the DDR. The CPU can send the compressed image data of the specified image to the image processing module via the SC and the DDR. In some examples, the electronic device can read a portion (e.g., 70%) of the compressed image data into the system cache and another portion (e.g., 30%) of the compressed image data into the DDR. When transferring the raw data to the image processing module, the electronic device can transfer 70% of the raw data to the image processing module via the system cache and transfer 30% of the raw data to the image processing module via the DDR, thereby increasing the data transmission rate.
[0081] The image processing module can decompress and decode the compressed image data of the specified image to obtain the decompressed and decoded image data of the specified image, and process the decompressed and decoded image data to obtain image data in a second data format. The description of how the electronic device obtains the image data in the second data format can be found in the embodiment shown in FIG2 and will not be repeated here. Afterwards, the electronic device can send the image data in the second data format to the image scaling module through the system cache. The image scaling module can obtain the image data of the specified image with the size adjusted based on the data provided by the image processing module. The data format of the resized image data is also the above-mentioned second data format.
[0082] Afterwards, the electronic device's image scaling module can send the resized image data to the GPU via the system cache. The GPU can render a specified image based on the processed image data, and the electronic device can display the specified image.
[0083] As can be seen from the comparison of Figures 1 and 3, the image processing method provided in the embodiment of the present application allows the electronic device to display a specified image more quickly compared to the scenario shown in Figure 1. For example, taking an image with a size of 1080*1920 as an example, the differences between when an electronic device processes image data using the method shown in Figure 1 and the image processing method provided in the embodiment of the present application are explained.
[0084] Table 3: Image data corresponding to different image processing methods
[0085] As can be seen from Table 3 above, the size of the original image is 1080*1920. When the image is transmitted in RGBA encoding format, the number of data channels is 4, and the slice size is 16*16. After the electronic device slices the original image and processes it, the image size is 7.9MB, the image compression rate is 1, and the traffic memory is 15.8MB. Among them, the traffic memory refers to the size of the storage space occupied in the system cache when transmitting image data. Since the image compression rate is 1, when the electronic device transmits image data in RGBA encoding format, it will still transmit data from all four channels, and the storage space occupied in the system cache is 7.9*2=15.8MB.
[0086] When the image is transmitted in the second data format, the number of data channels is 1.5, and the slice size is 512*512. After the electronic device slices the original image and processes it, the image size is 2.9MB, the image compression rate is 0.5, and the traffic memory is 1.8MB. Since the image compression rate is 0.5, and since the arrangement of the image data in the second data format is also different from the arrangement of the image data in the RGBA encoding format, the amount of image data will be further reduced. Therefore, the image data in the second data format can be transmitted through the system cache. When the image data is transferred to the system cache, the data size may become 1 / 3 of the original, that is, it occupies 2.9 / 3≈0.96MB of memory. The system cache needs to allocate 2.9 / 3*2≈1.8MB of memory space for the image data.
[0087] In summary, the system cache-based image processing method provided in the embodiment of the present application occupies only 1 / 8 of the memory space in the system cache of the method shown in Figure 1. Combining Figure 5 with Figure 1, it can be seen that when the various hardware modules transmit image data, the method provided in the embodiment of the present application can still use the system cache for transfer for some images with larger data volumes, without occupying DDR space, thereby improving the data transmission rate.
[0088] In some application scenarios, when an electronic device displays an image with a size of 2048px*2048px and an image size of 1.1MB at a size of 900px*900px, the time consumed by using different image processing methods is shown in Table 4 below.
[0089] Table 4: The time required for electronic devices to process image data in different data formats
[0090] As shown in Table 4, during the image display process, when the encoding format of the image data of the designated image of the electronic device is RGBA, the electronic device uses a soft solution method to parse the image data, decode the image, scale the image, and render the image, which will take a lot of time. In addition, since the image data volume is large, the data needs to be transmitted through DDR, and the transmission takes a long time. Therefore, it takes more time for the electronic device to display the image. When the encoding format of the image data of the designated image of the electronic device is the second data format, the electronic device can use a hard solution method to parse the image data. In addition, the image data volume is small, and the data can be directly transmitted through the system cache, and the transmission time is short. Therefore, the electronic device takes less time to decode the image, scale the image, and render the image using the GPU.
[0091] Moreover, since the electronic device uses RGBA data encoding to perform image decoding and rendering operations, which takes a long time, in order to display the image faster when the user opens the image again, the electronic device can convert the obtained 900px*900px image into a PNG image format and save it in an external memory. In this way, it takes another 181ms for the electronic device to cache the data of the 900px*900px image. The image processing method based on system cache provided in the present application can quickly decode and render the image after the size is changed, and there is no need for caching. Therefore, when the electronic device displays an image at a different size for the first time, the image is displayed in the manner shown in FIG1, and the total time taken to process the image data is 270ms. The image processing method based on system cache provided in the embodiment of the present application is used to display the image, and the total time taken to process the image data is 10ms, which reduces the time it takes for the electronic device to process the image data.
[0092] The electronic device provided by the embodiments of the present application is introduced below.
[0093] The electronic device may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, an in-vehicle device, a smart home device and / or a smart city device. The embodiments of the present application do not impose any special restrictions on the specific type of the electronic device.
[0094] FIG6 shows a schematic structural diagram of the electronic device 100 .
[0095] The electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0096] It should be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0097] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0098] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0099] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0100] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.
[0101] It is understood that the interface connection relationship between the modules illustrated in the embodiment of the present invention is merely an illustrative illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.
[0102] The charging management module 140 is configured to receive charging input from a charger. While charging the battery 142, the charging management module 140 can also power the electronic device through the power management module 141. The power management module 141 is configured to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the display 194, the camera 193, and the wireless communication module 160.
[0103] The wireless communication functionality of electronic device 100 is implemented using antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, a modem processor, and a baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
[0104] The mobile communication module 150 can provide wireless communication solutions including 2G / 3G / 4G / 5G applied on the electronic device 100.
[0105] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium- or high-frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs sound signals through an audio device (including but not limited to the speaker 170A, the receiver 170B, etc.) or displays images or videos through the display screen 194.
[0106] The wireless communication module 160 can provide wireless communication solutions for application on the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.
[0107] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150 , and antenna 2 is coupled to wireless communication module 160 , so that electronic device 100 can communicate with the network and other devices through wireless communication technology.
[0108] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0109] Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.
[0110] The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
[0111] The ISP processes data fed back by camera 193. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then passed to the ISP for processing and converted into a visible image. The ISP can also perform algorithmic optimization on image noise and brightness. It can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be located within camera 193.
[0112] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0113] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0114] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. This allows electronic device 100 to play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG4.
[0115] The NPU is a neural network (NN) computing processor. Drawing on the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it rapidly processes input information and can continuously self-learn. The NPU can enable intelligent cognitive applications in electronic device 100, such as image recognition, face recognition, speech recognition, and text comprehension.
[0116] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 via the external memory interface 120 to implement data storage. For example, files such as music and videos can be stored in the external non-volatile memory.
[0117] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0118] The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor. For example, music playback, recording, etc. The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The speaker 170A, also known as the "speaker", is used to convert audio electrical signals into sound signals. The receiver 170B, also known as the "earpiece", is used to convert audio electrical signals into sound signals. The microphone 170C, also known as the "microphone" or "microphone", is used to convert sound signals into electrical signals.
[0119] The pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, the pressure sensor 180A can be located on the display screen 194. The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. The air pressure sensor 180C is used to measure air pressure. The magnetic sensor 180D includes a Hall effect sensor and can be used to detect the opening and closing of the flip cover. The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). The distance sensor 180F is used to measure distance. The proximity light sensor 180G can also be used for automatic unlocking and locking in the holster mode and pocket mode. The ambient light sensor 180L is used to sense ambient light brightness. The fingerprint sensor 180H is used to collect fingerprints. The temperature sensor 180J is used to detect temperature. The touch sensor 180K, also known as the "touch panel," can be located on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also known as a "touch screen." The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194. The bone conduction sensor 180M can obtain vibration signals. The buttons 190 include a power button, a volume button, etc. The motor 191 can generate vibration prompts. The indicator 192 can be an indicator light, which can be used to indicate the charging status, power changes, and can also be used to indicate messages, missed calls, notifications, etc. The SIM card interface 195 is used to connect a SIM card.
[0120] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A system cache-based image processing method, applied to electronic equipment, characterized in that: The electronic device comprises a central processing unit (CPU), a graphics processing unit (GPU), and a system cache (SC); the method comprises: The electronic device receives an input to display a first image; In response to the input of displaying the first image, the electronic device acquires first data of the first image based on a first data format; The electronic device divides the first data into a plurality of data slices through the CPU, each data slice including data of x*y pixels in the first data; The electronic device compresses the multiple data slices to obtain second data in a second data format; The electronic device transmits the second data from the CPU to the GPU through the SC; The electronic device renders the first image based on the second data through the GPU; The electronic device displays the first image.
2. The method according to claim 1, characterized in that The electronic device acquires first data in a first data format, specifically including: In response to the first input, the electronic device acquires original data from a read-only memory ROM of the electronic device through the CPU, wherein the original data is compressed data of the first image; The electronic device decompresses and decodes the original data through the CPU to obtain the first data.
3. The method according to claim 2, characterized in that The obtaining of original data from the ROM by the CPU specifically includes: The electronic device reads the original data from the ROM to an internal memory of the electronic device through the CPU, and the internal memory is also used to store the first data.
4. The method according to claim 1, characterized in that: The electronic device transmits the second data from the CPU to the GPU through the SC, specifically comprising: Determining whether the amount of the second data is less than or equal to a data amount threshold of the SC transmission; In response to a data amount of the second data being less than or equal to a data amount threshold transmitted by the SC, the SC transmits the second data to the GPU.
5. The method according to any one of claims 1 to 4, characterized in that The data slice includes a first data block and a second data block, the first data block includes the value of the Y component of the pixel point, and the second data block includes the value of the U component and the value of the V component of the pixel point.
6. The method according to any one of claims 1 to 5, characterized in that The electronic device divides the first data into a plurality of data slices by the CPU, specifically including: The electronic device obtains a U value based on the values of the U components of each of the four adjacent pixels in the first data, and uses the U value as the value of the U components of the four pixels; The electronic device obtains a V value based on the values of the V components of each of four adjacent pixels of the first image, and uses the V value as the value of the V components of the four pixels; The electronic device divides the data of each x*y pixel points in the first data into a data slice.
7. The method according to any one of claims 1 to 6, characterized in that The size of the first image corresponding to the original data is a first size; and the method further includes: Before the electronic device transmits the second data from the CPU to the GPU through the SC, the electronic device processes the second data to adjust the size of the first image from the first size to a second size; The electronic device displays the first image, specifically comprising: The electronic device displays the first image of the second size.
8. The method according to any one of claims 1 to 7, characterized in that The encoding format of the first data is YUV; the encoding format of the multiple data slices is YUV420.
9. The method according to any one of claims 1 to 8, characterized in that The x is greater than 100, and the y is greater than 100.
10. The method according to claim 9, characterized in that The x is equal to 512, and the y is equal to 512.
11. An electronic device, characterized in that: It comprises a processor and a memory; wherein the memory is coupled to the processor, the memory is used to store computer program code, and the computer program code comprises computer instructions, and when the processor executes the computer instructions, the electronic device executes the method as described in any one of claims 1-10.
12. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on an electronic device, the electronic device is caused to execute the method as claimed in any one of claims 1 to 10.
13. A chip, characterized in that: The method comprises a processing circuit and an interface circuit, wherein the interface circuit is used to receive code instructions and transmit the code instructions to the processing circuit, and the processing circuit is used to run the code instructions to execute the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Image processing method based on system cache and related device
CN118741146A
Method and system for processing pictures with original data format
CN103795928A
Systems and methods for converting two-dimensional images into three-dimensional images
US20120235988A1
Partitioning high resolution images into sub-images for display
US20120287151A1
Methods of and apparatus for storing data in memory in data processing systems
US20130198485A1
