Image decoding method and device, electronic equipment and readable storage medium

By selecting YUV decoding according to the encoding format and width conditions of the target image during the image decoding process, unnecessary RGB decoding is avoided, the problem of resource waste is solved, and storage efficiency is improved.

CN118660167APending Publication Date: 2024-09-17VIVO MOBILE COMM CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410839241.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

In the prior art, the image is converted to the RGB encoding format by default during the image decoding process, resulting in a waste of resources, especially for YUV format images that do not require RGB decoding.

Method used

When the decoding image interface is called, the encoding format of the target image is obtained, and YUV decoding is performed when the encoding format matches YUV and the width is an integer multiple of 2 to avoid unnecessary RGB decoding process.

Benefits of technology

It reduces the waste of resources in the image decoding process and improves storage efficiency, especially saving memory when the hardware cache stores images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118660167A
    Figure CN118660167A
Patent Text Reader

Abstract

The invention discloses an image decoding method and device, electronic equipment and a readable storage medium, and belongs to the field of image processing. The method comprises the following steps: acquiring a coding format of a target image under the condition that a decoding image interface is called and parameters transmitted into the decoding image interface carry hardware configuration marks; and under the condition that the coding format is matched with the YUV coding format and the width value of the target image is an integral multiple of 2, performing YUV decoding on the target image to obtain YUV pixel information of the target image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of image processing, and specifically relates to an image decoding method, device, electronic device and readable storage medium. Background Art

[0002] In the related art, when an electronic device decodes an image, it will convert the image encoding format into an RGB encoding format by default, and then store the decoded RGB pixel parameters in a GPU or a CPU.

[0003] In this way, no matter what encoding format the target image is in, it is necessary to convert the image encoding into RGB encoding first, that is, if the target image is an image in a non-RGB encoding format, it is necessary to convert it into RGB encoding format first, thereby causing a waste of resources. Summary of the invention

[0004] 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 images by the electronic device.

[0005] In a first aspect, an embodiment of the present application provides an image decoding method, which includes: when a decoding image interface is called and a parameter passed into the decoding image interface carries a hardware configuration tag, obtaining the encoding format of a target image; when the encoding format matches the YUV encoding format and the 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.

[0006] In the second aspect, an embodiment of the present application provides an image decoding device, which includes: an acquisition module and a decoding module; the acquisition module is used to obtain the encoding format of the target image when the decoding image interface is called and the parameters passed into the decoding image interface carry a hardware configuration mark; the decoding module is used to perform YUV decoding on the target image when the encoding format 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.

[0007] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0008] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0009] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0010] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.

[0011] In the embodiment of the present application, when the decoding image interface is called and the parameters passed into the decoding image interface carry the hardware configuration mark, 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 the YUV pixel information of the target image. In this way, the electronic device can avoid the waste of resources in the image decoding process caused by using the RGB decoding format for images that do not need to be decoded according to the RGB decoding method. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 It is one of the schematic diagrams of an image decoding method provided in an embodiment of the present application;

[0013] Figure 2 This is a second schematic diagram of an image decoding method provided in an embodiment of the present application;

[0014] Figure 3 This is one of the structural schematic diagrams of an image decoding device provided in an embodiment of the present application;

[0015] Figure 4 This is a second structural diagram of an image decoding device provided in an embodiment of the present application;

[0016] Figure 5 This is a third structural diagram of an image decoding device provided in an embodiment of the present application;

[0017] Figure 6 This is one of the hardware structure diagrams of an electronic device provided in an embodiment of the present application;

[0018] Figure 7 This is the second schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0020] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0021] The terms "at least one (item)", "at least one of" and the like in the specification and claims of the present application refer to any one, any two or a combination of more than two of the objects included therein. For example, at least one (item) of a, b, and c can be represented by: "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 (items)" refers to two or more, and its meaning is similar to that of "at least one (item)".

[0022] The following is an explanation of the terms that may be involved in the embodiments of the present application:

[0023] 1. Bitmap: The form in which images are stored in memory. A bitmap is an array of bits that specifies the color of each pixel in a pixel matrix. Also known as a dot matrix image or a drawn image, it is composed of individual points called pixels (picture elements).

