CN109874012B - Video coding method, encoder, electronic device and medium - Google Patents

Video coding method, encoder, electronic device and medium Download PDF

Info

Publication number
CN109874012B
CN109874012B CN201711261657.3A CN201711261657A CN109874012B CN 109874012 B CN109874012 B CN 109874012B CN 201711261657 A CN201711261657 A CN 201711261657A CN 109874012 B CN109874012 B CN 109874012B
Authority
CN
China
Prior art keywords
block
coefficient
quantized
zero
transform
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
CN201711261657.3A
Other languages
Chinese (zh)
Other versions
CN109874012A (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.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud 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 Beijing Kingsoft Cloud Network Technology Co Ltd, Beijing Kingsoft Cloud Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN201711261657.3A priority Critical patent/CN109874012B/en
Priority to PCT/CN2018/119146 priority patent/WO2019109906A1/en
Publication of CN109874012A publication Critical patent/CN109874012A/en
Application granted granted Critical
Publication of CN109874012B publication Critical patent/CN109874012B/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/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/90Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using coding techniques not provided for in groups H04N19/10-H04N19/85, e.g. fractals
    • H04N19/91Entropy coding, e.g. variable length coding [VLC] or arithmetic coding

Landscapes

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

Abstract

The embodiment of the invention provides a video coding method, an encoder, electronic equipment and a medium, wherein the video coding method is applied to the encoder and comprises the following steps: acquiring a transformation coefficient block obtained for each video frame data block to be coded; comparing each transformation coefficient in the transformation coefficient block with a preset threshold value respectively, and replacing the transformation coefficient smaller than the preset threshold value with 0 to obtain a new transformation coefficient block; judging whether the new transformation coefficient block is an all-zero block; if the new transformation coefficient block is an all-zero block, the number of non-zero transformation coefficients in the video frame data block is coded to be 0, and the coding of the video frame data block is finished; if the new transformation coefficient block is not an all-zero block, carrying out quantization processing on the transformation coefficient block to obtain a quantized quantization coefficient block; and performing entropy coding according to the quantized quantization coefficient block.

Description

Video coding method, encoder, electronic device and medium
Technical Field
The present invention relates to the field of video encoding technologies, and in particular, to a video encoding method, an encoder, an electronic device, and a medium.
Background
With the continuous development of multimedia digital video application and the continuous improvement of the demand of people for video cloud computing, the data volume of an original video information source can not be borne by the bandwidth and storage resources of the existing transmission network. Therefore, compression of video signals has become one of the hot spots for academic research and industrial application at home and abroad. Video compression, also known as video coding, aims to eliminate redundant information between video signals.
Referring to fig. 1, fig. 1 is a basic flowchart of a Video encoder currently using the High Efficiency Video Coding (HEVC) standard for encoding. The basic process comprises the following steps:
a block dividing step: an encoder receives an input video signal, divides images or frames of the video signal into blocks to be coded, wherein the blocks to be coded are usually square blocks, other non-square blocks are allowed, and the sizes of the blocks to be coded are generally 8x8, 16x16, 32x32 and 64x 64;
a prediction step: predicting a video signal in a current block to be coded to obtain a prediction signal in a reference block; the method comprises the steps that every two pixels of corresponding positions of a reference block and a current block to be coded are subjected to difference to form a residual signal in a residual block;
a transformation step: transforming the residual signal in the residual block from a space domain frequency spectrum to a frequency domain, and concentrating the energy of the residual signal in the residual block on a few low-frequency transformation coefficients with preset number through preset linear operation to obtain a transformation coefficient block with two-dimensional transformation coefficients with more concentrated energy in a transformation domain;
a quantization step: quantizing the two-dimensional transform coefficients in the transform coefficient block by using quantization information preset by an encoder and pixel bit depth information extracted from a block to be coded, and reducing the quantized coefficients in the quantized quantization coefficient block into coefficients smaller than the transform coefficients in the original transform coefficient block;
entropy coding step: and performing entropy coding according to the quantized quantization coefficient block to form a final code stream.
Although the prior art video encoder implements compression encoding, the encoding speed still needs to be improved.
Disclosure of Invention
Embodiments of the present invention provide a video encoding method, an encoder, an electronic device, and a medium, so as to improve encoding speed. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a video encoding method, including:
acquiring a transformation coefficient block obtained for each video frame data block to be coded;
comparing each transformation coefficient in the transformation coefficient block with a preset threshold value respectively, and replacing the transformation coefficient smaller than the preset threshold value with 0 to obtain a new transformation coefficient block;
judging whether the new transformation coefficient block is an all-zero block;
if the new transform coefficient block is an all-zero block, the number of non-zero transform coefficients in the video frame data block is coded to be 0, and the coding of the video frame data block is finished;
if the new transformation coefficient block is not an all-zero block, carrying out quantization processing on the transformation coefficient block to obtain a quantized quantization coefficient block;
and performing entropy coding according to the quantized coefficient block.
Optionally, the performing entropy coding according to the quantized coefficient block includes:
judging whether the quantized coefficient block is an all-zero block;
if the quantized coefficient block is judged to be an all-zero block, the number of non-zero quantized coefficients in the quantized coefficient block is coded to be 0, and the coding of the video frame data block is finished;
and if the quantized coefficient block is judged not to be an all-zero block, entropy coding is carried out on the quantized coefficient block.
Optionally, the obtaining the transform coefficient block obtained for each video frame data block to be encoded includes:
predicting each video frame data block to be coded to obtain a residual block corresponding to the video frame data block;
and carrying out frequency spectrum transformation on the residual block corresponding to the video frame data block to obtain the transformation coefficient block.
Optionally, the preset threshold is obtained by pre-calculating according to the following formula:
Figure BDA0001493735820000031
where Th (x, y) is a preset threshold corresponding to a transform coefficient in the transform coefficient block, where (x, y) in Th (x, y) is a position of the transform coefficient in the transform coefficient block, where, when the transform coefficient block is a two-dimensional matrix, x is a row of the position of the transform coefficient in the transform coefficient block, y is a column of the position of the transform coefficient in the transform coefficient block, QP is a preset quantization parameter, shift is a shift value, shift takes a value of 29-B-M, where B is pixel bit depth information of a video frame data block to be encoded, M is a size of a residual block corresponding to the video frame data block, the residual block is a residual block of N × N, and M is log2N, offset is an offset value
Figure BDA0001493735820000032
G={G0,G1,G2,G3,G4,G5}={2-4/6,2-3/6,2-2/6,2-1/6,20,21/6},f={f0,f1,f2,f3,f4,f5{26214,23302,20560,18396,16384,14564}, w (x, y) is a preset quantization weight factor, factor is a preset threshold factor, and the value range of the factor is [1, 1.5 ]]。
Optionally, the quantizing the transform coefficient block includes:
and carrying out quantization processing on the transformation coefficient block by utilizing preset quantization information and pixel bit depth information of the video frame data block to be coded.
Alternatively, it is calculated by the following formula:
Figure BDA0001493735820000033
a block of quantized coefficients is obtained after quantization,
wherein Q (x, Y) represents the quantized coefficient block, x (x, Y) of Q (x, Y) is a position of a coefficient in the quantized coefficient block, x is a row of positions of quantized coefficients in the quantized coefficient block, Y is a column of positions of quantized coefficients in the quantized coefficient block, Y (x, Y) is a transform coefficient located at a position in the transform coefficient block, where (x, Y) is a position of a transform coefficient in the transform coefficient block, x is a row of positions of transform coefficients in the transform coefficient block, Y is a column of positions of transform coefficients in the transform coefficient block, sign (Y (x, Y)) represents positive and negative values of transform coefficients in the transform coefficient block, when the transform coefficient block is a two-dimensional matrix, the value set of sign (Y (x, Y)) is { -1, 0,1 }.
Optionally, the entropy encoding of the quantized coefficient block includes:
determining a first position corresponding to a first non-zero quantized coefficient and a second position corresponding to a last non-zero quantized coefficient of each quantized coefficient block according to a preset sequence;
and entropy coding all quantized coefficients of each quantized coefficient block from a first non-zero quantized coefficient corresponding to a first position to a last non-zero quantized coefficient corresponding to a second position.
In a second aspect, an embodiment of the present invention provides an encoder, including:
the first acquisition module is used for acquiring a transformation coefficient block obtained by aiming at each video frame data block to be coded;
a comparison and replacement module, configured to compare each transform coefficient in the transform coefficient block with a preset threshold, and replace a transform coefficient smaller than the preset threshold with 0 to obtain a new transform coefficient block;
the judging module is used for judging whether the new transformation coefficient block is an all-zero block;
a first encoding module, configured to, if the new transform coefficient block is an all-zero block, encode that the number of non-zero transform coefficients in the video frame data block is 0, and end encoding of the video frame data block;
a second obtaining module, configured to perform quantization processing on the new transform coefficient block to obtain a quantized quantization coefficient block if the new transform coefficient block is not an all-zero block;
and the second coding module is used for carrying out entropy coding according to the quantized coefficient block.
Optionally, the second encoding module is configured to specifically include:
the judging submodule is used for judging whether the quantized coefficient block is an all-zero block;
a first encoding sub-module, configured to, if it is determined that the quantized coefficient block is an all-zero block, encode that the number of non-zero quantized coefficients in the quantized coefficient block is 0, and end encoding of the video frame data block;
and the second coding sub-module is used for entropy coding the quantized coefficient block if the quantized coefficient block is judged not to be a full zero block.
Optionally, the first obtaining module includes:
the prediction submodule is used for predicting each video frame data block to be coded to obtain a residual block corresponding to the video frame data block;
and the obtaining submodule is used for carrying out frequency spectrum transformation on the residual block corresponding to the video frame data block to obtain the transformation coefficient block.
Optionally, the preset threshold is obtained by pre-calculating according to the following formula:
Figure BDA0001493735820000051
where Th (x, y) is a preset threshold corresponding to a transform coefficient in the transform coefficient block, where (x, y) in Th (x, y) is a position of the transform coefficient in the transform coefficient block, where, when the transform coefficient block is a two-dimensional matrix, x is a row of the position of the transform coefficient in the transform coefficient block, y is a column of the position of the transform coefficient in the transform coefficient block, QP is a preset quantization parameter, shift is a shift value, shift takes a value of 29-B-M, where B is pixel bit depth information of a video frame data block to be encoded, M is a size of a residual block corresponding to the video frame data block, the residual block is a residual block of N × N, and M is log2N, offset is an offset value
Figure BDA0001493735820000052
G={G0,G1,G2,G3,G4,G5}={2-4/6,2-3/6,2-2/6,2-1/6,20,21/6},f={f0,f1,f2,f3,f4,f5{26214,23302,20560,18396,16384,14564}, w (x, y) is a preset quantization weight factor, factor is a preset threshold factor, and the value range of the factor is [1, 1.5 ]]。
Optionally, the second obtaining module is specifically configured to perform quantization processing on the transform coefficient block by using preset quantization information and pixel bit depth information of the video frame data block to be encoded.
Optionally, the second obtaining module is specifically configured to calculate by the following formula:
Figure BDA0001493735820000061
a block of quantized coefficients is obtained after quantization,
wherein Q (x, Y) represents the quantized block of quantized coefficients, x, Y of Q (x, Y) is the position of a coefficient in the block of quantized coefficients, x is the row of the block of quantized coefficients, Y is the column of the block of quantized coefficients, Y (x, Y) is a transform coefficient located at the position in the block of transform coefficients, where (x, Y) is the position of a transform coefficient in the block of transform coefficients, x is the row of the block of transform coefficients, Y is the column of the block of transform coefficients, sign (Y (x, Y)) represents the positive or negative value of a transform coefficient in the block of transform coefficients, sign (Y (x, y)) is { -1, 0,1 }.
Optionally, the second encoding submodule is specifically configured to:
determining a first position corresponding to a first non-zero quantized coefficient and a second position corresponding to a last non-zero quantized coefficient of each quantized coefficient block according to a preset sequence;
and entropy coding all quantized coefficients of each quantized coefficient block from a first non-zero quantized coefficient corresponding to a first position to a last non-zero quantized coefficient corresponding to a second position.
In a third aspect, an embodiment of the present invention provides an electronic device, including an encoder and a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions executable by the encoder, and the encoder is caused by the machine-executable instructions to: the steps of the video encoding method described above in the first aspect are implemented.
In a fourth aspect, an embodiment of the present invention provides an electronic device, including a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to: the steps of the video encoding method described above in the first aspect are implemented.
In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored in the storage medium, and the computer program, when executed by a processor, implements the steps of the video encoding method in the first aspect.
In a sixth aspect, embodiments of the present invention provide a computer program product containing instructions, which when executed on a computer, cause the computer to perform the steps of the video encoding method of the first aspect.
In a seventh aspect, an embodiment of the present invention provides a computer program, which, when run on a computer, causes the computer to execute the steps of the video encoding method for implementing the first aspect.
In the video encoding method, the encoder, the electronic device, and the medium provided in the embodiments of the present invention, each transform coefficient in a transform coefficient block is compared with a preset threshold, and a transform coefficient smaller than the preset threshold is replaced with 0, if a new transform coefficient block is an all-zero block, the corresponding transform coefficient block before the new transform coefficient block replaces the transform coefficient is not quantized, the number of non-zero transform coefficients in an encoded video frame data block is 0, and encoding is ended; if the new transformation coefficient block is not an all-zero block, only carrying out quantization processing on the corresponding transformation coefficient block before the new transformation coefficient block replaces the transformation coefficient to obtain a quantized quantization coefficient block; and performing entropy coding according to the quantized quantization coefficient block.
Therefore, in the embodiment of the present invention, when a new transform coefficient block is an all-zero block, the corresponding transform coefficient block before replacing the transform coefficient with the new transform coefficient block is not quantized, and the number of non-zero transform coefficients in the video frame data block is directly encoded to be 0, so that the number of transform coefficient blocks subjected to entropy encoding is reduced, and the encoding speed is further improved.
Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a basic flow diagram of a prior art video encoder employing a high efficiency video standard;
FIG. 2 is a first flowchart illustrating a video encoding method according to an embodiment of the present invention;
FIG. 3 is a second flowchart of a video encoding method according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating a first structure of an encoder according to an embodiment of the present invention;
FIG. 5 is a general block diagram of a video encoder to which an embodiment of the present invention is applied;
FIG. 6 is a first structural diagram of an electronic device according to an embodiment of the invention;
fig. 7 is a second structural diagram of the electronic device according to the embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. 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 invention.
In view of the situation that although the prior art video encoder implements compression encoding, the encoding speed still needs to be improved, embodiments of the present invention provide a video encoding method, an encoder, an electronic device, and a medium, so as to improve the encoding speed.
The following first describes a video encoding method provided by an embodiment of the present invention.
The video encoding method provided in the embodiment of the present invention may be applied to an encoder or a processor, and is not limited in the embodiment of the present invention.
As shown in fig. 2, a video encoding method provided in an embodiment of the present invention may include the following steps:
in step 201, a transform coefficient block obtained for each video frame data block to be encoded is obtained.
In a specific embodiment, this step may obtain the transform coefficient block obtained for each block of video frame data to be encoded by:
firstly, predicting each video frame data block to be coded to obtain a residual block corresponding to the video frame data block; and then carrying out frequency spectrum transformation on the residual block corresponding to the video frame data block to obtain the transformation coefficient block.
In other embodiments, the transform coefficient block obtained for each video frame data block to be encoded may be stored in a preset database, and step 201 may obtain the transform data block directly from the preset database.
In this embodiment, the video frame data block to be encoded may be a 4x4 video frame data block, may also be an 8x8 video frame data block, may also be a 16x16 video frame data block, and may also be a 32x32 video frame data block, which is not limited herein. Any block of video frame data that can implement the embodiment of the present invention falls within the scope of the embodiment of the present invention, which is not limited herein.
Step 202, comparing each transform coefficient in the transform coefficient block with a preset threshold respectively, and replacing the transform coefficient smaller than the preset threshold with 0 to obtain a new transform coefficient block.
In a specific embodiment, the preset threshold may be preset according to an empirical value or an industrial requirement, and generally the preset threshold is a value greater than or equal to 0, for example, the value may be a value in a range from 0 to 3. The larger the value of the value, the more partial information of the transform coefficient loss in the transform coefficient block. The setting of the specific preset threshold value can be determined according to actual conditions. The embodiment of the invention only uses one preset threshold value, so that the comparison process is relatively convenient and fast to complete.
In other specific embodiments, the corresponding preset threshold is calculated for different quantization information and pixel bit depth information of a video frame data block to be coded, and the preset quantization information, the pixel depth information and the corresponding preset threshold are stored. The preset quantization information includes: a preset quantization weight factor and a preset quantization parameter. Therefore, in the whole video coding process, the video coding method can directly use the pre-stored preset threshold value, the preset threshold value does not need to be calculated in real time, and the occupied running memory of video coding can be reduced.
After the video frame data block to be encoded is obtained, preset quantization information and pixel bit depth information of the video frame data block to be encoded may be obtained first, and a preset threshold corresponding to each transform coefficient in the transform coefficient block is searched from preset thresholds stored in advance.
The preset threshold is obtained by calculating according to the following formula:
Figure BDA0001493735820000091
where Th (x, y) is a preset threshold corresponding to a transform coefficient in a transform coefficient block, where (x, y) in Th (x, y) is a position of the transform coefficient in the transform coefficient block, where, when the transform coefficient block is a two-dimensional matrix, x is a row of the position of the transform coefficient in the transform coefficient block, y is a column of the position of the transform coefficient in the transform coefficient block, QP is a preset quantization parameter, shift is a shift value, and shift takes a value of 29-B-M, where B is pixel bit depth information of a video frame data block to be encoded, M is a size of a residual block corresponding to the video frame data block, and the residual block is a size of the residual block corresponding to the video frame data blockFor a residual block of N × N, M ═ log2N, offset is an offset value
Figure BDA0001493735820000101
G={G0,G1,G2,G3,G4,G5}={2-4/6,2-3/6,2-2/6,2-1/6,20,21/6},f={f0,f1,f2,f3,f4,f5Where w (x, y) is a preset quantization weight factor, w (x, y) may be equal to 1, and is not limited herein, the factor is a preset threshold factor, and the factor has a value range of [1, 1.5 ]]The preset threshold value can be changed by a threshold factor.
The above Th (x, y) formula is derived by the following derivation:
Figure BDA0001493735820000102
Figure BDA0001493735820000103
Figure BDA0001493735820000104
if the new transform coefficient block is an all-zero block, it is required to satisfy that all Q (x, y) are less than 1; at this time, the new transform coefficient block | Y (x, Y) | should satisfy the following formula,
Figure BDA0001493735820000105
wherein if factor is 1, let | Y (x, Y) & gtY<Th (x, y) is obtained
Figure BDA0001493735820000111
When the factor is 1, theoretically, no additional quantization loss is caused if the precision and rounding problem in quantization are not considered, that is, the quantized coefficient block after quantizationIs an all-zero block, but the coding speed is limited at this time; when factor>1, extra quantization loss is introduced, that is, all transform coefficients in a transform coefficient block corresponding to a non-all-zero block may be replaced by all-zero coefficients, thereby bringing quantization loss, but on the premise that the loss is tolerable, the encoding speed may be increased. The threshold factor multiplied by Th (x, y) is used to balance the loss and the acceleration. In general, the larger the factor, the larger the threshold, the greater the corresponding coding loss, and the greater the acceleration of the encoder. The factor can be adjusted according to the requirements of users.
The user can balance the quantization loss and the coding time according to the self requirement, and the size of the preset threshold value is set. Therefore, the preset threshold reduces the whole coding time and improves the coding rate on the premise of not losing the coding performance as much as possible.
The preset quantization information in the above formula includes: the method comprises the steps of presetting quantization parameters, presetting quantization step length and presetting quantization weight factors.
Generally, the above QS (Quantization Step) describes the size of the Quantization degree, and QS (qp) is (2)1/6)QP-4The Quantization step size can be quantitatively represented by QP (Quantization Parameter). The quantization may be divided into different levels according to different quantization steps, and the quantization parameter is generally divided into 52 levels, i.e., 0 to 51.
The range of the step length which can be selected by quantization is larger, the larger the step length is, the coarser the quantization result is, the more information is lost, and the higher the compression performance is. The user selects the step size in the step size range according to the self requirement, so that the encoder can control the code rate and the quality of the video stream more freely.
The quantization weight factor can set the weight according to the importance of different positions, and is generally set to 1, i.e. no weight is indicated.
The pixel bit depth information refers to the number of bits (bit) used per pixel. The pixel bit depth information may be 8 bits. Common video signals are 8 bits deep, while signals are required to be relatively High, such as HDR (High-Dynamic Range, High Dynamic illumination rendering image) video, which uses 10 bits and 12 bits.
The pixel bit depth determines the number of possible colors per pixel of the color image or determines the number of possible gray levels per pixel of the gray scale image. For example, each pixel of a color image is represented by R, G, B three components, and if each component is 8 bits, then a pixel shares a 24-bit representation, i.e., the pixel bit depth information is 24 bits, and each pixel may be 224I.e., 16777216, in one of tens of millions of colors. Thus, the pixel bit depth information may also be referred to as image depth. The more bits of a pixel that the pixel bit depth information indicates, the more colors can be expressed and the deeper the depth represented by the pixel. Generally, the deeper the pixel bit depth, the larger the amount of data, and the larger the required transmission bandwidth and storage space. Conversely, if the pixel bit depth is too shallow, the quality of the image is affected and the image appears to be rough and unnatural.
Step 203, judging whether the new transformation coefficient block is an all-zero block, if so, executing step 204, and if not, executing step 205;
in this step, it is determined whether all the transform coefficients in the new transform coefficient block are zero, and the transform coefficients in the new transform coefficient block may be determined whether the transform coefficients are zero in parallel in one row or one column, or the transform coefficients in the new transform coefficient block may be determined serially one by one, which is not limited herein. The parallel mode of judging whether the transformation coefficient in the new transformation coefficient block is zero is high in efficiency, and the serial mode of judging whether the transformation coefficient in the new transformation coefficient block is zero one by one is small in occupied operation memory.
Step 204, the number of the non-zero transform coefficients in the encoded video frame data block is 0, and the encoding of the video frame data block is finished.
In the embodiment of the present invention, when the new transform coefficient block is an all-zero block, the number of non-zero transform coefficients in the video frame data block is directly encoded to be 0, and the encoding of the video frame data block is finished without performing quantization and entropy encoding on the transform coefficient block corresponding to the new transform coefficient block before replacing the transform coefficient.
Step 205, the transform coefficient block is quantized to obtain a quantized quantization coefficient block.
In the embodiment of the invention, only when the new transform coefficient block is not an all-zero block, the corresponding transform coefficient block before the new transform coefficient block replaces the transform coefficient is quantized.
Specifically, in the embodiment of the present invention, the following formula may be used to calculate:
Figure BDA0001493735820000131
a block of quantized coefficients is obtained after quantization,
wherein Q (x, Y) represents a quantized block of quantized coefficients, x, Y of Q (x, Y) is the position of a coefficient in the block of quantized coefficients, x is the row of the block of quantized coefficients, Y is the column of the block of quantized coefficients, Y (x, Y) is a transform coefficient located at the position in the block of transform coefficients, where (x, Y) is the position of a transform coefficient in the block of transform coefficients, x is the row of the block of transform coefficients, Y is the column of the block of transform coefficients, sign (Y (x, Y)) represents the positive or negative value of a transform coefficient in the block of transform coefficients, sign (Y (x, y)) is { -1, 0,1 }. By using the formula, the quantization of the corresponding transform coefficient block before replacing the transform coefficient by the new transform coefficient block can be realized only when the new transform coefficient block is not an all-zero block, so as to improve the accuracy of quantization.
In a specific embodiment, the step 205 performs quantization processing on the transform coefficient block by using the following steps:
and carrying out quantization processing on the transformation coefficient block by utilizing preset quantization information and pixel bit depth information of the video frame data block to be coded.
To trade off visual quality and compression performance, quantization is employed. The quantization is performed by rounding a transform coefficient block after the spectral transform and scaling the transform coefficient block by a division method. Quantization causes transform coefficients in a transform coefficient block to lose part of the information. Therefore, on the premise of not reducing the visual effect of watching the video by the user, the loss of partial information can be allowed, and unnecessary information in the video watched by the user can be reduced.
And step 206, performing entropy coding according to the quantized coefficient block.
After the quantized coefficient block is obtained, entropy encoding can be performed according to the quantized coefficient block. After the entropy coding is completed, the video coding of the video frame data block to be coded is completed. The above entropy encoding includes: shannon (Shannon) coding, Huffman (Huffman) coding and arithmetic coding (arithmeticcoding). This is not an example.
Therefore, in the embodiment of the present invention, when a new transform coefficient block is an all-zero block, the corresponding transform coefficient block before replacing the transform coefficient with the new transform coefficient block is not quantized, and the number of non-zero transform coefficients in the video frame data block is directly encoded to be 0, so that the number of transform coefficient blocks subjected to entropy encoding is reduced, and the encoding speed is further improved.
Referring to fig. 3, a specific overall flow of the video encoding method according to the embodiment of the present invention includes the following steps:
step 301, obtaining each video frame data block to be encoded and other video information, where the other video information includes a coefficient value in the video frame data block, a coefficient value of a transform coefficient block, and preset quantization information.
Step 302, each transform coefficient in the transform coefficient block is compared with a preset threshold value respectively.
Step 303, judging whether all the transformation coefficients in the transformation coefficient block are smaller than a preset threshold value; if not, step 304 is performed, and if not, step 306 is performed.
And 304, performing quantization processing on the corresponding transform coefficient block before the new transform coefficient block replaces the transform coefficient to obtain a quantized quantization coefficient block.
In step 305, it is determined whether the quantized coefficient block is an all zero block. If yes, go to step 307; if there are still non-zero coefficients, step 308 is performed.
Step 306, replacing the transform coefficient smaller than the preset threshold value with 0, obtaining a new transform coefficient block, judging that the new transform coefficient block is an all-zero block, and then executing step 307.
Step 307, the number of non-zero transform coefficients in the encoded video frame data block is 0.
And 308, entropy coding the quantized coefficient block. Specifically, entropy coding is performed on the number of non-zero quantized coefficients and all quantized coefficients between a first non-zero quantized coefficient and a last non-zero quantized coefficient in the encoded data block.
In one embodiment, the step 308 includes:
determining a first position corresponding to a first non-zero quantized coefficient and a second position corresponding to a last non-zero quantized coefficient of each quantized coefficient block according to a preset sequence;
and entropy coding all quantized coefficients from a first non-zero quantized coefficient corresponding to a first position to a last non-zero quantized coefficient corresponding to a second position in each quantized coefficient block.
By applying the embodiment of the invention, the quantized coefficient block corresponding to the non-all-zero block can be subjected to entropy coding, and the coding performance loss is small.
Entropy encoding is performed on the quantized coefficient block corresponding to the non-all-zero block, and specific implementation examples are as follows:
for example, one: assuming that the 4x4 video frame data block has undergone the steps of prediction, transformation and quantization, obtaining a corresponding quantized coefficient block;
the quantized block of coefficients is a 4x4 block, and entropy coding is performed on the 4x4 block:
entropy encoding all quantized coefficients between each 4x4 block of data from a first non-zero quantized coefficient corresponding to a first position to a last non-zero quantized coefficient corresponding to a second position.
Example two: assuming that the 8x8 video frame data block has undergone the steps of prediction, transformation and quantization, obtaining a corresponding quantized coefficient block;
the quantized block of coefficients is an 8x8 block, and entropy coding is performed on the 8x8 block: first, the 8x8 data block may be divided into 4 data blocks of 4x4, and then the 4 data blocks of 4x4 are numbered according to a preset sequence, for example, the 4 data blocks of 4x4 are numbered as 01, 02, 03 and 04;
when the data blocks of 4x4 corresponding to numbers 02 and 04 are all zero blocks, the number of non-zero quantized coefficients in the quantized coefficient block is 0 for all quantized coefficients in the data block of 4x4 corresponding to numbers 02 and 04, and the encoding of the video frame data block is finished.
Judging that the data blocks with the numbers of 01 and 03 respectively corresponding to 4x4 are not all zero blocks, and searching a first position of a first non-zero quantized coefficient and a second position of a last non-zero quantized coefficient in the data block with the number of 01 corresponding to 4x 4;
searching a first position of a first non-zero quantized coefficient and a second position of a last non-zero quantized coefficient in a data block of 4x4 corresponding to the number 03;
all quantized coefficients between a 4x4 data block numbered 01 from a first non-zero quantized coefficient corresponding to a first position to a last non-zero quantized coefficient corresponding to a second position, an
And entropy coding all quantized coefficients between the first non-zero quantized coefficient corresponding to the first position and the last non-zero quantized coefficient corresponding to the second position of the data block of 4x4 corresponding to the number 03. The preset sequence is set according to industrial requirements.
For example, the above-mentioned implementation process can be implemented by a 16x16 video frame data block or a 32x32 video frame data block, and is not described herein again. Any method capable of entropy coding with quantized coefficient blocks falls within the scope of the embodiments of the present invention.
In other specific embodiments, entropy encoding is performed on the quantized coefficient block corresponding to the non-all-zero block, and specific implementation examples are as follows:
assuming that the 8x8 video frame data block has undergone the steps of prediction, transformation and quantization, obtaining a corresponding quantized coefficient block;
the quantized block of coefficients is an 8x8 block, and entropy coding is performed on the 8x8 block: first, the 8x8 data block may be divided into 4 data blocks of 4x4, and then the 4 data blocks of 4x4 are numbered according to a preset sequence, for example, the numbers of the 4 data blocks of 4x4 are 1, 2, 3, and 4, respectively;
when the data blocks numbered 1, 2, 3 and 4 and corresponding to 4x4 are not all zero blocks, assuming that the quantized coefficients of the data block numbered 2 and corresponding to 4x4 and the quantized coefficients of the data block numbered 3 and corresponding to 4x4 are all non-zero quantized coefficients, sequentially searching the data blocks numbered 1, 2, 3 and 4 and corresponding to 4x4, searching the first position of the first non-zero quantized coefficient in the data block numbered 1 and corresponding to 4x4, and searching the second position of the last non-zero quantized coefficient in the data block numbered 4 and corresponding to 4x 4;
all quantized coefficients from a first non-zero quantized coefficient corresponding to a first position in a 4x4 data block corresponding to the number 1, all quantized coefficients of a 4x4 data block corresponding to the number 2, all quantized coefficients of a 4x4 data block corresponding to the number 3, and a last non-zero quantized coefficient corresponding to a second position in a 4x4 data block corresponding to the number 4 are entropy-encoded. The preset sequence can be set according to industrial requirements.
Therefore, in the embodiment of the present invention, when a new transform coefficient block is an all-zero block, the corresponding transform coefficient block before replacing the transform coefficient with the new transform coefficient block is not quantized, and the number of non-zero transform coefficients in the video frame data block is directly encoded to be 0, so that the number of transform coefficient blocks subjected to entropy encoding is reduced, and the encoding speed is further improved.
By using the video coding method of the embodiment of the invention, the coding time of the video coder can be reduced, and the video coding method can be proved by experimental data.
Specific experimental data are shown in table 1 below, where the experimental data are obtained by performing an experiment on an encoder by using the video encoding method according to the embodiment of the present invention, and during the experiment, the threshold factor is set to 1.1. Table 1 below shows the comparison result between the conventional encoding method and the video encoding method using the embodiment of the present invention, and table 2 shows the average value of the comparison results obtained in table 1.
For the parameter Δ fps in tables 1 and 2, it can be obtained by the following formula.
Figure BDA0001493735820000171
Δ fps was determined.
Wherein Δ FPS represents FPSproposedAnd FPSanchorThe ratio of (a) to (b). The Δ fps can indicate whether the encoding speed of the encoder is accelerated. fps denotes the frame rate per second, i.e. the number of frames per second or the number of frames per second that the video can play. Wherein, FPSanchorRepresenting a frame rate FPS, FPS for encoding a video segment using an existing encoderproposedShows the FPS of the same encoder after the fast coding method based on the transformation coefficient of the embodiment of the invention is adopted, and the FPS in the table 1 and the table 2anchor、FPSproposedCorresponding positive values indicate acceleration, corresponding negative values indicate deceleration, and Δ fps greater than 100% indicates acceleration. The 100% indicates that the encoder uses the video encoding method of the embodiment of the present invention to obtain the same encoding frame rate as the encoder uses the existing video encoding method.
TABLE 1
Figure BDA0001493735820000172
Figure BDA0001493735820000181
The video segments in tables 1 and 2 are classA, classB, classC, classD, classE, 15fps, 30fps, 20fps, show, others, respectively. Wherein, class A, class B, class C, class D and class E are standard experimental video fragments. The video clips are customized for users by 15fps, 30fps, 20fps, show and others, namely, the video clips are intercepted according to the requirements of the users. The image or frame of the video signal corresponding to the video segment may be divided into blocks to be encoded, and the video encoding method according to the embodiment of the present invention is performed by using the divided blocks to be encoded.
Wherein, U and V are two chrominance signals respectively, Y is a luminance signal, YUV is a combined signal, and BD-rate represents performance. Wherein, when the value is negative, the code rate is reduced and the coding performance is improved under the condition of the peak Signal-to-Noise ratio (PSNR) which shows the same PSNR (Peak Signal to Noise ratio). The positive value is that the code rate increases and the coding performance decreases. The coding performance includes compression performance.
By using the video segment classA A, the coding performance of Y is reduced by 1.62%, the coding performance of U is improved by 0.14%, the coding performance of V is improved by 0.34%, the coding performance of YUV is reduced by 1.35%, and Δ fps is 111.91%, which indicates that the video segment has 11.91% of coding acceleration, wherein 11.91% is obtained by subtracting 100% from 111.91% corresponding to Δ fps. Thus, compared with the conventional video coding method, the video coding method of the embodiment of the invention improves the coding rate by 11.91 percent when the video segment classA is subjected to the video coding method of the embodiment of the invention.
TABLE 2
Figure BDA0001493735820000182
As can be seen from table 2, when the factor is set to 1.1, the video coding method according to the embodiment of the present invention has a coding performance that is reduced by 1.09%, improved by 0.42%, improved by 0.31%, and reduced by 0.86%, compared to the conventional video coding method, although the coding performance is improved by 0.09%, respectively, from Y, U, V, YUV corresponding to the BD-rate, and the coding performance is improved by 0.47%, which is known to have a certain effect, but the coding rate is improved by 10.471%, which is known to be about 10.47% obtained by subtracting 100% from 110.47% corresponding to Δ fps. Therefore, the video coding method of the embodiment of the invention accelerates the coding rate.
As shown in fig. 4, an embodiment of the present invention provides an encoder, including:
a first obtaining module 401, configured to obtain a transform coefficient block obtained for each video frame data block to be encoded;
a comparison and replacement module 402, configured to compare each transform coefficient in the transform coefficient block with a preset threshold, and replace a transform coefficient smaller than the preset threshold with 0 to obtain a new transform coefficient block;
a judging module 403, configured to judge whether the new transform coefficient block is an all-zero block;
a first encoding module 404, configured to, if the new transform coefficient block is an all-zero block, encode the number of non-zero transform coefficients in the video frame data block to be 0, and end encoding the video frame data block;
a second obtaining module 405, configured to perform quantization processing on the new transform coefficient block to obtain a quantized quantization coefficient block if the new transform coefficient block is not an all-zero block;
and a second encoding module 406, configured to perform entropy encoding according to the quantized coefficient block.
Therefore, in the embodiment of the present invention, when a new transform coefficient block is an all-zero block, the corresponding transform coefficient block before replacing the transform coefficient with the new transform coefficient block is not quantized, and the number of non-zero transform coefficients in the video frame data block is directly encoded to be 0, so that the number of transform coefficient blocks subjected to entropy encoding is reduced, and the encoding speed is further improved.
Optionally, the second encoding module is configured to specifically include:
the judging submodule is used for judging whether the quantized coefficient block is an all-zero block;
a first encoding sub-module, configured to, if it is determined that the quantized coefficient block is an all-zero block, encode that the number of non-zero quantized coefficients in the quantized coefficient block is 0, and end encoding of the video frame data block;
and the second coding sub-module is used for entropy coding the quantized coefficient block if the quantized coefficient block is judged not to be a full zero block.
Optionally, the first obtaining module includes:
the prediction submodule is used for predicting each video frame data block to be coded to obtain a residual block corresponding to the video frame data block;
and the obtaining submodule is used for carrying out frequency spectrum transformation on the residual block corresponding to the video frame data block to obtain the transformation coefficient block.
Optionally, the preset threshold is obtained by pre-calculating according to the following formula:
Figure BDA0001493735820000201
where Th (x, y) is a preset threshold corresponding to a transform coefficient in the transform coefficient block, where (x, y) in Th (x, y) is a position of the transform coefficient in the transform coefficient block, where, when the transform coefficient block is a two-dimensional matrix, x is a row of the position of the transform coefficient in the transform coefficient block, y is a column of the position of the transform coefficient in the transform coefficient block, QP is a preset quantization parameter, shift is a shift value, shift takes a value of 29-B-M, where B is pixel bit depth information of a video frame data block to be encoded, M is a size of a residual block corresponding to the video frame data block, the residual block is a residual block of N × N, and M is log2N, offset is an offset value
Figure BDA0001493735820000202
G={G0,G1,G2,G3,G4,G5}={2-4/6,2-3/6,2-2/6,2-1/6,20,21/6},f={f0,f1,f2,f3,f4,f5{26214,23302,20560,18396,16384,14564}, w (x, y) is a preset quantization weight factor, factor is a preset threshold factor, and the value range of the factor is [1, 1.5 ]]。
Optionally, the second obtaining module is specifically configured to perform quantization processing on the transform coefficient block by using preset quantization information and pixel bit depth information of the video frame data block to be encoded.
Optionally, the second obtaining module is specifically configured to calculate by the following formula:
Figure BDA0001493735820000203
a block of quantized coefficients is obtained after quantization,
wherein Q (x, Y) represents the quantized block of quantized coefficients, x, Y of Q (x, Y) is the position of a coefficient in the block of quantized coefficients, x is the row of the block of quantized coefficients, Y is the column of the block of quantized coefficients, Y (x, Y) is a transform coefficient located at the position in the block of transform coefficients, where (x, Y) is the position of a transform coefficient in the block of transform coefficients, x is the row of the block of transform coefficients, Y is the column of the block of transform coefficients, sign (Y (x, Y)) represents the positive or negative value of a transform coefficient in the block of transform coefficients, sign (Y (x, y)) is { -1, 0,1 }.
Optionally, the second encoding submodule is specifically configured to:
determining a first position corresponding to a first non-zero quantized coefficient and a second position corresponding to a last non-zero quantized coefficient of each quantized coefficient block according to a preset sequence;
and entropy coding all quantized coefficients of each quantized coefficient block from a first non-zero quantized coefficient corresponding to a first position to a last non-zero quantized coefficient corresponding to a second position.
Embodiments of the present invention can be applied to the encoder shown in fig. 5. For video conforming to the existing video coding standard, the video generated by coding can be directly decoded by a common player. The encoder may also implement the following functions: for each video frame data block of a block to be coded, selecting an optimal interframe coding type from various interframe coding types according to a rate distortion criterion to obtain motion information and coded reconstructed frame information, predicting the video frame data block by using the selected interframe coding type, obtaining a predicted value of the block to be coded by using the motion information and the coded reconstructed frame information, subtracting the predicted value and a pixel value of the block to be coded to obtain a residual value, sequentially transforming, quantizing, scanning and entropy coding the residual value, coding a code stream, and coding the motion information into the code stream to finish a coding process, wherein the interframe coding type comprises the following steps: forward encoding, backward encoding.
The encoder may further scan the quantized coefficients, select a scanning order according to a prediction and transformation manner, and convert two-dimensional quantized coefficients in the quantized coefficient block into a one-dimensional quantized coefficient sequence, where the scanned one-dimensional quantized coefficient sequence tends to be arranged from large to small, and the preset scanning order includes: the scanning device comprises a Z-shaped scanning mode, a horizontal scanning mode and a vertical scanning mode, wherein an optimal scanning mode is selected from the three scanning modes through a rate distortion optimization criterion; and sequentially inputting the one-dimensional quantization coefficient sequence into an entropy coder for coding, and coding the selection information of the scanning mode into a code stream to form a final code stream.
The encoder may undertake video compression and decompression and/or implement a video codec according to one or more standards or specifications, such as h.264mpeg-4(Moving picture experts Group), h.265 High Efficiency video coding or HEVC (High Efficiency video coding), among others. Embodiments of the invention are not limited to any particular video coding standard or specification.
An embodiment of the present invention provides an electronic device, as shown in fig. 6, including an encoder 61 and a machine-readable storage medium 62, where the machine-readable storage medium stores machine-executable instructions executable by the encoder, and the encoder is caused by the machine-executable instructions to: the method comprises the following steps:
acquiring a transformation coefficient block obtained for each video frame data block to be coded;
comparing each transformation coefficient in the transformation coefficient block with a preset threshold value respectively, and replacing the transformation coefficient smaller than the preset threshold value with 0 to obtain a new transformation coefficient block;
judging whether the new transformation coefficient block is an all-zero block;
if the new transform coefficient block is an all-zero block, the number of non-zero transform coefficients in the video frame data block is coded to be 0, and the coding of the video frame data block is finished;
if the new transformation coefficient block is not an all-zero block, carrying out quantization processing on the transformation coefficient block to obtain a quantized quantization coefficient block;
and performing entropy coding according to the quantized coefficient block.
Therefore, in the embodiment of the present invention, when a new transform coefficient block is an all-zero block, the corresponding transform coefficient block before replacing the transform coefficient with the new transform coefficient block is not quantized, and the number of non-zero transform coefficients in the video frame data block is directly encoded to be 0, so that the number of transform coefficient blocks subjected to entropy encoding is reduced, and the encoding speed is further improved.
An embodiment of the present invention further provides an electronic device, including a processor and a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions executable by the processor, and the processor is caused by the machine-executable instructions to: the method comprises the following steps:
acquiring a transformation coefficient block obtained for each video frame data block to be coded;
comparing each transformation coefficient in the transformation coefficient block with a preset threshold value respectively, and replacing the transformation coefficient smaller than the preset threshold value with 0 to obtain a new transformation coefficient block;
judging whether the new transformation coefficient block is an all-zero block;
if the new transform coefficient block is an all-zero block, the number of non-zero transform coefficients in the video frame data block is coded to be 0, and the coding of the video frame data block is finished;
if the new transformation coefficient block is not an all-zero block, carrying out quantization processing on the transformation coefficient block to obtain a quantized quantization coefficient block;
and performing entropy coding according to the quantized coefficient block.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
Therefore, in the embodiment of the present invention, when a new transform coefficient block is an all-zero block, the corresponding transform coefficient block before replacing the transform coefficient with the new transform coefficient block is not quantized, and the number of non-zero transform coefficients in the video frame data block is directly encoded to be 0, so that the number of transform coefficient blocks subjected to entropy encoding is reduced, and the encoding speed is further improved.
An embodiment of the present invention further provides an electronic device, as shown in fig. 7, including a processor 701, a communication interface 702, a memory 703 and a communication bus 704, where the processor 701, the communication interface 702, and the memory 703 complete mutual communication through the communication bus 704,
a memory 703 for storing a computer program;
the processor 701 is configured to implement the following steps when executing the program stored in the memory 703:
acquiring a transformation coefficient block obtained for each video frame data block to be coded;
comparing each transformation coefficient in the transformation coefficient block with a preset threshold value respectively, and replacing the transformation coefficient smaller than the preset threshold value with 0 to obtain a new transformation coefficient block;
judging whether the new transformation coefficient block is an all-zero block;
if the new transform coefficient block is an all-zero block, the number of non-zero transform coefficients in the video frame data block is coded to be 0, and the coding of the video frame data block is finished;
if the new transformation coefficient block is not an all-zero block, carrying out quantization processing on the transformation coefficient block to obtain a quantized quantization coefficient block;
and performing entropy coding according to the quantized coefficient block.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
The method provided by the embodiment of the invention can be applied to electronic equipment. Specifically, the electronic device may be: desktop computers, laptop computers, intelligent mobile terminals, servers, and the like. Without limitation, any electronic device that can implement the present invention is within the scope of the present invention.
Therefore, in the embodiment of the present invention, when a new transform coefficient block is an all-zero block, the corresponding transform coefficient block before replacing the transform coefficient with the new transform coefficient block is not quantized, and the number of non-zero transform coefficients in the video frame data block is directly encoded to be 0, so that the number of transform coefficient blocks subjected to entropy encoding is reduced, and the encoding speed is further improved.
An embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by a processor, the computer program implements the following steps: acquiring a transformation coefficient block obtained for each video frame data block to be coded;
comparing each transformation coefficient in the transformation coefficient block with a preset threshold value respectively, and replacing the transformation coefficient smaller than the preset threshold value with 0 to obtain a new transformation coefficient block;
judging whether the new transformation coefficient block is an all-zero block;
if the new transform coefficient block is an all-zero block, the number of non-zero transform coefficients in the video frame data block is coded to be 0, and the coding of the video frame data block is finished;
if the new transformation coefficient block is not an all-zero block, carrying out quantization processing on the transformation coefficient block to obtain a quantized quantization coefficient block;
and performing entropy coding according to the quantized coefficient block.
Therefore, in the embodiment of the present invention, when a new transform coefficient block is an all-zero block, the corresponding transform coefficient block before replacing the transform coefficient with the new transform coefficient block is not quantized, and the number of non-zero transform coefficients in the video frame data block is directly encoded to be 0, so that the number of transform coefficient blocks subjected to entropy encoding is reduced, and the encoding speed is further improved.
Embodiments of the present invention provide a computer program product comprising instructions which, when run on a computer, cause the computer to perform the steps of the video encoding method described above.
Embodiments of the present invention provide a computer program which, when run on a computer, causes the computer to perform the steps of implementing the video encoding method described above.
For the encoder/electronic device/storage medium/computer program product/computer program embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the encoder/electronic device/storage medium/computer program product/computer program embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and in relation to the description, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (16)

