Method, device, electronic device and storage medium for determining encoding mode
By determining the chromaticity offset and quantization parameters based on the texture characteristics of the brightness and chromaticity components in video encoding, the problem of large cost error in rate distortion in the prior art is solved, and the applicability and performance of the encoding mode are improved.
Patent Information
- Application Number
- CN202310159502.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-20
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2043-02-20
AI Technical Summary
In the prior art, the chromaticity component QP is set by adding a fixed offset (deltaQP) to the brightness QP, resulting in a large cost error of rate distortion, which leads to poor coding mode performance.
The chromaticity offset is determined based on the texture characteristics of the luminance component and the chromaticity component, and the chromaticity quantization parameter is determined based on the chromaticity offset and the preset luminance quantization parameter, thereby selecting the target encoding mode with the lowest rate distortion cost from multiple preset encoding modes.
By considering the color channel texture characteristics of the video content, the determined chromaticity quantization parameters are more matched with the target image, which improves the applicability and coding performance of the encoding mode.
Smart Images

Figure CN116347088B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video coding technology, and in particular to a method, device, electronic device, and storage medium for determining a coding mode. Background Art
[0002] With the development of video coding technology, block-based hybrid coding frameworks have been widely used. Hybrid coding frameworks provide multiple coding modes, and the encoder needs to evaluate each coding mode one by one to determine the one with the best coding performance.
[0003] In practical applications, the performance of each coding mode is typically measured based on its rate-distortion cost. The rate-distortion cost of a coding mode is determined by the coding distortion, the number of bits required for encoding, and the quantization parameter. In related art, after the quantization parameter (QP) of the luma component is fixed, the quantization parameter of the chroma component is obtained by adding a fixed offset (deltaQP) to the luma QP.
[0004] However, setting the chrominance component QP by adding a fixed offset (deltaQP) to the luma QP cannot be adapted to all images, so the calculated rate-distortion cost has a large error, which leads to poor performance of the final determined coding mode. Summary of the Invention
[0005] The present disclosure provides a method, device, electronic device, and storage medium for determining a coding mode, which are used to solve the technical problem of poor performance of the coding mode determined in the related art. The technical solution of the present disclosure is as follows:
[0006] According to a first aspect of an embodiment of the present disclosure, a method for determining a coding mode is provided, the method comprising: acquiring image data of a target image; the image data comprising image data corresponding to a luminance component and image data corresponding to a chrominance component; determining texture features of the image data corresponding to the luminance component and texture features of the image data corresponding to each chrominance component respectively; the texture features being used to reflect the texture complexity of the luminance component image in the target image, or the texture complexity of the chrominance component image in the target image; determining a chrominance offset based on the texture features of the image data corresponding to the luminance component and the texture features of the image data corresponding to each chrominance component; the chrominance offset being used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the image data represented by each chrominance component; determining a chrominance quantization parameter based on the chrominance offset and a preset luminance quantization parameter, and determining a target coding mode from a plurality of preset coding modes based on the chrominance quantization parameter and the preset luminance quantization parameter; the target coding mode being a coding mode with the smallest rate-distortion cost after encoding the target image among the plurality of preset coding modes.
[0007] Optionally, the texture features of the image data corresponding to the luminance component and the texture features of the image data corresponding to each chrominance component are determined separately, including: for the image data corresponding to any luminance component or chrominance component, the image data is divided into blocks according to a preset size to obtain multiple data blocks, and the multiple data blocks are transformed and quantized to obtain coefficient matrices corresponding to each data block; each data block contains the same number of pixel values; the cumulative value of each coefficient matrix is determined to obtain multiple cumulative values; the cumulative value is the sum of the absolute values of each coefficient in the coefficient matrix; and the average value corresponding to the multiple cumulative values is determined as the texture feature of the image data.
[0008] Optionally, multiple data blocks are transformed and quantized to obtain a coefficient matrix corresponding to each data block, including: for any data block, determining the average value corresponding to multiple pixel values in the data block; subtracting the average value from each pixel value to obtain a residual matrix corresponding to the data block; transforming and quantizing the residual matrix to obtain a coefficient matrix corresponding to each data block.
[0009] Optionally, the target image includes first image data corresponding to a first chromaticity component and second image data corresponding to a second chromaticity component; the chromaticity information of the first image data is different from the chromaticity information of the second image data; the chromaticity offset is determined according to the texture features of the image data corresponding to the luminance component and the texture features of the image data corresponding to each chromaticity component, including: determining a first chromaticity offset according to the texture features of the image data corresponding to the luminance component and the texture features of the first image data; the first chromaticity offset is used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the first image data; determining a second chromaticity offset according to the texture features of the image data corresponding to the luminance component and the texture features of the second image data; the second chromaticity offset is used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the second image data; and determining the average offset of the first chromaticity offset and the second chromaticity offset as the chromaticity offset.
[0010] Optionally, determining the chroma quantization parameter according to the chroma offset and the preset luminance quantization parameter includes: determining the chroma quantization parameter according to the chroma offset and the preset luminance quantization parameter.
[0011] Optionally, a target coding mode is determined from multiple preset coding modes based on the chromaticity quantization parameters and the preset luminance quantization parameters, including: based on the chromaticity quantization parameters and the preset luminance quantization parameters, respectively determining the rate-distortion cost after each preset coding model encodes the target image to obtain multiple rate-distortion costs; determining the minimum rate-distortion cost from the multiple rate-distortion costs, and determining the coding mode corresponding to the minimum rate-distortion cost as the target coding mode.
[0012] Optionally, based on the chrominance quantization parameter and the preset luminance quantization parameter, the rate-distortion cost of each preset coding model after encoding the target image is determined respectively, and multiple rate-distortion costs are obtained, including: for any preset coding mode, obtaining the coding distortion generated by the preset coding mode when encoding the target image, and the number of bits consumed by the preset coding mode when encoding the target image; the coding distortion includes the luminance coding distortion of the luminance component image and the chrominance coding distortion of the chrominance component image; the number of bits includes the number of bits consumed by the luminance component image and the number of bits consumed by the chrominance component image; according to the chrominance quantization parameter, the preset luminance quantization parameter and the first preset formula, the chrominance coding distortion is determined. The weight of the chromaticity coding distortion; the first preset formula is used to characterize the change of the weight of the chromaticity coding distortion under different chromaticity quantization parameters and different luminance quantization parameters; the chromaticity coding distortion is weighted according to the weight of the chromaticity coding distortion, and the luminance coding distortion, the number of bits of the consumed luminance component image, the number of bits of the consumed chromaticity component image and the weighted chromaticity coding distortion are substituted into the second preset formula to obtain the rate-distortion cost corresponding to the preset coding mode; the second preset formula is used to characterize the change of the rate-distortion cost under different luminance coding distortion, different chromaticity coding distortion, different numbers of bits of luminance component images and different numbers of bits of chromaticity component images.
[0013] According to a second aspect of an embodiment of the present disclosure, a coding device is provided, the coding device including an acquisition unit, a determination unit and a processing unit; the acquisition unit is configured to acquire image data of a target image; the image data includes image data corresponding to a luminance component and image data corresponding to a chrominance component; the determination unit is configured to determine, for a target image whose image data is represented by a luminance component and at least one chrominance component, texture features of the image data corresponding to the luminance component and texture features of the image data corresponding to each chrominance component; the texture features are used to reflect the texture complexity of the luminance component image in the target image, or the texture complexity of the chrominance component image in the target image. degree; the determining unit is further configured to determine the chroma offset according to the texture features of the image data corresponding to the luminance component and the texture features of the image data corresponding to each chroma component; the chroma offset is used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the image data represented by each chroma component; the processing unit is configured to determine the chroma quantization parameter according to the chroma offset and the preset luminance quantization parameter, and determine the target coding mode from multiple preset coding modes based on the chroma quantization parameter and the preset luminance quantization parameter; the target coding mode is the coding mode with the smallest rate-distortion cost after encoding the target image in the multiple preset coding modes.
[0014] Optionally, the determination unit is specifically configured to: for image data corresponding to any luminance component or chrominance component, divide the image data into blocks according to a preset size to obtain multiple data blocks, and transform and quantize the multiple data blocks to obtain a coefficient matrix corresponding to each data block; each data block contains the same number of pixel values; determine the cumulative value of each coefficient matrix to obtain multiple cumulative values; the cumulative value is the sum of the absolute values of each coefficient in the coefficient matrix; and determine the average value corresponding to the multiple cumulative values as the texture feature of the image data.
[0015] Optionally, the determination unit is specifically configured to: for any data block, determine the average value corresponding to multiple pixel values in the data block; subtract the average value from each pixel value to obtain a residual matrix corresponding to the data block; transform and quantize the residual matrix to obtain a coefficient matrix corresponding to each data block.
[0016] Optionally, the target image includes first image data corresponding to a first chromaticity component and second image data corresponding to a second chromaticity component; the chromaticity information of the first image data is different from the chromaticity information of the second image data; the determination unit is specifically configured to: determine a first chromaticity offset based on the texture features of the image data corresponding to the luminance component and the texture features of the first image data; the first chromaticity offset is used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the first image data; determine a second chromaticity offset based on the texture features of the image data corresponding to the luminance component and the texture features of the second image data; the second chromaticity offset is used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the second image data; and determine the average offset of the first chromaticity offset and the second chromaticity offset as the chromaticity offset.
[0017] Optionally, the determining unit is specifically configured to: determine the chroma quantization parameter according to the chroma offset and a preset luminance quantization parameter.
[0018] Optionally, the processing unit is specifically configured to: determine the rate-distortion cost after encoding the target image by each preset coding model based on the chrominance quantization parameter and the preset luminance quantization parameter, and obtain multiple rate-distortion costs; determine the minimum rate-distortion cost from the multiple rate-distortion costs, and determine the coding mode corresponding to the minimum rate-distortion cost as the target coding mode.
[0019] Optionally, the processing unit is specifically configured to: for any preset coding mode, obtain the coding distortion generated by encoding the target image using the preset coding mode, and the number of bits consumed by encoding the target image using the preset coding mode; the coding distortion includes the luminance coding distortion of the luminance component image and the chrominance coding distortion of the chrominance component image; the number of bits includes the number of bits consumed by the luminance component image and the number of bits consumed by the chrominance component image; determine the weight of the chrominance coding distortion according to the chrominance quantization parameter, the preset luminance quantization parameter and the first preset formula; the first preset formula is used to characterize the weight of the chrominance coding distortion at different chrominance levels The method comprises the following steps: weighting the chroma coding distortion according to the weight of the chroma coding distortion, substituting the luminance coding distortion, the number of bits of the consumed luminance component image, the number of bits of the consumed chroma component image, and the weighted chroma coding distortion into a second preset formula to obtain a rate-distortion cost corresponding to the preset coding mode; the second preset formula is used to characterize the change of the rate-distortion cost under different luminance coding distortions, different chroma coding distortions, different numbers of bits of luminance component images, and different numbers of bits of chroma component images.
[0020] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor and a memory for storing instructions executable by the processor; wherein the processor is configured to execute instructions to implement the method for determining a coding mode of the first aspect above.
[0021] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which instructions are stored. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method for determining a coding mode as described in the first aspect above.
[0022] The technical solution provided by the present disclosure provides at least the following beneficial effects: an encoding device obtains image data of a target image; because the image data includes image data corresponding to the luma component and image data corresponding to the chroma components, the encoding device needs to separately determine the texture features of the image data represented by the luma component and the texture features of the image data represented by each chroma component, thereby clarifying the texture complexity of the luma component image in the target image, or the texture complexity of the chroma component image in the target image. Furthermore, the encoding device determines a chroma offset based on the texture features of the image data represented by the luma component and the texture features of the image data represented by each chroma component. Because the chroma offset reflects the degree of deviation between the texture features of the image data represented by the luma component and the texture features of the image data represented by each chroma component, the encoding device can determine different chroma offsets for images with different texture features. Therefore, the encoding device determines chroma quantization parameters based on the chroma offset and a preset luma quantization parameter, which better matches the target image. Based on the chroma quantization parameters and the preset luma quantization parameter, the encoding device determines a target encoding mode from multiple preset encoding modes; the target encoding mode is the encoding mode that, among the multiple preset encoding modes, minimizes the rate-distortion penalty after encoding the target image. It can be understood that compared to the related art, which sets the chroma component QP by adding a fixed offset (deltaQP) to the luma QP, the chroma offset in the present disclosure is no longer fixed, but is instead determined based on the texture features of the target image. As a result, the resulting chroma component QP is more closely aligned with the target image. Therefore, the target coding mode determined from multiple preset coding modes based on the chroma quantization parameters and the preset luma quantization parameter in the present disclosure is more suitable for the target image.
[0023] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.
[0025] Figure 1 is a structural diagram of a video coding system according to an exemplary embodiment;
[0026] Figure 2 This is a flowchart of a method for determining a coding mode according to an exemplary embodiment;
[0027] Figure 3 This is a second flowchart of a method for determining a coding mode according to an exemplary embodiment;
[0028] Figure 4 FIG3 is a flowchart of a method for determining a coding mode according to an exemplary embodiment;
[0029] Figure 5 FIG4 is a fourth flow chart of a method for determining a coding mode according to an exemplary embodiment;
[0030] Figure 6 is a schematic structural diagram of an encoding device according to an exemplary embodiment;
[0031] Figure 7 The figure is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0032] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0033] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.
[0034] In addition, in the description of the embodiments of the present disclosure, unless otherwise specified, " / " means or. For example, A / B can mean A or B. "And / or" in this document is simply a description of the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present disclosure, "plurality" means two or more than two.
[0035] It should be noted that the user information (including but not limited to user device information, user personal information, user behavior information, etc.) and data (including but not limited to program code, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0036] Before explaining the embodiments of the present disclosure in detail, some relevant technical terms and related technologies involved in the embodiments of the present disclosure are first introduced.
[0037] A digital image is an image produced by capturing the actual picture using input devices such as scanners and cameras, and is composed of multiple pixels.
[0038] Pixels are the basic units of image display. Pixels are composed of small squares in an image. These small squares have a clear position and assigned color values. The color and position of the small squares determine how the image appears.
[0039] Image data refers to the collection of grayscale values for each pixel, expressed numerically. Real-world images are typically represented by the intensity and spectrum (color) of light at each point in the image. Converting image information into digital data requires breaking the image down into many small regions, called pixels, whose grayscale is represented by a numerical value. Color images are often represented using the three primary colors red (Red), green (Green), and blue (Blue), or GRB.
[0040] Video is a continuous sequence of images, consisting of consecutive frames, each of which is an image. The frame rate refers to the number of frames per second (FPS) of a video.
[0041] Video encoding converts one video format into another. The purpose of encoding is compression. Due to the human eye's persistence of vision, when a sequence of frames is played at a certain rate, we perceive a video of continuous motion. Because consecutive frames are highly similar, encoding and compression are necessary to remove spatial and temporal redundancy for storage and transmission.
[0042] YUV is a color encoding method. It is often used in various video processing components. The reason why YUV is used instead of RGB in the video encoding field is mainly because RGB signals are not easy to compress. Taking into account human perception, YUV adds the concept of brightness when encoding photos or videos, allowing for reduced chromaticity bandwidth. Among them, "Y" represents brightness (Luminance or Luma), which is the grayscale value, and "U" and "V" represent chromaticity (Chrominance or Chroma), which is used to describe the color and saturation of the image and is used to specify the color of the pixel.
[0043] Transcoding refers to the direct conversion of a signal from one coding scheme to another (without converting the signal back to analog form). A source encoder first converts the source signal into a binary information sequence. To transmit the desired source information faster and in greater quantities while maintaining a constant transmission rate, the data is compressed. This is done through source coding, removing significant amounts of redundant information. This significantly improves transmission efficiency.
[0044] In the field of digital signal processing, quantization refers to the process of approximating the continuous value of a signal (or a large number of possible discrete values) to a finite number (or fewer) of discrete values.
[0045] The quantization step size (Qstep), also known as the quantization matrix, is a term often used in broadcast television and video codecs. It is a key parameter of the quantizer. These values are determined experimentally, starting with a low value and comparing the input image with the quantized and dequantized output images. The quantization step size is gradually increased until a difference is perceived subjectively, at which point the perceptual threshold is reached.
[0046] Video bitrate refers to the number of bits of data transmitted per unit time, typically measured in kbps (kilobits per second). More generally, it's the sampling rate. The higher the sampling rate per unit time, the higher the accuracy, and the closer the processed file will be to the original.
[0047] The quantization parameter (QP) is the serial number of the quantization step size (Qstep). For example, for luma encoding, the quantization step size (Qstep) has 52 values, with QP ranging from 0 to 51; for chroma encoding, Q ranges from 0 to 39.
[0048] The quantization parameter reflects the compression of spatial detail. Smaller values result in finer quantization, higher image quality, and a longer bitrate. For example, a smaller QP preserves most detail; increasing the QP reduces detail, lowers the bitrate, and increases image distortion, resulting in lower image quality.
[0049] With the development of video coding technology, block-based hybrid coding frameworks have gained widespread application. This framework employs a set block size, performing prediction, transform, quantization, reconstruction, and in-loop filtering to complete video coding. However, this framework offers multiple coding modes, and the encoder must evaluate each mode individually to determine the one with the best performance.
[0050] In practical applications, the performance of each coding mode is usually measured based on its rate-distortion cost. The rate-distortion cost of a coding mode is determined by the coding distortion under the mode, the number of bits required for encoding, and the quantization parameter.
[0051] For example, in a video encoder, rate-distortion optimization is used to select a mode, and the formula is as follows:
[0052] argminJ=D+λ*R Formula 1
[0053] Among them, argmin represents the variable value that minimizes the objective function J, J is the rate-distortion cost of a specific mode encoding, D is the coding distortion generated by using the mode encoding, R is the number of bits required for encoding the mode (i.e., the bit rate), and λ is the rate-distortion optimization factor, which is related to the quantization parameter. The specific calculation formula of λ is related to the encoding standard and encoder. In the 265 standard encoder implementation, the calculation formula is as follows:
[0054] λ=a*2 QP / 6 Formula 2
[0055] Among them, QP is the quantization parameter and a is a constant.
[0056] In video encoding, the YUV420P color space format is usually used for encoding. In the YUV420P color space format, every 2x2 Y channel pixels correspond to 1 U / V channel pixel, and the ratio between the number of pixels is 4 times.
[0057] The relationship between the QP of the UV component and the QP of the Y component can be expressed as follows:
[0058] QP uv =QP Y +deltaQP uv Formula 3
[0059] QP uv is the QP of the UV component, QP Y is the QP of the component, deltaQP uv It is the QP offset of the UV component.
[0060] Combined with formula 2, the rate-distortion optimization factor λ of the UV component can be obtained uv and the rate-distortion optimization factor λ of the Y component Y The relationship between can be expressed as: It is recorded as Formula 4.
[0061] For the UV component, the rate-distortion optimization process can be expressed as:
[0062] argminJ UV =(D U +D V )+λ uv *(R U +R V ) Formula 5
[0063] Among them, D U Denotes the coding distortion of the U component, D V Represents the coding distortion of the V component, R U Indicates the bit rate of the U component, R VIndicates the bit rate of the V component.
[0064] Since multiplication by a fixed positive number does not affect the relative size of the results between different coding modes, the above formula 5 can be equivalent to:
[0065] argminJ UV =W UV *(D U +D V )+W UV *λ uv (R U +R V ) Formula 6
[0066] in, It is recorded as Formula 7.
[0067] Finally, combined with the coding distortion D of the Y component Y With bit rate R Y , we can get the formula:
[0068] argminJ=D Y +W UV *(D U +D V )+λ*(R U +R V +R Y ) Formula 8
[0069] In the related art, after the QP of the luma component is fixed, the QP of the chroma component is obtained by adding a fixed offset (deltaQP) to the luma QP.
[0070] However, in different video contents, there are obvious differences in the texture correlation and content complexity between luminance and chrominance. By adding a fixed offset (deltaQP) to the luminance QP to set the chrominance component QP, the calculated W UV And λ cannot be applied to every video frame, which makes the final calculated rate-distortion cost error large, and further leads to poor performance of the final determined coding mode.
[0071] In view of this, an embodiment of the present disclosure provides a method for determining a coding mode. When evaluating the coding mode, the content texture characteristics between color channels of different video contents are fully considered so that the rate-distortion optimization decision can obtain the best overall coding quality.
[0072] The image generation method provided by the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0073] The method for determining the coding mode provided by the embodiment of the present disclosure may be applicable to a video coding system. Figure 1 FIG. 1 shows a structural diagram of the video coding system. Figure 1 As shown, the video encoding system 10 includes an encoding device 11 and an electronic device 12. The encoding device 11 is connected to the electronic device 12. The encoding device 11 and the electronic device 12 can be connected in a wired manner or a wireless manner, which is not limited in the present embodiment.
[0074] The encoding device 11 may store a plurality of preset encoding modes, such as merge mode, 2Nx2N mode, 2NxN mode, Nx2N mode, 2NxnU mode, 2NxnD mode, nLx2N mode and nRx2N mode.
[0075] The encoding device 11 is configured to determine, for a target image of image data represented by a luma component and at least one chroma component, texture features of the image data represented by the luma component and texture features of the image data represented by each chroma component. The encoding device 11 is further configured to determine a chroma offset based on the texture features of the image data represented by the luma component and the texture features of the image data represented by each chroma component. The encoding device 11 is further configured to determine a chroma quantization parameter based on the chroma offset and a preset luma quantization parameter, and to determine a target encoding mode from a plurality of preset encoding modes based on the chroma quantization parameter and the preset luma quantization parameter.
[0076] The encoding device 11 can implement the method for determining the encoding mode of the embodiment of the present disclosure in various electronic devices 12. For example, the electronic device 12 can be a mobile phone, a tablet computer, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a desktop computer, a cloud server, etc. The embodiment of the present disclosure does not limit the specific type of electronic device.
[0077] In different application scenarios, the encoding device 11 and the electronic device 12 may be independent devices or integrated into the same device, which is not specifically limited in the embodiments of the present disclosure.
[0078] When the encoding device 11 and the electronic device 12 are integrated into the same device, the data transmission method between the encoding device 11 and the electronic device 12 is data transmission between the internal modules of the device. In this case, the data transmission process between the two is the same as the data transmission process between the encoding device 11 and the electronic device 12 when they are independent of each other.
[0079] In the following embodiments provided in the embodiments of the present disclosure, description is given by taking an example in which the encoding device 11 and the electronic device 12 are independently configured.
[0080] Figure 2 FIG. 1 is a flow chart of a method for determining a coding mode according to some exemplary embodiments. In some embodiments, the above-mentioned method for determining a coding mode can be applied to the following examples: Figure 1 The encoding device and electronic device shown can also be applied to other similar devices.
[0081] like Figure 2 As shown, the method for determining the encoding mode provided by the embodiment of the present disclosure includes the following S201-S203.
[0082] S201. For a target image of image data represented by a luminance component and at least one chrominance component, the encoding apparatus determines texture features of the image data corresponding to the luminance component and texture features of the image data corresponding to each chrominance component.
[0083] The texture feature is used to reflect the texture complexity of the luminance component image in the target image, or the texture complexity of the chrominance component image in the target image.
[0084] It should be noted that the target image can be any frame of the video to be encoded. The target image can be represented by both a luminance component image and a chrominance component image. That is, the image data of the target image includes image data corresponding to the luminance component and image data corresponding to at least one chrominance component.
[0085] For example, the target image can be in YUV format, a pixel format that represents luma and chroma components separately. The image data corresponding to the luma component (i.e., the Y component) represents brightness, or grayscale values, and the image formed by this data is called a luma component image. The image data corresponding to each chroma component (i.e., the U / V components) represents chroma, describing the color and saturation of the target image and specifying the color of a pixel. The image formed by this data is called a chroma component image.
[0086] As a possible implementation manner, the encoding device first determines the texture features of the image data corresponding to the luminance component, and then sequentially determines the texture features of the image data corresponding to each chrominance component.
[0087] For example, the encoding device first determines the texture feature C of the Y image corresponding to the Y component of the target image. Y , then the encoding device determines the texture feature C of the U image corresponding to the U component of the target image U Finally, the encoding device determines the texture feature C of the V image corresponding to the V component of the target imageV .
[0088] As another possible implementation manner, the encoding device simultaneously determines the texture features of the image data corresponding to the luminance component and the texture features of the image data corresponding to each chrominance component.
[0089] S202: The encoding apparatus determines a chroma offset according to texture features of the image data corresponding to the luminance component and texture features of the image data corresponding to each chroma component.
[0090] The chroma offset is used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the image data represented by each chroma component.
[0091] As a possible implementation manner, the encoding device determines the ratio between the texture feature of the image data corresponding to the chrominance component and the texture feature of the image data corresponding to the luminance component as the chrominance offset.
[0092] As another possible implementation, the encoding device substitutes the texture features of the image data corresponding to the luminance component and the texture features of the image data corresponding to each chrominance component into the offset calculation formula to obtain the chrominance offset.
[0093] For example, the offset calculation formula is as follows:
[0094]
[0095] Among them, F UV 、B UV It is a constant parameter and can be set in the encoding device in advance by the operation and maintenance personnel.
[0096] S203 : The encoding apparatus determines a chroma quantization parameter according to the chroma offset and the preset luma quantization parameter, and determines a target encoding mode from a plurality of preset encoding modes based on the chroma quantization parameter and the preset luma quantization parameter.
[0097] The target coding mode is a coding mode with the lowest rate-distortion cost after coding the target image among multiple preset coding modes.
[0098] As a possible implementation, the encoding device determines the sum of the chroma offset and the preset luma quantization parameter as the chroma quantization parameter. Further, the encoding device determines a target encoding mode from a plurality of preset encoding modes based on the chroma quantization parameter and the preset luma quantization parameter.
[0099] The technical solution provided by the present disclosure provides at least the following beneficial effects: For a target image comprising image data represented by a luma component and at least one chroma component, an encoding device determines texture features of the image data represented by the luma component and texture features of the image data represented by each chroma component, thereby determining the texture complexity of the luma component image or the texture complexity of the chroma component image in the target image. Furthermore, the encoding device determines a chroma offset based on the texture features of the image data represented by the luma component and the texture features of the image data represented by each chroma component. Because the chroma offset reflects the degree of deviation between the texture features of the image data represented by the luma component and the texture features of the image data represented by each chroma component, the encoding device can determine different chroma offsets for images with different texture features. Therefore, the chroma quantization parameters determined by the encoding device based on the chroma offset and a preset luma quantization parameter are more closely aligned with the target image. Based on the chroma quantization parameters and the preset luma quantization parameter, the encoding device determines a target encoding mode from multiple preset encoding modes; the target encoding mode is the encoding mode that, among the multiple preset encoding modes, minimizes the rate-distortion penalty after encoding the target image. It can be understood that compared to the related art, which sets the chroma component QP by adding a fixed offset (deltaQP) to the luma QP, the chroma offset in the present disclosure is no longer fixed, but is instead determined based on the texture features of the target image. As a result, the resulting chroma component QP is more closely aligned with the target image. Therefore, the target coding mode determined from multiple preset coding modes based on the chroma quantization parameters and the preset luma quantization parameter in the present disclosure is more suitable for the target image.
[0100] In one design, in order to determine the texture features of the image data corresponding to the luminance component and the texture features of the image data corresponding to each chrominance component, such as Figure 3 As shown, the above S201 provided by the embodiment of the present disclosure specifically includes:
[0101] S2011. For image data corresponding to any luminance component or chrominance component, the encoding device divides the image data into blocks according to a preset size to obtain multiple data blocks, and transforms and quantizes the multiple data blocks to obtain a coefficient matrix corresponding to each data block.
[0102] Each data block contains the same number of pixel values.
[0103] As one possible implementation, for image data corresponding to any luminance component or chrominance component, the encoding device divides the image data into blocks of a preset size to obtain multiple data blocks. Furthermore, for each data block, the encoding device determines the average value corresponding to multiple pixel values in the data block, subtracts the average value from each pixel value, and obtains a residual matrix corresponding to the data block. The encoding device transforms and quantizes the residual matrix to obtain a coefficient matrix corresponding to each data block.
[0104] It should be noted that the transformation, also known as coding transform, refers to the direct conversion of a signal from one coding scheme to another (without converting the signal back to analog form). In practical applications, discrete cosine transform (DCT) can be used for coding transform.
[0105] For example, the encoding device divides the image data of each component (Y image data, U image data, and V image data) into blocks of a specific size (e.g., into multiple 8x8 blocks). For each 8x8 block, the encoding device calculates the average value of the 64 pixel values within the block, and then subtracts the average value from each pixel value in the block to obtain an 8x8 residual matrix. Furthermore, the encoding device transforms and quantizes this residual matrix to obtain an 8x8 coefficient matrix.
[0106] S2012. The encoding device determines the accumulated values of each coefficient matrix to obtain multiple accumulated values.
[0107] The accumulated value is the sum of the absolute values of the coefficients in the coefficient matrix.
[0108] As a possible implementation manner, for each coefficient matrix, the encoding device calculates the sum of the absolute values of all coefficients in the coefficient matrix, and accumulates the sum to obtain an accumulated value corresponding to the coefficient matrix.
[0109] S2013. The encoding device determines an average value corresponding to the multiple accumulated values as a texture feature of the image data.
[0110] As a possible implementation, since one image data corresponds to multiple coefficient matrices, the encoding device averages the accumulated values corresponding to each coefficient matrix to obtain an average value, and uses the average value as the texture feature of the image data.
[0111] In one design, the target image includes first image data corresponding to a first chrominance component and second image data corresponding to a second chrominance component; wherein the chrominance information of the first image data is different from the chrominance information of the second image data. In order to determine the chrominance offset, as Figure 4As shown, the above S202 provided by the embodiment of the present disclosure specifically includes:
[0112] S2021. The encoding device determines a first chroma offset according to texture features of the image data corresponding to the luminance component and texture features of the first image data.
[0113] The first chroma offset is used to reflect the degree of deviation between the texture feature of the image data represented by the luminance component and the texture feature of the first image data.
[0114] As a possible implementation manner, the encoding device substitutes the texture features of the image data corresponding to the luminance component and the texture features of the first image data into the first offset calculation formula to obtain the first chroma offset.
[0115] Exemplarily, the first offset calculation formula is as follows:
[0116]
[0117] Among them, F U 、B U It is a constant parameter and can be set in the encoding device in advance by the operation and maintenance personnel.
[0118] S2022. The encoding apparatus determines a second chroma offset according to texture features of the image data corresponding to the luminance component and texture features of the second image data.
[0119] The second chroma offset is used to reflect the degree of deviation between the texture feature of the image data represented by the luminance component and the texture feature of the second image data.
[0120] As a possible implementation manner, the encoding device substitutes the texture features of the image data corresponding to the luminance component and the texture features of the second image data into the second offset calculation formula to obtain the second chroma offset.
[0121] Exemplarily, the second offset calculation formula is as follows:
[0122]
[0123] Among them, F V 、B V It is a constant parameter and can be set in the encoding device in advance by the operation and maintenance personnel.
[0124] S2023. The encoding device determines a chroma offset according to the first chroma offset and the second chroma offset.
[0125] As a possible implementation manner, the encoding device calculates an average value of the first chroma offset and the second chroma offset, and uses the average value as the chroma offset.
[0126] As a possible implementation, the encoding device weights the first chroma offset and the second chroma offset according to a preset weight to obtain the chroma offset. In one design, in order to determine the target encoding mode from multiple preset encoding modes, such as Figure 5 As shown, the above S203 provided by the embodiment of the present disclosure specifically includes:
[0127] S2031 : The encoding apparatus determines, based on the chrominance quantization parameter and the preset luminance quantization parameter, the rate-distortion cost of each preset encoding model after encoding the target image, to obtain a plurality of rate-distortion costs.
[0128] As a possible implementation method, for any preset coding mode, the coding device obtains the coding distortion generated by the preset coding mode when encoding the target image, and the number of bits consumed by the preset coding mode when encoding the target image; the coding distortion includes the luminance coding distortion of the luminance component image and the chrominance coding distortion of the chrominance component image; the number of bits includes the number of bits consumed in the luminance component image and the number of bits consumed in the chrominance component image. Furthermore, the coding device determines the weight of the chrominance coding distortion based on the chrominance quantization parameter, the preset luminance quantization parameter, and the first preset formula. The coding device weights the chrominance coding distortion according to the weight of the chrominance coding distortion, and substitutes the luminance coding distortion, the number of bits consumed in the luminance component image, the number of bits consumed in the chrominance component image, and the weighted chrominance coding distortion into the second preset formula to obtain the rate-distortion cost corresponding to the preset coding mode.
[0129] It should be noted that the first preset formula is used to characterize the change in the weight of chroma coding distortion under different chroma quantization parameters and different luma quantization parameters; the second preset formula is used to characterize the change in rate-distortion cost under different luma coding distortion, different chroma coding distortion, different numbers of bits of luma component images, and different numbers of bits of chroma component images. For example, the first preset formula can refer to Formula 7 above, and the second preset formula can refer to Formula 8 above.
[0130] S2032: The encoding apparatus determines a minimum rate-distortion cost from a plurality of rate-distortion costs, and determines a coding mode corresponding to the minimum rate-distortion cost as a target coding mode.
[0131] As one possible implementation, the encoding device arranges the calculated multiple rate-distortion costs in descending order to determine the minimum rate-distortion cost. Furthermore, the encoding device determines the encoding mode corresponding to the minimum rate-distortion cost as the target encoding mode, and then uses the target encoding mode to encode the target image or the video corresponding to the target image.
[0132] The above embodiments mainly introduce the solutions provided by the embodiments of the present disclosure from the perspective of the device (equipment). It is understandable that in order to implement the above methods, the device or equipment includes hardware structures and / or software modules corresponding to the execution of each method flow, and these hardware structures and / or software modules corresponding to the execution of each method flow can constitute an electronic device. It should be easy for those skilled in the art to appreciate that, in combination with the algorithm steps of each example described in the embodiments disclosed herein, the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.
[0133] The embodiments of the present disclosure can divide the functional modules of the device or equipment according to the above method examples. For example, the device or equipment can divide each functional module corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiments of the present disclosure is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0134] Figure 6 FIG. 1 is a schematic diagram of a coding device according to an exemplary embodiment. Figure 6 As shown, the encoding device 30 provided by the embodiment of the present disclosure includes an acquisition unit 301, a determination unit 302 and a processing unit 303.
[0135] An acquisition unit 301 is configured to acquire image data of a target image; the image data includes image data corresponding to a luminance component and image data corresponding to chrominance components. A determination unit 302 is configured to, for a target image having image data represented by a luminance component and at least one chrominance component, determine, respectively, texture features of the image data corresponding to the luminance component and texture features of the image data corresponding to each chrominance component. The texture features are used to reflect the texture complexity of the luminance component image in the target image, or the texture complexity of the chrominance component image in the target image. The determination unit 302 is further configured to determine a chrominance offset based on the texture features of the image data corresponding to the luminance component and the texture features of the image data corresponding to each chrominance component. The chrominance offset is used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the image data represented by each chrominance component. A processing unit 303 is configured to determine a chrominance quantization parameter based on the chrominance offset and a preset luminance quantization parameter, and to determine a target coding mode from a plurality of preset coding modes based on the chrominance quantization parameter and the preset luminance quantization parameter. The target coding mode is a coding mode that minimizes the rate-distortion cost after encoding the target image among the plurality of preset coding modes.
[0136] Optionally, the determination unit 302 is specifically configured to: for image data corresponding to any luminance component or chrominance component, divide the image data into blocks according to a preset size to obtain multiple data blocks, and transform and quantize the multiple data blocks to obtain a coefficient matrix corresponding to each data block; each data block contains the same number of pixel values; determine the cumulative value of each coefficient matrix to obtain multiple cumulative values; the cumulative value is the sum of the absolute values of each coefficient in the coefficient matrix; and determine the average value corresponding to the multiple cumulative values as the texture feature of the image data.
[0137] Optionally, the determination unit 302 is specifically configured to: for any data block, determine the average value corresponding to multiple pixel values in the data block; subtract the average value from each pixel value to obtain a residual matrix corresponding to the data block; transform and quantize the residual matrix to obtain a coefficient matrix corresponding to each data block.
[0138] Optionally, the target image includes first image data corresponding to a first chromaticity component and second image data corresponding to a second chromaticity component; the chromaticity information of the first image data is different from the chromaticity information of the second image data; the determination unit 302 is specifically configured to: determine a first chromaticity offset based on the texture features of the image data corresponding to the luminance component and the texture features of the first image data; the first chromaticity offset is used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the first image data; determine a second chromaticity offset based on the texture features of the image data corresponding to the luminance component and the texture features of the second image data; the second chromaticity offset is used to reflect the degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the second image data; and determine the average offset of the first chromaticity offset and the second chromaticity offset as the chromaticity offset.
[0139] Optionally, the determining unit 302 is specifically configured to: determine a chroma quantization parameter according to the chroma offset and a preset luminance quantization parameter.
[0140] Optionally, the processing unit 303 is specifically configured to: determine the rate-distortion cost after encoding the target image by each preset coding model based on the chrominance quantization parameter and the preset luminance quantization parameter, and obtain multiple rate-distortion costs; determine the minimum rate-distortion cost from the multiple rate-distortion costs, and determine the coding mode corresponding to the minimum rate-distortion cost as the target coding mode.
[0141] Optionally, the processing unit 303 is specifically configured to: for any preset coding mode, obtain the coding distortion generated by encoding the target image with the preset coding mode, and the number of bits consumed by encoding the target image with the preset coding mode; the coding distortion includes the luminance coding distortion of the luminance component image and the chrominance coding distortion of the chrominance component image; the number of bits includes the number of bits consumed by the luminance component image and the number of bits consumed by the chrominance component image; determine the weight of the chrominance coding distortion according to the chrominance quantization parameter, the preset luminance quantization parameter and the first preset formula; and calculate the weight of the chrominance coding distortion according to the weight of the chrominance coding distortion. The coding distortion is weighted, and the luminance coding distortion, the number of bits consumed by the luminance component image, the number of bits consumed by the chrominance component image, and the weighted chrominance coding distortion are substituted into the second preset formula to obtain the rate-distortion cost corresponding to the preset coding mode; the first preset formula is used to characterize the change of the weight of the chrominance coding distortion under different chrominance quantization parameters and different luminance quantization parameters; the second preset formula is used to characterize the change of the rate-distortion cost under different luminance coding distortion, different chrominance coding distortion, different numbers of bits of luminance component images, and different numbers of bits of chrominance component images.
[0142] Figure 7This is a schematic diagram of the structure of an electronic device provided by the present disclosure. Figure 7 As shown, the electronic device 40 may include at least one processor 401 and a memory 402 for storing processor-executable instructions, wherein the processor 401 is configured to execute the instructions in the memory 402 to implement the method for determining the encoding mode in the above embodiment.
[0143] In addition, the electronic device 40 may further include a communication bus 403 and at least one communication interface 404 .
[0144] The processor 401 may be a central processing unit (CPU), a microprocessor unit, an ASIC, or one or more integrated circuits for controlling the execution of the program of the disclosed solution.
[0145] The communication bus 403 may include a pathway for transmitting information between the aforementioned components.
[0146] The communication interface 404 uses any transceiver or other device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc.
[0147] The memory 402 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor via a bus. The memory may also be integrated with the processor.
[0148] The memory 402 is used to store instructions for executing the solution of the present disclosure, and the execution is controlled by the processor 401. The processor 401 is used to execute the instructions stored in the memory 402, thereby realizing the functions of the method for determining the encoding mode of the present disclosure.
[0149] As an example, combining Figure 6 The functions implemented by the acquisition unit 301, the determination unit 302 and the processing unit 303 in the encoding device 30 are the same as those implemented by Figure 7 The function of the processor 401 in is the same.
[0150] In a specific implementation, as an embodiment, the processor 401 may include one or more CPUs, such as Figure 7 CPU0 and CPU1 in.
[0151] In a specific implementation, as an embodiment, the electronic device 40 may include multiple processors, such as Figure 7 4 and 5. The processors 401 and 407 are shown in FIG. Each of these processors may be a single-CPU processor or a multi-CPU processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0152] In a specific implementation, as an embodiment, the electronic device 40 may further include an output device 405 and an input device 406. The output device 405 communicates with the processor 401 and can display information in a variety of ways. For example, the output device 405 can be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device 406 communicates with the processor 401 and can accept user input in a variety of ways. For example, the input device 406 can be a mouse, a keyboard, a touch screen device, or a sensor device.
[0153] Those skilled in the art will understand that Figure 7 The structure shown in the figure does not constitute a limitation on the electronic device 40, and the electronic device 40 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0154] In addition, the present disclosure also provides a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the method for determining the encoding mode provided in the above embodiment.
[0155] In addition, the present disclosure also provides a computer program product, including computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method for determining the encoding mode provided in the above embodiment.
[0156] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the disclosure herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the claims.
Claims
1. A method for determining a coding mode, characterized in that: The method comprises: Acquire image data of a target image; the image data includes image data corresponding to a luminance component and image data corresponding to a chrominance component; For image data corresponding to any one of the luminance components or the chrominance components, the image data is divided into blocks according to a preset size to obtain a plurality of data blocks, and the plurality of data blocks are transformed and quantized to obtain coefficient matrices corresponding to the data blocks; each data block contains the same number of pixel values; Determine the cumulative value of each coefficient matrix to obtain a plurality of cumulative values; the cumulative value is the sum of the absolute values of each coefficient in the coefficient matrix; Determining an average value corresponding to the multiple accumulated values as a texture feature of the image data; the texture feature is used to reflect the texture complexity of the luminance component image in the target image, or the texture complexity of the chrominance component image in the target image; determining a chroma offset based on texture features of the image data corresponding to the luminance component and texture features of the image data corresponding to each of the chroma components; the chroma offset is used to reflect the degree of deviation between the texture features of the image data corresponding to the luminance component and the texture features of the image data corresponding to each of the chroma components; According to the chroma offset and the preset luminance quantization parameter, a chroma quantization parameter is determined, and based on the chroma quantization parameter and the preset luminance quantization parameter, a target coding mode is determined from multiple preset coding modes; the target coding mode is the coding mode with the lowest rate-distortion cost after encoding the target image among the multiple preset coding modes.
2. The method for determining the coding mode according to claim 1, wherein: The transforming and quantizing the multiple data blocks to obtain a coefficient matrix corresponding to each of the data blocks includes: For any data block, determining an average value corresponding to a plurality of pixel values in the data block; Subtracting the average value from each pixel value to obtain a residual matrix corresponding to the data block; The residual matrix is transformed and quantized to obtain a coefficient matrix corresponding to each data block.
3. The method for determining the coding mode according to claim 1, wherein: The target image includes first image data corresponding to a first chrominance component and second image data corresponding to a second chrominance component; chrominance information of the first image data is different from chrominance information of the second image data; The determining of the chroma offset according to the texture feature of the image data corresponding to the luminance component and the texture feature of the image data corresponding to each of the chroma components includes: determining a first chroma offset based on texture features of the image data corresponding to the luminance component and texture features of the first image data; the first chroma offset being used to reflect a degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the first image data; determining a second chromaticity offset based on texture features of the image data corresponding to the luminance component and texture features of the second image data; the second chromaticity offset being used to reflect a degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the second image data; The chroma offset is determined according to the first chroma offset and the second chroma offset.
4. The method for determining a coding mode according to claim 1, wherein: The determining of the chroma quantization parameter according to the chroma offset and the preset luminance quantization parameter includes: The sum of the chroma offset and the preset luminance quantization parameter is determined as the chroma quantization parameter.
5. The method for determining a coding mode according to any one of claims 1 to 4, characterized in that: The determining a target coding mode from a plurality of preset coding modes based on the chrominance quantization parameter and the preset luma quantization parameter includes: Based on the chrominance quantization parameter and the preset luminance quantization parameter, respectively determining a rate-distortion cost after encoding the target image using each preset coding model to obtain a plurality of rate-distortion costs; A minimum rate-distortion cost is determined from the multiple rate-distortion costs, and a coding mode corresponding to the minimum rate-distortion cost is determined as the target coding mode.
6. The method for determining the coding mode according to claim 5, wherein: The method further comprises: determining, based on the chrominance quantization parameter and the preset luminance quantization parameter, a rate-distortion cost after encoding the target image by each preset coding model, to obtain a plurality of rate-distortion costs, including: For any preset coding mode, obtaining coding distortion generated by encoding the target image using the preset coding mode and the number of bits consumed by encoding the target image using the preset coding mode; the coding distortion includes luminance coding distortion of the luminance component image and chrominance coding distortion of the chrominance component image; and the number of bits includes the number of bits consumed by the luminance component image and the number of bits consumed by the chrominance component image; Determining a weight of the chroma coding distortion based on the chroma quantization parameter, the preset luma quantization parameter, and a first preset formula; wherein the first preset formula is used to characterize a change in the weight of the chroma coding distortion under different chroma quantization parameters and different luma quantization parameters; The chromaticity coding distortion is weighted according to the weight of the chromaticity coding distortion, and the luminance coding distortion, the number of bits consumed of the luminance component image, the number of bits consumed of the chromaticity component image, and the weighted chromaticity coding distortion are substituted into a second preset formula to obtain the rate-distortion cost corresponding to the preset coding mode; the second preset formula is used to characterize the change in the rate-distortion cost under different luminance coding distortions, different chromaticity coding distortions, different numbers of bits of luminance component images, and different numbers of bits of chromaticity component images.
7. An encoding device, characterized in that The encoding device includes an acquisition unit, a determination unit and a processing unit; The acquisition unit is configured to acquire image data of a target image; the image data includes image data corresponding to a luminance component and image data corresponding to a chrominance component; The determining unit is configured to divide the image data corresponding to any one of the luminance component or the chrominance component into blocks of a preset size to obtain a plurality of data blocks, and transform and quantize the plurality of data blocks to obtain coefficient matrices corresponding to the data blocks; each data block contains the same number of pixel values; The determining unit is further configured to determine a cumulative value of each of the coefficient matrices to obtain a plurality of cumulative values; the cumulative value is a cumulative sum of the absolute values of each coefficient in the coefficient matrix; The determining unit is further configured to determine an average value corresponding to the multiple accumulated values as a texture feature of the image data; the texture feature is used to reflect the texture complexity of the luminance component image in the target image, or the texture complexity of the chrominance component image in the target image; The determining unit is further configured to determine a chroma offset based on texture features of the image data corresponding to the luminance component and texture features of the image data corresponding to each of the chroma components; the chroma offset is used to reflect a degree of deviation between the texture features of the image data represented by the luminance component and the texture features of the image data represented by each of the chroma components; The processing unit is configured to determine a chroma quantization parameter according to the chroma offset and a preset luma quantization parameter, and determine a target coding mode from a plurality of preset coding modes based on the chroma quantization parameter and the preset luma quantization parameter; The target coding mode is a coding mode with the lowest rate-distortion cost after encoding the target image among the multiple preset coding modes.
8. An electronic device, characterized in that: include: A processor and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the method for determining the encoding mode according to any one of claims 1 to 6.
9. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method for determining a coding mode according to any one of claims 1 to 6.
Citation Information
Patent Citations
Video processing method for rate distortion optimization based on multi-color space and application
CN114205586A
Chroma quantization in video coding
EP2854404A2