CN112565755A - Video frame encoding method and device, electronic equipment and readable storage medium - Google Patents

Video frame encoding method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN112565755A
CN112565755A CN201910853101.6A CN201910853101A CN112565755A CN 112565755 A CN112565755 A CN 112565755A CN 201910853101 A CN201910853101 A CN 201910853101A CN 112565755 A CN112565755 A CN 112565755A
Authority
CN
China
Prior art keywords
coding
target
coding matrix
initial
video frame
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.)
Granted
Application number
CN201910853101.6A
Other languages
Chinese (zh)
Other versions
CN112565755B (en
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.)
Guangzhou Huya Technology Co Ltd
Original Assignee
Guangzhou Huya 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 Guangzhou Huya Technology Co Ltd filed Critical Guangzhou Huya Technology Co Ltd
Priority to CN201910853101.6A priority Critical patent/CN112565755B/en
Publication of CN112565755A publication Critical patent/CN112565755A/en
Application granted granted Critical
Publication of CN112565755B publication Critical patent/CN112565755B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/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/184Methods 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 bits, e.g. of the compressed video stream
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/189Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the adaptation method, adaptation tool or adaptation type used for the adaptive coding
    • H04N19/196Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the adaptation method, adaptation tool or adaptation type used for the adaptive coding being specially adapted for the computation of encoding parameters, e.g. by averaging previously computed encoding parameters
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/85Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression

Landscapes

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

Abstract

The application provides a video frame coding method, a video frame coding device, electronic equipment and a readable storage medium, and relates to the technical field of video coding.

Description

