CN115941946A - Video coding method and related device, coding equipment and storage medium - Google Patents

Video coding method and related device, coding equipment and storage medium Download PDF

Info

Publication number
CN115941946A
CN115941946A CN202211139813.XA CN202211139813A CN115941946A CN 115941946 A CN115941946 A CN 115941946A CN 202211139813 A CN202211139813 A CN 202211139813A CN 115941946 A CN115941946 A CN 115941946A
Authority
CN
China
Prior art keywords
parameter
quality
current frame
quantization parameter
quality parameter
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
CN202211139813.XA
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.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology 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 Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202211139813.XA priority Critical patent/CN115941946A/en
Publication of CN115941946A publication Critical patent/CN115941946A/en
Pending legal-status Critical Current

Links

Images

Abstract

The application discloses a video coding method and a related device, coding equipment and a storage medium, wherein the video coding method comprises the following steps: analyzing the actually allocated code rate based on a code rate control model to obtain a first quantization parameter of a current frame in the video to be coded; mapping the first quantization parameter based on the numerical value mapping relation to obtain a first quality parameter of the current frame; determining whether to correct the first quantization parameter based on a first difference value between the first quality parameter and a second quality parameter of the reference frame to obtain a target quantization parameter of the current frame; the reference frame is a frame which is positioned in front of the current frame in the video to be coded; the second quality parameter characterizes a value of the quality parameter after encoding the reference frame based on the second quantization parameter; on this basis, the current frame is encoded based on the target quantization parameter of the current frame. According to the scheme, the video quality stability can be ensured, and the visual sudden change can be reduced as much as possible.

Description