[0024] 2. Luminance and Chroma Coding (YUV): It is a color coding method adopted by the European television system and is the color space used by the analog color television system. The importance of using the YUV color space is that its luminance signal Y and chrominance signals U and V are separated.

[0025] 3. Red, Green and Blue (RGB): A bitmap color encoding method that uses the optical intensity of the three primary colors of red, green and blue to represent a color. This is the most common bitmap encoding method and can be used directly for screen display. R represents the red channel, G represents the green channel, and B represents the blue channel.

[0026] 4. RGBA: A color space where R represents the red channel, G represents the green channel, B represents the blue channel, and A represents the transparency channel.

[0027] 5. Color Space: Color space refers to a mathematical model used to describe and represent color. It is a three-dimensional mathematical space used to describe color properties such as brightness, hue and saturation.

[0028] 6. Hardware Buffer: It is a graphics memory buffer introduced in Android, which is used to efficiently share graphics data between different graphics processing units.

[0029] 7. Hardware Config: If the image carries this tag, then under this configuration, the image will be stored in the GPU and the image is immutable. This configuration is only applicable when the only operation of the image is to draw itself on the screen.

[0030] 8. Application Programming Interface (API): An API is a set of definitions, programs, and protocols that enable computer software to communicate with each other. One of the main functions of an API is to provide a common set of functions. Programmers can reduce programming tasks by developing applications by calling API functions. API is also a kind of middleware that provides data sharing for various platforms.

[0031] It should be noted that the image decoding method provided in the embodiments of the present application can be executed by electronic devices such as mobile phones, tablet computers, laptop computers, PDAs, and vehicle-mounted electronic devices. In some embodiments of the present application, the image decoding method provided in the embodiments of the present application is described by taking the electronic device as the execution subject to execute the image decoding method as an example.

[0032] The image decoding method, device, electronic device and readable storage medium provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.

[0033] In the operating system of electronic devices, the memory usage of images has always been a problem that has been criticized. In earlier versions of the operating system, in order to be compatible with devices without GPUs, images were allocated and stored in the CPU memory by default. Later, the GPU rendering pipeline was introduced, and images had to be copied to the GPU memory when they were drawn, which caused a lot of waste. For this reason, the operating system introduced Hardware Config. Images carrying this tag can only be accessed by the GPU, not by the CPU, thus reducing the image's memory usage in the CPU. That is, since the CPU cannot access the image with Hardware Config set, there is no need to copy it for the CPU to access, which can save half of the memory.

[0034] However, the electronic device will store pixels in the image format indicated in Hardware Config by default, for example, in RGBA8888 format. If the original image is in YUV format, the electronic device will decode the YUV format image into an RGB format image, and then store the pixels in RGBA8888 format, which will waste resources.

[0035] In the embodiment of the present application, when the decoding image interface is called and the parameters passed into the decoding image interface carry the hardware configuration mark, 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 the YUV pixel information of the target image. In this way, the electronic device can avoid the waste of resources in the image decoding process caused by using the RGB decoding format for images that do not need to be decoded according to the RGB decoding method.

[0036] The image decoding method provided in this embodiment may be executed by an image decoding device, which may be an electronic device, or a control module or a processing module in the electronic device. The technical solution provided in the embodiment of this application is described below using an electronic device as an example.

[0037] The present application provides an image decoding method. Figure 1 FIG. 1 is a flowchart of an image decoding method provided by an embodiment of the present application, and the method can be applied to electronic devices. Figure 1 As shown, the image decoding method provided in the embodiment of the present application may include the following steps 201 and 202.

[0038] Step 201: When a decoding image interface is called and a parameter passed into the decoding image interface carries a hardware configuration tag, the electronic device obtains a coding format of a target image.

[0039] In some embodiments of the present application, the target image is a bitmap, that is, the target image is a pixel map, so different decoding methods can be used to decode the pixel information of the image and store the image in the hardware of the electronic device. Optionally, the target image is determined by a parameter passed into the decoded image interface, and the parameter indicates the storage path of the target image.

