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

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

Info

Publication number
CN112565755B
CN112565755B CN201910853101.6A CN201910853101A CN112565755B CN 112565755 B CN112565755 B CN 112565755B CN 201910853101 A CN201910853101 A CN 201910853101A CN 112565755 B CN112565755 B CN 112565755B
Authority
CN
China
Prior art keywords
target
encoding
coding
video frame
matrix
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.)
Active
Application number
CN201910853101.6A
Other languages
Chinese (zh)
Other versions
CN112565755A (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 device, electronic equipment and a readable storage medium, which relate to the technical field of video coding, and are characterized in that an initial QP coding matrix corresponding to a target video frame and a target coding parameter corresponding to the frame type of the target video frame are obtained, after the QP adjustment corresponding to the initial QP coding matrix is calculated, the initial QP coding matrix is updated according to the target coding parameter and the QP adjustment to obtain an optimized QP coding matrix, so that the target video frame is coded by utilizing the optimized QP coding matrix.

Description

Video frame encoding method, video frame encoding device, electronic equipment and readable storage medium
Technical Field
The present invention relates to the field of video encoding technologies, and in particular, to a video frame encoding method, apparatus, electronic device, and readable storage medium.
Background
With the rapid development of internet technology, the demand of users for high-definition videos is increasing, and the data volume of video multimedia is also increasing, so that if the video is not compressed, the video is difficult to be applied to actual storage and transmission.
The video compression decoding technology can effectively remove redundant information in video data, and realizes rapid transmission and offline storage of the video data in the Internet.
However, when the video frames are compression-encoded by the current video compression technology, the video frames of different types are encoded in the same way, so that the information of the key video frames is not represented enough.
Disclosure of Invention
The present invention provides a video frame encoding method, apparatus, electronic device, and readable storage medium, which can increase the information amount of key video frames contained in a code stream, but decrease the information amount of non-key video frames, so that when decoding, decoding can be performed by using more key video frame information, and the decoding quality is improved.
In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
in a first aspect, an embodiment of the present application provides a video frame encoding method, including:
obtaining an initial QP (quantization parameter ) encoding matrix and a target encoding parameter corresponding to a target video frame, wherein the target encoding parameter corresponds to a frame type of the target video frame;
calculating QP adjustment quantity corresponding to the initial QP coding matrix;
updating the initial QP coding matrix according to the target coding parameter and the QP adjustment amount to obtain an optimized QP coding matrix;
the target video frame is encoded using the optimized QP encoding matrix.
In a second aspect, embodiments of the present application provide a video frame encoding apparatus, the apparatus comprising:
the preprocessing module is used for 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;
the preprocessing module is further used for calculating QP adjustment quantity corresponding to the initial QP encoding matrix;
the preprocessing module is further configured to update the initial QP encoding matrix according to the target encoding parameter and the QP adjustment amount to obtain an optimized QP encoding matrix;
and the encoding module is used for encoding the target video frame by utilizing the optimized QP encoding matrix.
In a third aspect, embodiments of the present application provide an electronic device including a memory for storing one or more programs; a processor; the video frame encoding method described above is implemented when the one or more programs are executed by the processor.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the video frame encoding method described above.
According to the video frame coding method, the video frame coding device, the electronic equipment and the readable storage medium, through 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, after calculating the QP adjustment corresponding to the initial QP coding matrix, updating the initial QP coding matrix according to the target coding parameter and the QP adjustment to obtain the optimized QP coding matrix, and therefore the target video frame is coded by utilizing the optimized QP coding matrix.
In order to make the above 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 needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered limiting in scope, and that other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 shows a schematic 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 in an embodiment of the present application;
FIG. 3 shows a diagram of code quality comparison;
fig. 4 shows a schematic flow chart of sub-steps of S203 in fig. 2;
fig. 5 shows a schematic flow chart of sub-steps 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 shows a schematic structural diagram of a video frame encoding apparatus provided in an embodiment of the present application.
In the figure: 100-an electronic device; 101-memory; 102-a processor; 103-a communication interface; 300-video frame encoding means; 301-a preprocessing module; 302-encoding module.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of 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 apparent that the described embodiments are some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, which are generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, as provided in the accompanying drawings, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures. Also, 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 one … …" does not exclude the presence of other like 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 compressed video size, the video quality, etc. The narrow-band high-definition technology can reduce the video code rate as much as possible without affecting the subjective viewing quality of the video, which is a concern of video transmission service providers, because reducing the code rate means the reduction of video playing bandwidth and saves the cost of video transmission.
There are many optimization features of the x264 encoder, one of which is adaptive quantization, and the adaptive quantization function of x264 can assign a suitable code rate to the video frame based on the human eye characteristics. For example, the human eye is generally more sensitive to flat regions and less sensitive to complex regions, so the adaptive quantization of x264 tends to assign more code rate to flat regions, i.e., lower QP for flat regions, and less code rate to complex regions, i.e., raise QP for complex regions. However, this coding scheme does not distinguish the importance of each of the different types of video frames to video coding, resulting in insufficient information presentation of the key video frames during video coding.
To this end, based on the above-mentioned drawbacks, one possible implementation manner provided in the embodiments of the present application is: the method comprises the steps of obtaining an initial QP coding matrix corresponding to a target video frame and a target coding parameter corresponding to the frame type of the target video frame, after calculating to obtain a QP adjustment amount corresponding to the initial QP coding matrix, updating the initial QP coding matrix according to the target coding parameter and the QP adjustment amount to obtain an optimized QP coding matrix, and then 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, but not the information amount of the key video frames is reduced, and the coded code stream contains more information of the key video frames.
Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may 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 server, such as a server used by a video transmission server to provide services for users, or may be used as a user, such as a terminal used by users to upload video, for example, a mobile phone, a tablet computer, a personal computer, etc., as long as the electronic device 100 is capable of encoding video frames when transmitting video streams.
The electronic device 100 comprises a memory 101, a processor 102 and a communication interface 103, wherein the memory 101, the processor 102 and the communication interface 103 are electrically connected with each other directly or indirectly to realize data transmission or interaction. 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 to store software programs and modules, such as program instructions/modules corresponding to the video frame coding 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 performing various functional applications and data processing. The communication interface 103 may be used for communication of signaling or data with other node devices.
The Memory 101 may be, but is not limited to, a random access Memory (Random Access Memory, RAM), a Read Only Memory (ROM), a programmable Read Only Memory (Programmable Read-Only Memory, PROM), an erasable Read Only Memory (Erasable Programmable Read-Only Memory, EPROM), an electrically erasable programmable Read Only Memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
The processor 102 may be an integrated circuit chip with signal processing capabilities. The processor 102 may be a general purpose processor including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
It is to be understood that the configuration shown in fig. 1 is merely illustrative, and that electronic device 100 may also 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 video frame encoding method provided in the embodiment of the present application will be exemplarily described below with the electronic device 100 shown in fig. 1 as a schematic execution body.
Referring to fig. 2, fig. 2 is a schematic flowchart 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 target coding parameters corresponding to a target video frame;
s203, calculating QP adjustment quantity corresponding to the initial QP coding matrix;
s205, updating the initial QP coding matrix according to the target coding parameter and the QP adjustment amount to obtain an optimized QP coding matrix;
s207, encoding the target video frame by using the optimized QP encoding matrix.
In the embodiment of the application, when the electronic device encodes the target video frame, the electronic device may be based on the respective ac component energy of each macro block in the target video frame and combine with a first-order exponential model, for example, y=x 1/8 Calculating to obtain the QP offset initial value of each macro block in the target video frame; and then counting the QP offset initial values of all macro blocks in the target video frame, thereby obtaining an initial QP coding matrix corresponding to the target video frame.
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 Prediction Frame, bi-directional Frame) are 0.4, 0.75, and 0.9, if the Frame type of the target video Frame is an I Frame, the encoding parameter corresponding to the I Frame may be 0.4 as the target encoding parameter; if the frame type of the target video frame is a P frame, the coding parameter corresponding to the P frame is 0.75 as the target coding parameter; if the frame type of the target video frame is B-frame, the coding parameter corresponding to B-frame may be 0.9 as the target coding parameter.
It should be understood that the above-listed encoding parameters corresponding to the I frame, the P frame, and the B frame are merely illustrative, and in some other possible application scenarios in this application embodiment, the encoding parameters corresponding to 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, respectively, or 0.4, 0.7, and 0.85, respectively, depending on the specific application scenario or user settings, which is not limited by the values of the encoding parameters corresponding to the I frame, the P frame, and the B frame, as long as each type of video frame corresponds to the encoding parameters, such as the encoding parameters corresponding to the I frame, the P frame, and the B frame may also be set to 0.4, 0.75, and 0.9, respectively.
Then, the electronic device calculates the QP adjustment amount corresponding to the initial QP encoding matrix based on the obtained initial QP encoding matrix. For example, a QP average value of all 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 average value obtained by the calculation is scaled by a set weight coefficient, and the result is used as the QP adjustment amount.
Then, the electronic device updates the initial QP encoding matrix according to the target encoding parameters corresponding to the target video frame and the calculated QP adjustment amount to obtain an optimized QP encoding matrix, and encodes the target video frame by using the optimized QP encoding 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 corresponding frame types.
For example, for a key video frame in a video stream, for example, an I frame, a target encoding parameter corresponding to the I frame and a QP adjustment amount corresponding to the I frame may be used to reduce a value in a QP encoding matrix corresponding to the frame, so that a quantization step length of the I frame when encoded is reduced, an encoding result is clearer, and a code stream is larger; for non-key video frames in the video stream, such as B frames, the value in the QP coding matrix corresponding to the frame can be increased by utilizing the target coding parameter corresponding to the B frames and the QP adjustment quantity corresponding to the frame, so that the quantization step length of the B frames when being coded is increased, the coding result is more fuzzy, and the code stream is smaller; in summary, according to the scheme provided by the embodiment of the application, the information amount of the key video frames contained in the code stream can be increased, but the information amount of the non-key video frames is reduced, compared with the current video compression scheme, the same compressed data amount contains more information of the key video frames, and further, when decoding is performed, the more information of the key video frames can be utilized for decoding, so that the decoding quality is improved.
Based on the above design, the video frame coding method provided in the embodiment of the present application obtains 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, calculates the QP adjustment corresponding to the initial QP coding matrix, and then updates the initial QP coding matrix according to the target coding parameter and the QP adjustment to obtain the optimized QP coding matrix, so that the target video frame is coded by using the optimized QP coding matrix.
The same source video frames are encoded according to the video frame encoding scheme provided in the embodiment of the present application and the existing encoding scheme, and then decoded, and SSIM (structural similarity index, structural similarity) corresponding to each of the two encoding schemes is calculated, so as to measure the similarity between the video frames obtained by encoding by each of the two encoding schemes and the source video frames obtained by decoding, thereby obtaining the encoding quality comparison diagram shown in fig. 3.
As can be seen from the comparison of the coding quality shown in fig. 3, assuming that the source video frame is coded with the same code rate for the same source video frame, compared with the video frame coded according to the existing video frame coding scheme, the SSIM calculated after decoding is larger; that is, compared with the existing video frame coding scheme, the video frame coded according to the video frame coding scheme provided by the embodiment of the application has the advantages that the video frame obtained after decoding is more similar to the source video frame, and the decoding quality is higher.
Wherein, in executing S205, implementation may be performed in various manners. Illustratively, as one possible implementation, the algebraic sum of both the initial QP encoding matrix and the QP adjustment amount may be multiplied by the target encoding parameter to obtain an optimized QP encoding matrix.
For example, the formula for calculating the optimized QP encoding matrix may be as follows:
final=(init-mean)·strength_werght[i]
where init represents the initial QP encoding matrix, mean represents the QP adjustment amount, struth_werght i represents the target encoding parameter, final represents the optimized QP encoding matrix.
That is, in the embodiment of the present application, each QP offset initial value in the initial QP encoding matrix may be first subtracted by the QP adjustment amount, so as to adjust the range of values of all QP offset initial values in the initial QP encoding matrix; and then scaling the difference value between the initial QP coding matrix and the QP adjustment by utilizing the target coding parameters, so that the QP corresponding to the target video frame is integrally scaled according to the frame type of the target video frame, and the optimized QP coding matrix is obtained.
The target coding parameters can be adjusted on the whole, and the target coding parameters corresponding to the key video frames are set to be smaller than the target coding parameters corresponding to the non-key video frames, so that the QPs corresponding to the non-key video frames are adjusted upwards as much as possible compared with the QPs corresponding to the key video frames, and the non-key video frames occupy less code streams when being coded; and the QP corresponding to the key video frame is adjusted downwards as much as possible, so that the key video frame occupies more code stream when being encoded.
It can be appreciated that the foregoing adjustment manner is reflected in an application scenario, such as an x264 encoder, and may be reflected in 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 fewer code streams.
Based on the above design, in the video frame coding method provided in the embodiment of the present application, after the value range 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, so that 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, so that the non-key video frame occupies fewer code streams when being coded, and the key video frame occupies more code streams when being coded.
It should be noted that, the above formula for calculating the optimized QP encoding matrix is only illustrative, and in some other possible implementations of the embodiments of the present application, other ways or formulas may be used to calculate the optimized QP encoding matrix, so long as the initial QP encoding matrix can be updated according to the target encoding parameter and the QP adjustment amount, so that the optimized QP encoding matrix is obtained.
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 in the manner of 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 upward as much as possible and adjust the QP corresponding to the key video frame downward as much as possible, referring to fig. 4, fig. 4 shows a schematic flowchart of the substep of S203 in fig. 2, as a possible implementation manner, S203 may include the following substeps:
s203-1, calculating a QP average corresponding to the initial QP coding matrix;
s203-3, processing the QP average by using the set function to obtain the QP adjustment.
In the embodiment of the present application, the QP average value obtained by calculation may be further processed by using a set function on the basis of the QP average value obtained by calculation corresponding to the initial QP encoding matrix, so as to obtain the QP adjustment amount corresponding to the initial QP encoding matrix.
The QP average value of the video frame may be generally used to characterize the detail area condition of the video frame, where a larger QP average value represents a relatively large detail area contained in the video frame; while a smaller QP average represents a relatively smaller detail region contained by the video.
In addition, the QP average value of the video frame is generally 8-15, and a monotonically increasing function can be set in the range of the value, so that the larger the QP average value is, the larger the 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:
mean′=mean-a·(mean 2 -b)/mean
in the formula, a and b are set parameters, mean is a QP average value, and mean' is a QP adjustment amount.
Wherein the values of the parameters a and b need to meet the above formula and meet the monotonic increment in the range of 8-15, for example, a can be set to 0.5, b can be set to 14, or a is set to 0.7, and b can be set to 12.
That is, in the embodiment of the present application, the larger the QP average value, the larger the detail area representing the video frame, the larger the QP adjustment amount corresponding to the video frame, so that the QP of the video frame is adjusted as downward as possible, and the final result is that the QP for encoding is adjusted smaller, and more video frames with more detail areas are encoded with more code streams.
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 encoding matrix through calculation, so that the QP average value is processed by using the set function, and the QP adjustment amount corresponding to the initial QP encoding matrix is obtained, so that the QP adjustment amount can be adaptively adjusted according to the QP average value corresponding to the initial QP encoding matrix, and further, the target video frame can be encoded in combination with the detail characteristic 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 modes may be set to calculate the QP adjustment amount, so long as the QP adjustment amount corresponding to the initial QP encoding matrix can be calculated, which is not limited in the embodiment of the present application.
In addition, to implement S201, referring to fig. 5, fig. 5 shows a schematic flow chart of sub-steps of S201 in fig. 2, as one possible implementation, S201 may include the following sub-steps:
s201-1, obtaining a target frame type corresponding to a target video frame;
s201-3, taking the coding parameter corresponding to the target frame type as a target coding parameter according to the corresponding relation of the frame parameters.
In this embodiment of the present application, a frame parameter correspondence may be recorded in the electronic device, where the frame parameter correspondence is recorded with a one-to-one correspondence 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 correspondence by maintaining frame parameter configuration information, where the frame parameter configuration information may be represented as the following table 1:
TABLE 1
Frame type Coding parameters
I-frame 0.4
P-frame 0.75
B frame 0.9
In an application scenario of, for example, the x264 encoder, the frame type of the target video frame may be identified by, for example, a lookahead function module, so as to determine the target encoding parameter according to the frame type of the target video frame in combination with the frame parameter configuration information shown in table 1; if the target video frame is determined to be the I frame, the coding parameter 0.4 corresponding to the I frame can be used as the target coding parameter; if the target video frame is determined to be the B frame, the coding parameter 0.9 corresponding to the B frame can be used as the target coding parameter.
Alternatively, in another exemplary implementation manner of the embodiment of the present application, the electronic device may record the frame parameter correspondence by recording a frame parameter array, for example, the frame parameter array may be expressed as:
strength_weight[3]={0.4,0.75,0.9}
the indexes corresponding to the I frame, the P frame and the B frame are respectively 0, 1 and 2, namely: 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 executing S201, if it is determined that the target video frame is an I frame, I is assigned to 0, so as to determine a target coding parameter strungth_weight [0] =0.4; if the target video frame is determined to be a P frame, i is assigned to be 1, so that a target coding parameter strength_weight [1] =0.75 is determined; if the target video frame is determined to be a B frame, i is assigned to be 2, so that a target coding parameter strength_weight [2] =0.9 is determined.
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, referring to fig. 6, fig. 6 shows another schematic flowchart of a video frame encoding method according to an embodiment of the present application, as a possible implementation manner, before executing S203, the video frame encoding method may further include the following steps:
s202, processing the initial QP coding matrix by using the target coding parameters to obtain an intermediate QP coding matrix.
In the embodiment of the application, before the QP adjustment amount is obtained, the initial QP encoding matrix may be processed by using the target encoding parameter, 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 further greater than the information of the non-key video frame during encoding; and by reasonably setting the target coding parameters, the QP value corresponding to the target video frame can be reduced, so that the data processing amount is reduced.
For example, the formula for calculating the intermediate QP encoding matrix may be satisfied as follows:
mid=init·strength_werght[i]
where, strngth_werght [ i ] represents the target coding parameter, init represents the initial QP encoding matrix, mid represents the intermediate QP encoding matrix.
Assuming that the encoding parameter corresponding to the I frame is strength_weight [0] =0.4, the encoding parameter corresponding to the P frame is strength_weight [1] =0.75, and the encoding parameter corresponding to the B frame is strength_weight [2] =0.9, when S202 is performed, the value of QP corresponding to the I frame is reduced to 0.4 times as large as the original QP, the value of QP corresponding to the P frame is reduced to 0.75 times as large as the original QP, and the value of QP corresponding to the B frame is reduced to 0.9 times as large as the original QP; in contrast, if the QP corresponding to the I frame is most reduced, more information of the I frame can be contained in the code stream, and if the P frame is less frequently reduced, information of the B frame can be contained in the code stream is reduced; and the amount of data that the electronic device needs to process during encoding is correspondingly reduced.
Note that, when S203 is executed, the QP adjustment amount corresponding to the intermediate QP encoding matrix needs to be calculated with the intermediate QP encoding matrix as a calculation target at the time of S203.
Similarly, when S205 is executed, the intermediate QP encoding matrix is updated based on the target encoding parameter and the QP adjustment amount, with the intermediate QP encoding matrix being the update target, to obtain an optimized QP encoding matrix.
Referring to fig. 7, fig. 7 shows a schematic block 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 encoding matrix and a target encoding parameter corresponding to a target video frame, where the target encoding parameter corresponds to a frame type of the target video frame;
the preprocessing module 301 is further configured to calculate a QP adjustment amount corresponding to the initial QP encoding matrix;
the preprocessing module 301 is further configured to update the initial QP encoding matrix according to the target encoding parameter and the QP adjustment amount, to obtain an optimized QP encoding matrix;
the encoding module 302 is configured to encode the target video frame using the optimized QP encoding matrix.
Optionally, as a possible implementation manner, the preprocessing module 301 is specifically configured to, when updating the initial QP encoding matrix according to the target encoding parameter and the QP adjustment amount to obtain the optimized QP encoding matrix:
the target coding parameter is multiplied by the algebraic sum of both the initial QP encoding matrix and the QP adjustment to obtain an optimized QP encoding matrix.
Alternatively, as one possible implementation, the formula for calculating the optimized QP encoding matrix satisfies the following:
final=(init-mean)·strength_werght[i]
where init represents the initial QP encoding matrix, mean represents the QP adjustment amount, struth_werght i represents the target encoding parameter, final represents the optimized QP encoding matrix.
Optionally, as a possible implementation manner, the preprocessing module 301 is specifically configured to, when calculating the QP adjustment amount corresponding to the initial QP encoding matrix:
calculating a QP average value corresponding to the initial QP coding matrix;
and processing the QP average value by using the set function to obtain the QP adjustment quantity.
Alternatively, as one possible implementation, the formula for calculating the QP adjustment amount satisfies the following:
mean′=mean-a·(mean 2 -b)/mean
in the formula, a and b are set parameters, mean is a QP average value, and mean' is a QP adjustment amount.
Optionally, as a possible implementation manner, the preprocessing module 301 is specifically configured to, when obtaining the target coding parameter corresponding to the target video frame:
obtaining a target frame type corresponding to a target video frame;
and taking the coding parameter corresponding to the target frame type as a target coding parameter according to the frame parameter corresponding relation, wherein the frame parameter corresponding relation records one-to-one correspondence between a plurality of frame types and a plurality of coding parameters.
Optionally, as a possible implementation, the preprocessing module 301 is further configured to, before calculating the QP adjustment amount corresponding to the initial QP encoding matrix:
processing the initial QP coding matrix by utilizing the target coding parameters to obtain an intermediate QP coding matrix;
the preprocessing module 301 is specifically configured to, when calculating the QP adjustment amount corresponding to the initial QP encoding matrix:
calculating QP adjustment quantity corresponding to the intermediate QP coding matrix;
the preprocessing module 301 is specifically configured to, when updating the initial QP encoding matrix according to the target encoding parameter and the QP adjustment amount to obtain an optimized QP encoding matrix:
and updating the intermediate QP coding matrix according to the target coding parameter and the QP adjustment quantity 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 manners as well. The apparatus embodiments described above are merely illustrative, for example, of the flowcharts and block diagrams in the figures that 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 a single part, or each module may exist alone, or two or more modules may be integrated to form a single 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 may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk.
In summary, according to the video frame encoding method, apparatus, electronic device and readable storage medium provided in the embodiments of the present application, by obtaining an initial QP encoding matrix corresponding to a target video frame and a target encoding parameter corresponding to a frame type of the target video frame, and calculating a QP adjustment corresponding to the initial QP encoding matrix, then updating the initial QP encoding matrix according to the target encoding parameter and the QP adjustment to obtain an optimized QP encoding matrix, so that the target video frame is encoded by using the optimized QP encoding matrix.
And the value domain of the initial QP coding matrix is integrally adjusted by the QP adjustment quantity, and then the difference value between the initial QP coding matrix and the QP adjustment quantity is scaled by the target coding parameter, so that the optimized QP coding matrix is obtained, QP corresponding to the non-key video frame can be adjusted upwards as much as possible, QP corresponding to the key video frame is adjusted downwards as much as possible, so that the non-key video frame occupies fewer code streams when being coded, and the key video frame occupies more code streams when being coded.
And the QP average value corresponding to the initial QP encoding matrix is obtained through calculation, so that the QP average value is processed by a set function to obtain the QP adjustment quantity corresponding to the initial QP encoding matrix, the QP adjustment quantity can be adaptively adjusted according to the QP average value corresponding to the initial QP encoding matrix, and the target video frame can be encoded according to the detail characteristic of the target video frame.
Before the QP adjustment amount is obtained, the initial QP encoding matrix is processed by utilizing the target encoding 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 the information of the non-key video frame during encoding; and the data processing amount at the time of encoding can be reduced.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the same, but rather, various modifications and variations may be made by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application should 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 characteristics 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 (9)

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 QP adjustment quantity corresponding to the initial QP coding matrix;
updating the initial QP encoding matrix according to the target encoding parameter and the QP adjustment amount to obtain an optimized QP encoding matrix, including: multiplying the algebraic difference between the initial QP coding matrix and the QP adjustment by the target coding parameter to obtain the optimized QP coding matrix;
the target video frame is encoded using the optimized QP encoding matrix.
2. The method of claim 1, wherein the formula for calculating the optimized QP encoding matrix satisfies the following:
final=(init-mean)·strength_werght[i]
wherein init represents the initial QP encoding matrix, mean represents the QP adjustment amount, struth_right [ i ] represents the target encoding parameter, final represents the optimized QP encoding matrix.
3. The method of claim 1, wherein the step of calculating the QP adjustment amount corresponding to the initial QP encoding 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 quantity.
4. A method according to claim 3, wherein the formula for calculating the QP adjustment amount satisfies the following:
mean′=mean-a·(mean 2 -b)/mean
wherein a and b are set parameters, mean is the QP average value, and mean' is the QP adjustment amount.
5. The method of claim 1, wherein the step of obtaining the target coding 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 types as the target coding parameters according to the frame parameter corresponding relation, wherein the frame parameter corresponding relation records one-to-one correspondence between a plurality of frame types and a plurality of coding parameters.
6. The method of claim 1, wherein prior to the step of calculating the QP adjustment amount corresponding to the initial QP encoding matrix, the method further comprises:
processing the initial QP coding matrix by utilizing the target coding parameters to obtain an intermediate QP coding matrix;
the step of calculating the QP adjustment amount corresponding to the initial QP encoding matrix includes:
calculating QP adjustment quantity corresponding to the intermediate QP coding matrix;
updating the initial QP coding matrix according to the target coding parameter and the QP adjustment amount to obtain an optimized QP coding matrix, wherein the method comprises the following steps:
and updating the intermediate QP coding matrix according to the target coding parameter and the QP adjustment quantity to obtain an optimized QP coding matrix.
7. A video frame encoding apparatus, the apparatus comprising:
the preprocessing module is used for 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;
the preprocessing module is further used for calculating QP adjustment quantity corresponding to the initial QP encoding matrix;
the preprocessing module is further configured to update the initial QP encoding matrix according to the target encoding parameter and the QP adjustment amount to obtain an optimized QP encoding matrix; the preprocessing module is specifically configured to: multiplying the algebraic difference between the initial QP coding matrix and the QP adjustment by the target coding parameter to obtain the optimized QP coding matrix;
and the encoding module is used for encoding the target video frame by utilizing the optimized QP encoding matrix.
8. An electronic device, comprising:
a memory for storing one or more programs;
a processor;
the method of any of claims 1-6 is implemented when the one or more programs are executed by the processor.
9. A computer readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the method according to any of claims 1-6.
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 CN112565755A (en) 2021-03-26
CN112565755B true 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)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2415269B1 (en) * 2009-03-31 2020-03-11 Citrix Systems, Inc. A framework for quality-aware video optimization
US8483272B2 (en) * 2010-09-24 2013-07-09 Intel Corporation System and method for frame level bit rate control without pre-analysis
CN103051901B (en) * 2013-01-14 2015-10-28 北京华兴宏视技术发展有限公司 Video data coding device and method for coding video data
US9661329B2 (en) * 2014-04-30 2017-05-23 Intel Corporation Constant quality video coding

