CN115550656A - I frame code rate control method and device suitable for hardware implementation - Google Patents

I frame code rate control method and device suitable for hardware implementation Download PDF

Info

Publication number
CN115550656A
CN115550656A CN202211134183.7A CN202211134183A CN115550656A CN 115550656 A CN115550656 A CN 115550656A CN 202211134183 A CN202211134183 A CN 202211134183A CN 115550656 A CN115550656 A CN 115550656A
Authority
CN
China
Prior art keywords
frame
intra
coding
coded
complexity
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211134183.7A
Other languages
Chinese (zh)
Inventor
刘鹏飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ASR Microelectronics Co Ltd
Original Assignee
ASR Microelectronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ASR Microelectronics Co Ltd filed Critical ASR Microelectronics Co Ltd
Priority to CN202211134183.7A priority Critical patent/CN115550656A/en
Publication of CN115550656A publication Critical patent/CN115550656A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/103Selection of coding mode or of prediction mode
    • H04N19/11Selection of coding mode or of prediction mode among a plurality of spatial predictive coding modes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/189Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the adaptation method, adaptation tool or adaptation type used for the adaptive coding
    • H04N19/19Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the adaptation method, adaptation tool or adaptation type used for the adaptive coding using optimisation based on Lagrange multipliers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention discloses an I frame code rate control method suitable for hardware implementation. And adopting a plurality of intra-frame coding modes to carry out preliminary screening on each image block to be coded, and screening out intra-frame coding mode candidates and intra-frame coding mode prediction costs corresponding to the intra-frame coding mode candidates. Screening intra-frame coding mode prediction costs corresponding to each intra-frame coding mode candidate of an image block to be coded, and selecting the minimum intra-frame coding mode prediction cost to represent the intra-frame coding complexity of the image block to be coded; and then taking the sum of the intra-frame coding complexity of all image blocks in the video frame as the intra-frame coding complexity of the video frame. And calculating the frame-level Lagrange multiplier of the I frame to be coded according to the actual coding bit number, the frame-level Lagrange multiplier and the intra-frame coding complexity of the previous coded I frame and by combining the target coding bit number and the intra-frame coding complexity of the I frame to be coded. The invention has the advantages of high calculation accuracy, low hardware overhead and low implementation cost.

Description