[0040] In some embodiments of the present application, the above hardware may be any one of the following: GPU, CPU.

[0041] In some embodiments of the present application, the above-mentioned decoding image interface includes any one of the following decoding methods: YUV decoding, RGB decoding.

[0042] Exemplarily, the above YUV decoding is to use an image decoder to directly decode the YUV pixel information in the target image.

[0043] Exemplarily, the RGB decoding is to use an image decoder to directly decode the RGB pixel information in the target image.

[0044] In some embodiments of the present application, when the electronic device receives a calling interface instruction through the above-mentioned decoding image interface, it calls the decoding image interface to select a decoding method according to the parameters carried in the calling interface instruction to decode the target image.

[0045] In some embodiments of the present application, the above-mentioned calling interface instruction can be an instruction in any form.

[0046] In some embodiments of the present application, the parameters carried in the above-mentioned calling interface instruction may include but are not limited to: hardware configuration tags and storage methods of target images.

[0047] In some embodiments of the present application, the above storage method may include but is not limited to ALPHA-8, RGB-565, ARGB-4444, ARGB-8888 or YUV-4444.

[0048] For example, ALPHA-8 consists of 8 bits, no RGB value and YUV value, only ALPHA value, and one pixel occupies 1 byte.

[0049] For example, in RGB-565, R is 5 bits, G is 6 bits, and B is 5 bits, a total of 16 bits, and one pixel occupies 2 bytes.

[0050] For example, in RGB-4444, A is 4 bits, R is 4 bits, G is 4 bits, and B is 4 bits, a total of 16 bits, and one pixel occupies 2 bytes.

[0051] For example, in RGB-8888, A is 8 bits, R is 8 bits, G is 8 bits, and B is 8 bits, a total of 32 bits, and one pixel occupies 4 bytes.

[0052] For example, in YUV-4444, A is 4 bits, R is 4 bits, G is 4 bits, and B is 4 bits, a total of 16 bits, and one pixel occupies 2 bytes.

[0053] In some embodiments of the present application, in a scenario where an image needs to be saved, the electronic device will be triggered to send a calling interface instruction to the decoding image interface.

[0054] In some embodiments of the present application, scenarios where the electronic device needs to save images include but are not limited to any of the following:

[0055] Use electronic devices to take photos;

[0056] Download images from within the app;

[0057] Receive images transmitted from other electronic devices.

[0058] In some embodiments of the present application, the above encoding format may be any one of the following: YUV encoding format, RGB encoding format.

[0059] Exemplarily, the above YUV encoding format is a format for encoding the color of the target image according to brightness and chromaticity.

[0060] Exemplarily, the RGB encoding format is an image in which the target image is encoded according to the colors of the red channel, the green channel and the blue channel.

[0061] In some embodiments of the present application, the target image may carry a Hardware Config tag to inform the electronic device to use hardware cache to store the image.

[0062] It should be noted that if the parameters of the decoded image interface do not carry the Hardware Config tag, it means that the target image cannot use the hardware cache to store the image, and the image is decoded and stored in the memory according to the normal operation.

[0063] Step 202: When 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, the electronic device performs YUV decoding on the target image to obtain YUV pixel information of the target image.

[0064] 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 an image file corresponding to the target image.

[0065] In some embodiments of the present application, the image file of the target image is used to store image information of the target image.

[0066] Exemplarily, the above-mentioned image file may be in JPEG, PNG and WEBP formats.

[0067] For example, JPEG is a lossy compression format that stores a single bitmap with 24-bit color compression, but does not support transparency. When using JPEG for compression, it is necessary to select an appropriate compression rate to avoid poor image quality.

[0068] For example, PNG is a lossy compression format that supports all colors. Since it is lossless compression, PNG occupies a large space. Currently, PNG is generally converted to WEBP for use.

[0069] For example, WEBP supports lossless compression 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 multi-frame animation. The only disadvantage is that the compression efficiency is inferior to JPEG and PNG.

[0070] In some embodiments of the present application, the above-mentioned YUV pixel information may be the pixel value of each pixel in the target image.