Video coding method and related device, coding equipment and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a video encoding method, a related apparatus, an encoding device, and a storage medium.
Background
In recent years, with continuous optimization of information infrastructure, demands for high definition and ultra high definition in the field of audios and videos are increasing, and the innovation progress of the technology in the field of videos is deeply influenced, and particularly, the video coding technology becomes one of the research and development fields with important investment.
In the traditional video coding method, in the process of coding the current frame, the user experience is poor due to the fact that the subjective quality stability cannot be ensured and the visual mutation happens. In view of the above, how to ensure video quality stability and reduce visual mutation as much as possible is an urgent problem to be solved.
Disclosure of Invention
The technical problem mainly solved by the present application is to provide a video encoding method, and a related apparatus, an encoding device, and a storage medium, which can ensure video quality stability and reduce visual sudden changes as much as possible.
In order to solve the above problem, a first aspect of the present application provides a video encoding method, including: analyzing the actually allocated code rate based on a code rate control model to obtain a first quantization parameter of a current frame in the video to be coded; mapping the first quantization parameter based on a numerical mapping relation to obtain a first quality parameter of the current frame, wherein the numerical mapping relation represents a corresponding relation between the quantization parameter and the quality parameter; the first quality parameter represents a value of a quality parameter after encoding the current frame based on the first quantization parameter; determining whether to correct the first quantization parameter based on a first difference value between the first quality parameter and a second quality parameter of the reference frame to obtain a target quantization parameter of the current frame; the reference frame is a previous frame positioned in the current frame in the video to be coded; the second quality parameter characterizes a value of the quality parameter after encoding the reference frame based on the second quantization parameter; on this basis, the current frame is encoded based on the target quantization parameter of the current frame.
In order to solve the above problem, a second aspect of the present application provides a video encoding apparatus, which includes an obtaining module, an analyzing module, a mapping module, a determining module, and an encoding module. The analysis module is used for analyzing based on a code rate control model and an actual allocated code rate to obtain a first quantization parameter of a current frame in a video to be coded; the mapping module is used for mapping the first quantization parameter based on the numerical value mapping relation to obtain a first quality parameter of the current frame; the numerical value mapping relationship represents the corresponding relationship between the quantitative parameters and the quality parameters; the first quality parameter represents a value of a quality parameter after encoding the current frame based on the first quantization parameter; the determining module is used for determining whether to correct the first quantization parameter based on a first difference value between the first quality parameter and a second quality parameter of the reference frame to obtain a target quantization parameter of the current frame; the reference frame is a previous frame positioned in the current frame in the video to be coded; the second quality parameter characterizes a value of the quality parameter after encoding the reference frame based on the second quantization parameter; the encoding module is used for encoding the current frame based on the target quantization parameter of the current frame.
In order to solve the above problem, a third aspect of the present application provides an encoding apparatus, which includes a memory and a processor coupled to each other, the memory storing program instructions, and the processor being configured to execute the program instructions to implement the video encoding method in the first aspect.
In order to solve the above problem, a fourth aspect of the present application provides a computer-readable storage medium storing program instructions executable by a processor, the program instructions being for implementing the video encoding method in the first aspect.
According to the scheme, the actually allocated code rate is analyzed based on the code rate control model, and a first quantization parameter of a current frame in the video to be coded is obtained; mapping the first quantization parameter based on a numerical mapping relation to obtain a first quality parameter of the current frame, wherein the numerical mapping relation represents a corresponding relation between the quantization parameter and the quality parameter; the first quality parameter represents the value of the quality parameter after the current frame is coded based on the first quantization parameter; determining whether to correct the first quantization parameter based on a first difference value between the first quality parameter and a second quality parameter of the reference frame to obtain a target quantization parameter of the current frame; the reference frame is a frame which is positioned in front of the current frame in the video to be coded; the second quality parameter characterizes a value of the quality parameter after encoding the reference frame based on the second quantization parameter; on the basis, the current frame is coded based on the target quantization parameter of the current frame. On one hand, the first quantization parameter of the current frame in the video to be coded is obtained by analyzing based on a code rate control model and the actually allocated code rate, so that the accuracy of the current frame in the video to be coded relative to the video coding parameter is improved, on the other hand, whether the first quantization parameter is corrected or not is determined by constraining the numerical values of the quality parameters of the front frame and the rear frame, namely, by the first difference value between the coding parameters of the front frame and the rear frame, so that after the video to be coded is coded, the video quality stability can be ensured, and the visual mutation is reduced as much as possible.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the application.
FIG. 1 is a schematic flowchart of an embodiment of a video encoding method of the present application;
FIG. 2 is a flowchart illustrating an embodiment of a process for obtaining a target quantization parameter of a current frame;
FIG. 3 is a schematic flow chart diagram illustrating another embodiment of a video encoding method of the present application;
FIG. 4 is a block diagram of an embodiment of a video encoding apparatus of the present application;
FIG. 5 is a block diagram of an embodiment of the encoding apparatus of the present application;
FIG. 6 is a block diagram of an embodiment of a computer-readable storage medium of the present application.
Detailed Description
The embodiments of the present application will be described in detail below with reference to the drawings.
In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular system structures, interfaces, techniques, etc. in order to provide a thorough understanding of the present application.
The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship. Further, the term "plurality" herein means two or more than two. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of a, B, and C, and may mean including any one or more elements selected from the group consisting of a, B, and C.
Referring to fig. 1, fig. 1 is a flowchart illustrating a video encoding method according to an embodiment of the present application.
Specifically, the method may include the steps of:
step S11: and analyzing based on the code rate control model and the actual allocated code rate to obtain a first quantization parameter of the current frame in the video to be coded.
In an implementation scenario, before analyzing based on the rate control model and the actually allocated rate to obtain the first quantization parameter of the current frame in the video to be encoded, the actually allocated rate may be obtained first. Specifically, the user may directly input the set allocation code rate, and after obtaining the allocation code rate set by the user, determine the set allocation code rate as the actual allocation code rate.
In another implementation scenario, in order to improve accuracy of actually allocating a code rate, a target allocation code rate and a target quality level set by a user may be received first, where the target allocation code rate is a code rate expected to be allocated by the user, and the target quality level is not greater than a highest quality level. After the target allocation code rate and the target quality level set by the user are obtained, the target allocation code rate can be weighted based on the ratio between the target quality level and the highest quality level to obtain the actual allocation code rate. Is exemplified byIs provided with R target Allocating code rate for the target set by the user, quality being the target quality level max For the highest quality level, the function represents the function, and then the code rate R is actually allocated alloc Can be calculated by the following formula:
R alloc =function(R target ,quality,quality max )
the function includes, but is not limited to, the following formula:
Figure BDA0003853099210000041
wherein, theta is a weighting coefficient, and the value range of theta is between 0 and 1. In a specific implementation scenario, the value range of θ may be 0.9 to 1, so that the actual allocation code rate does not reach the target allocation code rate during the weighting process. By weighting the target allocation code rate, the error in the process of confirming the actual allocation code rate can be reduced, and the accuracy of the obtained quantization parameter is improved.
In an implementation scenario, after the actual allocated code rate is obtained, analysis may be further performed based on a code rate control model and the actual allocated code rate to obtain a first quantization parameter of a current frame in a video to be encoded. Illustratively, the QP, quantization factors λ, ρ, and the like of a current frame in the coded video may be calculated based on a rate control model, specifically, the parameter values of QP, λ, and the like may be calculated by an R- λ model, the parameter values of QP, Q, and the like may be calculated by an R-Q model, and the parameter values of ρ, QP, and the like may be calculated by an R- ρ model. It should be noted that the rate control model is selected from a model set, the model set at least comprises at least one of an R- λ model, an R- ρ model and an R-Q model, the rate control model represents a corresponding relationship between quantization parameters and a rate, the quantization parameters comprise any one of QP and quantization factors of the rate control model, when the R- λ model is selected as the rate control model, the quantization factor is λ, when the R- ρ model is selected as the rate control model, the quantization factor is ρ, and when the R-Q model is selected, the quantization factor is qscale.
In one specific implementation scenario, the rate control model is an R- λ model, and the R- λ model constructs a mapping relationship between allocated bits R (bpp) and a quantization factor λ, which can be expressed as follows:
λ=α·bpp β
where α and β are parameters, α and β can be initialized, illustratively, α can be initialized to 3.2003, β can be initialized to-1.367, and bpp can be set to 0.4, and of course, α can also be initialized to 3, β can be initialized to-1, and bpp can be set to 0.3. The initialization value of the parameter may be set according to actual conditions, and is not specifically limited herein. For example, with α initialized to 3.2003, β initialized to-1.367, bpp set to 0.4, the calculation for λ is:
λ=α·bpp β =3.2003*(0.4) -1.367 =11.2
and calculating a quantization factor lambda value of the current frame about video coding through the allocated bit bpp and the parameters alpha and beta, solving the quantization parameter QP through a fixed mapping relation by lambda, wherein the mapping relation between the lambda and the QP is expressed as follows:
QP=4.2*ln(λ)+13=4.2*ln(11.2)+13≈24
it should be noted that QP is a number of quantization step, and therefore must be an integer. The value of the quantization factor lambda 11.2 and the value 24 of the quantization parameter QP of the current frame with respect to video coding can thus be derived.
Further, after obtaining the quantization factor of the current frame with respect to video coding, parameters in the mapping relationship between the allocation bit R (bpp) and the quantization factor λ may also be updated, and specifically, α and β may be updated on the basis of the quantization parameter of the previous frame, thereby ensuring that the difference between the quantization parameters of each frame is small. The updating method adopted by the parameter α can be expressed as follows:
α new =α oldα *(ln(λ act )-ln(λ com ))*α old
wherein alpha is new Representing the updated parameter α, α old Representing the quantization parameters alpha, theta of the previous frame α Representing coefficients for adjusting the convergence speed of the formula,the setting can be performed according to actual conditions, and exemplarily, the setting can be 0.1. Lambda [ alpha ] act The method is obtained by calculating the QP actually adopted in the previous frame video coding process through the mapping relation, namely firstly obtaining the QP actually adopted in the previous frame video coding process, and then calculating the lambda through the mapping relation between the lambda and the QP act A value; lambda [ alpha ] com The method is obtained by calculating the actually adopted distribution bit bpp in the previous frame video coding process through a mapping relation, and it needs to be noted that in the calculation process, the parameter values of alpha and beta are the quantization parameters of the previous frame, specifically, the actually adopted distribution bit bpp in the previous frame video coding process can be obtained firstly, then the mapping relation between the distribution bit bpp and the quantization factor lambda is calculated to obtain lambda com The value is obtained. The updating method adopted by the parameter β can be expressed as follows:
β new =β oldβ *(ln(λ act )-ln(λ com ))*lnbpp act
wherein, beta new Represents the updated parameter beta, beta old Representing the quantization parameter β, θ of the previous frame β The coefficient is used to adjust the convergence rate of the formula, and may be set according to actual conditions, for example, 0.05, or 0.04, 0.03, and the like, and may be specifically determined according to actual conditions. Lambda [ alpha ] act The method is obtained by calculating the QP actually adopted in the previous frame video coding process through the mapping relation, namely firstly obtaining the QP actually adopted in the previous frame video coding process, and then calculating the lambda through the mapping relation between the lambda and the QP act A value; lambda [ alpha ] com The method is obtained by calculating the actually adopted distribution bit bpp in the previous frame video coding process through a mapping relation, and it needs to be noted that in the calculation process, the parameter values of alpha and beta are the quantization parameters of the previous frame, specifically, the actually adopted distribution bit bpp in the previous frame video coding process can be obtained firstly, then the mapping relation between the distribution bit bpp and the quantization factor lambda is calculated to obtain lambda com A value; bpp act The allocated bit bpp actually used in the video encoding process of the previous frame. After updating the video coding parameters alpha and beta for each frame,and obtaining a per-frame quantization parameter QP based on the updated parameter. Of course, the rate control model may also select an R-Q model, an R- ρ model, etc., and the way of calculating the quantization parameter QP of each frame by different rate control models may be analogized, which is not described herein again.
It should be noted that, if the code rate control parameter is an R- λ model and the quantization parameter is a quantization factor λ, after the quantization parameter is obtained, the QP is further calculated according to a mapping relation expression between λ and QP, so as to obtain a first quantization parameter related to a current frame in the video to be encoded.
Step S12: and mapping the first quantization parameter based on the numerical value mapping relation to obtain a first quality parameter of the current frame.
In an implementation scenario, before mapping the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame, the corresponding relationship between the quantization parameter and the quality parameter, that is, the numerical mapping relationship between the quantization parameter and the quality parameter, may be obtained first. Specifically, the digital mapping relationship between the quality parameter and the quantization parameter in different scenes may be obtained by respectively fitting based on sample videos in different scenes, and it should be noted that the digital mapping relationship may be a digital mapping relationship between any quantization parameter and the quality parameter, for example, when the code rate control model is an R- λ model, the mapping relationship between the quantization factor λ and the quality parameter PSNR may be a mapping relationship between the QP and the quality parameter SSIM. The sample video may be a video taken in the daytime, a video taken in the nighttime, or a video taken in the rainy day. The shooting scene of the sample video can be selected according to the actual situation, and is not specifically limited herein. Specifically, fix-QP encoding may be performed on a sample video in a certain scene for multiple times, that is, a fixed QP (or a fixed quantization factor) is used to encode a certain frame in a video frame, so as to obtain a PSNR, thereby obtaining a quantization parameter corresponding to the frame image, where the quantization parameter corresponding to the frame image may include a time-space domain texture complexity, a QP, a PSNR, and the like, and is not specifically limited herein. After a large number of quantization parameters under different scenes are obtained, fitting is performed, and then a numerical mapping relation between the quality parameters and the quantization parameters is obtained. In the above manner, the sample videos in different scenes are respectively fitted to obtain the numerical mapping relationship between the quality parameters and the quantization parameters in different scenes, which is beneficial to improving the accuracy of the numerical mapping relationship between the quality parameters and the quantization parameters.
In a specific implementation scene, scene detection is performed on the basis of a video to be coded, so that a target scene to which the video to be coded belongs is obtained, and then a numerical mapping relation between quality parameters and quantization parameters in the target scene is selected as a numerical mapping relation suitable for the video to be coded. In the mode, the scene is detected, and the corresponding numerical value mapping relation is selected, so that the accuracy of selecting the numerical value mapping relation between the quality evaluation parameter and the quantization parameter is improved.
In an implementation scenario, the quality parameter represents an evaluation parameter used for evaluating encoding quality after encoding, and for example, the quality parameter may be PSNR (Peak Signal-to-Noise Ratio), or SSIM (Structural Similarity), and the quality parameter may be determined according to an actual situation, which is not limited specifically herein.
In one implementation scenario, the quantization parameter is used to encode each video frame, and the quantization parameter may be determined according to a rate control model. Illustratively, the quantization parameter may include QP, or may include quantization factors λ, ρ, and qscale, and the quantization parameter may be determined according to an actual situation, which is not specifically limited herein. Further, the quantization parameter may be determined according to a rate control model, which is selected from a model set, where the model set at least includes one of an R- λ model, an R- ρ model, and an R-Q model, and certainly, the model set may also include a URQ model. The models in the model set may be selected according to actual conditions, and are not specifically limited herein.
In one implementation scenario, the quantization parameter may be further selected after determining the rate control model. Exemplarily, when the rate control model is an R- λ model, the quantization Parameter includes any one of a quantization factor λ and a QP (Quantizer Parameter), and the quality Parameter may be any one of a PSNR and an SSIM; when the code rate control model is an R-Q model, the quantization parameter comprises any one of quantization factors qscale and QP, and the quality parameter can be any one of PSNR and SSIM; when the rate control model is an R-p model, the quantization parameter includes any one of quantization factors p and QP, and the quality parameter may be any one of PSNR and SSIM. The rate control model may be selected according to an actual situation, and the quantization parameter may be determined according to the rate control model, which is not specifically limited herein.
In one implementation scenario, the numerical mapping between the quality parameter and the quantization parameter may be represented by a functional relationship, which may include, but is not limited to, an exponential function, a logarithmic function, a power function, and the like.
In an implementation scenario, the numerical mapping relationship is further related to the spatial-temporal texture complexity, and several numerical intervals of the spatial-temporal texture complexity respectively correspond to different numerical mapping relationships. Therefore, the complexity value of the current frame with respect to the complexity of the time-space domain texture can be obtained first, and then the numerical mapping relation corresponding to the numerical interval in which the complexity value is located is selected as the numerical mapping relation suitable for the current frame. In the mode, the corresponding numerical value mapping relation is selected based on the complexity value of the current frame relative to the complexity of the time-space domain texture, so that the accuracy of selecting the numerical value mapping relation is improved.
In one implementation scenario, the temporal texture information is used to measure the temporal texture complexity of the current frame, and the spatial texture information is used to measure the spatial texture complexity of the current frame. In order to obtain the complexity value of the current frame with respect to the complexity of the temporal-spatial texture, a first complexity value of the current frame with respect to the complexity of the temporal-spatial texture compared to the reference frame may be obtained first. Specifically, the information of the reference frame can be obtained first, using P curr-1 And then, calculating the time domain texture complexity BlkT of the current block according to the pixel difference value of the current block and the pixel difference value of the block at the same position of the reference frame image, wherein the calculation formula is as follows:
Figure BDA0003853099210000091
where Σ represents the sum of the sums, M, N represent the width and height of the current block, respectively,
Figure BDA0003853099210000092
a value representing a pixel of the current frame,
Figure BDA0003853099210000093
representing the value of the reference frame pixel, | | representing the absolute value. Assuming that the total number of the macro blocks of the current frame image is D, the time domain texture complexity of the current frame image is the average of the sum of the time domain texture complexities of all the macro blocks, and the calculation formula is as follows:
Figure BDA0003853099210000094
where Σ represents the cumulative sum, textureT is the first complexity value of the temporal texture complexity. In addition, a second complexity value of the current frame with respect to the spatial texture complexity is obtained, specifically, an average pixel value of the current block may be calculated first, and assuming that the current block size is M × N, the calculation formula is as follows:
Figure BDA0003853099210000095
where, Σ represents the cumulative sum, M, N represent the width and height of the current block, respectively, P i,j Representing the pixel values of the current block,
Figure BDA0003853099210000096
representing the average pixel value. On the basis, calculating the difference value between the value of all the pixel points in the current block and the average pixel value, accumulating the difference values of all the pixel points in the current block, and averaging to obtain the space domain texture complexity BlkS of each pixel block, wherein the calculation formula is as follows:
Figure BDA0003853099210000097
where, Σ represents the cumulative sum, M, N represent the width and height of the current block, respectively, P i,j Representing the pixel values of the current block,
Figure BDA0003853099210000098
representing the average pixel value, | | represents the absolute value. Assuming that the total number of the macro blocks of the current frame image is D, the spatial texture complexity of the current frame image is the average of the sum of the spatial texture complexities of all the macro blocks, and the calculation formula is as follows:
Figure BDA0003853099210000101
wherein, sigma represents BlkT with k from 0 to D-1 S textureS is a second complexity value of the current frame with respect to spatial texture complexity. On the basis, in order to more accurately represent the texture information of the current frame image, the space domain texture complexity and the time domain texture complexity of the image can be combined, namely, the weighting processing can be carried out based on the first complexity value and the second complexity value, and the complexity of the current frame relative to the time-space domain texture is obtained. Specifically, the first complexity value is textureT, the second complexity value is textureS, and the textureS are weighted, and the calculation formula is as follows:
textureST=k 1 ·textureS+k 2 ·textureT
wherein textureST represents a complexity value, k, of the current frame with respect to the complexity of the spatio-temporal texture 1 And k 2 Weight coefficients of the first complexity value and the second complexity value respectively, and a relation k exists 1 +k 2 And =1. In the above manner, the first complexity value and the second complexity value are weighted, which is helpful for improving the accuracy of the complexity value of the current frame with respect to the complexity of the temporal-spatial domain texture.
In a specific implementation scenario, a numerical mapping relationship between a quality parameter and a quantization parameter is obtained by fitting based on a complexity value of a time-space domain texture complexity of a video to be encoded. In addition, a complexity value of the complexity of the space-time texture of the video to be coded can be obtained, a numerical mapping relation between a quality parameter corresponding to the complexity value and a quantization parameter is selected based on the complexity value of the space-time texture, the numerical mapping relation is used as a numerical mapping relation suitable for the video to be coded, and analysis is performed based on a code rate control model and an actual allocated code rate to obtain a first quantization parameter of a current frame in the video to be coded.
In an implementation scene, a numerical mapping relationship between the quality parameter and the quantization parameter can be obtained by fitting based on videos to be coded of different scenes and in combination with a complexity value of a time-space domain texture complexity of the videos to be coded. Specifically, the PSNR may be determined by using the quantization parameter QP or the quantization factors λ and ρ, and the like, so as to obtain a quantization parameter corresponding to the current frame image, and after obtaining a large number of quantization parameters of different spatial domain texture complexities, fitting is performed, so as to determine a numerical mapping relationship between the quality parameter and the quantization parameter. Illustratively, the numerical mapping relationship between the quality parameter and the quantization parameter may be expressed as:
PSNR = function (quantization parameter, texture est)
The PSNR is a quality evaluation parameter, the function represents a function, and the textureST is a complexity value of the complexity of a time-space domain texture; the quantization parameter may be QP, or may be a quantization factor λ, ρ, or the like. Further, the quantization parameter is QP, and the mapping relationship can be expressed as:
function(QP,textureST)=α*exp(β*QP)
the parameters α and β may be determined according to actual conditions, and are not specifically limited herein.
In a specific implementation scene, scene detection is carried out on the basis of a video to be coded to obtain a target scene to which the video to be coded belongs, and then a numerical mapping relation between quality parameters and quantization parameters in the current scene is selected as a numerical mapping relation suitable for the video to be coded by combining the complexity value of the time-space domain texture complexity of the video to be coded. On the basis, the first quantization parameter of the current frame in the video to be coded is obtained by analyzing based on the code rate control model and the actually allocated code rate.
In an implementation scenario, in order to obtain the first quality parameter of the current frame, a first quantization parameter of the current frame with respect to the quantization parameter may be obtained first, a numerical mapping relationship between the quality parameter and the quantization parameter is determined, and based on the numerical mapping relationship, the first quality parameter of the current frame after being encoded based on the first quantization parameter is obtained. For example, if the complexity of the current frame temporal-spatial texture is 20, the quantization parameter is QP, the quality parameter is PSNR, and the numerical mapping relationship between the quality parameter and the quantization parameter is: when 15-straw texturest-straw 30, the mapping is expressed as:
PSNR=α*exp(β*QP)=40*exp(-0.02*QP)
if the value of QP is 24, calculating a first quality parameter after encoding the current frame based on the first quantization parameter as:
PSNR=40*exp(-0.02*QP)=24.8
in another implementation scenario, in order to obtain the second quality parameter after the reference frame is encoded, a second quantization parameter related to the reference frame may be obtained first, and a numerical mapping relationship between the quality parameter and the quantization parameter is determined, and based on the numerical mapping relationship, the second quality parameter after the reference frame is encoded based on the second quantization parameter is obtained. Illustratively, if the complexity value of the reference frame time-space domain texture complexity is 40, the quantization parameter is QP, the quality parameter is PSNR, and the numerical mapping relationship between the quality parameter and the quantization parameter is: at 30 ≦ textureST <50, the mapping is expressed as:
PSNR=α*exp(β*QP)=30*exp(-0.03*QP)
if the value of QP is 24, calculating a second quality parameter after encoding the reference frame based on the first quantization parameter as:
PSNR=30*exp(-0.03*QP)=14.6
therefore, if the numerical mapping relation between the quality parameters and the quantization parameters is represented by a piecewise function, the target scene to which the video to be coded belongs is determined, the complexity value of the space-time domain texture complexity is within a certain range, and the numerical mapping relation expressions are the same. Of course, the numerical mapping relationship between the quality parameter and the quantization parameter may be determined according to actual situations, and is not specifically limited herein.
Step S13: and determining whether to correct the first quantization parameter based on a first difference value between the first quality parameter and a second quality parameter of the reference frame to obtain a target quantization parameter of the current frame.
Referring to fig. 2, fig. 2 is a flowchart illustrating an embodiment of a process of obtaining a target quantization parameter of a current frame. Specifically, the method may include the steps of:
step S21: judging whether the first difference value is not less than a preset threshold value or not; if not, executing step S22; otherwise, step S23 is executed.
In an implementation scenario, a first quality parameter of a current frame and a second quality parameter of a reference frame are obtained first, where it is to be noted that the first quality parameter represents a value of the quality parameter after the current frame is encoded based on the first quantization parameter, and the second quality parameter represents a value of the quality parameter after the reference frame is encoded based on the second quantization parameter. On the basis, a first difference value between the first quality parameter and the second quality parameter is obtained through calculation, the first difference value is compared with a preset threshold value, a comparison result between the first difference value and the preset threshold value is obtained, the preset threshold value can be set to be 2, 3, 4 and the like, the preset threshold value can be set according to actual conditions, and no specific limitation is made here. And selecting whether to revise the first quantization parameter or not based on the comparison result so as to obtain the target quantization parameter of the current frame, wherein the reference frame is a frame which is positioned in front of the current frame in the video to be coded.
In particular, the second quality parameter of the reference frame encoding may be expressed as PSNR pre Expressing the first quality parameter of the current frame as PSNR curr Then, the first difference between the first quality parameter and the second quality parameter being lower than the preset threshold may be expressed as:
|PSNR curr- PSNR pre |<ε
wherein epsilon is a preset threshold value, epsilon is greater than 0, and | represents an absolute value.
Step S22: the first quantization parameter is taken as a target quantization parameter.
In one implementation scenario, in response to the first difference threshold being lower than the preset error, i.e., the first quantization parameter does not need to be revised, the first quantization parameter may be directly used as the target quantization parameter.
Step S23: and multiplying the preset threshold by the preset proportion to obtain a quality adjustment amplitude, and determining a quality adjustment direction based on the size relation between the first quality parameter and the second quality parameter.
In an implementation scenario, in response to that the first difference is not lower than a preset threshold, that is, the first quantization parameter needs to be optimized, the first quality parameter is adjusted based on the preset threshold to obtain a third quality parameter, and a second difference between the third quality parameter and the second quality parameter is smaller than the preset threshold. Specifically, the preset threshold may be multiplied by a preset ratio to obtain a quality adjustment range, where a value range of the preset ratio is between 0 and 1, for example, the preset ratio may be 0.4, 0.5, 0.7, and the like, and in a specific implementation scenario, the preset ratio may be set to 0.5, and the preset ratio is set to 0.5 to adjust the first quantization parameter, so that the video quality stability may be stronger. The preset ratio may be set according to actual conditions, and is not specifically limited herein. In addition, the adjustment direction is determined based on the magnitude relation between the first quality parameter and the second quality parameter, and the preset proportion is determined based on the quality stability requirement between adjacent video frames. It should be noted that the preset ratio is not greater than 1, so that the quality stability between adjacent video frames is higher. The adjustment direction includes: specifically, when the first quality parameter is smaller than the second quality parameter, the adjustment direction is the direction of increasing the first quality parameter, and when the first quality parameter is larger than the second quality parameter, the adjustment direction is the direction of decreasing the first quality parameter. Illustratively, the range of the complexity of the time-space domain textures of the current frame and the reference frame is all 15-texturest-30, and a mapping relation expression corresponding to a preset threshold value epsilon =2 is expressed as follows:
PSNR=40*exp(-0.02*QP)
if the quantization parameters of the current frame and the reference frame are set to QP respectively curr =27,QP pre =22, the calculation result of the first quality parameter of the current frame and the second quality parameter of the reference frame is PSNR curr =23.4,PSNR pre =25.8, the first difference between the first quality parameter and the second quality parameter can be expressed as:
|PSNR curr -PSNR pre |=|23.4-25.8|=2.4
because the first difference between the first quality parameter and the second quality parameter is greater than the preset threshold and the first quality parameter is smaller than the second quality parameter, the adjustment direction is determined to be the direction for increasing the first quality parameter, the preset ratio is set to be 0.5, and the quality adjustment amplitude can be obtained by multiplying the preset ratio by the preset threshold, namely the quality adjustment amplitude is 1.
Step S24: and adjusting the first quality parameter according to the quality adjustment direction and the quality adjustment amplitude to obtain a third quality parameter.
In an implementation scenario, if the adjustment direction is a direction for increasing the first quality parameter, increasing the quality adjustment amplitude on the basis of the first quality parameter to obtain a third quality parameter; and if the adjustment direction is the direction of reducing the first quality parameter, reducing the quality adjustment range on the basis of the first quality parameter to obtain a third quality parameter. Illustratively, if the mass adjustment amplitude is 1, the adjustment direction is a direction of increasing the first mass parameter, and the first mass parameter is 23.4, then 1 is increased on the basis of the first mass parameter, resulting in a third mass parameter of 24.4. It should be noted that a second difference between the third quality parameter and the second quality parameter is lower than a preset threshold, so that after the third quality parameter is obtained, a second difference between the third quality parameter and the second quality parameter may be further obtained, in response to that the second difference is not lower than the preset threshold, the third quality parameter is adjusted to a new third quality parameter, and a difference is obtained based on the new third quality parameter and the second quality parameter, and iteration is continued until the difference between the new third quality parameter and the second quality parameter meets the preset threshold, and then the iteration is stopped.
Step S25: and mapping the third quality parameter based on the numerical mapping relation to obtain a target quantization parameter.
In an implementation scenario, a corresponding numerical mapping relationship is obtained, and the third quality parameter is mapped based on the numerical mapping relationship to obtain a target quantization parameter. Illustratively, the complexity of the temporal-spatial domain textures of the current frame and the reference frame both range from 15<textureST<30, the preset threshold value epsilon =2 corresponds to a mapping relation expression of PSNR =40 × exp (-0.02 × QP), and the quantization parameters of the current frame and the reference frame are respectively set to be QPs curr =27,QP pre =22, the calculation result of the first quality parameter of the current frame and the second quality parameter of the reference frame is PSNR curr =23.4,PSNR pre And =25.8, the third quality parameter is obtained as 24.4, and mapping is performed based on the mapping relation expression PSNR =40 × exp (-0.02 × QP), so that QP is obtained as 25.
Step S14: and coding the current frame based on the target quantization parameter of the current frame.
In an implementation scenario, a target quantization parameter is obtained after the first quantization parameter is optimized, and the current frame is encoded through the target quantization parameter, so that the video quality stability can be ensured, and visual sudden change can be reduced as much as possible. It should be noted that, if the rate control parameter is an R- λ model, the quantization parameter may be a quantization factor λ or a QP, and if the quantization parameter is the quantization factor λ, after the target quantization parameter is obtained, the quantization parameter QP is calculated according to a mapping relation expression between λ and QP.
It should be noted that the first quantization parameter, the second quantization parameter, and the third quantization parameter are substantially quantization parameters, and the difference is that the three represent specific values of the quantization parameters under different conditions.
According to the scheme, the actually allocated code rate is analyzed based on the code rate control model, and a first quantization parameter of a current frame in the video to be coded is obtained; mapping the first quantization parameter based on a numerical mapping relation to obtain a first quality parameter of the current frame, wherein the numerical mapping relation represents a corresponding relation between the quantization parameter and the quality parameter; the first quality parameter represents a value of a quality parameter after encoding the current frame based on the first quantization parameter; determining whether to correct the first quantization parameter based on a first difference value between the first quality parameter and a second quality parameter of the reference frame to obtain a target quantization parameter of the current frame; the reference frame is a frame which is positioned in front of the current frame in the video to be coded; the second quality parameter characterizes a value of the quality parameter after encoding the reference frame based on the second quantization parameter; on the basis, the current frame is coded based on the target quantization parameter of the current frame. On one hand, the first quantization parameter of the current frame in the video to be coded is obtained by analyzing based on a code rate control model and the actually allocated code rate, so that the accuracy of the current frame in the video to be coded relative to the video coding parameter is improved, on the other hand, whether the first quantization parameter is corrected or not is determined by constraining the numerical values of the quality parameters of the front frame and the rear frame, namely, by the first difference value between the coding parameters of the front frame and the rear frame, so that after the video to be coded is coded, the video quality stability can be ensured, and the visual mutation is reduced as much as possible.
Referring to fig. 3, fig. 3 is a flowchart illustrating a video encoding method according to another embodiment of the present application.
Specifically, the following steps may be included:
step S31: and analyzing the actually allocated code rate based on a code rate control model to obtain a first quantization parameter of the current frame in the video to be coded.
In an implementation scenario, an actual allocation code rate may be obtained first, and the actual allocation code rate may be determined based on direct input of a user, and the target allocation code rate and the target quality level set by the user may also be received first, and then the target allocation code rate is weighted based on a ratio between the target quality level and the highest quality level to obtain the actual allocation code rate.
In an implementation scenario, after the rate control model is determined, the actually allocated rate is analyzed based on the determined rate control model to obtain a first quantization parameter of the current frame. The manner of obtaining the first quantization parameter may be according to the foregoing embodiments, and is not described herein again.
Step S32: and obtaining a numerical value mapping relation between the quantization parameter and the quality parameter.
In one implementation scenario, a target scene to which a video to be encoded belongs is determined, and a numerical mapping relationship between a quality parameter and a quantization parameter is selected based on the target scene. Of course, the numerical mapping relationship between the quantization parameter and the quality parameter may also be determined based on the correlation between the spatial-temporal texture complexity and the numerical mapping relationship. Step S33: and acquiring a first quality parameter of the current frame and a second quality parameter of the reference frame.
In an implementation scenario, the manner of obtaining the first quality parameter of the current frame and the second quality parameter of the reference frame may refer to the manner of obtaining the first quality parameter and the second quality parameter in the foregoing disclosed embodiment, which is not described herein again.
Step S34: a first difference between the first quality parameter and the second quality parameter is obtained.
In one implementation scenario, after determining the first quality parameter and the second quality parameter, an absolute value of a difference between the first quality parameter and the second quality parameter is obtained, so as to obtain a first difference between the first quality parameter and the second quality parameter.
Step S35: judging whether the first difference value is not less than a preset threshold value or not; if not, executing step S36; otherwise, step S37 is executed.
Step S36: the first quantization parameter is taken as a target quantization parameter.
In one implementation scenario, if the first difference is lower than the preset threshold, the first quantization parameter may be used as the target quantization parameter. And since the difference between the first quality parameter and the second quality parameter is lower than a preset threshold, after the video is encoded, the stability of the video quality is ensured.
Step S37: and adjusting the first quality parameter to be a third quality parameter.
In an implementation scenario, the adjustment manner for adjusting the first quality parameter to the third quality parameter may refer to the adjustment manner in the foregoing disclosed embodiment, and is not described herein again.
Step S38: and mapping the third quality parameter based on the numerical mapping relation to obtain a target quantization parameter.
In an implementation scenario, after the first quality parameter is adjusted to the third quality parameter, if a third difference value between the third quality parameter and the second quality parameter is lower than a preset threshold, a corresponding numerical mapping relationship may be selected, and mapping is performed based on the selected numerical mapping relationship, so as to obtain the target quantization parameter.
Step S39: and coding the current frame based on the target quantization parameter of the current frame.
In an implementation scene, a current frame is coded based on a determined target quantization parameter, so that the phenomenon that the distance between quantization parameters of a front frame and a rear frame is too large to cause the respiratory effect of the subjective quality of a video is avoided as much as possible, and further, the visual mutation is reduced.
According to the scheme, the actually allocated code rate is analyzed based on the code rate control model, and a first quantization parameter of a current frame in the video to be coded is obtained; mapping the first quantization parameter based on a numerical mapping relation to obtain a first quality parameter of the current frame, wherein the numerical mapping relation represents a corresponding relation between the quantization parameter and the quality parameter; the first quality parameter represents a value of a quality parameter after encoding the current frame based on the first quantization parameter; determining whether to correct the first quantization parameter based on a first difference value between the first quality parameter and a second quality parameter of the reference frame to obtain a target quantization parameter of the current frame; the reference frame is a frame which is positioned in front of the current frame in the video to be coded; the second quality parameter characterizes a value of the quality parameter after encoding the reference frame based on the second quantization parameter; on the basis, the current frame is coded based on the target quantization parameter of the current frame. On one hand, the first quantization parameter of the current frame in the video to be coded is obtained by analyzing based on a code rate control model and the actually allocated code rate, so that the accuracy of the current frame in the video to be coded relative to the video coding parameter is improved, on the other hand, whether the first quantization parameter is corrected or not is determined by constraining the numerical values of the quality parameters of the front frame and the rear frame, namely, by the first difference value between the coding parameters of the front frame and the rear frame, so that after the video to be coded is coded, the video quality stability can be ensured, and the visual mutation is reduced as much as possible.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Referring to fig. 4, fig. 4 is a block diagram of an embodiment of a video encoding apparatus according to the present application. Video encoding device 40 includes an analysis module 41, a mapping module 42, a determination module 43, and an encoding module 44. The analysis module 41 is configured to analyze an actually allocated code rate based on a code rate control model to obtain a first quantization parameter of a current frame in a video to be coded; the mapping module 42 is configured to map the first quantization parameter based on the numerical mapping relationship to obtain a first quality parameter of the current frame; the numerical value mapping relationship represents the corresponding relationship between the quantization parameter and the quality parameter; the first quality parameter represents the value of the quality parameter after the current frame is coded based on the first quantization parameter; the determining module 43 is configured to determine whether to modify the first quantization parameter based on a first difference between the first quality parameter and the second quality parameter of the reference frame, so as to obtain a target quantization parameter of the current frame; the reference frame is a previous frame positioned in the current frame in the video to be coded; the second quality parameter characterizes a value of the quality parameter after encoding the reference frame based on the second quantization parameter; the encoding module 44 is configured to encode the current frame based on the target quantization parameter of the current frame.
According to the scheme, on one hand, the first quantization parameter of the current frame in the video to be coded is obtained by analyzing based on the code rate control model and the actually allocated code rate, so that the accuracy of the current frame in the video to be coded relative to the video coding parameter is improved, on the other hand, whether the first quantization parameter is corrected or not is determined by constraining the numerical value of the quality parameters of the front frame and the rear frame, namely, the first difference value between the coding parameters of the front frame and the rear frame, so that after the video to be coded is coded, the quality stability of the video can be ensured, and the visual mutation is reduced as much as possible.
In some disclosed embodiments, the determining module 43 includes an adjusting submodule, configured to adjust the first quantization parameter in response to the first difference not being smaller than a preset threshold, so as to obtain a target quantization parameter; the determining module 43 further includes a determining submodule, and the determining submodule is configured to use the first quantization parameter as the target quantization parameter in response to the first difference being smaller than the preset threshold.
Therefore, by constraining the values of the quality parameters of the two frames before and after, the value difference of the coding parameters between the two frames before and after can be ensured to meet the preset condition, and further, after coding, the video quality stability can be ensured.
In some disclosed embodiments, the adjusting submodule includes an adjusting unit, and the adjusting unit is configured to adjust the first quality parameter based on a preset threshold, so as to obtain a third quality parameter; a second difference value between the third quality parameter and the second quality parameter is smaller than a preset threshold value; the adjusting submodule further comprises a mapping unit, and the mapping unit is used for obtaining a target quantization parameter based on the quantization parameter mapped by the third quality parameter in the numerical value mapping relation.
In some disclosed embodiments, the adjusting unit includes a determining subunit, the determining subunit is configured to multiply a preset threshold by a preset ratio to obtain a quality adjustment amplitude, and determine the quality adjustment direction based on a magnitude relationship between the first quality parameter and the second quality parameter; wherein the preset proportion is determined based on the quality stability requirement between adjacent video frames; the adjusting unit further comprises an adjusting subunit, and the adjusting subunit is used for adjusting the first quality parameter according to the quality adjusting direction and the quality adjusting amplitude to obtain a third quality parameter.
Therefore, the adjustment direction is further determined, so that the difference value of the quality parameters of the two frames before and after the adjustment is ensured to be within a certain range, and the size relationship after the adjustment is consistent with that before the adjustment, thereby being beneficial to ensuring the stability of the video quality after the video coding is carried out.
In some disclosed embodiments, the numerical mapping relationship is related to the spatial-temporal texture complexity, and a plurality of numerical intervals of the spatial-temporal texture complexity respectively correspond to different numerical mapping relationships; the video coding device 40 comprises a calculation module for obtaining a complexity value of the current frame with respect to the complexity of the temporal-spatial texture; the video encoding apparatus 40 further includes a selection module, which is configured to select a numerical mapping relationship corresponding to the numerical interval where the complexity value is located as a numerical mapping relationship applicable to the current frame.
Therefore, the corresponding numerical value mapping relation is selected based on the complexity value of the current frame relative to the complexity of the time-space domain texture, and the accuracy of selecting the numerical value mapping relation is improved.
In some disclosed embodiments, the computation module comprises an obtaining sub-module for obtaining a first complexity value of the current frame with respect to the complexity of the temporal texture compared to the reference frame and for obtaining a second complexity value of the current frame with respect to the complexity of the spatial texture; the calculation module further comprises a processing submodule, and the processing submodule is used for carrying out weighting processing on the basis of the first complexity value and the second complexity value to obtain the complexity value of the current frame relative to the complexity of the time-space domain texture.
Therefore, the accuracy of the complexity value of the current frame with respect to the complexity of the spatio-temporal texture is improved by weighting the first complexity value and the second complexity value.
In some disclosed embodiments, the video encoding apparatus 40 includes a fitting module, configured to respectively perform fitting based on sample videos in different scenes to obtain corresponding relationships between quantization parameters and quality parameters in different scenes; performing scene detection based on a video to be coded to obtain a target scene to which the video to be coded belongs; and selecting the corresponding relation between the quantization parameter and the quality parameter in the target scene as a numerical value mapping relation suitable for the video to be coded.
Therefore, the numerical mapping relation between the quality parameters and the quantization parameters in different scenes is obtained by respectively fitting the sample videos in different scenes, and the accuracy of the numerical mapping relation between the quality parameters and the quantization parameters is improved.
In some disclosed embodiments, the video encoding apparatus 40 includes a receiving module, configured to receive a target allocation bitrate and a target quality level set by a user; the video encoding device 40 further includes a weighting module, and the weighting module is configured to weight the target allocation bit rate based on a ratio between the target quality level and the highest quality level to obtain an actual allocation bit rate.
Therefore, by weighting the target allocation code rate, errors in the process of confirming the actual allocation code rate can be reduced, and the accuracy of the acquired quantization parameters is improved.
In some disclosed embodiments, the quality parameter includes at least any one of PSNR, SSIM;
and/or the code rate control model is selected from the model set, the model set at least comprises at least one of an R-lambda model, an R-rho model and an R-Q model, the code rate control model represents the corresponding relation between quantization parameters and code rates, the quantization parameters comprise any one of quantization factors of QP and the code rate control model, when the R-lambda model is selected as the code rate control model, the quantization factor is lambda, when the R-rho model is selected as the code rate control model, the quantization factor is rho, and when the R-Q model is selected, the quantization factor is qscale.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a module or a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some interfaces, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be 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 embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application.
Referring to fig. 5, fig. 5 is a block diagram of an embodiment of an encoding apparatus of the present application. The encoding device 50 comprises a memory 51 and a processor 52 coupled to each other, the memory 51 storing program instructions, and the processor 52 being configured to execute the program instructions to implement the steps in any of the above-described embodiments of the video encoding method. Specifically, the encoding device 50 may include, but is not limited to: servers, desktop computers, notebook computers, etc., without limitation thereto.
In particular, the processor 52 is configured to control itself and the memory 51 to implement the steps in any of the above-described embodiments of the video encoding method. Processor 52 may also be referred to as a CPU (Central Processing Unit). Processor 52 may be an integrated circuit chip having signal processing capabilities. The Processor 52 may also be a general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. In addition, processor 52 may be implemented collectively by a plurality of integrated circuit chips.
According to the scheme, on one hand, the first quantization parameter of the current frame in the video to be coded is obtained by analyzing based on the code rate control model and the actually allocated code rate, so that the accuracy of the current frame in the video to be coded relative to the video coding parameter is improved, on the other hand, whether the first quantization parameter is corrected or not is determined by constraining the numerical value of the quality parameters of the front frame and the rear frame, namely, the first difference value between the coding parameters of the front frame and the rear frame, so that after the video to be coded is coded, the quality stability of the video can be ensured, and the visual mutation is reduced as much as possible.
Referring to fig. 6, fig. 6 is a block diagram illustrating an embodiment of a computer-readable storage medium according to the present application. The computer readable storage medium 60 stores program instructions 61 executable by the processor, the program instructions 61 for implementing the steps in any of the video encoding method embodiments described above.
According to the scheme, on one hand, the first quantization parameter of the current frame in the video to be coded is obtained by analyzing based on the code rate control model and the actually allocated code rate, so that the accuracy of the current frame in the video to be coded relative to the video coding parameter is improved, on the other hand, whether the first quantization parameter is corrected or not is determined by constraining the numerical value of the quality parameters of the front frame and the rear frame, namely, the first difference value between the coding parameters of the front frame and the rear frame, so that after the video to be coded is coded, the quality stability of the video can be ensured, and the visual mutation is reduced as much as possible.
The foregoing storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
If the technical scheme of the application is used for collecting, transmitting and using the data, the requirements of relevant laws and regulations are met.

