Video coding method and device and related equipment
By combining the CTU initial quantitative parameter offset and the CTU error information generated during the motion estimation process, the target quantization parameter offset of the video frame is determined to solve the problem of quantitative parameter bias in the video coding process. Improve coding efficiency.
Patent Information
- Application Number
- CN202411497744.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-01-28
AI Technical Summary
In the video encoding process, since the motion compensation time domain filter module is placed behind the code rate control module, the quantization parameters are deviated, which affects the encoding efficiency of the encoder.
By obtaining the error information and initial quantification parameter offset of the encoded tree unit CTU in the video frame, the CTU's target quantification parameter offset is determined, and the video frame is coded based on this.
Effectively solve the problem of quantitative parameter deviation, improve the coding efficiency of the video, and avoid quantitative parameter conflicts and excessive adjustment problems caused by the two independent mechanisms of code rate control and MCTF.
Smart Images

Figure CN119383340A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video processing technology, and in particular to a video encoding method, a video encoding device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] In the video encoding process, the bit rate control module is used to analyze the input source video and determine the quantization parameter (QP) used to control the compression quality. However, the motion compensated temporal filter (MCTF) module is usually placed after the bit rate control module. The source video is modified after the MCTF filter, which makes the quantization parameter determined based on the source video used in the video image after the MCTF filter, resulting in deviations in the quantization parameter, affecting the encoding efficiency of the encoder.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] The present disclosure provides a video encoding method, a video encoding device, an electronic device, a computer-readable storage medium, and a computer program product to overcome the above problems or at least partially solve the above problems.
[0005] An embodiment of the present disclosure provides a video encoding method, the method comprising: obtaining a video frame to be processed, the video frame to be processed comprising one or more coding tree units (CTUs); for each of the CTUs, determining error information of the CTU, and obtaining an initial quantization parameter offset of the CTU; the error information of the CTU is obtained during a motion estimation process, and the initial quantization parameter offset of the CTU is generated during a bit rate control process; determining a target quantization parameter offset of the CTU according to the initial quantization parameter offset of the CTU and the error information of the CTU; and encoding the video frame to be processed according to the target quantization parameter offsets of one or more of the CTUs.
[0006] In some embodiments of the present disclosure, the CTU includes one or more first image blocks; wherein, determining the error information of the CTU includes: for each of the first image blocks, obtaining a matching block of the first image block in a reference video frame; calculating an error between the first image block and the obtained matching block, and determining the calculated error value as the error information of the first image block; and performing mean calculation on the error information of one or more of the first image blocks to obtain the error information of the CTU.
[0007] In some embodiments of the present disclosure, the CTU includes one or more second image blocks; wherein, obtaining the initial quantization parameter offset of the CTU includes: for each second image block, obtaining the initial quantization parameter offset of the second image block; the initial quantization parameter offset of the second image block is calculated during the process of performing bit rate control; and performing mean calculation on the initial quantization parameter offsets of one or more second image blocks to obtain the initial quantization parameter offset of the CTU.
[0008] In some embodiments of the present disclosure, determining the target quantization parameter offset of the CTU based on the initial quantization parameter offset of the CTU and the error information of the CTU includes: quantizing the initial quantization parameter offset of the CTU to obtain a quantized initial quantization parameter offset; quantizing the error information of the CTU to obtain quantized error information; and determining the target quantization parameter offset of the CTU based on the quantized initial quantization parameter offset and the quantized error information.
[0009] In some embodiments of the present disclosure, the quantizing of the initial quantization parameter offset of the CTU to obtain the quantized initial quantization parameter offset includes: determining the initial quantization parameter offset of the CTU as a reference offset; traversing the one or more CTUs and counting the number of CTUs whose initial quantization parameter offset is greater than the reference offset; calculating the ratio of the counted number of CTUs to the number of the one or more CTUs, and determining the calculated ratio as the quantized initial quantization parameter offset.
[0010] In some embodiments of the present disclosure, the error information of the CTU is quantized to obtain the quantized error information, including: determining that the error information of the CTU is benchmark error information; traversing the one or more CTUs, and counting the number of CTUs whose error information is greater than the benchmark error information; calculating the ratio of the number of counted CTUs to the number of the one or more CTUs, and determining the calculated ratio to be the quantized error information.
[0011] In some embodiments of the present disclosure, the determining the target quantization parameter offset of the CTU based on the quantized initial quantization parameter offset and the quantized error information includes: if the quantized error information is greater than a first error threshold and the quantized initial quantization parameter offset is less than the first offset threshold, then determining the target quantization parameter offset of the CTU to be the first offset; if the quantized error information is greater than a second error threshold and the quantized initial quantization parameter offset is less than the second offset threshold, then determining the target quantization parameter offset of the CTU to be the second offset; if the quantized error information is less than a third error threshold and the quantized initial quantization parameter offset is greater than the third offset threshold, then determining the target quantization parameter offset of the CTU to be the third offset; if the quantized error information is less than a fourth error threshold and the quantized initial quantization parameter offset is greater than the fourth offset threshold, then determining the target quantization parameter offset of the CTU to be the fourth offset.
[0012] In some embodiments of the present disclosure, the first error threshold is greater than or equal to the second error threshold, the first offset threshold is less than or equal to the second offset threshold, the first offset and the second offset are less than 0, and the first offset is less than the second offset; the third error threshold is less than or equal to the fourth error threshold, the third offset threshold is greater than or equal to the fourth offset threshold, the third offset and the fourth offset are greater than 0, and the third offset is less than the fourth offset.
[0013] In some embodiments of the present disclosure, the method further includes: obtaining a weight parameter of the CTU; adjusting the weight parameter of the CTU according to a target quantization parameter offset of the CTU to obtain an adjusted weight parameter; and filtering the CTU according to the adjusted weight parameter.
[0014] In some embodiments of the present disclosure, encoding the video frame to be processed according to the target quantization parameter offset of one or more of the CTUs includes: obtaining the quantization parameter of the video frame to be processed; adjusting the quantization parameter of the video frame to be processed according to the target quantization parameter offset of one or more of the CTUs to obtain the adjusted quantization parameter; encoding the video frame to be processed according to the adjusted quantization parameter.
[0015] An embodiment of the present disclosure provides a video encoding device, the device comprising: an acquisition unit, configured to acquire a video frame to be processed, the video frame to be processed comprising one or more coding tree units (CTUs); an offset determination unit, configured to determine error information of each CTU and acquire an initial quantization parameter offset of the CTU; the error information of the CTU is obtained during a motion estimation process, and the initial quantization parameter offset of the CTU is generated during a bit rate control process; a target quantization parameter offset of the CTU is determined according to the initial quantization parameter offset of the CTU and the error information of the CTU; and an encoding unit, configured to perform encoding processing on the video frame to be processed according to the target quantization parameter offsets of one or more CTUs.
[0016] An embodiment of the present disclosure provides an electronic device, including: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the executable instructions to implement the above-mentioned video encoding method.
[0017] An embodiment of the present disclosure provides a computer-readable storage medium. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the above-mentioned video encoding method.
[0018] An embodiment of the present disclosure provides a computer program product, including a computer program, which implements the above-mentioned video encoding method when executed by a processor.
[0019] The video encoding method provided by the embodiment of the present disclosure can accurately determine the target quantization parameter offset of the CTU by combining the CTU initial quantization parameter offset generated in the bit rate control process and the CTU error information generated in the motion estimation process, and perform encoding processing based on the target quantization parameter offset, thereby solving the problem of quantization parameter deviation caused by directly applying the quantization parameter determined based on the source video that has not been filtered by MCTF to the video image after MCTF filtering, and effectively improving the encoding efficiency of the video.
[0020] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0022] Figure 1A schematic diagram showing the relationship between the rate control module and the MCTF module in the video coding framework;
[0023] Figure 2 A schematic diagram showing an exemplary system architecture to which the video encoding method according to the embodiment of the present disclosure can be applied;
[0024] Figure 3 A flowchart of a video encoding method according to an embodiment of the present disclosure is shown;
[0025] Figure 4 A process diagram of determining a target quantization parameter offset of a CTU according to an embodiment of the present disclosure is shown;
[0026] Figure 5 A process diagram of determining a target quantization parameter offset of a CTU according to an embodiment of the present disclosure is shown;
[0027] Figure 6 A schematic diagram of performing MCTF processing on a video frame to be processed according to an embodiment of the present disclosure is shown;
[0028] Figure 7 An architecture diagram of a video encoding method according to an embodiment of the present disclosure is shown;
[0029] Figure 8 A block diagram of a video encoding device according to an embodiment of the present disclosure is shown;
[0030] Fig. 9 A schematic structural diagram of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0031] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0032] The features, structures or characteristics described in the present disclosure may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring the various aspects of the present disclosure.
[0033] The collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of the user personal information involved in this disclosure are in compliance with the relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.
[0034] The accompanying drawings are only schematic diagrams of the present disclosure, and the same reference numerals in the drawings represent the same or similar parts, so their repeated description will be omitted. Some block diagrams shown in the accompanying drawings do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in at least one hardware module or integrated circuit, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0035] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and steps, nor must they be executed in the order described. For example, some steps can be decomposed, and some steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0036] In this specification, the terms "a", "an", "the", "said" and "at least one" are used to indicate the presence of at least one element / component / etc.; the term "plurality" refers to two or more; the terms "comprising", "including" and "having" are used to express an open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first", "second" and "third" etc. are used only as labels and are not intended to limit the quantity of their objects.
[0037] Figure 1 The diagram shows the relationship between the bit rate control module and the MCTF module in the video coding framework. The bit rate control module is used to guide the encoder to encode each image block in the video image, so as to maximize the video compression efficiency. The bit rate control module analyzes the input source video and determines the quantization parameter used to control the image compression quality. The quantization parameter value is inversely correlated with the image quality. The lower the quantization parameter, the higher the image quality. MCTF is a pre-coding processing filtering algorithm widely used by many coding standards. The algorithm is used to remove the temporal noise of the video before encoding, so as to improve the overall coding compression rate of the video.
[0038] like Figure 1As shown, in the video encoding process, the MCTF module is placed after the bit rate control module. After MCTF processing, the source video is filtered and modified, which makes the quantization parameters determined based on the source video used in the video image after MCTF filtering, resulting in deviations in the quantization parameters, affecting the encoding efficiency of the encoder.
[0039] In the related art, a method for adjusting the quantization parameters of video images after MCTF filtering is proposed. The method takes the Coding Tree Unit (CTU) as a unit, and mainly adjusts the quantization parameter of the CTU according to the error value between the CTU and the corresponding matching block calculated by MCTF in the motion compensation module to obtain the quantization parameter offset of the CTU.
[0040] However, this quantization parameter adjustment method does not take into account the impact of the bit rate control module. The bit rate control module calculates the corresponding quantization parameter offset for the CTU in each frame based on the characteristics of the video content. Since the quantization parameter offset of the CTU calculated by the bit rate control module is very similar to the quantization parameter offset of the CTU calculated by the above quantization parameter adjustment method, this shows that when the bit rate control is turned on, the quantization parameter offset calculated by the above quantization parameter adjustment method will not have an effective adjustment result.
[0041] For example, assuming that the CTU currently requires a quantization parameter offset of -2, and the rate control module and the above quantization parameter adjustment method both calculate -2, then the combined effect of the two will cause the quantization parameter of the CTU to be added with a quantization parameter offset of -4, resulting in an error.
[0042] Based on this, the embodiment of the present disclosure provides a video encoding method, which solves the problem of errors in quantization parameters caused by the inconsistency between the video processed by the rate control module and the actual encoded video due to the introduction of MCTF in a coding framework having a rate control module and a MCTF module, thereby effectively improving the video encoding efficiency.
[0043] Figure 2 A schematic diagram showing an exemplary system architecture to which the video encoding method according to an embodiment of the present disclosure can be applied is shown.
[0044] like Figure 2 As shown, the system architecture may include a server 201, a network 202 and a terminal device 203. The network 202 is used to provide a medium for a communication link between the terminal device 203 and the server 201. The network 202 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0045] In an exemplary embodiment, the terminal device 203 for data transmission with the server 201 may include but is not limited to a smart phone, a tablet computer, a laptop computer, a smart speaker, a digital assistant, an AR (Augmented Reality) device, a VR (Virtual Reality) device, a smart wearable device, etc., or the terminal device 203 may also be a personal computer, such as a laptop computer and a desktop computer, etc. Optionally, the operating system running on the electronic device may include but is not limited to Android system, IOS system, Linux, Windows, etc.
[0046] Server 201 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. In some practical applications, server 201 can also be a server of a network platform, which can be, for example, a trading platform, a live broadcast platform, a social platform, or an audio platform, etc., which is not limited in the embodiments of the present disclosure. Among them, the server can be a single server or a cluster formed by multiple servers, and the present disclosure does not limit the specific architecture of the server.
[0047] In some embodiments of the present disclosure, the process of video encoding by server 201 may be: obtaining a video frame to be processed, the video frame to be processed includes one or more CTUs; for each CTU, determining the error information of the CTU, obtaining the initial quantization parameter offset of the CTU, and then determining the target quantization parameter offset of the CTU based on the initial quantization parameter offset of the CTU and the error information of the CTU; encoding the video frame to be processed based on the target quantization parameter offsets of one or more CTUs.
[0048] In addition, it should be noted that Figure 2 What is shown is only one application environment of the video encoding method provided by the present disclosure. Figure 2 The number of terminal devices 203, networks 202 and servers 201 is only for illustration, and any number of terminal devices, networks and servers may be provided according to actual needs.
[0049] Figure 3 A flowchart of a video encoding method according to an embodiment of the present disclosure is shown. Figure 3 The execution subject of the method provided in the embodiment may be any electronic device, such as Figure 2The server 201 in the embodiment is also as follows Figure 2 The terminal device 203 in Figure 2 The server 201 and the terminal device 203 in the embodiment jointly implement the video encoding method, but the present disclosure is not limited thereto. Figure 3 , the video encoding method provided by the embodiment of the present disclosure includes the following steps.
[0050] Step S310: obtaining a video frame to be processed, where the video frame to be processed includes one or more CTUs.
[0051] In the video encoding process, a video to be processed is obtained, that is, a video to be encoded, and the video to be processed includes one or more video frames to be processed. For each video frame to be processed, the video encoding method provided in steps S310 to S330 is used to encode the video frame to be processed.
[0052] The video frame to be processed is composed of a series of pixel data, which is further decomposed into smaller processing units, namely CTU. CTU can be regarded as the basic unit for segmenting video frames in video encoding. Specifically, it can be divided into blocks of different sizes according to different resolutions, such as 128x 128, 64x64, 32x32 and other sizes.
[0053] Step S320, for each CTU, determine the error information of the CTU and obtain the initial quantization parameter offset of the CTU; the error information of the CTU is obtained in the motion estimation process, and the initial quantization parameter offset of the CTU is generated in the bit rate control process; determine the target quantization parameter offset of the CTU according to the initial quantization parameter offset of the CTU and the error information of the CTU.
[0054] The error information of CTU is obtained during the motion estimation process, which reflects the difference between CTU and its matching block in the reference video frame. Motion estimation is a key technology in video coding standards, which aims to reduce temporal redundancy in the video by finding similar areas (i.e. matching blocks) in the current frame to those in the previous frame (or subsequent frame).
[0055] When analyzing each CTU in the processed video frame, the CTU is compared with the corresponding area in the reference video frame to obtain a matching block corresponding to the CTU, and then the difference between the CTU and the matching block is calculated, for example, the mean square error (MSE) and the sum of absolute differences (SAD) to form the error information of the CTU.
[0056] The initial quantization parameter offset of CTU is generated during the rate control process. During the rate control process, a basic quantization parameter is set for the video frame to be processed or a group of CTUs, and an initial quantization parameter offset is calculated for each CTU based on the content characteristics of the video frame to be processed and the global rate limit. This initial offset is to optimize the compression quality of each CTU while meeting the total rate limit.
[0057] After obtaining the error information and initial quantization parameter offset of the CTU, one or more strategies can be used to determine the target quantization parameter offset of the CTU. For example, for a CTU with a large error (i.e., an area with intense motion or complex texture), the target quantization parameter offset can be reduced (i.e., the quantization parameter is lowered) to reduce the quantization loss; conversely, for a CTU with a small error, the target quantization parameter offset can be increased (i.e., the quantization parameter is increased) to save bit rate.
[0058] Step S330 : encoding the video frame to be processed according to the target quantization parameter offset of one or more CTUs.
[0059] After obtaining the target quantization parameter offset of one or more CTUs in the video frame to be processed, the quantization parameter of each CTU is adjusted according to the target quantization parameter offset to control the compression ratio and distortion. This step involves predicting, transforming, quantizing, and entropy coding each CTU to ensure that each CTU can be properly coded according to its importance and complexity. Finally, the coded data of all CTUs in the video frame to be processed are assembled into a compressed video frame and output as a coded stream.
[0060] In the disclosed embodiment, by combining the CTU initial quantization parameter offset generated in the bit rate control process and the CTU error information generated in the motion estimation process, the target quantization parameter offset of the CTU can be accurately determined, and encoding processing is performed based on this target quantization parameter offset, thereby solving the problem of quantization parameter deviation caused by directly applying the quantization parameter determined based on the source video that has not been filtered by MCTF to the video image after MCTF filtering, thereby effectively improving the encoding efficiency of the video.
[0061] Furthermore, since the initial quantization parameter offset of CTU is generated by the bit rate control process, and the error information of CTU is generated in the motion estimation process, the target quantization parameter offset of CTU is obtained by combining the two, and finally encoding is performed based on this target quantization parameter offset, which effectively avoids the quantization parameter conflict and over-adjustment problems caused by the simultaneous action of two independent mechanisms, bit rate control and MCTF, and ensures that the calculated CTU target quantization parameter offset can play an effective adjustment result, thereby achieving the optimization of coding efficiency while ensuring video quality.
[0062] In some embodiments of the present disclosure, a CTU includes one or more first image blocks. Determining the error information of the CTU includes: for each first image block, obtaining a matching block of the first image block in a reference video frame; calculating an error between the first image block and the obtained matching block, and determining the calculated error value as the error information of the first image block; and performing mean calculation on the error information of the one or more first image blocks to obtain the error information of the CTU.
[0063] In the embodiment of the present disclosure, the first image block can be understood as a basic processing unit for calculating error information, and each CTU includes one or more first image blocks. The reference video frame refers to a reference video frame of the video frame to be processed, such as an adjacent video frame of the video frame to be processed.
[0064] For each first image block in the CTU, the reference video frame is searched for a block that is most similar to the first image block. This block is called a matching block. After obtaining the matching block of the first image block, the error between the first image block and the matching block, such as the pixel difference, is calculated, and the calculated error value is regarded as the error information of the first image block. The error information of each first image block in the CTU is obtained, and the average of these error information is calculated to obtain the error information of the CTU. Among them, the search process for the matching block involves motion estimation technology, and the matching block is found by comparing the similarity between the first image block and the candidate block in the reference video frame. Therefore, the error information of the CTU can be considered to be obtained in the motion estimation process.
[0065] The basic idea of MCTF is to reduce the difference between adjacent frames through motion estimation and compensation, and then use some form of filter (such as wavelet transform) to further remove the remaining redundancy. Motion estimation is an indispensable part of the MCTF process, which provides the necessary motion information for subsequent motion compensation and time domain filtering. Therefore, in the embodiment of the present disclosure, the error information of the CTU can be calculated during the motion estimation and compensation process of MCTF, and the first image block is the filtering unit when performing MCTF processing. For example, if MCTF is filtered in 8x8 blocks, the size of the first image block is 8x8. In the CTU size of 128x128, a total of 256 first image blocks can be included, that is, 256 filtering units of MCTF are included.
[0066] In the embodiment of the present disclosure, the error information of the first image block is the MSE between the first image block and the matching block, and the specific calculation formula is as follows:
[0067]
[0068] In formula (1), W and H are the width and height of the first image block. For example, if the size of the first image block is 8x8, then W and H are both equal to 8. SSD is the matching error between the first image block and the matching block. The specific calculation method is as follows:
[0069]
[0070] In formula (2), W and H are the width and height of the first image block, I1 and I2 represent the first image block and the matching block respectively, and (i, j) represents the pixel coordinates.
[0071] For each CTU, after obtaining the MSE of each first image block in the CTU, the error information of the CTU can be calculated according to the following formula:
[0072]
[0073] In formula (3), avgCTUMSE represents the error information of the CTU, and M represents the number of first image blocks in the CTU. For example, when the size of the CTU is 128x128 and the size of the first image block is 8x8, M is equal to 256.
[0074] In the disclosed embodiment, the error information of the CTU is obtained in the process of motion estimation. Since motion estimation is an indispensable part of the MCTF process, it provides necessary motion information for subsequent motion compensation and time domain filtering. Therefore, the error information of the CTU is calculated in the process of motion estimation and compensation of the MCTF. Specifically, the filter unit of the MCTF is taken as the first image block, and the error between the first image block and the matching block of the first image block in the reference video frame is calculated as the error information of the first image block. The error information of all the first image blocks in the CTU is averaged to obtain the error information of the CTU. In this way, the error information of the CTU can be calculated directly in the process of motion estimation and compensation of the MCTF, which avoids additional calculation processes, simplifies the algorithm flow, and improves calculation efficiency.
[0075] In some embodiments of the present disclosure, the CTU includes one or more second image blocks. The initial quantization parameter offset of the CTU is obtained, including: for each second image block, obtaining the initial quantization parameter offset of the second image block; the initial quantization parameter offset of the second image block is calculated in the process of performing bit rate control; the initial quantization parameter offset of the one or more second image blocks is averaged to obtain the initial quantization parameter offset of the CTU.
[0076] In the embodiment of the present disclosure, the second image block can be understood as a basic processing unit for calculating the initial quantization parameter offset, and each CTU includes one or more second image blocks.
[0077] In the process of bit rate control, in order to more finely control the video quality, a quantization parameter offset, that is, the initial quantization parameter offset deltaQp, is calculated for each second image block in the CTU according to the complexity of the video content. Then, the initial quantization parameter offsets of all second image blocks in the CTU are averaged to obtain the initial quantization parameter offset of the CTU. The specific calculation formula is as follows:
[0078]
[0079] In formula (4), avgCTUDQP represents the initial quantization parameter offset of CTU, N represents the number of second image blocks included in CTU, deltaQp i Indicates the initial quantization parameter offset of the i-th second image block. For example, if the size of the CTU is 128x128 and the size of the second image block is 16x16, then N is equal to 64.
[0080] In the disclosed embodiment, the initial quantization parameter offset of the CTU is determined using the quantization parameter offset calculated during the rate control process, and the target quantization parameter offset of the CTU is subsequently determined based on the initial quantization parameter offset of the CTU, so that the target quantization parameter offset of the CTU is used for encoding processing, thereby avoiding directly using the quantization parameter offset obtained during the rate control process, and being able to better balance the relationship between video quality and encoding efficiency while maintaining the rate control accuracy.
[0081] Figure 4 FIG. 2 shows a process diagram of determining a target quantization parameter offset of a CTU according to an embodiment of the present disclosure. Figure 4 , determining the target quantization parameter offset of a CTU may include the following steps.
[0082] Step S410: quantize the initial quantization parameter offset of the CTU to obtain a quantized initial quantization parameter offset.
[0083] In some embodiments of the present disclosure, an initial quantization parameter offset of a CTU is quantized to obtain a quantized initial quantization parameter offset, including: determining the initial quantization parameter offset of the CTU as a reference offset; traversing one or more CTUs and counting the number of CTUs whose initial quantization parameter offset is greater than the reference offset; calculating a ratio of the counted number of CTUs to the number of one or more CTUs, and determining the calculated ratio to be the quantized initial quantization parameter offset.
[0084] For each CTU, after obtaining the initial quantization parameter offset of the CTU, the initial quantization parameter offset of the CTU is quantized to obtain the quantized initial quantization parameter offset of the CTU. The specific quantization process is: for the current CTU, count the number of CTUs that are larger than the initial quantization parameter offset of the current CTU, and then calculate the proportion of the number of CTUs counted to the total CTUs. The calculation formula is as follows:
[0085]
[0086] In formula (5), cur represents the current CTU, avgCTUDQP cur Indicates the initial quantization parameter offset of the current CTU, CTUNUM indicates the number of CTUs in the video frame to be processed, bigDQPNum cur Indicates the avgCTUDQP of the current CTU. cur Formula (5) can be regarded as a conditional statement. When idx is equal to 1, first determine whether avgCTUDQP1>avgCTUDQP cur Whether this condition is true, if true, add 1, otherwise add 0, that is, do not add 1; idx ranges from 1 to CTUNUM, traverses each avgCTUDQP to see if it is true, and finally gets the avgCTUDQP that is higher than the current CTU cur Large number of CTUs.
[0087] In formula (6), DQPRatio cur Indicates the ratio of the number of CTUs counted to the total number of CTUs, that is, the initial quantization parameter offset of the current CTU after quantization.
[0088] Step S420: quantize the error information of the CTU to obtain quantized error information.
[0089] In some embodiments of the present disclosure, error information of a CTU is quantized to obtain quantized error information, including: determining the error information of the CTU as benchmark error information; traversing one or more CTUs and counting the number of CTUs whose error information is greater than the benchmark error information; calculating a ratio of the number of counted CTUs to the number of one or more CTUs, and determining the calculated ratio to be the quantized error information.
[0090] For each CTU, after obtaining the error information of the CTU, the error information of the CTU is quantized to obtain the quantized error information of the CTU. The specific quantization process is: for the current CTU, count the number of CTUs with greater error information than the current CTU, and then calculate the proportion of the number of CTUs counted to the total CTUs. The calculation formula is as follows:
[0091]
[0092] In formula (7), cur represents the current CTU, avgCTUMSE cur Indicates the error information of the current CTU, CTUNUM indicates the number of CTUs in the video frame to be processed, bigMSENum cur Indicates the avgCTUMSE calculated compared to the current CTU cur Formula (7) can be regarded as a conditional statement. When idx is equal to 1, first determine whether avgCTUMSE1>avgCTUMSE cur Whether this condition is true, if true, add 1, otherwise add 0, that is, do not add 1; idx ranges from 1 to CTUNUM, traverses each avgCTUMSE to see if it is true, and finally gets the avgCTUMSE higher than the current CTU cur Large number of CTUs.
[0093] In formula (8), MSERatio cur Indicates the ratio of the number of counted CTUs to the total CTUs, that is, the quantized error information of the current CTU.
[0094] In the disclosed embodiment, after obtaining the initial quantization parameter offset of each CTU, the initial quantization parameter offset of other CTUs in the video frame to be processed is used to quantize it, and the quantized initial quantization parameter offset of the CTU is obtained. After obtaining the error information of each CTU, the error information of other CTUs in the video frame to be processed is used to quantize it, and the quantized error information of the CTU is obtained. In this way, the encoding requirements of each CTU can be better evaluated through the quantized initial quantization parameter offset and quantized error information of each CTU.
[0095] Step S430: determining a target quantization parameter offset of the CTU based on the quantized initial quantization parameter offset and the quantized error information.
[0096] In the disclosed embodiment, the quantization parameter offset is negatively correlated with the encoding quality. The smaller the quantization parameter offset of a certain image block, the better the image block needs to be encoded. It can also be deduced that the initial quantization parameter offset avgCTUDQP of each CTU and the initial parameter offset DQPRatio after quantization are inversely correlated. When the initial quantization parameter offset avgCTUDQP of a CTU is smaller than the initial quantization parameter offset avgCTUDQP of other CTUs, it means that the CTU needs to be encoded better than other CTUs. In this case, the larger the initial quantization parameter offset DQPRatio of the CTU after quantization will be. In other words, the larger the initial quantization parameter offset DQPRatio of a CTU after quantization, the better the CTU needs to be encoded compared to other CTUs.
[0097] In the disclosed embodiment, the error information avgCTUMSE and the quantized error information MSERatio of each CTU are inversely correlated. When the error information avgCTUMSE of a CTU is larger than the error information of other CTUs, it means that the filtering strength of MCTF for the CTU is greater. This is because the greater the filtering strength, the greater the error between the image block and the matching block of the image block. At this time, the error information of the image block is also greater. In this case, the quantized error information MSERatio of the CTU will be smaller. In other words, the smaller the quantized error information MSERatio of a CTU, the greater the MCTF filtering strength corresponding to the CTU, indicating that the CTU needs to be encoded better than other CTUs.
[0098] Since the MCTF filter strength is positively correlated with the subsequent encoding quality, that is, the greater the MCTF filter strength of a certain image block, the better the image block needs to be encoded. Therefore, when the MCTF filter strength of a CTU is greater, the error information MSERatio of the CTU after quantization is smaller, and the initial quantization parameter offset avgCTUDQP of the CTU should be smaller than that of other CTUs, that is, the initial quantization parameter offset DQPRatio of the CTU after quantization is larger.
[0099] In the disclosed embodiment, after obtaining the initial quantization parameter offset after quantization of each CTU and the error information after quantization of each CTU, the target quantization parameter offset of the CTU is determined according to the following principle: the larger the initial quantization parameter offset DQPRatio after quantization of a CTU, the better the encoding of the CTU needs to be compared with other CTUs; the smaller the error information MSERatio after quantization of a CTU, the greater the MCTF filtering strength corresponding to the CTU, indicating that the CTU needs to be better encoded than other CTUs.
[0100] In some embodiments of the present disclosure, a target quantization parameter offset of a CTU is determined based on an initial quantization parameter offset after quantization and error information after quantization, including: if the error information after quantization is greater than a first error threshold and the initial quantization parameter offset after quantization is less than the first offset threshold, the target quantization parameter offset of the CTU is determined to be the first offset; if the error information after quantization is greater than a second error threshold and the initial quantization parameter offset after quantization is less than the second offset threshold, the target quantization parameter offset of the CTU is determined to be the second offset; if the error information after quantization is less than a third error threshold and the initial quantization parameter offset after quantization is greater than the third offset threshold, the target quantization parameter offset of the CTU is determined to be the third offset; if the error information after quantization is less than a fourth error threshold and the initial quantization parameter offset after quantization is greater than the fourth offset threshold, the target quantization parameter offset of the CTU is determined to be the fourth offset.
[0101] Among them, the first error threshold is greater than or equal to the second error threshold, the first offset threshold is less than or equal to the second offset threshold, the first offset and the second offset are less than 0, and the first offset is less than the second offset; the third error threshold is less than or equal to the fourth error threshold, the third offset threshold is greater than or equal to the fourth offset threshold, the third offset and the fourth offset are greater than 0, and the third offset is less than the fourth offset.
[0102] Figure 5 FIG. 2 shows a process diagram of determining a target quantization parameter offset of a CTU according to an embodiment of the present disclosure. Figure 5 For each CTU, the target quantization parameter offset DQP of the CTU is determined based on the initial quantization parameter offset DQPRatio and the quantized error information MSERatio of the CTU. PCDA The specific implementation includes the following steps.
[0103] Step S510, obtaining quantized error information MSERatio of the CTU and quantized initial quantization parameter offset DQPRatio of the CTU;
[0104] Step S520, determine whether the quantized error information MSERatio of the CTU is greater than the first error threshold T11, and whether the quantized initial quantization parameter offset DQPRatio of the CTU is less than the first offset threshold T21. If so, set the target quantization parameter offset DQPRatio of the CTU to PCDA Set to the first offset dqp1, otherwise jump to step S530;
[0105] Step S530, determine whether the quantized error information MSERatio of the CTU is greater than the second error threshold T12, and whether the quantized initial quantization parameter offset DQPRatio of the CTU is less than the second offset threshold T22. If so, set the target quantization parameter offset DQPRatio of the CTU to PCDA Set to the second offset dqp2, otherwise jump to step S540;
[0106] Step S540, determine whether the quantized error information MSERatio of the CTU is less than the third error threshold T13, and whether the quantized initial quantization parameter offset DQPRatio of the CTU is greater than the third offset threshold T23, if so, set the target quantization parameter offset DQPRatio of the CTU to PCDA Set to the third offset dqp3, otherwise jump to step S550;
[0107] Step S550, determine whether the quantized error information MSERatio of the CTU is less than the fourth error threshold T14, and whether the quantized initial quantization parameter offset DQPRatio of the CTU is greater than the fourth offset threshold T24, if so, set the target quantization parameter offset DQPRatio of the CTU to PCDA Set to the fourth offset dqp4;
[0108] Step S560: If the above conditions are not met, the target quantization parameter offset DQP of the CTU is PCDA Set to 0.
[0109] Among them, T11, T12, T13, T14, T21, T22, T23 and T24 are user-defined thresholds, dqp1, dqp2, dqp3 and dqp4 are user-defined offsets, and the following relationship needs to be satisfied: T11 is greater than or equal to T12; T13 is less than or equal to T14; T21 is less than or equal to T22; T23 is greater than or equal to T24; dqp1 and dqp2 are both less than 0, and dqp1 is less than dqp2; dqp3 and dqp4 are both greater than 0, and dqp4 is greater than dqp3.
[0110] It should be noted that the execution order of the condition judgment in the above steps S510 to S560 can be adjusted according to actual needs, and the embodiments of the present disclosure do not limit this.
[0111] For ease of understanding, the case where the quantized error information MSERatio of the CTU is greater than the first error threshold T11, and the initial quantization parameter offset DQPRatio of the CTU after quantization is less than the first offset threshold T21 is used for explanation. If the MSERatio of a CTU is large, a smaller quantization parameter should be assigned, and considering that the bit rate control module may have already considered this issue, for example, if the bit rate control module has assigned a quantization parameter less than 0 to the CTU, there is no need to assign a target quantization parameter offset DQP less than 0. PCDA The initial quantization parameter offset DQPRatio of the CTU after quantization can be used for screening. Since the initial quantization parameter offset DQPRatio of the CTU after quantization is relatively small, it means that the avgCTUDQP of the CTU is a larger value, that is, the rate control module allocates a larger quantization parameter offset to the CTU. Therefore, the quantization parameter of the CTU needs to be reduced and a DQP less than 0 is allocated to it. PCDA , that is, the first offset dqp1 is allocated to the CTU.
[0112] It should be noted that the first offset dqp1, the second offset dqp2, the third offset dqp3 and the fourth offset dqp4 are used to control the target quantization parameter offset DQP PCDA The size of the target quantization parameter offset DQP can be found by CTUs in different situations. PCDA The first offset dqp1 and the second offset dqp2 are both values less than 0, and the first offset dqp1 is smaller than the second offset dqp2; the third offset dqp3 and the fourth offset dqp4 are both values greater than 0, and the fourth offset dqp4 is greater than the third offset dqp3.
[0113] In a possible implementation, T11, T12, T13, T14, T21, T22, T23 and T24 are set to 0.8, 0.3, 0.7, 0.3, 0.1, 0.9, 0.3, 0.8, respectively, and dqp1, dqp2, dqp3 and dqp4 are set to -2, -1, 1, 2, respectively.
[0114] In the disclosed embodiment, when the error information of the CTU after quantization is large (i.e., greater than the first or second error threshold), the target quantization parameter offset of the CTU is set to the first or second offset less than 0, and the information loss in the encoding process can be reduced by reducing the quantization parameter offset (i.e., using a smaller quantization step), thereby improving the encoding quality. In particular, when the initial quantization parameter offset of the CTU after quantization is small (i.e., less than the first offset threshold), further reducing the offset (such as the first offset is less than the second offset) can more finely control the quantization process and reduce the quantization noise. Conversely, when the error information of the CTU after quantization is small (i.e., less than the third or fourth error threshold), the target quantization parameter offset of the CTU is set to the third or fourth offset greater than 0, and the quantization parameter offset can be increased (i.e., using a larger quantization step) to improve the encoding efficiency and reduce the amount of encoded data while ensuring a certain encoding quality.
[0115] Furthermore, by using different error thresholds and offset thresholds in combination, the amount of data required for encoding can be reduced by appropriately increasing the quantization step size while ensuring that the encoding quality is not significantly reduced, thereby improving the encoding efficiency. In addition, this design method based on thresholds and offsets is relatively simple and intuitive, easy to implement in the existing video encoding framework, and the encoding algorithm can be further expanded and optimized by adjusting or increasing the number of thresholds and offsets.
[0116] In some embodiments of the present disclosure, the video encoding method further includes: obtaining a weight parameter of the CTU; adjusting the weight parameter of the CTU according to a target quantization parameter offset of the CTU to obtain an adjusted weight parameter; and filtering the CTU according to the adjusted weight parameter.
[0117] Figure 6 A schematic diagram of performing MCTF processing on a video frame to be processed according to an embodiment of the present disclosure is shown. t To filter, first determine P t The reference video frame is Figure 6 in and P t The four adjacent frames before and after are denoted as P t-4 , P t-3 , P t-2 , P t-1 , P t+1 , P t+2 , P t+3 , P t+4 For example, if the video frame to be processed is the 8th frame, the 4th, 5th, 6th, 7th, 9th, 10th, 11th, and 12th frames are set as reference video frames.
[0118] P tBlock-level motion estimation is performed with the adjacent 8 frames to search for P t Each 8x8 first image block in the 8 reference video frames (as described above, the first image block is the MCTF filter unit) is a matching block in the 8 reference video frames, and the position offset of the matching block relative to the first image block is a motion vector (MV). t There are 8 reference frames, so P t Each 8x8 first image block in has 8 MVs, denoted as MV t-4 , MV t-3 , MV t-2 , MV, MV t+1 , MV t+2 , MV t+3 , MV t+4 ,like Figure 6 shown.
[0119] In the motion estimation process, after searching for the matching block of the 8x8 first image block, the block error E between the first image block and the matching block is calculated. The calculation method of E is as follows:
[0120]
[0121] In formula (9), SSD is the matching error between the first image block and the matching block, which has been explained in the above formula (2) and will not be repeated here. V represents the variance of the first image block, which is calculated as follows:
[0122]
[0123] Wherein, W and H are the width and height of the first image block, I1 represents the first image block, (i, j) represents the pixel coordinates, and μ represents the average pixel value of the first image block I1.
[0124] For each first image block, there are 8 matching blocks, each matching block corresponds to a block error E, so the block errors between the first image block and the 8 matching blocks are E t-4 ,E t-3 ,E t-2 ,E t-1 ,E t+1 ,E t+2 ,E t+3 ,E t+4 After obtaining the block errors between the first image block and the eight matching blocks, different weight parameters are assigned to the eight matching blocks and the first image block according to the obtained block errors, which are W t-4 ,W t-3 ,W t-2 ,W t-1 ,W t, W t+1 ,Wt+2 ,W t+3 ,W t+4 ,like Figure 6 shown.
[0125] Finally, the video frame P to be processed t Each 8x8 first image block in the image frame P is weighted in a certain proportion with the 8 matching blocks searched in the adjacent 8 reference video frames, and a total of 9 image blocks are weighted according to the assigned weight parameters to obtain the result of time domain filtering, that is, a filtered 8x8 image block, which will replace the video frame to be processed P t The original first image block in .
[0126] In the disclosed embodiment, the weight parameter of CTU can be understood as the weight parameter assigned during MCTF time domain filtering. For example, a CTU of 128x 128 size, a first image block of 8x8 size, and 256 first image blocks are included in the CTU. For each first image block, the weight parameter assigned when filtering the first image block is obtained, specifically including the weight parameter assigned to the matching block corresponding to each first image block and the first image block. The weight parameters assigned when filtering the 256 first image blocks constitute the weight parameters of the CTU.
[0127] The target quantization parameter offset is at the CTU level. For each first image block, the fine-tuning weight parameter w of the matching block corresponding to the first image block can be calculated according to the target quantization parameter offset of the CTU to which the first image block belongs. PCDA , will fine-tune the weight parameter w PCDA The weight parameter assigned by MCTF when filtering the first image block is multiplied to obtain the adjusted weight parameter, and the first image block and the matching block corresponding to the first image block are weighted in a certain proportion according to the adjusted weight parameter to obtain the result of time domain filtering, that is, the first image block after filtering.
[0128] In a possible implementation manner, for the cur-th CTU, that is, the current CTU, its specific w PCDA The export rules are as follows:
[0129] (1) Target quantization parameter offset DQP for CTU PCDA Greater than 0
[0130] If DQP PCDA is the first offset dqp1, then w PCDA The calculation formula is as follows:
[0131]
[0132] If DQP PCDA is the second offset dqp2, then wPCDA The calculation formula is as follows:
[0133]
[0134] (2) Target quantization parameter offset DQP for CTU PCDA Less than 0
[0135] If DQP PCDA is the third offset dqp3, then w PCDA The calculation formula is as follows:
[0136]
[0137] If DQP PCDA is the fourth offset dqp4, then w PCDA The calculation formula is as follows:
[0138]
[0139] After obtaining the current CTU w PCDA After that, for the first image block in the current CTU, different weight parameters assigned to the matching blocks of the first image block are obtained. For example, for the first image block, there are 8 matching blocks, and the weight parameter assigned when filtering the first image block is W t-4 ,W t-3 ,W t-2 ,W t-1 ,W t, W t+1 ,W t+2 ,W t+3 ,W t+4 , and these weight parameters are combined with the w of the current CTU PCDA The adjusted weight parameters, i.e., new weight parameters, are obtained by multiplying them together to obtain the first image block and the eight matching blocks by using the adjusted weight parameters to obtain the filtered first image block.
[0140] It should be noted that if the target quantization parameter offset DQP of CTU PCDA If it is 0, it means that there is no need to adjust the weight parameters of the CTU, that is, the weight parameters allocated by the MCTF to the first image block are directly used for filtering.
[0141] In the disclosed embodiment, the weight parameter of the MCTF filtering process is adjusted according to the target quantization parameter offset of the CTU, so that the filtering process in the encoding process is more accurate and efficient, and the adjustment of the weight parameter can reflect the importance or complexity of the CTU in the video frame, so as to allocate resources more reasonably in the encoding process. Filtering is one of the key steps in video encoding for removing coding noise and improving image quality. By adjusting the weight parameter according to the target quantization parameter offset of the CTU, the filtering process can be made more in line with the actual needs of the CTU, reducing unnecessary filtering operations while retaining more image details.
[0142] In some embodiments of the present disclosure, encoding processing is performed on a video frame to be processed according to a target quantization parameter offset of one or more CTUs, including: obtaining a quantization parameter of the video frame to be processed; adjusting the quantization parameter of the video frame to be processed according to the target quantization parameter offset of one or more CTUs to obtain an adjusted quantization parameter; and encoding processing is performed on the video frame to be processed according to the adjusted quantization parameter.
[0143] The quantization parameter of the video frame to be processed refers to a basic quantization parameter set for the video frame to be processed during the bit rate control process. For each CTU in the video frame to be processed, the quantization parameter of the video frame to be processed is adjusted according to the target quantization parameter offset of the CTU to obtain the adjusted quantization parameter of the CTU. The adjusted quantization parameters of all CTUs in the video frame to be processed constitute the adjusted quantization parameter set of the video frame to be processed, and these adjusted quantization parameters are used to encode the video frame to be processed.
[0144] In the disclosed embodiment, the target quantization parameter offset of each CTU is used to adjust the quantization parameter of the video frame to be processed and then the encoding process is performed, so that the encoding process will be more accurate, and the bit rate can be more effectively controlled while maintaining the video quality. In addition, since the quantization parameter finally used for encoding is obtained by adjusting the quantization parameter of the video frame to be processed according to the target quantization parameter offset of each CTU, that is, the quantization parameter finally used for encoding of each CTU is optimized according to its own characteristics, the quality of the encoded video will be more uniform, for example, important or complex areas will be more protected to avoid quality loss caused by over-compression, while relatively unimportant areas can accept greater compression to save bit rate.
[0145] Figure 7 FIG. 1 shows an architecture diagram of a video encoding method according to an embodiment of the present disclosure. Figure 7 As shown, between performing MCFT motion compensation and MCTF temporal filtering, the target quantization parameter offset DQP of the CTU is determined PCDA The target quantization parameter offset DQP of CTU has been described in detail above.PCDA The determination process of , will not be repeated here. And, using the target quantization parameter offset DQP of CTU PCDA Adjust the weight of MCTF temporal filtering. Use the target quantization parameter offset DQP of CTU PCDA And the quantization parameter QP generated by the bit rate control module rc A new quantization parameter QP is obtained, and encoding processing is performed using the new quantization parameter QP.
[0146] In the disclosed embodiment, by combining the CTU initial quantization parameter offset generated in the bit rate control process and the CTU error information generated in the motion estimation process, the target quantization parameter offset of the CTU can be accurately determined, and encoding processing is performed based on this target quantization parameter offset, thereby solving the problem of quantization parameter deviation caused by directly applying the quantization parameter determined based on the source video that has not been filtered by MCTF to the video image after MCTF filtering, thereby effectively improving the encoding efficiency of the video.
[0147] Furthermore, since the initial quantization parameter offset of CTU is generated by the bit rate control process, and the error information of CTU is generated in the motion estimation process, the target quantization parameter offset of CTU is obtained by combining the two, and finally encoding is performed based on this target quantization parameter offset, which effectively avoids the quantization parameter conflict and over-adjustment problems caused by the simultaneous action of two independent mechanisms, bit rate control and MCTF, and ensures that the calculated CTU target quantization parameter offset can play an effective adjustment result, thereby achieving the optimization of coding efficiency while ensuring video quality.
[0148] It can be understood that the same / similar parts between the various embodiments of the above method in this specification can refer to each other, and each embodiment focuses on the differences from other embodiments. For related points, please refer to the description of other method embodiments.
[0149] Figure 8 FIG. 4 is a block diagram of a video encoding device according to an embodiment of the present disclosure. Figure 8 As shown, the device 800 includes an acquisition unit 810, an offset determination unit 820 and an encoding unit 830.
[0150] The acquisition unit 810 is configured to acquire a video frame to be processed, and the video frame to be processed includes one or more coding tree units CTU. The offset determination unit 820 is configured to determine the error information of each CTU and acquire the initial quantization parameter offset of the CTU, wherein the error information of the CTU is obtained during the motion estimation process, and the initial quantization parameter offset of the CTU is generated during the bit rate control process; according to the initial quantization parameter offset of the CTU and the error information of the CTU, the target quantization parameter offset of the CTU is determined. The encoding unit 830 is configured to encode the video frame to be processed according to the target quantization parameter offset of one or more CTUs.
[0151] In some embodiments of the present disclosure, the CTU includes one or more first image blocks; wherein the offset determination unit 820 is further configured to: for each first image block, obtain a matching block of the first image block in a reference video frame; calculate an error between the first image block and the obtained matching block, and determine the calculated error value as error information of the first image block; and perform mean calculation on the error information of the one or more first image blocks to obtain error information of the CTU.
[0152] In some embodiments of the present disclosure, the CTU includes one or more second image blocks; wherein the offset determination unit 820 is further configured to: for each second image block, obtain an initial quantization parameter offset of the second image block, the initial quantization parameter offset of the second image block being calculated during the process of performing bit rate control; perform mean calculation on the initial quantization parameter offsets of the one or more second image blocks to obtain an initial quantization parameter offset of the CTU.
[0153] In some embodiments of the present disclosure, the offset determination unit 820 is further configured to: quantize the initial quantization parameter offset of the CTU to obtain the quantized initial quantization parameter offset; quantize the error information of the CTU to obtain the quantized error information; and determine the target quantization parameter offset of the CTU based on the quantized initial quantization parameter offset and the quantized error information.
[0154] In some embodiments of the present disclosure, the offset determination unit 820 is further configured to: determine the initial quantization parameter offset of the CTU as a reference offset; traverse one or more CTUs, and count the number of CTUs whose initial quantization parameter offset is greater than the reference offset; calculate the ratio of the counted number of CTUs to the number of one or more CTUs, and determine the calculated ratio as the quantized initial quantization parameter offset.
[0155] In some embodiments of the present disclosure, the offset determination unit 820 is further configured to: determine that the error information of the CTU is the benchmark error information; traverse one or more CTUs, and count the number of CTUs whose error information is greater than the benchmark error information; calculate the ratio of the number of counted CTUs to the number of one or more CTUs, and determine that the calculated ratio is the quantized error information.
[0156] In some embodiments of the present disclosure, the offset determination unit 820 is further configured to: if the quantized error information is greater than the first error threshold, and the initial quantization parameter offset after quantization is less than the first offset threshold, then determine the target quantization parameter offset of the CTU to be the first offset; if the quantized error information is greater than the second error threshold, and the initial quantization parameter offset after quantization is less than the second offset threshold, then determine the target quantization parameter offset of the CTU to be the second offset; if the quantized error information is less than the third error threshold, and the initial quantization parameter offset after quantization is greater than the third offset threshold, then determine the target quantization parameter offset of the CTU to be the third offset; if the quantized error information is less than the fourth error threshold, and the initial quantization parameter offset after quantization is greater than the fourth offset threshold, then determine the target quantization parameter offset of the CTU to be the fourth offset.
[0157] In some embodiments of the present disclosure, the first error threshold is greater than or equal to the second error threshold, the first offset threshold is less than or equal to the second offset threshold, the first offset and the second offset are less than 0, and the first offset is less than the second offset; the third error threshold is less than or equal to the fourth error threshold, the third offset threshold is greater than or equal to the fourth offset threshold, the third offset and the fourth offset are greater than 0, and the third offset is less than the fourth offset.
[0158] In some embodiments of the present disclosure, the device 800 also includes a filtering unit 840, which is configured to: obtain a weight parameter of the CTU; adjust the weight parameter of the CTU according to a target quantization parameter offset of the CTU to obtain an adjusted weight parameter; and filter the CTU according to the adjusted weight parameter.
[0159] In some embodiments of the present disclosure, the encoding unit 830 is further configured to: obtain a quantization parameter of a video frame to be processed; adjust the quantization parameter of the video frame to be processed according to a target quantization parameter offset of one or more CTUs to obtain an adjusted quantization parameter; and encode the video frame to be processed according to the adjusted quantization parameter.
[0160] Regarding the device in the above embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.
[0161] Fig. 9FIG. 1 is a schematic diagram showing the structure of an electronic device according to an embodiment of the present disclosure. It should be noted that: Fig. 9 The electronic device 900 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0162] like Fig. 9 As shown, the electronic device 900 is in the form of a general computing device. The components of the electronic device 900 may include but are not limited to: at least one processing unit 910, at least one storage unit 920, and a bus 930 connecting different system components (including the storage unit 920 and the processing unit 910).
[0163] The storage unit stores program codes, which can be executed by the processing unit 910, so that the processing unit 910 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 910 can perform the following steps: Figure 3 Follow the steps shown in .
[0164] The storage unit 920 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 9201 and / or a cache storage unit 9202 , and may further include a read-only storage unit (ROM) 9203 .
[0165] The storage unit 920 may also include a program / utility 9204 having a set (at least one) of program modules 9205, such program modules 9205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0166] Bus 930 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0167] The electronic device 900 may also communicate with one or more external devices 1000 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 900, and / or communicate with any device that enables the electronic device 900 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 950. Furthermore, the electronic device 900 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 940. As shown, the network adapter 940 communicates with other modules of the electronic device 900 via a bus 930. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0168] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.
[0169] The program product for implementing the above method according to the embodiment of the present invention may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.
[0170] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0171] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0172] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0173] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0174] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0175] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0176] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0177] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
[0178] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A video encoding method, characterized in that: The method comprises: Acquire a video frame to be processed, where the video frame to be processed includes one or more coding tree units CTU; For each of the CTUs, error information of the CTU is determined, and an initial quantization parameter offset of the CTU is obtained; the error information of the CTU is obtained during motion estimation, and the initial quantization parameter offset of the CTU is generated during rate control; a target quantization parameter offset of the CTU is determined according to the initial quantization parameter offset of the CTU and the error information of the CTU; The to-be-processed video frame is encoded according to the target quantization parameter offset of one or more CTUs.
2. The method according to claim 1, characterized in that The CTU includes one or more first image blocks; The determining the error information of the CTU includes: For each of the first image blocks, obtaining a matching block of the first image block in a reference video frame; calculating an error between the first image block and the obtained matching block, and determining the calculated error value as error information of the first image block; Perform mean calculation on error information of one or more of the first image blocks to obtain error information of the CTU.
3. The method according to claim 1, characterized in that The CTU includes one or more second image blocks; The obtaining of the initial quantization parameter offset of the CTU includes: For each of the second image blocks, an initial quantization parameter offset of the second image block is obtained; the initial quantization parameter offset of the second image block is calculated during the process of performing bit rate control; Perform a mean calculation on the initial quantization parameter offsets of one or more of the second image blocks to obtain an initial quantization parameter offset of the CTU.
4. The method according to claim 1, characterized in that: The determining, according to the initial quantization parameter offset of the CTU and the error information of the CTU, a target quantization parameter offset of the CTU includes: Quantizing the initial quantization parameter offset of the CTU to obtain a quantized initial quantization parameter offset; quantizing the error information of the CTU to obtain quantized error information; Based on the quantized initial quantization parameter offset and the quantized error information, a target quantization parameter offset of the CTU is determined.
5. The method according to claim 4, characterized in that The quantizing the initial quantization parameter offset of the CTU to obtain the quantized initial quantization parameter offset includes: Determine an initial quantization parameter offset of the CTU as a reference offset; Traversing the one or more CTUs, and counting the number of CTUs whose initial quantization parameter offset is greater than the reference offset; A ratio of the number of the counted CTUs to the number of the one or more CTUs is calculated, and the calculated ratio is determined as the initial quantization parameter offset after quantization.
6. The method according to claim 4, characterized in that The quantizing the error information of the CTU to obtain quantized error information includes: Determining the error information of the CTU as reference error information; Traversing the one or more CTUs, and counting the number of CTUs whose error information is greater than the benchmark error information; A ratio of the number of the statistically calculated CTUs to the number of the one or more CTUs is calculated, and the calculated ratio is determined as the quantized error information.
7. The method according to claim 4, characterized in that The determining, based on the quantized initial quantization parameter offset and the quantized error information, a target quantization parameter offset of the CTU includes: If the quantized error information is greater than a first error threshold, and the quantized initial quantization parameter offset is less than a first offset threshold, determining that the target quantization parameter offset of the CTU is the first offset; If the quantized error information is greater than a second error threshold, and the quantized initial quantization parameter offset is less than a second offset threshold, determining that the target quantization parameter offset of the CTU is the second offset; If the quantized error information is less than a third error threshold, and the quantized initial quantization parameter offset is greater than a third offset threshold, determining that the target quantization parameter offset of the CTU is a third offset; If the quantized error information is less than a fourth error threshold, and the quantized initial quantization parameter offset is greater than a fourth offset threshold, then the target quantization parameter offset of the CTU is determined to be a fourth offset.
8. The method according to claim 7, characterized in that The first error threshold is greater than or equal to the second error threshold, the first offset threshold is less than or equal to the second offset threshold, the first offset and the second offset are less than 0, and the first offset is less than the second offset; The third error threshold is less than or equal to the fourth error threshold, the third offset threshold is greater than or equal to the fourth offset threshold, the third offset and the fourth offset are greater than 0, and the third offset is less than the fourth offset.
9. The method according to claim 1, characterized in that: The method further comprises: Obtaining a weight parameter of the CTU; Adjusting a weight parameter of the CTU according to a target quantization parameter offset of the CTU to obtain an adjusted weight parameter; The CTU is filtered according to the adjusted weight parameter.
10. The method according to claim 1, characterized in that The encoding process of the to-be-processed video frame according to the target quantization parameter offset of one or more CTUs includes: Obtaining a quantization parameter of the video frame to be processed; Adjusting the quantization parameter of the to-be-processed video frame according to the target quantization parameter offset of one or more CTUs to obtain an adjusted quantization parameter; The to-be-processed video frame is encoded according to the adjusted quantization parameter.
11. A video encoding device, characterized in that: The device comprises: An acquisition unit is configured to acquire a video frame to be processed, where the video frame to be processed includes one or more coding tree units CTU; an offset determination unit, configured to determine, for each CTU, error information of the CTU, and obtain an initial quantization parameter offset of the CTU; the error information of the CTU is obtained during motion estimation, and the initial quantization parameter offset of the CTU is generated during rate control; and determine a target quantization parameter offset of the CTU according to the initial quantization parameter offset of the CTU and the error information of the CTU; The encoding unit is configured to perform encoding processing on the to-be-processed video frame according to a target quantization parameter offset of one or more of the CTUs.
12. An electronic device, characterized in that: include: processor; A memory for storing the processor executable instructions; wherein the processor is configured to execute the executable instructions to implement the video encoding method according to any one of claims 1 to 10.
13. A computer-readable storage medium, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the video encoding method according to any one of claims 1 to 10.
14. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the video encoding method according to any one of claims 1 to 10 is implemented.