Method, device, electronic device and storage medium for determining intra-frame coding mode
By determining the current encoding prediction mode in intracoding and calculating the distortion value, the problem of high computational complexity of reconstructed pixels in the prior art is solved, and more efficient encoding prediction mode selection and encoding efficiency are achieved.
Patent Information
- Application Number
- CN202111666394.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-12-31
AI Technical Summary
In the prior art, when calculating the rate distortion cost of each encoding prediction mode, the calculation complexity of the reconstruction pixel is high and the encoding efficiency is low.
In the preset at least two encoding prediction modes, the current encoding prediction mode is determined, and the current pixel block to be measured is determined in the current frame image, the reference reconstruction pixel block is obtained according to the current encoding prediction mode, and the distortion value is calculated by transforming residuals and preset distortion estimation algorithm to form the reconstruction pixel block of the pixel block to be measured, avoiding quantization, inverse quantization, and inverse transformation operations.
The calculation amount of reconstructed pixel blocks is reduced, hardware resources are saved, processing efficiency is improved, and RD-cost efficiency is improved for calculating each encoding prediction mode, thereby improving coding efficiency.
Smart Images

Figure CN114286108B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video coding technology, and in particular to a method, device, electronic device and storage medium for determining an intra-frame coding mode. Background Art
[0002] At present, network applications are gradually developing towards multimedia services. As an important part of multimedia services, video has become one of the main carriers of information dissemination. The widespread application of video has put forward new requirements for video quality. Now the resolution of various videos is getting higher and higher. At the same time, the growth rate of video data volume has far exceeded the development speed of storage devices and network bandwidth. Therefore, video compression coding technology has received long-term and extensive attention.
[0003] In the existing video compression coding technology, intra-frame coding is predictive coding using only intra-frame information. Its coding process is independent of the information of the previous and next frames, and the coding process is independent and has low complexity. It is one of the main coding methods of new generation encoders such as H264 and H265. In the above-mentioned new generation encoders such as H264 and H265, intra-frame coding includes three types of intra-frame coding modes, namely intra-frame 4*4 luminance prediction, intra-frame 16*16 luminance prediction, and intra-frame 8*8 chrominance prediction. Among them, each intra-frame coding mode has multiple coding prediction modes. For example, there are 9 optional coding prediction modes for intra-frame 4*4 luminance prediction, 4 optional coding prediction modes for intra-frame 16*16 luminance prediction, and 4 coding prediction modes for intra-frame 8*8 chrominance prediction. Since the parameters required for each coding prediction mode are different, the coding effects achieved for different video images are also different. In order to select the best coding prediction mode for different video images, in current technology, a set of coding prediction modes with the best rate-distortion performance can be selected for the encoder from all possible coding prediction modes through the rate-distortion optimization (RDO) algorithm. Therefore, in order to select the coding prediction mode with the best rate-distortion performance from many coding prediction modes, it is necessary to traverse all coding prediction modes and simultaneously calculate the rate-distortion cost (Rate-Distortion Cost) corresponding to each coding prediction mode. When calculating RD-cost, it is necessary to calculate the distortion between the reconstructed pixel and the original pixel. In the process of calculating the distortion between the reconstructed pixel and the original pixel, it is necessary to first obtain the reconstructed pixel. At present, the way to obtain the reconstructed pixel is to transform, quantize, dequantize, inversely transform and other operations on the prediction residual between the predicted pixel block and the pixel block to be tested, which has high computational complexity and low coding efficiency. Summary of the invention
[0004] In view of this, the present application provides a method, device, electronic device and storage medium for determining an intra-frame coding mode, so as to solve the problem of high computational complexity of reconstructing pixels and low coding efficiency when calculating the rate-distortion cost of each coding prediction mode in the prior art.
[0005] In a first aspect, an embodiment of the present application provides a method for determining an intra-frame coding mode, including:
[0006] Determine a current coding prediction mode in at least two preset coding prediction modes, determine a current pixel block to be tested in a current frame image, and obtain a reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode;
[0007] Determine a predicted pixel block of the current pixel block to be tested according to the reference reconstructed pixel block, and obtain a prediction residual of the current pixel block to be tested according to the current pixel block to be tested and the predicted pixel block;
[0008] Performing transformation processing on the prediction residual of the current pixel block to be tested to obtain a transformation residual;
[0009] Calculating a distortion value corresponding to the transform residual according to the transform residual and a preset distortion estimation algorithm;
[0010] A reconstructed pixel block corresponding to the current pixel block to be tested is formed according to the prediction residual, the distortion value corresponding to the transform residual and the prediction pixel block.
[0011] Preferably, determining a current pixel block to be tested, and obtaining a reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode comprises:
[0012] In the current frame image, according to a preset order, a current pixel block to be tested is determined from at least one pixel block to be tested for which a corresponding reconstructed pixel block has not been determined;
[0013] According to the current pixel block to be tested and the current coding prediction mode, a reference reconstructed pixel block corresponding to the current pixel block to be tested under the current coding prediction mode is determined in the reconstructed pixel blocks.
[0014] Preferably, forming the reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction residual, the distortion value corresponding to the transform residual and the prediction pixel block comprises:
[0015] Calculating a residual reconstruction value corresponding to the prediction residual according to the prediction residual and the distortion value corresponding to the transformation residual;
[0016] A reconstructed pixel block corresponding to the current pixel block to be tested is formed according to the residual reconstruction value corresponding to the prediction residual and the predicted pixel block.
[0017] Preferably, it also includes:
[0018] Quantizing the transformation residual to obtain quantization information of the current pixel block to be tested;
[0019] A rate-distortion cost corresponding to the current pixel block to be tested in the current coding prediction mode is calculated according to the current pixel block to be tested, the reconstructed pixel block corresponding to the current pixel block to be tested, and the quantization information.
[0020] Preferably, it also includes:
[0021] Detecting whether the current pixel block to be tested has a corresponding rate-distortion cost calculated in each of the at least two preset coding prediction modes;
[0022] If the corresponding rate-distortion cost is calculated for the current pixel block to be tested in each of the at least two preset coding prediction modes, the coding prediction mode in which the rate-distortion cost corresponding to the current pixel block to be tested is minimized is determined as the target coding prediction mode of the current pixel block to be tested;
[0023] The target coding prediction mode is used to encode the current pixel block to be tested.
[0024] Preferably, it also includes:
[0025] If there is a current pixel block to be tested for which the corresponding rate-distortion cost has not been calculated under at least one preset coding prediction mode, then in at least one preset coding prediction mode for which the corresponding rate-distortion cost has not been calculated, select a preset coding prediction mode to update it as the current coding prediction mode, and re-execute the steps of determining the current pixel block to be tested in the current frame image, obtaining the reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode, to step of detecting whether the current pixel block to be tested has calculated the corresponding rate-distortion cost under each of the at least two preset coding prediction modes, until the current pixel block to be tested has calculated the corresponding rate-distortion cost under each of the at least two preset coding prediction modes.
[0026] Preferably, it also includes:
[0027] When the current frame image is not the last uncoded frame image in the acquired multiple frame images, the next frame image of the current frame image is acquired, and the next frame image is updated to the current frame image, and the step of determining the current coding prediction mode in at least two preset coding prediction modes, and determining the current pixel block to be tested in the current frame image is re-executed, and a reference reconstructed pixel block corresponding to the current pixel block to be tested is obtained according to the current coding prediction mode, and the step of encoding the current pixel block to be tested using the target coding prediction mode is performed until the current frame image is the last uncoded frame image in the acquired multiple frame images.
[0028] In a second aspect, an embodiment of the present application provides a device for determining an intra-frame coding mode, including:
[0029] A processing unit, configured to determine a current coding prediction mode in at least two preset coding prediction modes, determine a current pixel block to be tested in a current frame image, and obtain a reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode;
[0030] an acquisition unit, configured to determine a predicted pixel block of the current pixel block to be tested according to the reference reconstructed pixel block, and acquire a prediction residual of the current pixel block to be tested according to the current pixel block to be tested and the predicted pixel block;
[0031] The processing unit is further used to perform transformation processing on the prediction residual of the current pixel block to be tested to obtain a transformation residual;
[0032] A calculation unit, configured to calculate a distortion value corresponding to the transform residual according to the transform residual and a preset distortion estimation algorithm;
[0033] The processing unit is further configured to form a reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction residual, the distortion value corresponding to the transform residual and the prediction pixel block.
[0034] Preferably, the processing unit is specifically configured to determine, in the current frame image, according to a preset order, a current pixel block to be tested from at least one pixel block to be tested for which a corresponding reconstructed pixel block has not been determined;
[0035] According to the current pixel block to be tested and the current coding prediction mode, a reference reconstructed pixel block corresponding to the current pixel block to be tested under the current coding prediction mode is determined in the reconstructed pixel blocks.
[0036] Preferably, the processing unit is specifically configured to calculate a residual reconstruction value corresponding to the prediction residual according to the prediction residual and the distortion value corresponding to the transformation residual;
[0037] A reconstructed pixel block corresponding to the current pixel block to be tested is formed according to the residual reconstruction value corresponding to the prediction residual and the predicted pixel block.
[0038] Preferably, the processing unit is further used to perform quantization processing on the transformation residual to obtain quantization information of the current pixel block to be tested;
[0039] The processing unit is further used to calculate the rate-distortion cost corresponding to the current pixel block to be tested in the current coding prediction mode according to the current pixel block to be tested, the reconstructed pixel block corresponding to the current pixel block to be tested, and the quantization information.
[0040] Preferably, the device further comprises:
[0041] A detection unit, configured to detect whether the current pixel block to be tested has a corresponding rate-distortion cost calculated in each of the at least two preset coding prediction modes;
[0042] a determining unit, configured to determine, if the corresponding rate-distortion cost of the current pixel block to be tested is calculated under each of the at least two preset coding prediction modes, the coding prediction mode in which the rate-distortion cost corresponding to the current pixel block to be tested is the minimum as the target coding prediction mode of the current pixel block to be tested;
[0043] The processing unit is further configured to encode the current pixel block to be tested by adopting the target encoding prediction mode.
[0044] Preferably, the processing unit is also used to, if there is a current pixel block to be tested for which the corresponding rate-distortion cost has not been calculated under at least one preset coding prediction mode, select a preset coding prediction mode from at least one preset coding prediction mode for which the corresponding rate-distortion cost has not been calculated, update it to the current coding prediction mode, and re-execute in the current frame image, determine the current pixel block to be tested, obtain the reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode to trigger the detection unit to detect whether the current pixel block to be tested has calculated the corresponding rate-distortion cost under each of the at least two preset coding prediction modes, until the current pixel block to be tested has calculated the corresponding rate-distortion cost under each of the at least two preset coding prediction modes.
[0045] Preferably, the processing unit is also used to obtain the next frame image of the current frame image when the current frame image is not the last unencoded frame image in the acquired multiple frame images, and update the next frame image to the current frame image, and re-execute the current coding prediction mode in at least two preset coding prediction modes, and determine the current pixel block to be tested in the current frame image, obtain the reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode, and encode the current pixel block to be tested using the target coding prediction mode until the current frame image is the last unencoded frame image in the acquired multiple frame images.
[0046] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed, the electronic device executes any one of the methods described in the first aspect above.
[0047] In a fourth aspect, an embodiment of the present application provides a storage medium, including: the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute any method described in the first aspect above.
[0048] By adopting the scheme provided in the embodiment of the present application, in at least two coding prediction modes, a current coding prediction mode is determined, and a current pixel block to be tested is determined in a current frame image, a reference reconstructed pixel block corresponding to the current pixel block to be tested is obtained according to the current coding prediction mode, a predicted pixel block of the current pixel block to be tested is determined according to the current pixel block to be tested and the reference reconstructed pixel block, and a prediction residual of the current pixel block to be tested is obtained according to the current pixel block to be tested and the predicted pixel block; the prediction residual is transformed to obtain a transformed residual; a distortion value corresponding to the transformed residual is calculated according to the transformed residual and a preset distortion estimation algorithm; and a reconstructed pixel block corresponding to the current pixel block to be tested is formed according to the prediction residual, the distortion value corresponding to the transformed residual and the predicted pixel block. That is to say, in the embodiment of the present application, when reconstructing a pixel block, it is only necessary to transform the prediction residuals of the current pixel block to be tested and the predicted pixel block, and it is only necessary to use a distortion estimation algorithm on the transformed residuals to obtain the distortion corresponding to the transformed residuals, and then the reconstructed pixel block corresponding to the current pixel block to be tested can be obtained based on the distortion corresponding to the transformed residuals, the predicted residuals and the predicted pixel block, without the need for quantization, inverse quantization, inverse transformation and other operations, which greatly reduces the amount of calculation when reconstructing the pixel block, saves hardware resources, and improves the processing efficiency when reconstructing the pixel block. In this way, the efficiency of calculating the RD-cost of each coding prediction mode can be improved, thereby improving the coding efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0050] Figure 1 A schematic diagram of a scenario of a coding prediction mode for intra-frame coding provided in an embodiment of the present application;
[0051] Figure 2 A schematic diagram of another scenario of an intra-frame coding prediction mode provided in an embodiment of the present application;
[0052] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0053] Figure 4 A schematic flow chart of a method for determining an intra-frame coding mode provided in an embodiment of the present application;
[0054] Figure 5 A schematic diagram of a scenario for determining an intra-frame coding mode provided in an embodiment of the present application;
[0055] Figure 6 A schematic flow chart of another method for determining an intra-frame coding mode provided in an embodiment of the present application;
[0056] Figure 7 A schematic diagram of another scenario for determining an intra-frame coding mode provided in an embodiment of the present application;
[0057] Figure 8 A schematic diagram of the structure of a device for determining an intra-frame coding mode provided in an embodiment of the present application;
[0058] Fig. 9 A schematic diagram of the structure of another device for determining an intra-frame coding mode provided in an embodiment of the present application;
[0059] Fig.10 A schematic diagram of the structure of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0061] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0062] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0063] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0064] Before a detailed introduction to the embodiments of the present application, the terms that are applied or may be applied to the embodiments of the present application are first explained.
[0065] Image coding, also known as image compression, refers to the technology of representing an image or the information contained in the image with fewer bits while meeting a certain quality requirement (signal-to-noise ratio or subjective evaluation score).
[0066] The general purpose of rate-distortion optimization (RDO) is to obtain the least possible image distortion at the lowest possible encoding bit rate. That is, how to minimize the distortion under a given encoding bit rate, where rate refers to the amount of information (bit rate R); distortion refers to the difference between the received short signal and the source signal (distortion D).
[0067] In the related art, intra-frame coding is one of the main coding methods of new generation encoders such as H264 and H265. Taking the H264 encoder as an example, in the H264 encoder, intra-frame coding includes three types of intra-frame coding modes, namely intra-frame 4*4 brightness prediction, intra-frame 16*16 brightness prediction and intra-frame 8*8 chrominance prediction.
[0068] Intra-frame 4*4 brightness prediction predicts each 4*4 brightness block independently, which is suitable for encoding images with a lot of details. Figure 1 As shown, there are 9 optional coding prediction modes for intra-frame 4*4 brightness prediction, and the reference pixels required for each coding prediction mode are shown in Table 1 below:
[0069] Table 1
[0070]
[0071]
[0072] Intra-frame 16*16 brightness prediction is suitable for flat area image coding, such as Figure 2 As shown, there are four optional coding prediction modes for intra-frame 16*16 brightness prediction, namely mode 0: horizontal coding prediction mode, mode 1: vertical coding prediction mode, mode 2: DC coding prediction mode and mode 3: plane coding prediction mode.
[0073] There are also 4 optional coding prediction modes for intra-frame 8*8 chrominance prediction, namely mode 0: DC coding prediction mode, mode 1: horizontal coding prediction mode, mode 2: vertical coding prediction mode and mode 3: plane coding prediction mode.
[0074] Since the parameters required for each coding prediction mode are different, the coding effects achieved for different video images are also different. In order to select the optimal coding prediction mode for different video images, in current technology, a set of coding prediction modes with the best rate-distortion performance can be selected for the encoder from all possible coding prediction modes through a rate-distortion optimization algorithm. Therefore, in order to select the coding prediction mode with the best rate-distortion performance from a large number of coding prediction modes, it is necessary to traverse all coding prediction modes and simultaneously calculate the rate-distortion cost corresponding to each coding prediction mode. When calculating RD-cost, it is necessary to calculate the distortion between the reconstructed pixel and the original pixel. In the process of calculating the distortion between the reconstructed pixel and the original pixel, it is necessary to first obtain the reconstructed pixel. At present, the way to obtain the reconstructed pixel is to transform, quantize, dequantize, inversely transform and other operations on the prediction residual between the reference pixel block and the pixel block to be tested, which has high computational complexity and low predictive coding efficiency.
[0075] In response to the above problems, an embodiment of the present application provides a method for determining an intra-frame coding mode, in which a current coding prediction mode is determined in at least two coding prediction modes, and a current pixel block to be tested is determined in a current frame image, a reference reconstructed pixel block corresponding to the current pixel block to be tested is obtained according to the current coding prediction mode, a predicted pixel block of the current pixel block to be tested is determined according to the current pixel block to be tested and the reference reconstructed pixel block, and a prediction residual of the current pixel block to be tested is obtained according to the current pixel block to be tested and the predicted pixel block; the prediction residual is transformed to obtain a transformed residual; a distortion value corresponding to the transformed residual is calculated according to the transformed residual and a preset distortion estimation algorithm; and a reconstructed pixel block corresponding to the current pixel block to be tested is formed according to the prediction residual, the distortion value corresponding to the transformed residual, and the predicted pixel block. That is to say, in the embodiment of the present application, when reconstructing a pixel block, it is only necessary to transform the prediction residual of the current pixel block to be tested and the prediction pixel block, and it is only necessary to use a distortion estimation algorithm on the transformation residual to obtain the distortion corresponding to the transformation residual, and then the reconstructed pixel block corresponding to the current pixel block to be tested can be obtained according to the distortion corresponding to the transformation residual, the prediction residual and the prediction pixel block, without the need for quantization, inverse quantization, inverse transformation and other operations, which greatly reduces the amount of calculation when reconstructing the pixel block, saves hardware resources, and improves the processing efficiency when reconstructing the pixel block. In this way, the efficiency of calculating the RD-cost of each coding prediction mode can be improved, and then the target coding prediction module of each pixel block to be tested can be determined more quickly, thereby improving the coding efficiency. The following is a detailed description.
[0076] See also Figure 3 , is a schematic diagram of an electronic device provided in an embodiment of the present application. Figure 3 The electronic device is described in detail by taking a mobile phone 300 as an example. Figure 3 3 shows the front view and rear view of the mobile phone 300. Two front cameras 311 and 112 are configured on the front side of the mobile phone 300, and four rear cameras 321, 322, 323, and 324 are configured on the rear side of the mobile phone 300. Multiple cameras can provide users with multiple shooting modes. Users can select corresponding shooting modes to shoot according to the shooting scene to improve user experience.
[0077] Understandable, Figure 3The above is only an exemplary description and should not be used as a limitation on the scope of protection of this application. For example, different mobile phones may have different camera configuration numbers and configuration locations. In addition, in addition to mobile phones, the electronic devices involved in the embodiments of the present application may also be tablet computers, personal computers (PCs), personal digital assistants (PDAs), smart watches, netbooks, wearable electronic devices, augmented reality (AR) devices, virtual reality (VR) devices, vehicle-mounted devices, smart cars, smart speakers, robots, smart glasses, smart TVs, etc.
[0078] It should be noted that in some possible implementations, the electronic device may also be called a terminal device, a user equipment (UE), etc., which is not limited in the embodiments of the present application.
[0079] See also Figure 4 , which is a flow chart of a method for determining an intra-frame coding mode according to an embodiment of the present application. Figure 3 The electronic device shown, the method includes:
[0080] Step S401: determine a current coding prediction mode among at least two preset coding prediction modes, determine a current pixel block to be tested in a current frame image, and obtain a reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode.
[0081] In an embodiment of the present application, when an electronic device needs to encode a frame of image, intra-frame encoding can be used to encode the frame of image. Since intra-frame encoding includes multiple encoding prediction modes, the encoding effect of each encoding prediction mode is different for different images. In order to select the optimal encoding prediction mode, the encoding prediction mode of intra-frame encoding needs to be determined for each frame of image. When determining the optimal encoding prediction mode, the rate-distortion cost can be calculated, and the optimal encoding prediction mode is determined by the value of the rate-distortion cost. When calculating the rate-distortion cost, the distortion between the reconstructed pixel block and the original pixel block needs to be calculated, that is, the sum of square errors between the reconstructed pixel block and the original pixel block is calculated. Therefore, before calculating the rate-distortion cost, the pixel block needs to be reconstructed first. For the convenience of implementation, each frame of image is usually divided into multiple pixel blocks that do not overlap and have the same size, and the reconstructed pixel block is determined for each pixel block, and then the optimal encoding prediction mode can be determined according to the reconstructed pixel block, that is, the target encoding prediction mode is determined, and the pixel block is encoded accordingly using the determined target encoding prediction mode. Intra-frame coding includes three types of intra-frame coding modes, namely, intra-frame 4*4 brightness prediction, intra-frame 16*16 brightness prediction and intra-frame 8*8 chrominance prediction. That is, for each frame of image, when using the brightness macroblock of the coding mode, there are two division methods, namely 4*4 size and 16*16 size. In other words, according to the brightness of each frame, each frame of image is divided into multiple 4*4 pixel blocks, or divided into multiple 16*16 pixel blocks. When using the chrominance macroblock of the coding mode, there is a division method of 8*8 size. In other words, according to the chrominance of each frame, each frame of image is divided into multiple 8*8 pixel blocks.
[0082] Since the electronic device may obtain multiple frames of images when performing image encoding, it is necessary to determine the coding prediction mode in the intra-frame coding mode for each frame of image. Since the determination method for each frame of image is the same, in the embodiment of the present application, the current frame image can be used as an example for explanation. In the current frame image, the current frame image can be divided into multiple pixel blocks of a specified size according to a preset division method. In the embodiment of the present application, the preset division method can be used as an example for explanation of the 4*4 size of the luminance macroblock. That is, the current frame image is divided into multiple pixel blocks of 4*4 size. It is necessary to perform pixel reconstruction on each pixel block of 4*4 size. At this time, the electronic device can divide the current frame image into multiple pixel blocks of 4*4 size, and determine the pixel block to be tested for pixel reconstruction, that is, the current pixel block to be tested. Since each type of intra-frame coding mode includes multiple coding prediction modes, in the embodiment of the present application, it is necessary to determine the target coding prediction mode for the current pixel block to be tested in multiple coding prediction modes, so it is necessary to calculate the rate-distortion cost corresponding to the current pixel block to be tested in each coding prediction mode. At this time, the electronic device can determine one coding prediction mode as the current coding prediction mode from among at least two preset coding prediction modes. Since each coding prediction mode requires the use of relevant data of adjacent reconstructed pixel blocks to obtain the reconstructed pixel block corresponding to the current pixel block to be tested, and the adjacent reconstructed pixel blocks to be used by each coding prediction mode are not completely the same, when determining the current pixel block to be tested and the current coding prediction mode, it is necessary to determine the reference reconstructed pixel block corresponding to the current pixel block to be tested from the reconstructed pixel blocks.
[0083] As a possible implementation manner, in the current frame image, determining the current pixel block to be tested, and obtaining the reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode includes:
[0084] In the current frame image, according to a preset order, a current pixel block to be tested is determined in at least one pixel block to be tested whose corresponding reconstructed pixel block has not been determined. According to the current pixel block to be tested and the current coding prediction mode, a reference reconstructed pixel block corresponding to the current pixel block to be tested in the current coding prediction mode is determined in the reconstructed pixel blocks.
[0085] In the embodiment of the present application, in the current frame image, after the current frame image is divided into a plurality of 4*4 pixel blocks, the current pixel block to be tested can be determined in a preset order from at least one pixel block to be tested for which the corresponding reconstructed pixel block has not been determined, with the pixel block to be 4*4 as a unit. The preset order is pre-set and can include an order from the left side to the right side of the image and from the top side to the bottom side of the image.
[0086] After the current pixel block to be tested is determined, since there are multiple coding prediction modes, and since the rate-distortion cost corresponding to the current pixel block to be tested needs to be calculated for each coding prediction mode, it is necessary to determine a coding prediction mode as the current coding prediction mode among multiple coding prediction modes for which the rate-distortion cost corresponding to the current pixel block to be tested has not been calculated, so as to calculate the rate-distortion cost corresponding to the current pixel block to be tested under the current coding prediction mode. Since the reference reconstructed pixel blocks required for each coding prediction mode are different, after the current coding prediction mode is determined, the reference reconstructed pixel block corresponding to the current pixel block to be tested under the current coding prediction mode can be determined from the reconstructed pixel blocks according to the current coding prediction mode and the current pixel block to be tested.
[0087] It should be noted that when the current pixel block to be tested has no corresponding reference reconstructed pixel block, that is, when the current pixel block to be tested is the pixel block to be tested in the first row or the first column of the current frame image, the reference reconstructed pixel block has not been calculated. At this time, the preset reference pixel block stored in the storage medium can be used as the reference reconstructed pixel block corresponding to the current pixel block to be tested.
[0088] Step S402: determine a predicted pixel block of the current pixel block to be tested according to the current pixel block to be tested and the reference reconstructed pixel block, and obtain a prediction residual of the current pixel block to be tested according to the current pixel block to be tested and the predicted pixel block.
[0089] In an embodiment of the present application, after determining the current pixel block to be tested and the parameter reconstruction pixel block, the predicted pixel block of the current pixel to be tested can be calculated, that is, the value of each pixel in the predicted pixel block can be determined according to the current coding prediction mode and the reference reconstruction pixel block, and then the predicted pixel block of the current pixel to be tested can be determined. For example, the value of the pixel in the reference reconstruction pixel block is determined as the value of the pixel at the corresponding position in the predicted pixel block. After determining the predicted pixel block of the current pixel block to be tested, the prediction residual of the current pixel block to be tested can be calculated based on the current pixel block to be tested and the pixel block to be tested. That is, the pixel difference between each pixel in the current pixel block to be tested and the pixel at the corresponding position in the predicted pixel block is calculated to obtain the prediction residual of the current pixel block to be tested.
[0090] Step S403: transform the prediction residual of the current pixel block to be tested to obtain a transformed residual.
[0091] In the embodiment of the present application, since the image contains a lot of flat area content or a region with slowly changing content, the dispersed distribution of the image energy in the spatial domain can be transformed into a relatively concentrated distribution in the frequency domain, thereby achieving the effect of reducing the transmission code stream and compressing the image. Based on this, after calculating the prediction residual of the current pixel block to be tested, the electronic device can transform the prediction residual of the current pixel block to be tested to obtain a transformation residual.
[0092] As a possible implementation method, the electronic device can calculate the prediction residual by the formula F=D f YD f T The transformation residual is calculated. f is the transformation matrix of the preset frequency domain, specified by the H.264 / AVC standard, f represents the frequency domain, F is the transformation residual, and Y is the prediction residual. f With D f T are transposed matrices of each other, for example,
[0093] That is, by calculating D f , prediction residuals, and D f T The product of is used to obtain the transformed residual.
[0094] Step S404: Calculate a distortion value corresponding to the transform residual according to the transform residual and a preset distortion estimation algorithm.
[0095] It should be noted that in the process of image coding and compression, the distortion mainly comes from the quantization process. In the quantization process, due to the need to right-shift q bits for rounding, q low bits are discarded, resulting in distortion. Among them, q is an integer greater than 0, and the value of q is determined according to the number of bits that need to be right-shifted when rounding is required in the actual calculation process.
[0096] In the embodiment of the present application, after calculating the transformation residual, the electronic device may calculate the distortion corresponding to the transformation residual using a preset distortion estimation algorithm, and determine the distortion value corresponding to the transformation residual.
[0097] As a possible implementation method, the electronic device can use formula D l =((|low -qbits -offset| / 2 q_bits )*Q step ) 2 Calculate the distortion value. l Indicates the distortion value, low -qbits Indicates the amount of data lost by the right shift bits during the quantization process, offset indicates the offset, q_bits indicates the number of right shift bits during the quantization process, Q step Indicates the quantization step size.
[0098] Step S405 : forming a reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction residual, the distortion value corresponding to the transform residual and the prediction pixel block.
[0099] In the embodiment of the present application, after calculating the distortion value corresponding to the change parameter, the electronic device can form a reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction parameter, the distortion value corresponding to the transformation residual and the predicted pixel block.
[0100] As a possible implementation, forming a reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction residual, the distortion value corresponding to the transformation residual and the prediction pixel block includes:
[0101] According to the distortion values corresponding to the prediction residual and the transformation residual, a residual reconstruction value corresponding to the prediction residual is calculated. According to the residual reconstruction value corresponding to the prediction residual and the prediction pixel block, a reconstructed pixel block corresponding to the current pixel block to be tested is formed.
[0102] In an embodiment of the present application, when reconstructing pixels, the electronic device can use the prediction residual, the distortion value corresponding to the transform residual, and the prediction pixel block to form a reconstructed pixel block corresponding to the current pixel block to be tested. Since the prediction residual is distorted during the encoding process, in order to improve the accuracy of the reconstructed pixel block, it is necessary to compensate the prediction residual before forming the reconstructed pixel block corresponding to the current pixel block to be tested. At this time, after calculating the distortion value corresponding to the transform residual, the residual reconstruction value corresponding to the prediction residual can be calculated according to the prediction residual and the distortion value corresponding to the transform residual. As a possible implementation method, the difference between the prediction residual and the distortion value corresponding to the transform residual can be used as the residual reconstruction value corresponding to the prediction residual. For example, the difference between the value of each prediction residual in the matrix of the prediction residual and the distortion value of the corresponding position in the matrix of the distortion value corresponding to the transform residual can be used as the residual reconstruction value of the corresponding position in the matrix of the residual reconstruction value.
[0103] After calculating the residual reconstruction value corresponding to the prediction residual, the reconstructed pixel block corresponding to the current pixel block to be tested can be formed according to the residual reconstruction value corresponding to the prediction residual and the prediction pixel block. As a possible implementation method, the sum of the residual reconstruction value corresponding to the prediction residual and the prediction pixel block can be used as the reconstructed pixel block corresponding to the current pixel block to be tested. That is, the sum of each residual reconstruction value in the residual reconstruction matrix and the value of the pixel point at the corresponding position in the prediction pixel block can be used as the value of the pixel point at the corresponding position in the reconstructed pixel block corresponding to the current pixel block to be tested, such as Figure 5 shown.
[0104] Through the above method, the reconstructed pixel block corresponding to the current pixel block to be tested can be calculated, and when calculating the reconstructed pixel block corresponding to the current pixel block to be tested, it is only necessary to transform the prediction residual, and there is no need to perform inverse quantization and inverse transformation processes, which greatly reduces the calculation complexity and improves the rate of reconstructing the pixel block, thereby increasing the rate of using the calculated reconstructed pixel block for RDC, thereby improving the efficiency of determining the coding prediction mode.
[0105] See also Figure 6 , is a flow chart of another method for determining an intra-frame coding mode provided by an embodiment of the present application. This method is applied to Figure 3 The electronic device shown in the figure. The method described in the embodiments of the present application is relative to the attached Figure 4 The method described above adds a process of calculating the corresponding rate-distortion cost, which is as follows:
[0106] Step S601: determine a current coding prediction mode among at least two preset coding prediction modes, determine a current pixel block to be tested in a current frame image, and obtain a reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode.
[0107] For details, please refer to step S401 and no further details will be given here.
[0108] Step S602: determine a predicted pixel block of a current pixel block to be tested according to a reference reconstructed pixel block, and obtain a prediction residual of the current pixel block to be tested according to the current pixel block to be tested and the predicted pixel block.
[0109] For details, please refer to step S402 and no further details will be given here.
[0110] Step S603: transform the prediction residual of the current pixel block to be tested to obtain a transformed residual.
[0111] For details, please refer to step S403 and no further details will be given here.
[0112] Step S604: Calculate the distortion value corresponding to the transform residual according to the transform residual and a preset distortion estimation algorithm.
[0113] For details, please refer to step S404 and no further details will be given here.
[0114] Step S605: forming a reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction residual, the distortion value corresponding to the transform residual and the prediction pixel block.
[0115] For details, please refer to step S405 and no further details will be given here.
[0116] Step S606: quantize the transformation residual to obtain quantization information of the current pixel block to be tested.
[0117] In an embodiment of the present application, after calculating the change residual, the electronic device needs to quantize the change residual in order to perform subsequent RDC calculations, thereby obtaining the quantization information of the current pixel block to be tested. For example, a quantization matrix can be pre-set, and after calculating the transformation residual, the value of each change residual in the matrix of the transformation residual can be divided by the corresponding quantization value in the quantization matrix, and the quotient can be rounded to obtain the quantized value. The quantization information of the current pixel block to be tested can be calculated in the above manner.
[0118] Step S607: Calculate the rate-distortion cost corresponding to the current pixel block to be tested in the current coding prediction mode according to the current pixel block to be tested, the reconstructed pixel block corresponding to the current pixel block to be tested, the quantization information, and the coding rate.
[0119] In an embodiment of the present application, after obtaining the quantization information of the current pixel block to be tested, the electronic device needs to encode the quantization information, the coding prediction mode and other information. When encoding the quantization information, the coding prediction mode and other information, the bit rate when encoding the quantization information and the bit rate when encoding the coding prediction mode and other information can be obtained.
[0120] After obtaining the bit rate when encoding the quantization information and the bit rate when encoding the encoding prediction mode and other information, the electronic device can calculate the rate-distortion cost corresponding to the current pixel block to be tested under the current encoding prediction mode based on the current pixel block to be tested, the reconstructed pixel block corresponding to the current pixel block to be tested, the quantization information, and each encoding bit rate.
[0121] As a possible implementation, the electronic device can calculate the distortion value between the current pixel block to be tested and the reconstructed pixel block corresponding to the current pixel block to be tested using the square error sum formula according to the current pixel block to be tested, the reconstructed pixel block corresponding to the current pixel block to be tested, the quantization information, and the coding rate, and calculate the rate distortion cost corresponding to the current pixel block to be tested in the current coding prediction mode according to the distortion value between the current pixel block to be tested and the reconstructed pixel block corresponding to the current pixel block to be tested, the quantization information, and the coding rate. The square error sum formula is as follows: Among them i Represents the pixel value corresponding to the i-th pixel in the current pixel block to be tested; rec i represents the pixel reconstruction value corresponding to the i-th pixel in the reconstructed pixel block; N represents the number of pixels in the current pixel block to be tested; D represents the distortion value between the current pixel block to be tested and the reconstructed pixel block corresponding to the current pixel block to be tested.
[0122] As a possible implementation method, the electronic device calculates the rate-distortion cost corresponding to the current pixel block to be tested in the current coding prediction mode according to the distortion, quantization information and various coding rates between the current pixel block to be tested and the reconstructed pixel block corresponding to the current pixel block to be tested, using the formula RDcost=D+λR. Wherein, RDcost represents the rate-distortion cost corresponding to the current pixel block to be tested in the current coding prediction mode, λ represents the Lagrangian factor, and R represents the coding rate of the quantization information and the coding rate of the coding prediction mode and other information.
[0123] Step S608: Detect whether the current pixel block to be tested has calculated a corresponding rate-distortion cost in each of the at least two preset coding prediction modes.
[0124] In the embodiment of the present application, since there are multiple coding prediction modes in intra-frame coding, it is necessary to select the optimal coding prediction mode from the multiple coding prediction modes to encode the current pixel block to be tested. Therefore, it is necessary to calculate the rate-distortion cost corresponding to the current pixel block to be tested in each coding prediction mode, so as to determine the optimal coding prediction mode for the current pixel block to be tested according to the rate-distortion cost corresponding to the current pixel block to be tested in each coding prediction mode. Based on this, after the electronic device calculates the rate-distortion cost of the current pixel block to be tested in the currently used coding prediction mode, it is necessary to detect whether the rate-distortion cost of the current pixel block to be tested is calculated in other coding prediction modes. That is, it is detected whether the corresponding rate-distortion cost of the current pixel block to be tested is calculated in all the preset coding prediction modes in each intra-frame coding mode. If, among at least two preset coding prediction modes, there is a current pixel block to be tested for which the corresponding rate-distortion cost has not been calculated in at least one coding prediction mode, it is necessary to determine a coding prediction mode in at least one coding prediction mode in which the corresponding rate-distortion cost has not been calculated, and determine the reconstructed pixel block corresponding to the current pixel block to be tested under the coding prediction mode, so as to calculate the rate-distortion cost under the coding prediction mode.
[0125] If the corresponding rate-distortion cost of the current pixel block to be tested is calculated under each of at least two coding prediction modes, it means that the rate-distortion cost corresponding to the current pixel block to be tested in all coding prediction modes has been obtained. At this time, the optimal coding prediction mode is determined according to the corresponding rate-distortion cost under each coding prediction mode, and it is determined as the target coding prediction mode of the current pixel block.
[0126] The electronic device performs different steps according to different determination results. When the corresponding rate-distortion cost is calculated for the current pixel block to be tested in each of the at least two preset coding prediction modes, steps S609a-S611 are performed. When the corresponding rate-distortion cost is not calculated for the current pixel block to be tested in at least one preset coding prediction mode, step S609b is performed.
[0127] S609a. If the corresponding rate-distortion cost is calculated for the current pixel block under each of the at least two preset coding prediction modes, the coding prediction mode in which the rate-distortion cost corresponding to the current pixel block under test is minimized is determined as the target coding prediction mode for the current pixel block under test.
[0128] In an embodiment of the present application, when the electronic device detects that the current pixel block to be tested calculates the corresponding rate-distortion cost in each of the at least two preset coding prediction modes, the electronic device can compare the rate-distortion costs to determine the minimum value of the rate-distortion cost, and then determine the coding prediction mode where the minimum value of the rate-distortion cost corresponding to the current pixel block to be tested is located. Under this coding prediction mode, the coding distortion of the current pixel block to be tested is the smallest and the coding rate is the highest, that is, for the current pixel block to be tested, the coding effect performance of the coding prediction mode where the corresponding rate-distortion cost is the smallest is the best, and at this time, the coding prediction mode where the rate-distortion cost corresponding to the current pixel block to be tested is the smallest can be determined as the target coding prediction mode.
[0129] Step S609b: If there is a current pixel block to be tested for which the corresponding rate-distortion cost has not been calculated under at least one preset coding prediction mode, then in at least one preset coding prediction mode for which the corresponding rate-distortion cost has not been calculated, select a preset coding prediction mode to update it as the current coding prediction mode, and re-execute the steps of determining the current pixel block to be tested in the current frame image, obtaining the reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode to the step of detecting whether the current pixel block to be tested has calculated the corresponding rate-distortion cost under each of the preset at least two coding prediction modes, until the current pixel block to be tested has calculated the corresponding rate-distortion cost under each of the preset at least two coding prediction modes.
[0130] In an embodiment of the present application, if the electronic device determines that there is a current pixel block to be tested for which the corresponding rate-distortion cost has not been calculated in at least one preset coding prediction mode, it means that the current pixel block to be tested has not calculated the corresponding rate-distortion cost in all preset coding prediction modes. At this time, it is necessary to calculate the rate-distortion cost of the current pixel block to be tested in the preset coding prediction mode for which the corresponding rate-distortion cost has not been calculated. Based on this, the electronic device can select a preset coding prediction mode from at least one preset coding prediction mode for which the corresponding rate-distortion cost has not been calculated, and update it to the current coding prediction mode, so as to re-execute the above steps S601-S609 using the current coding prediction mode, that is, to re-execute the formation of the reconstructed pixel block of the current pixel block to be tested and the acquisition of quantization information, and calculate the corresponding rate-distortion cost of the current pixel block to be tested in the current coding prediction mode using the reconstructed pixel block, the current pixel block to be tested and the quantization information. And re-detect whether the current pixel block to be tested has calculated the corresponding rate-distortion cost in each of the preset at least two coding prediction modes. If the corresponding rate-distortion cost of the current pixel block to be tested is not calculated in at least one preset coding prediction mode, a preset coding prediction mode is selected again from at least one preset coding prediction mode in which the corresponding rate-distortion cost is not calculated, and it is updated as the current coding prediction mode, and the above steps S601 to S609 are re-executed until it is detected that the corresponding rate-distortion cost of the current pixel block to be tested is calculated in each of the at least two preset coding prediction modes.
[0131] S610: Encode the current pixel block to be tested using a target coding prediction mode.
[0132] In the embodiment of the present application, after determining the target coding prediction mode of the current module to be tested, the electronic device may use the target coding prediction mode to perform coding processing on the pixel block to be tested.
[0133] See also Figure 7 , is a comparison diagram of a rate-distortion curve provided in an embodiment of the present application. Figure 7 2 is a comparison diagram between the rate-distortion curve obtained by the method of the present application and the rate-distortion curve obtained by quantizing, transforming, inversely quantizing and inversely transforming the prediction residual to obtain a reconstructed pixel block, and using the reconstructed pixel block to calculate the corresponding rate-distortion cost. Figure 7 It can be seen that the rate distortion curve obtained by the method of the present application is basically consistent with the rate distortion curve obtained by the conventional method in the prior art. Due to the method of the present application, there is no need to perform inverse transformation and inverse quantization, and the implementation method is simpler and less complex.
[0134] Step S611: When the current frame image is not the last uncoded frame image in the acquired multiple frame images, the next frame image of the current frame image is acquired, and the next frame image is updated to the current frame image, and the step of determining the current coding prediction mode in at least two preset coding prediction modes, and determining the current pixel block to be tested in the current frame image is re-executed, and the reference reconstructed pixel block corresponding to the current pixel block to be tested is obtained according to the current coding prediction mode, and the step of encoding the current pixel block to be tested using the target coding prediction mode is performed until the current frame image is the last uncoded frame image in the acquired multiple frame images.
[0135] In an embodiment of the present application, when acquiring multiple frames of images, each frame of image needs to be intra-coded. Therefore, after determining the target coding prediction mode for each pixel block in the current frame of image through the above steps and using the target coding prediction mode for coding, the next frame of image of the current frame of image in the acquired multiple frames of image can be intra-coded. At this time, the electronic device can detect whether the current frame of image is the last frame of image of the acquired multiple frames of image, for example, detect whether there is an uncoded image after the current frame of image, and if so, acquire the next frame of image. At this time, the electronic device can update the acquired next frame of image to the current frame of image, and re-execute the process of determining the target coding prediction mode of each pixel block in the current frame of image for the updated current frame of image, and when determining the target coding prediction mode of each pixel block, use the target coding prediction mode to perform corresponding coding processing on each pixel block. That is, after the electronic device updates the next frame of image to the current frame of image, it can re-execute the above steps S601-S610 until the current frame of image is the last uncoded image.
[0136] See also Figure 8 , is a schematic diagram of the structure of a device for determining an intra-frame coding mode provided by an embodiment of the present application. Figure 8 As shown, the device for determining the intra-frame coding mode includes:
[0137] The processing unit 801 is used to determine a current coding prediction mode among at least two preset coding prediction modes, determine a current pixel block to be tested in a current frame image, and obtain a reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode.
[0138] As a possible implementation method, the processing unit 801 is specifically used to determine, in the current frame image, in accordance with a preset order, a current pixel block to be tested from at least one pixel block to be tested for which a corresponding reconstructed pixel block has not been determined; and according to the current pixel block to be tested and the current coding prediction mode, determine, in the reconstructed pixel blocks, a reference reconstructed pixel block corresponding to the current pixel block to be tested under the current coding prediction mode.
[0139] The acquisition unit 802 is used to determine the predicted pixel block of the current pixel block to be tested according to the reference reconstructed pixel block, and acquire the prediction residual of the current pixel block to be tested according to the current pixel block to be tested and the predicted pixel block.
[0140] The processing unit 801 is further configured to perform transformation processing on the prediction residual of the current pixel block to be tested to obtain a transformation residual.
[0141] The calculation unit 803 is further configured to calculate a distortion value corresponding to the transformation residual according to the transformation residual and a preset distortion estimation algorithm.
[0142] The processing unit 801 is further configured to form a reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction residual, the distortion value corresponding to the transform residual and the prediction pixel block.
[0143] As a possible implementation method, the processing unit 801 is specifically used to calculate the residual reconstruction value corresponding to the prediction residual according to the distortion value corresponding to the prediction residual and the transformation residual; and form a reconstructed pixel block corresponding to the current pixel block to be tested according to the residual reconstruction value corresponding to the prediction residual and the prediction pixel block.
[0144] As a possible implementation manner, the processing unit 801 is further configured to perform quantization processing on the transformation residual to obtain quantization information of the current pixel block to be tested.
[0145] The processing unit 801 is further configured to calculate a rate-distortion cost corresponding to the current pixel block to be tested in the current coding prediction mode according to the current pixel block to be tested, the reconstructed pixel block corresponding to the current pixel block to be tested, and the quantization information.
[0146] See also Fig. 9 , is a schematic diagram of another device structure for determining an intra-frame coding mode provided in an embodiment of the present application. Fig. 9 As shown, the device also includes:
[0147] The detection unit 804 is used to detect whether the corresponding rate-distortion cost of the current pixel block to be detected is calculated in each of the at least two preset coding prediction modes.
[0148] The determination unit 805 is used to determine the coding prediction mode in which the rate-distortion cost corresponding to the current pixel block to be tested is minimized as the target coding prediction mode of the current pixel block to be tested if the corresponding rate-distortion cost is calculated for the current pixel block to be tested under each of at least two preset coding prediction modes.
[0149] The processing unit 801 is further configured to encode the current pixel block to be tested by adopting a target encoding prediction mode.
[0150] The processing unit 801 is also used to, if there is a current pixel block to be tested for which the corresponding rate-distortion cost has not been calculated in at least one preset coding prediction mode, select a preset coding prediction mode from at least one preset coding prediction mode for which the corresponding rate-distortion cost has not been calculated, update it as the current coding prediction mode, and re-execute in the current frame image, determine the current pixel block to be tested, obtain the reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode to trigger the detection unit 804 to detect whether the current pixel block to be tested has calculated the corresponding rate-distortion cost in each of the preset at least two coding prediction modes, until the current pixel block to be tested has calculated the corresponding rate-distortion cost in each of the preset at least two coding prediction modes.
[0151] The processing unit 801 is also used to obtain the next frame image of the current frame image when the current frame image is not the last uncoded frame image in the acquired multiple frame images, and update the next frame image to the current frame image, and re-execute the current coding prediction mode in the preset at least two coding prediction modes, and determine the current pixel block to be tested in the current frame image, obtain the reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode, and encode the current pixel block to be tested using the target coding prediction mode until the current frame image is the last uncoded frame image in the acquired multiple frame images.
[0152] Corresponding to the above embodiments, the present application also provides an electronic device. Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, the electronic device 1000 may include: a processor 1001, a memory 1002 and a communication unit 1003. These components communicate through one or more buses, and those skilled in the art can understand that the structure of the server shown in the figure does not constitute a limitation on the embodiment of the present invention, it can be a bus structure or a star structure, and can also include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0153] The communication unit 1003 is used to establish a communication channel so that the storage device can communicate with other devices, receive user data sent by other devices or send user data to other devices.
[0154] The processor 1001 is the control center of the storage device. It uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs and / or modules stored in the memory 1002, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 1001 can only include a central processing unit (CPU). In an embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.
[0155] The memory 1002 is used to store the execution instructions of the processor 1001. The memory 1002 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0156] When the execution instruction in the memory 1002 is executed by the processor 1001, the electronic device 1000 can execute Figure 6 Some or all of the steps in the illustrated embodiments.
[0157] In a specific implementation, the present invention further provides a computer storage medium, wherein the computer storage medium may store a program, and when the program is executed, the program may include some or all of the steps of each embodiment of the method for determining the intra-frame coding mode provided by the present invention. The storage medium may be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0158] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention or some parts of the embodiments.
[0159] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the device embodiment and the terminal embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.
Claims
1. A method for determining an intra-frame coding mode, characterized in that: include: For each pixel block, determining a reconstructed pixel block; Determining a target coding prediction mode according to the reconstructed pixel block; The step of determining the reconstructed pixel block for each pixel block includes: determining a current coding prediction mode in at least two preset coding prediction modes, determining a current pixel block to be tested in a current frame image, and obtaining a reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode; Determine a predicted pixel block of the current pixel block to be tested according to the reference reconstructed pixel block, and obtain a prediction residual of the current pixel block to be tested according to the current pixel block to be tested and the predicted pixel block; Performing transformation processing on the prediction residual of the current pixel block to be tested to obtain a transformation residual; Calculating a distortion value corresponding to the transform residual according to the transform residual and a preset distortion estimation algorithm; forming a reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction residual, the distortion value corresponding to the transform residual and the prediction pixel block; The forming of the reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction residual, the distortion value corresponding to the transformation residual and the prediction pixel block comprises: Calculating a residual reconstruction value corresponding to the prediction residual according to the prediction residual and the distortion value corresponding to the transformation residual; A reconstructed pixel block corresponding to the current pixel block to be tested is formed according to the residual reconstruction value corresponding to the prediction residual and the predicted pixel block.
2. The method according to claim 1, characterized in that: The step of determining a current pixel block to be tested in the current frame image and obtaining a reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode comprises: In the current frame image, according to a preset order, a current pixel block to be tested is determined from at least one pixel block to be tested for which a corresponding reconstructed pixel block has not been determined; According to the current pixel block to be tested and the current coding prediction mode, a reference reconstructed pixel block corresponding to the current pixel block to be tested under the current coding prediction mode is determined in the reconstructed pixel blocks.
3. The method according to claim 2, characterized in that Also includes: Quantizing the transformation residual to obtain quantization information of the current pixel block to be tested; A rate-distortion cost corresponding to the current pixel block to be tested in the current coding prediction mode is calculated according to the current pixel block to be tested, the reconstructed pixel block corresponding to the current pixel block to be tested, and the quantization information.
4. The method according to claim 3, characterized in that: Also includes: Detecting whether the current pixel block to be tested has a corresponding rate-distortion cost calculated in each of the at least two preset coding prediction modes; If the corresponding rate-distortion cost is calculated for the current pixel block to be tested in each of the at least two preset coding prediction modes, the coding prediction mode in which the rate-distortion cost corresponding to the current pixel block to be tested is minimized is determined as the target coding prediction mode of the current pixel block to be tested; The target coding prediction mode is used to encode the current pixel block to be tested.
5. The method according to claim 4, characterized in that Also includes: If there is a current pixel block to be tested for which the corresponding rate-distortion cost has not been calculated under at least one preset coding prediction mode, then in at least one preset coding prediction mode for which the corresponding rate-distortion cost has not been calculated, select a preset coding prediction mode to update it as the current coding prediction mode, and re-execute the steps of determining the current pixel block to be tested in the current frame image, obtaining the reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode, to step of detecting whether the current pixel block to be tested has calculated the corresponding rate-distortion cost under each of the at least two preset coding prediction modes, until the current pixel block to be tested has calculated the corresponding rate-distortion cost under each of the at least two preset coding prediction modes.
6. The method according to claim 1, characterized in that Also includes: When the current frame image is not the last uncoded frame image in the acquired multiple frame images, the next frame image of the current frame image is acquired, and the next frame image is updated to the current frame image, and the step of determining the current coding prediction mode in at least two preset coding prediction modes, and determining the current pixel block to be tested in the current frame image is re-executed, and a reference reconstructed pixel block corresponding to the current pixel block to be tested is obtained according to the current coding prediction mode, and the step of encoding the current pixel block to be tested using the target coding prediction mode is performed until the current frame image is the last uncoded frame image in the acquired multiple frame images.
7. A device for determining an intra-frame coding mode, characterized in that: include: A processing unit, configured to determine a reconstructed pixel block for each pixel block; Determining a target coding prediction mode according to the reconstructed pixel block; The step of determining the reconstructed pixel block for each pixel block includes: determining a current coding prediction mode in at least two preset coding prediction modes, determining a current pixel block to be tested in a current frame image, and obtaining a reference reconstructed pixel block corresponding to the current pixel block to be tested according to the current coding prediction mode; an acquisition unit, configured to determine a predicted pixel block of the current pixel block to be tested according to the reference reconstructed pixel block, and acquire a prediction residual of the current pixel block to be tested according to the current pixel block to be tested and the predicted pixel block; The processing unit is further used to perform transformation processing on the prediction residual of the current pixel block to be tested to obtain a transformation residual; A calculation unit, configured to calculate a distortion value corresponding to the transform residual according to the transform residual and a preset distortion estimation algorithm; The processing unit is further configured to form a reconstructed pixel block corresponding to the current pixel block to be tested according to the prediction residual, the distortion value corresponding to the transformation residual and the prediction pixel block; The processing unit is specifically configured to calculate a residual reconstruction value corresponding to the prediction residual according to the prediction residual and the distortion value corresponding to the transformation residual; A reconstructed pixel block corresponding to the current pixel block to be tested is formed according to the residual reconstruction value corresponding to the prediction residual and the predicted pixel block.
8. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores a computer program, and when the computer program is executed, the electronic device executes the method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Partition-based intra coding concept
CN111971959A
Method and device for improving rate distortion optimization calculation efficiency, equipment and storage medium
CN113347417A