1. A video encoding method, comprising:
acquiring a transformation coefficient block obtained for each video frame data block to be coded;
comparing each transformation coefficient in the transformation coefficient block with a preset threshold respectively, replacing the transformation coefficient smaller than the preset threshold with 0 to obtain a new transformation coefficient block, wherein the preset threshold is a preset threshold corresponding to each transformation coefficient in the transformation coefficient block from the preset thresholds stored in advance for each transformation coefficient block;
judging whether the new transformation coefficient block is an all-zero block;
if the new transform coefficient block is an all-zero block, the number of non-zero transform coefficients in the video frame data block is coded to be 0, and the coding of the video frame data block is finished;
if the new transformation coefficient block is not an all-zero block, carrying out quantization processing on the transformation coefficient block to obtain a quantized quantization coefficient block;
and carrying out entropy coding according to the quantized quantization coefficient block.
2. The video coding method of claim 1, wherein entropy coding based on the quantized block of coefficients comprises:
judging whether the quantized coefficient block is an all-zero block;
if the quantized coefficient block is judged to be an all-zero block, the number of non-zero quantized coefficients in the quantized coefficient block is coded to be 0, and the coding of the video frame data block is finished;
and if the quantized coefficient block is judged not to be an all-zero block, entropy coding is carried out on the quantized coefficient block.
3. The video coding method according to claim 1 or 2, wherein the obtaining the transform coefficient block obtained for each block of video frame data to be coded comprises:
predicting each video frame data block to be coded to obtain a residual block corresponding to the video frame data block;
and carrying out frequency spectrum transformation on the residual block corresponding to the video frame data block to obtain the transformation coefficient block.
4. The video coding method of claim 3,
the preset threshold is obtained by pre-calculating according to the following formula:
Figure FDA0002480140330000021
and Th (x, y) is a preset threshold corresponding to a transform coefficient in the transform coefficient block, where (x, y) in Th (x, y) is a position of the transform coefficient in the transform coefficient block, when the transform coefficient block is a two-dimensional matrix, x is a row of the position of the transform coefficient in the transform coefficient block, y is a column of the position of the transform coefficient in the transform coefficient block, QP is a preset quantization parameter, shift is a shift value, shift takes a value of 29-B-M, where B is pixel bit depth information of a video frame data block to be encoded, M is a size of a residual block corresponding to the video frame data block, the residual block is a residual block of N × N, and M is log2N, offset is an offset value
Figure FDA0002480140330000022
G={G0,G1,G2,G3,G4,G5}={2-4/6,2-3/6,2-2/6,2-1/6,20,21/6},f={f0,f1,f2,f3,f4,f5{26214,23302,20560,18396,16384,14564}, w (x, y) is a preset quantization weight factor, factor is a preset threshold factor, and the value range of the factor is [1, 1.5 ]]。
5. The video encoding method of claim 4,
the quantizing the transform coefficient block includes:
and carrying out quantization processing on the transformation coefficient block by utilizing preset quantization information and pixel bit depth information of the video frame data block to be coded.
6. The video coding method of claim 5, wherein the calculation is performed by the following formula:
Figure FDA0002480140330000023
a block of quantized coefficients is obtained after quantization,
wherein Q (x, Y) represents the quantized block of quantized coefficients, x, Y of Q (x, Y) is the position of a coefficient in the block of quantized coefficients, x is the row of the block of quantized coefficients, Y is the column of the block of quantized coefficients, Y (x, Y) is a transform coefficient located at a position in the block of transform coefficients, where (x, Y) is the position of a transform coefficient in the block of transform coefficients, x is the row of the block of transform coefficients, Y is the column of the block of transform coefficients, sign (Y (x, Y)) represents the positive or negative value of a transform coefficient in the block of transform coefficients, the value set of sign (Y (x, Y)) is { -1, 0,1 }.
7. The video coding method of claim 2,
the entropy encoding of the quantized coefficient block includes:
determining a first position corresponding to a first non-zero quantized coefficient and a second position corresponding to a last non-zero quantized coefficient of each quantized coefficient block according to a preset sequence;
and entropy coding all quantized coefficients of each quantized coefficient block from a first non-zero quantized coefficient corresponding to a first position to a last non-zero quantized coefficient corresponding to a second position.
8. An encoder, comprising:
the first acquisition module is used for acquiring a transformation coefficient block obtained by aiming at each video frame data block to be coded;
the comparison and replacement module is used for comparing each transformation coefficient in the transformation coefficient block with a preset threshold respectively, replacing the transformation coefficient smaller than the preset threshold with 0, and obtaining a new transformation coefficient block, wherein the preset threshold is used for searching the preset threshold corresponding to each transformation coefficient in the transformation coefficient block from the preset threshold stored in advance for each transformation coefficient block;
the judging module is used for judging whether the new transformation coefficient block is an all-zero block;
a first encoding module, configured to, if the new transform coefficient block is an all-zero block, encode that the number of non-zero transform coefficients in the video frame data block is 0, and end encoding of the video frame data block;
the second acquisition module is used for carrying out quantization processing on the new transformation coefficient block to obtain a quantized quantization coefficient block if the new transformation coefficient block is not an all-zero block;
and the second coding module is used for carrying out entropy coding according to the quantized coefficient block.
9. The encoder according to claim 8, characterized in that the second encoding module is configured to include in particular:
the judging submodule is used for judging whether the quantized quantization coefficient block is an all-zero block;
the first coding submodule is used for coding the number of non-zero quantization coefficients in the quantized quantization coefficient block to be 0 if the quantized quantization coefficient block is judged to be a full-zero block, and ending the coding of the video frame data block;
and the second coding sub-module is used for entropy coding the quantized coefficient block if the quantized coefficient block is judged not to be a full zero block.
10. The encoder according to claim 8 or 9, wherein the first obtaining module comprises:
the prediction submodule is used for predicting each video frame data block to be coded to obtain a residual block corresponding to the video frame data block;
and the obtaining submodule is used for carrying out frequency spectrum transformation on the residual block corresponding to the video frame data block to obtain the transformation coefficient block.
11. The encoder according to claim 10, wherein the preset threshold is pre-calculated by the following formula:
Figure FDA0002480140330000041
and Th (x, y) is a preset threshold corresponding to a transform coefficient in the transform coefficient block, where (x, y) in Th (x, y) is a position of the transform coefficient in the transform coefficient block, when the transform coefficient block is a two-dimensional matrix, x is a row of the position of the transform coefficient in the transform coefficient block, y is a column of the position of the transform coefficient in the transform coefficient block, QP is a preset quantization parameter, shift is a shift value, shift takes a value of 29-B-M, where B is pixel bit depth information of a video frame data block to be encoded, M is a size of a residual block corresponding to the video frame data block, the residual block is a residual block of N × N, and M is log2N, offset is an offset value
Figure FDA0002480140330000051
G={G0,G1,G2,G3,G4,G5}={2-4/6,2-3/6,2-2/6,2-1/6,20,21/6},f={f0,f1,f2,f3,f4,f5{26214,23302,20560,18396,16384,14564}, w (x, y) is a preset quantization weight factor, factor is a preset threshold factor, and the value range of the factor is [1, 1.5 ]]。
12. The encoder of claim 11, wherein the second obtaining module is specifically configured to perform quantization processing on the transform coefficient block by using preset quantization information and pixel bit depth information of the video frame data block to be encoded.
13. The encoder according to claim 12, wherein the second obtaining module is specifically configured to calculate by the following formula:
Figure FDA0002480140330000052
a block of quantized coefficients is obtained after quantization,
wherein Q (x, Y) represents the quantized block of quantized coefficients, x, Y of Q (x, Y) is the position of a coefficient in the block of quantized coefficients, x is the row of the block of quantized coefficients, Y is the column of the block of quantized coefficients, Y (x, Y) is a transform coefficient located at a position in the block of transform coefficients, where (x, Y) is the position of a transform coefficient in the block of transform coefficients, x is the row of the block of transform coefficients, Y is the column of the block of transform coefficients, sign (Y (x, Y)) represents the positive or negative value of a transform coefficient in the block of transform coefficients, the value set of sign (Y (x, Y)) is { -1, 0,1 }.
14. The encoder according to claim 9,
the second encoding submodule is specifically configured to:
determining a first position corresponding to a first non-zero quantized coefficient and a second position corresponding to a last non-zero quantized coefficient of each quantized coefficient block according to a preset sequence;
and entropy coding all quantized coefficients of each quantized coefficient block from a first non-zero quantized coefficient corresponding to a first position to a last non-zero quantized coefficient corresponding to a second position.
15. An electronic device comprising a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to: carrying out the method steps of any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that a computer program is stored in the storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-7.
CN201711261657.3A 2017-12-04 2017-12-04 Video coding method, encoder, electronic device and medium Active CN109874012B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201711261657.3A CN109874012B (en) 2017-12-04 2017-12-04 Video coding method, encoder, electronic device and medium
PCT/CN2018/119146 WO2019109906A1 (en) 2017-12-04 2018-12-04 Video encoding method, encoder, electronic device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711261657.3A CN109874012B (en) 2017-12-04 2017-12-04 Video coding method, encoder, electronic device and medium