[0071] In some embodiments of the present application, when the target image is in YUV encoding format, the electronic device performs YUV decoding on the target image and stores the decoded YUV pixel information in the hardware; conversely, if the width value of the image size is not an integer multiple of 2, the target image is RGB decoded and the decoded RGB pixel information is stored in the hardware.

[0072] In some embodiments of the present application, since the pixel information of the target image is stored in the hardware, based on the characteristics of the hardware, when storing the image, one of the two pixels in the image is usually sampled and stored. Therefore, the YUV image can only be decoded into 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, the YUV pixel cannot be decoded.

[0073] In some embodiments of the present application, the above-mentioned image decoding process is: extract run-level symbols from the bit sequence of the image. These symbols are converted into a series of coefficients and reordered into a quantization 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 called "inverse quantization". Then, the extracted re-scaled coefficients are inversely transformed to reconstruct the decoded image of the clothes, and the decoded image includes the YUV pixel parameters of each pixel in the image.

[0074] In some embodiments of the present application, since the target image is stored in hardware, based on the characteristics of the hardware, when storing a YUV image, one of the two pixels in the image is usually sampled and stored. Therefore, the YUV image can only be stored in the YUV storage format if 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, it cannot be stored in the YUV storage format.

[0075] 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 embodiment of the present application further includes step 301. Further, the step 202 specifically includes step 202a:

[0076] Step 301: The electronic device obtains the image format of the target image.

[0077] In some embodiments of the present application, the electronic device obtains image information of the target image from an image file of the target image.

[0078] Exemplarily, the electronic device may decompress the image file of the target image to obtain image information of the target image.

[0079] Exemplarily, the above-mentioned image information may include but is not limited to image size, image encoding format, image format, etc.

[0080] In some embodiments of the present application, the above-mentioned image format may be a dot-9 format, or an image in a non-dot-9 format.

[0081] Exemplarily, the above-mentioned point 9 image format is an image format after the image is stretched.

[0082] It should be noted that the electronic device can obtain a processed point 9 image after stretching the target image, and the target image can be an image in a YUV encoding format or an image in an RGB encoding format.

[0083] It is understandable that electronic devices have an automatic horizontal screen function. The same interface will change the direction of image display as the parameters of the direction sensor in the electronic device change. 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 electronic devices display images, there will be a variety of different resolutions. After the cut files of many controls are enlarged and stretched, the corners will be blurred and distorted. At this time, the electronic device will use the point nine PNG technology to stretch the image horizontally and vertically at the same time to achieve a perfect display effect at multiple resolutions.

[0084] Step 202c: When the image format does not match the target image format and the encoding format of the target image is the YUV encoding format, the electronic device performs YUV decoding on the target image to obtain YUV pixel information of the target image.

[0085] In some embodiments of the present application, the target image format is used to represent that at least a portion of an image region needs to undergo image processing, such as stretching processing.

[0086] In some embodiments of the present application, the above-mentioned target image format can be user-defined or the default format of the electronic device, and the present application does not impose any limitation thereto.

[0087] In some embodiments of the present application, the target image format may be a dot-9 image format.

[0088] In some embodiments of the present application, if the image format of the target image is not dot-9 format, the electronic device determines that it does not match the target image format and performs YUV decoding on the target image to obtain YUV pixel information of the target image.

[0089] In this way, since the image in dot-9 format has undergone image processing, the pixel information of the image is more complex than the target image and is not suitable for hardware cache storage of the image. If the image is stored in the YUV storage format, it may cause waste of resources. Therefore, when the image format is not in the dot-9 format, the electronic device will use the YUV storage format to avoid the problem of waste of resources.

[0090] Optionally, in some embodiments of the present application, after the above step 202 of "performing YUV decoding on the target image to obtain YUV pixel information of the target image", the image decoding method provided in the embodiments of the present application further includes step 401.

[0091] Step 401: The electronic device stores YUV pixel information in the first hardware.

[0092] In some embodiments of the present application, the first hardware is hardware indicated by a hardware configuration mark.

[0093] Exemplarily, the first hardware may be a GPU or a CPU.

[0094] In some embodiments of the present application, after the electronic device recognizes that the parameters passed in by the decoding image interface carry a hardware configuration tag, that is, the hardware indicated by the Hardware Config tag, it stores the pixel information of the decoded image in the hardware, that is, the first hardware mentioned above.

[0095] In this way, the electronic device can store the image in appropriate hardware according to the hardware indicated by Hardware Config to reduce the memory of other hardware.

[0096] In the embodiment of the present application, when the decoding image interface is called and the parameters passed into the decoding image interface carry the hardware configuration mark, 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 the YUV pixel information of the target image. In this way, the electronic device can avoid the waste of resources in the image decoding process caused by using the RGB decoding format for images that do not need to be decoded according to the RGB decoding method.

[0097] Optionally, in some embodiments of the present application, the above step 202 may be replaced by the following step 203:

[0098] Step 203: When the image format of the target image matches the target image format, the electronic device performs RGB decoding on the target image to obtain RGB pixel information of the target image.

[0099] In some embodiments of the present application, the target image format is used to represent that at least a portion of an image region needs to undergo image processing, such as stretching processing.

[0100] In some embodiments of the present application, the above-mentioned target image format can be user-defined or the default format of the electronic device, and the present application does not impose any limitation thereto.

[0101] In some embodiments of the present application, the target image format may be a dot-9 image format.

[0102] In some embodiments of the present application, if the image format of the target image is dot 9 format, the electronic device determines that it matches the target image format, and performs RGB decoding on the target image to obtain RGB pixel information of the target image.

[0103] In some embodiments of the present application, the above-mentioned image decoding process is: extract run-level symbols from the bit sequence of the image. These symbols are converted into a series of coefficients and reordered into a quantization 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 called "inverse quantization". Then, the extracted re-scaled coefficients are inversely transformed to reconstruct the decoded image of the clothes, and the decoded image includes the RGB pixel parameters of each pixel in the image.

[0104] In this way, since the image in dot-9 format has undergone image processing, the pixel information of the image is more complex than the target image and is not suitable for hardware cache storage of the image. If the image is stored according to the YUV pixel information decoded from the image, it may cause waste of resources. Therefore, when the image format is dot-9 format, the RGB pixel information decoded by the electronic device is used to store the image, which can avoid the problem of waste of resources.

[0105] Optionally, in some embodiments of the present application, the above step 202 may also be replaced by the following step 204:

[0106] Step 204: When the target image encoding format matches the RGB encoding format, the electronic device performs RGB decoding on the target image to obtain RGB pixel information of the target image.

[0107] In some embodiments of the present application, when the encoding format of the target image is an RGB encoding format, the electronic device determines that it matches the RGB encoding format.

[0108] In some embodiments of the present application, the above-mentioned image decoding process is: extract run-level symbols from the bit sequence of the image. These symbols are converted into a series of coefficients and reordered into a quantization 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 called "inverse quantization". Then, the extracted re-scaled coefficients are inversely transformed to reconstruct the decoded image of the clothes, and the decoded image includes the RGB pixel information of each pixel in the image.

[0109] Optionally, in some embodiments of the present application, the above step 202 may also be replaced by the following step 205.

[0110] Step 205: When the encoding format of the target image matches the YUV encoding format and the width value of the target image is not an integer multiple of 2, the electronic device performs RGB decoding on the target image to obtain RGB pixel information of the target image.

[0111] In some embodiments of the present application, the electronic device may determine the width value of the target image after acquiring the image size of the target image, and perform YUV decoding on the target image when the width value of the target image is an integer multiple of 2; otherwise, if the width value of the target image is not an integer multiple of 2, perform RGB decoding on the target image.

[0112] In some embodiments of the present application, the above-mentioned image decoding process is: extract run-level symbols from the bit sequence of the image. These symbols are converted into a series of coefficients and reordered into a quantization 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 called "inverse quantization". Then, the extracted re-scaled coefficients are inversely transformed to reconstruct the decoded image of the clothes, and the decoded image includes the RGB pixel information of each pixel in the image.

[0113] In this way, the electronic device can flexibly select different decoding methods to decode the image according to the image format of the target image, the encoding format of the image, and the image parameters, thereby avoiding the problem of converting the image in the YUV encoding format into RGB after decoding, thereby reducing the waste of resources in the image decoding process.

