Image decoding method and apparatus, and electronic device and readable storage medium
By matching the YUV encoding format during image decoding and performing YUV decoding when the image width is an integer multiple of 2, the problem of wasted image decoding resources is solved, and more efficient resource utilization is achieved.
Patent Information
- Application Number
- PCT/CN2025/102484
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-26
- Filing Date
- 2025-06-20
- Publication Date
- 2026-01-02
AI Technical Summary
In the existing technology, electronic devices waste resources because they default to converting the image encoding format to RGB encoding format during the image decoding process.
When the image decoding interface is called and a hardware configuration flag is passed in, the encoding format of the target image is obtained, and YUV decoding is performed when the encoding format matches the YUV encoding format and the image width is an integer multiple of 2, thus avoiding unnecessary RGB decoding.
This reduces resource waste during image decoding and improves resource utilization efficiency.
Smart Images

Figure CN2025102484_02012026_PF_FP_ABST
Abstract
Description
Image decoding method, device, electronic device and readable storage medium
[0001] Cross-reference to Related Applications
[0002] The present application claims priority to the Chinese patent application No. 202410839241.9 filed on June 26, 2024 in China, the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0003] The present application belongs to the field of image processing, and particularly relates to an image decoding method, device, electronic device and readable storage medium. BACKGROUND
[0004] In the related art, when an electronic device decodes an image, the image is converted into an RGB coding format by default, and then the decoded RGB pixel parameters are stored to a GPU or a CPU.
[0005] In this way, no matter what the coding format of the target image is, the image coding needs to be converted into an RGB coding format first, that is, if the target image is an image in a non-RGB coding format, the image needs to be converted into an RGB coding format first, thereby causing waste of resources. SUMMARY
[0006] The purpose of the embodiments of the present application is to provide an image decoding method, device, electronic device and readable storage medium, which can reduce the waste of resources in the process of decoding an image by an electronic device.
[0007] In a first aspect, the embodiments of the present application provide an image decoding method, which comprises: in a case where a decode image interface is called and a parameter carried by the decode image interface carries a hardware configuration mark, obtaining a coding format of a target image; in a case where the coding format matches a YUV coding format and a width value of the target image is an integer multiple of 2, performing YUV decoding on the target image to obtain YUV pixel information of the target image.
[0008] In a second aspect, the embodiments of the present application provide an image decoding device, which comprises: an obtaining module and a decoding module; the obtaining module is configured to, in a case where a decode image interface is called and a parameter carried by the decode image interface carries a hardware configuration mark, obtain a coding format of a target image; and the decoding module is configured to, in a case where the coding format matches a YUV coding format and a width value of the target image is an integer multiple of 2, perform YUV decoding on the target image to obtain YUV pixel information of the target image.
[0009] In a third aspect, an electronic device is provided. The electronic device includes a processor and a memory. The memory stores programs or instructions executable by the processor. The programs or instructions, when executed by the processor, implement the steps of the method of the first aspect.
[0010] In a fourth aspect, a readable storage medium is provided. The readable storage medium stores programs or instructions. The programs or instructions, when executed by a processor, implement the steps of the method of the first aspect.
[0011] In a fifth aspect, a chip is provided. The chip includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is configured to execute programs or instructions to implement the method of the first aspect.
[0012] In a sixth aspect, a computer program product is provided. The computer program product is stored in a storage medium. The computer program product is executed by at least one processor to implement the method of the first aspect.
[0013] In the embodiments of the present application, when the decoding image interface is called and the parameter carried by the incoming decoding image interface carries the hardware configuration flag, the encoding format of the target image is obtained. When the encoding format matches the YUV encoding format and the width value of the target image is an integer multiple of 2, the target image is YUV decoded to obtain YUV pixel information of the target image. In this way, the electronic device can avoid wasting resources in the image decoding process caused by decoding images that do not need to be decoded in the RGB decoding mode according to the RGB decoding format. BRIEF DESCRIPTION OF DRAWINGS
[0014] FIG. 1 is a schematic diagram of an image decoding method according to an embodiment of the present application;
[0015] FIG. 2 is a schematic diagram of an image decoding method according to an embodiment of the present application;
[0016] FIG. 3 is a schematic diagram of an image decoding device according to an embodiment of the present application;
[0017] FIG. 4 is a schematic diagram of an image decoding device according to an embodiment of the present application;
[0018] FIG. 5 is a schematic diagram of an image decoding device according to an embodiment of the present application;
[0019] FIG. 6 is a schematic diagram of an electronic device according to an embodiment of the present application;
[0020] FIG. 7 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0021] The technical solutions in the embodiments of the present application will be clearly described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art belong to the scope of protection of the present application.
[0022] The terms "first", "second", and the like in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a particular order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than that illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of a kind and do not limit the number of objects, for example, the first object can be one or more. In addition, "and / or" in the specification and claims indicates at least one of the connected objects, and the character " / " generally indicates that the objects before and after are in an "or" relationship.
[0023] The terms "at least one", "at least one of", and the like in the specification and claims of the present application refer to any one of the objects, a combination of any two or more of the objects. For example, at least one of a, b, and c can mean "a", "b", "c", "a and b", "a and c", "b and c", and "a, b, and c", where a, b, and c can be single or multiple. Similarly, "at least two" refers to two or more, and has a similar meaning to "at least one".
[0024] The following explains the terms that may be involved in the embodiments of the present application:
[0025] 1. Bitmap: the form in which an image is stored in memory. A bitmap is an array of bits that dictates the color of each pixel in a pixel matrix. Also known as a raster image or a drawn image, it is composed of individual dots called pixels.
[0026] 2. Luminance chrominance encoding method (YUV): a color encoding method adopted by European television systems, which is a color space adopted by analog color television systems. The importance of using YUV color space is that its luminance signal Y and chrominance signals U and V are separated
[0027] 3. Red-green-blue encoding method (RGB): a color encoding method for bitmaps, which uses the optical intensity of red, green, and blue three primary colors to represent a color. This is the most common bitmap encoding method and can be directly used for screen display. R represents the red channel, G represents the green channel, and B represents the blue channel.
[0028] 4. RGBA: A color space, R represents the red channel, G represents the green channel, B represents the blue channel, and A represents the transparency channel.
[0029] 5. ColorSpace: Color space refers to a mathematical model used to describe and represent colors. It is a three-dimensional mathematical space used to describe the properties of colors, such as brightness, hue, and saturation.
[0030] 6. HardwareBuffer: A graphics memory buffer introduced in Android, used to efficiently share graphics data between different graphics processing units.
[0031] 7. Hardware Config: If the image carries this tag, the image will be stored in the GPU under this configuration, and the image is immutable. This configuration is only applicable when the only operation of the image is to draw itself on the screen.
[0032] 8. Application Programming Interface (API): Application Programming Interface is a set of definitions, programs and protocols that enable communication between computer software through API interfaces. One of the main functions of API is to provide a common set of functions. Programmers can develop applications by calling API functions, which can reduce programming tasks. API is also a kind of middleware that provides data sharing for various platforms.
[0033] It should be noted that the image decoding method provided by the embodiments of the present application can be executed by a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted electronic device, etc. In some embodiments of the present application, the electronic device is taken as an example to execute the image decoding method, and the image decoding method provided by the embodiments of the present application is described.
[0034] The image decoding method, device, electronic device and readable storage medium provided by the embodiments of the present application will be described in detail below in combination with the drawings and specific embodiments and their application scenarios.
[0035] The occupation of image in memory in the operating system of electronic equipment has been a problem that people complain about. In the earlier operating system version, in order to be compatible with the device without GPU, the image is stored in the CPU memory by default. After the introduction of the rendering pipeline of GPU, the image also needs to be copied to the memory of GPU when drawing, which causes great waste. Therefore, the operating system introduces Hardware Config, and the image carrying the tag can only be accessed by GPU and cannot be accessed by CPU, so as to reduce the occupation of image in CPU memory, that is, the image with Hardware Config set cannot be accessed by CPU, so it is not necessary to copy a copy for CPU access, which can save half of the memory.
[0036] However, the electronic device will store the pixel points according to the image format indicated in the Hardware Config by default, for example, store the pixel points in the RGBA8888 format. If the original format of the picture is YUV format, the electronic device will decode the YUV format image into RGB format image, and then store the pixel points in the RGBA8888 format, so that the resources are wasted.
[0037] In the embodiment of the present application, in the case that the decode image interface is called and the parameter carried by the decode image interface carries a hardware configuration tag, the encoding format of the target image is obtained; in the case that the encoding format matches the YUV encoding format and the width value of the target image is an integer multiple of 2, the target image is YUV decoded to obtain YUV pixel information of the target image. In this way, the electronic device can avoid the resource waste in the image decoding process caused by decoding the image that does not need to be decoded in the RGB decoding mode according to the RGB decoding format.
[0038] The execution subject of the image decoding method provided in the embodiment can be an image decoding device, which can be an electronic device, or a control module or a processing module in the electronic device, etc. The technical solutions provided in the embodiments of the present application will be described below with the electronic device as an example.
[0039] The embodiment of the present application provides an image decoding method, and FIG. 1 shows a flowchart of an image decoding method provided in the embodiment of the present application, which can be applied to an electronic device. As shown in FIG. 1, the image decoding method provided in the embodiment of the present application can include the following steps 201 and 202.
[0040] Step 201, in the case that the decode image interface is called and the parameter carried by the decode image interface carries a hardware configuration tag, the electronic device obtains the encoding format of the target image.
[0041] In some embodiments of the present application, the target image is a bitmap, that is, the target image is a pixel image, and thus the pixel information of the image can be decoded by using different decoding modes and stored in the hardware of the electronic device. Alternatively, the target image is determined by a parameter passed through the decoding image interface, and the parameter indicates the storage path of the target image.
[0042] In some embodiments of the present application, the hardware can be any one of a GPU and a CPU.
[0043] In some embodiments of the present application, the decoding image interface includes any one of YUV decoding and RGB decoding.
[0044] For example, the YUV decoding is directly decoding YUV pixel information in the target image by using an image decoder.
[0045] For example, the RGB decoding is directly decoding RGB pixel information in the target image by using an image decoder.
[0046] In some embodiments of the present application, when the electronic device receives the calling interface instruction through the decoding image interface, the decoding image interface decodes the target image according to the parameter carried in the calling interface instruction.
[0047] In some embodiments of the present application, the calling interface instruction can be any form of instruction.
[0048] In some embodiments of the present application, the parameter carried in the calling interface instruction can include, but is not limited to, a hardware configuration flag and a storage mode of the target image.
[0049] In some embodiments of the present application, the storage mode can include, but is not limited to, ALPHA-8, RGB-565, ARGB-4444, ARGB-8888 or YUV-4444.
[0050] For example, ALPHA-8 is composed of 8, has no RGB value and YUV value, only ALPHA value, and one pixel occupies 1 byte.
[0051] For example, RGB-565 is composed of 16 bits, R is 5 bits, G is 6 bits, and B is 5 bits, and one pixel point occupies 2 bytes.
[0052] For example, RGB-4444 is composed of 16 bits, A is 4 bits, R is 4 bits, G is 4 bits, and B is 4 bits, and one pixel point occupies 2 bytes.
[0053] Exemplarily, RGB-8888, A is 8 bits, R is 8 bits, G is 8 bits, B is 8 bits, a total of 32 bits, one pixel point occupies 4 bytes.
[0054] Exemplarily, YUV-4444, A is 4 bits, R is 4 bits, G is 4 bits, B is 4 bits, a total of 16 bits, one pixel point occupies 2 bytes.
[0055] In some embodiments of the present application, in a scenario where the image needs to be saved, the electronic device triggers the decoding image interface to send a call interface instruction.
[0056] In some embodiments of the present application, the scenario where the electronic device needs to save the image includes but is not limited to any one of the following:
[0057] Taking a photo using the electronic device;
[0058] Downloading an image from an application program;
[0059] Receiving an image transmitted from another electronic device.
[0060] In some embodiments of the present application, the encoding format can be any one of the following: YUV encoding format, RGB encoding format.
[0061] Exemplarily, the YUV encoding format is a format for encoding the target image according to the brightness and color of the color.
[0062] Exemplarily, the RGB encoding format is an image for encoding the target image according to the color of the red channel, the green channel and the blue channel.
[0063] In some embodiments of the present application, the target image can carry a Hardware Config label, which is used to inform the electronic device to use hardware cache to store the image.
[0064] It should be noted that if the Hardware Config label is not carried in the parameters of the decoding image interface, it means that the target image cannot use hardware cache to store the image, and then the image is decoded and stored in the memory according to the conventional operation.
[0065] Step 202, the electronic device decodes the target image in the case that the encoding format of the target image matches the YUV encoding format and the width value of the target image is an integer multiple of 2, to obtain YUV pixel information of the target image.
[0066] In some embodiments of the present application, the width value of the target image and the encoding format of the target image can be obtained from the image file corresponding to the target image.
[0067] In some embodiments of the present application, the image file of the target image is used to store the image information of the target image.
[0068] Exemplarily, the image file can be in JPEG, PNG and WEBP formats.
[0069] Exemplarily, JPEG is a lossy compression format, which compresses a single bitmap in 24-bit color, but does not support transparency. When using JPEG compression, an appropriate compression rate needs to be selected to avoid too poor image quality.
[0070] Exemplarily, PNG is a lossy compression format that supports all colors. PNG occupies a larger space due to lossless compression, and currently PNG is generally converted to WEBP for use.
[0071] Exemplarily, WEBP supports both lossless and lossy compression, and its lossless compression rate is better than PNG, and its lossy compression rate is better than JPEG. At the same time, it supports all colors and supports multi-frame animation. The only disadvantage is that the compression efficiency is lower than JPEG and PNG.
[0072] In some embodiments of the present application, the YUV pixel information can be the pixel value of each pixel in the target image.
[0073] In some embodiments of the present application, if the electronic device queries that the width value of the target image is an integer multiple of 2 when the target image is in YUV encoding format, the electronic device decodes the target image in YUV and stores the decoded YUV pixel information in hardware; otherwise, if the width value of the image size is not an integer multiple of 2, the electronic device decodes the target image in RGB and stores the decoded RGB pixel information in hardware.
[0074] In some embodiments of the present application, since the pixel information of the target image is stored in hardware, based on the characteristics of hardware, when the image is stored, usually one of the two pixel points in the image is sampled and stored. Therefore, the YUV image can only be decoded to obtain YUV pixel information when the width value of the image is an integer multiple of 2. If the width value of the YUV image is not an integer multiple of 2, YUV pixel information cannot be decoded.
[0075] In some embodiments of the present application, the image decoding process is as follows: run-level symbols are extracted from the bit sequence of the image. These symbols are converted into a series of coefficients and reordered into a quantized coefficient block. At this point, the decoding operation is exactly the opposite of the corresponding encoding operation. Each coefficient is multiplied by an integer scaling factor, which is usually referred to as "dequantization". Then, the dequantized coefficients are reconstructed by inverse transformation to reconstruct the decoded image, which includes the YUV pixel parameters of each pixel point in the image.
[0076] In some embodiments of the present application, since the target image is stored in hardware, based on the hardware characteristics, when the YUV image is stored, usually one of the two pixels in the image is sampled and stored, therefore, the YUV image can be stored in YUV storage format only when the width value of the image size is a multiple of 2, if the width value of the YUV image is not a multiple of 2, then it cannot be stored in YUV storage format.
[0077] Optionally, in some embodiments of the present application, before the step 202 of "YUV decoding the target image to obtain YUV pixel information of the target image", the image decoding method provided by the embodiments of the present application further includes step 301, and further, the step 202 specifically includes step 202a:
[0078] Step 301, the electronic device acquires the image format of the target image.
[0079] In some embodiments of the present application, the electronic device acquires the image information of the target image from the image file of the target image.
[0080] For example, the electronic device can decompress the image file of the target image to obtain the image information of the target image.
[0081] For example, the image information can include but is not limited to image size, image encoding format, image format, etc.
[0082] In some embodiments of the present application, the image format can be a point 9 format or a non-point 9 format image.
[0083] For example, the point 9 image format is the image format after stretching the image.
[0084] It should be noted that the electronic device can obtain the processed point 9 image after stretching the target image, and the target image can be a YUV encoded image or an RGB encoded image.
[0085] It can be understood that the electronic device has an automatic landscape function, and the same interface will change the image display direction according to the parameters of the direction sensor in the electronic device. After the interface of the electronic device changes direction, the graphics on the interface will be stretched due to the change in length and width, causing distortion of the graphics. When the electronic device displays an image, there are many different resolutions, and many control cutout files will be blurred and distorted after being enlarged and stretched. At this time, the electronic device can use the point nine PNG technology to stretch the picture horizontally and vertically at the same time to achieve perfect display effect under multiple resolutions.
[0086] In step 202c, the electronic device performs YUV decoding on the target image in a case where the image format does not match the target image format and the encoding format of the target image is a YUV encoding format, to obtain YUV pixel information of the target image.
[0087] In some embodiments of the present application, the target image format is used to represent that at least a partial region of the image needs to be processed, for example, stretched.
[0088] In some embodiments of the present application, the target image format can be customized by a user or can be a default of the electronic device, which is not limited in the present application.
[0089] In some embodiments of the present application, the target image format can be a point 9 image format.
[0090] In some embodiments of the present application, if the image format of the target image is not the point 9 format, the electronic device determines that the image format does not match the target image format, and performs YUV decoding on the target image to obtain YUV pixel information of the target image.
[0091] In this way, since the point 9 format image is processed, the pixel information of the image is more responsible than that of the target image, and is not suitable for storing the image in the hardware cache. If the image is stored in the YUV storage format, resource waste may be caused. Therefore, in a case where the image format is not the point 9 format, the electronic device stores the image in the YUV storage format, thereby avoiding the problem of resource waste.
[0092] Optionally, in some embodiments of the present application, after the step 202 of performing YUV decoding on the target image to obtain YUV pixel information of the target image, the image decoding method provided by the embodiments of the present application further includes step 401.
[0093] In step 401, the electronic device stores the YUV pixel information in a first hardware.
[0094] In some embodiments of the present application, the first hardware is a hardware indicated by the hardware configuration marker.
[0095] For example, the first hardware can be a GPU or a CPU.
[0096] In some embodiments of the present application, after the electronic device identifies that the parameter carried in the decoding image interface carries the hardware indicated by the hardware configuration marker, that is, the Hardware Config marker, the electronic device stores the pixel information of the decoded image in the hardware, that is, the first hardware.
[0097] In this way, the electronic device can store the image into the appropriate hardware according to the hardware indicated by the Hardware Config, so as to reduce the memory of other hardware.
[0098] In the embodiments of the present application, in a case where the decoding image interface is invoked and the parameter carried in the decoding image interface carries the hardware configuration flag, the encoding format of the target image is acquired; in a case where the encoding format matches the YUV encoding format and the width value of the target image is an integer multiple of 2, the target image is YUV decoded to obtain YUV pixel information of the target image. In this way, the electronic device can avoid wasting resources in the image decoding process caused by decoding the image in the RGB decoding format which is not required to be decoded in the RGB decoding manner.
[0099] Optionally, in some embodiments of the present application, the above step 202 can be replaced by the following step 203:
[0100] Step 203, the electronic device decodes the target image in the RGB decoding manner to obtain the RGB pixel information of the target image in a case where the image format of the target image matches the target image format.
[0101] In some embodiments of the present application, the target image format is used to represent that at least part of the region of the image needs to be processed, for example, stretched.
[0102] In some embodiments of the present application, the target image format can be customized by the user or can be the default of the electronic device, which is not limited in the present application.
[0103] In some embodiments of the present application, the target image format can be a point 9 image format.
[0104] In some embodiments of the present application, if the image format of the target image is the point 9 format, the electronic device judges that the target image format matches and decodes the target image in the RGB decoding manner to obtain the RGB pixel information of the target image.
[0105] In some embodiments of the present application, the image decoding process is as follows: run-level symbols are extracted from the bit sequence of the image. These symbols are converted into a series of coefficients and reordered into a quantized coefficient block. At this point, the decoding operation is just the opposite of the corresponding encoding operation. Each coefficient is multiplied by an integer scaling factor, which is usually referred to as “dequantization”. Then, the dequantized coefficients are reconstructed into the decoded image by inverse transformation, and the decoded image includes the RGB pixel parameters of each pixel point in the image.
[0106] Thus, since the image in the dot 9 format is processed, the pixel information of the image is more complex than that of the target image, and is not suitable for storing the image in the hardware cache. If the YUV pixel information decoded from the image is stored, resource waste may be caused. Therefore, in the case where the image format is the dot 9 format, the RGB pixel information decoded by the electronic device is stored, and the problem of resource waste can be avoided.
[0107] Optionally, in some embodiments of the present application, the step 202 can be replaced by the following step 204:
[0108] In step 204, the electronic device decodes the target image in the RGB format to obtain the RGB pixel information of the target image, in the case where the encoding format of the target image matches the RGB format.
[0109] In some embodiments of the present application, in the case where the encoding format of the target image is the RGB format, the electronic device determines that the RGB format is matched.
[0110] In some embodiments of the present application, the image decoding process is as follows: run-level symbols are extracted from the bit sequence of the image. The symbols are converted into a series of coefficients and reordered into a quantized coefficient block. At this point, the decoding operation is exactly opposite to the corresponding encoding operation. Each coefficient is multiplied by an integer scaling factor, which is usually referred to as "dequantization". Then, the dequantized coefficients are reconstructed by inverse transformation to reconstruct the decoded image, which includes the RGB pixel information of each pixel point in the image.
[0111] Optionally, in some embodiments of the present application, the step 202 can be replaced by the following step 205.
[0112] In step 205, the electronic device decodes the target image in the RGB format to obtain the RGB pixel information of the target image, in the case where the encoding format of the target image matches the YUV format and the width value of the target image is not an integer multiple of 2.
[0113] In some embodiments of the present application, after obtaining the image size of the target image, the electronic device can determine the width value of the target image. In the case where the width value of the target image is an integer multiple of 2, the electronic device decodes the target image in the YUV format. Otherwise, in the case where the width value of the target image is not an integer multiple of 2, the electronic device decodes the target image in the RGB format.
[0114] In some embodiments of the present application, the image decoding process is as follows: run-level symbols are extracted from the bit sequence of the image. These symbols are converted into a series of coefficients and reordered into a quantized coefficient block. At this point, the decoding operation is the inverse of the corresponding encoding operation. Each coefficient is multiplied by an integer scaling factor, which is commonly referred to as "dequantization". The dequantized coefficients are then reconstructed into the decoded image by inverse transformation, which includes the RGB pixel information of each pixel in the image.
[0115] In this way, the electronic device can flexibly select different decoding modes to decode the image according to the image format of the target image, the encoding format of the image, and the parameters of the image, thereby avoiding the problem of converting the image in YUV encoding format after decoding, and further reducing the waste of resources in the image decoding process.
[0116] Optionally, in some embodiments of the present application, the step 203 to step 205 "decoding the target image in RGB to obtain the RGB pixel information of the target image" specifically includes step 501:
[0117] Step 501, the electronic device stores the RGB pixel parameters in the second hardware.
[0118] In some embodiments of the present application, the second hardware is the hardware indicated by the hardware configuration marker.
[0119] For example, the second hardware can be a GPU or a CPU.
[0120] In some embodiments of the present application, after the electronic device identifies the hardware indicated by the hardware configuration marker, i.e. the Hardware Config marker, the pixel information of the decoded image is stored in the hardware, i.e. the second hardware.
[0121] It should be noted that the RGB pixel information in the step 203 to step 205 can include the RGB pixel value of each pixel in the target image, or pixel parameters, etc.
[0122] In this way, the electronic device can store the image in the appropriate hardware according to the hardware indicated by the Hardware Config, so as to reduce the memory of other hardware.
[0123] The following possible embodiment details the actual implementation process of the embodiments of the present application. Specifically, as shown in FIG. 2, it includes steps A1 to A6:
[0124] Step A1: The electronic device receives a request for image decoding and calls the decode image interface to store the image.
[0125] Step A2: If the image is detected by the decoding image interface of the electronic device and the Hardware Config flag is configured, it means that the electronic device can store the picture using the hardware cache. If the Hardware Config flag is configured, step A3 is performed, and if not, step A6 is performed.
[0126] Step A3: The electronic device determines whether the image format of the target image is a point 9 format or an RGC format image, that is, the target image format described above. If yes, step A6 is performed, and if not, step A4 is performed.
[0127] Exemplarily, point 9 is an image format commonly used by electronic devices, which is between Bitmap and vector graphics. Such an image requires some post-processing, such as stretching only in a certain area, and thus is not suitable for hardware cache storage.
[0128] Step A4: The electronic device queries the YUV information of the target image, that is, the image information in the image file. If the image in the YUV image format is aligned, the width value of the image is a multiple of 2, step A5 is performed, and if the image width value is not a multiple of 2, step A6 is performed.
[0129] Step A5: The electronic device calls the picture decoder to directly decode the YUV pixels of the target image, which is less color format conversion compared to outputting the RGBA format, and the decoding speed is faster. At the same time, the electronic device allocates a hardware cache matching the YUV format, and saves the YUV pixel parameters to the hardware cache.
[0130] Step A6: The electronic device calls the image decoder to output the RGBA pixel parameters of the original picture by default. At the same time, the electronic device allocates a hardware cache matching the image format of the target image, and saves the pixel parameters of the target image to the hardware cache.
[0131] In this way, the storage of the picture by the third-party application will occupy the memory space of the electronic device. The third-party application uses the scheme, and only decodes to the hardware cache for GPU access for pictures such as jpeg or webp, without copying a copy to the memory for CPU access, thereby saving 50% of the memory. In addition, the storage according to the YUV storage format directly saves the image decoding resources, and compared with the RGBA format, it can save 40%-63% of the memory, and the overall memory occupation of one picture can save about 80%.
[0132] Each method embodiment described above, or each possible implementation manner in each method embodiment can be executed alone or in combination of any two or more, and the specific execution can be determined according to actual use requirements, which is not limited in the embodiments of the present application.
[0133] The image decoding method provided in the embodiments of the present application can be executed by an electronic device or an image decoding apparatus. The image decoding method provided in the embodiments of the present application is described below by taking an electronic device as an example.
[0134] FIG. 3 shows a possible structural diagram of an image decoding apparatus involved in the embodiments of the present application. As shown in FIG. 3, the image decoding apparatus 700 can include an obtaining module and a decoding module.
[0135] The obtaining module 701 is configured to obtain an encoding format of a target image in a case where a decoding image interface is invoked and a parameter carried by the decoding image interface carries a hardware configuration mark. The decoding module 702 is configured to perform YUV decoding on the target image to obtain YUV pixel information of the target image in a case where the encoding format matches a YUV encoding format and a width value of the target image is an integer multiple of 2.
[0136] Optionally, in some embodiments of the present application, the obtaining module 701 is further configured to obtain an image format of the target image before performing YUV decoding on the target image to obtain the YUV pixel information of the target image. The decoding module 702 is specifically configured to perform YUV decoding on the target image to obtain the YUV pixel information of the target image in a case where the image format does not match a target image format and the encoding format is the YUV encoding format.
[0137] Optionally, in some embodiments of the present application, the decoding module 702 is further configured to perform RGB decoding on the target image to obtain RGB pixel information of the target image in a case where the image format matches the target image format.
[0138] Optionally, in some embodiments of the present application, in combination with FIG. 3, as shown in FIG. 4, the apparatus 700 further includes a storage module 703. The storage module 703 is configured to store the YUV pixel information in a first hardware after the decoding module 702 performs YUV decoding on the target image to obtain the YUV pixel information of the target image. The first hardware is a hardware indicated by the hardware configuration mark.
[0139] Optionally, in some embodiments of the present application, the decoding module 702 is further configured to:
[0140] perform RGB decoding on the target image to obtain RGB pixel information of the target image in a case where the encoding format matches a YUV encoding format and the width value of the target image is not an integer multiple of 2; or
[0141] perform RGB decoding on the target image to obtain RGB pixel information of the target image in a case where the encoding format matches a RGB encoding format.
[0142] Optionally, in some embodiments of the present application, as shown in Figure 5, the apparatus 700 further comprises a storage module 704, which is configured to store the RGB pixel information in the second hardware, which is the hardware indicated by the hardware configuration mark, after the decoding module 702 decodes the target image in the RGB mode to obtain the RGB pixel information of the target image.
[0143] In the image decoding apparatus provided by the embodiments of the present application, in the case that the decoding image interface is invoked and the parameter carried by the decoding image interface carries the hardware configuration mark, the encoding format of the target image is obtained; in the case that the encoding format matches the YUV encoding format and the width value of the target image is an integer multiple of 2, the target image is decoded in the YUV mode to obtain the YUV pixel information of the target image. In this way, the electronic device can avoid the resource waste in the image decoding process caused by decoding the image in the RGB decoding mode when the image does not need to be decoded in the RGB decoding mode.
[0144] The image decoding apparatus in the embodiments of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than the terminal. For example, the electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted electronic device, a Mobile Internet Device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), and the like, and can also be a server, a Network Attached Storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, and the like, and the embodiments of the present application are not limited in this regard.
[0145] The image decoding apparatus in the embodiments of the present application can be an apparatus with an operating system. The operating system can be an Android operating system, an ios operating system, or other possible operating systems, and the embodiments of the present application are not limited in this regard.
[0146] The image decoding apparatus provided by the embodiments of the present application can implement all the processes implemented by the image decoding method embodiments, and thus repeated details are not described herein.
[0147] Optionally, as shown in FIG. 6, the embodiment of the present application further provides an electronic device 800, comprising a processor 801 and a memory 802, wherein the memory 802 stores programs or instructions executable on the processor 801, and the programs or instructions are executed by the processor 801 to implement the steps of the above-mentioned image decoding method embodiments and achieve the same technical effects. To avoid repetition, details are not described herein.
[0148] It should be noted that the electronic device in the embodiment of the present application includes the mobile electronic device and the non-mobile electronic device described above.
[0149] FIG. 7 is a schematic diagram of a hardware structure of an electronic device for implementing the embodiment of the present application.
[0150] The electronic device 100 includes, but is not limited to, a radio frequency unit 101, a network module 102, an audio output unit 103, an input unit 104, a sensor 105, a display unit 106, a user input unit 107, an interface unit 108, a memory 109, and a processor 110, etc.
[0151] Those skilled in the art can understand that the electronic device 100 can further include a power supply (such as a battery) for supplying power to each component, and the power supply can be logically connected to the processor 110 through a power management system, so as to realize the functions of power management, such as charging, discharging, and power consumption management, through the power management system. The electronic device structure shown in FIG. 7 does not constitute a limitation on the electronic device, and the electronic device can include more or fewer components than those shown, or combine certain components, or different component arrangements, which are not described herein.
[0152] The processor 110 is configured to obtain an encoding format of a target image when a decoding image interface is called and a parameter carried by the decoding image interface carries a hardware configuration mark. The processor 110 is configured to perform YUV decoding on the target image to obtain YUV pixel information of the target image when the encoding format matches the YUV encoding format and a width value of the target image is an integer multiple of 2.
[0153] Optionally, in some embodiments of the present application, the processor 110 is further configured to obtain an image format of the target image before performing YUV decoding on the target image to obtain YUV pixel information of the target image. The processor 110 is configured to perform YUV decoding on the target image to obtain YUV pixel information of the target image when the image format does not match the target image format and the encoding format is the YUV encoding format.
[0154] Optionally, in some embodiments of the present application, the processor 110 is further configured to, in a case where the image format matches the target image format, perform RGB decoding on the target image to obtain RGB pixel information of the target image.
[0155] Optionally, in some embodiments of the present application, the memory 109 is configured to store the YUV pixel information in the first hardware after the processor 110 performs YUV decoding on the target image to obtain the YUV pixel information of the target image, wherein the first hardware is a hardware indicated by the hardware configuration flag.
[0156] Optionally, in some embodiments of the present application, the processor 110 is further configured to:
[0157] perform RGB decoding on the target image to obtain RGB pixel information of the target image in a case where the encoding format matches the YUV encoding format and the width value of the target image is not an integer multiple of 2; or
[0158] perform RGB decoding on the target image to obtain RGB pixel information of the target image in a case where the encoding format matches the RGB encoding format.
[0159] Optionally, in some embodiments of the present application, the memory 109 is further configured to store the RGB pixel information in the second hardware after the processor 110 performs RGB decoding on the target image to obtain the RGB pixel information of the target image, wherein the second hardware is a hardware indicated by the hardware configuration flag.
[0160] In the electronic device provided in the embodiments of the present application, in a case where the decoding image interface is called and the parameter carried by the decoding image interface carries the hardware configuration flag, the encoding format of the target image is obtained; and in a case where the encoding format matches the YUV encoding format and the width value of the target image is an integer multiple of 2, YUV decoding is performed on the target image to obtain YUV pixel information of the target image. In this way, the electronic device can avoid resource waste in the image decoding process caused by performing RGB decoding on images that do not need to be decoded in the RGB decoding mode.
[0161] It should be understood that in the embodiments of the present application, the input unit 104 can include a graphics processor (GPU) 1041 and a microphone 1042. The graphics processor 1041 processes image data of a still picture or a video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 106 can include a display panel 1061, which can be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 107 includes at least one of a touch panel 1071 and other input devices 1072. The touch panel 1071 is also referred to as a touch screen. The touch panel 1071 can include two parts of a touch detection device and a touch controller. The other input devices 1072 can include, but are not limited to, a physical keyboard, function keys (such as volume control keys, on-off keys, and the like), a trackball, a mouse, a joystick, and the like, which will not be described here.
[0162] The memory 109 can be used to store software programs and various data. The memory 109 can mainly include a first storage area storing programs or instructions and a second storage area storing data, wherein the first storage area can store an operating system, application programs or instructions required by at least one function (such as a sound playing function, an image playing function, and the like), and the like. In addition, the memory 109 can include a volatile memory or a non-volatile memory, or the memory 109 can include both volatile and non-volatile memories. The non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synch link dynamic random access memory (SLDRAM), and a direct memory bus random access memory (Direct Rambus RAM, DRRAM). The memory 109 in the embodiments of the present application includes but is not limited to these and any other suitable types of memory.
[0163] The processor 110 can include one or more processing units; optionally, the processor 110 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and an application program, and the modem processor mainly processes a wireless communication signal, such as a baseband processor. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 110.
[0164] The embodiment of the present application further provides a readable storage medium, and the readable storage medium stores a program or instructions, the program or instructions are executed by a processor to realize each process of the above-mentioned image decoding method embodiment, and the same technical effects can be achieved, to avoid repetition, which will not be described here.
[0165] The processor is the processor in the electronic device in the above-mentioned embodiment. The readable storage medium includes a computer readable storage medium, such as a computer readable only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0166] The embodiment of the present application further provides a chip, and the chip includes a processor and a communication interface, the communication interface is coupled with the processor, and the processor is used to run a program or instructions to realize each process of the above-mentioned image decoding method embodiment, and the same technical effects can be achieved, to avoid repetition, which will not be described here.
[0167] It should be understood that the chip mentioned in the embodiment of the present application can also be referred to as a system level chip, a system chip, a chip system, or a system on chip, etc.
[0168] The embodiment of the present application provides a computer program product, and the program product is stored in a storage medium, and the program product is executed by at least one processor to realize each process of the above-mentioned image decoding method embodiment, and the same technical effects can be achieved, to avoid repetition, which will not be described here.
[0169] It should be noted that, in the present document, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element. Furthermore, it is to be understood that the method and apparatus of the present application can be carried out by more than one process, method, article, or apparatus either simultaneously, concurrently, or with intervening action that are carried out at the same time, either in a simultaneous fashion or in a fashion that is interleaved in time. For example, the described methods can be performed in a different order from that described, and / or various steps can be combined or omitted, and / or additional steps can be added, without departing from the scope of the present application. Also, features described with respect to certain examples can be combined in other examples.
[0170] From the above description of the embodiments, it is apparent that the above-mentioned method can be realized by means of software and necessary universal hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solution of the present application can be embodied in the form of computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a plurality of instructions for making a terminal (which can be a mobile phone, computer, server, or network equipment, etc.) execute the method described in various embodiments of the present application.
[0171] The embodiments of the present application are described above in conjunction with the drawings, but the present application is not limited to the above-mentioned specific embodiments, and the above-mentioned specific embodiments are only illustrative, not restrictive, and those skilled in the art can make many forms under the inspiration of the present application without departing from the scope of the present application and the scope protected by the claims.
Claims
1. An image decoding method, the method comprising: When the image decoding interface is invoked and the parameters passed to the image decoding interface carry hardware configuration flags, obtain the encoding format of the target image; When the encoding format matches the YUV encoding format and the width of the target image is an integer multiple of 2, the target image is YUV decoded to obtain the YUV pixel information of the target image.
2. The method according to claim 1, wherein, Before performing YUV decoding on the target image to obtain the YUV pixel information of the target image, the method further includes: Obtain the image format of the target image; The step of performing YUV decoding on the target image to obtain the YUV pixel information of the target image includes: If the image format does not match the target image format and the encoding format is YUV encoding format, the target image is YUV decoded to obtain the YUV pixel information of the target image.
3. The method according to claim 2, wherein, The method further includes: If the image format matches the target image format, the target image is RGB decoded to obtain the RGB pixel information of the target image.
4. The method according to claim 1, wherein, After performing YUV decoding on the target image to obtain the YUV pixel information of the target image, the method further includes: The YUV pixel information is stored in a first hardware, which is the hardware indicated by the hardware configuration tag.
5. The method according to claim 1, wherein, The method further includes: If the encoding format matches the YUV encoding format and the width value of the target image is not an integer multiple of 2, then the target image is RGB decoded to obtain the RGB pixel information of the target image; or, If the encoding format matches the RGB encoding format, the target image is RGB decoded to obtain the RGB pixel information of the target image.
6. The method according to claim 5, wherein, After performing RGB decoding on the target image to obtain the RGB pixel information of the target image, the method further includes: The RGB pixel information is stored in a second hardware, which is the hardware indicated by the hardware configuration tag.
7. An image decoding apparatus, the image decoding apparatus comprising: Acquisition module and decoding module; The acquisition module is used to acquire the encoding format of the target image when the decoding image interface is called and the parameters passed to the decoding image interface carry hardware configuration flags. The decoding module is used to perform YUV decoding on the target image to obtain the YUV pixel information of the target image when the encoding format matches the YUV encoding format and the width of the target image is an integer multiple of 2.
8. The method according to claim 7, wherein, The acquisition module is further configured to acquire the image format of the target image before performing YUV decoding on the target image to obtain the YUV pixel information of the target image; The decoding module is specifically used to perform YUV decoding on the target image to obtain the YUV pixel information of the target image when the image format does not match the target image format and the encoding format is YUV encoding format.
9. The apparatus according to claim 8, wherein, The decoding module is further configured to perform RGB decoding on the target image to obtain the RGB pixel information of the target image when the image format matches the target image format.
10. The apparatus according to claim 7, wherein, The device further includes a storage module; the storage module is used to store the YUV pixel information of the target image after the decoding module performs YUV decoding on the target image to obtain the YUV pixel information of the target image, the first hardware being the hardware indicated by the hardware configuration mark.
11. The apparatus according to claim 7, wherein, The decoding module is also used for: If the encoding format matches the YUV encoding format and the width value of the target image is not an integer multiple of 2, the target image is RGB decoded to obtain the RGB pixel information of the target image. or, If the encoding format matches the RGB encoding format, the target image is RGB decoded to obtain the RGB pixel information of the target image.
12. The method according to claim 11, wherein, The device further includes a storage module; the storage module is used to store the RGB pixel information of the target image after the decoding module performs RGB decoding on the target image to obtain the RGB pixel information of the target image, the second hardware being the hardware indicated by the hardware configuration mark.
13. An electronic device comprising a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the image decoding method as described in any one of claims 1 to 6.
14. A readable computer storage medium storing a program or instructions that, when executed by a processor, implement the steps of the image decoding method as described in any one of claims 1 to 6.
15. A chip comprising a processor and a communication interface coupled to the processor, the processor being configured to run a program or instructions to implement the steps of the image decoding method as described in any one of claims 1 to 6.
16. A computer program product, said program product being executed by at least one processor to implement the steps of the image decoding method as claimed in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for image transmission for source device and target device
CN107105119A
Video information transmission method, terminal and server
CN108881920A
Camera middle layer image processing method and system on chip
CN109120938A
Video playing method and device
CN114710702A
High-frame-rate multi-path target detection method for edge device
CN116883691A