Also Published As

Publication number Publication date
CN112565755A (en) 2021-03-26

Similar Documents

Publication Publication Date Title
JP5365518B2 (en) Image processing apparatus and method
CN108574841B (en) Coding method and device based on self-adaptive quantization parameter
US8718146B2 (en) Method, medium, and system encoding/decoding video data using bitrate adaptive binary arithmetic coding
US8848788B2 (en) Method and apparatus for joint quantization parameter adjustment
JP5590133B2 (en) Moving picture coding apparatus, moving picture coding method, moving picture coding computer program, moving picture decoding apparatus, moving picture decoding method, and moving picture decoding computer program
WO2009035149A1 (en) Image processing device and image processing method
CN108235016A (en) A kind of bit rate control method and device
US11197021B2 (en) Coding resolution control method and terminal
US8582898B2 (en) Method and apparatus for encoding and decoding image based on code table selection adapted to residual value distribution
CN112165620B (en) Video encoding method and device, storage medium and electronic equipment
EP4322523A1 (en) Residual coding method and device, video coding method and device, and storage medium
WO2022021422A1 (en) Video coding method and system, coder, and computer storage medium
CN111316642A (en) Method and apparatus for signaling image coding and decoding partition information
CN101426135B (en) Encoding apparatus, method of controlling thereof
US8938001B1 (en) Apparatus and method for coding using combinations
CN104125460A (en) Method and apparatus for controlling video bitrates
CN113973205A (en) Code rate control bit distribution method based on video content characteristics and storage medium
CN112565755B (en) Video frame encoding method, video frame encoding device, electronic equipment and readable storage medium
CN116527909A (en) Method, apparatus, device, storage medium and program product for transmitting coding parameters
CN116193118A (en) LCEVC-based enhancement layer coding method, device, equipment and medium
CN117640941A (en) Video encoding method, video encoding device, electronic equipment and computer readable storage medium
CN116137658A (en) Video coding method and device
CN112584143A (en) Video coding method, device and system and computer readable storage medium
CN112822493A (en) Adaptively encoding video frames based on complexity
CN114422783B (en) Video encoding method, electronic device, and storage medium

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