Claims (12)

1. A video encoding method, comprising:
analyzing the actually allocated code rate based on a code rate control model to obtain a first quantization parameter of a current frame in the video to be coded;
mapping the first quantization parameter based on a numerical value mapping relation to obtain a first quality parameter of the current frame; wherein the numerical mapping relationship characterizes a correspondence between the quantization parameter and the quality parameter; the first quality parameter characterizes a value of a quality parameter after encoding of the current frame based on the first quantization parameter;
determining whether to correct the first quantization parameter based on a first difference value between the first quality parameter and a second quality parameter of a reference frame to obtain a target quantization parameter of the current frame; wherein the reference frame is a frame in the video to be coded, which is located before the current frame; the second quality parameter characterizes a value of the quality parameter after encoding the reference frame based on a second quantization parameter;
and coding the current frame based on the target quantization parameter of the current frame.
2. The method of claim 1, wherein the determining whether to modify the first quantization parameter based on a first difference between the first quality parameter and a second quality parameter of a reference frame to obtain a target quantization parameter of the current frame comprises:
responding to the first difference value not less than a preset threshold value, and adjusting the first quantization parameter to obtain the target quantization parameter;
and in response to the first difference value being smaller than the preset threshold value, taking the first quantization parameter as the target quantization parameter.
3. The method of claim 2, wherein the adjusting the first quantization parameter to obtain the target quantization parameter comprises:
adjusting the first quality parameter based on the preset threshold value to obtain a third quality parameter; wherein a second difference between the third quality parameter and the second quality parameter is smaller than the preset threshold;
and obtaining the target quantization parameter based on the quantization parameter mapped by the third quality parameter in the numerical mapping relation.
4. The method of claim 3, wherein the adjusting the first quality parameter based on the preset threshold to obtain a third quality parameter comprises:
multiplying the preset threshold by a preset proportion to obtain a quality adjustment amplitude, and determining a quality adjustment direction based on the magnitude relation between the first quality parameter and the second quality parameter; wherein the preset proportion is determined based on quality stability requirements between adjacent video frames;
and adjusting the first quality parameter according to the quality adjustment direction and the quality adjustment amplitude to obtain the third quality parameter.
5. The method according to claim 1, wherein the numerical mapping relationship is related to a space-time domain texture complexity, and a plurality of numerical intervals of the space-time domain texture complexity respectively correspond to different numerical mapping relationships; before the mapping the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame, the method further includes:
acquiring a complexity value of the current frame about the complexity of the time-space domain texture;
and selecting a numerical value mapping relation corresponding to the numerical value interval where the complexity value is located as a numerical value mapping relation suitable for the current frame.
6. The method according to claim 5, wherein said obtaining the complexity value of the current frame with respect to the complexity of the spatio-temporal texture comprises:
acquiring a first complexity value of the current frame relative to the complexity of the time domain texture compared with the reference frame, and acquiring a second complexity value of the current frame relative to the complexity of the space domain texture;
and performing weighting processing based on the first complexity value and the second complexity value to obtain the complexity value of the current frame relative to the complexity of the time-space domain texture.
7. The method of claim 1, wherein before the mapping the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame, the method further comprises:
respectively fitting based on sample videos in different scenes to obtain corresponding relations between the quantization parameters and the quality parameters in the different scenes;
performing scene detection based on the video to be coded to obtain a target scene to which the video to be coded belongs;
and selecting the corresponding relation between the quantization parameter and the quality parameter under the target scene as a numerical value mapping relation suitable for the video to be coded.
8. The method of claim 1, wherein before the analyzing the actually allocated bitrate based on the bitrate control model to obtain the first quantization parameter of the current frame in the video to be encoded, the method further comprises:
receiving a target distribution code rate and a target quality grade set by a user;
and weighting the target distribution code rate based on the ratio of the target quality grade to the highest quality grade to obtain the actual distribution code rate.
9. The method according to any of claims 1 to 8, characterized in that the quality parameters comprise at least any of PSNR, SSIM;
and/or the code rate control model is selected from a model set, the model set at least comprises at least one of an R-lambda model, an R-rho model and an R-Q model, the code rate control model represents the corresponding relation between quantization parameters and code rates, the quantization parameters comprise any one of QP and quantization factors of the code rate control model, when the R-lambda model is selected as the code rate control model, the quantization factor is lambda, when the R-rho model is selected as the code rate control model, the quantization factor is rho, and when the R-Q model is selected, the quantization factor is qscale.
10. A video encoding apparatus, comprising:
the analysis module is used for analyzing the actually allocated code rate based on the code rate control model to obtain a first quantization parameter of the current frame in the video to be coded;
the mapping module is used for mapping the first quantization parameter based on a numerical mapping relation to obtain a first quality parameter of the current frame; wherein the numerical mapping represents a correspondence between the quantization parameter and the quality parameter; the first quality parameter characterizes a value of a quality parameter after encoding of the current frame based on the first quantization parameter;
a determining module, configured to determine whether to modify the first quantization parameter based on a first difference between the first quality parameter and a second quality parameter of a reference frame, so as to obtain a target quantization parameter of the current frame; wherein the reference frame is a frame in the video to be coded, which is located before the current frame; the second quality parameter characterizes a value of the quality parameter after encoding the reference frame based on a second quantization parameter;
and the coding module is used for coding the current frame based on the target quantization parameter of the current frame.
11. An encoding device comprising a memory and a processor coupled to each other, the memory storing program instructions, the processor being configured to execute the program instructions to implement the video encoding method of any one of claims 1 to 9.
12. A computer-readable storage medium, in which program instructions executable by a processor are stored, the program instructions being for implementing the video encoding method of any one of claims 1 to 9.
CN202211139813.XA 2022-09-19 2022-09-19 Video coding method and related device, coding equipment and storage medium Pending CN115941946A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211139813.XA CN115941946A (en) 2022-09-19 2022-09-19 Video coding method and related device, coding equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211139813.XA CN115941946A (en) 2022-09-19 2022-09-19 Video coding method and related device, coding equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115941946A true CN115941946A (en) 2023-04-07