[0114] Optionally, in some embodiments of the present application, the “decoding the target image in RGB to obtain the RGB pixel information of the target image” in the above steps 203 to 205 specifically includes step 501:

[0115] Step 501: The electronic device stores RGB pixel parameters in the second hardware.

[0116] In some embodiments of the present application, the second hardware is hardware indicated by a hardware configuration mark.

[0117] Exemplarily, the second hardware may be a GPU or a CPU.

[0118] In some embodiments of the present application, after the electronic device identifies the hardware configuration tag carried in the parameters passed by the decoding image interface, that is, the hardware indicated by the Hardware Config tag, it stores the pixel information of the decoded image in the hardware, that is, the above-mentioned second hardware.

[0119] It should be noted that the RGB pixel information in the above steps 203 to 205 may include the RGB pixel value of each pixel in the target image, or pixel parameters, etc.

[0120] In this way, the electronic device can store the image in appropriate hardware according to the hardware indicated by Hardware Config to reduce the memory of other hardware.

[0121] The following is a possible embodiment that describes in detail the actual implementation process of the embodiment of the present application. Specifically, Figure 2 As shown, it includes steps A1 to A6:

[0122] Step A1: The electronic device receives a request for image decoding and calls an image decoding interface to store the image.

[0123] Step A2: If the image is detected to be configured with a Hardware Config tag through the decoded image interface of the electronic device, it means that the electronic device can use the hardware cache to store the image. If the Hardware Config tag is configured, step A3 is executed; if not, step A6 is executed.

[0124] Step A3: The electronic device determines whether the image format of the target image is a dot-9 format or an RGC format image, that is, the above target image format. If yes, execute step A6; if no, execute step A4.

[0125] For example, point 9 is an image format commonly used in electronic devices, which is between Bitmap and vector graphics. This type of image requires some post-processing, such as stretching only a certain area, and is therefore not suitable for hardware cache storage.

[0126] Step A4: The electronic device queries the YUV information of the target image, that is, the image information in the above image file. If the image in the YUV image format has a width value that is a multiple of 2 after alignment, then execute step A5; if the image width value is not a multiple of 2, then execute step A6.

[0127] Step A5: The electronic device calls the image decoder to directly decode the YUV pixels of the target image. Compared with the output RGBA format, there is no color format conversion here, 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.

[0128] Step A6: The electronic device calls the image decoder and outputs the RGBA pixel parameters of the original image by default. At the same time, the electronic device allocates a hardware cache that matches the image format of the target image and saves the pixel parameters of the target image to the hardware cache.

[0129] In this way, third-party applications will occupy the memory space of electronic devices when storing pictures. When third-party applications use this solution, for pictures such as jpeg or webp, they will only decode them to the hardware cache that is only accessible to the GPU, and will not copy them to the memory accessed by the CPU, thus saving 50% of memory. In addition, directly storing them in the YUV storage format saves resources for image decoding, and compared with the RGBA format, it can save 40%-63% of memory. Overall, one picture can save about 80% of memory usage.

[0130] Each of the above-mentioned method embodiments, or various possible implementation methods in each method embodiment can be executed separately, or any two or more of them can be executed in combination with each other. The specific implementation method can be determined according to actual usage requirements, and the embodiments of the present application do not limit this.

[0131] The image decoding method provided in the embodiment of the present application can be executed by an electronic device or an image decoding apparatus. In the embodiment of the present application, an electronic device executing the image decoding method is taken as an example to illustrate the image decoding method provided in the embodiment of the present application.

[0132] Figure 3 A possible structural diagram of an image decoding device involved in an embodiment of the present application is shown. Figure 3 As shown, the image decoding device 700 may include: an acquisition module and a decoding module;

[0133] Among them, the above-mentioned acquisition module 701 is used to obtain the encoding format of the target image when the decoding image interface is called and the parameters passed into the decoding image interface carry the hardware configuration mark; the above-mentioned decoding module 702 is used to perform YUV decoding on the target image when the encoding format matches the YUV encoding format and the width value of the target image is an integer multiple of 2 to obtain the YUV pixel information of the target image.