I frame code rate control method and device suitable for hardware implementation
Technical Field
The present invention relates to a video coding technology, and in particular, to a code rate control method.
Background
Video coding techniques characterize video information by compressing redundant components in a video picture and using as little data as possible. Common Video Coding standards include AVC (Advanced Video Coding, also known as h.264), HEVC (High Efficiency Video Coding, also known as h.265), and the like. Video coding techniques take image blocks as the most basic coding units. For example, in HEVC, the basic Unit of Coding is a CU (Coding Unit). A CU may be an image block of 64 pixels × 64 pixels, or 32 pixels × 32 pixels, or 16 pixels × 16 pixels, or 8 pixels × 8 pixels in size.
In order to remove information redundancy in spatial and temporal domains, an intra-coding (intra-coding) technique and an inter-coding (inter-coding) technique are used for video coding of an input video frame. The encoded video frames may be generally divided into I-frames that employ intra-coding techniques only, and P-frames and B-frames that employ a mixture of intra-coding techniques and inter-coding techniques. When the I frame is subjected to video coding, only an intra-frame coding technology is adopted, only the information of the video frame is used for coding, and the information of other coded video frames is not referred. All image blocks inside the I-frame are encoded as intra-coded blocks. When a P frame and a B frame are coded, an intra-frame coding technique and an inter-frame coding technique are mixed, and not only the information of the current video frame is used for coding, but also the information of one or more other coded video frames is referred to. Image blocks inside P and B frames may be encoded as intra-coded blocks or as inter-coded blocks. For each image block inside a P-frame and a B-frame, if the rate-distortion cost of the intra-coding technique is smaller, this image block will be coded as an intra-coded block; if the rate-distortion cost of using the inter-coding technique is smaller, this image block will be coded as an inter-coded block. For each input video frame, the type Of encoded frame is determined by a Group Of Pictures (GOP) parameter set by the user. Fig. 1 shows a common group of pictures structure, which includes I-frames, P-frames or B-frames.
In order to improve the video compression rate as much as possible, common video coding algorithms are usually lossy compression algorithms, such as AVC and HEVC. This causes the difference between the encoded and reconstructed video and the original video, i.e. the encoded and reconstructed video will be distorted. For lossy compression algorithms, the coding performance needs to be measured jointly by the coding bit Rate (Rate) and the coding-induced Distortion (distorsion). In the process of video coding, the coding bit rate and the coding distortion are mutually restricted and contradictory, for example, reducing the coding bit rate tends to increase the coding distortion, and reducing the coding distortion tends to increase the coding bit rate. Rate Distortion Optimization (RDO) is to reduce coding Distortion as much as possible at a certain coding bit Rate or reduce the coding bit Rate as much as possible at a certain coding Distortion. At present, in common video coding algorithms, a rate distortion optimization method based on a Lagrange multiplier lambda is adopted. Let D be the coding Distortion, R be the coding bit Rate, J be the coding Rate Distortion Cost (RD Cost), J = D + λ × R. The rate-distortion optimization method based on the lagrange multiplier λ can be expressed as min (J), where min () represents the minimum value. When the video is coded, each coding mode has the corresponding coding distortion D and the corresponding coding bit rate R, so that the coding rate distortion cost J corresponding to each coding mode can be calculated. And the coding mode with the minimum rate-distortion cost J is selected for video coding, so that the optimal coding performance can be obtained. The process of selecting the optimal coding Mode for each image block to be coded by the encoder through a rate-distortion optimization method is called Mode selection (Mode Decision) of the image block to be coded.
Referring to fig. 2, the conventional mode selection system for an image block to be encoded includes a video frame encoding type selection module 11, an intra-frame encoding mode prediction module 12, an inter-frame encoding mode prediction module 13, an intra-frame encoding mode rate distortion optimization module 14, an inter-frame encoding mode rate distortion optimization module 15, and an encoding mode selection module 16.
The video frame coding type selection module 11 determines the type of the current video frame to be coded according to group of picture (GOP) parameters set by a user, that is, determines whether the current video frame to be coded needs to be coded into an I frame, a P frame or a B frame.
The intra-frame coding mode prediction module 12 performs preliminary screening on a large number of intra-frame coding modes, and screens out one or more intra-frame coding mode candidates with the lowest prediction cost by calculating the prediction cost corresponding to each intra-frame coding mode. Similarly, the inter-frame coding mode prediction module 13 performs preliminary screening on a large number of inter-frame coding modes, and screens out one or more inter-frame coding mode candidates with the lowest prediction cost by calculating the prediction cost corresponding to each inter-frame coding mode.
The intra-frame coding mode rate-distortion optimization module 14 calculates an accurate rate-distortion cost for all intra-frame coding mode candidates, and takes the intra-frame coding mode with the smallest rate-distortion cost as the optimal intra-frame coding mode. Similarly, the interframe coding mode rate-distortion optimization module 15 calculates accurate rate-distortion costs for all interframe coding mode candidates, and takes the interframe coding mode with the minimum rate-distortion cost as the optimal interframe coding mode.
The encoding mode selection module 16 uses the optimal intra-frame encoding mode as the optimal encoding mode for the image block in the I frame, and uses the one with the smaller rate-distortion cost in the optimal intra-frame encoding mode and the optimal inter-frame encoding mode as the optimal encoding mode for the image block in the P frame or the B frame.
If the current video frame to be coded is an I frame, since the I frame only adopts an intra-frame coding technology, the image blocks inside the I frame are processed by the intra-frame coding mode prediction module 12, the intra-frame coding mode rate-distortion optimization module 14 and the coding mode selection module 16, and then the optimal coding mode of the image blocks is obtained. If the current video frame to be coded is a P frame or a B frame, because the P frame and the B frame adopt an intra-frame coding technology and an inter-frame coding technology in a mixed manner, the image blocks inside the video frame are processed by an intra-frame coding mode prediction module 12, an inter-frame coding mode prediction module 13, an intra-frame coding mode rate distortion optimization module 14, an inter-frame coding mode rate distortion optimization module 15 and a coding mode selection module 16, and then the optimal coding mode of the image blocks is obtained. It can be seen that no matter the frame is an I frame, a P frame or a B frame, the image blocks inside the frame need to pass through the intra-coding mode prediction module 12 to calculate the prediction cost corresponding to the intra-coding mode.
In essence, the coding mode prediction modules 12 and 13 and the coding mode rate-distortion optimization modules 14 and 15 are both methods for performing rate-distortion optimization to screen the coding modes of the image block. The two modules are different mainly in the precision of the adopted cost calculation method. In the prediction modules 12 and 13 of the coding mode, a cost calculation method with less calculation amount and lower precision is generally adopted, the distortion cost is generally calculated by using SAD (Sum of Absolute Difference) algorithm or SATD (Sum of Absolute Difference) algorithm, the coding bit rate cost is generally calculated by using a simplified bit rate estimation algorithm such as exponential-Golomb coding (exponential-Golomb coding) algorithm, and the coding mode prediction stage does not generally introduce transformation and quantization operations. In a rate-distortion optimization module of a Coding mode, a cost calculation method with a large calculation amount and high precision is generally adopted, SSD (Sum of Squared errors) algorithm is generally used for calculating distortion cost, context-based Adaptive Binary arithmetic Coding (CABAC) algorithm or CAVLC (Context-based Adaptive Variable Length Coding, context-Adaptive Variable Length Coding) algorithm is generally used for calculating Coding bit rate cost, and transform and quantization operation are generally introduced in a Coding mode rate-distortion optimization stage. Conventionally, the rate-distortion cost calculated by the coding mode prediction modules 12 and 13 is referred to as the prediction cost of the coding mode.
In real life, the channel bandwidth (channel capacity) for transmitting compressed video is limited. If the coding bit rate of the compressed video is too high and exceeds the capacity of the channel bandwidth, the video transmission congestion and even packet loss can be caused. If the coding bit rate of the compressed video is too low, the channel bandwidth is not fully utilized, and higher video quality cannot be obtained. Therefore, it is necessary to use a rate control technique to control the output rate of the video encoder to match the channel bandwidth.
The Rate Control (Rate Control) technology is to adjust the encoding parameters of the video encoder to make the output Rate of the video encoder equal to the preset target Rate, and reduce the encoding distortion as much as possible to improve the video encoding quality. Currently, in an HEVC reference encoder HM (High Efficiency Video Coding Test Model), an adopted rate control algorithm is based on the JCTVC-K0103 proposal. The JCTVC-K0103 proposal establishes a mathematical relation model (namely an R-lambda model) of the coding bit rate R and the Lagrange multiplier lambda, and realizes a code rate control task through two links of target bit allocation and target bit control.
In the JCTVC-K0103 proposal, target bit allocation is performed at three levels, namely, a GOP (Group Of Pictures, i.e., a set Of temporally continuous video frames) level, a video frame level, and a basic coding unit level. After the target bit distribution of the video frame level is carried out, the target coding bit number of the current video frame to be coded is determined, and the value of the Lagrange multiplier (frame-level Lagrange multiplier) lambda of the current video frame to be coded is calculated according to an R-lambda model provided in the JCTVC-K0103 proposal: λ = α bpp β . Wherein, λ is Lagrange multiplier of current video frame to be coded; alpha and beta are R-lambda model parameters, the values of which are determined by video content and encoder configuration parameters and are continuously updated along with the progress of the encoding process; bpp, i.e. the number of bits per pixel (bit per pixel), represents the average target coding bit number allocated to each pixel, and its value is the quotient of the target coding bit number of the video frame to be coded and the number of pixels of the video frame. After the lagrangian multiplier λ of the current video frame to be encoded is calculated, λ can be used for rate distortion optimization in the encoding process.
Because the video coding algorithm has a large amount of operation, in order to increase the video coding speed and realize real-time coding and transmission, it is a common practice in the industry to use an Application Specific Integrated Circuit (ASIC) to accelerate the hardware of the video coding process. Such application specific integrated circuits that hardware accelerate the video encoding process are commonly referred to as hardware video encoders.
Rate control of I-frames has been a difficult point in hardware video encoders. This is because, in the conventional JCTVC-K0103 proposal, the rate control parameters (α and β) of the I frame are empirical values, and there is no direct relationship with the complexity of the content of the I frame. This results in a large error of the calculated frame-level lagrange multiplier λ, and finally results in a large difference between the actual coded bit number of the I frame and the target bit number, which causes a severe instantaneous code rate fluctuation. If the frame-level Lagrange multiplier lambda of the I frame needs to be accurately calculated, a special image preprocessing stage needs to be added before the I frame is coded to evaluate and calculate the content complexity of the I frame. And then adjusting parameters of a code rate control algorithm according to the content complexity of the I frame, and then encoding the I frame by using the adjusted code rate control parameters. The frame-level Lagrange multiplier lambda of the I frame calculated by the scheme is generally more accurate, and the code rate control effect is better. However, in a hardware video encoder, adding a special pre-processing stage is not only costly, but also increases the delay of video encoding, and thus is not suitable for implementation in a hardware video encoder.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: a code rate control method of an I frame suitable for being realized by a hardware video encoder is designed, and on the basis of not increasing a special image preprocessing level, a frame level Lagrange multiplier lambda of the I frame is accurately calculated, so that the actual coding bit number of the I frame is closer to the target coding bit number, and the process of code rate control is more accurate.
In order to solve the above technical problem, the present invention provides an I-frame rate control method suitable for hardware implementation, which includes the following steps. Step S21: and adopting a plurality of intra-frame coding modes for preliminary screening of each image block to be coded, namely calculating the prediction cost corresponding to each intra-frame coding mode, and screening one or more intra-frame coding modes with the lowest prediction cost as intra-frame coding mode candidates and the intra-frame coding mode prediction cost corresponding to each intra-frame coding mode candidate. Step S22: screening intra-frame coding mode prediction costs corresponding to each intra-frame coding mode candidate of an image block to be coded, and selecting the minimum intra-frame coding mode prediction cost to represent the intra-frame coding complexity of the image block to be coded; and then taking the sum of the intra-frame coding complexity of all image blocks in the video frame as the intra-frame coding complexity of the video frame. Step S23: calculating a frame-level Lagrange multiplier of the I frame to be coded according to the actual coding bit number, the frame-level Lagrange multiplier and the intra-frame coding complexity of the previous coded I frame and by combining the target coding bit number and the intra-frame coding complexity of the I frame to be coded; the intra-frame coding complexity of the I frame to be coded is obtained by replacing the intra-frame coding complexity of the previous coded video frame of the I frame to be coded.
Further, in the step S22, only the intra-coding complexity of each I frame and the video frame before each I frame is calculated.
Further, in step S23, the frame-level lagrangian multiplier λ of the I frame to be encoded new By the formula five:
Figure BDA0003850878750000041
obtaining; wherein f is -1 The inverse function of a first function f representing the relation between the ratio of different frame-level Lagrange multipliers and the ratio of different actual coding bit numbers when I frame coding is carried out; i (n) new Representing the target coding bit number of the I frame to be coded; i (m) old Representing the actual number of coded bits of the previous coded I frame; g is a second function representing the relation between the ratio of different intra-frame coding complexity and different actual coding bit number when I-frame coding is carried out; omega n-1 Representing the intra-coding complexity of the video frame coded immediately before the I-frame to be coded, instead of the intra-coding complexity omega of the I-frame to be coded n ;ω m Represents the intra-coding complexity of the previous coded I-frame; lambda [ alpha ] old Representing the frame-level lagrange multiplier of the previous encoded I frame.
Further, the first function f is represented by formula one:
Figure BDA0003850878750000051
obtaining; the concrete expression form of the first function f is obtained by calculating and fitting the actual parameters of the I frame in the video after being coded.
Further, the second function g is represented by formula two:
Figure BDA0003850878750000052
obtaining; concrete expression of the second function gThe formula is obtained by calculating and performing function fitting on the actual parameters of the I frame in the video after encoding.
Further, I frame encoding experiments are carried out on a large number of different video streams in advance, an expression of the first function f and an expression of the second function g are obtained in a function fitting mode and stored in the video encoder.
Further, in step S23, after the frame-level lagrangian multiplier of the I frame to be encoded is calculated, the I frame to be encoded is encoded, and the actual encoding bit number and intra-frame encoding complexity thereof are obtained.
Further, step S24 is added after the step S23. Step S24: after the current I frame is coded, correcting a first function f and a second function g used in the process of calculating the frame-level Lagrange multiplier of the I frame to be coded according to the actual coding bit number, the frame-level Lagrange multiplier and the intra-frame coding complexity of the I frame just coded and the I frame coded last time.
The invention also provides an I-frame code rate control device suitable for hardware implementation, which comprises an intra-frame coding mode prediction module, an intra-frame coding complexity calculation module and an I-frame Lagrangian constant calculation module. The intra-frame coding mode prediction module is used for preliminarily screening a plurality of intra-frame coding modes for an image block to be coded, namely calculating the prediction cost corresponding to each intra-frame coding mode, and screening one or more intra-frame coding modes with the lowest prediction cost as intra-frame coding mode candidates and the intra-frame coding mode prediction cost corresponding to each intra-frame coding mode candidate. The intra-frame coding complexity calculation module is used for screening intra-frame coding mode prediction cost corresponding to each intra-frame coding mode candidate of the image block to be coded, and selecting the minimum intra-frame coding mode prediction cost to represent the intra-frame coding complexity of the image block to be coded; and then taking the sum of the intra-frame coding complexity of all image blocks in the video frame as the intra-frame coding complexity of the video frame. The I frame Lagrange constant calculation module is used for calculating a frame level Lagrange multiplier of the I frame to be coded according to the actual coding bit number, the frame level Lagrange multiplier and the intra-frame coding complexity of the previous coded I frame and by combining the target coding bit number and the intra-frame coding complexity of the I frame to be coded; the intra-frame coding complexity of the I frame to be coded is obtained by replacing the intra-frame coding complexity of the previous coded video frame of the I frame to be coded.
Further, an I frame Lagrangian constant calculation correction module is added after the I frame Lagrangian constant calculation module. And the I frame Lagrange constant calculation and correction module is used for correcting a first function f and a second function g used in the process of calculating the frame-level Lagrange multiplier of the I frame to be encoded according to the actual encoding bit number, the frame-level Lagrange multiplier and the intra-frame encoding complexity of the I frame just encoded and the I frame previously encoded after the I frame is encoded.
The invention has the technical effects that: the frame-level Lagrange multiplier of the I frame to be coded is calculated by utilizing the information of the coded video frame, the calculation accuracy is high, and the accuracy of the code rate control of the I frame is effectively improved. In addition, the invention does not need to increase the image preprocessing stage, the hardware overhead is small, and the realization cost is low; the optional correction step can eliminate accumulated errors, so that the code rate control process of the I frame can adapt to the change of the content of the video stream, and the robustness of the code rate control of the I frame is improved.
Drawings
FIG. 1 is a diagram of a common image group structure.
Fig. 2 is a schematic structural diagram of a conventional mode selection system for an image block to be encoded.
Fig. 3 is a flowchart of a first embodiment of an I-frame rate control method suitable for hardware implementation according to the present invention.
Fig. 4 is a flowchart of a second embodiment of the I-frame rate control method suitable for hardware implementation according to the present invention.
Fig. 5 is a schematic structural diagram of a first embodiment of an I-frame rate control apparatus suitable for hardware implementation according to the present invention.
Fig. 6 is a schematic structural diagram of a second embodiment of an I-frame rate control apparatus suitable for hardware implementation according to the present invention.
The reference numbers in the figures illustrate: the video frame coding method comprises a video frame coding type selection module 11, an intra-frame coding mode prediction module 12, an inter-frame coding mode prediction module 13, an intra-frame coding mode rate distortion optimization module 14, an inter-frame coding mode rate distortion optimization module 15, an encoding mode selection module 16, an intra-frame coding mode prediction module 21, an intra-frame coding complexity calculation module 22, an I-frame Lagrange constant calculation module 23 and an I-frame Lagrange constant calculation and correction module 24.
Detailed Description
Referring to fig. 3, an embodiment of the method for controlling I-frame rate suitable for hardware implementation according to the present invention includes the following steps.
Step S21: and adopting a plurality of intra-frame coding modes for preliminary screening of each image block to be coded, namely calculating the prediction cost corresponding to each intra-frame coding mode, and screening one or more intra-frame coding modes with the lowest prediction cost of the image block to be coded as intra-frame coding mode candidates and the intra-frame coding mode prediction cost corresponding to each intra-frame coding mode candidate. The prediction cost refers to a low-computation-amount and low-precision coding rate distortion cost J, wherein J = D + lambda x R. Wherein, D is coding distortion, and SAD algorithm or SATD algorithm is generally used; r is the coding bit rate, typically using a simplified bit rate estimation algorithm. And transform and quantization operations are not generally introduced in the calculation process. This step is a step inherent in the existing video coding process, and intra-coding mode prediction is performed for all image blocks of I-frames, P-frames, and B-frames.
Step S22: screening intra-frame coding mode prediction costs corresponding to each intra-frame coding mode candidate of an image block to be coded, and selecting the minimum intra-frame coding mode prediction cost to represent the intra-frame coding complexity of the image block to be coded; and then taking the sum of the intra-frame coding complexity of all image blocks in the video frame as the intra-frame coding complexity of the video frame. Preferably, this step only calculates the intra-coding complexity of each I-frame, and the video frame preceding each I-frame, and not the intra-coding complexity of the other video frames. In this step, the calculation results of intra-frame coding mode prediction in the existing video coding process are multiplexed, specifically, the calculation results of intra-frame coding mode prediction of all image blocks in each I frame and all image blocks in a video frame before each I frame (intra-frame coding mode candidates and their corresponding intra-frame coding mode prediction costs) are multiplexed, and no additional image preprocessing stage needs to be introduced, which is an innovation of the present invention.
Step S23: according to the actual coding bit number of the previous coded I frame and the frame-level Lagrange multiplier lambda old And calculating the frame level Lagrange multiplier lambda of the I frame to be coded by combining the target coding bit number of the I frame to be coded and the intra-frame coding complexity new . The intra-frame coding complexity of the I frame to be coded is obtained by replacing the intra-frame coding complexity of the previous coded video frame of the I frame to be coded. In calculating frame-level Lagrange multiplier lambda of I frame to be coded new Later, the I frame to be encoded can be encoded, and its actual number of coded bits and intra-frame coding complexity can be obtained.
Frame-level Lagrange multiplier lambda of I frame to be coded new By the formula five:
Figure BDA0003850878750000071
seeking, this is one example. Wherein, f -1 The first function f is an inverse function of the first function f which represents the relation between the ratio of different frame-level Lagrange multipliers and the ratio of different actual coding bit numbers when I frame coding is carried out. I (n) new And representing the target coding bit number of the I frame to be coded. I (m) old Representing the actual number of coded bits of the previous coded I frame. g is a second function representing the relationship between the ratio of the complexity of different intra-frames to the number of different actual coded bits when I-frame coding is performed. Omega n-1 Representing the intra-coding complexity of the video frame coded immediately before the I-frame to be coded, instead of the intra-coding complexity omega of the I-frame to be coded n 。ω m Indicating the intra coding complexity of the previous coded I frame. Lambda [ alpha ] old Representing the frame-level lagrange multiplier of the previous encoded I frame. In this step, the information of the encoded I-frame is used to derive the frame level pull of the I-frame to be encodedGlanz multiplier lambda new And the replacement operation of the intra-frame coding complexity of the I-frame to be coded using the temporal correlation of successive video frames, belong to the innovations of the present invention.
Referring to fig. 1, the mth frame and the nth frame are two I frames adjacent to each other in front of and behind each other, and there may be zero or more P frames or B frames between them. Order I (m) old Denotes the m-th frame by λ old The actual number of coded bits after coding, let I (m) new Denotes the m-th frame by λ new The actual number of coded bits after coding, let I (n) old Denotes the nth frame by λ old The actual number of coded bits after coding, let I (n) new Denotes the nth frame by λ new The actual number of coded bits after coding, let ω be m Represents the complexity of the intra coding of the mth frame, let ω n Indicating the intra coding complexity of the nth frame.
The first function f is represented by formula one:
Figure BDA0003850878750000072
and (6) obtaining. The physical meaning of formula one is: i frame coding is carried out on the same video frame by using different frame-level Lagrange multipliers, the ratio of the actual coding bit number obtained after coding is related to the ratio of the frame-level Lagrange multipliers, and the relationship can be expressed by a first function f. The specific expression form of the first function f may be obtained by performing operation and function fitting on actual parameters of an I frame in a video after encoding, which is not described herein again.
The second function g is represented by formula two:
Figure BDA0003850878750000081
and (6) obtaining. The second formula has the physical meaning that I frame coding is carried out on different video frames by using the same frame-level Lagrange multiplier, the ratio of the actual coding bit number obtained after coding is related to the ratio of the intra-frame coding complexity of the video frames, and the relationship can be expressed by a second function g. The concrete expression form of the second function g can be operated by the actual parameters of the I frame in the video after being codedAnd the function fitting is obtained, which is not described herein again.
In the specific implementation of the invention, a large number of experiments show that the first function f and the second function g keep similar rules in different videos. The invention obtains the expression of the first function f and the expression of the second function g by carrying out I frame coding experiments on a large number of different video streams in advance in a function fitting mode, and stores the expressions in a video encoder. Since the first function f and the second function g are obtained after I-frame coding a plurality of different video streams, the expression of the first function f and the expression of the second function g are adapted to most video streams and are not limited to one video stream. Therefore, the first function f and the second function g in the above formula one and formula two belong to a known functional relationship. When a new video stream is I-frame coded by using a preset first function f and a preset second function g, the situation that the content of the new video stream is not well adapted can be met with small probability. At this time, the first function f and the second function g need to be corrected according to the actual encoding parameters after the I frame encoding in the video stream, as an optional correction step S24 described later.
Derivation is performed based on the first formula and the second formula to obtain a third formula:
Figure BDA0003850878750000082
Figure BDA0003850878750000083
further derivation yields equation four:
Figure BDA0003850878750000084
in formula four, the mth frame is the coded I frame, and if the coding process is completed, the corresponding actual number of coded bits I (m) old Frame-level Lagrange multiplier lambda adopted in coding old And intra coding complexity ω m Are all known quantities. The nth frame is the I frame to be encoded, then I (n) new Represents the desired target number of coded bits, and is a known quantity; omega n The complexity of the intra-coding representing the nth frame is an unknown quantity since the nth frame has not yet been coded;λ new Representing the actual number of coded bits in the nth frame as the desired target number of coded bits I (n) new The frame-level lagrange multipliers required to be used are unknown quantities and also quantities required to be obtained. To calculate the frame-level Lagrange multiplier lambda of the I frame to be encoded by using the formula IV new The present invention exploits the temporal correlation of successive video frames (successive video frames are similar in content), using the intra-coding complexity ω of the coded n-1 th frame adjacent to the n-th frame n-1 Instead of the intra-coding complexity ω of the nth frame to be coded n . Because the sampling time of the (n-1) th frame is very close to that of the nth frame, the contents of the two video frames are very similar, the error of the replacement operation of the intra-frame coding complexity is very small, and the frame-level Lagrange multiplier lambda of the I frame to be coded can not be generated new The calculation of (a) has a great influence. Thus, since the encoding of the (n-1) th frame has been completed, the intra-coding complexity ω thereof n-1 Is a known quantity. In equation four, let ω n-1 Instead of omega n Then the formula five can be obtained.
Referring to fig. 4, step S24 is added after step S23 in the second embodiment of the method for controlling I frame rate suitable for hardware implementation according to the present invention.
Step S24: after the current I frame is coded, calculating the frame-level Lagrange multiplier lambda of the I frame to be coded according to the actual coding bit number, the frame-level Lagrange multiplier and the intra-frame coding complexity of the I frame just coded and the I frame coded previously new The first function f and the second function g used in (1) are used for correction. The step is used for inhibiting errors introduced by intra-frame coding complexity replacement operation, so that accumulation is not generated due to increase of the number of the coded frames, the first function f and the second function g are more adaptive to the content characteristics of the current video stream, and the calculation of the frame-level Lagrange multiplier of the subsequent I frame is more accurate.
Still taking fig. 1 as an example, the nth frame is the current I frame that has just been encoded, and the mth frame is the previous I frame that has been encoded. And (3) performing function fitting on the first function f by adopting a formula I, wherein parameters in the formula I adopt actual coding bit numbers obtained after the m-th frame and the n-th frame are coded and frame-level Lagrange multipliers. And (4) performing function fitting on the second function g by adopting a formula II, wherein the parameters in the formula II adopt the actual coding bit number and the intra-frame coding complexity obtained after the m-th frame and the n-th frame are coded.
Referring to fig. 5, an embodiment of the I-frame rate control apparatus suitable for hardware implementation according to the present invention includes an intra-frame coding mode prediction module 21, an intra-frame coding complexity calculation module 22, and an I-frame lagrangian constant calculation module 23. The apparatus shown in fig. 5 corresponds to the method shown in fig. 3.
The intra-frame coding mode prediction module 21 is configured to perform preliminary screening on an image block to be coded by using a plurality of intra-frame coding modes, that is, calculate prediction costs corresponding to the intra-frame coding modes, and screen out one or more intra-frame coding modes with the lowest prediction costs as intra-frame coding mode candidates and intra-frame coding mode prediction costs corresponding to each intra-frame coding mode candidate. It should be noted that the intra-coding mode prediction module 21 in fig. 5 and the intra-coding mode prediction module 12 in fig. 2 are only different in reference numeral, and are substantially the same module.
The intra-frame coding complexity calculation module 22 is configured to screen intra-frame coding mode prediction costs corresponding to each intra-frame coding mode candidate of the image block to be coded, and select the minimum intra-frame coding mode prediction cost to represent the intra-frame coding complexity of the image block to be coded; and then taking the sum of the intra-frame coding complexity of all image blocks in the video frame as the intra-frame coding complexity of the video frame.
The I frame lagrangian constant calculation module 23 is configured to calculate a frame-level lagrangian multiplier λ according to an actual encoding bit number of a previous encoded I frame old And calculating the frame level Lagrange multiplier lambda of the I frame to be coded by combining the target coding bit number of the I frame to be coded and the intra-frame coding complexity new . The intra-frame coding complexity of the I frame to be coded is obtained by replacing the intra-frame coding complexity of the previous coded video frame of the I frame to be coded.
Referring to fig. 6, in the second embodiment of the I-frame rate control apparatus suitable for hardware implementation according to the present invention, an I-frame lagrangian constant calculation and correction module 24 is added after the I-frame lagrangian constant calculation module 23 in the first embodiment. The apparatus shown in fig. 6 corresponds to the method shown in fig. 4.
The I-frame lagrangian constant calculation and correction module 24 is configured to calculate a frame-level lagrangian multiplier λ of an I-frame to be encoded according to an actual encoding bit number, a frame-level lagrangian multiplier, and an intra-frame encoding complexity of an I-frame to be encoded just after encoding of the current I-frame is completed and an I-frame to be encoded last before new The first function f and the second function g used in (1) are used for correction.
The invention provides an I frame code rate control method suitable for a hardware video encoder, which is characterized in that the intra-frame encoding complexity of a video frame is represented by using the intra-frame encoding mode prediction cost generated in the video frame encoding process, an image preprocessing stage is not required to be added, the hardware overhead is low, and the realization cost is low. The code rate control method provided by the invention also utilizes the information of the coded video frame to calculate the frame-level Lagrange multiplier of the I frame to be coded, the calculation accuracy is high, and the accuracy of the code rate control of the I frame is effectively improved. The code rate control method provided by the invention also utilizes the actual coding information after the I frame coding is finished to correct the frame-level Lagrange multiplier lambda calculation method of the I frame, so that the accumulated error can be effectively eliminated, the code rate control process of the I frame can adapt to the change of the content of the video frame, and the robustness of the code rate control of the I frame is improved.
The above are merely preferred embodiments of the present invention, and are not intended to limit the present invention. Various modifications and alterations to this invention will become apparent to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. An I frame code rate control method suitable for hardware implementation is characterized by comprising the following steps;
step S21: the method comprises the steps that a plurality of intra-frame coding modes are adopted for each image block to be coded to carry out preliminary screening, namely, prediction costs corresponding to the intra-frame coding modes are calculated, and one or more intra-frame coding modes with the lowest prediction costs are screened out to serve as intra-frame coding mode candidates and intra-frame coding mode prediction costs corresponding to the intra-frame coding mode candidates;
step S22: screening intra-frame coding mode prediction costs corresponding to each intra-frame coding mode candidate of an image block to be coded, and selecting the minimum intra-frame coding mode prediction cost to represent the intra-frame coding complexity of the image block to be coded; then, taking the sum of the intra-frame coding complexity of all image blocks in the video frame as the intra-frame coding complexity of the video frame;
step S23: calculating a frame-level Lagrange multiplier of the I frame to be coded according to the actual coding bit number, the frame-level Lagrange multiplier and the intra-frame coding complexity of the previous coded I frame and by combining the target coding bit number and the intra-frame coding complexity of the I frame to be coded; the intra-frame coding complexity of the I frame to be coded is obtained by replacing the intra-frame coding complexity of the previous coded video frame of the I frame to be coded.
2. The method for controlling I-frame rate according to claim 1, wherein in step S22, the intra-coding complexity of each I-frame and the video frame before each I-frame is calculated.
3. The method for controlling I-frame rate according to claim 1, wherein in step S23, the I-frame to be encoded has a frame-level lagrangian multiplier λ new By the formula five:
Figure FDA0003850878740000011
obtaining; wherein, f -1 Is an inverse function of a first function f representing the relation of the ratio of different frame-level Lagrange multipliers to different actual coding bit numbers when I frame coding is carried out; i (n) new Representing the target coding bit number of the I frame to be coded; i (m) old Representing the actual number of coded bits of the previous coded I frame; g is a symbol indicating "different when I-frame coding is performedA second function of the relationship between the ratio of the intra-frame coding complexity and the ratio of different actual coding bit numbers; omega n-1 Representing the intra-coding complexity of the video frame coded immediately before the I-frame to be coded, instead of the intra-coding complexity omega of the I-frame to be coded n ;ω m Represents the intra coding complexity of the previous coded I frame; lambda old Representing the frame-level lagrange multiplier of the previous encoded I frame.
4. The method for I-frame rate control suitable for hardware implementation as claimed in claim 3, wherein the first function f is represented by the formula one:
Figure FDA0003850878740000012
obtaining; the concrete expression form of the first function f is obtained by calculating and fitting the actual parameters of the I frame in the video after being coded.
5. The method for I-frame rate control suitable for hardware implementation as claimed in claim 3, wherein the second function g is represented by formula two:
Figure FDA0003850878740000013
obtaining; the specific expression form of the second function g is obtained by calculating and fitting the actual parameters of the I frame in the video after encoding.
6. The method as claimed in claim 4 or 5, wherein the I-frame code rate control method is implemented by performing I-frame encoding experiments on a plurality of different video streams in advance, obtaining the expression of the first function f and the expression of the second function g by means of function fitting, and storing the first function and the second function in the video encoder.
7. The method as claimed in claim 3, wherein in step S23, after calculating the frame-level lagrangian multiplier of the I frame to be encoded, the I frame to be encoded is encoded, and the actual number of bits to be encoded and the intra-frame encoding complexity are obtained.
8. The method for controlling I frame rate according to claim 7, wherein a step S24 is added after the step S23;
step S24: after the current I frame is coded, correcting a first function f and a second function g used in the process of calculating the frame-level Lagrange multiplier of the I frame to be coded according to the actual coding bit number, the frame-level Lagrange multiplier and the intra-frame coding complexity of the I frame just coded and the I frame coded last time.
9. An I frame code rate control device suitable for hardware realization is characterized by comprising an intra-frame coding mode prediction module, an intra-frame coding complexity calculation module and an I frame Lagrange constant calculation module;
the intra-frame coding mode prediction module is used for preliminarily screening a plurality of intra-frame coding modes for an image block to be coded, namely calculating the prediction cost corresponding to each intra-frame coding mode, screening one or more intra-frame coding modes with the lowest prediction cost as intra-frame coding mode candidates and the intra-frame coding mode prediction cost corresponding to each intra-frame coding mode candidate;
the intra-frame coding complexity calculation module is used for screening intra-frame coding mode prediction cost corresponding to each intra-frame coding mode candidate of the image block to be coded, and selecting the minimum intra-frame coding mode prediction cost to represent the intra-frame coding complexity of the image block to be coded; then taking the sum of the intra-frame coding complexity of all image blocks in the video frame as the intra-frame coding complexity of the video frame;
the I frame Lagrange constant calculation module is used for calculating a frame level Lagrange multiplier of the I frame to be coded according to the actual coding bit number, the frame level Lagrange multiplier and the intra-frame coding complexity of the previous coded I frame and by combining the target coding bit number and the intra-frame coding complexity of the I frame to be coded; the intra-frame coding complexity of the I frame to be coded is obtained by replacing the intra-frame coding complexity of the previous coded video frame of the I frame to be coded.
10. The I-frame rate control device suitable for hardware implementation as claimed in claim 9, wherein an I-frame lagrangian constant calculation correction module is added after the I-frame lagrangian constant calculation module;
and the I frame Lagrange constant calculation and correction module is used for correcting a first function f and a second function g used in the process of calculating the frame-level Lagrange multiplier of the I frame to be encoded according to the actual encoding bit number, the frame-level Lagrange multiplier and the intra-frame encoding complexity of the I frame just encoded and the I frame previously encoded after the I frame is encoded.
CN202211134183.7A 2022-09-18 2022-09-18 I frame code rate control method and device suitable for hardware implementation Pending CN115550656A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211134183.7A CN115550656A (en) 2022-09-18 2022-09-18 I frame code rate control method and device suitable for hardware implementation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211134183.7A CN115550656A (en) 2022-09-18 2022-09-18 I frame code rate control method and device suitable for hardware implementation