Video frame encoding method and device, electronic equipment and readable storage medium
Technical Field
The present application relates to the field of video coding technologies, and in particular, to a video frame coding method, an apparatus, an electronic device, and a readable storage medium.
Background
With the rapid development of internet technology, the demand of users for high-definition videos is increasing, the data volume of video multimedia is also increasing, and if the videos are not compressed, the videos are difficult to be applied to actual storage and transmission.
The video compression decoding technology can effectively remove redundant information in the video data and realize the rapid transmission and offline storage of the video data in the internet.
However, when the current video compression technology is used for compression coding of video frames, the same method is adopted for coding different types of video frames, and the information representation of key video frames is not prominent enough.
Disclosure of Invention
The present application aims to provide a video frame encoding method, an apparatus, an electronic device, and a readable storage medium, which can increase the information amount of key video frames contained in a code stream, and decrease the information amount of non-key video frames, so that when decoding, more key video frames can be used for decoding, thereby improving the decoding quality.
In order to achieve the above purpose, the embodiments of the present application employ the following technical solutions:
in a first aspect, an embodiment of the present application provides a video frame encoding method, where the method includes:
obtaining an initial QP (quantization parameter) coding matrix and a target coding parameter corresponding to a target video frame, wherein the target coding parameter corresponds to a frame type of the target video frame;
calculating the QP adjustment amount corresponding to the initial QP coding matrix;
updating the initial QP coding matrix according to the target coding parameters and the QP adjustment amount to obtain an optimized QP coding matrix;
encoding the target video frame using the optimized QP encoding matrix.
In a second aspect, an embodiment of the present application provides a video frame encoding device, including:
the device comprises a preprocessing module, a target coding module and a target coding module, wherein the preprocessing module is used for obtaining an initial QP coding matrix and target coding parameters corresponding to a target video frame, and the target coding parameters correspond to the frame type of the target video frame;
the preprocessing module is further used for calculating a QP adjustment amount corresponding to the initial QP coding matrix;
the preprocessing module is further configured to update the initial QP coding matrix according to the target coding parameter and the QP adjustment amount to obtain an optimized QP coding matrix;
and the coding module is used for coding the target video frame by utilizing the optimized QP coding matrix.
In a third aspect, an embodiment of the present application provides an electronic device, which includes a memory for storing one or more programs; a processor; the one or more programs, when executed by the processor, implement the video frame encoding method described above.
In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the video frame encoding method described above.
According to the video frame encoding method, the video frame encoding device, the electronic device and the readable storage medium, the initial QP encoding matrix corresponding to the target video frame and the target encoding parameters corresponding to the frame type of the target video frame are obtained, the QP adjustment amount corresponding to the initial QP encoding matrix is obtained through calculation, the initial QP encoding matrix is updated according to the target encoding parameters and the QP adjustment amount, and the optimized QP encoding matrix is obtained, so that the target video frame is encoded by using the optimized QP encoding matrix.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and it will be apparent to those skilled in the art that other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 shows a schematic structural block diagram of an electronic device provided in an embodiment of the present application;
fig. 2 shows a schematic flow chart of a video frame encoding method provided by an embodiment of the present application;
FIG. 3 shows a coding quality comparison diagram;
FIG. 4 shows a schematic flow chart of the substeps of S203 in FIG. 2;
FIG. 5 shows a schematic flow diagram of the substeps of S201 in FIG. 2;
fig. 6 shows another schematic flow chart of a video frame encoding method provided by an embodiment of the present application;
fig. 7 is a schematic block diagram of a video frame encoding apparatus according to an embodiment of the present application.
In the figure: 100-an electronic device; 101-a memory; 102-a processor; 103-a communication interface; 300-video frame encoding means; 301-a pre-processing module; 302-encoding module.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, 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, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present application, 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 identical elements in a process, method, article, or apparatus that comprises the element.
x264 is a video compression encoder based on the h.264/MPEG-4AVC video compression standard that provides a variety of parameters that can be set to control video coding efficiency. Different parameter settings affect the encoding time, the size of the compressed video, the video quality, etc. The narrow-band high-definition technology can reduce video code rate as much as possible without influencing subjective watching quality of videos, which is a problem that video transmission service providers are concerned about, because reducing the code rate means reducing video playing bandwidth, and video transmission cost is saved.
There are many optimization characteristics of the x264 encoder, one of which is adaptive quantization, and the adaptive quantization function of x264 can allocate a proper code rate to a video frame based on human eye characteristics. For example, the human eye is generally sensitive to a flat region and less sensitive to a complex region, so that the adaptive quantization of x264 tends to allocate more code rate to the flat region, i.e., lower the QP of the flat region, and allocate less code rate to the complex region, i.e., raise the QP of the complex region. However, the coding scheme does not distinguish the importance degree of different types of video frames to video coding, so that the information representation of key video frames is not outstanding enough during video coding.
Therefore, based on the above defects, a possible implementation manner provided by the embodiment of the present application is as follows: the method comprises the steps of obtaining an initial QP coding matrix corresponding to a target video frame and target coding parameters corresponding to the frame type of the target video frame, calculating a QP adjustment amount corresponding to the initial QP coding matrix, updating the initial QP coding matrix according to the target coding parameters and the QP adjustment amount to obtain an optimized QP coding matrix, and coding the target video frame by using the optimized QP coding matrix, so that the information amount of key video frames contained in a code stream is increased, the information amount of non-key video frames is decreased, and the coded code stream contains more information of the key video frames.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Referring to fig. 1, fig. 1 shows a schematic block diagram of an electronic device 100 provided in an embodiment of the present application, where the electronic device 100 may be used as a service end, such as a server used by a video transmission service provider to provide services for a user, and may also be used as a user end, such as a terminal used by the user to upload video, for example, a mobile phone, a tablet computer, a personal computer, and the like, as long as the electronic device 100 can encode video frames when transmitting a video stream.
The electronic device 100 includes a memory 101, a processor 102, and a communication interface 103, the memory 101, the processor 102, and the communication interface 103 being electrically connected to each other, directly or indirectly, to enable transmission or interaction of data. For example, the components may be electrically connected to each other via one or more communication buses or signal lines.
The memory 101 may be used for storing software programs and modules, such as program instructions/modules corresponding to the video frame encoding apparatus 300 provided in the embodiments of the present application, and the processor 102 executes the software programs and modules stored in the memory 101, thereby executing various functional applications and data processing. The communication interface 103 may be used for communicating signaling or data with other node devices.
The Memory 101 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Programmable Read-Only Memory (EEPROM), and the like.
The processor 102 may be an integrated circuit chip having signal processing capabilities. The Processor 102 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
It will be appreciated that the configuration shown in FIG. 1 is merely illustrative and that electronic device 100 may include more or fewer components than shown in FIG. 1 or have a different configuration than shown in FIG. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
The following describes an exemplary video frame encoding method provided by an embodiment of the present application, with the electronic device 100 shown in fig. 1 as an exemplary implementation subject.
Referring to fig. 2, fig. 2 is a schematic flow chart of a video frame encoding method according to an embodiment of the present application, including the following steps:
s201, obtaining an initial QP coding matrix and a target coding parameter corresponding to a target video frame;
s203, calculating the QP adjustment amount corresponding to the initial QP coding matrix;
s205, updating the initial QP coding matrix according to the target coding parameters and the QP adjustment quantity to obtain an optimized QP coding matrix;
and S207, encoding the target video frame by using the optimized QP encoding matrix.
In the embodiment of the present application, when the electronic device encodes the target video frame, the electronic device may combine a first-order exponential model, such as y ═ x, based on the respective ac component energy of each macro block in the target video frame, and combine the ac component energy with a first-order exponential model1/8Calculating to obtain respective QP offset initial values of each macro block in the target video frame; then, the respective QP offset initial values of all macro blocks in the target video frame are counted, so that an initial QP coding matrix corresponding to the target video frame is obtained.
The electronic equipment also obtains a target coding parameter corresponding to the frame type of the target video frame according to the frame type of the target video frame; for example, assuming that the encoding parameters corresponding to an I Frame (Intra Frame), a P Frame (predictive Frame), and a B Frame (Bidirectional predictive Frame) are 0.4, 0.75, and 0.9, respectively, if the Frame type of the target video Frame is an I Frame, the encoding parameter 0.4 corresponding to the I Frame may be used as the target encoding parameter; if the frame type of the target video frame is a P frame, the coding parameter 0.75 corresponding to the P frame may be used as the target coding parameter; if the frame type of the target video frame is a B frame, the encoding parameter 0.9 corresponding to the B frame may be used as the target encoding parameter.
It is to be understood that the above listed encoding parameters for the I frame, the P frame, and the B frame are only exemplary, and in some other possible application scenarios of the embodiment of the present application, the encoding parameters for the I frame, the P frame, and the B frame may also be set to other values, such as 0.5, 0.7, and 0.8, or 0.4, 0.7, and 0.85, respectively, depending on a specific application scenario or a user setting, and the embodiment of the present application does not limit the values of the encoding parameters for the I frame, the P frame, and the B frame, as long as each type of video frame corresponds to the encoding parameter, such as 0.4, 0.75, and 0.9, respectively, for example.
Then, the electronic device calculates the QP adjustment amount corresponding to the initial QP encoding matrix according to the obtained initial QP encoding matrix. For example, the QP average value of all the QP offset initial values included in the initial QP encoding matrix is counted and calculated, and the calculated QP average value is used as the QP adjustment amount; alternatively, the QP adjustment amount is obtained by scaling the calculated QP average value by a set weight coefficient.
Next, the electronic device updates the initial QP coding matrix according to the target coding parameters corresponding to the target video frame and the calculated QP adjustment amount to obtain an optimized QP coding matrix, and then codes the target video frame by using the optimized QP coding matrix, so that the QP corresponding to the target video frame is reduced or increased compared with video frames of other frame types according to the frame type corresponding to the QP.
For example, for a key video frame, such as an I frame, in a video stream, a value in a QP encoding matrix corresponding to the frame may be reduced by using a target encoding parameter corresponding to the I frame and a QP adjustment amount corresponding to the frame, so that a quantization step size of the I frame is reduced when the I frame is encoded, a result obtained by encoding is clearer, and a code stream is larger; for a non-key video frame in a video stream, such as a B frame, a value in a QP coding matrix corresponding to the frame can be increased by using a target coding parameter corresponding to the B frame and a QP adjustment amount corresponding to the frame, so that the quantization step length of the B frame is increased when the B frame is coded, the coded result is more fuzzy, and the code stream is smaller; in summary, the scheme provided by the embodiment of the present application can increase the information amount of the key video frames included in the code stream, but decrease the information amount of the non-key video frames, so that compared with the current video compression scheme, the same compressed data amount includes more information of the key video frames, and further, when decoding, the information of more key video frames can be used for decoding, thereby improving the decoding quality.
It can be seen that, based on the above design, in the video frame encoding method provided in this embodiment of the present application, after obtaining the initial QP coding matrix corresponding to the target video frame and the target coding parameter corresponding to the frame type of the target video frame and calculating the QP adjustment corresponding to the initial QP coding matrix, the initial QP coding matrix is updated according to the target coding parameter and the QP adjustment to obtain the optimized QP coding matrix, so that the target video frame is encoded by using the optimized QP coding matrix.
For example, after the same source video frame is encoded according to the video frame encoding scheme provided by the embodiment of the present application and the existing encoding scheme, the source video frame is decoded, and the SSIMs (structural similarity) corresponding to the two encoding schemes are calculated, so as to measure the similarity between the video frame obtained by encoding and decoding the two encoding schemes and the source video frame, thereby obtaining the encoding quality comparison diagram shown in fig. 3.
As can be known from the encoding quality comparison diagram shown in fig. 3, assuming that the source video frames are encoded at the same code rate for the same source video frame, the SSIM calculated after decoding is larger for the video frames encoded according to the encoding scheme provided in the embodiment of the present application than for the video frames encoded according to the existing video frame encoding scheme; that is to say, compared with the existing video frame encoding scheme, the video frame encoded according to the video frame encoding scheme provided by the embodiment of the present application is more similar to the source video frame after being decoded, and the decoding quality is higher.
Here, when S205 is executed, it may be implemented in various ways. Illustratively, as one possible implementation, the algebraic sum of the initial QP coding matrix and the QP adjustment amount may be multiplied by the target coding parameter to obtain an optimized QP coding matrix.
For example, the formula for calculating the optimized QP coding matrix may satisfy the following:
final=(init-mean)·strength_werght[i]
in the formula, init represents an initial QP coding matrix, mean represents a QP adjustment amount, strengthh _ right [ i ] represents a target coding parameter, and final represents an optimized QP coding matrix.
That is to say, in the embodiment of the present application, a QP adjustment amount may be subtracted from each QP offset initial value in the initial QP coding matrix, so as to adjust the value range of all QP offset initial values in the initial QP coding matrix; and then, the difference value between the initial QP coding matrix and the QP adjustment amount is zoomed by using the target coding parameters, so that the QP corresponding to the target video frame is zoomed integrally according to the frame type of the target video frame, and the optimized QP coding matrix is obtained.
The target coding parameters can integrally adjust the QP of the target video frame, and the target coding parameters corresponding to the key video frame are set to be smaller than the target coding parameters corresponding to the non-key video frame, so that the QP corresponding to the non-key video frame is adjusted upwards as much as possible compared with the QP corresponding to the key video frame, and the non-key video frame occupies less code stream when being coded; and the QP corresponding to the key video frame is adjusted downwards as far as possible, so that the key video frame occupies more code streams when being coded.
It can be understood that the above adjustment manner is reflected in an application scene such as an x264 encoder, and may be embodied that the adaptive quantization strength for the key video frame is lower, and the adaptive quantization strength for the non-key video frame is higher, so that the key video frame occupies more code streams, and the non-key video frame occupies less code streams.
It can be seen that, based on the above design, in the video frame encoding method provided in this embodiment of the present application, after the value domain of the initial QP coding matrix is integrally adjusted by the QP adjustment amount, the difference between the initial QP coding matrix and the QP adjustment amount is scaled by the target coding parameter, so as to obtain an optimized QP coding matrix, and the QP corresponding to the non-key video frame is adjusted upward as much as possible while the QP corresponding to the key video frame is adjusted downward as much as possible, so that the non-key video frame occupies less code streams while being encoded, and the key video frame occupies more code streams while being encoded.
It should be noted that the above formula for obtaining the optimized QP coding matrix through calculation is only an illustration, and in some other possible implementation manners of the embodiment of the present application, some other manners or formulas may also be used for calculation, as long as the initial QP coding matrix can be updated according to the target coding parameter and the QP adjustment amount, so as to obtain the optimized QP coding matrix, and the manner for obtaining the QP coding matrix through calculation is not limited in the embodiment of the present application.
In the embodiment of the present application, when the QP adjustment amount is calculated, the calculated QP average value may be used as the QP adjustment amount by counting the QP average values of all the QP offset initial values included in the initial QP encoding matrix as described above.
In order to further adjust the QP corresponding to the non-key video frame up as much as possible and adjust the QP corresponding to the key video frame down as much as possible, please refer to fig. 4, where fig. 4 shows a schematic flowchart of the sub-step of S203 in fig. 2, and as a possible implementation manner, S203 may include the following sub-steps:
s203-1, calculating a QP average value corresponding to the initial QP coding matrix;
s203-3, the QP average value is processed by the set function to obtain the QP adjustment amount.
In this embodiment of the present application, on the basis of obtaining the QP average value corresponding to the initial QP coding matrix by calculation, the QP average value obtained by calculation may be further processed by using a set function, so as to obtain the QP adjustment amount corresponding to the initial QP coding matrix.
The QP average value of the video frame can be generally used for representing the situation of the detail area of the video frame, and the larger the QP average value is, the more the detail area contained in the video frame is represented; the smaller the QP average, the less detail area the video contains.
Furthermore, the average value of the QP of the video frame is generally 8-15, and within the range of the value range, a monotonically increasing function can be set, so that the larger the average value of the QP is, the larger the obtained QP adjustment amount is, and the QP corresponding to the video frame is adjusted downward as a whole.
For example, the formula for calculating the QP adjustment amount may satisfy the following equation:
mean′=mean-a·(mean2-b)/mean
in the formula, a and b are set parameters, mean is the mean value of QP, and mean' is the QP adjustment amount.
The values of the parameters a and b need to satisfy the above formula, and satisfy the mean in a range of 8-15, and satisfy monotonic increase, for example, a may be set to 0.5 and b may be set to 14, or a may be set to 0.7 and b may be set to 12.
That is to say, in the embodiment of the present application, the larger the QP average value is, the larger the detail area representing the video frame is, the larger the QP adjustment amount corresponding to the video frame is, so that the QP of the video frame is adjusted downward as much as possible, and finally, the obtained result is that the QP used for encoding is adjusted to be smaller, and the video frame with more detail areas is encoded by using more code streams.
Therefore, based on the above design, the video frame encoding method provided in the embodiment of the present application obtains the QP average value corresponding to the initial QP coding matrix through calculation, so as to process the QP average value by using the set function, and obtain the QP adjustment amount corresponding to the initial QP coding matrix, so that the QP adjustment amount can be adaptively adjusted according to the QP average value corresponding to the initial QP coding matrix, and further, the target video frame can be encoded by combining the detailed characteristics of the target video frame.
It should be noted that the above formula for calculating the QP adjustment amount and the values of the parameters a and b are only illustrative, and in some other possible implementations of the embodiment of the present application, the parameters a and b may be set to other values, and other calculation formulas or manners may be set to calculate the QP adjustment amount, as long as the QP adjustment amount corresponding to the initial QP coding matrix can be calculated, which is not limited in the embodiment of the present application.
In addition, to implement S201, please refer to fig. 5, fig. 5 shows a schematic flowchart of the sub-steps of S201 in fig. 2, and as a possible implementation, S201 may include the following sub-steps:
s201-1, obtaining a target frame type corresponding to a target video frame;
s201-3, according to the frame parameter corresponding relation, using the coding parameter corresponding to the target frame type as the target coding parameter.
In this embodiment of the present application, a frame parameter corresponding relationship may be recorded in the electronic device, and the frame parameter corresponding relationship records a one-to-one corresponding relationship between a plurality of frame types and a plurality of encoding parameters.
For example, in an exemplary implementation manner of the embodiment of the present application, the electronic device may record the frame parameter corresponding relationship in a manner of maintaining frame parameter configuration information, where the frame parameter configuration information may be represented as the following table 1:
TABLE 1
Frame type Encoding parameters
I frame 0.4
P frame 0.75
B frame 0.9
In an application scene of an x264 encoder, for example, a lookahead function module may be used to identify a frame type of a target video frame, so as to determine a target encoding parameter according to the frame type of the target video frame and in combination with frame parameter configuration information shown in table 1; for example, if the target video frame is determined to be an I frame, the encoding parameter 0.4 corresponding to the I frame may be used as the target encoding parameter; if the target video frame is determined to be a B frame, the encoding parameter 0.9 corresponding to the B frame may be used as the target encoding parameter.
Or, in another exemplary implementation manner of the embodiment of the present application, the electronic device may further record the frame parameter corresponding relationship by recording a frame parameter array, for example, the frame parameter array may be represented as:
strength_weight[3]={0.4,0.75,0.9}
wherein, the respective corresponding indexes of the I frame, the P frame and the B frame are 0, 1 and 2 respectively, that is: the coding parameter corresponding to the I frame is strength _ weight [0] ═ 0.4, the coding parameter corresponding to the P frame is strength _ weight [1] ═ 0.75, and the coding parameter corresponding to the B frame is strength _ weight [2] ═ 0.9.
In step S201, if it is determined that the target video frame is an I frame, assigning I to 0, and thus determining that the target coding parameter strength _ weight [0] ═ 0.4; if the target video frame is determined to be a P frame, assigning i to be 1, and determining that a target coding parameter strength _ weight [1] ═ 0.75; if the target video frame is determined to be a B frame, i is assigned to 2, and thus the target encoding parameter strength _ weight [2] is determined to be 0.9.
In addition, to further adjust the amount of key video frame information and non-key video frame information that can be included in the bitstream, please refer to fig. 6, fig. 6 shows another schematic flowchart of a video frame encoding method provided in an embodiment of the present application, and as a possible implementation manner, before executing S203, the video frame encoding method may further include the following steps:
s202, the initial QP coding matrix is processed by using the target coding parameters to obtain an intermediate QP coding matrix.
In the embodiment of the application, before solving the QP adjustment amount, the target coding parameters can be used to process the initial QP coding matrix, so that the initial QP corresponding to the key video frame is reduced compared with the initial QP corresponding to the non-key video frame, and further, the information amount of the key video frame in the code stream is more than the information of the non-key video frame during coding; in addition, by reasonably setting the target coding parameters, the value of the QP corresponding to the target video frame can be reduced, thereby reducing the data processing amount.
For example, the formula for calculating the intermediate QP coding matrix may satisfy the following:
mid=init·strength_werght[i]
in the formula, strengthh _ werght [ i ] represents a target coding parameter, init represents an initial QP coding matrix, and mid represents an intermediate QP coding matrix.
Assuming that the coding parameter corresponding to the I frame is strengthh _ weight [0] ═ 0.4, the coding parameter corresponding to the P frame is strengthh _ weight [1] ═ 0.75, and the coding parameter corresponding to the B frame is strengthh _ weight [2] ═ 0.9, when S202 is executed, the value of QP corresponding to the I frame is reduced to 0.4 times of the original value, the value of QP corresponding to the P frame is reduced to 0.75 times of the original value, and the value of QP corresponding to the B frame is reduced to 0.9 times of the original value; in contrast, if the QP corresponding to the I frame is reduced the most, the code stream can contain more information of the I frame, and if the QP corresponding to the P frame is reduced the least, the information of the B frame contained in the code stream can be reduced; and the amount of data that the electronic equipment needs to process is correspondingly reduced when encoding.
Note that, before S203 is executed, it is necessary to calculate a QP adjustment amount corresponding to the intermediate QP coding matrix with the intermediate QP coding matrix as a calculation target when S203 is executed.
Similarly, when S205 is executed, the intermediate QP coding matrix is also used as an update target, and the intermediate QP coding matrix is updated according to the target coding parameters and the QP adjustment amount, so as to obtain an optimized QP coding matrix.
Referring to fig. 7 based on the same inventive concept as the video frame encoding method, fig. 7 shows a schematic structural diagram of a video frame encoding apparatus 300 according to an embodiment of the present application, where the video frame encoding apparatus 300 includes a preprocessing module 301 and an encoding module 302. Wherein:
the preprocessing module 301 is configured to obtain an initial QP coding matrix and a target coding parameter corresponding to a target video frame, where the target coding parameter corresponds to a frame type of the target video frame;
the preprocessing module 301 is further configured to calculate a QP adjustment corresponding to the initial QP encoding matrix;
the preprocessing module 301 is further configured to update the initial QP coding matrix according to the target coding parameter and the QP adjustment amount, so as to obtain an optimized QP coding matrix;
the encoding module 302 is configured to encode the target video frame using the optimized QP coding matrix.
Optionally, as a possible implementation manner, when the initial QP coding matrix is updated according to the target coding parameter and the QP adjustment amount to obtain the optimized QP coding matrix, the preprocessing module 301 is specifically configured to:
and multiplying the target coding parameter by the algebraic sum of the initial QP coding matrix and the QP adjustment quantity to obtain an optimized QP coding matrix.
Optionally, as a possible implementation manner, the formula for calculating the optimized QP coding matrix satisfies the following:
final=(init-mean)·strength_werght[i]
in the formula, init represents an initial QP coding matrix, mean represents a QP adjustment amount, strengthh _ right [ i ] represents a target coding parameter, and final represents an optimized QP coding matrix.
Optionally, as a possible implementation manner, when calculating the QP adjustment amount corresponding to the initial QP encoding matrix, the preprocessing module 301 is specifically configured to:
calculating a QP average value corresponding to the initial QP coding matrix;
and processing the QP average value by using a set function to obtain the QP adjustment amount.
Optionally, as a possible implementation manner, the formula for calculating the QP adjustment amount satisfies the following:
mean′=mean-a·(mean2-b)/mean
in the formula, a and b are set parameters, mean is the mean value of QP, and mean' is the QP adjustment amount.
Optionally, as a possible implementation manner, when obtaining the target encoding parameter corresponding to the target video frame, the preprocessing module 301 is specifically configured to:
obtaining a target frame type corresponding to a target video frame;
and according to the frame parameter corresponding relation, taking the coding parameters corresponding to the target frame type as target coding parameters, wherein the frame parameter corresponding relation records the one-to-one corresponding relation between a plurality of frame types and a plurality of coding parameters.
Optionally, as a possible implementation manner, before calculating the QP adjustment corresponding to the initial QP encoding matrix, the preprocessing module 301 is further configured to:
processing the initial QP coding matrix by using the target coding parameters to obtain an intermediate QP coding matrix;
when calculating the QP adjustment corresponding to the initial QP encoding matrix, the preprocessing module 301 is specifically configured to:
calculating the QP adjustment amount corresponding to the intermediate QP coding matrix;
the preprocessing module 301, when updating the initial QP coding matrix according to the target coding parameter and the QP adjustment to obtain the optimized QP coding matrix, is specifically configured to:
and updating the intermediate QP coding matrix according to the target coding parameters and the QP adjustment amount to obtain an optimized QP coding matrix.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The apparatus embodiments described above are merely illustrative and, for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s).
It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules 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 or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: u disk, removable hard disk, read only memory, random access memory, magnetic or optical disk, etc. for storing program codes.
In summary, according to the video frame encoding method, the video frame encoding device, the electronic device, and the readable storage medium provided in the embodiments of the present application, after obtaining the initial QP encoding matrix corresponding to the target video frame and the target encoding parameter corresponding to the frame type of the target video frame and calculating the QP adjustment amount corresponding to the initial QP encoding matrix, the initial QP encoding matrix is updated according to the target encoding parameter and the QP adjustment amount to obtain the optimized QP encoding matrix, so that the target video frame is encoded by using the optimized QP encoding matrix.
And after the value field of the initial QP coding matrix is integrally adjusted by the QP adjustment amount, the difference value between the initial QP coding matrix and the QP adjustment amount is zoomed by the target coding parameter, so that an optimized QP coding matrix is obtained, the QP corresponding to the non-key video frame can be adjusted upwards as much as possible, the QP corresponding to the key video frame can be adjusted downwards as much as possible, and the non-key video frame occupies less code streams when being encoded, and the key video frame occupies more code streams when being encoded.
And calculating to obtain a QP average value corresponding to the initial QP coding matrix, processing the QP average value by using a set function, and obtaining a QP adjustment amount corresponding to the initial QP coding matrix, so that the QP adjustment amount can be adaptively adjusted according to the QP average value corresponding to the initial QP coding matrix, and further, the target video frame can be coded by combining the detail characteristics of the target video frame.
Before the QP adjustment amount is obtained, the initial QP coding matrix is processed by using the target coding parameters, so that the initial QP corresponding to the key video frame is reduced compared with the initial QP corresponding to the non-key video frame, and the information amount of the key video frame in the code stream is more than that of the non-key video frame during coding; and the data processing amount during encoding can be reduced.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned.