Publications (2)

Publication Number Publication Date
CN109874012A CN109874012A (en) 2019-06-11
CN109874012B true CN109874012B (en) 2020-09-11

Family

ID=66750052

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711261657.3A Active CN109874012B (en) 2017-12-04 2017-12-04 Video coding method, encoder, electronic device and medium

Country Status (2)

Country Link
CN (1) CN109874012B (en)
WO (1) WO2019109906A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111783512B (en) * 2019-11-11 2024-05-14 西安宇视信息科技有限公司 Image processing method, device, equipment and storage medium
CN113132731A (en) * 2019-12-31 2021-07-16 腾讯科技(深圳)有限公司 Video decoding method, device, equipment and storage medium
CN112543338B (en) * 2020-10-16 2022-03-04 腾讯科技(深圳)有限公司 Video decoding method and device, computer readable medium and electronic equipment
WO2022205297A1 (en) * 2021-04-01 2022-10-06 深圳市大疆创新科技有限公司 Data processing method and device, chip, unmanned aerial vehicle, and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101193304A (en) * 2007-09-14 2008-06-04 四川虹微技术有限公司 An implementation method for quick conversion and quantification of video coding
CN103098469A (en) * 2010-07-09 2013-05-08 三星电子株式会社 Method and apparatus for entropy encoding/decoding a transform coefficient
CN103220514A (en) * 2012-01-20 2013-07-24 索尼公司 Coefficient coding harmonization in HEVC
CN103796033A (en) * 2014-01-24 2014-05-14 同济大学 Efficient video coding zero-coefficient early detection method
WO2015038510A1 (en) * 2013-09-16 2015-03-19 Magnum Semiconductor, Inc. Apparatuses and methods for adjusting coefficients using dead zones
CN104469378A (en) * 2013-09-19 2015-03-25 黑莓有限公司 Coding position data for the last non-zero transform coefficient in a coefficient group
US9247257B1 (en) * 2011-11-30 2016-01-26 Google Inc. Segmentation based entropy encoding and decoding
CN105306956A (en) * 2015-11-13 2016-02-03 浙江工商大学 Method for increasing discrete cosine transform processing speed of HEVC coder

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1770863A (en) * 2004-11-02 2006-05-10 华为技术有限公司 Method for confirming zero block pre-determination condition and zero block pre-determination method
KR100773761B1 (en) * 2006-09-14 2007-11-09 한국전자통신연구원 The apparatus and method of moving picture encoding
CN101795404A (en) * 2009-10-21 2010-08-04 深圳市融创天下科技发展有限公司 Quantized step size based zero block threshold value determination method and zero block prejudging method
CN108777797B (en) * 2010-04-13 2021-01-29 Ge视频压缩有限责任公司 Device, method, storage medium and corresponding coding device for decoding a block of transform coefficients
US9264724B2 (en) * 2013-10-11 2016-02-16 Blackberry Limited Sign coding for blocks with transform skipped

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101193304A (en) * 2007-09-14 2008-06-04 四川虹微技术有限公司 An implementation method for quick conversion and quantification of video coding
CN103098469A (en) * 2010-07-09 2013-05-08 三星电子株式会社 Method and apparatus for entropy encoding/decoding a transform coefficient
US9247257B1 (en) * 2011-11-30 2016-01-26 Google Inc. Segmentation based entropy encoding and decoding
CN103220514A (en) * 2012-01-20 2013-07-24 索尼公司 Coefficient coding harmonization in HEVC
WO2015038510A1 (en) * 2013-09-16 2015-03-19 Magnum Semiconductor, Inc. Apparatuses and methods for adjusting coefficients using dead zones
CN104469378A (en) * 2013-09-19 2015-03-25 黑莓有限公司 Coding position data for the last non-zero transform coefficient in a coefficient group
CN103796033A (en) * 2014-01-24 2014-05-14 同济大学 Efficient video coding zero-coefficient early detection method
CN105306956A (en) * 2015-11-13 2016-02-03 浙江工商大学 Method for increasing discrete cosine transform processing speed of HEVC coder

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
An Adaptive and Low-Complexity All-zero Block Detection for HEVC Encoder;Jing Cui等;《2017 IEEE International Symposium on Circuits and Systems (ISCAS)》;20170528;第1-4页 *
An All-Zero Block Detection Scheme for Low-Complexity HEVC Encoders;Bumshik Lee等;《IEEE Transactions on Multimedia》;20160420;第18卷(第7期);第1257-1268页 *
An efficient all zero block detection algorithm based on frequency characteristics of DCT in HEVC;Henglu Wei等;《2015 VISUAL COMMUNICATIONS AND IMAGE PROCESSING (VCIP)》;20151213;第1页第I节第2段、第2页第II-A节 *
Henglu Wei等.An efficient all zero block detection algorithm based on frequency characteristics of DCT in HEVC.《2015 VISUAL COMMUNICATIONS AND IMAGE PROCESSING (VCIP)》.2015,1-4. *
Hybrid Zero Block Detection for High Efficiency Video Coding;Hongfei Fan等;《IEEE Transactions on Multimedia》;20160106;第8卷(第3期);第537-543页 *

