A key frame-oriented bit rate control method and device
By dividing the key frames into sub-blocks and calculating the contribution cost of the coding units, and adopting the coding reference chain and intra-frame prediction method, the problems of low key frame compression rate and poor picture quality are solved, and higher compression rate and clarity are achieved.
Patent Information
- Application Number
- CN202310638476.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-31
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-05-31
AI Technical Summary
In the existing technology, the compression rate of key frames is low, resulting in poor image quality and serious error propagation problems. It is necessary to improve the bit rate control method to increase the compression rate and clarity of key frames.
The key frame is divided into several sub-blocks, and the coding unit contribution cost of each sub-block is calculated. A higher compression rate is achieved by compressing the redundancy between blocks within the frame, and the coding reference chain and intra-frame prediction method are used to optimize the bit rate distribution.
The image quality and compression rate of key frames are improved, ensuring that each sub-block obtains the best bit rate allocation and reducing error propagation.
Smart Images

Figure CN116723316B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video coding, and in particular to a key frame-oriented bit rate control method and device. Background Art
[0002] With the development of the times, whether it is video calls or live broadcasts on demand, users' demand for frame rates is also increasing. Therefore, in the video encoding process, due to the reference relationship between frames, if there is an abnormality in an intermediate frame, all subsequent images that refer to the abnormal frame will be erroneous. Therefore, in order to prevent the spread of errors and the superposition of errors, the existence of key frames is very important.
[0003] Since the compression rate of key frames is too low compared to P frames, the effect of using key frames as a reference is not good, so it is necessary to perform appropriate bit rate control on key frames to increase the compression rate while improving image quality. Summary of the Invention
[0004] The present invention provides a key frame-oriented bit rate control method and device, which can allocate the best bit rate to the key frame and improve the clarity and compression rate of the key frame.
[0005] In order to solve the above technical problems, a first embodiment of the present invention provides a key frame-oriented bit rate control method, comprising:
[0006] Obtain a first key frame, and divide the first key frame into a plurality of sub-blocks;
[0007] Determine a number of coding units corresponding to each sub-block according to the coding unit allocation of each sub-block;
[0008] Calculate the contribution cost of each coding unit to the corresponding sub-block;
[0009] Add up all the contribution cost values corresponding to each sub-block to generate the coding cost value of each sub-block;
[0010] Calculate the quantization parameter of the corresponding sub-block according to the coding cost value of each sub-block;
[0011] The bit rate is allocated to the first key frame according to the quantization parameters of all sub-blocks.
[0012] The present invention first divides a key frame into several sub-blocks, wherein the position of each sub-block can overlap with several coding units. For each sub-block, the contribution cost values of the corresponding several coding units are added together to obtain the coding cost value of each sub-block. The quantization parameter of the sub-block can be calculated based on the coding cost value. The bit rate can be allocated based on the quantization parameters of all sub-blocks in the key frame. By compressing the redundancy between blocks in the frame to achieve a higher compression rate, each sub-block in the frame can obtain the best bit rate allocation, thereby improving the image quality of the key frame and increasing the compression rate.
[0013] Furthermore, the calculation of the contribution cost of each coding unit to the corresponding sub-block is specifically as follows:
[0014] Determine the coding reference chain of each coding unit;
[0015] Calculate the coding cost of each coding unit according to the coding reference chain of each coding unit;
[0016] According to the allocation of each coding unit in the corresponding sub-block, the contribution cost value of each coding unit to the corresponding sub-block is calculated.
[0017] The present invention calculates the contribution cost value of the coding unit, which requires first determining the coding reference chain of the coding unit. The coding cost value of each coding unit can be calculated based on the determined coding reference chain. According to the distribution of the coding unit in the corresponding sub-blocks, the contribution cost value of the coding unit to the corresponding sub-blocks can be calculated respectively, thereby improving the accuracy of the contribution cost value.
[0018] Furthermore, the coding reference chain of each coding unit is determined as follows:
[0019] determining a plurality of reference chains corresponding to the first coding unit;
[0020] Set each reference chain as a reference path in sequence, perform intra-frame spatial domain reference on the first coding unit, and calculate each generation value of the first coding unit under each reference path;
[0021] A reference chain with the smallest cost value is determined as the coding reference chain of the first coding unit, and the first coding unit is added to the end of the coding reference chain.
[0022] Each coding unit of the present invention has several reference chains, and each of the reference chains is used as a reference path. The cost value of the coding unit under each reference chain can be calculated, and the reference chain with the smallest cost value is determined as the coding reference chain of the coding unit, which can improve the efficiency and convenience of finding the best reference chain.
[0023] Furthermore, the determining of the coding reference chain of each coding unit further includes:
[0024] Performing intra-frame prediction on the first coding unit and calculating an intra-frame prediction cost;
[0025] If the intra prediction cost of the first coding unit is less than the cost values of the first coding unit under each reference path, constructing the first coding unit alone as a first reference chain;
[0026] The first reference chain is determined as a coding reference chain of the first coding unit.
[0027] When determining the reference chain of a coding unit, the present invention not only considers the existing reference chain, but also performs intra-frame prediction on itself and calculates the intra-frame prediction cost. If its own intra-frame prediction cost is lower than the cost of the existing reference chain, it can set itself as another reference chain as its own coding reference chain. In addition to the existing reference chain, the present invention also considers the situation of not referring to other coding units, calculates its own cost when performing intra-frame prediction, and compares it with the cost of the reference chain. This can more comprehensively consider and determine the coding reference chain of the coding unit, thereby improving the clarity of the key frame.
[0028] Furthermore, the calculation of the encoding cost of each encoding unit is specifically as follows:
[0029] According to each reference unit within the preset reference range, perform intra-frame spatial reference on the first coding unit respectively, and record the intra-frame spatial reference cost value corresponding to each reference unit;
[0030] Determine the minimum intra-frame spatial domain reference cost value among the intra-frame spatial domain reference cost values as the first intra-frame spatial domain reference cost value of the first coding unit;
[0031] Performing optimal intra-frame prediction on the first coding unit, and recording a first intra-frame prediction cost value of the first coding unit;
[0032] Calculate the total cost value of the reference chain where the first coding unit is located according to the spatial domain reference cost value and the first intra-frame prediction cost value within the first frame;
[0033] The total cost value of the reference chain where the first coding unit is located is determined as the coding cost value of the first coding unit.
[0034] The present invention provides a reference range for several reference units that can be referenced by the first coding unit. By performing an intra-frame spatial reference based on each reference unit, a first intra-frame spatial reference cost value can be obtained. By performing an optimal intra-frame prediction on the first coding unit itself, a first intra-frame prediction cost value can be obtained. Based on the formula and the two values obtained above, the total cost value of the reference chain in which the first coding unit resides can be calculated, thereby determining the coding cost value of the first coding unit. Both the intra-frame spatial reference cost value and the intra-frame prediction cost value are calculated under optimal conditions, which increases the reference value of the cost value and the accuracy of subsequent calculations.
[0035] Furthermore, the total cost value of the reference chain where the first coding unit is located is calculated based on the first intra-frame spatial domain reference cost value and the first intra-frame prediction cost value, specifically:
[0036]
[0037] Among them, Intra_cost′ is the first intra-frame prediction cost value of the first coding unit; IBC_cost′ is the first intra-frame spatial reference cost value of the first coding unit; CUTransCost′ is the current total cost value of the reference chain where the first coding unit is located; CUTransCostOri′ is the previous total cost value of the reference chain where the first coding unit is located.
[0038] Furthermore, the contribution cost of each coding unit to the corresponding sub-block is calculated based on the allocation of each coding unit in the corresponding sub-block, specifically:
[0039]
[0040] Among them, CU A is the contribution cost of the first coding unit to sub-block A; CUTransCost′ is the total cost of the reference chain where the first coding unit is located; S A is the area of the first coding unit in sub-block A, and S is the total area of the first coding unit.
[0041] Furthermore, the quantization parameter of the corresponding sub-block is calculated according to the coding cost value of each sub-block, specifically:
[0042]
[0043] Among them, QP CU is the quantization parameter of the sub-block; QP Frame is the quantization parameter of the current key frame; CUTransCost is the current total cost value of the reference chain where the coding unit corresponding to the sub-block is located; Intra_cost is the intra-frame prediction cost value of the sub-block; A is the formula coefficient.
[0044] The present invention provides a rate control method for key frames. The key frame is first divided into several sub-blocks, where the position of each sub-block can overlap with several coding units. For each sub-block, the contribution cost values of the corresponding coding units are added together to obtain the coding cost value of each sub-block. The quantization parameter of the sub-block can be calculated based on the coding cost value, and the rate can be allocated based on the quantization parameters of all sub-blocks in the key frame. The present invention can achieve a higher compression rate by compressing the redundancy between blocks within the frame, and perform rate control on the key frame, so that each sub-block in the frame can obtain the optimal rate allocation, thereby improving image quality.
[0045] Accordingly, the present invention provides a key frame-oriented bit rate control device, comprising: an acquisition module, a determination module, a first calculation module, a generation module, a second calculation module and an allocation module;
[0046] The acquisition module is used to acquire a first key frame and divide the first key frame into a plurality of sub-blocks;
[0047] The determining module is used to determine a number of coding units corresponding to each sub-block according to the coding unit allocation of each sub-block;
[0048] The first calculation module is used to calculate the contribution cost value of each coding unit to the corresponding sub-block;
[0049] The generating module is used to add all the contribution cost values corresponding to each sub-block to generate the coding cost value of each sub-block;
[0050] The second calculation module is used to calculate the quantization parameter of the corresponding sub-block according to the encoding cost value of each sub-block;
[0051] The allocation module is used to allocate bit rates for the first key frame according to the quantization parameters of all sub-blocks.
[0052] Furthermore, the first calculation module includes: a determination unit, a calculation unit and a generation unit;
[0053] The determining unit is used to determine the coding reference chain of each coding unit;
[0054] The calculation unit is used to calculate the coding cost value of each coding unit according to the coding reference chain of each coding unit;
[0055] The generating unit is used to generate a contribution cost value of each coding unit to the corresponding sub-block according to the allocation of each coding unit in the corresponding sub-block.
[0056] The present invention provides a rate control device for key frames. Based on the organic combination of modules, the key frame is divided into several sub-blocks, wherein the position of each sub-block can overlap with several coding units. The contribution cost values of the corresponding several coding units are added together for each sub-block to obtain the coding cost value of each sub-block. The quantization parameter of the sub-block can be calculated based on the coding cost value. The rate of the key frame can be allocated based on the quantization parameters of all sub-blocks in the key frame, thereby improving the clarity and compression rate of the key frame. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 A schematic flow chart of an embodiment of a key frame-oriented bit rate control method provided by the present invention;
[0058] Figure 2 A schematic flow chart of another embodiment of the key frame-oriented bit rate control method provided by the present invention;
[0059] Figure 3 A schematic diagram of image sub-block division provided by the present invention;
[0060] Figure 4 A schematic diagram of a reference chain provided by the present invention;
[0061] Figure 5 A schematic diagram of the coding unit allocation provided by the present invention;
[0062] Figure 6 This is a structural diagram of an embodiment of a key frame-oriented bit rate control device provided by the present invention. DETAILED DESCRIPTION
[0063] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0064] In describing the present invention, it should be understood that the terms used in the present invention are as follows:
[0065] 1. “SAD”: (Sum of Absolute Differences)
[0066] 2. “CU”: (Coding Unit) coding unit.
[0067] 3. “IBC”: (Intra Block Copy) intra-frame block copy.
[0068] 4. “QP”: (Quantized Parameter) quantization parameter.
[0069] See also Figure 1 , is a flow chart of an embodiment of a key frame-oriented bit rate control method provided by the present invention. The method includes steps 101 to 106, each of which is specifically as follows:
[0070] Step 101: Obtain a first key frame and divide the first key frame into several sub-blocks.
[0071] Step 102: Determine a number of coding units corresponding to each sub-block according to the allocation of coding units to each sub-block.
[0072] In this embodiment of the present invention, because intra-frame block copying uses correlation between blocks within a frame (not necessarily adjacent blocks) for reference, it can achieve a higher compression ratio by compressing the redundancy between blocks within the frame. Using intra-frame block copying, the present invention can perform rate control on key frames, ensuring that each sub-block within the frame receives the optimal rate allocation.
[0073] As an example of an embodiment of the present invention, see Figure 3 Figure 1 is a schematic diagram of image subblock partitioning provided by the present invention. To perform rate control on intra-block copies, it is necessary to first determine the minimum subblock NxN for QP allocation based on encoder requirements (complexity constraints) or factors such as resolution. The entire image is then segmented based on this NxN partitioning for subsequent encoding.
[0074] Step 103: Calculate the contribution cost of each coding unit to the corresponding sub-block.
[0075] In the embodiment of the present invention, see Figure 2 , is a flow chart of another embodiment of the key frame-oriented bit rate control method provided by the present invention. Step 103 of the method includes steps 201 to 203, each of which is specifically as follows:
[0076] Step 201: Determine the coding reference chain of each coding unit.
[0077] In the embodiment of the present invention, the determining of the coding reference chain of each coding unit is specifically as follows:
[0078] determining a plurality of reference chains corresponding to the first coding unit;
[0079] Set each reference chain as a reference path in sequence, perform intra-frame spatial domain reference on the first coding unit, and calculate each generation value of the first coding unit under each reference path;
[0080] A reference chain with the smallest cost value is determined as the coding reference chain of the first coding unit, and the first coding unit is added to the end of the coding reference chain.
[0081] In an embodiment of the present invention, after motion estimation is performed on a key frame, several reference chains will exist. The reference transfer relationship between two adjacent elements in the reference chain can be quantified. When a coding unit uses each reference chain as a reference path, the generation value of each coding unit at the time of reference is calculated respectively. By comparing the calculated generation values, the reference chain with the smallest cost value can be determined as the reference chain of the coding unit. This can fully consider and determine the coding reference chain of the coding unit, thereby improving the clarity of the key frame.
[0082] As an example of an embodiment of the present invention, see Figure 4, is a schematic diagram of a reference chain provided by the present invention. CU4 is the current coding unit to be encoded. The coding units above and to the left of CU4 have been encoded, while the units to the right and below CU4 have not been encoded. In the encoded area, the coding units with reference relationships can form a reference chain, such as Figure 4 In the CU3-CU2-CU1 chain, if CU4 has the smallest cost calculated with reference to CU3, then this reference chain can be selected as the reference, and CU4 can be added to the end of the reference chain, expanding the original reference chain from CU3-CU2-CU1 to CU4-CU3-CU2-CU1.
[0083] In the embodiment of the present invention, determining the coding reference chain of each coding unit further includes:
[0084] Performing intra-frame prediction on the first coding unit and calculating an intra-frame prediction cost;
[0085] If the intra prediction cost of the first coding unit is less than the cost values of the first coding unit under each reference path, constructing the first coding unit alone as a first reference chain;
[0086] The first reference chain is determined as a coding reference chain of the first coding unit.
[0087] In an embodiment of the present invention, when determining the reference chain of a coding unit, not only the existing reference chain can be considered, but also intra-frame prediction can be performed on itself to calculate the intra-frame prediction cost. If its own intra-frame prediction cost is lower than the cost of the existing reference chain, it can be set as another reference chain as its own coding reference chain. In addition to the existing reference chain, the situation of not referring to other coding units is also considered, and the cost value when performing intra-frame prediction on itself is calculated and compared with the cost value of the reference chain. This can more comprehensively consider and determine the coding reference chain of the coding unit, thereby improving the clarity of the key frame.
[0088] Step 202: Calculate the coding cost of each coding unit according to the coding reference chain of each coding unit.
[0089] In the embodiment of the present invention, the calculation of the encoding cost value of each encoding unit is specifically as follows:
[0090] According to each reference unit within the preset reference range, perform intra-frame spatial reference on the first coding unit respectively, and record the intra-frame spatial reference cost value corresponding to each reference unit;
[0091] Determine the minimum intra-frame spatial domain reference cost value among the intra-frame spatial domain reference cost values as the first intra-frame spatial domain reference cost value of the first coding unit;
[0092] Performing optimal intra-frame prediction on the first coding unit, and recording a first intra-frame prediction cost value of the first coding unit;
[0093] Calculate the total cost value of the reference chain where the first coding unit is located according to the spatial domain reference cost value and the first intra-frame prediction cost value within the first frame;
[0094] The total cost value of the reference chain where the first coding unit is located is determined as the coding cost value of the first coding unit.
[0095] In an embodiment of the present invention, since the encoding raster scan order is from top to bottom and left to right based on macroblocks, when encoding the current coding unit, the areas above and to the left of the current coding unit have already been encoded and can be used as a reference for the current coding unit. Therefore, the reference range of the coding unit can be set above or to the left of the coding unit (the encoded area), but cannot be set to the lower right of the coding unit (the unencoded area). Within the reference range, there are several reference units that the first coding unit can refer to. By performing an intra-frame spatial reference based on each reference unit, a first intra-frame spatial reference cost value can be obtained. By performing an optimal intra-frame prediction on the first coding unit itself, a first intra-frame prediction cost value can be obtained. Based on the formula and the two values obtained above, the total cost value of the reference chain in which the first coding unit is located can be calculated, thereby determining the encoding cost value of the first coding unit. Both the intra-frame spatial reference cost value and the intra-frame prediction cost value are calculated under optimal conditions, which improves the reference value of the cost value and the accuracy of subsequent calculations.
[0096] As an example of an embodiment of the present invention, the minimum intra-frame spatial domain reference cost of a coding unit can be calculated by calculating the SAD value between the coding unit and each reference unit, comparing the calculated SAD values corresponding to each reference unit, and finally taking the reference unit with the minimum SAD value as the best reference block of the current coding unit, and recording the above minimum SAD value as IBC_cost, and determining that the IBC_cost is the intra-frame spatial domain reference cost of the current coding unit. Then, the best intra-frame prediction is performed on the coding unit itself, and the calculated SAD value is recorded as Intra_cost, and determining that the Intra_cost is the intra-frame prediction cost of the current coding unit. Among them, SAD is only a measure of cost, and the present invention can also be measured by SATD or SSD.
[0097] In the embodiment of the present invention, the total cost value of the reference chain where the first coding unit is located is calculated based on the first intra-frame spatial domain reference cost value and the first intra-frame prediction cost value, specifically:
[0098]
[0099] Among them, Intra_cost′ is the first intra-frame prediction cost value of the first coding unit; IBC_cost′ is the first intra-frame spatial reference cost value of the first coding unit; CUTransCost′ is the current total cost value of the reference chain where the first coding unit is located; CUTransCostOri′ is the previous total cost value of the reference chain where the first coding unit is located.
[0100] In the embodiment of the present invention, after determining the reference chain of the coding unit, the coding unit will be added to the end of the reference chain to form a new reference chain. The coding cost value of the coding unit is equal to the total cost value of the reference chain where the coding unit is located, and the total cost value of the reference chain is an iterative value. Figure 4 For example, to calculate the coding cost of CU4, we need to first calculate the total cost when CU4 is added to the reference chain, that is, the total cost of CU3-CU2-CU1, and define this value as CUTransCostOri′. Combined with CU4's own intra-frame prediction cost and the intra-frame spatial reference cost, the total cost of CU4-CU3-CU2-CU1 can be calculated using the formula to determine the coding cost of CU4. If the coding unit is at the front end of the reference chain, CUTransCost is set to 0.
[0101] Step 203: Calculate the contribution cost of each coding unit to the corresponding sub-block according to the allocation of each coding unit in the corresponding sub-block.
[0102] In the embodiment of the present invention, the contribution cost of each coding unit to the corresponding sub-block is calculated according to the allocation of each coding unit in the corresponding sub-block, specifically:
[0103]
[0104] Among them, CU A is the contribution cost of the first coding unit to sub-block A; CUTransCost′ is the total cost of the reference chain where the first coding unit is located; S A is the area of the first coding unit in sub-block A, and S is the total area of the first coding unit.
[0105] In the embodiment of the present invention, see Figure 5 , a schematic diagram of the coding unit allocation provided by the present invention. Each coding unit can correspond to multiple sub-blocks, and the contribution cost of the coding unit to the corresponding sub-block can be calculated based on the overlapping area of the coding unit and the sub-block. Figure 5For example, if the coding unit in the middle does not belong to a complete sub-block, the cost of the coding unit can be weighted and allocated to the four sub-blocks surrounding the coding unit based on the area they occupy in the coding unit. The overlapping areas of the coding unit in the middle and the four surrounding sub-blocks are SA, SB, SC, and SD respectively. To calculate the contribution cost of the coding unit to the upper left sub-block, you can first calculate the coding cost of the coding unit, then calculate the ratio of the overlapping area of the coding unit and the upper left sub-block to the total area of the coding unit itself, that is, the ratio of SA to the total area S of the coding unit, and then calculate the contribution cost of the coding unit to the upper left sub-block based on the ratio. Similarly, to calculate the contribution cost of the upper right sub-block, you need to calculate the ratio of the overlapping area of the coding unit and the upper right sub-block to the total area of the coding unit itself, that is, the ratio of SB to the total area S of the coding unit. The remaining steps are the same as those for calculating the contribution cost of the upper left sub-block and are not repeated here.
[0106] Step 104: Add up all contribution cost values corresponding to each sub-block to generate a coding cost value for each sub-block.
[0107] In an embodiment of the present invention, a sub-block may correspond to multiple coding units. After calculating the contribution cost of each coding unit to the corresponding sub-block, these contribution cost values may be added together to obtain the coding cost value of the sub-block for subsequent rate control.
[0108] Step 105: Calculate the quantization parameter of the corresponding sub-block according to the coding cost of each sub-block.
[0109] In the embodiment of the present invention, the quantization parameter of the corresponding sub-block is calculated according to the coding cost value of each sub-block, specifically:
[0110]
[0111] Among them, QP is the quantization parameter of the sub-block; QP Frame is the quantization parameter of the current key frame; CUTransCost is the current total cost value of the reference chain where the coding unit corresponding to the sub-block is located; Intra_cost is the intra-frame prediction cost value of the sub-block; A is the formula coefficient.
[0112] In the embodiment of the present invention, after obtaining the coding cost value of the sub-block, the quantization parameter of the sub-block can be calculated according to the formula. In the above formula, QP FrameIt is the encoding quantization parameter of the current key frame, which can be obtained through the rate control model of the encoder. Intra_cost is the intra-frame prediction cost of the sub-block, which can be obtained by performing intra-frame prediction on the sub-block itself. Similar to the coding unit, the SAD value can also be calculated, and the calculated SAD value is recorded as the intra-frame prediction cost of the sub-block. Among them, SAD is only a measure of cost. The present invention can also be measured by SATD or SSD. CUTransCost is the current total cost of the reference chain where the coding unit of the sub-block corresponds to. Since a sub-block can correspond to multiple coding units, to calculate the quantization parameter of the sub-block, it is necessary to calculate the current total cost of the reference chain where all coding units are located, and then substitute it into the above formula for addition to calculate the quantization parameter of the sub-block.
[0113] Step 106: Perform bit rate allocation on the first key frame according to the quantization parameters of all sub-blocks.
[0114] In an embodiment of the present invention, bitrate allocation can be performed after the quantization parameters of all sub-blocks in a key frame are calculated. The bitrates of different regions of the key frame are allocated on demand through a related model. According to the principle of diminishing marginal returns, more bitrate is allocated to sub-blocks with higher cost values. That is, the smaller the QP value of the sub-block, the more bitrate is allocated. The opposite is true for sub-blocks with lower cost values. That is, the larger the QP value of the sub-block, the less bitrate is allocated. This improves the image quality of the key frame and increases the compression rate.
[0115] Correspondingly, such as Figure 6 , which is a schematic structural diagram of an embodiment of a key frame-oriented bit rate control device provided by the present invention, the device includes an acquisition module 301, a determination module 302, a first calculation module 303, a generation module 304, a second calculation module 305, and an allocation module 306;
[0116] The acquisition module 301 is used to acquire a first key frame and divide the first key frame into a plurality of sub-blocks;
[0117] The determination module 302 is configured to determine a number of coding units corresponding to each sub-block according to the coding unit allocation of each sub-block;
[0118] The first calculation module 303 is used to calculate the contribution cost of each coding unit to the corresponding sub-block;
[0119] The generating module 304 is used to add up all the contribution cost values corresponding to each sub-block to generate the coding cost value of each sub-block;
[0120] The second calculation module 305 is used to calculate the quantization parameter of the corresponding sub-block according to the encoding cost value of each sub-block;
[0121] The allocation module 306 is configured to allocate bit rates for the first key frame according to the quantization parameters of all sub-blocks.
[0122] In the embodiment of the present invention, the first calculation module 303 includes: a determination unit, a calculation unit and a generation unit;
[0123] The determination unit is used to determine the coding reference chain of each coding unit;
[0124] The calculation unit is used to calculate the coding cost value of each coding unit according to the coding reference chain of each coding unit;
[0125] The generating unit is configured to generate a contribution cost value of each coding unit to the corresponding sub-block according to the allocation of each coding unit in the corresponding sub-block.
[0126] In summary, the keyframe-oriented rate control method and apparatus provided by the embodiments of the present invention first divide the keyframe into several sub-blocks, where the position of each sub-block can overlap with several coding units. For each sub-block, the contribution cost values of the corresponding coding units are added together to obtain the coding cost value of each sub-block. The quantization parameter of the sub-block can be calculated based on the coding cost value, and the rate can be allocated based on the quantization parameters of all sub-blocks in the keyframe. The present invention can achieve a higher compression rate by compressing the redundancy between blocks within the frame, performing rate control on the keyframe, so that each sub-block within the frame can obtain the optimal rate allocation, thereby improving image quality.
[0127] The specific embodiments described above further illustrate the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A key frame-oriented bit rate control method, characterized in that: include: Obtain a first key frame, and divide the first key frame into a plurality of sub-blocks; Determine a number of coding units corresponding to each sub-block according to the coding unit allocation of each sub-block; Calculate the contribution cost of each coding unit to the corresponding sub-block; Add up all the contribution cost values corresponding to each sub-block to generate the coding cost value of each sub-block; Calculate the quantization parameter of the corresponding sub-block according to the coding cost value of each sub-block; Allocate bitrate for the first key frame according to the quantization parameters of all sub-blocks; The calculation of the contribution cost of each coding unit to the corresponding sub-block is specifically as follows: Determine the coding reference chain of each coding unit; Calculate the coding cost of each coding unit according to the coding reference chain of each coding unit; Calculate the contribution cost of each coding unit to the corresponding sub-block according to the allocation of each coding unit in the corresponding sub-block; The coding reference chain of each coding unit is determined as follows: determining a plurality of reference chains corresponding to the first coding unit; Set each reference chain as a reference path in sequence, perform intra-frame spatial domain reference on the first coding unit, and calculate each generation value of the first coding unit under each reference path; Determine a reference chain with the smallest cost value as the coding reference chain of the first coding unit, and add the first coding unit to the end of the coding reference chain; The determining of the coding reference chain of each coding unit further includes: Performing intra-frame prediction on the first coding unit and calculating an intra-frame prediction cost; If the intra prediction cost of the first coding unit is less than the cost values of the first coding unit under each reference path, constructing the first coding unit alone as a first reference chain; The first reference chain is determined as a coding reference chain of the first coding unit.
2. The key frame-oriented bit rate control method according to claim 1, characterized in that: The calculation of the encoding cost value of each encoding unit is specifically as follows: According to each reference unit within the preset reference range, perform intra-frame spatial reference on the first coding unit respectively, and record the intra-frame spatial reference cost value corresponding to each reference unit; Determine the minimum intra-frame spatial domain reference cost value among the intra-frame spatial domain reference cost values as the first intra-frame spatial domain reference cost value of the first coding unit; Performing optimal intra-frame prediction on the first coding unit, and recording a first intra-frame prediction cost value of the first coding unit; Calculate the total cost value of the reference chain where the first coding unit is located according to the spatial domain reference cost value and the first intra-frame prediction cost value within the first frame; The total cost value of the reference chain where the first coding unit is located is determined as the coding cost value of the first coding unit.
3. The key frame-oriented rate control method according to claim 2, characterized in that: The total cost value of the reference chain where the first coding unit is located is calculated according to the first intra-frame spatial domain reference cost value and the first intra-frame prediction cost value, specifically: in, is a first intra-frame prediction cost value of a first coding unit; is the first intra-frame spatial domain reference cost value of the first coding unit; is the current total cost value of the reference chain where the first coding unit is located; is the previous total cost value of the reference chain where the first coding unit is located.
4. The key frame-oriented rate control method according to claim 3, characterized in that: The contribution cost of each coding unit to the corresponding sub-block is calculated based on the allocation of each coding unit in the corresponding sub-block, specifically: in, is the contribution cost of the first coding unit to sub-block A; is the current total cost value of the reference chain where the first coding unit is located; is the area of the first coding unit in sub-block A, is the total area of the first coding unit.
5. The key frame-oriented rate control method according to claim 1, wherein: The quantization parameter of the corresponding sub-block is calculated according to the coding cost value of each sub-block, specifically: in, is the quantization parameter of the sub-block; is the quantization parameter of the current key frame; is the current total cost value of the reference chain where the coding unit of the sub-block corresponds to; is the intra prediction cost of the sub-block; A is the formula coefficient.
6. A key frame-oriented bit rate control device, characterized in that: include: an acquisition module, a determination module, a first calculation module, a generation module, a second calculation module, and an allocation module; The acquisition module is used to acquire a first key frame and divide the first key frame into a plurality of sub-blocks; The determining module is used to determine a number of coding units corresponding to each sub-block according to the coding unit allocation of each sub-block; The first calculation module is used to calculate the contribution cost value of each coding unit to the corresponding sub-block; The generating module is used to add all the contribution cost values corresponding to each sub-block to generate the coding cost value of each sub-block; The second calculation module is used to calculate the quantization parameter of the corresponding sub-block according to the encoding cost value of each sub-block; The allocation module is used to allocate bit rates for the first key frame according to the quantization parameters of all sub-blocks; The first calculation module includes: a determination unit, a calculation unit and a generation unit; The determining unit is used to determine the coding reference chain of each coding unit; The calculation unit is used to calculate the coding cost value of each coding unit according to the coding reference chain of each coding unit; The generating unit is used to generate a contribution cost value of each coding unit to the corresponding sub-block according to the allocation of each coding unit in the corresponding sub-block; the determining of the coding reference chain of each coding unit is specifically as follows: determining a plurality of reference chains corresponding to the first coding unit; Set each reference chain as a reference path in sequence, perform intra-frame spatial domain reference on the first coding unit, and calculate each generation value of the first coding unit under each reference path; Determine a reference chain with the smallest cost value as the coding reference chain of the first coding unit, and add the first coding unit to the end of the coding reference chain; The determining of the coding reference chain of each coding unit further includes: Performing intra-frame prediction on the first coding unit and calculating an intra-frame prediction cost; If the intra prediction cost of the first coding unit is less than the cost values of the first coding unit under each reference path, constructing the first coding unit alone as a first reference chain; The first reference chain is determined as a coding reference chain of the first coding unit.
Citation Information
Patent Citations
System and method for reducing video coding fluctuation
CN110832856A
Video coding method, device, system and computer readable storage medium
CN112584143A
Coding method and device, equipment and storage medium
CN114845105A