[0134] Optionally, in some embodiments of the present application, the above-mentioned acquisition module 701 is also used to obtain 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 above-mentioned decoding module 702 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 the YUV encoding format.

[0135] Optionally, in some embodiments of the present application, the above decoding module 702 is also used to perform RGB decoding on the target image to obtain RGB pixel information of the target image when the image format matches the target image format.

[0136] Optionally, in some embodiments of the present application, combined with Figure 3 ,like Figure 4 As shown, the above-mentioned device 700 also includes a storage module 703; the storage module 703 is used for the above-mentioned decoding module 702 to perform YUV decoding on the target image, and after obtaining the YUV pixel information of the target image, the YUV pixel information is stored in the first hardware, and the first hardware is the hardware indicated by the hardware configuration mark.

[0137] Optionally, in some embodiments of the present application, the decoding module 702 is further used to:

[0138] When 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,

[0139] When the encoding format matches the RGB encoding format, the target image is RGB decoded to obtain the RGB pixel information of the target image.

[0140] Optionally, in some embodiments of the present application, combined with Figure 3 ,like Figure 5 As shown, the above-mentioned device 700 also includes a storage module 704; the storage module 704 is used for the above-mentioned decoding module 702 to perform RGB decoding on the target image, and after obtaining the RGB pixel information of the target image, the RGB pixel information is stored in the second hardware, and the second hardware is the hardware indicated by the hardware configuration mark.

[0141] In the image decoding device provided in the embodiment of the present application, when the decoding image interface is called and the parameters passed into the decoding image interface carry the hardware configuration mark, 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 the YUV pixel information of the target image. In this way, the electronic device can avoid the waste of resources in the image decoding process caused by using the RGB decoding format for images that do not need to be decoded according to the RGB decoding method.

[0142] The image decoding device in the embodiment 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 a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0143] The image decoding device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0144] The image decoding device provided in the embodiment of the present application can implement each process implemented in the embodiment of the image decoding method, and will not be described again here to avoid repetition.

[0145] Alternatively, if Figure 6 As shown, an embodiment of the present application further provides an electronic device 800, including a processor 801 and a memory 802, wherein the memory 802 stores a program or instruction that can be executed on the processor 801, and when the program or instruction is executed by the processor 801, each step of the above-mentioned image decoding method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0146] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0147] Figure 7 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0148] The electronic device 100 includes but is not limited to components such as 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.

[0149] Those skilled in the art will appreciate that the electronic device 100 may also include a power source (such as a battery) for supplying power to various components, and the power source may be logically connected to the processor 110 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 7 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0150] Among them, the above-mentioned processor 110 is used to obtain the encoding format of the target image when the decoding image interface is called and the parameters passed into the decoding image interface carry the hardware configuration mark; the above-mentioned processor 110 is used to perform YUV decoding on the target image when the encoding format matches the YUV encoding format and the width value of the target image is an integer multiple of 2 to obtain the YUV pixel information of the target image.

[0151] Optionally, in some embodiments of the present application, the above-mentioned processor 110 is also used to obtain 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 above-mentioned processor 110 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 the YUV encoding format.

[0152] Optionally, in some embodiments of the present application, the processor 110 is further configured to perform RGB decoding on the target image to obtain RGB pixel information of the target image when the image format matches the target image format.

[0153] Optionally, in some embodiments of the present application, the memory 109 is used by the processor 110 to perform YUV decoding on the target image, and after obtaining YUV pixel information of the target image, the YUV pixel information is stored in the first hardware, where the first hardware is the hardware indicated by the hardware configuration mark.

[0154] Optionally, in some embodiments of the present application, the processor 110 is further configured to:

[0155] When 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,

[0156] When the encoding format matches the RGB encoding format, the target image is RGB decoded to obtain the RGB pixel information of the target image.

[0157] Optionally, in some embodiments of the present application, the memory 109 is also used by the processor 110 to perform RGB decoding on the target image, and after obtaining the RGB pixel information of the target image, the RGB pixel information is stored in the second hardware, and the second hardware is the hardware indicated by the hardware configuration mark.