Also Published As

Publication number Publication date
CN109874012A (en) 2019-06-11
WO2019109906A1 (en) 2019-06-13

Similar Documents

Publication Publication Date Title
US9215463B2 (en) Image encoding/decoding method and device
CN109874012B (en) Video coding method, encoder, electronic device and medium
TWI516095B (en) Video encoding and decoding using transforms
CN100581252C (en) Method for improving entropy coding
JP5989839B2 (en) Video decoding device
KR101320611B1 (en) A method and apparatus for encoding/decoding of N bit video data with quantization parameter extension
TW201540049A (en) Data encoding and decoding
CN1695381A (en) Sharpness enhancement in post-processing of digital video signals using coding information and local spatial features
KR101973571B1 (en) Methods and apparatus for video transform encoding/decoding
Naccari et al. Intensity dependent spatial quantization with application in HEVC
CN116982262A (en) State transition for dependent quantization in video coding
CN107343199B (en) Rapid adaptive compensation method for sampling points in HEVC (high efficiency video coding)
JP3359086B2 (en) Code amount control apparatus and method
JP2022183942A (en) Encoder and program
JP2015186252A (en) Encoding method conversion device and program
CN117979006A (en) Low-illumination live video real-time transcoding enhancement bright structure quantization method
CN112422964A (en) Progressive coding method and device
Ethiraj et al. Hierarchical Prediction and Context Adaptive Coding for Lossless Color Image Compression
JPH10224791A (en) Adaptive quantization system for orthogonal transformation

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