Publications (1)

Publication Number Publication Date
CN115550656A true CN115550656A (en) 2022-12-30

Family

ID=84727651

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211134183.7A Pending CN115550656A (en) 2022-09-18 2022-09-18 I frame code rate control method and device suitable for hardware implementation

Country Status (1)

Country Link
CN (1) CN115550656A (en)

Similar Documents

Publication Publication Date Title
KR100942395B1 (en) Rate control for multi-layer video design
JP5676705B2 (en) Improved video rate control for video coding standards
CN109862359B (en) Code rate control method and device based on layered B frame and electronic equipment
US9071841B2 (en) Video transcoding with dynamically modifiable spatial resolution
KR101518358B1 (en) A buffer-based rate control exploiting frame complexity buffer level and position of intra frames in video coding
CN106791848B (en) Two-Pass code rate control method based on HEVC
CN113489981B (en) Zero-delay code rate control method considering time domain rate distortion optimization
US10958912B2 (en) Bit prediction based bit rate control method and apparatus for video coding process supporting offline CABAC
KR101959490B1 (en) Method for video bit rate control and apparatus thereof
KR20080029333A (en) Video compressing encoding device based on feed-back structure for a fast encoding and decision method of optimal mode
JP5706759B2 (en) Image coding apparatus and image coding method
KR20000070810A (en) Encoder and encoding method
KR101086724B1 (en) ?? Deciding Method of H.264/AVC Encoder using Complexity of Frame, and H.264/AVC Encoder implementing the same
CN110971900A (en) Code rate control method suitable for 4K and 8K ultrahigh-definition motion flat video
JPH09294267A (en) Image compression coder
CN115550656A (en) I frame code rate control method and device suitable for hardware implementation
JP5136470B2 (en) Moving picture coding apparatus and moving picture coding method
CN116886921A (en) Code rate control method and device for video frame level of I frame
CN111541898A (en) Method, device, server and storage medium for determining coding mode
CN116248882A (en) Code rate control method and device for I frame image block level
CN116320434A (en) Code rate control method and device for P frame and/or B frame image block level
JP3690259B2 (en) High-speed moving image encoding apparatus and high-speed moving image encoding method
KR0123243B1 (en) Bit rate control method in a scene conversion
CN116437092A (en) Code rate control method and device for avoiding generation of oversized I frame
CN116939207A (en) Code rate control method and device for image block level of I frame

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination