CN114979640A - Encoding method, encoder and computer readable storage medium - Google Patents

Encoding method, encoder and computer readable storage medium Download PDF

Info

Publication number
CN114979640A
CN114979640A CN202210546977.8A CN202210546977A CN114979640A CN 114979640 A CN114979640 A CN 114979640A CN 202210546977 A CN202210546977 A CN 202210546977A CN 114979640 A CN114979640 A CN 114979640A
Authority
CN
China
Prior art keywords
current frame
complexity
frame
quantization
preset
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
CN202210546977.8A
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.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp 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 Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202210546977.8A priority Critical patent/CN114979640A/en
Publication of CN114979640A publication Critical patent/CN114979640A/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/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/124Quantisation
    • 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/136Incoming video signal characteristics or properties
    • H04N19/14Coding unit complexity, e.g. amount of activity or edge presence estimation
    • 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/172Methods 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 picture, frame or field

Landscapes

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

Abstract

The embodiment of the application discloses an encoding method, an encoder and a computer readable storage medium, which can improve the video quality of an encoded video, and the method comprises the following steps: when the current frame is the first frame in the video to be coded, acquiring image information of the current frame in the process of controlling the inter-frame level code rate; calculating a complexity accumulated value of the current frame based on the image information of the current frame; based on the complexity accumulated value of the current frame, carrying out coding quantization estimation on the current frame to obtain an initial quantization step length of the current frame; and coding the current frame based on the initial quantization step size of the current frame to obtain a coding result of the current frame.

Description

Encoding method, encoder and computer readable storage medium
The present application is based on the chinese patent application having application number 202010693484.8, application date 2020, 07/17/2020, and application name "a coding method, encoder and computer readable storage medium", and filed in the scope of the description of the chinese patent application, the entire content of which is incorporated herein by reference.
Technical Field
The present application relates to the field of audio and video encoding, and in particular, to an encoding method, an encoder, and a computer-readable storage medium.
Background
Video coding is a video compression technology, which is a technology for compressing video by utilizing time domain redundancy and space domain redundancy of video information, and can achieve the purpose of reducing storage space and network bandwidth occupied by the video. The code rate control is a key technology in video coding, and aims to ensure the optimal objective quality of the video under the condition of ensuring that the occupied bit number is constant after the video is compressed. Quantization Parameter (QP) is a key parameter in video coding technology, and directly determines the degree of compression of a video coding unit, thereby controlling the bitrate and video quality after video coding. In the prior art, an artificial preset mode is usually adopted for setting an initial value of a compression coefficient related to a quantization parameter, information feedback cannot be performed according to specific video content, and adaptive adjustment is realized, so that unreasonable QP set when a first frame is encoded is easily caused, the code rate of an Instant Decoding Refresh (IDR) frame is wasted, and the video quality is reduced.
Disclosure of Invention
Embodiments of the present application are directed to providing an encoding method, an encoder, and a computer-readable storage medium, which can improve video quality of encoded video.
The technical scheme of the application is realized as follows:
in a first aspect, an embodiment of the present application provides an encoding method applied to an encoder, including:
when the current frame is the first frame in the video to be coded, acquiring image information of the current frame in the process of controlling the inter-frame level code rate;
calculating a complexity accumulated value of the current frame based on the image information of the current frame;
based on the complexity accumulated value of the current frame, performing coding quantization estimation on the current frame to obtain an initial quantization step size of the current frame;
and coding the current frame based on the initial quantization step length of the current frame to obtain a coding result of the current frame.
In a second aspect, an embodiment of the present application provides an encoder, including: an obtaining unit, a calculating unit, a quantizing unit and an encoding unit, wherein,
the acquiring unit is used for acquiring the image information of the current frame in the inter-frame level code rate control process when the current frame is the first frame in the video to be coded;
the calculating unit is used for calculating the complexity accumulated value of the current frame based on the image information of the current frame;
the quantization unit is configured to perform coding quantization estimation on the current frame based on the complexity cumulative value of the current frame to obtain an initial quantization step size of the current frame;
and the coding unit is used for coding the current frame based on the initial quantization step size of the current frame to obtain the coding result of the current frame.
In a third aspect, an embodiment of the present application provides an encoder, including:
a memory for storing executable data instructions;
a processor, configured to implement the encoding method as described in any one of the above when executing the executable instructions stored in the memory.
In a fourth aspect, the present application provides a computer-readable storage medium storing executable instructions for causing a processor to implement the encoding method as described in any one of the above.
The embodiment of the application provides an encoding method, an encoder and a computer readable storage medium, wherein the method comprises the following steps: when the current frame is the first frame in the video to be coded, acquiring the image information of the current frame in the process of controlling the inter-frame level code rate; calculating a complexity accumulated value of the current frame based on the image information of the current frame; based on the complexity accumulated value of the current frame, carrying out coding quantization estimation on the current frame to obtain an initial quantization step length of the current frame; and coding the current frame based on the initial quantization step size of the current frame to obtain a coding result of the current frame. By the method in the embodiment of the application, the complexity of the first frame can be estimated through the image information of the first frame, and the reasonable setting of the QP value is carried out based on the complexity of the first frame in the actual video, so that the video coding based on the reasonable QP value can obtain a more accurate coding result, and the video quality of the coded video is finally improved.
Drawings
FIG. 1 is a flow chart of encoding in a current X.264 encoding system;
fig. 2 is a first flowchart of an encoding method according to an embodiment of the present application;
fig. 3 is a first encoding flowchart provided in an embodiment of the present application;
fig. 4 is a second encoding flowchart provided in the embodiment of the present application;
fig. 5 is a diagram illustrating an implementation manner of a macroblock-level rate control process according to an embodiment of the present disclosure;
fig. 6 is another implementation manner of a macroblock-level rate control process according to an embodiment of the present application;
fig. 7 is a second flowchart of an encoding method according to an embodiment of the present application;
fig. 8 is a flowchart of a coding method according to an embodiment of the present application;
fig. 9 is a fourth flowchart of an encoding method according to an embodiment of the present application;
fig. 10 is a fifth flowchart of an encoding method according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of an encoder according to an embodiment of the present application
Fig. 12 is a schematic structural diagram of a second encoder according to an embodiment of the present disclosure.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
Before further detailed description of the embodiments of the present application, terms and expressions referred to in the embodiments of the present application will be described, and the terms and expressions referred to in the embodiments of the present application will be used for the following explanation.
1) H.264: highly compressed digital video codec standards.
2) X.264: open source h.264 video coding function libraries.
3) SATD: sum of Absolute values of prediction residuals of 4 × 4 blocks with residuals subjected to hadamard transform is a simple time-frequency transform, and is used for reflecting the size of a generated code stream.
4) QP: quantization parameter, i.e. quantization step size. The smaller the value of QP, the smaller the quantization step size, and the higher the quantization accuracy, which means that the amount of data generated may be larger in the case of the same picture quality.
5) VBV: video Buffering Verifier, Video buffer checker, for ensuring that the output coded code stream will not generate buffer underflow at the receiving end.
6) AQ: adaptive Quantization.
7) MB: macro Block.
8) RCEQ: the Rate-Control Equation, the Rate Control formula and the RCEQ establish a mapping model from motion complexity to quantization step size.
9) PSNR: peak Signal to Noise Ratio, an objective measure for evaluating image quality.
The H.264 adopts a Lagrange cost function to control coding, which is one of the main reasons that the complexity of the H.264 coding is higher, X.264 is used as an application version of the H.264, and SATD of a half-precision frame is used as a main basis for selecting QP. The x.264 rate control process is divided into an inter-frame rate control process and a macroblock rate control process, wherein the allocation of QP values for each frame is implemented by inter-frame rate control, and the allocation of QP values within each frame is implemented by macroblock rate control. The x.264 rate control process mainly depends on two variables, one is the complexity of the video frame and the other is the budget of the rate. Generally, the higher the complexity of a video frame, the more bits are required for encoding. As shown in fig. 1, fig. 1 is a coding flow chart of the current x.264 coding system. After a video to be coded enters a coding system, the video to be coded enters an inter-frame level code rate control process (namely frame level code rate control) and a macroblock level code rate control process at the same time, in the inter-frame level code rate control process, a video frame buffer queue is firstly provided for the video to be coded through a look ahead module 100 to assist in completing more stable code rate control, and then the complexity of a current frame in the video to be coded is estimated through a complexity estimation module 101, wherein the complexity of the current frame can be fuzzy complexity exemplarily; the quantization level calculation module 103 is configured to perform quantization level calculation according to the complexity of the current frame output by the complexity estimation module 101, obtain a quantization scale corresponding to the current frame, and adjust the quantization scale according to a rate factor (rateactor) provided by the rate factor calculation module 102 to obtain an initial quantization level; the code rate factor calculation module 102 is configured to calculate a complexity cumulative value of the current frame according to the fed back code rate of the coded frame, and then calculate a code rate factor (rateactor) according to the complexity cumulative value and provide the rate factor to the quantization level calculation module 103; the initial quantization level output by the quantization level calculation module 103 is further adjusted by a buffer control (VBV) module 104 based on the size of the buffer area at the receiving end to obtain a quantization level, and the quantization level is converted into an initial quantization step by a quantization level conversion module 105 and provided to a macroblock-level quantization step adjustment module 106. Meanwhile, the code rate control process of the macroblock level and the code rate control process of the interframe level are synchronously performed, wherein the macroblock calculation module 108 is used for calculating the macroblock structure (MBTree) of the current frame according to the image content of the current frame, and the adaptive quantization module 107 is used for calculating the average macroblock energy of the current frame according to the macroblock structure and the image content of the current frame and determining a preset quantization intensity factor corresponding to the average macroblock energy; the macroblock-level quantization step adjustment 106 is configured to adjust an initial quantization step of the current frame according to a preset quantization strength factor to obtain a quantization step corresponding to the current frame. And finally, the coding module 109 codes the current frame according to the quantization step corresponding to the current frame, and continues the above process until all frames in the video to be coded are coded, and then outputs the coded code stream.
As can be seen from the encoding method shown in fig. 1, currently, in the frame-level rate control process, the rate factor calculation module 102 needs to calculate a rate factor according to the feedback of the previous frame encoding result, and further adjusts the quantization proportion calculated in the quantization level calculation module 103 to obtain an initial quantization level. However, for the first frame, such as an IDR frame, the position of the first frame where the first frame is located cannot be fed back by the encoding result of the previous frame, so the current implementation mode is to manually set a fixed numerical value as the initial value of the code rate factor, and then gradually calculate the QP value of the first frame according to the initial value of the fixed code rate factor, which may cause that the QP value setting of the first frame cannot be adaptively adjusted according to the complexity, thereby causing the waste of the code rate and reducing the quality of the whole video. Further, at present, in the macroblock-level rate control process, the quantization strength factor pre-calculated in the adaptive quantization module 107 is in a fixed and unchangeable state in the encoding process of the entire video, but the video content in actual encoding is constantly changed, if a large quantization strength factor is used in a complex region, the quantization step length finally obtained according to the quantization strength factor adjustment is obviously increased, and under the condition of a low rate, the blurring phenomenon of the complex region is serious, so that the quality of the entire video is further reduced.
The embodiment of the present application provides an encoding method applied to an encoder, as shown in fig. 2:
s101, when the current frame is the first frame in the video to be coded, acquiring image information of the current frame in the inter-frame level code rate control process.
In the embodiment of the present application, for a first frame in a video to be encoded, an encoder first acquires image information of the first frame.
In this embodiment, the image information includes any one of an average macroblock energy of the first frame, a gradient value of the first frame, edge information of the first frame, and histogram information of the first frame.
In some embodiments of the present application, based on the rate control flow shown in fig. 1, since the execution process of the macroblock calculation module 108 is logically prior to the inter-frame rate control process in the macro-level rate control process, considering that in the flow of fig. 1, on the basis of not increasing the calculation amount, the encoder may use the average macroblock energy generated in the execution process of the macroblock calculation module 108 as the image information of the current frame, so as to estimate the complexity accumulated value of the first frame in the video to be encoded by using the average macroblock energy, as shown in fig. 3.
In this embodiment of the present application, the macroblock calculating module 108 in fig. 3 feeds back the calculated average macroblock energy to the code rate factor calculating module 102 in the inter-frame level code rate control process, so that the code rate factor calculating module 102 can calculate a code rate factor according to the average macroblock energy of the first frame, and further adjust the initial quantization step corresponding to the first frame according to the code rate factor.
In other embodiments of the present application, when the image information of the current frame is a gradient value, edge information, or histogram information, the encoder may calculate, as shown in fig. 4, the gradient value, edge information, or histogram information of the current frame according to the pixel information included in the current frame through the image processing module 110, and feed the gradient value, edge information, or histogram information of the current frame back to the code rate factor calculation module 102, so that the code rate factor calculation module 102 can calculate the code rate factor according to the gradient value, edge information, or histogram information of the first frame, and further adjust the initial quantization step size corresponding to the first frame according to the code rate factor. For example, the encoder may calculate a gray level change in a neighborhood of each pixel in the current frame according to gray level information in the pixel information, and further calculate a gradient value that may reflect a detail contrast degree and a texture change feature of the current frame, and use the gradient value as image information of the current frame; in other embodiments, the encoder may further obtain edge information of the current frame according to the gradient value, and use the edge information as image information of the current frame, so as to identify and analyze content in the current frame according to the edge information; alternatively, the encoder may calculate histogram information that reflects the brightness, luminance, and color level distribution of the current frame based on the grayscale information in the pixel information, and use the histogram information as the image information of the current frame.
And S102, calculating a complexity accumulated value of the current frame based on the image information of the current frame.
In the embodiment of the application, the encoder calculates the complexity accumulated value of the current frame based on the image information of the current frame, so that the code rate factor can be reasonably initialized according to the complexity accumulated value of the first frame, and the quantization proportion of the first frame is adjusted through the code rate factor.
In the embodiment of the application, for different types of image information, a corresponding objective function model can be established in advance, the image information of a first frame is taken as an input value of the objective function model, an initial quantization step is taken as an output value of the objective function model, the output initial quantization step satisfies low-code-rate and high-quality video application as a target, the figure of the output initial quantization step is analyzed through multiple simulation experiments, the figure of the output initial quantization step is good or bad, a curve of the initial quantization step and the image information is fitted through a function fitting mode, the functional relation between the initial quantization step corresponding to the optimal value of the initial quantization step and the image information is obtained, and then a relation formula between the image information of a current frame and the complexity accumulated value is deduced according to the functional relation between the initial quantization step and the image information and the preset functional relation between the initial quantization step and the complexity accumulated value, and calculating the complexity accumulated value of the current frame based on the relational formula.
It can be seen that, because the relationship formula between the image information of the current frame and the complexity cumulative value is obtained by performing curve fitting on the initial quantization step and the image information through multiple simulation experiments, the complexity cumulative value calculated through the image information of the current frame can be more suitable for the real image content of the current frame, thereby ensuring that the code rate factor calculated according to the complexity cumulative value and the initial quantization step adjusted according to the code rate factor are more accurate.
S103, based on the complexity accumulated value of the current frame, coding quantization estimation is carried out on the current frame to obtain an initial quantization step size of the current frame.
In this embodiment of the application, when the current frame is the first frame, the encoder may calculate the complexity cumulative value of the first frame based on the image information of the first frame.
In this embodiment, when the current frame is a non-leading frame, the encoder may calculate the complexity cumulative value of the non-leading frame by combining the encoding result of the previous frame of the non-leading frame.
In the embodiment of the application, the encoder may estimate the complexity of the current frame through the complexity estimation module, calculate the quantization proportion of the current frame according to the complexity, calculate the code rate factor corresponding to the first frame according to the complexity accumulated value of the current frame, perform one-time adjustment on the quantization proportion according to the code rate factor to obtain an initial quantization level, further adjust the initial quantization level through the cache control module to obtain the quantization level of the current frame, and convert the quantization level into the initial quantization step according to the preset mapping relationship between the quantization level and the quantization step.
And S104, coding the current frame based on the initial quantization step size of the current frame to obtain a coding result of the current frame.
In the embodiment of the application, after the encoder obtains the initial quantization step of the current frame, that is, the QP value, the code rate control process of the inter-frame level corresponding to the current frame is completed, and the encoder can continue to adjust the initial quantization step of the current frame through the macroblock level code rate control process to obtain the quantization step of the current frame.
In some embodiments of the present application, as shown in fig. 5, in a macroblock-level rate control process 1, an encoder may perform a macroblock energy calculation process, divide a current frame into a plurality of different macroblocks according to image content, calculate macroblock energy of each macroblock according to a sum of a pixel value and a square error of a pixel in each macroblock, and further obtain average macroblock energy of the current frame. And finally, in the process of adjusting the quantization step length, obtaining an offset value of an initial quantization step length through the preset quantization intensity factor, and adjusting the initial quantization step length through the offset value of the initial quantization step length to obtain the quantization step length of the current frame.
In general, if the current frame has more dynamic conditions, the corresponding average macroblock energy is higher, and the encoder may select a lower preset quantization strength factor aq _ strength value, for example, select aq _ strength whose value is between 0.6 and 0.8, so as to retain more high-frequency details and improve the overall video quality; if the number of static pictures of the current frame is large, the corresponding average macroblock energy is low, the encoder can select a high aq _ strength value, and exemplarily, the encoder can select aq _ strength which is greater than or equal to 1, so as to prevent color bands from being generated in a dark part due to insufficient bits. In some embodiments, the above method process may be implemented by:
Figure BDA0003649541740000091
strength ═ h- > param.rc.f _ aq _ strengthh × avg _ adj; adjusting the quantization strength of the current frame by presetting a quantization strength factor aq _ strength and an average macroblock energy avg _ adj.
Figure BDA0003649541740000092
qp _ adj ═ strength (qp _ adj-avg _ adj) + bias _ strength (1.f-14.f/(qp _ adj _ qp _ adj)); // QP offset value QP _ adj setting
In the embodiment of the present application, for the code, if QP _ adj-avg _ adj is greater than 0, the QP of the macroblock with large macroblock energy is adjusted to be larger, so that the larger the QP _ offset finally calculated, the more blurred the complex region is; if QP _ adj-avg _ adj is smaller than 0, the larger the strength is, the smaller QP _ offset is, the smaller the final QP is, and the clearer the flat region is, and because h- > param.
In other embodiments of the present application, as shown in fig. 6, in the macroblock-level rate control process 2, an encoder obtains the content complexity of each macroblock through a complexity information calculation process by using the macroblock energy of each macroblock calculated in the macroblock energy calculation process, divides the current frame into different regions based on the content complexity of each macroblock in a complexity reference adjustment process according to a preset complexity reference, sets different preset quantization strength factors aq _ strand in the different regions through an adaptive quantization process, and finally performs offset adjustment on the initial quantization step according to the different preset quantization strength factors aq _ strand in each region through a quantization step adjustment process to obtain quantization steps corresponding to the regions, so as to realize the change of the preset quantization strength factors aq _ strand along with the image complexity, the method can reduce the preset quantization intensity factor of the complex area, reduce the fuzzy phenomenon of the complex area, and improve the adaptability of the preset quantization intensity factor to the video content.
In the embodiment of the application, after the encoder obtains the quantization step corresponding to each macro block in the current frame according to the macro-level quantization step adjustment module, the current frame can be encoded based on the quantization step to obtain the encoding result of the current frame. And the encoder performs the encoding of the next frame by the same code rate control flow based on the encoding result of the current frame until the encoding of the video to be encoded is completed.
It can be understood that, in the embodiment of the present application, for a first frame of a video to be encoded, an encoder may obtain a complexity cumulative value corresponding to the first frame based on image information of the first frame, and further perform further calculation according to the complexity cumulative value to obtain an initial quantization step size of the first frame, thereby implementing that the initial quantization step size of the first frame may be adaptively set according to the complexity of the first frame, avoiding code rate waste caused by manually setting an unreasonable initial quantization step size of the first frame, improving the quality of the video after encoding, further, in a macroblock-level code rate control process, the encoder may perform a setting of a preset quantization intensity factor of a current frame in a partition-to-partition scene according to the macroblock complexity, thereby calculating suitable quantization step sizes for different complexity regions of the current frame according to different preset quantization intensity factors, and implementing an adaptation of the preset quantization intensity factor along with the image complexity, the definition of the image is improved, and the quality of the coded video is further improved.
Next, the encoding method in the embodiment of the present application is further described by taking the average macroblock energy of the first frame as an example.
In some embodiments of the present application, based on fig. 2, when the current frame is a first frame in a video to be encoded, in the inter-frame rate control process, the encoder acquiring image information of the current video in S101 may be implemented through S1011 to S1012, as shown in fig. 7:
and S1011, in the macro block level code rate control process, carrying out macro block division on the current frame to obtain at least one macro block.
In the embodiment of the application, an encoder performs macroblock division on a current frame based on image content of the current frame through a macroblock calculation module to obtain at least one macroblock.
In some embodiments, at least one macroblock may be in the form of an MB tree.
S1012, calculating an average macroblock energy of at least one macroblock.
In this embodiment, the encoder may calculate the macroblock energy of each macroblock according to the sum of the pixel value and the square error in each macroblock of the at least one macroblock, and then obtain the average macroblock energy of the at least one macroblock according to the macroblock energy of each macroblock.
It can be understood that, in the embodiment of the present application, the average macroblock energy is used as the image information of the first frame, the average macroblock energy calculated in the macroblock-level rate control process may be directly used, no additional image processing is required, and the amount of calculation of the encoder is reduced.
In some embodiments of the present application, based on fig. 2 or fig. 7, when the current frame is a first frame in a video to be encoded, in the inter-frame level rate control process, the encoder in S102 may calculate the accumulated complexity value of the current frame based on the image information of the current frame through S1021-S1022, as shown in fig. 8:
s1021, carrying out complexity evaluation on the current frame according to the average macro block energy, the preset first frame coding bit and at least one preset fitting factor to obtain the estimated coding complexity of the current frame; at least one preset fitting factor is used for fitting a relation curve between the average macro block energy and the initial quantization step size.
In the embodiment of the present application, the encoder performs complexity evaluation on the current frame according to the average macroblock energy, the preset first frame coding bits, and at least one preset fitting factor, and a specific process of obtaining the estimated coding complexity of the current frame may be: multiplying the average macro block energy by a first fitting factor to obtain a first product result; multiplying the preset first frame code bit by a second fitting factor to obtain a second product result; calculating the difference value of the first product result minus the second product result, and adding the difference value and the third fitting factor to obtain the estimated encoding complexity; the at least one preset fitting factor comprises a first fitting factor, a second fitting factor and a third fitting factor. As shown in equation (1):
cplxr_zero=s 1 ×avg_energy-s 2 ×wanted_bits_window+s 3 (1)
in the above formula (1), avg _ energy is the average macroblock energy of the current frame, i.e. the first frame, cplxr _ zero is the estimated complexity of the current frame calculated according to the average macroblock energy, s 1 、s 2 And s 3 The at least one preset fitting factor in the embodiment of the present application is obtained by adjusting a relationship between an initial quantization step and avg _ energy through a large number of simulation experiments, analyzing and testing the quality of the initial quantization step of the video, and fitting a QP-energy curve, with the goal of satisfying low-bitrate and high-quality video applications, that is, the preset fitting factor in the embodiment of the present application is an optimal value of a corresponding parameter item in formula (1) obtained by a function curve fitting manner. In some embodiments, s 1 Can be 13000, s 2 Can be 0.3858, s 3 The value of (2) may be 515000, or values of other preset fitting factors may be calculated in a function curve fitting manner according to an actual encoding target, specifically selected according to actual applications, and the embodiment of the present application is not limited.
In formula (1), the counted _ bits _ window represents the target file size of the encoded frame, i.e. the total bit value of the encoded frame, and can be obtained by formula (2) as follows:
wanted_bits_window=bitrate/fps (2)
the fps in the formula (2) is a preset frame rate of a video to be coded, the bitrate represents a code rate after coding, the bitrate of the first frame is a preset value, and the bitrate of the non-first frame is a corresponding code rate after coding of the previous frame, so that the counted _ bits _ window of the first frame is also equal to the preset value.
And S1022, calculating the complexity accumulated value of the current frame based on the estimated coding complexity.
In this embodiment, the calculating, by the encoder, the accumulated value of the complexity of the current frame based on the estimated coding complexity may include:
s10221, obtaining the number of macroblocks of at least one macroblock.
S10222, according to the estimated encoding complexity, the number of macro blocks of at least one macro block and the preset compression parameters, the complexity accumulated value is initially calculated to obtain the complexity accumulated value of the current frame.
In the embodiment of the application, the encoder acquires the number of macro blocks of at least one macro block obtained after the macro block calculation module divides the macro block process, the preset compression parameters are used as the power of the estimated encoding complexity for operation, and the operation result is multiplied by the preset coefficient and the half power of the number of the macro blocks to obtain the complexity accumulated value of the current frame.
For example, the above calculation process may be as shown in formula (3):
cplxr_sum=0.01×cplxr_zero qcom ×(mbcount) 1/2 (3)
in equation (3), qcomp is a preset compression parameter. The parameter is externally adjustable and can take values between 0 and 1. mbcount is the number of macroblocks of at least one macroblock.
In some embodiments, when the current frame is the top frame, the code implementation of the encoder calculating the complexity cumulative value cplxr _ sum of the current frame through S1012 may be as follows:
Figure BDA0003649541740000131
in the current frame level rate control process, the calculation method of the complexity cumulative value cplxr _ sum of the first frame is shown in formula (4):
cplxr_sum=0.01×(7×10 5 ) qcompress ×(mbcount) 1/2 (4)
the code corresponding to equation (1) is implemented as follows:
Figure BDA0003649541740000132
Figure BDA0003649541740000141
it can be understood that, in the current frame-level rate control process, the complexity cumulative value cplxr _ sum of the first frame is initialized as a fixed value, and adaptive adjustment cannot be realized according to the actual complexity of the first frame. Further, the video coding method can not further calculate according to a reasonable compression coefficient, so that the initial quantization step of the first frame finally calculated according to the compression coefficient is influenced, and the quality of the coded video is reduced. In the embodiment of the application, the calculation of the complexity cumulative value cplxr _ sum of the first frame is obtained through the complexity estimation of the first frame, so that the complexity adaptive adjustment following the first frame can be realized according to the initial quantization step length of the first frame obtained through the calculation of the complexity cumulative value cplxr _ sum, the rationality of the setting of the initial quantization step length of the first frame is improved, the coding rate is saved, and the video quality after coding is improved.
It should be noted that, in some embodiments of the present application, when the current frame is a non-leading frame in a video to be encoded, the encoder may perform accumulation processing on the complexity based on the number of bits of a previous frame corresponding to the current frame after encoding and a quantization parameter of the previous frame, so as to obtain a complexity accumulated value of the current frame. That is, when the current frame is a non-top frame, the encoder calculates the complexity accumulation value of the current frame according to the encoding result of the previous frame, as shown in formula (5):
Figure BDA0003649541740000142
in formula (5), bits (i-1) is an actual bit number obtained by encoding a previous frame, qscale _ raw (i-1) is a quantization specific weight value corresponding to the previous frame without being adjusted by a code rate factor, qscale _ adj (i-1) is an initial quantization level corresponding to the previous frame after being adjusted by the code rate factor, cplxr _ sum (i-1) is a complexity accumulated value corresponding to the previous frame, and cplxr _ sum (i) is a complexity accumulated value of a current frame.
It can be understood that the complexity accumulation value of the current frame is an iteration quantity, and is gradually accumulated in the encoding process, so that the complexity accumulation value setting of the first frame affects the encoding quality of the whole video. According to the method, the complexity accumulated value of the first frame is calculated through average macro block energy, self-adaptive adjustment of the complexity accumulated value of the first frame according to the complexity of the first frame can be achieved, the complexity accumulated value of the first frame is set more accurately, and therefore the quality of the whole video coding is improved.
In some embodiments of the present application, based on fig. 8, in S103, the encoder performs encoding quantization estimation on the current frame based on the complexity cumulative value of the current frame, and obtaining the initial quantization step size of the current frame may be implemented through S1031 to S1034, as shown in fig. 9:
and S1031, carrying out fuzzy complexity estimation on the current frame, carrying out compression processing on the fuzzy complexity obtained by estimation, and calculating to obtain the complexity of the current frame.
In the embodiment of the application, an encoder performs sampling filtering on a current frame to obtain a small picture with half of the original resolution, performs half-pixel precision prediction on the small picture, subtracts the small picture from an original picture to obtain a residual error, performs Hadamard transform on the residual error and calculates the absolute sum to obtain the SATD, namely the fuzzy complexity of the current frame can be obtained according to the weighted average of the SATD value of the current frame and the SATD value of the previous adjacent frame.
In the embodiment of the present application, the encoder may perform blur complexity estimation on the current frame as shown in formula (6) and formula (7), as follows:
BlurCplx=Cplxsum/Cplxcount (6)
Figure BDA0003649541740000151
in equation (6), BlurCplx represents the blur complexity, and the encoder can obtain BlurCplx by weighting the complexity of neighboring encoded frames according to equation (6). In formula (6), Cplxsum represents a coding complexity weighted sum, Cplxcount represents a coding frame number weighted sum, and the Cplxsum and Cplxcount calculation method is as shown in formula (7), i is a sequence number of a frame to be coded, sadd is a residual absolute value sum SATD of a current frame after motion compensation, sadd of a first frame is a preset value, and sadd of a non-first frame can be calculated according to a time-frequency transformation mode and is used for reflecting the size of a generated code stream.
In the embodiment of the present application, since the constant quality of a video frame does not mean that a constant QP value is used, and for a high-complexity scene, according to the visual characteristics of human eyes, human eyes hardly feel the loss of details subjectively, the bit rate can be reduced by performing nonlinear compression on the fuzzy complexity of a current frame by using a perceptual coding optimization method, as shown in formula (8):
rceq=BlurCplx (1-qcomp) ,qcomp∈[0,1] (8)
in formula (8), rceq represents complexity after perceptual coding optimization, and can be used as quantization proportion for evaluating quantization degree of a current frame; the specific meaning of qcomp is that when qcomp is equal to 1, the quantization specific gravities, i.e. rceq, of the frames are the same, and the bits allocated to the flat frame and the complex frame are the same; when qcomp is 0, the quantization specific gravity of each frame is in proportion to the blurring complexity of each frame, and finally the QP value of each frame is equal, which is equivalent to closing the perceptual coding optimization.
S1032, calculating the ratio of the total bit value and the complexity accumulated value of the coded frame in the video to be coded to obtain the code rate factor of the current frame.
In the embodiment of the present application, an encoder calculates a ratio between a total bit value and a complexity cumulative value of an encoded frame in a video to be encoded, as a bitrate factor of a current frame, as shown in formula (9) and formula (10):
ratefactor=wanted_bits_window/cplxr_sum (9)
in formula (9), rateactor is a rate factor of the current frame generated by the rate factor calculation module according to the coded frame bitrate.
And S1033, obtaining the quantization level of the current frame based on the complexity and the code rate factor.
In this embodiment, the encoder may first use a ratio of the quantization specific gravity to the code rate factor as an initial quantization level of the current frame.
In the embodiment of the present application, an encoder may calculate a ratio of a quantization specific gravity, rceq, to a code rate factor, rateactor, by using formula (10), to obtain an initial quantization level of a current frame:
qscale=rceq/ratefactor (10)
in equation (10), qscale is the initial quantization level of the current frame.
In the embodiment of the present application, after the encoder obtains the initial quantization level of the current frame, the encoder may adjust the initial quantization level based on a preset target bit number to obtain the quantization level of the current frame.
In the embodiment of the application, the preset target bit number is the size of a receiving end buffer area corresponding to the coded video, and the encoder can adjust the initial quantization level according to the deviation between the preset target bit number and the total bit value generated after the current frame is actually coded through the cache control module to obtain the quantization level of the current frame, so that the generated code stream is stable in size.
S1034, based on the mapping relation between the preset quantization level and the initial quantization step length, converting the quantization level of the current frame into the initial quantization step length.
In the embodiment of the present application, the mapping relationship between the preset quantization level and the initial quantization step may be as shown in equation (11):
Figure BDA0003649541740000171
in the formula (10), a, b, and c are empirical coefficients, in some embodiments, a may be 12, b may be 6, c may be 0.85, qscale is a quantization level, and QP is a quantization step size obtained by converting the quantization level.
Therefore, after the encoder calculates the quantization level, the quantization level of the current frame may be converted into an initial quantization step based on a mapping relationship between a preset quantization level and the initial quantization step.
In some embodiments of the present application, based on fig. 2 or fig. 7, in S104, the encoder encodes the current frame based on the initial quantization step of the current frame, and obtaining the encoding result of the current frame may be implemented through S1041-S1044, as shown in fig. 10:
s1041, in the macro block level code rate control, after macro block division is carried out on the current frame, the content complexity of each macro block is obtained.
In the embodiment of the application, after a current frame is subjected to macro block division in a macro block level code rate control, complexity data generated when the energy of each macro block is calculated is used as the content complexity corresponding to each macro block.
S1042, according to the content complexity of each macro block and a preset complexity threshold, performing region division on the current frame to obtain at least one region.
In the embodiment of the present application, the encoder first sets a preset complexity threshold, where the preset complexity threshold may be an empirical value, for example, the preset complexity threshold may be a value between [80000,85000], and preferably, the preset complexity threshold may be 82400.
In the embodiment of the application, an encoder performs region division on a current frame by taking a macro block as a unit according to the comparison between the content complexity of each macro block and a preset complexity threshold, and divides the macro blocks with the complexity higher than and lower than the preset complexity threshold into different regions, so as to obtain at least one region. Wherein the complexity of each of the at least one region is different.
In some embodiments, the encoder may divide the current frame into a high complexity region and a low complexity region by presetting a complexity threshold.
S1043, determining a preset quantization intensity factor of each region in the at least one region, and adjusting the initial quantization step size according to the preset quantization intensity factor corresponding to each region to obtain a quantization step size corresponding to each region.
In the embodiment of the present application, the encoder first determines the area complexity of each area according to the content complexity of the macro block included in each area.
In some embodiments, the encoder may calculate an average of content complexity of each macroblock included in each region, as the region complexity of each region, or may also select the average according to other calculation methods, such as variance, and the like, specifically according to actual situations, which is not limited in this embodiment of the application.
In the embodiment of the application, the encoder determines the preset quantization strength factor of each region according to the preset corresponding relationship between the region complexity and the preset quantization strength factor. Wherein the predetermined quantization strength factor is inversely proportional to the region complexity.
In the embodiment of the present application, the preset quantization strength factor aq _ strength may be used to adjust the flat region blocking effect and the texture region blurring effect. The higher aq _ strength is, the more the high-frequency information of the complex region is reduced, but the definition of the flat region is improved, which also means that the texture is blurred, and conversely, the lower aq _ strength is, the more the high-frequency information of the complex region is retained, and the definition of the flat region is reduced, that is, the texture region is clearer.
In some embodiments, the encoder may divide the current frame into a high complexity region and a low complexity region, and set a preset quantization strength factor aq _ strength of the high complexity region to be 0.5, and set a preset quantization strength factor aq _ strength of the low complexity region to be 1.0, so as to reduce a blur phenomenon through the lower aq _ strength, and improve the overall quality of the encoded video, where specific codes are as follows:
Figure BDA0003649541740000181
Figure BDA0003649541740000191
in the above code, h- > param.rc.f _ aq _ strengthh _ cplx is 0.5, and represents a preset quantization strength factor aq _ strength of a high complexity region, and frame- > s _ cplx is the region complexity obtained according to the content complexity of each macroblock in the region, and when the region complexity is greater than a preset complexity threshold 82400, the encoder may use the high complexity quantization strength factor aq _ strength, that is, 0.5, to set an initial quantization step size of the high complexity region, so as to reduce the high complexity region blurring phenomenon.
In the embodiment of the application, the encoder determines the preset quantization strength factor set on each region according to the region complexity of each region by the same method, and adjusts the initial quantization step according to the preset quantization strength factor set on each region, so as to correspondingly obtain the quantization step corresponding to each region. That is to say, the quantization step finally calculated by the current frame in the embodiment of the present application is at least one quantization step, and the at least one quantization step corresponds to the complexity of the content scene in the current frame, and can be adaptively adjusted according to the regional complexity of the content scene.
And S1044, coding each region of the current frame according to the quantization step corresponding to each region to obtain a coding result of the current frame.
In the embodiment of the application, the encoder encodes each region of the current frame according to the quantization step corresponding to each region to obtain the encoding result of the current frame.
It can be understood that, in the embodiment of the present application, the encoder performs region division on the current frame through the complexity of the macro block, so that when the quantization step length is adjusted in the process of controlling the code rate at the macro block level, region-based adaptive adjustment can be performed according to the complexity of the current frame, the accuracy of the quantization step length is improved, and thus the accuracy of the encoded video is improved.
In some embodiments, based on the encoding method provided in the embodiments of the present application, common standard video data is used as a test sequence on an x.264 software encoding platform, the resolution of the video is fixedly set to 960 × 540, an ABR mode is used for an encoding algorithm, and a code rate is set to be relatively low 1.2Mb/s, based on which, the encoded video obtained by the current encoding method, the objective PSNR value of the encoded video obtained by the encoding method in the embodiments of the present application, and the corresponding code rate control condition are respectively tested, and the experimental results are shown in table 1. Table 1 shows the comparison between the bit rate and the PSNR of the encoded video obtained by the current encoding method and the encoding method of the embodiment of the present application, as follows:
Figure BDA0003649541740000201
TABLE 1
As can be seen from the comparative data in table 1, the encoding scheme optimized in the embodiment of the present application can ensure the capability of the encoder for controlling the code rate, and does not cause failure of the code rate control due to the introduction of the algorithm, and meanwhile, the overall average improvement in the objective quality of the PSNR is about 0.145dB, so that it can be concluded that the encoding method provided in the embodiment of the present application can improve the video quality of the encoded video, and does not cause compression rate burden.
An encoder is provided in the embodiment of the present application, fig. 11 is a schematic structural diagram of a composition of the encoder provided in the embodiment of the present application, and as shown in fig. 11, the encoder 110 includes: an obtaining unit 1101, a calculating unit 1102, a quantizing unit 1103, and an encoding unit 1104, wherein,
the obtaining unit 1101 is configured to, when a current frame is a first frame in a video to be encoded, obtain image information of the current frame in an inter-frame level code rate control process;
the calculating unit 1102 is configured to calculate a complexity cumulative value of the current frame based on the image information of the current frame;
the quantization unit 1103 is configured to perform coding quantization estimation on the current frame based on the complexity cumulative value of the current frame, so as to obtain an initial quantization step size of the current frame;
the encoding unit 1104 is configured to encode the current frame based on the initial quantization step of the current frame, so as to obtain an encoding result of the current frame.
In some embodiments, the image information includes any one of an average macroblock energy of the first frame, a gradient value of the first frame, edge information of the first frame, and histogram information of the first frame.
In some embodiments, the image information is an average macroblock energy of the first frame, and the calculating unit 1102 is further configured to perform complexity evaluation on the current frame according to the average macroblock energy, preset first frame coding bits, and at least one preset fitting factor to obtain an estimated coding complexity of the current frame; the at least one preset fitting factor is used for fitting a relation curve between the average macro block energy and an initial quantization step; and calculating the complexity accumulated value of the current frame based on the estimated coding complexity.
In some embodiments, the calculating unit 1102 is further configured to multiply the average macroblock energy by a first fitting factor to obtain a first product result; multiplying the preset first frame code bit by a second fitting factor to obtain a second product result; calculating a difference value obtained by subtracting the second product result from the first product result, and adding the difference value and a third fitting factor to obtain the estimated encoding complexity; wherein the at least one predetermined fitting factor includes the first fitting factor, the second fitting factor, and the third fitting factor.
In some embodiments, the obtaining unit 1101 is further configured to perform macroblock division on the current frame in a macroblock-level code rate control process to obtain at least one macroblock; an average macroblock energy of the at least one macroblock is calculated.
In some embodiments, the calculating unit 1102 is further configured to obtain a macroblock number of the at least one macroblock; and performing initial value calculation on the complexity accumulated value according to the estimated coding complexity, the number of the macro blocks of the at least one macro block and the preset compression parameter to obtain the complexity accumulated value of the current frame.
In some embodiments, the calculating unit 1102 is further configured to perform an operation on the preset compression parameter as the power of the estimated coding complexity, and multiply an operation result by a preset coefficient and a power of half of the number of the macro blocks to obtain the complexity accumulated value of the current frame.
In some embodiments, the obtaining unit 1101 is further configured to calculate gradient values, edge information, or histogram information of the current frame according to pixel information included in the current frame.
In some embodiments, the encoding unit 1104 is further configured to, in macroblock-level rate control, obtain content complexity of each macroblock after performing macroblock division on the current frame; according to the content complexity of each macro block and a preset complexity threshold, carrying out region division on the current frame to obtain at least one region; determining a preset quantization intensity factor of each region in the at least one region, and adjusting the initial quantization step size according to the preset quantization intensity factor corresponding to each region to obtain a quantization step size corresponding to each region; and coding each region of the current frame according to the quantization step corresponding to each region to obtain a coding result of the current frame.
In some embodiments, the encoding unit 1104 is further configured to determine the region complexity of each region according to the content complexity of the macro block included in each region; determining a preset quantization intensity factor of each region according to a preset corresponding relation between the region complexity and a preset quantization intensity factor; the preset quantization intensity factor is inversely proportional to the region complexity.
In some embodiments, the quantization unit 1103 is further configured to perform blur complexity estimation on the current frame, perform compression processing on the estimated blur complexity, and calculate the complexity of the current frame; calculating the ratio of the total bit value of the coded frame in the video to be coded to the complexity accumulated value to obtain a code rate factor of the current frame; obtaining the quantization level of the current frame based on the complexity and the code rate factor; and converting the quantization level of the current frame into the initial quantization step based on the mapping relation between a preset quantization level and the initial quantization step.
In some embodiments, the quantization unit 1103 is further configured to use a ratio of the complexity to the code rate factor as an initial quantization level of the current frame; and adjusting the initial quantization level based on a preset target bit number to obtain the quantization level of the current frame.
In some embodiments, the calculating unit 1102 is configured to, before performing coding quantization estimation on the current frame based on the complexity cumulative value of the current frame to obtain an initial quantization step of the current frame, perform complexity accumulation processing based on a coded bit number of a previous frame corresponding to the current frame and a quantization parameter of the previous frame to obtain the complexity cumulative value of the current frame when the current frame is a non-first frame in the video to be coded.
It should be noted that the above description of the embodiment of the apparatus, similar to the above description of the embodiment of the method, has similar beneficial effects as the embodiment of the method. For technical details not disclosed in the embodiments of the apparatus of the present application, reference is made to the description of the embodiments of the method of the present application for understanding.
It should be noted that, in the embodiment of the present application, if the information display method is implemented in the form of a software functional module and is sold or used as an independent product, the information display method may also be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application or portions thereof that contribute to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which may be a terminal, a server, etc.) to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read Only Memory (ROM), a magnetic disk, or an optical disk. Thus, embodiments of the present application are not limited to any specific combination of hardware and software.
Correspondingly, the embodiment of the present application further provides a computer program product, where the computer program product includes computer-executable instructions for implementing the steps in the encoding method provided by the embodiment of the present application.
Accordingly, embodiments of the present application further provide a computer storage medium, where computer-executable instructions are stored on the computer storage medium, and the computer-executable instructions are used to implement the steps of the encoding method provided in the foregoing embodiments.
An embodiment of the present application further provides an encoder, fig. 12 is a schematic diagram of a composition structure of the encoder provided in the embodiment of the present application, and as shown in fig. 12, the encoder 1200 includes: a memory 1201 for storing a computer program;
a processor 1202, configured to implement the steps of the encoding method provided in the foregoing embodiment when executing the computer program stored in the memory 1201;
the encoder 1200 also includes a communication bus 1203; for connecting the memory 1201 and the processor 1202, and for implementing connection communication between the memory 1201 and the processor 1202.
The Memory 1201 is configured to store computer programs and applications to be processed by the processor 1202, and may also buffer data (e.g., image data, audio data, voice communication data, and video communication data) to be processed or already processed by the processor 1202 and modules in the encoder, and may be implemented by a FLASH Memory (FLASH) or a Random Access Memory (RAM).
The processor 1202 implements the steps of any of the above-described encoding methods when executing the program.
The Processor 1103 may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understood that the electronic device implementing the above-described processor function may be other electronic devices, and the embodiments of the present application are not limited thereto.
The computer-readable storage medium/Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read Only Memory (EPROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a magnetic Random Access Memory (FRAM), a Flash Memory (Flash Memory), a magnetic surface Memory, an optical Disc, or a Compact Disc Read-Only Memory (CD-ROM), and the like; but may also be various terminals such as mobile phones, computers, tablet devices, personal digital assistants, etc., that include one or any combination of the above-mentioned memories.
Here, it should be noted that: the above description of the storage medium and device embodiments is similar to the description of the method embodiments above, with similar advantageous effects as the method embodiments. For technical details not disclosed in the embodiments of the storage medium and apparatus of the present application, reference is made to the description of the embodiments of the method of the present application for understanding.
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in the various embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application. The above-mentioned serial numbers of the embodiments of the present application are merely for description, and do not represent the advantages and disadvantages of the embodiments.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units; can be located in one place or distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the scheme of the embodiment of the application.
In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit may be implemented in the form of hardware, or in the form of hardware plus a software functional unit.
Alternatively, the integrated units described above in the present application may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as independent products. Based on such understanding, the technical solutions of the embodiments of the present application may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing an automatic test line of a device to perform all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a removable storage device, a ROM, a magnetic or optical disk, or other various media that can store program code.
The methods disclosed in the several method embodiments provided in the present application may be combined arbitrarily without conflict to obtain new method embodiments.
The features disclosed in the several method or apparatus embodiments provided in the present application may be combined arbitrarily, without conflict, to arrive at new method embodiments or apparatus embodiments.
The above description is only for the embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (17)

1. An encoding method applied to an encoder, the method comprising:
in the process of controlling the code rate of the interframe level, coding quantization estimation is carried out on the current frame based on the complexity accumulated value of the current frame to obtain the initial quantization step length of the current frame;
in the macro-block-level code rate control, after macro-block division is carried out on the current frame, the content complexity of each macro-block is obtained;
dividing the current frame into at least one region based on the content complexity of each macro block, and determining a preset quantization intensity factor corresponding to each region in the at least one region;
adjusting the initial quantization step size according to the preset quantization intensity factor corresponding to each region to obtain the quantization step size corresponding to each region;
and coding each region of the current frame according to the quantization step corresponding to each region to obtain a coding result of the current frame.
2. The method of claim 1, wherein the dividing the current frame into at least one region based on the content complexity of each macroblock comprises:
and according to the content complexity of each macro block and a preset complexity threshold, carrying out region division on the current frame to obtain the at least one region.
3. The method of claim 1, wherein determining the preset quantization intensity factor for each of the at least one region comprises:
determining the area complexity of each area according to the content complexity of the macro block contained in each area;
determining a preset quantization intensity factor of each region according to a preset corresponding relation between the region complexity and a preset quantization intensity factor; the preset quantization intensity factor is inversely proportional to the region complexity.
4. The method according to any one of claims 1-3, wherein before performing the encoded quantization estimation on the current frame based on the complexity accumulation value of the current frame to obtain the initial quantization step size of the current frame, the method further comprises:
when the current frame is the first frame in the video to be coded, acquiring image information of the current frame in the process of controlling the inter-frame level code rate;
and calculating the complexity accumulated value of the current frame based on the image information of the current frame.
5. The method according to claim 4, wherein the image information comprises any one of an average macroblock energy of the first frame, a gradient value of the first frame, edge information of the first frame, and histogram information of the first frame.
6. The method according to claim 5, wherein the image information is an average macroblock energy of the first frame, and the calculating a complexity cumulative value of the current frame based on the image information of the current frame comprises:
performing complexity evaluation on the current frame according to the average macro block energy, a preset first frame coding bit and at least one preset fitting factor to obtain an estimated coding complexity of the current frame; the at least one preset fitting factor is used for fitting a relation curve between the average macro block energy and an initial quantization step;
and calculating the complexity accumulated value of the current frame based on the estimated coding complexity.
7. The method of claim 6, wherein the performing complexity estimation on the current frame according to the average macroblock energy, a preset first frame coding bit and at least one preset fitting factor to obtain an estimated coding complexity of the current frame comprises:
multiplying the average macro block energy by a first fitting factor to obtain a first product result;
multiplying the preset first frame code bit by a second fitting factor to obtain a second product result;
calculating a difference value obtained by subtracting the second product result from the first product result, and adding the difference value and a third fitting factor to obtain the estimated encoding complexity; wherein the at least one predetermined fitting factor includes the first fitting factor, the second fitting factor, and the third fitting factor.
8. The method of claim 6, wherein the obtaining the image information of the current frame comprises:
in the macro-block level code rate control process, carrying out macro-block division on the current frame to obtain at least one macro-block;
an average macroblock energy of the at least one macroblock is calculated.
9. The method of claim 8, wherein the calculating a complexity accumulation value for the current frame based on the pre-estimated coding complexity comprises:
acquiring the macroblock number of the at least one macroblock;
and performing initial value calculation on the complexity accumulated value according to the estimated coding complexity, the number of the macro blocks of the at least one macro block and the preset compression parameter to obtain the complexity accumulated value of the current frame.
10. The method of claim 9, wherein the performing an initial calculation on the accumulated complexity value according to the estimated coding complexity, the number of macroblocks of the at least one macroblock, and the preset compression parameter to obtain the accumulated complexity value of the current frame comprises:
and taking the preset compression parameter as the power of the estimated coding complexity for operation, and multiplying the operation result by a preset coefficient and the power of half of the number of the macro blocks to obtain the complexity accumulated value of the current frame.
11. The method of claim 5, wherein the obtaining the image information of the current frame comprises:
and calculating gradient values, edge information or histogram information of the current frame according to pixel information contained in the current frame.
12. The method according to any one of claims 1-11, wherein said performing an encoded quantization estimation on the current frame based on the complexity accumulation value of the current frame to obtain an initial quantization step size of the current frame comprises:
performing fuzzy complexity estimation on the current frame, performing compression processing on the estimated fuzzy complexity, and calculating to obtain the complexity of the current frame;
calculating the ratio of the total bit value of the coded frame in the video to be coded to the complexity accumulated value to obtain the code rate factor of the current frame;
obtaining the quantization level of the current frame based on the complexity and the code rate factor;
and converting the quantization level of the current frame into the initial quantization step based on the mapping relation between a preset quantization level and the initial quantization step.
13. The method of claim 12, wherein deriving the quantization level of the current frame based on the complexity and the rate factor comprises:
taking the ratio of the complexity to the code rate factor as the initial quantization level of the current frame;
and adjusting the initial quantization level based on a preset target bit number to obtain the quantization level of the current frame.
14. The method according to any of claims 1-11, wherein before performing the encoded quantization estimation on the current frame based on the complexity accumulation value of the current frame to obtain the initial quantization step size of the current frame, the method further comprises:
and when the current frame is a non-first frame in the video to be coded, carrying out accumulation processing on the complexity based on the coded bit number of a previous frame corresponding to the current frame and the quantization parameter of the previous frame to obtain the complexity accumulation value of the current frame.
15. An encoder, comprising: a quantization unit and an encoding unit, wherein,
the quantization unit is used for performing coding quantization estimation on the current frame based on the complexity accumulated value of the current frame in the process of controlling the inter-frame level code rate to obtain the initial quantization step length of the current frame;
the coding unit is used for obtaining the content complexity of each macro block after macro block division is carried out on the current frame in macro block level code rate control; dividing the current frame into at least one region based on the content complexity of each macro block, and determining a preset quantization intensity factor corresponding to each region in the at least one region; adjusting the initial quantization step size according to the preset quantization intensity factor corresponding to each region to obtain the quantization step size corresponding to each region; and coding each region of the current frame according to the quantization step corresponding to each region to obtain a coding result of the current frame.
16. An encoder, comprising:
a memory for storing executable data instructions;
a processor for implementing the method of any one of claims 1 to 14 when executing executable instructions stored in the memory.
17. A computer-readable storage medium having stored thereon executable instructions for causing a processor, when executed, to implement the method of any one of claims 1 to 14.
CN202210546977.8A 2020-07-17 2020-07-17 Encoding method, encoder and computer readable storage medium Pending CN114979640A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210546977.8A CN114979640A (en) 2020-07-17 2020-07-17 Encoding method, encoder and computer readable storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210546977.8A CN114979640A (en) 2020-07-17 2020-07-17 Encoding method, encoder and computer readable storage medium
CN202010693484.8A CN111866504B (en) 2020-07-17 2020-07-17 Encoding method, encoder and computer readable storage medium

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202010693484.8A Division CN111866504B (en) 2020-07-17 2020-07-17 Encoding method, encoder and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN114979640A true CN114979640A (en) 2022-08-30

Family

ID=73001604

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202010693484.8A Active CN111866504B (en) 2020-07-17 2020-07-17 Encoding method, encoder and computer readable storage medium
CN202210546977.8A Pending CN114979640A (en) 2020-07-17 2020-07-17 Encoding method, encoder and computer readable storage medium

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202010693484.8A Active CN111866504B (en) 2020-07-17 2020-07-17 Encoding method, encoder and computer readable storage medium

Country Status (2)

Country Link
CN (2) CN111866504B (en)
WO (1) WO2022012183A1 (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111866504B (en) * 2020-07-17 2022-06-21 Oppo广东移动通信有限公司 Encoding method, encoder and computer readable storage medium
CN113573070A (en) * 2021-06-03 2021-10-29 浙江大华技术股份有限公司 Image coding method and device and computer storage medium
CN113438488B (en) * 2021-06-18 2023-01-31 北京锐马视讯科技有限公司 Low-bit-rate video optimization coding method, device, equipment and storage medium
CN113612999B (en) * 2021-08-20 2024-03-22 北京市商汤科技开发有限公司 Video processing method and device, electronic equipment and storage medium
CN113784126A (en) * 2021-09-17 2021-12-10 Oppo广东移动通信有限公司 Image encoding method, apparatus, device and storage medium
CN116205277A (en) * 2021-11-30 2023-06-02 北京灵汐科技有限公司 Event processing method and device, electronic equipment and computer readable medium
CN114245127B (en) * 2021-12-13 2024-03-19 北京百度网讯科技有限公司 Parameter adjustment method, device, equipment and medium of cloud desktop encoder
CN114584834B (en) * 2022-01-27 2024-02-13 百果园技术(新加坡)有限公司 Video quality optimization method, device, equipment and storage medium
CN115002512B (en) * 2022-05-23 2023-11-28 北京市商汤科技开发有限公司 Video transcoding method and device, electronic equipment and storage medium
CN116095319A (en) * 2022-07-26 2023-05-09 杭州海康威视数字技术股份有限公司 Video decoding method, device and storage medium
CN116567286B (en) * 2023-07-10 2023-09-22 武汉幻忆信息科技有限公司 Online live video processing method and system based on artificial intelligence
CN116896641B (en) * 2023-09-11 2023-12-12 禹创半导体(深圳)有限公司 Image compression method, device, equipment and storage medium

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102036062B (en) * 2009-09-29 2012-12-19 华为技术有限公司 Video coding method and device and electronic equipment
CN101882316A (en) * 2010-06-07 2010-11-10 深圳市融创天下科技发展有限公司 Method, device and system for regional division/coding of image
CN102036074A (en) * 2010-12-21 2011-04-27 汉王科技股份有限公司 Embedded equipment-based code rate control method and device
CN104219522B (en) * 2013-06-04 2018-02-16 北京大学 Bit rate control method and device in a kind of encoding video pictures
CN104796725B (en) * 2014-01-21 2019-10-01 Vixs系统公司 With method intra prediction pretreated video encoder and be used therewith
US20150215621A1 (en) * 2014-01-30 2015-07-30 Qualcomm Incorporated Rate control using complexity in video coding
CN105049850B (en) * 2015-03-24 2018-03-06 上海大学 HEVC bit rate control methods based on area-of-interest
US20180324439A1 (en) * 2017-05-08 2018-11-08 Mediatek Inc. Method and apparatus for adaptive video encoding
CN109076212A (en) * 2017-12-27 2018-12-21 深圳市大疆创新科技有限公司 The method and code device of code rate control
CN109168030B (en) * 2018-10-12 2021-03-26 中南大学 Video transcoding method, device and storage medium thereof
CN111866504B (en) * 2020-07-17 2022-06-21 Oppo广东移动通信有限公司 Encoding method, encoder and computer readable storage medium

Also Published As

Publication number Publication date
WO2022012183A1 (en) 2022-01-20
CN111866504A (en) 2020-10-30
CN111866504B (en) 2022-06-21

Similar Documents

Publication Publication Date Title
CN111866504B (en) Encoding method, encoder and computer readable storage medium
CN109068137B (en) Region of interest aware video coding
JP4847521B2 (en) Block noise removal filtering technology for video encoding according to multiple video standards
CN108574841B (en) Coding method and device based on self-adaptive quantization parameter
US20080240235A1 (en) Adaptive deadzone size adjustment in quantization
JP6989491B2 (en) Quantization methods and equipment in video coding and decoding
JP6881819B2 (en) Video transcoding methods, computer equipment, and storage media
JP2002335527A (en) Moving picture frame encoding method and adaptive quantization method and data compression rate deciding method and encoder
KR101603747B1 (en) Method and apparatus for rate control accuracy in video encoding
CN104041035A (en) Lossless Coding and Associated Signaling Methods for Compound Video
JPWO2009050889A1 (en) Video decoding method and video encoding method
JP6568078B2 (en) Method and apparatus for encoding image data and method and apparatus for decoding image data
JP2001512651A (en) Calculation method of quantization matrix for each frame
JP2012527160A (en) Method and apparatus for adjusting improved quantization rounding offset for video encoding and decoding
KR20180073231A (en) Apparatus and method for encoding video adjusting quantization parameter
KR20150123810A (en) Method and device for selecting an image dynamic range conversion operator
KR20180074150A (en) Method and apparatus for video data encoding with sao filtering
TWI428022B (en) Video control method for instant video encoding chips
JP2005530423A (en) Method and system for optimizing image sharpness during encoding
WO2022021422A1 (en) Video coding method and system, coder, and computer storage medium
KR20080005747A (en) Improvement device and quantization for the quality of image with roi and the method for operating
EP2060125A2 (en) Method and apparatus for analytical and empirical hybrid encoding distortion modeling
RU2587412C2 (en) Video rate control based on transform-coefficients histogram
CN112866696A (en) 4K, 8K and 16K ultra-high-definition video coding optimization control method and device
CN109618155B (en) Compression encoding method

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