Family

ID=86552849

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211139813.XA Pending CN115941946A (en) 2022-09-19 2022-09-19 Video coding method and related device, coding equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115941946A (en)

Similar Documents

Publication Publication Date Title
US7403562B2 (en) Model based rate control for predictive video encoder
US8761248B2 (en) Method and system for intelligent video adaptation
JP6067737B2 (en) Method, apparatus, computer program, and storage medium for video quality measurement
CN113766226A (en) Image encoding method, apparatus, device and storage medium
CN106688232A (en) Perceptual optimization for model-based video encoding
CN111193931B (en) Video data coding processing method and computer storage medium
EP3545677A1 (en) Methods and apparatuses for encoding and decoding video based on perceptual metric classification
US7346106B1 (en) Robust multi-pass variable bit rate encoding
CN110062230B (en) Image coding method and device
US20230385645A1 (en) Method for automatic hybrid quantization of deep artificial neural networks
CN113784129A (en) Point cloud quality evaluation method, encoder, decoder and storage medium
US11025914B1 (en) Method based on global rate-distortion optimization for rate control in video coding
CN114900692A (en) Video stream frame rate adjusting method and device, equipment, medium and product thereof
US9280813B2 (en) Blur measurement
CN112437301B (en) Code rate control method and device for visual analysis, storage medium and terminal
John et al. Rate distortion optimization over large scale video corpus with machine learning
CN1266335A (en) Device and method for adjusting bit rate in multiplex system
WO2022021422A1 (en) Video coding method and system, coder, and computer storage medium
CN115941946A (en) Video coding method and related device, coding equipment and storage medium
CN115152217A (en) Techniques for controllable video coding of regions of interest
Song et al. Optimized rate control algorithm of high-efficiency video coding based on region of interest
WO1997039417A2 (en) Method and apparatus for training a neural network to use a fidelity metric
KR101253917B1 (en) Apparatus and method for estimating of motion in a moving picture
JP2001526850A (en) Method and apparatus for optimizing a quantization value in an image encoder
US7822117B1 (en) Video encoder rate control using bit usage measuring and allocating by macroblock classes

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