Image coding method, device, equipment and storage medium
By acquiring image content complexity information to determine the quantization parameters of image encoding, the problem of inaccurate calculation of quantization parameters in the prior art is solved, and the image compression quality is improved.
Patent Information
- Application Number
- CN202111095305.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-17
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2041-09-17
AI Technical Summary
The prior art does not fully consider the image content when determining the quantization parameters (QP), resulting in inaccurate QP calculations and affecting the image compression quality.
By obtaining the content complexity information of the current image, including the complexity information of the starting image and the current macroblock, the content complexity value is determined, and the target quantization parameters of the current macroblock are determined based on the value.
The accuracy of the quantization parameters is improved, the quantization operation is more in line with the image content, and the overall quality of image encoding is improved.
Smart Images

Figure CN113784126B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image processing, and more specifically, to an image encoding method, apparatus, device and storage medium. Background Art
[0002] Digital video technology can be incorporated into a variety of video devices, such as digital televisions, smart phones, computers, e-readers or video players, etc. With the development of video technology, the amount of data included in video data is large. In order to facilitate the transmission of video data, video devices implement video compression technology to make video data more efficiently transmitted or stored.
[0003] Bit rate control is to optimize the objective quality of the video while ensuring that the number of bits occupied after video compression is certain. The size of the quantization parameter directly determines the compression degree of the video encoding unit, thereby controlling the bit rate and video quality after video encoding.
[0004] However, in the current process of determining a quantization parameter (QP), the influence of image content is not fully considered, resulting in inaccurate QP calculation and poor image compression quality. Summary of the invention
[0005] The embodiments of the present application provide an image encoding method, apparatus, device and storage medium to improve the accuracy of QP calculation and enhance the image compression quality.
[0006] In a first aspect, the present application provides an image encoding method, comprising:
[0007] Acquire content complexity information corresponding to a current image to be encoded, the content complexity information comprising at least one of complexity information of a starting image in video data where the current image is located and complexity information of a current macroblock in the current image;
[0008] Determining a content complexity value corresponding to the current image according to the content complexity information;
[0009] Determining a target quantization parameter of the current macroblock according to the content complexity value;
[0010] The current macroblock is encoded according to the target quantization parameter of the current macroblock.
[0011] In a second aspect, an embodiment of the present application provides an image processing device for executing the method in the first aspect or its respective implementations. Specifically, the image processing device includes a functional unit for executing the method in the first aspect or its respective implementations.
[0012] In a third aspect, a video encoder is provided, comprising a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the method in the first aspect or its implementations.
[0013] In a fourth aspect, a video coding and decoding system is provided, including a video encoder. The video encoder is used to execute the method in the first aspect or its implementation manners.
[0014] In a fifth aspect, a chip is provided for implementing the method in any one of the first to second aspects or in each of their implementations. Specifically, the chip includes: a processor for calling and running a computer program from a memory, so that a device equipped with the chip executes the method in the first aspect or in each of its implementations.
[0015] In a sixth aspect, a computer-readable storage medium is provided for storing a computer program, wherein the computer program enables a computer to execute the method in the above-mentioned first aspect or its various implementations.
[0016] In a seventh aspect, a computer program product is provided, comprising computer program instructions, which enable a computer to execute the method in the above-mentioned first aspect or its various implementations.
[0017] In an eighth aspect, a computer program is provided, which, when executed on a computer, enables the computer to execute the method in the first aspect or its various implementations.
[0018] Based on the above technical solution, by obtaining the complexity information of the starting image in the video data where the current image is located and at least one of the complexity information of the current macroblock in the current image, and according to at least one of the complexity information of the starting image and the complexity information of the current macroblock, the content complexity value corresponding to the current image is determined, and according to the content complexity value, the target quantization parameter of the current macroblock is determined, and finally according to the target quantization parameter of the current macroblock, the current macroblock is encoded. That is, when determining the target quantization parameter of the current macroblock, the present application takes into account the influence of the content complexity of the starting image and / or the current macroblock on the target QP of the current macroblock, thereby improving the accuracy of determining the QP of the current macroblock, making the quantization operation more in line with the image content, and improving the overall quality of image encoding. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A schematic block diagram of a video encoding and decoding system involved in an embodiment of the present application;
[0020] Figure 2 is a schematic block diagram of a video encoder provided in an embodiment of the present application;
[0021] Figure 3 is a schematic block diagram of a video decoder provided in an embodiment of the present application;
[0022] Figure 4 A schematic diagram of the framework of the X.264 rate control system involved in the embodiment of the present application;
[0023] Figure 5 A flowchart of an image encoding method provided by an embodiment of the present application;
[0024] Figure 6 A schematic diagram of a flow chart of an image encoding method provided in one embodiment of the present application;
[0025] Figure 7 A schematic diagram of X.264 encoding provided in an embodiment of the present application;
[0026] Figure 8 A schematic diagram of a flow chart of an image encoding method provided in one embodiment of the present application;
[0027] Fig. 9 A schematic diagram of X.264 encoding provided in an embodiment of the present application;
[0028] Fig.10 A schematic diagram of a flow chart of an image encoding method provided in one embodiment of the present application;
[0029] Fig.11 A schematic diagram of X.264 encoding provided in an embodiment of the present application;
[0030] Fig.12 It is a schematic diagram of the MB division method;
[0031] Fig.13 A schematic diagram of intra-frame mode selection involved in an embodiment of the present application;
[0032] Fig.14 A schematic diagram of inter-frame mode selection involved in an embodiment of the present application;
[0033] Fig.15 is a schematic block diagram of an image encoding device provided in an embodiment of the present application;
[0034] Fig.16 It is a schematic block diagram of the encoding device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The present application can be applied to the field of image coding and decoding, the field of video coding and decoding, the field of hardware video coding and decoding, the field of dedicated circuit video coding and decoding, the field of real-time video coding and decoding, etc. For example, the scheme of the present application can be combined with an audio and video coding standard (AVS), such as the H.264 / audio video coding (AVC) standard, the H.265 / high efficiency video coding (HEVC) standard, and the H.266 / versatile video coding (VVC) standard. Alternatively, the scheme of the present application can be combined with other proprietary or industry standards and operate, and the standards include ITU-TH.261, ISO / IECMPEG-1Visual, ITU-TH.262 or ISO / IECMPEG-2Visual, ITU-TH.263, ISO / IECMPEG-4Visual, ITU-TH.264 (also known as ISO / IECMPEG-4AVC), including scalable video coding (SVC) and multi-view video coding (MVC) extensions. It should be understood that the technology of the present application is not limited to any specific coding standard or technology.
[0036] To facilitate understanding, first combine Figure 1 The video encoding and decoding system involved in the embodiments of the present application is introduced.
[0037] Figure 1 This is a schematic block diagram of a video encoding and decoding system involved in an embodiment of the present application. It should be noted that: Figure 1 This is just an example. The video encoding and decoding system of the embodiment of the present application includes but is not limited to Figure 1 As shown. Figure 1 As shown, the video encoding and decoding system 100 includes an encoding device 110 and a decoding device 120. The encoding device is used to encode (which can be understood as compressing) video data to generate a code stream, and transmit the code stream to the decoding device. The decoding device decodes the code stream generated by the encoding device to obtain decoded video data.
[0038] The encoding device 110 of the embodiment of the present application can be understood as a device with a video encoding function, and the decoding device 120 can be understood as a device with a video decoding function, that is, the embodiment of the present application includes a wider range of devices for the encoding device 110 and the decoding device 120, such as smartphones, desktop computers, mobile computing devices, notebook (e.g., laptop) computers, tablet computers, set-top boxes, televisions, cameras, display devices, digital media players, video game consoles, vehicle-mounted computers, etc.
[0039] In some embodiments, the encoding device 110 may transmit the encoded video data (eg, a code stream) to the decoding device 120 via the channel 130. The channel 130 may include one or more media and / or devices capable of transmitting the encoded video data from the encoding device 110 to the decoding device 120.
[0040] In one example, the channel 130 includes one or more communication media that enable the encoding device 110 to transmit the encoded video data directly to the decoding device 120 in real time. In this example, the encoding device 110 can modulate the encoded video data according to the communication standard and transmit the modulated video data to the decoding device 120. The communication medium includes a wireless communication medium, such as a radio frequency spectrum, and optionally, the communication medium may also include a wired communication medium, such as one or more physical transmission lines.
[0041] In another example, the channel 130 includes a storage medium, which can store the video data encoded by the encoding device 110. The storage medium includes a variety of locally accessible data storage media, such as optical disks, DVDs, flash memories, etc. In this example, the decoding device 120 can obtain the encoded video data from the storage medium.
[0042] In another example, the channel 130 may include a storage server that can store the video data encoded by the encoding device 110. In this example, the decoding device 120 can download the stored encoded video data from the storage server. Alternatively, the storage server can store the encoded video data and transmit the encoded video data to the decoding device 120, such as a web server (e.g., for a website), a file transfer protocol (FTP) server, etc.
[0043] In some embodiments, the encoding device 110 includes a video encoder 112 and an output interface 113. The output interface 113 may include a modulator / demodulator (modem) and / or a transmitter.
[0044] In some embodiments, the encoding device 110 may further include a video source 111 in addition to the video encoder 112 and the input interface 113 .
[0045] The video source 111 may include at least one of a video acquisition device (eg, a video camera), a video archive, a video input interface, and a computer graphics system, wherein the video input interface is used to receive video data from a video content provider, and the computer graphics system is used to generate video data.
[0046] The video encoder 112 encodes the video data from the video source 111 to generate a code stream. The video data may include one or more pictures or a sequence of pictures. The code stream contains the coding information of the picture or the sequence of pictures in the form of a bit stream. The coding information may include the coded picture data and associated data. The associated data may include a sequence parameter set (SPS for short), a picture parameter set (PPS for short) and other syntax structures. The SPS may contain parameters applied to one or more sequences. The PPS may contain parameters applied to one or more pictures. The syntax structure refers to a set of zero or more syntax elements arranged in a specified order in the code stream.
[0047] The video encoder 112 transmits the encoded video data directly to the decoding device 120 via the output interface 113. The encoded video data may also be stored in a storage medium or a storage server for subsequent reading by the decoding device 120.
[0048] In some embodiments, the decoding device 120 includes an input interface 121 and a video decoder 122 .
[0049] In some embodiments, the decoding device 120 may include a display device 123 in addition to the input interface 121 and the video decoder 122 .
[0050] The input interface 121 includes a receiver and / or a modem. The input interface 121 can receive the encoded video data through the channel 130 .
[0051] The video decoder 122 is used to decode the encoded video data to obtain decoded video data, and transmit the decoded video data to the display device 123 .
[0052] The display device 123 displays the decoded video data. The display device 123 may be integrated with the decoding device 120 or external to the decoding device 120. The display device 123 may include a variety of display devices, such as a liquid crystal display (LCD), a plasma display, an organic light emitting diode (OLED) display, or other types of display devices.
[0053] also, Figure 1 This is only an example, and the technical solution of the embodiment of the present application is not limited to Figure 1 For example, the technology of the present application can also be applied to single-sided video encoding or single-sided video decoding.
[0054] The video encoder involved in the embodiments of the present application is introduced below.
[0055] Figure 2 2 is a schematic block diagram of a video encoder provided in an embodiment of the present application. It should be understood that the video encoder 200 can be used to perform lossy compression on an image, or can be used to perform lossless compression on an image. The lossless compression can be visually lossless compression or mathematically lossless compression.
[0056] The video encoder 200 can be applied to image data in luminance and chrominance (YCbCr, YUV) format. For example, the YUV ratio can be 4:2:0, 4:2:2 or 4:4:4, Y represents brightness (Luma), Cb (U) represents blue chrominance, Cr (V) represents red chrominance, and U and V represent chrominance (Chroma) for describing color and saturation. For example, in color format, 4:2:0 means that every 4 pixels have 4 luminance components and 2 chrominance components (YYYYCbCr), 4:2:2 means that every 4 pixels have 4 luminance components and 4 chrominance components (YYYYCbCrCbCr), and 4:4:4 means full pixel display (YYYYCbCrCbCrCbCrCbCr).
[0057] For example, the video encoder 200 reads video data, and for each frame of the video data, divides a frame of the image into a number of coding tree units (CTU), "largest coding unit" (LCU for short) or "coding tree block" (CTB for short). Each CTU can be associated with a pixel block of equal size in the image. Each pixel can correspond to a luminance (luminance or luma) sample and two chrominance (chrominance or chroma) samples. Therefore, each CTU can be associated with a luminance sampling block and two chrominance sampling blocks. The size of a CTU is, for example, 128×128, 64×64, 32×32, etc. A CTU can be further divided into a number of coding units (CU) for encoding, and the CU can be a rectangular block or a square block. The CU can be further divided into a prediction unit (PU for short) and a transform unit (TU for short), thereby separating the encoding, prediction, and transformation, and making the processing more flexible. In an example, a CTU is divided into CUs in a quadtree manner, and a CU is divided into TUs and PUs in a quadtree manner.
[0058] The video encoder and video decoder may support various PU sizes. Assuming that the size of a particular CU is 2N×2N, the video encoder and video decoder may support PU sizes of 2N×2N or N×N for intra-frame prediction, and support symmetric PUs of 2N×2N, 2N×N, N×2N, N×N or similar sizes for inter-frame prediction. The video encoder and video decoder may also support asymmetric PUs of 2N×nU, 2N×nD, nL×2N, and nR×2N for inter-frame prediction.
[0059] In some embodiments, Figure 2 As shown, the video encoder 200 may include: a prediction unit 210, a residual unit 220, a transform / quantization unit 230, an inverse transform / quantization unit 240, a reconstruction unit 250, a loop filter unit 260, a decoded image buffer 270, and an entropy coding unit 280. It should be noted that the video encoder 200 may include more, fewer, or different functional components.
[0060] Optionally, in the present application, the current block may be referred to as a current coding unit (CU) or a current prediction unit (PU), etc. A prediction block may also be referred to as a predicted block to be coded or an image prediction block, and a reconstructed block to be coded may also be referred to as a reconstructed block or an image reconstructed block to be coded.
[0061] In some embodiments, the prediction unit 210 includes an inter-frame prediction unit 211 and an intra-frame estimation unit 212. Since there is a strong correlation between adjacent pixels in a frame of a video, an intra-frame prediction method is used in the video coding and decoding technology to eliminate spatial redundancy between adjacent pixels. Since there is a strong similarity between adjacent frames in a video, an inter-frame prediction method is used in the video coding and decoding technology to eliminate temporal redundancy between adjacent frames, thereby improving coding efficiency.
[0062] The inter-frame prediction unit 211 can be used for inter-frame prediction. Inter-frame prediction can refer to the image information of different frames. Inter-frame prediction uses motion information to find reference blocks from reference frames, and generates prediction blocks based on the reference blocks to eliminate temporal redundancy. The frames used for inter-frame prediction can be P frames and / or B frames. P frames refer to forward prediction frames, and B frames refer to bidirectional prediction frames. Motion information includes a reference frame list where the reference frame is located, a reference frame index, and a motion vector. The motion vector can be an integer pixel or a sub-pixel. If the motion vector is a sub-pixel, it is necessary to use interpolation filtering in the reference frame to make the required sub-pixel block. Here, the integer pixel or sub-pixel block in the reference frame found according to the motion vector is called a reference block. Some technologies will directly use the reference block as a prediction block, and some technologies will generate a prediction block based on the reference block. Reprocessing the reference block to generate a prediction block can also be understood as using the reference block as a prediction block and then processing the prediction block to generate a new prediction block.
[0063] The most commonly used inter-frame prediction methods currently include: geometric partitioning mode (GPM) in the VVC video codec standard, and angular weighted prediction (AWP) in the AVS3 video codec standard. These two intra-frame prediction modes have something in common in principle. The inter-frame modes involved in this application include but are not limited to the inter-frame modes listed above.
[0064] The intra-frame estimation unit 212 only refers to the information of the same frame image to predict the pixel information in the block to be encoded in the current frame to eliminate spatial redundancy. The frame used for intra-frame prediction can be an I frame.
[0065] In some embodiments, the intra prediction method further includes a multiple reference line (MRL) intra prediction method. MRL can use more reference pixels to improve coding efficiency.
[0066] There are multiple prediction modes for intra-frame prediction. H.264 has 9 modes for intra-frame prediction of 4×4 blocks. Mode 0 is to copy the pixels above the current block vertically to the current block as the prediction value; Mode 1 is to copy the reference pixels on the left horizontally to the current block as the prediction value; Mode 2 (DC) is to use the average value of the 8 points A~D and I~L as the prediction value of all points, and Modes 3 to 8 are to copy the reference pixels to the corresponding positions of the current block at a certain angle. Because some positions of the current block cannot correspond exactly to the reference pixels, it may be necessary to use the weighted average of the reference pixels, or the sub-pixels of the interpolated reference pixels.
[0067] The intra-frame prediction modes used by HEVC are Planar, DC, and 33 angle modes, for a total of 35 prediction modes. The intra-frame modes used by VVC are Planar, DC, and 65 angle modes, for a total of 67 prediction modes. The intra-frame modes used by AVS3 are DC, Plane, Bilinear, and 63 angle modes, for a total of 66 prediction modes.
[0068] It should be noted that with the increase of angle modes, intra-frame prediction will be more accurate and more in line with the needs of the development of high-definition and ultra-high-definition digital videos.
[0069] The residual unit 220 may generate a residual block of the CU based on the pixel blocks of the CU and the prediction blocks of the PUs of the CU. For example, the residual unit 220 may generate a residual block of the CU so that each sample in the residual block has a value equal to the difference between the following two: a sample in the pixel blocks of the CU and a corresponding sample in the prediction blocks of the PUs of the CU.
[0070] The transform / quantization unit 230 may quantize the transform coefficients. The transform / quantization unit 230 may quantize the transform coefficients associated with the TUs of the CU based on a quantization parameter (QP) value associated with the CU. The video encoder 200 may adjust the degree of quantization applied to the transform coefficients associated with the CU by adjusting the QP value associated with the CU.
[0071] The inverse transform / quantization unit 240 may apply inverse quantization and inverse transform to the quantized transform coefficients, respectively, to reconstruct a residual block from the quantized transform coefficients.
[0072] The reconstruction unit 250 may add the samples of the reconstructed residual block to the corresponding samples of one or more prediction blocks generated by the prediction unit 210 to generate a reconstructed block to be encoded associated with the TU. By reconstructing the sample blocks of each TU of the CU in this manner, the video encoder 200 may reconstruct the pixel blocks of the CU.
[0073] Loop filtering unit 260 may perform a deblocking filtering operation to reduce blocking effects of pixel blocks associated with a CU.
[0074] In some embodiments, the loop filtering unit 260 includes a deblocking filtering unit, a sample adaptive offset SAO unit, and an adaptive loop filtering ALF unit.
[0075] The decoded image buffer 270 may store the reconstructed pixel blocks. The inter prediction unit 211 may use the reference image containing the reconstructed pixel blocks to perform inter prediction on PUs of other images. In addition, the intra estimation unit 212 may use the reconstructed pixel blocks in the decoded image buffer 270 to perform intra prediction on other PUs in the same image as the CU.
[0076] The entropy encoding unit 280 may receive the quantized transform coefficients from the transform / quantization unit 230. The entropy encoding unit 280 may perform one or more entropy encoding operations on the quantized transform coefficients to generate entropy-encoded data.
[0077] The basic process of video encoding involved in the present application is as follows: at the encoding end, the current image is divided into blocks, and for the current block, the prediction unit 210 uses intra-frame prediction or inter-frame prediction to generate a prediction block of the current block. The residual unit 220 can calculate the residual block based on the original block of the prediction block and the current block, that is, the difference between the original block of the prediction block and the current block, and the residual block can also be called residual information. The residual block can remove information that is not sensitive to the human eye through the transformation and quantization process of the transformation / quantization unit 230 to eliminate visual redundancy. Optionally, the residual block before transformation and quantization by the transformation / quantization unit 230 can be called a time domain residual block, and the time domain residual block after transformation and quantization by the transformation / quantization unit 230 can be called a frequency residual block or a frequency domain residual block. The entropy coding unit 280 receives the quantized transform coefficient output by the transformation and quantization unit 230, and can entropy encode the quantized transform coefficient and output a code stream. For example, the entropy coding unit 280 can eliminate character redundancy according to the target context model and the probability information of the binary code stream.
[0078] In addition, the video encoder performs inverse quantization and inverse transformation on the quantized transform coefficients output by the transform quantization unit 230 to obtain a residual block of the current block, and then adds the residual block of the current block to the prediction block of the current block to obtain a reconstructed block of the current block. As the encoding proceeds, reconstructed blocks corresponding to other blocks to be encoded in the current image can be obtained, and these reconstructed blocks are spliced to obtain a reconstructed image of the current image. Since errors are introduced during the encoding process, in order to reduce the errors, the reconstructed image is filtered, for example, the reconstructed image is filtered using ALF to reduce the difference between the pixel values of the pixels in the reconstructed image and the original pixel values of the pixels in the current image. The filtered reconstructed image is stored in the decoded image cache 270, and can be used as a reference frame for inter-frame prediction for subsequent frames.
[0079] It should be noted that the block division information determined by the encoder, as well as the mode information or parameter information such as prediction, transformation, quantization, entropy coding, loop filtering, etc., are carried in the bitstream when necessary. The decoder parses the bitstream and determines the same block division information, prediction, transformation, quantization, entropy coding, loop filtering, etc. mode information or parameter information as the encoder by analyzing the existing information, thereby ensuring that the decoded image obtained by the encoder is the same as the decoded image obtained by the decoder.
[0080] Figure 3 It is a schematic block diagram of a video decoder provided in an embodiment of the present application.
[0081] like Figure 3As shown, the video decoder 300 includes an entropy decoding unit 310, a prediction unit 320, an inverse quantization / transformation unit 330, a reconstruction unit 340, a loop filter unit 350, and a decoded image buffer 360. It should be noted that the video decoder 300 may include more, fewer, or different functional components.
[0082] The video decoder 300 may receive a bitstream. The entropy decoding unit 310 may parse the bitstream to extract syntax elements from the bitstream. As part of parsing the bitstream, the entropy decoding unit 310 may parse the syntax elements in the bitstream that have been entropy encoded. The prediction unit 320, the inverse quantization / transformation unit 330, the reconstruction unit 340, and the loop filter unit 350 may decode the video data according to the syntax elements extracted from the bitstream, that is, generate decoded video data.
[0083] In some embodiments, the prediction unit 320 includes an intra-frame estimation unit 321 and an inter-frame prediction unit 322 .
[0084] The intra estimation unit 321 may perform intra prediction to generate a prediction block of a PU. The intra estimation unit 321 may use an intra prediction mode to generate a prediction block of a PU based on pixel blocks of spatially neighboring PUs. The intra estimation unit 321 may also determine an intra prediction mode of a PU according to one or more syntax elements parsed from a code stream.
[0085] The inter prediction unit 322 may construct a first reference image list (list 0) and a second reference image list (list 1) according to the syntax elements parsed from the code stream. In addition, if the PU is encoded using inter prediction, the entropy decoding unit 310 may parse the motion information of the PU. The inter prediction unit 322 may determine one or more reference blocks of the PU according to the motion information of the PU. The inter prediction unit 322 may generate a prediction block of the PU according to the one or more reference blocks of the PU.
[0086] The inverse quantization / transform unit 330 may inversely quantize (ie, dequantize) the transform coefficients associated with the TU. The inverse quantization / transform unit 330 may use the QP value associated with the CU of the TU to determine the degree of quantization.
[0087] After inverse quantizing the transform coefficients, the inverse quantization / transform unit 330 may apply one or more inverse transforms to the inverse quantized transform coefficients in order to generate a residual block associated with the TU.
[0088] The reconstruction unit 340 uses the residual block associated with the TU of the CU and the prediction block of the PU of the CU to reconstruct the pixel block of the CU. For example, the reconstruction unit 340 may add samples of the residual block to corresponding samples of the prediction block to reconstruct the pixel block of the CU to obtain a reconstructed block to be encoded.
[0089] The loop filtering unit 350 may perform a deblocking filtering operation to reduce blocking effects of pixel blocks associated with a CU.
[0090] In some embodiments, the loop filtering unit 350 includes a deblocking filtering unit, a sample adaptive offset SAO unit, and an adaptive loop filtering ALF unit.
[0091] The video decoder 300 may store the reconstructed image of the CU in the decoded image buffer 360. The video decoder 300 may use the reconstructed image in the decoded image buffer 360 as a reference image for subsequent prediction, or transmit the reconstructed image to a display device for presentation.
[0092] The basic process of video decoding involved in this application is as follows: the entropy decoding unit 310 can parse the code stream to obtain the prediction information, quantization coefficient matrix, etc. of the current block, and the prediction unit 320 uses intra-frame prediction or inter-frame prediction for the current block based on the prediction information to generate a prediction block of the current block. The inverse quantization / transformation unit 330 uses the quantization coefficient matrix obtained from the code stream to inverse quantize and inverse transform the quantization coefficient matrix to obtain a residual block. The reconstruction unit 340 adds the prediction block and the residual block to obtain a reconstructed block. The reconstructed blocks constitute a reconstructed image, and the loop filtering unit 350 performs loop filtering on the reconstructed image based on the image or on the block to obtain a decoded image. The decoded image can also be called a reconstructed image. On the one hand, the reconstructed image can be displayed by a display device, and on the other hand, it can be stored in the decoded image cache 360 as a reference frame for inter-frame prediction for subsequent frames.
[0093] The above is the basic process of the video codec under the block-based hybrid coding framework. With the development of technology, some modules or steps of the framework or process may be optimized. The present application is applicable to the basic process of the video codec under the block-based hybrid coding framework, but is not limited to the framework and process.
[0094] Figure 4 The schematic diagram of the framework of the X.264 encoding system involved in the embodiment of the present application is shown in FIG. X.264 is one of the most widely used software encoders at present, and can provide a high compression rate and high-quality video quality for standard definition and high definition videos.
[0095] The X.264 rate control process is divided into the inter-frame rate control process and the macroblock rate control process. The allocation of QP values for each frame is achieved by the inter-frame rate control, while the allocation of QP values within each frame is achieved by the macroblock rate control. The X.264 rate control process mainly depends on two variables, one is the complexity of the video frame, and the other is the bit rate budget. Generally, the higher the complexity of the video frame, the more bits are required for encoding. Figure 4 As shown, after the video to be encoded enters the encoding system, it will synchronously enter the inter-frame level rate control process and the macroblock level rate control process.
[0096] The forward feedback module 400 is used to provide a video frame buffer queue for the video to be encoded, so as to assist in achieving more stable bit rate control.
[0097] The complexity estimation module 401 is used to estimate the complexity of the current frame in the video to be encoded.
[0098] The rate factor calculation module 402 is used to calculate the complexity accumulation value of the current frame according to the feedback bit rate of the encoded frame, and then calculate the rate factor according to the complexity accumulation value.
[0099] The quantization level calculation module 403 is used to calculate the quantization level according to the complexity of the current frame output by the complexity estimation module 401, obtain the quantization ratio corresponding to the current frame, and adjust the quantization ratio according to the rate factor (ratefactor) provided by the rate factor calculation module 402 to obtain the initial quantization level.
[0100] The buffer control (VBV) module 404 adjusts the initial quantization level of the current frame output by the quantization level calculation module 403 based on the size of the buffer area at the receiving end to obtain the quantization level of the current frame.
[0101] The quantization level conversion QP module 405 is used to convert the quantization level output by the buffer control (VBV) module 404 into an initial quantization parameter, and provide it to the macroblock level quantization parameter adjustment module 406 .
[0102] The macroblock tree (MBTree) partitioning module 408 is used to calculate the macroblock structure (MBTree) of the current frame according to the image content of the current frame.
[0103] The adaptive quantization module 407 is used to calculate the average macroblock energy of the current frame according to the macroblock structure and image content of the current frame, and determine the quantization strength factor corresponding to the average macroblock energy.
[0104] The macroblock-level quantization step size adjustment 406 is used to adjust the initial quantization step size of the current frame according to the quantization strength factor to obtain a quantization parameter corresponding to the current frame.
[0105] The quantization and entropy coding module 409 is used to encode the current frame according to the quantization parameter corresponding to the current frame, and continue the above process until all frames in the video to be encoded are encoded, and then output the encoded code stream.
[0106] Depend on Figure 4It can be seen that the inter-frame rate control process includes: providing a video frame buffer queue for the video to be encoded through the forward feedback module 410 to assist in completing a more stable rate control, and then estimating the complexity of the current frame in the video to be encoded through the complexity estimation module 401. For example, the complexity of the current frame can be fuzzy complexity. The rate factor calculation module 402 is used to calculate the complexity accumulation value of the current frame according to the feedback of the encoded frame rate, and then calculate the rate factor (ratefactor) according to the complexity accumulation value. The quantization level calculation module 403 calculates the quantization level according to the complexity of the current frame output by the complexity estimation module 401, obtains the quantization ratio (i.e., quantization level) corresponding to the current frame, and adjusts the quantization ratio according to the rate factor (ratefactor) provided by the rate factor calculation module 402 to obtain the initial quantization level. The cache control (VBV) module 404 further adjusts the initial quantization level based on the size of the receiving end buffer area to obtain the quantization level. The quantization level to QP module 405 converts the quantization level into an initial quantization parameter and provides it to the macroblock level quantization parameter adjustment module 406 .
[0107] The macroblock-level bit rate control process includes: first, the macroblock tree division module 408 calculates the macroblock structure (MBTree) of the current frame according to the image content of the current frame; then, the adaptive quantization module 407 calculates the average macroblock energy of the current frame according to the macroblock structure and image content of the current frame, and determines the quantization strength factor corresponding to the average macroblock energy; the macroblock-level quantization parameter adjustment module 406 adjusts the initial quantization parameter of the current frame according to the quantization strength factor to obtain the quantization parameter corresponding to the current frame. Finally, the quantization and entropy coding module 409 encodes the current frame according to the quantization parameter corresponding to the current frame, and the above process continues until all frames in the video to be encoded are encoded, and the encoded bit stream is output.
[0108] By the above Figure 4 It can be seen that during the QP setting and adjustment process of the X.264 coding framework, the adaptive ability to the video content is weak, and the influence of the complexity of the starting frame and / or the complexity of the current macroblock on the QP is not considered, which makes the QP of the macroblock inaccurately determined, resulting in poor overall quality of the encoded image.
[0109] In order to solve the above technical problems, the embodiment of the present application determines the content complexity value through the complexity information of the starting image and / or the complexity information of the current macroblock, and determines the target QP of the current macroblock according to the content complexity value. That is, in the embodiment of the present application, when determining the target QP of the current macroblock, the influence of the content complexity of the starting image and / or the current macroblock on the target QP of the current macroblock is taken into account, thereby achieving accurate determination of the QP of the current macroblock, making the quantization operation more consistent with the image content, and improving the overall quality of image encoding.
[0110] The technical solutions of the embodiments of the present application are described in detail below through some embodiments. The following embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0111] Figure 5 This is a flow chart of an image encoding method provided by an embodiment of the present application. This application mainly relates to the steps of determining the quantization parameter in the image encoding process, and the execution subject can be the above Figure 1 and Figure 2 The encoding device in Figure 5 As shown, the method of the embodiment of the present application includes:
[0112] S501. Obtain content complexity information corresponding to a current image to be encoded, where the content complexity information includes at least one of complexity information of a starting image in video data where the current image is located and complexity information of a current macroblock in the current image.
[0113] The video data to be encoded in the present application includes multiple continuous images, each of which can be divided into at least one macroblock. A macroblock represents an nXn image area, such as a 16X16 image area, and the macroblock includes a luminance component and a chrominance component. A macroblock can be divided into at least one coding unit, and the QP of the coding units in the same macroblock can be the same, that is, the quantization parameter of the macroblock. During encoding, the residual block of the coding unit is determined, and the residual block is transformed to obtain a transform coefficient. The transform coefficient is quantized using the determined QP and then encoded to obtain a bit stream.
[0114] The present application mainly relates to the process of determining QP in the above encoding process.
[0115] The current image can be understood as an image in the video data that is in a coded state. The current image can be the first image in the video data, that is, the starting image, or any image in the video data except the starting image.
[0116] The current image can be divided into a plurality of macroblocks, and the current macroblock can be understood as a macroblock in the current image that is in an encoding state.
[0117] In some embodiments, the starting image, as a key image for video encoding, has a significant impact on the overall quality of the video. Therefore, in order to improve the calculation accuracy of QP, the present application considers the impact of the complexity of the starting image on QP when calculating QP, thereby improving the calculation accuracy of QP.
[0118] This embodiment does not limit the specific content of the complexity information of the starting image.
[0119] In one example, YUV data, as the input part of video encoding, covers all the information of uncompressed video. Therefore, directly using YUV data as the representation of the complexity information of video content is a simple and effective method. Therefore, the YUV data of the starting image can be used as the complexity information of the starting image.
[0120] In another example, the Y component in the YUV data represents the brightness information of the video, can reflect the basic texture information, and can reflect the complexity of the video content. Therefore, the Y component in the YUV data of the starting image can be used as the complexity information of the starting image.
[0121] In another example, the complexity information of the starting image includes at least one of the amount of coding information of macroblocks included in the starting image, the coding bit depth, and the number of macroblocks included in the starting image.
[0122] The amount of coding information of a macroblock is the sum of squared MB errors generated in the X.264 coding process, reflecting the complexity of the coding unit.
[0123] In some embodiments, the complexity information of the current macroblock has an impact on the adjustment process of the QP of the current macroblock. Therefore, in the adjustment process of the QP, the complexity information of the current macroblock is considered to improve the adjustment accuracy of the QP.
[0124] This embodiment does not limit the specific content of the complexity information of the current macroblock.
[0125] In one example, the YUV data of the current macroblock is used as the complexity information of the current macroblock.
[0126] In another example, the Y component in the YUV data of the current macroblock is used as the complexity information of the current macroblock.
[0127] In another example, the complexity information of the current macroblock includes the amount of encoding information of the current macroblock.
[0128] S502: Determine a content complexity value according to the content complexity information.
[0129] The content complexity information of the present application includes at least one of the complexity information of the starting image in the video data where the current image is located and the complexity information of the current macroblock in the current image. Therefore, in the above S502, the content complexity value is determined according to the content complexity information, including the following ways:
[0130] Method 1: if the content complexity information includes complexity information of the starting image, the complexity value of the starting image is determined according to the complexity information of the starting image, and the complexity value of the starting image is determined as the content complexity value.
[0131] For example, if the complexity information of the starting image includes YUV data, the size of the YUV data is used to determine the complexity value of the starting image, and the complexity value of the starting image is determined as the content complexity value corresponding to the current image. Figure 7 The embodiment shown.
[0132] In the first approach, the content complexity value corresponding to the current image includes the complexity value of the starting image.
[0133] Mode 2: If the content complexity information includes the complexity information of the current macroblock, the complexity value of the current macroblock is determined according to the complexity information of the current macroblock, and the complexity value of the current macroblock is determined as the content complexity value.
[0134] For example, if the complexity information of the current macroblock includes YUV data, the size of the YUV data is used to determine the complexity value of the current macroblock, and the complexity value of the current macroblock is determined as the content complexity value corresponding to the current image. Fig. 9 The embodiment shown.
[0135] In the second method, the content complexity value corresponding to the current image includes the complexity value of the current macroblock.
[0136] Method three, if the content complexity information includes the complexity information of the starting image and the complexity information of the current macroblock, then the complexity value of the starting image is determined according to the complexity information of the starting image, and the complexity value of the current macroblock is determined according to the complexity information of the current macroblock, and the complexity value of the starting image and the complexity value of the current macroblock are determined as the content complexity value.
[0137] In the third method, the content complexity value corresponding to the current image includes the complexity value of the starting image and the complexity value of the current macroblock.
[0138] S503: Determine a target quantization parameter of the current macroblock according to the content complexity value.
[0139] The content complexity value of the embodiment of the present application includes at least one of the complexity value of the starting image and the complexity value of the current macroblock. According to different contents included in the content complexity value, the target quantization parameter of the current macroblock is determined according to the content complexity value in S503, including at least the following situations:
[0140] Case 1: if the content complexity value includes the complexity value of the starting image, the initial quantization parameter of the current macroblock is determined according to the complexity value of the starting image, and the target quantization parameter of the current macroblock is determined according to the initial quantization parameter.
[0141] Case 2: If the content complexity value includes the complexity value of the current macroblock, the initial quantization parameter of the current macroblock is determined according to the complexity value of the current image, and the initial quantization parameter of the current macroblock is adjusted according to the complexity value of the current macroblock to obtain the target quantization parameter of the current macroblock.
[0142] Case 3: If the content complexity value includes the complexity value of the starting image and the complexity value of the current macroblock, the initial quantization parameter of the current macroblock is determined according to the complexity value of the starting image, and the initial quantization parameter of the current macroblock is adjusted according to the complexity value of the current macroblock to obtain the target quantization parameter of the current macroblock.
[0143] S504: Encode the current macroblock according to the target quantization parameter of the current macroblock.
[0144] Specifically, a prediction mode is selected, a prediction is performed on the current macroblock to obtain a prediction block of the current macroblock, the current macroblock is subtracted from the prediction value to obtain a residual block of the current macroblock, and the residual block of the current macroblock is transformed to obtain a transformation coefficient of the current macroblock. The transformation coefficient of the current macroblock is quantized using the target quantization parameter of the current macroblock determined above to obtain a quantized transformation coefficient of the current macroblock, and finally the quantized transformation coefficient of the current macroblock is encoded to obtain a bitstream.
[0145] The image encoding method provided by the embodiment of the present application obtains at least one of the complexity information of the starting image in the video data where the current image is located and the complexity information of the current macroblock in the current image, and determines the content complexity value corresponding to the current image according to at least one of the complexity information of the starting image and the complexity information of the current macroblock, determines the target quantization parameter of the current macroblock according to the content complexity value, and finally encodes the current macroblock according to the target quantization parameter of the current macroblock. That is, when determining the target quantization parameter of the current macroblock, the present application takes into account the influence of the content complexity of the starting image and / or the current macroblock on the target QP of the current macroblock, thereby improving the accuracy of determining the QP of the current macroblock, making the quantization operation more consistent with the image content, and improving the overall quality of image encoding.
[0146] Combine the following Figure 6 and Figure 7 When the content complexity information includes the complexity information of the starting image, the encoding process of the embodiment of the present application is introduced.
[0147] Figure 6 A flowchart of an image encoding method provided by an embodiment of the present application is shown in FIG. Figure 6 As shown, including:
[0148] S601: Obtain complexity information of a starting image.
[0149] The implementation process of the above S601 is specifically referred to the description of the above S501, which will not be repeated here.
[0150] At this time, the above S502 includes the following step S602.
[0151] S602: Determine a complexity value of the starting image according to complexity information of the starting image.
[0152] In this embodiment, according to the complexity information of the starting image, the methods for determining the complexity value of the starting image include but are not limited to the following methods:
[0153] Method 1: If the complexity information of the starting image is the YUV data of the starting image, the complexity value of the starting image is determined according to the size of the YUV data of the starting image. For example, the sum of the YUV sizes corresponding to each pixel in the starting image is determined as the complexity value of the starting image.
[0154] Method 2: If the complexity information of the starting image is the Y component in the YUV data of the starting image, the complexity value of the starting image is determined according to the size of the Y component of the starting image. For example, the sum of the sizes of the Y components corresponding to each pixel in the starting image is determined as the complexity value of the starting image.
[0155] Method three, if the complexity information of the starting image includes the amount of coding information of the macroblocks included in the starting image, the coding bit depth and the number of macroblocks included in the starting image, then calculate the product of the amount of coding information and the coding bit depth of the macroblocks in the starting image, add the product to the first preset value to obtain the sum, use the second preset value as the exponent, perform exponential operation on the sum, and obtain the first operation result corresponding to the macroblock; calculate the sum of the first operation results corresponding to the macroblocks in the starting image, and determine the ratio of the sum to the number of macroblocks included in the starting image as the complexity value of the starting image.
[0156] In the third method, for each macroblock in the starting image, the amount of coding information of the macroblock is obtained, the product of the amount of coding information of the macroblock and the coding bit depth used for coding is calculated, and the product is added to the first preset value to obtain a sum value. Then, the sum value is exponentially operated with the second preset value as the exponent to obtain the first operation result corresponding to the macroblock. After adding the first operation results of each macroblock in the starting image, it is divided by the number of macroblocks included in the starting image to obtain a ratio, and the ratio is determined as the complexity value of the starting image.
[0157] In one example, the complexity value of the starting image is determined according to the following formula (1):
[0158]
[0159] Among them, i_frame_0_energy represents the complexity value of the starting image, i_mb_energy(x) represents the amount of coding information of the macroblocks included in the starting image, bit_depth represents the coding bit depth, and i_mb_count represents the number of macroblocks included in the starting image.
[0160] Correspondingly, the above S503 includes the following steps S603 to S606.
[0161] S603: Determine a first complexity value of the current image according to the complexity value of the starting image.
[0162] In this step, according to whether the current image is the starting image, the above S603 includes the following cases 11 and 12:
[0163] Case 11: If the current image is the starting image, the first complexity value of the current image is determined according to the complexity value of the starting image. Specifically, the first complexity value of the current image is determined according to the complexity value of the starting image, including but not limited to the following methods:
[0164] Method 1: if the complexity value of the starting image is less than the first value, then determining the first complexity value of the current image as the first preset complexity value.
[0165] In the first approach, there is no restriction on specific values of the first numerical value and the first preset complexity value.
[0166] Optionally, the first value is 2.505.
[0167] Optionally, the first preset complexity value is 1000000.
[0168] Method 2: If the complexity value of the starting image is greater than or equal to the second value, the product of the complexity value of the starting image and the third value is determined as the first complexity value of the current image.
[0169] In the second method, there is no restriction on the specific values of the second value and the third value.
[0170] Optionally, the second value is 4.45.
[0171] Method three: if the complexity value of the starting image is greater than or equal to the first value and less than the second value, the product of the complexity value of the starting image and the fourth value is determined as the first complexity value of the current image.
[0172] In the second method, there is no restriction on the specific value of the fourth value.
[0173] The calculation methods of the above methods 1 to 3 are obtained by statistically analyzing the complexity information of the historical starting images. If the current image is the starting image, the first complexity value of the current image is determined in segments according to the above method, so as to accurately calculate the first complexity value of the current image.
[0174] If the current image is not the starting image, the first complexity value of the current image is determined according to situation 12.
[0175] Case 12: If the current image is not the starting image, S503-A1 includes determining the satd of the current image. According to the complexity value of the starting image and the satd of the current image, a first complexity value of the current image is determined.
[0176] Among them, satd is the sum of absolute values of residuals after motion compensation. The satd of the first frame is a preset value. The satd of non-first frames can be calculated according to the time-frequency transformation method to reflect the size of the generated code stream.
[0177] In the above situation 12, the implementation methods of determining the first complexity value of the current image according to the complexity value of the starting image and the satd of the current image include but are not limited to the following:
[0178] Method 1: According to a preset rule, the complexity value of the starting image and the satd of the current image are calculated, and the calculation result is determined as the first complexity value of the current image.
[0179] Mode 2: In the above situation 12, according to the complexity value of the starting image and the satd of the current image, determining the first complexity value of the current image can be achieved by the following steps S603-A11 to S603-A133:
[0180] S603-A11, obtaining the resolution of the current image. The resolution of the current image can be obtained from the metadata of the video data.
[0181] S603-A12. According to the resolution of the current image, in the correspondence between the preset resolution and the resolution factor, query the resolution factor corresponding to the current image. The embodiment of the present application includes a correspondence between the predicted resolution and the resolution factor, and the correspondence includes a correspondence between different resolutions and different resolution factors. The correspondence may be in a table. The encoding device may query the resolution factor corresponding to the resolution of the current image in the correspondence table.
[0182] S603-A13, determine a first complexity value of the current image according to a resolution factor corresponding to the current image, a complexity value of the starting image and a satd of the current image.
[0183] According to the difference of satd of the current image, the first complexity value of the current image is determined in segments in the following manner. That is, the implementation manners of the above S603-A13 include but are not limited to the following:
[0184] Method 1: If the satd of the current image is greater than the first satd value and the complexity value of the starting image is greater than the second preset complexity value, then multiply the third preset value by the resolution factor to obtain a first product; subtract the satd of the current image from the first product to obtain a first difference; multiply the first difference by the complexity value of the starting image to obtain a second product; compare the second product with the fourth preset value to obtain a first ratio, and then add it to the first product to obtain the first complexity value of the current image.
[0185] In the first approach, there is no restriction on the specific values of the second preset complexity value, the third preset value and the fourth preset value.
[0186] Optionally, the second preset complexity value is 2.505.
[0187] Optionally, the third preset value is 700000.
[0188] Optionally, the fourth preset value is 4.5.
[0189] Optionally, the first satd value is the product of the third preset value and a resolution factor, for example, the first satd value=700000*resolution_rate, where resolution_rate is the resolution factor.
[0190] In an example, in method 1, the first complexity value of the current image can be obtained according to the following formula (2):
[0191] rcc->cplxr_sum=(rcc->last_satd-700000*resolution_rate)*h->param.i_frame_0_energy / 4.5+700000*resolution_rate (2)
[0192] Among them, rcc->cplxr_sum represents the first complexity value of the current image, rcc->last_satd represents the satd of the current image, h->param.i_frame_0_energy represents the complexity value of the starting image, and resolution_rate represents the resolution factor corresponding to the current image.
[0193] Method 2: If the satd of the current image is greater than the first satd value and less than the second satd value, and the complexity value of the starting image is less than or equal to the second preset complexity value, then the complexity value of the starting image is compared with the fifth preset value to obtain a second ratio; the sixth preset value is added to the second ratio to obtain a second sum; the second sum is multiplied by the satd of the current image to obtain a third product; the seventh preset value is multiplied by the resolution factor to obtain a fourth product; and the ratio of the third product to the fourth product is determined as the first complexity value of the current image.
[0194] In the second method, there is no restriction on the specific values of the fifth preset value, the sixth preset value and the seventh preset value.
[0195] Optionally, the fifth preset value is 5.0.
[0196] Optionally, the sixth preset value is 7.
[0197] Optionally, the seventh preset value is 17.
[0198] Optionally, the second satd value is a product of a preset value and a resolution factor, for example, the second satd value=1000000*resolution_rate.
[0199] In an example, the second method can obtain the first complexity value of the current image according to the following formula (3):
[0200] rcc->cplxr_sum=(7+h->param.i_frame_0_energy / 5.0)*rcc->last_satd / (17*resolution_rate) (3)
[0201] Method three: if the satd of the current image is greater than or equal to the second satd value and less than the third satd value, and the complexity value of the starting image is less than or equal to the second preset complexity value, then the complexity value of the starting image is compared with the eighth preset value to obtain a third ratio; the ninth preset value is added to the third ratio to obtain a third sum; the third sum is multiplied by the satd of the current image to obtain a fourth product; the tenth preset value is multiplied by the resolution factor to obtain a fifth product; the ratio of the fourth product to the fifth product is determined as the first complexity value of the current image.
[0202] In the third approach, there is no restriction on specific values of the resolution factor threshold, the eighth preset value, the ninth preset value and the tenth preset value.
[0203] Optionally, the eighth preset value is 4.0.
[0204] Optionally, the ninth preset value is 7.
[0205] Optionally, the tenth preset value is 17.
[0206] Optionally, the third satd value is a product of a preset value and a resolution factor, for example, the third satd value=1700000*resolution_rate.
[0207] In an example, the third method can obtain the first complexity value of the current image according to the following formula (4):
[0208] rcc->cplxr_sum=(7+h->param.i_frame_0_energy / 4.0)*rcc->last_satd / (17*resolution_rate) (4)
[0209] Method 4: If the satd of the current image is less than the first satd value, the first complexity value of the current image is determined according to the satd of the current image and the resolution factor corresponding to the current image.
[0210] For example, the ratio of the satd of the current image to the resolution factor corresponding to the current image is determined as the first complexity value of the current image.
[0211] For another example, the tenth preset value is multiplied by the satd of the current image to obtain a sixth product; the eleventh preset value is multiplied by the resolution factor to obtain a seventh product; and the ratio of the sixth product to the seventh product is determined as the first complexity value of the current image.
[0212] In an example, the fourth method can obtain the first complexity value of the current image according to the following formula (5):
[0213] rcc->cplxr_sum=7*rcc->last_satd / (17*resolution_rate) (5)
[0214] In this case 12, if the current image is not the starting image, the first complexity value of the current image can be calculated segmented according to the above method. Since the above segmented calculation formula is obtained by statistically analyzing the relationship between the complexity value of the historical starting image and the encoding cost of the image, based on the above segmented method, the first complexity value of the current image can be accurately calculated based on the complexity value of the starting image.
[0215] In some embodiments, the codes for the specific implementation process of the above-mentioned methods 1 to 4 are shown in Table 1:
[0216] Table 1
[0217]
[0218]
[0219]
[0220] If the content complexity value includes the complexity value of the starting image, the first complexity value of the current image is calculated according to the segmented calculation method. Then, step S604 is executed to determine the initial quantization level of the current image according to the first complexity value of the current image.
[0221] S604: Determine an initial quantization level of the current image according to the first complexity value of the current image.
[0222] The implementation process of determining the initial quantization level of the current image according to the first complexity value of the current image in S604 includes but is not limited to the following methods:
[0223] Method 1: using the first complexity value of the current image determined above to determine the initial quantization level of the current image, the ratio of the first complexity value of the current image to the rate factor determined by the rate factor calculation module is determined as the initial quantization level of the current image.
[0224] Method 2: First, the blur complexity value of the current image is determined through the complexity estimation module, and then the second complexity value of the current image is determined based on the blur complexity value of the current image. Finally, the initial quantization level of the current image is determined based on the second complexity value and the first complexity value of the current image.
[0225] Exemplarily, the blur complexity value of the current image can be determined according to the following formula (6):
[0226] BlurCplx=Cplxsum / Cplxcount (6)
[0227] Among them, the update method of Cplxsum and Cplxcount is shown in formula (7):
[0228]
[0229] Among them, BlurCplx represents the blur complexity of the current image, Cplxsum represents the weighted sum of coding complexity, Cplxcount represents the weighted sum of the number of coded frames, i is the sequence number of the frame to be coded, satd is the sum of the absolute values of the residuals SATD after motion compensation of the current image, the satd of the first frame is a preset value, and the satd of non-first frames can be calculated according to the time-frequency transformation method, which is used to reflect the size of the generated code stream.
[0230] In an example, the blur complexity of the current image may be determined as the second complexity value of the current image.
[0231] In one example, since the constant quality of the video frame does not mean that a constant QP value should be used, according to the visual characteristics of the human eye, for highly complex scenes, it is difficult for the human eye to subjectively feel the loss of details. Therefore, the blur complexity of the current image can be nonlinearly compressed through perceptual coding optimization methods to reduce the bit rate and obtain a second complexity value of the current image.
[0232] For example, according to the following formula (8), the blur complexity value of the current image is compressed:
[0233] rceq = BlurCplx (1-qcomp) ,qcomp∈[0,1] (8)
[0234] In formula (8), rceq represents the complexity after perceptual coding optimization, that is, the second complexity value of the current image. The specific meaning of qcomp is that when qcomp is equal to 1, the quantization weight of each frame, that is, rceq, is the same, and the bits allocated to smooth frames and complex frames are the same; when qcomp = 0, the quantization weight of each frame is proportional to its blur complexity, and the QP value of each frame is equal, which is equivalent to turning off this perceptual coding optimization.
[0235] According to the above method, after the second complexity value of the current image is determined, the initial quantization level of the current image is determined according to the second complexity value and the first complexity value of the current image. For example, the second complexity value and the first complexity value of the current image are added to obtain the complexity sum value of the current image, and the ratio of the complexity sum value to the bit rate factor is determined as the initial quantization level of the current image.
[0236] Exemplarily, the initial quantization level of the current image is determined according to the following formula (9):
[0237] qscale=(rceq+rcc->cplxr_sum) / ratefactor (9)
[0238] In formula (9), qscale is the initial quantization level of the current frame, rcc->cplxr_sum is the first complexity value of the current image, rceq is the second complexity value of the current image, and ratefactor is the bit rate factor.
[0239] After the initial quantization level of the current image is determined according to the above steps, the above step S503 - A3 is performed, that is, the initial quantization parameter of the current macroblock is determined according to the initial quantization level of the current image.
[0240] S605: Determine an initial quantization parameter of the current macroblock according to the initial quantization level.
[0241] In one example, according to the initial quantization level of the current image, the initial quantization parameter of the current image can be determined by the following formula (10):
[0242] QP=a+bXlog2(qscale / c) (10)
[0243] Wherein, QP is the initial quantization parameter of the current image, a, b, c are all empirical values, optional, a=12, b=6, c=0.85.
[0244] After the initial quantization parameter of the current image is determined, the initial quantization parameter of the current image is determined as the initial quantization parameter of the current macroblock.
[0245] S606: Determine a target quantization parameter of the current macroblock according to the initial quantization parameter.
[0246] In some embodiments, the target quantization parameter of the current macroblock may be determined according to the initial quantization parameter of the current macroblock in the following ways, but not limited to:
[0247] Method 1: The initial quantization parameter of the current macroblock is determined as the target quantization parameter of the current macroblock.
[0248] In a second method, the quantization strength factor calculated by the adaptive quantization module is used to adjust the initial quantization parameter of the current macroblock to obtain the target quantization parameter of the current macroblock.
[0249] S607 . Encode the current macroblock according to the target quantization parameter of the current macroblock.
[0250] The implementation process of the above S607 refers to the description of the above S504, which will not be repeated here.
[0251] In some embodiments, Figure 7 A schematic diagram of X.264 encoding provided in an embodiment of the present application is shown in FIG. Figure 7As shown, if the content complexity information corresponding to the current image includes the complexity information of the starting image, the adaptive quantization module 407 determines the first complexity value of the current image through the above-mentioned complexity segmentation calculation method, and feeds back the determined first complexity value of the current image to the quantization level calculation module 403. The quantization level calculation module 403 determines the initial quantization parameter of the current image according to the first complexity value of the current image. Optionally, the quantization level calculation module 403 adjusts the initial quantization parameter of the current image according to the rate factor determined by the rate factor calculation module 402. Optionally, the VBV module 404 further adjusts the initial quantization level based on the size of the buffer area at the receiving end to obtain the quantization level. The quantization level to QP module 405 converts the quantization level into an initial quantization parameter and provides it to the macroblock level quantization parameter adjustment module 406.
[0252] The image encoding method provided by the embodiment of the present application, if the content complexity information corresponding to the current image includes the complexity information of the starting image, determines the complexity value of the starting image through the complexity information of the starting image, and determines the first complexity value of the current image based on the complexity value of the starting image, and then determines the initial quantization level of the current image based on the first complexity value of the current image, and then determines the initial quantization parameter of the current macroblock based on the initial quantization level, and determines the target quantization parameter of the current macroblock based on the initial quantization parameter, and finally encodes the current macroblock based on the target quantization parameter of the current macroblock. That is, in this embodiment, when determining the target quantization parameter of the current macroblock, the influence of the content complexity of the starting image on the target QP of the current macroblock is taken into account, thereby achieving accurate determination of the QP of the current macroblock, making the quantization operation more in line with the image content, and improving the overall quality of image encoding.
[0253] Combine the following Figure 8 and Fig. 9 When the content complexity information includes the complexity information of the current macroblock, the encoding process of the embodiment of the present application is introduced.
[0254] Figure 8 A flowchart of an image encoding method provided by an embodiment of the present application is shown in FIG. Figure 8 As shown, including:
[0255] S701. Obtain complexity information of the current macroblock.
[0256] The implementation process of the above S701 is specifically referred to the description of the above S501, which will not be repeated here.
[0257] At this time, the above S502 includes the following step S702.
[0258] S702: Determine the complexity value of the current macroblock according to the complexity information of the current macroblock.
[0259] In this embodiment, according to the complexity information of the current macroblock, the methods for determining the complexity value of the current macroblock include but are not limited to the following methods:
[0260] Method 1: If the complexity information of the current macroblock is the YUV data of the current macroblock, the complexity value of the current macroblock is determined according to the YUV data size of the current macroblock. For example, the sum of the YUV sizes corresponding to each pixel in the current macroblock is determined as the complexity value of the current macroblock.
[0261] Method 2: If the complexity information of the current macroblock is the Y component in the YUV data of the current macroblock, the complexity value of the current macroblock is determined according to the size of the Y component of the current macroblock. For example, the sum of the Y component sizes corresponding to each pixel in the current macroblock is determined as the complexity value of the current macroblock.
[0262] Method three: if the complexity information of the current macroblock includes the amount of coding information of the current macroblock, the amount of coding information of the current macroblock is determined as the complexity value of the current macroblock.
[0263] In one example, the complexity value of the current macroblock is determined according to the following formula (11):
[0264] i_var_y=i_mb_energy (11)
[0265] Among them, i_var_y represents the complexity value of the current macroblock, and i_mb_energy represents the amount of coding information of the current macroblock.
[0266] Correspondingly, the above S503 includes the following steps S703 to S706.
[0267] S703: Determine the blur complexity value of the current image.
[0268] Specifically refer to the above formulas (6) and (7) to calculate the blur complexity value of the current image.
[0269] S704: Determine an initial quantization parameter of the current macroblock according to the blur complexity value of the current image.
[0270] Specifically, an initial quantization parameter of the current image is determined according to the blur complexity value of the current image, and the initial quantization parameter of the current image is determined as the initial quantization parameter of the current macroblock.
[0271] In one example, a ratio of a blur complexity value of a current image to a rate factor is determined as an initial quantization parameter of the current image.
[0272] In one example, according to the above formula (8), the blur complexity value of the current image is compressed to obtain a second complexity value of the current image, and the ratio of the second complexity value of the current image to the bit rate factor is determined as the initial quantization parameter of the current image.
[0273] For example, the initial quantization parameter of the current image is determined by using the following formula (12).
[0274] qscale=(rceq) / ratefactor (12)
[0275] Among them, qscale is the initial quantization parameter of the current image.
[0276] S705 . Adjust the initial quantization parameter of the current macroblock according to the complexity value of the current macroblock to obtain a target quantization parameter of the current macroblock.
[0277] In some embodiments, the method of determining the target quantization parameter of the current macroblock in S704 includes but is not limited to the following methods:
[0278] Method 1: if the complexity value of the current macroblock is less than a preset minimum threshold, the sum of the initial quantization parameter and the fifth value is determined as the target quantization parameter of the current macroblock.
[0279] This method does not limit the specific value of the fifth value.
[0280] Optionally, the fifth value is 3.
[0281] In a second method, if the complexity value of the current macroblock is greater than a preset maximum threshold, the difference between the initial quantization parameter and the sixth value is determined as the target quantization parameter of the current macroblock.
[0282] This second method does not limit the specific value of the sixth numerical value.
[0283] Optionally, the above sixth value is 3.
[0284] Mode three: if the initial quantization parameter of the current macroblock is greater than the preset quantization parameter, the sum of the initial quantization parameter and the seventh value is determined as the target quantization parameter of the current macroblock.
[0285] This method three does not restrict the specific value of the seventh value.
[0286] Optionally, the above seventh numerical value is 1.
[0287] Optionally, the preset quantization parameter is 30.
[0288] In an example, the above-mentioned preset minimum threshold, preset maximum threshold and preset quantization parameter are all obtained by statistically analyzing historical data.
[0289] In some embodiments, the codes for the specific implementation process of the above-mentioned methods 1 to 3 are shown in Table 2:
[0290] Table 2 MB QP adjustment key code example
[0291]
[0292] In Table 2, i_var_y represents the complexity value of the current macroblock, i_complex_high represents the preset maximum threshold, and i_complex_low represents the preset minimum threshold.
[0293] S706: Encode the current macroblock according to the target quantization parameter of the current macroblock.
[0294] The implementation process of the above S706 refers to the description of the above S504 and will not be repeated here.
[0295] Fig. 9 A schematic diagram of X.264 encoding provided in an embodiment of the present application is shown in FIG. Fig. 9 As shown, if the content complexity information corresponding to the current image includes the complexity information of the current macroblock, the complexity estimation module 401 estimates the second complexity value of the current image. The quantization level calculation module 403 calculates the quantization level according to the second complexity value of the current image output by the complexity estimation module 401, obtains the initial quantization level corresponding to the current image, and optionally adjusts the initial quantization level according to the rate factor provided by the rate factor calculation module 402. Optionally, the VBV module 404 further adjusts the initial quantization level based on the size of the buffer area at the receiving end to obtain the quantization level. The quantization level to QP module 405 converts the quantization level into an initial quantization parameter and provides it to the macroblock level quantization parameter adjustment module 406.
[0296] The macroblock-level quantization parameter adjustment module 406 determines the complexity value of the current macroblock, and uses the complexity value of the current macroblock to adjust the initial quantization parameter of the current image to obtain the target quantization parameter of the current macroblock. Optionally, in the above adjustment process, the macroblock-level quantization parameter adjustment module 406 integrates the quantization strength factor output by the adaptive quantization module 407 and the complexity value of the current macroblock, adjusts the initial quantization parameter of the current image, and obtains the target quantization parameter of the current macroblock.
[0297] The image encoding method provided by the embodiment of the present application, if the content complexity value only includes the complexity value of the current macroblock, then the fuzzy complexity value of the current image is determined, and the initial quantization parameter of the current macroblock is determined according to the fuzzy complexity value, and then the initial quantization parameter of the current macroblock is adjusted using the complexity value of the current macroblock, so that the adjusted quantization parameter is more consistent with the image content, thereby improving the calculation accuracy of the QP of the current macroblock.
[0298] Combine the following Fig.10 and Fig.11 When the content complexity information includes the complexity information of the starting image and the complexity information of the current macroblock, the encoding process of the embodiment of the present application is introduced.
[0299] Fig.10 A flowchart of an image encoding method provided by an embodiment of the present application is shown in FIG. Fig.10 As shown, including:
[0300] S801. Obtain complexity information of a starting image and complexity information of a current macroblock.
[0301] The implementation process of the above S801 is specifically referred to the description of the above S501, which will not be repeated here.
[0302] At this time, the above S502 includes the following step S802.
[0303] S802: Determine the complexity value of the starting image according to the complexity information of the starting image, and determine the complexity value of the current macroblock according to the complexity information of the current macroblock.
[0304] Among them, according to the complexity information of the starting image, the complexity value of the starting image can be determined by referring to the description of S602 above, and according to the complexity information of the current macroblock, the complexity value of the current macroblock can be determined by referring to the description of S702 above, which will not be repeated here.
[0305] S803: Determine an initial quantization parameter of the current macroblock according to the complexity value of the starting image.
[0306] The implementation process of the above S803 can refer to the detailed description of the above S603 to S605, which will not be repeated here.
[0307] S804 . Adjust the initial quantization parameter of the current macroblock according to the complexity value of the current macroblock to obtain a target quantization parameter of the current macroblock.
[0308] The implementation process of the above S804 is described in detail in the above S705 and will not be repeated here.
[0309] S805 . Encode the current macroblock according to the target quantization parameter of the current macroblock.
[0310] The implementation process of the above S805 refers to the description of the above S504, which will not be repeated here.
[0311] In some embodiments, Fig.11 A schematic diagram of X.264 encoding provided in an embodiment of the present application is shown in FIG. Fig.11 As shown, if the content complexity information corresponding to the current image includes the complexity information of the starting image and the complexity information of the current macroblock, the complexity estimation module 401 estimates the second complexity value of the current image, and feeds back the second complexity value of the current image to the quantization level calculation module 403. At the same time, the adaptive quantization module 407 determines the first complexity value of the current image through the complexity segmentation calculation method of this embodiment, and feeds back the determined first complexity value of the current image to the quantization level calculation module 403. The quantization level calculation module 403 calculates the quantization level according to the first complexity value and the second complexity value of the current image, obtains the initial quantization level corresponding to the current image, and optionally adjusts the initial quantization level according to the rate factor provided by the rate factor calculation module 402. Optionally, the VBV module 404 further adjusts the initial quantization level based on the size of the buffer area at the receiving end to obtain the quantization level. The quantization level conversion QP module 405 converts the quantization level into an initial quantization parameter and provides it to the macroblock level quantization parameter adjustment module 406.
[0312] The macroblock-level quantization parameter adjustment module 406 determines the complexity value of the current macroblock according to the complexity information of the current macroblock, and uses the complexity value of the current macroblock to adjust the initial quantization parameter of the current image to obtain the target quantization parameter of the current macroblock. Optionally, in the above adjustment process, the macroblock-level quantization parameter adjustment module 406 integrates the quantization strength factor output by the adaptive quantization module and the complexity value of the current macroblock, adjusts the initial quantization parameter of the current image, and obtains the target quantization parameter of the current macroblock.
[0313] The image encoding method provided by the embodiment of the present application, if the content complexity information includes the complexity information of the starting image and the complexity information of the current macroblock, calculates the complexity value of the starting image and the complexity value of the current macroblock, and determines the initial quantization parameter of the current macroblock according to the complexity value of the starting image, and then uses the complexity value of the current macroblock to adjust the initial quantization parameter of the current macroblock, so that the quantization parameter determination process is more in line with the image content, thereby improving the calculation accuracy of the QP of the current macroblock.
[0314] The above describes the process of determining the target quantization parameter of the current macroblock based on the content complexity of the starting image and / or the current macroblock. On this basis, in order to further improve the coding efficiency, the embodiment of the present application also provides an introduction to the process of dividing the macroblock.
[0315] MB division can be understood as a process of dividing an MB into coding units, and MB division is one of the important factors affecting the coding speed.
[0316] The X.264 macroblock is based on a 16x16 size. The specific division is as follows: Fig.12 As shown, for example, the plans include 16X16, 8X16, 16X8, 8X8, 4X8, 8X4, 4X4 and 16X16plan.
[0317] The MB division method can be understood as the MB encoding method, etc. The MB division method includes an intra-frame mode, an inter-frame mode, and a Skip mode.
[0318] Optionally, the intra-frame modes include: 16X16, 8X16, 16X8, 8X8, 4X8, 8X4, 4X4.
[0319] Optionally, the inter-frame modes include: 16X16, 8X16, 16X8, 8X8, 4X8, 8X4, 4X4.
[0320] In order to reduce the computational redundancy of MB division, the present application introduces the adjustment of the complexity threshold, that is, the rate-distortion cost threshold corresponding to at least one of the above intra-frame modes is adjusted so that the adjusted threshold is more in line with the actual situation.
[0321] In some embodiments, for the intra-frame mode, the embodiments of the present application determine the target intra-frame mode of the current macroblock through the following steps, specifically including: for the i-th intra-frame mode among the preset N intra-frame modes, determine the first rate-distortion cost when using the i-th intra-frame mode to encode the current macroblock, N is a positive integer, and i is a positive integer less than or equal to N; obtain the adjusted rate-distortion cost threshold corresponding to the i-th intra-frame mode; if the first rate-distortion cost is less than the adjusted rate-distortion cost threshold, then use the i-th intra-frame mode as the target intra-frame mode of the current macroblock, and encode the current macroblock, that is, use the i-th intra-frame mode to divide the current macroblock, for example, when the i-th intra-frame mode is 8X8 mode, then according to the division method of the 8X8 mode, the 16X16 current macroblock is divided into 4 8X8 sub-blocks, and the 8X8 sub-blocks are encoded as coding units.
[0322] In one example, the N intra-frame modes include the intra-frame modes of 16X16, 8X16, 16X8, 8X8, 4X8, 8X4, and 4X4, and according to the order of the intra-frame modes, the first rate-distortion cost corresponding to each intra-frame mode is calculated in sequence, and when the first rate-distortion cost is less than the adjusted rate-distortion cost threshold, the intra-frame mode is used to encode the current macroblock, and no subsequent intra-frame mode judgment is performed. For example, the first rate-distortion cost when the 16X16 intra-frame mode is used to encode the current macroblock is calculated first, and if the first rate-distortion cost is less than or equal to the adjusted rate-distortion cost threshold of the 16X16 intra-frame mode, the 16X16 intra-frame mode is determined as the target intra-frame mode of the current macroblock. If the first rate-distortion cost is greater than the rate-distortion cost threshold after adjustment of the 16X16 intra-frame mode, the first rate-distortion cost when encoding the current macroblock using the 8X16 intra-frame mode is calculated, and it is determined whether the first rate-distortion cost corresponding to the 8X16 intra-frame mode is less than or equal to the rate-distortion cost threshold after adjustment of the 8X16 intra-frame mode, and the process is performed in sequence.
[0323] In another example, the N intra-frame modes include 16X16, 8X8, and 4X4 intra-frame modes. Correspondingly, only the rate-distortion cost thresholds corresponding to these three intra-frame modes are adjusted. The intra-frame mode selection process is as follows: Fig.13As shown, firstly, the first rate-distortion cost (referred to as the first rate-distortion cost 16) when the current macroblock is encoded using the 16X16 intra mode is calculated, and it is determined whether the first rate-distortion cost 16 corresponding to the 16X16 intra mode is less than or equal to the rate-distortion cost threshold after the 16X16 intra mode is adjusted (referred to as the rate-distortion cost threshold 16). If the first rate-distortion cost 16 corresponding to the 16X16 intra mode is less than or equal to the rate-distortion cost threshold after the 16X16 intra mode is adjusted, the 16X16 intra mode is determined as the target intra mode of the current macroblock. If the first rate-distortion cost 16 corresponding to the 16X16 intra-frame mode is greater than the rate-distortion cost threshold 16 adjusted by the 16X16 intra-frame mode, the first rate-distortion cost (recorded as the first rate-distortion cost 8) when the current macroblock is encoded using the 8X8 intra-frame mode is calculated, and it is determined whether the first rate-distortion cost 8 corresponding to the 8X8 intra-frame mode is less than or equal to the rate-distortion cost threshold (recorded as the rate-distortion cost threshold 8) adjusted by the 8X8 intra-frame mode. If the first rate-distortion cost 8 corresponding to the 8X8 intra-frame mode is less than or equal to the rate-distortion cost threshold 8 adjusted by the 8X8 intra-frame mode, the 8X8 intra-frame mode is determined as the target intra-frame mode of the current macroblock. If the first rate-distortion cost 8 corresponding to the 8X8 intra-frame mode is greater than the rate-distortion cost threshold 8 adjusted by the 8X8 intra-frame mode, the first rate-distortion cost (referred to as the first rate-distortion cost 4) when the current macroblock is encoded using the 4X4 intra-frame mode is calculated, and it is determined whether the first rate-distortion cost 4 corresponding to the 4X4 intra-frame mode is less than or equal to the rate-distortion cost threshold 4 adjusted by the 4X4 intra-frame mode. If the first rate-distortion cost 4 corresponding to the 4X4 intra-frame mode is less than or equal to the rate-distortion cost threshold 4 adjusted by the 4X4 intra-frame mode, the 4X4 intra-frame mode is determined as the target intra-frame mode of the current macroblock. If the first rate-distortion cost 4 corresponding to the 4X4 intra-frame mode is greater than the rate-distortion cost threshold 4 adjusted by the 4X4 intra-frame mode, the target intra-frame mode of the current macroblock is determined from the remaining intra-frame modes.
[0324] In some embodiments, since the Skip mode directly uses the adjacent coded blocks as reference blocks, the amount of calculation is small, and when a macroblock is encoded using the Skip mode, except for the mark that the macroblock is encoded using the Skip mode, no other data of the macroblock is sent, thereby saving bit rate. Based on this, in order to increase the frequency of use of the Skip mode, the embodiments of the present application propose the following two solutions:
[0325] Solution 1: If the coding mode of the adjacent coded macroblock of the current macroblock is the Skip mode, the current macroblock is encoded using the Skip mode.
[0326] Solution 2: In the process of selecting the inter-frame mode, the selection of the Skip mode is added to increase the probability of using the Skip mode. Specifically, for the j-th inter-frame mode among the preset M inter-frame modes, the second rate-distortion cost when the j-th inter-frame mode is used to encode the current macroblock is determined, where M is a positive integer and j is a positive integer less than or equal to M; the third rate-distortion cost when the Skip mode is used to encode the current macroblock is determined; if the third rate-distortion cost is less than or equal to the second rate-distortion cost, the Skip mode is used to encode the current macroblock.
[0327] In some examples, the j-th inter-frame mode is any one of the M inter-frame modes.
[0328] In some other examples, in order to reduce the amount of calculation, the jth inter-frame mode is the first intra-frame mode among the M inter-frame modes, for example, the jth intra-frame mode is a 16X16 intra-frame mode. Fig.14 As shown, the second rate distortion cost when encoding the current macroblock using the 16X16 intra-frame mode is calculated, and the third rate distortion cost when encoding the current macroblock using the Skip mode is calculated. If the third rate distortion cost is less than or equal to the second rate distortion cost, the current macroblock is encoded using the Skip mode. If the third rate distortion cost is greater than the second rate distortion cost corresponding to the 16X16 inter-frame mode, then according to Fig.14 The process shown in FIG. 1 determines the costs corresponding to the inter-frame modes such as 8X8, 4X4, 4X8, and 8X4, and then selects the inter-frame mode with the smallest cost as the target inter-frame mode of the current image.
[0329] In the embodiment of the present application, by increasing the probability of selecting the Skip mode, the encoding speed can be greatly improved while ensuring the encoding compression rate and quality.
[0330] In order to further illustrate the effectiveness of the technical solution of the present application, in some embodiments, a commercial dedicated transcoding data set is selected for testing, with a total of 50 test videos, including video resolutions of 960x540, 1024x576, 1280x720, and 1920x1080. The ABR mode is adopted, and the bit rate is set at a relatively low 1.4Mb / s and a frame rate of 25fps. Under the same conditions, a horizontal comparison is made with the standard X.264. The overall average improvement in PSNR objective quality is about 0.575dB, and the encoding speed is increased by an average of 10%. It can be concluded that the technical solution of the present application has a more obvious improvement in the quality of the encoded video, and the encoding speed is increased, while the compression rate of the encoding is not affected. The encoder optimized by the embodiment of the present application meets the encoding standard, does not have compatibility issues, and can be widely used in video encoding, transcoding, editing and other scenes.
[0331] It should be understood that Figures 5 to 14 This is only an example of the present application and should not be construed as limiting the present application.
[0332] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the ideas of the present application, they should also be regarded as the contents disclosed in the present application.
[0333] It should also be understood that in the various method embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. In addition, in the embodiments of the present application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. Specifically, 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 objects associated before and after are in an "or" relationship.
[0334] Combination of the above Figures 5 to 14 , describes in detail the method embodiment of the present application, and the following is combined with Figure 15 to Figure 16 , describe in detail the device embodiments of the present application.
[0335] Fig.15 It is a schematic block diagram of an image encoding device provided in an embodiment of the present application.
[0336] like Fig.15 As shown, the image encoding device 10 includes:
[0337] An acquisition unit 11 is used to acquire content complexity information corresponding to a current image to be encoded, wherein the content complexity information includes at least one of complexity information of a starting image in video data where the current image is located and complexity information of a current macroblock in the current image;
[0338] A complexity determination unit 12, configured to determine a content complexity value corresponding to the current image according to the content complexity information;
[0339] A quantization parameter determination unit 13, configured to determine a target quantization parameter of the current macroblock according to the content complexity value;
[0340] The encoding unit 14 is used to encode the current macroblock according to the target quantization parameter of the current macroblock.
[0341] In some embodiments, the complexity determination unit 12 is specifically configured to determine the complexity value of the starting image according to the complexity information of the starting image if the content complexity information includes the complexity information of the starting image, and determine the complexity value of the starting image as the content complexity value;
[0342] If the content complexity information includes the complexity information of the current macroblock, determining the complexity value of the current macroblock according to the complexity information of the current macroblock, and determining the complexity value of the current macroblock as the content complexity value;
[0343] If the content complexity information includes the complexity information of the starting image and the complexity information of the current macroblock, the complexity value of the starting image is determined according to the complexity information of the starting image, and the complexity value of the current macroblock is determined according to the complexity information of the current macroblock, and the complexity value of the starting image and the complexity value of the current macroblock are determined as the content complexity value.
[0344] Optionally, the complexity information of the starting image includes at least one of an amount of coding information of macroblocks included in the starting image, a coding bit depth, and the number of macroblocks included in the starting image.
[0345] In some embodiments, the complexity determination unit 12 is specifically used to calculate the product of the amount of coding information of the macroblock in the starting image and the coding bit depth, and add the product to a first preset value to obtain a sum value, and use a second preset value as an exponent to perform an exponential operation on the sum value to obtain a first operation result corresponding to the macroblock; calculate the sum of the first operation results corresponding to the macroblocks in the starting image, and determine the ratio of the sum to the number of macroblocks included in the starting image as the complexity value of the starting image.
[0346] Optionally, the complexity information of the current macroblock includes the amount of encoding information of the current macroblock.
[0347] In some embodiments, the complexity determination unit 12 is specifically configured to determine the amount of encoding information of the current macroblock as the complexity value of the current macroblock.
[0348] In some embodiments, the quantization parameter determination unit 13 is specifically configured to determine an initial quantization parameter of the current macroblock according to the complexity value of the starting image if the content complexity value includes the complexity value of the starting image, and determine a target quantization parameter of the current macroblock according to the initial quantization parameter; and / or,
[0349] If the content complexity value includes the complexity value of the current macroblock, determining the blur complexity value of the current image, determining the initial quantization parameter of the current macroblock according to the blur complexity value of the current image, and adjusting the initial quantization parameter of the current macroblock according to the complexity value of the current macroblock to obtain a target quantization parameter of the current macroblock; and / or,
[0350] If the content complexity value includes the complexity value of the starting image and the complexity value of the current macroblock, the initial quantization parameter of the current macroblock is determined according to the complexity value of the starting image, and the initial quantization parameter of the current macroblock is adjusted according to the complexity value of the current macroblock to obtain the target quantization parameter of the current macroblock.
[0351] In some embodiments, the quantization parameter determination unit 13 is specifically used to determine the first complexity value of the current image according to the complexity value of the starting image; determine the initial quantization level of the current image according to the first complexity value of the current image; and determine the initial quantization parameter of the current macroblock according to the initial quantization level.
[0352] In some embodiments, the quantization parameter determination unit 13 is specifically configured to determine a first complexity value of the current image according to the complexity value of the starting image if the current image is the starting image; and / or,
[0353] If the current image is not the starting image, the residual absolute value sum satd of the current image after motion compensation is determined, and the first complexity value of the current image is determined according to the complexity value of the starting image and the satd of the current image.
[0354] In some embodiments, the quantization parameter determination unit 13 is specifically configured to determine that the first complexity value of the current image is a first preset complexity value if the complexity value of the starting image is less than a first value; and / or,
[0355] If the complexity value of the starting image is greater than or equal to the second value, then the product of the complexity value of the starting image and the third value is determined as the first complexity value of the current image; and / or,
[0356] If the complexity value of the starting image is greater than or equal to the first value and less than the second value, the product of the complexity value of the starting image and the fourth value is determined as the first complexity value of the current image.
[0357] In some embodiments, the quantization parameter determination unit 13 is specifically used to obtain the resolution of the current image; according to the resolution of the current image, in the correspondence between the preset resolution and the resolution factor, query the resolution factor corresponding to the current image; according to the resolution factor corresponding to the current image, the complexity value of the starting image and the satd of the current image, determine the first complexity value of the current image.
[0358] In some embodiments, the quantization parameter determination unit 13 is specifically used to multiply the third preset value by the resolution factor to obtain a first product if the satd of the current image is greater than the first satd value and the complexity value of the starting image is greater than the second preset complexity value; subtract the satd of the current image from the first product to obtain a first difference; multiply the first difference by the complexity value of the starting image to obtain a second product; compare the second product with the fourth preset value to obtain a first ratio, and then add the second ratio to the first product to obtain a first complexity value of the current image.
[0359] In some embodiments, the quantization parameter determination unit 13 is specifically used to compare the complexity value of the starting image with the fifth preset value to obtain a second ratio if the satd of the current image is greater than the first satd value and less than the second satd value, and the complexity value of the starting image is less than or equal to the second preset complexity value; add the sixth preset value to the second ratio to obtain a second sum; multiply the second sum by the satd of the current image to obtain a third product; multiply the seventh preset value by the resolution factor to obtain a fourth product; and determine the ratio of the third product to the fourth product as the first complexity value of the current image.
[0360] In some embodiments, the quantization parameter determination unit 13 is specifically used to compare the complexity value of the starting image with the eighth preset value to obtain a third ratio if the satd of the current image is greater than or equal to the second satd value and less than the third satd value, and the complexity value of the starting image is less than or equal to the second preset complexity value; add the ninth preset value to the third ratio to obtain a third sum; multiply the third sum by the satd of the current image to obtain a fourth product; multiply the tenth preset value by the resolution factor to obtain a fifth product; and determine the ratio of the fourth product to the fifth product as the first complexity value of the current image.
[0361] In some embodiments, the quantization parameter determination unit 13 is specifically used to determine the first complexity value of the current image according to the satd of the current image and the resolution factor corresponding to the current image if the satd of the current image is less than the first satd value.
[0362] In some embodiments, the quantization parameter determination unit 13 is specifically used to multiply the eleventh preset value by the satd of the current image to obtain a sixth product; multiply the twelfth preset value by the resolution factor to obtain a seventh product; and determine the ratio of the sixth product to the seventh product as the first complexity value of the current image.
[0363] In some embodiments, the quantization parameter determination unit 13 is specifically used to determine the blur complexity value of the current image; determine the second complexity value of the current image based on the blur complexity value of the current image; and determine the initial quantization level of the current image based on the first complexity value and the second complexity value of the current image.
[0364] In some embodiments, the quantization parameter determination unit 13 is specifically used to obtain a rate factor of the current image; and determine the ratio of the sum of the first complexity value and the second complexity value of the current image to the rate factor as the initial quantization level of the current image.
[0365] In some embodiments, the quantization parameter determination unit 13 is specifically configured to determine the sum of the initial quantization parameter and the fifth value as the target quantization parameter of the current macroblock if the complexity value of the current macroblock is less than a preset minimum threshold; and / or,
[0366] If the complexity value of the current macroblock is greater than a preset maximum threshold, the difference between the initial quantization parameter and the sixth value is determined as the target quantization parameter of the current macroblock.
[0367] In some embodiments, the quantization parameter determination unit 13 is further configured to determine the sum of the initial quantization parameter and the seventh value as the target quantization parameter of the current macroblock if the initial quantization parameter of the current macroblock is greater than a preset quantization parameter.
[0368] In some embodiments, the encoding unit 14 is further used to determine, for the i-th intra-frame mode among the preset N intra-frame modes, a first rate-distortion cost when using the i-th intra-frame mode to encode the current macroblock, where N is a positive integer and i is a positive integer less than or equal to N; obtain an adjusted rate-distortion cost threshold corresponding to the i-th intra-frame mode; if the first rate-distortion cost is less than or equal to the adjusted rate-distortion cost threshold, the i-th intra-frame mode is determined as the target intra-frame mode of the current macroblock, and the i-th intra-frame mode is used to encode the current macroblock.
[0369] In some embodiments, the encoding unit 14 is configured to encode the current macroblock using the Skip mode if the encoding mode of the adjacent encoded macroblock of the current macroblock is the Skip mode.
[0370] In some embodiments, for the jth inter-frame mode among the preset M inter-frame modes, a second rate-distortion cost is determined when the jth inter-frame mode is used to encode the current macroblock, where M is a positive integer and j is a positive integer less than or equal to M; a third rate-distortion cost is determined when the Skip mode is used to encode the current macroblock; if the third rate-distortion cost is less than or equal to the second rate-distortion cost, the Skip mode is used to encode the current macroblock.
[0371] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Fig.15 The device 10 shown can execute the method of the embodiment of the present application, and the aforementioned and other operations and / or functions of each unit in the device 10 are respectively for implementing the corresponding processes in each method such as the method, and for the sake of brevity, they are not repeated here.
[0372] The above describes the device and system of the embodiment of the present application from the perspective of the functional unit in conjunction with the accompanying drawings. It should be understood that the functional unit can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software units. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or a combination of hardware and software units in the decoding processor to perform. Optionally, the software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.
[0373] Fig.16 It is a schematic block diagram of the encoding device provided in an embodiment of the present application.
[0374] like Fig.16 As shown, the encoding device 30 is used to perform the above-mentioned image encoding method, and the encoding device 30 may include:
[0375] The memory 33 and the processor 32, the memory 33 is used to store the computer program 34 and transmit the program code 34 to the processor 32. In other words, the processor 32 can call and run the computer program 34 from the memory 33 to implement the method in the embodiment of the present application.
[0376] For example, the processor 32 may be configured to execute the steps in the above method 200 according to the instructions in the computer program 34 .
[0377] In some embodiments of the present application, the processor 32 may include but is not limited to:
[0378] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0379] In some embodiments of the present application, the memory 33 includes but is not limited to:
[0380] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0381] In some embodiments of the present application, the computer program 34 may be divided into one or more units, which are stored in the memory 33 and executed by the processor 32 to complete the method provided by the present application. The one or more units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 34 in the encoding device 30.
[0382] like Fig.16 As shown, the encoding device 30 may also include:
[0383] The transceiver 33 may be connected to the processor 32 or the memory 33 .
[0384] The processor 32 may control the transceiver 33 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 33 may include a transmitter and a receiver. The transceiver 33 may further include an antenna, and the number of antennas may be one or more.
[0385] It should be understood that the various components in the encoding device 30 are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0386] The present application also provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a computer, the computer can perform the method of the above method embodiment. In other words, the present application embodiment also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer can perform the method of the above method embodiment.
[0387] When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital point cloud optical disc (digital video disc, DVD)), or a semiconductor medium (e.g., a solid state drive (solid state disk, SSD)), etc.
[0388] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software 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 application.
[0389] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the unit is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0390] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional unit in each embodiment of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0391] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An image coding method, characterized in that: include: Acquire content complexity information corresponding to a current image to be encoded, the content complexity information comprising at least one of complexity information of a starting image in video data where the current image is located and complexity information of a current macroblock in the current image; Determining a content complexity value corresponding to the current image according to the content complexity information; Determining a target quantization parameter of the current macroblock according to the content complexity value; Encoding the current macroblock according to a target quantization parameter of the current macroblock; Wherein, determining the target quantization parameter of the current macroblock according to the content complexity value includes: If the content complexity value includes the complexity value of the starting image, determining the first complexity value of the current image according to the complexity value of the starting image, where the complexity value of the starting image is determined based on complexity information of the starting image; Determining an initial quantization level of the current image according to a first complexity value of the current image; Determining an initial quantization parameter of the current macroblock according to the initial quantization level, and determining a target quantization parameter of the current macroblock according to the initial quantization parameter; The determining, according to the complexity value of the starting image, a first complexity value of the current image comprises: If the current image is not the starting image, determining the residual absolute value sum satd of the current image after motion compensation, and obtaining the resolution of the current image; According to the resolution of the current image, querying the resolution factor corresponding to the current image in the preset correspondence relationship between the resolution and the resolution factor; Determine at least one preset value based on the satd size of the current image and the complexity value of the starting image; Based on the at least one preset value, the resolution factor, the satd of the current image, and the complexity value of the starting image are processed to obtain a first complexity value of the current image; Wherein, based on the at least one preset value, the resolution factor, the satd of the current image, and the complexity value of the starting image are processed to obtain a first complexity value of the current image, including: If the satd of the current image is greater than the first satd value, and the complexity value of the starting image is greater than the second preset complexity value, multiplying the third preset value by the resolution factor to obtain a first product; Subtracting the satd of the current image from the first product to obtain a first difference; Multiplying the first difference value by the complexity value of the starting image to obtain a second product; The second product is compared with a fourth preset value to obtain a first ratio, which is then added to the first product to obtain a first complexity value of the current image.
2. The method according to claim 1, characterized in that The determining, according to the content complexity information, a content complexity value corresponding to the current image includes: If the content complexity information includes the complexity information of the starting image, determining the complexity value of the starting image according to the complexity information of the starting image, and determining the complexity value of the starting image as the content complexity value; If the content complexity information includes the complexity information of the current macroblock, determining the complexity value of the current macroblock according to the complexity information of the current macroblock, and determining the complexity value of the current macroblock as the content complexity value; If the content complexity information includes the complexity information of the starting image and the complexity information of the current macroblock, the complexity value of the starting image is determined according to the complexity information of the starting image, and the complexity value of the current macroblock is determined according to the complexity information of the current macroblock. The complexity value of the starting image and the complexity value of the current macroblock are determined as the content complexity value, and the content complexity value includes the complexity value of the starting image and the complexity value of the current macroblock.
3. The method according to claim 2, characterized in that The complexity information of the starting image includes at least one of the amount of coding information of the macroblocks included in the starting image, the coding bit depth, and the number of macroblocks included in the starting image.
4. The method according to claim 3, characterized in that The determining the complexity value of the starting image according to the complexity information of the starting image includes: Calculating the product of the amount of coding information of the macroblock in the starting image and the coding bit depth, adding the product to a first preset value to obtain a sum value, and performing an exponential operation on the sum value using a second preset value as an exponent to obtain a first operation result corresponding to the macroblock; The sum of the first operation results corresponding to the macroblocks in the starting image is calculated, and the ratio of the sum to the number of macroblocks included in the starting image is determined as the complexity value of the starting image.
5. The method according to claim 2, characterized in that: The complexity information of the current macroblock includes the amount of encoding information of the current macroblock.
6. The method according to claim 5, characterized in that Determining the complexity value of the current macroblock according to the complexity information of the current macroblock includes: The amount of coding information of the current macroblock is determined as the complexity value of the current macroblock.
7. The method according to claim 1, characterized in that The method further comprises: If the content complexity value includes the complexity value of the current macroblock, the blur complexity value of the current image is determined, and the initial quantization parameter of the current macroblock is determined according to the blur complexity value of the current image. The initial quantization parameter of the current macroblock is adjusted according to the complexity value of the current macroblock to obtain the target quantization parameter of the current macroblock.
8. The method according to claim 1, characterized in that If the content complexity value includes the complexity value of the starting image and the complexity value of the current macroblock, then determining the target quantization parameter of the current macroblock according to the initial quantization parameter includes: An initial quantization parameter of the current macroblock is adjusted according to the complexity value of the current macroblock to obtain a target quantization parameter of the current macroblock.
9. The method according to claim 1, characterized in that: The determining, according to the complexity value of the starting image, a first complexity value of the current image comprises: If the current image is the starting image, a first complexity value of the current image is determined according to the complexity value of the starting image.
10. The method according to claim 9, characterized in that If the current image is the starting image, determining a first complexity value of the current image according to the complexity value of the starting image includes: If the complexity value of the starting image is less than the first value, determining the first complexity value of the current image to be a first preset complexity value; and / or, If the complexity value of the starting image is greater than or equal to the second value, then the product of the complexity value of the starting image and the third value is determined as the first complexity value of the current image; and / or, If the complexity value of the starting image is greater than or equal to the first value and less than the second value, the product of the complexity value of the starting image and the fourth value is determined as the first complexity value of the current image.
11. The method according to claim 1, characterized in that: The step of processing the resolution factor, the satd of the current image, and the complexity value of the starting image based on the at least one preset value to obtain a first complexity value of the current image includes: If the satd of the current image is greater than the first satd value and less than the second satd value, and the complexity value of the starting image is less than or equal to the second preset complexity value, then the complexity value of the starting image is compared with the fifth preset value to obtain a second ratio; Adding a sixth preset value to the second ratio to obtain a second sum; Multiplying the second sum value by the satd of the current image to obtain a third product; multiplying the seventh preset value by the resolution factor to obtain a fourth product; The ratio of the third product to the fourth product is determined as the first complexity value of the current image.
12. The method according to claim 1, characterized in that The step of processing the resolution factor, the satd of the current image, and the complexity value of the starting image based on the at least one preset value to obtain a first complexity value of the current image includes: If the satd of the current image is greater than or equal to the second satd value and less than the third satd value, and the complexity value of the starting image is less than or equal to the second preset complexity value, then the complexity value of the starting image is compared with the eighth preset value to obtain a third ratio; Adding the ninth preset value to the third ratio to obtain a third sum; Multiplying the third sum value by the satd of the current image to obtain a fourth product; multiplying the tenth preset value by the resolution factor to obtain a fifth product; The ratio of the fourth product to the fifth product is determined as the first complexity value of the current image.
13. The method according to claim 1, characterized in that The method further comprises: If the satd of the current image is less than the first satd value, a first complexity value of the current image is determined according to the satd of the current image and a resolution factor corresponding to the current image.
14. The method according to claim 13, characterized in that The determining, according to the satd of the current image and the resolution factor corresponding to the current image, a first complexity value of the current image comprises: multiplying the eleventh preset value by the satd of the current image to obtain a sixth product; multiplying the twelfth preset value by the resolution factor to obtain a seventh product; The ratio of the sixth product to the seventh product is determined as the first complexity value of the current image.
15. The method according to claim 1, characterized in that The step of determining an initial quantization level of the current image according to the first complexity value of the current image comprises: Determining a blur complexity value of the current image; Determining a second complexity value of the current image according to the blur complexity value of the current image; An initial quantization level of the current image is determined according to the first complexity value and the second complexity value of the current image.
16. The method according to claim 15, characterized in that Determining an initial quantization level of the current image according to the first complexity value and the second complexity value of the current image includes: Obtaining a bit rate factor of the current image; The ratio of the sum of the first complexity value and the second complexity value of the current image to the rate factor is determined as the initial quantization level of the current image.
17. The method according to claim 8, characterized in that The adjusting the initial quantization parameter of the current macroblock according to the complexity value of the current macroblock to obtain the target quantization parameter of the current macroblock includes: If the complexity value of the current macroblock is less than a preset minimum threshold, the sum of the initial quantization parameter and the fifth value is determined as the target quantization parameter of the current macroblock; and / or, If the complexity value of the current macroblock is greater than a preset maximum threshold, the difference between the initial quantization parameter and the sixth value is determined as the target quantization parameter of the current macroblock.
18. The method according to claim 8, characterized in that The method further comprises: If the initial quantization parameter of the current macroblock is greater than the preset quantization parameter, the sum of the initial quantization parameter and the seventh value is determined as the target quantization parameter of the current macroblock.
19. The method according to claim 1, characterized in that The method further comprises: For an i-th intra-frame mode among N preset intra-frame modes, determine a first rate-distortion cost when encoding the current macroblock using the i-th intra-frame mode, where N is a positive integer and i is a positive integer less than or equal to N; Obtaining an adjusted rate-distortion cost threshold corresponding to the i-th intra mode; If the first rate-distortion cost is less than or equal to the adjusted rate-distortion cost threshold, the current macroblock is encoded using the i-th intra mode.
20. The method according to claim 1, characterized in that The method further comprises: If the encoding mode of the adjacent encoded macroblock of the current macroblock is the Skip mode, the current macroblock is encoded using the Skip mode.
21. The method according to claim 1, characterized in that The method further comprises: For a j-th inter-frame mode among the preset M inter-frame modes, determine a second rate-distortion cost when the j-th inter-frame mode is used to encode the current macroblock, where M is a positive integer and j is a positive integer less than or equal to M; Determining a third rate distortion cost when encoding the current macroblock using the Skip mode; If the third rate-distortion cost is less than or equal to the second rate-distortion cost, the current macroblock is encoded using a Skip mode.
22. An image processing device, characterized in that: include: An acquisition unit, configured to acquire content complexity information corresponding to a current image to be encoded, wherein the content complexity information includes at least one of complexity information of a starting image in video data in which the current image is located and complexity information of a current macroblock in the current image; A complexity determination unit, configured to determine a content complexity value corresponding to the current image according to the content complexity information; A quantization parameter determination unit, configured to determine a target quantization parameter of the current macroblock according to the content complexity value; An encoding unit, configured to encode the current macroblock according to a target quantization parameter of the current macroblock; Wherein, the quantization parameter determination unit is specifically used for determining the first complexity value of the current image according to the complexity value of the starting image if the content complexity value includes the complexity value of the starting image, and the complexity value of the starting image is determined based on the complexity information of the starting image; determining the initial quantization level of the current image according to the first complexity value of the current image; determining the initial quantization parameter of the current macroblock according to the initial quantization level, and determining the target quantization parameter of the current macroblock according to the initial quantization parameter; wherein determining the first complexity value of the current image according to the complexity value of the starting image includes: if the current image is not the starting image, determining the sum of absolute values of residuals satd after motion compensation of the current image, and obtaining the resolution of the current image; according to the resolution of the current image, querying the resolution factor corresponding to the current image in the correspondence between the preset resolution and the resolution factor; based on the resolution of the current image The method comprises the following steps: determining at least one preset value based on the size of td and the size of the complexity value of the starting image; processing the resolution factor, the satd of the current image, and the complexity value of the starting image based on the at least one preset value to obtain a first complexity value of the current image, wherein the method comprises: if the satd of the current image is greater than the first satd value and the complexity value of the starting image is greater than the second preset complexity value, multiplying the third preset value by the resolution factor to obtain a first product; subtracting the satd of the current image from the first product to obtain a first difference; multiplying the first difference by the complexity value of the starting image to obtain a second product; comparing the second product with a fourth preset value to obtain a first ratio, and then adding the first ratio to the first product to obtain the first complexity value of the current image.
23. An encoder, characterized in that: include: Processor and memory; The memory is used to store computer programs; The processor is used to call and run the computer program stored in the memory to execute the method according to any one of claims 1 to 21.
24. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 21.
Citation Information
Patent Citations
Encoding method, encoder and computer readable storage medium
CN111866504A