Claims (10)

1. A method of video frame encoding, the method comprising:
obtaining an initial QP coding matrix and target coding parameters corresponding to a target video frame, wherein the target coding parameters correspond to the frame type of the target video frame;
calculating the QP adjustment amount corresponding to the initial QP coding matrix;
updating the initial QP coding matrix according to the target coding parameters and the QP adjustment amount to obtain an optimized QP coding matrix;
encoding the target video frame using the optimized QP encoding matrix.
2. The method of claim 1, wherein the step of updating the initial QP coding matrix according to the target coding parameters and the QP adjustment to obtain an optimized QP coding matrix comprises:
and multiplying the target coding parameter by the algebraic sum of the initial QP coding matrix and the QP adjustment quantity to obtain the optimized QP coding matrix.
3. The method of claim 2, wherein the formula for calculating the optimized QP coding matrix satisfies the following:
final=(init-mean)·strength_werght[i]
in the formula, init represents the initial QP coding matrix, mean represents the QP adjustment amount, strengthh _ right [ i ] represents the target coding parameter, and final represents the optimized QP coding matrix.
4. The method of claim 1, wherein the step of calculating the QP adjustment for the initial QP coding matrix comprises:
calculating a QP average value corresponding to the initial QP coding matrix;
and processing the QP average value by using a set function to obtain the QP adjustment amount.
5. The method of claim 4, wherein the formula for calculating the QP adjustment satisfies the following:
mean′=mean-a·(mean2-b)/mean
in the formula, a and b are set parameters, mean is the QP average value, and mean' is the QP adjustment amount.
6. The method of claim 1, wherein the step of obtaining target encoding parameters corresponding to the target video frame comprises:
obtaining a target frame type corresponding to the target video frame;
and taking the coding parameters corresponding to the target frame type as the target coding parameters according to the frame parameter corresponding relation, wherein the frame parameter corresponding relation records the one-to-one corresponding relation between a plurality of frame types and a plurality of coding parameters.
7. The method of claim 1, wherein prior to the step of calculating the QP adjustment for the initial QP coding matrix, the method further comprises:
processing the initial QP coding matrix by using the target coding parameters to obtain an intermediate QP coding matrix;
calculating the QP adjustment amount corresponding to the initial QP coding matrix, wherein the step comprises the following steps of:
calculating the QP adjustment amount corresponding to the intermediate QP coding matrix;
updating the initial QP coding matrix according to the target coding parameters and the QP adjustment amount to obtain an optimized QP coding matrix, wherein the step comprises the following steps:
and updating the intermediate QP coding matrix according to the target coding parameters and the QP adjustment quantity to obtain an optimized QP coding matrix.
8. An apparatus for encoding video frames, the apparatus comprising:
the device comprises a preprocessing module, a target coding module and a target coding module, wherein the preprocessing module is used for obtaining an initial QP coding matrix and target coding parameters corresponding to a target video frame, and the target coding parameters correspond to the frame type of the target video frame;
the preprocessing module is further used for calculating a QP adjustment amount corresponding to the initial QP coding matrix;
the preprocessing module is further configured to update the initial QP coding matrix according to the target coding parameter and the QP adjustment amount to obtain an optimized QP coding matrix;
and the coding module is used for coding the target video frame by utilizing the optimized QP coding matrix.
9. An electronic device, comprising:
a memory for storing one or more programs;
a processor;
the one or more programs, when executed by the processor, implement the method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN201910853101.6A 2019-09-10 2019-09-10 Video frame encoding method, video frame encoding device, electronic equipment and readable storage medium Active CN112565755B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910853101.6A CN112565755B (en) 2019-09-10 2019-09-10 Video frame encoding method, video frame encoding device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910853101.6A CN112565755B (en) 2019-09-10 2019-09-10 Video frame encoding method, video frame encoding device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112565755A true CN112565755A (en) 2021-03-26
CN112565755B CN112565755B (en) 2023-05-16