[0158] In the electronic device provided by the embodiment of the present application, when the decoding image interface is called and the parameters passed into the decoding image interface carry the hardware configuration mark, 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 the YUV pixel information of the target image. In this way, the electronic device can avoid the waste of resources in the image decoding process caused by using the RGB decoding format for images that do not need to be decoded according to the RGB decoding method.

[0159] It should be understood that in the embodiment of the present application, the input unit 104 may include a graphics processor (Graphics Processing Unit, GPU) 1041 and a microphone 1042, and the graphics processor 1041 processes the image data of a static picture or 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 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 107 includes a touch panel 1071 and at least one of other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include two parts: a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0160] The memory 109 can be used to store software programs and various data. The memory 109 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 109 may include a volatile memory or a non-volatile memory, or the memory 109 may include both volatile and non-volatile memories. Among them, the non-volatile memory may 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 may 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 (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0161] The processor 110 may 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 application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 110.

[0162] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned image decoding method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0163] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0164] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image decoding method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0165] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0166] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned image decoding method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0167] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0168] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0169] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. An image decoding method, characterized in that: The method comprises: When the decoding image interface is called and the parameter passed into the decoding image interface carries the hardware configuration tag, 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, YUV decoding is performed on the target image to obtain YUV pixel information of the target image.

2. The method according to claim 1, characterized in that: Before performing YUV decoding on the target image to obtain YUV pixel information of the target image, the method further includes: Acquire the image format of the target image; The YUV decoding of the target image to obtain YUV pixel information of the target image includes: When the image format does not match the target image format and the encoding format is a YUV encoding format, YUV decoding is performed on the target image to obtain YUV pixel information of the target image.

3. The method according to claim 2, characterized in that The method further comprises: In the case where the image format matches the target image format, RGB decoding is performed on the target image to obtain RGB pixel information of the target image.

4. The method according to claim 1, characterized in that: After performing YUV decoding on the target image to obtain YUV pixel information of the target image, the method further includes: The YUV pixel information is stored in first hardware, where the first hardware is the hardware indicated by the hardware configuration mark.

5. The method according to claim 1, characterized in that The method further comprises: When 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 RGB pixel information of the target image; or In the case where the encoding format matches the RGB encoding format, RGB decoding is performed on the target image to obtain RGB pixel information of the target image.

6. The method according to claim 5, characterized in that After performing RGB decoding on the target image to obtain RGB pixel information of the target image, the method further includes: The RGB pixel information is stored in second hardware, where the second hardware is the hardware indicated by the hardware configuration mark.

7. An image decoding device, characterized in that: The image decoding device comprises: an acquisition module and a 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 parameter passed into the decoding image interface carries the hardware configuration mark; The decoding module is used 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 the width value of the target image is an integer multiple of 2.

8. The method according to claim 7, characterized in that The acquisition module is further used 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 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.

9. The device according to claim 8, characterized in that The decoding module is further used to perform RGB decoding on the target image to obtain RGB pixel information of the target image when the image format matches the target image format.

10. The device according to claim 7, characterized in that The device also includes a storage module; the storage module is used for the decoding module to perform YUV decoding on the target image, and after obtaining the YUV pixel information of the target image, the YUV pixel information is stored in the first hardware, and the first hardware is the hardware indicated by the hardware configuration mark.

11. The device according to claim 7, characterized in that The decoding module is further used for: When the encoding format matches the YUV encoding format and the width value of the target image is not an integer multiple of 2, performing RGB decoding on the target image to obtain RGB pixel information of the target image; or, In the case where the encoding format matches the RGB encoding format, RGB decoding is performed on the target image to obtain RGB pixel information of the target image.

12. The method according to claim 11, characterized in that The device also includes a storage module; the storage module is used for the decoding module to perform RGB decoding on the target image, and after obtaining the RGB pixel information of the target image, the RGB pixel information is stored in the second hardware, and the second hardware is the hardware indicated by the hardware configuration mark.

13. An electronic device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the image decoding method as claimed in any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the image decoding method according to any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Image decoding method and apparatus, and electronic device and readable storage medium

    WO2026001854A1