Family

ID=75029017

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910853101.6A Active CN112565755B (en) 2019-09-10 2019-09-10 Video frame encoding method, video frame encoding device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112565755B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120076202A1 (en) * 2010-09-24 2012-03-29 Ilya Brailovskiy System and method for frame level bit rate control without pre-analysis
CN102450014A (en) * 2009-03-31 2012-05-09 拜特移动网络公司 A framework for quality-aware video optimization
CN103051901A (en) * 2013-01-14 2013-04-17 北京华兴宏视技术发展有限公司 Video data coding device and video data encoding method
CN106170979A (en) * 2014-04-30 2016-11-30 英特尔公司 Constant Quality video encodes

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102450014A (en) * 2009-03-31 2012-05-09 拜特移动网络公司 A framework for quality-aware video optimization
US20120076202A1 (en) * 2010-09-24 2012-03-29 Ilya Brailovskiy System and method for frame level bit rate control without pre-analysis
CN103051901A (en) * 2013-01-14 2013-04-17 北京华兴宏视技术发展有限公司 Video data coding device and video data encoding method
CN106170979A (en) * 2014-04-30 2016-11-30 英特尔公司 Constant Quality video encodes

Also Published As

Publication number Publication date
CN112565755B (en) 2023-05-16

Similar Documents

Publication Publication Date Title
CN108574841B (en) Coding method and device based on self-adaptive quantization parameter
CN114979640A (en) Encoding method, encoder and computer readable storage medium
CN111183647B (en) Method, apparatus, and computer-readable medium for decoding video data
KR102417732B1 (en) Quality estimation of adaptive multimedia streaming
CN113938682A (en) Video coding method and device and electronic equipment
US11197021B2 (en) Coding resolution control method and terminal
CN113473131A (en) Video coding code rate dynamic adjustment method and device, electronic equipment and storage medium
CN112738515A (en) Quantization parameter adjustment method and apparatus for adaptive quantization
US11317089B2 (en) Method, apparatus, and storage medium for dividing coding unit of video frame
EP4156691A2 (en) A method, an apparatus and a computer program product for video encoding and video decoding
CN103458239A (en) Image processing apparatus, image processing method, and program
CN112165620A (en) Video encoding method and device, storage medium and electronic equipment
CN109218722B (en) Video coding method, device and equipment
Zhang et al. Enhanced video compression based on effective bit depth adaptation
JP4611938B2 (en) Subjective quality estimation formula deriving method, subjective quality estimation formula deriving apparatus and processing program therefor
JP6806466B2 (en) Image coding device and its control method
CN112565755A (en) Video frame encoding method and device, electronic equipment and readable storage medium
CN116527909A (en) Method, apparatus, device, storage medium and program product for transmitting coding parameters
JP2017123545A (en) Video coding method, video encoder and video coding program
CN111901631B (en) Transcoding method, device, server and storage medium for live video
CN105872538A (en) Time-domain filtering method and time-domain filtering device
CN112822493A (en) Adaptively encoding video frames based on complexity
CN112584143A (en) Video coding method, device and system and computer readable storage medium
CN108206954B (en) Video coding method and device
CN105706447A (en) Moving image coding device, moving image decoding device, moving image coding method, moving image decoding method, and program

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
GR01 Patent grant
GR01 Patent grant