Video encoding method and device, electronic equipment and storage medium
By mapping and adjusting the parity of non-zero coefficients in the quantization coefficient block, the low efficiency problem caused by the transformation of the kernel index and writing to the bitstream in video coding of the LFNST algorithm is solved, thus improving the efficiency of video coding.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-20
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, the LFNST algorithm requires writing the transform kernel index into the bitstream during video encoding, resulting in low video encoding efficiency.
The transform kernel index of the coding block is determined by mapping the parity of the number of non-zero coefficients in the quantization coefficient block. The number of non-zero coefficients is adjusted to match the actual transform kernel index, thus hiding the transform kernel index in the bitstream and representing it only through parity.
This effectively saves the bitrate required to represent the LFNST transform kernel index, thus improving video coding efficiency.
Smart Images

Figure CN116233428B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a video encoding method, apparatus, electronic device and storage medium. Background Technology
[0002] The LFNST (Low-frequency non-separable transform) algorithm is a primary algorithm in the VVC (Versatile Video Coding) coding standard used to perform a secondary transform on transform blocks that select the intra-prediction mode, in order to further reduce the coefficient redundancy of the transform blocks.
[0003] When the LFNST algorithm is used for low-frequency non-separable secondary transformation in the coding unit (CU), related technologies often need to write the transform kernel index of LFNST into the bitstream, which cannot save the bitrate required to represent the transform kernel index, and also makes the video coding efficiency of related technologies low. Summary of the Invention
[0004] This disclosure provides a video encoding method, apparatus, electronic device, and storage medium to at least solve the problem of low video encoding efficiency in related technologies. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of the present disclosure, a video encoding method is provided, comprising:
[0006] Obtain coded blocks in video image frames and determine at least one quantization coefficient block in the coded blocks;
[0007] The parity of the number of non-zero coefficients in the quantized coefficient block is mapped to the transform kernel index of the coding block to obtain the current transform kernel index; the transform kernel index is used to characterize the selection state of the coefficient transform kernel for the coding block; the coefficient transform kernel is used to perform a low-frequency inseparable quadratic transform on the coefficients in the coding block;
[0008] If the current transform kernel index differs from the actual transform kernel index of the coding block, the number of non-zero coefficients in the quantization coefficient block is adjusted to obtain an adjusted quantization coefficient block; the parity of the number of non-zero coefficients in the adjusted quantization coefficient block is used to represent the actual transform kernel index.
[0009] Based on the adjusted quantization coefficient block, video encoded data of the video to which the video image frame belongs is generated.
[0010] In one possible implementation, after the steps of acquiring the coded blocks in the video image frame and determining at least one quantization coefficient block in the coded blocks, the method further includes: determining the first non-zero coefficient and the last non-zero coefficient in the quantization coefficient block according to a zigzag scanning order, and determining the position information of the first non-zero coefficient and the position information of the last non-zero coefficient; if the difference between the position information of the last non-zero coefficient and the position information of the first non-zero coefficient satisfies a preset difference condition, determining the quantization coefficient block as a usable coefficient block; if the number of usable coefficient blocks satisfies a preset number condition, performing the step of mapping the parity of the number of non-zero coefficients in the quantization coefficient block to the coefficient transformation kernel index of the coded block.
[0011] In one possible implementation, there are multiple quantization coefficients between the first non-zero coefficient and the last non-zero coefficient. If there is a zero coefficient among the multiple quantization coefficients, adjusting the number of non-zero coefficients in the quantization coefficient block to obtain an adjusted quantization coefficient block includes: determining one of the zero coefficients among the multiple quantization coefficients as a target quantization coefficient; adjusting the target quantization coefficient to a non-zero coefficient to obtain an adjusted quantization coefficient; and determining the adjusted quantization coefficient block based on the adjusted quantization coefficient.
[0012] In one possible implementation, determining one of the zero coefficients among the plurality of quantization coefficients as the target quantization coefficient includes: in the zigzag scanning sequence, determining the next quantization coefficient after the first non-zero coefficient in the scanning sequence as the current quantization coefficient among the plurality of quantization coefficients; obtaining the coefficient value of the current quantization coefficient; if the coefficient value of the current quantization coefficient is not equal to 0, in the zigzag scanning sequence, re-determining the next quantization coefficient after the current quantization coefficient in the scanning sequence as the current quantization coefficient, and returning to the step of obtaining the coefficient value of the current quantization coefficient, until the coefficient value of the current quantization coefficient is equal to 0; and determining the current quantization coefficient with a coefficient value equal to 0 as the target quantization coefficient.
[0013] In one possible implementation, adjusting the target quantization coefficient to a non-zero coefficient to obtain the adjusted quantization coefficient includes: obtaining the pre-quantization coefficient corresponding to the target quantization coefficient; and adjusting the target quantization coefficient from zero to a non-zero coefficient based on the coefficient value of the pre-quantization coefficient to obtain the adjusted quantization coefficient.
[0014] In one possible implementation, adjusting the target quantization coefficient from zero to a non-zero coefficient based on the coefficient value of the coefficient before quantization to obtain the adjusted quantization coefficient includes: setting the coefficient value of the target quantization coefficient to 1 when the coefficient value of the coefficient before quantization is greater than or equal to 0, to obtain the adjusted quantization coefficient; or setting the coefficient value of the target quantization coefficient to -1 when the coefficient value of the coefficient before quantization is less than 0, to obtain the adjusted quantization coefficient.
[0015] In one possible implementation, where no zero coefficients exist among the plurality of quantization coefficients, adjusting the number of non-zero coefficients in the quantization coefficient block to obtain an adjusted quantization coefficient block includes: in the zigzag scanning sequence, determining the next quantization coefficient after the first non-zero coefficient in the scanning sequence as the target quantization coefficient among the plurality of quantization coefficients; setting the coefficient value of the target quantization coefficient to 0 to obtain the adjusted quantization coefficient; and determining the adjusted quantization coefficient block based on the adjusted quantization coefficient.
[0016] According to a second aspect of the present disclosure, a video encoding apparatus is provided, comprising:
[0017] The acquisition unit is configured to acquire coded blocks in a video image frame and determine at least one quantization coefficient block in the coded blocks.
[0018] The mapping unit is configured to perform a transformation kernel index that maps the parity of the number of non-zero coefficients in the quantized coefficient block to the transform kernel index of the coding block, thereby obtaining the current transform kernel index; the transform kernel index is used to characterize the selection state of the coefficient transform kernel for the coding block; the coefficient transform kernel is used to perform a low-frequency inseparable quadratic transform on the coefficients in the coding block;
[0019] The adjustment unit is configured to adjust the number of non-zero coefficients in the quantization coefficient block when the current transform kernel index is different from the actual transform kernel index of the coding block, to obtain an adjusted quantization coefficient block; the parity of the number of non-zero coefficients in the adjusted quantization coefficient block is used to represent the actual transform kernel index.
[0020] The generation unit is configured to generate video encoded data of the video to which the video image frame belongs, based on the adjusted quantization coefficient block.
[0021] In one possible implementation, the apparatus is further configured to perform the following steps: determining the first and last non-zero coefficients in the quantization coefficient block in a zigzag scanning order, and determining the position information of the first and last non-zero coefficients; if the difference between the position information of the last non-zero coefficient and the position information of the first non-zero coefficient satisfies a preset difference condition, determining the quantization coefficient block as a usable coefficient block; and if the number of usable coefficient blocks satisfies a preset quantity condition, performing the step of mapping the parity of the number of non-zero coefficients in the quantization coefficient block to the coefficient transformation kernel index of the coding block.
[0022] In one possible implementation, there are multiple quantization coefficients between the first non-zero coefficient and the last non-zero coefficient. If there is a zero coefficient among the multiple quantization coefficients, the adjustment unit is configured to perform the following: determine one of the zero coefficients among the multiple quantization coefficients as a target quantization coefficient; adjust the target quantization coefficient to a non-zero coefficient to obtain an adjusted quantization coefficient; and determine the adjusted quantization coefficient block based on the adjusted quantization coefficient.
[0023] In one possible implementation, the adjustment unit is configured to, in the zigzag scanning sequence, determine the next quantization coefficient following the first non-zero coefficient as the current quantization coefficient among the plurality of quantization coefficients; obtain the coefficient value of the current quantization coefficient; if the coefficient value of the current quantization coefficient is not equal to 0, in the zigzag scanning sequence, re-determine the next quantization coefficient following the current quantization coefficient as the current quantization coefficient, and return to the step of obtaining the coefficient value of the current quantization coefficient, until the coefficient value of the current quantization coefficient is equal to 0; and determine the current quantization coefficient with a coefficient value equal to 0 as the target quantization coefficient.
[0024] In one possible implementation, the adjustment unit is configured to perform the following: obtain the pre-quantization coefficient corresponding to the target quantization coefficient; adjust the target quantization coefficient from zero to a non-zero coefficient based on the coefficient value of the pre-quantization coefficient to obtain the adjusted quantization coefficient.
[0025] In one possible implementation, the adjustment unit is configured to, when the coefficient value of the pre-quantization coefficient is greater than or equal to 0, set the coefficient value of the target quantization coefficient to 1 to obtain the adjusted quantization coefficient; or, when the coefficient value of the pre-quantization coefficient is less than 0, set the coefficient value of the target quantization coefficient to -1 to obtain the adjusted quantization coefficient.
[0026] In one possible implementation, where no zero coefficient exists among the plurality of quantization coefficients, the adjustment unit is configured to, in the zigzag scanning sequence, determine the next quantization coefficient following the first non-zero coefficient as the target quantization coefficient among the plurality of quantization coefficients; set the coefficient value of the target quantization coefficient to 0 to obtain the adjusted quantization coefficient; and determine the adjusted quantization coefficient block based on the adjusted quantization coefficient.
[0027] According to a third aspect of the present disclosure, an electronic device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the video encoding method as described in the first aspect or any possible implementation thereof.
[0028] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the video encoding method as described in the first aspect or any possible implementation thereof.
[0029] According to a fifth aspect of the present disclosure, a computer program product is provided, the program product including a computer program stored in a readable storage medium, wherein at least one processor of a device reads from the readable storage medium and executes the computer program, causing the device to perform the video encoding method described in the first aspect or any possible implementation thereof.
[0030] The technical solutions provided by the embodiments of this disclosure bring at least the following beneficial effects: by acquiring the coding block in the video image frame, at least one quantization coefficient block in the coding block is determined; the parity of the number of non-zero coefficients in the quantization coefficient block is mapped to the transform kernel index of the coding block to obtain the current transform kernel index; the transform kernel index is used to characterize the selection state of the coefficient transform kernel for the coding block; the coefficient transform kernel is used to perform a low-frequency inseparable quadratic transform on the coefficients in the coding block; when the current transform kernel index is different from the actual transform kernel index of the coding block, the number of non-zero coefficients in the quantization coefficient block is adjusted to obtain the adjusted quantization coefficient block; the adjusted quantization coefficient block... The parity of the number of non-zero coefficients in the quantization coefficient block is used to represent the actual transform kernel index. Based on the adjusted quantization coefficient block, video coding data of the video to which the video image frame belongs is generated. Thus, when the coding block uses the LFNST algorithm for low-frequency non-separable quadratic transform, the LFNST transform kernel index is represented by the parity of the number of non-zero coefficients in the quantization coefficient block. This hides the transform kernel index for the coding block during the video coding process, eliminating the need to write the LFNST transform kernel index into the bitstream. This effectively saves the bitrate required to represent the LFNST transform kernel index and improves video coding efficiency.
[0031] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0032] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0033] Figure 1 This is an application environment diagram illustrating a video coding method according to an exemplary embodiment.
[0034] Figure 2 This is a flowchart illustrating a video encoding method according to an exemplary embodiment.
[0035] Figure 3 This is a schematic diagram illustrating a transform block partitioning according to an exemplary embodiment.
[0036] Figure 4 This is a schematic diagram illustrating the encoding order of a quantization coefficient block according to an exemplary embodiment.
[0037] Figure 5 This is a flowchart illustrating another video encoding method according to an exemplary embodiment.
[0038] Figure 6 This is a block diagram illustrating a video encoding apparatus according to an exemplary embodiment.
[0039] Figure 7 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation
[0040] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0041] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure.
[0042] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0043] The video encoding method provided in this disclosure can be applied to, for example... Figure 1 In the application environment shown, terminal 102 and another electronic device 106 communicate with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated on server 104 or placed on a cloud or other network server. Specifically, electronic device 102 acquires the coded blocks in a video image frame and determines at least one quantization coefficient block within the coded block; electronic device 102 maps the parity of the number of non-zero coefficients in the quantization coefficient block to the transform kernel index of the coded block, obtaining the current transform kernel index; the transform kernel index is used to characterize the selection state of the coefficient transform kernel for the coded block; the coefficient transform kernel is used to perform a low-frequency, non-separable quadratic transform on the coefficients in the coded block; if the current transform kernel index differs from the actual transform kernel index of the coded block, electronic device 102 adjusts the number of non-zero coefficients in the quantization coefficient block to obtain an adjusted quantization coefficient block; the parity of the number of non-zero coefficients in the adjusted quantization coefficient block is used to represent the actual transform kernel index; based on the adjusted quantization coefficient block, electronic device 102 generates the video encoded data of the video to which the video image frame belongs. Electronic device 102 can transmit video encoded data to server 104. Server 104 can transmit the video encoded data to another electronic device 104, which can decode the video encoded data to recover the video data and display the recovered video data on an accessible display device. In practical applications, electronic device 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0044] Figure 2 This is a flowchart illustrating a video encoding method according to an exemplary embodiment, such as... Figure 2 As shown, this video encoding method is used in electronic devices and includes the following steps.
[0045] In step S202, the coded blocks in the video image frame are obtained, and at least one quantization coefficient block in the coded blocks is determined.
[0046] In practical implementation, taking the VVC standard as an example, after a video frame image is input, the electronic device divides the video frame image into several non-overlapping processing units according to a block size. Each processing unit performs a similar compression operation. This processing unit is called a CTU (Coding Tree Unit), or LCU. The CTU can be further divided into more refined parts to obtain one or more basic coding blocks (CUs, Coding Units). The CU is the most basic element in a coding process.
[0047] After the electronic device obtains the coded block in the video image frame, it can use the quantization module of the VVC standard to quantize the coefficients of the coded block to obtain at least one quantized coefficient block in the coded block, which is used to write the quantized coefficients into the bitstream.
[0048] It's important to note that the VVC standard doesn't write the quantized coefficients within a Transform Unit (TU) into the bitstream one by one from left to right and top to bottom. Instead, it first divides the TU into multiple 4x4 quantized coefficient blocks (CGs, Coefficient Coding Groups); secondly, it determines the first and last CGs containing non-zero coefficients; and finally, it encodes each CG from right to left and from back to front. For example... Figure 3 As shown in the figure, 310 represents TU, 320 represents CG, 330 represents the first CG containing a non-zero coefficient, and 340 represents the last CG containing a non-zero coefficient.
[0049] In step S204, the parity of the number of non-zero coefficients in the quantization coefficient block is mapped to the transform kernel index of the coding block to obtain the current transform kernel index.
[0050] The coefficient transform kernel is used to perform a low-frequency inseparable quadratic transform on the coefficients in the coded block. For ease of understanding by those skilled in the art, the algorithm for the low-frequency inseparable quadratic transform is briefly explained below:
[0051] The Low Frequency Inseparable Quadratic Transform (TU) algorithm is a tool in the transform module of the VVC standard. Its function is to use a coefficient transform kernel (LFNST transform kernel) to perform a quadratic transform on the coefficients of the transform block, transforming the spatial information of the TU into the frequency domain, thereby further removing the frequency domain redundancy between the transform coefficients of the TU block and thus improving coding performance.
[0052] It should be noted that in the VVC coding standard, the concepts of CU and TU are not strictly emphasized; CU and TU are exactly the same size. In the intra-frame / inter-frame prediction module, it is called CU, and after the prediction module, in the transform module, it is called TU; therefore, a CU and its TU are exactly the same size.
[0053] In practical applications, the low-frequency non-separable quadratic transform algorithm has 4 transform sets, each with 2 transform kernels, and the transform sets correspond one-to-one with the intra-frame prediction modes.
[0054] Since each transform set has two transform kernels, if a low-frequency non-separable secondary transform algorithm is used, each CU block needs to select a suitable coefficient transform kernel in the encoder through rate-distortion optimization. Taking the intra-prediction CU with IntraPredMode=60 (an intra-frame angle prediction mode in VVC) as an example, this CU needs to calculate the rate-distortion cost three times. The first is the rate-distortion cost cost0 without using the LFNST transform kernel for secondary transform. The second and third are the rate-distortion costs cost1 and cost2 derived from using the first and second transform kernels of the first LFNST transform set for secondary transform, respectively. Then, the selection is made based on the relationship between the three rate-distortion costs: if cost0 = min(cost0, cost1, cost2), the current CU block does not use LFNST for secondary transform; if cost1 = min(cost0, cost1, cost2), the current CU block selects the first LFNST transform kernel for transform, and so on for other cases.
[0055] It should be noted that the low-frequency non-separable quadratic transform algorithm is applied to the luma component. Since the low-frequency non-separable quadratic transform algorithm needs to determine the transform set based on the intra-frame prediction angle, the low-frequency non-separable quadratic transform algorithm is only applied to the intra-frame prediction CU of the luma component of VVC. The intra-frame prediction CU of chroma and the inter-frame prediction CU do not use the low-frequency non-separable quadratic transform algorithm.
[0056] The LFNST transform kernel index is used to characterize the selection status of the coefficient transform kernel for the coding block.
[0057] In the VVC coding standard, the LFNST algorithm uses truncated unary codes for encoding, as shown in Table 1:
[0058] Table 1 LFNST Transform Kernel Index Encoding Method
[0059] LFNST Transform Kernel Index Idx0 Idx1 Off 0 <![CDATA[1 st Kernel]]> 1 0 <![CDATA[2 nd Kernel]]> 1 1
[0060] Each intra-frame predicted CU will have three corresponding LFNST selection states: off / 1st Kernel / 2 nd Kernal corresponds to three states: not using LFNST for the second transformation, using the first transformation kernel for the second transformation, and using the second transformation kernel for the second transformation.
[0061] If the current CU does not use the LFNST algorithm for low-frequency non-separable quadratic transform, then only a 0 needs to be written to the bitstream; otherwise, a 1 needs to be written first, and then the decision of whether to write 0 or 1 to the bitstream depends on which transform core the current CU has selected. For example, assuming the current CU does not use the LFNST algorithm for low-frequency non-separable quadratic transform, the actual transform core index of this CU can be "0"; as another example, assuming the current CU selects the second transform core (i.e., 2... nd If a low-frequency inseparable quadratic transform is performed on the kernel, then the actual transform kernel index of the CU can be "11".
[0062] In specific implementation, for at least one quantization coefficient block in the coding block, the electronic device can determine the number of non-zero coefficients (nzSum, nozero Sum) in that quantization coefficient block. The electronic device can then map the parity of the number of non-zero coefficients in the quantization coefficient block to the transform kernel index of that coding block according to a preset correspondence table (i.e., the correspondence table between the number of non-zero coefficients nzSum and the LFNST index value), thereby obtaining the current transform kernel index.
[0063] This disclosure provides, as an example, a table showing the correspondence between the number of non-zero coefficients nzSum and the LFNST index value, as shown in Table 2:
[0064] Table 2. Correspondence between the number of non-zero coefficients (nzSum) and LFNST index values.
[0065] nzSum parity LFNST index value nzSum is an even number (nzSum%2=0) 0 nzSum is an odd number (nzSum%2=1) 1
[0066] As shown in Table 2, when nzSum is odd, it corresponds to the case where the LFNST index value is 1; otherwise, it corresponds to the case where the LFNST index value is 0.
[0067] For example, suppose the electronic device determines that the number of non-zero coefficients in the first quantization block of the coding block is 5 and the number of non-zero coefficients in the second quantization block is 6. It can be seen that the number of non-zero coefficients in the first quantization block is odd and the number of non-zero coefficients in the second quantization block is even. At this time, the electronic device can determine that the number of non-zero coefficients corresponding to the coding block is nzSum, which currently indicates that the current transform kernel index of the coding block is "10".
[0068] For example, suppose the electronic device determines that the number of non-zero coefficients in the first quantization coefficient block in the coding block is 6. It can be seen that the number of non-zero coefficients in the first quantization coefficient block is even. At this time, the electronic device can determine that the number of non-zero coefficients corresponding to the coding block is nzSum. This means that the current transform kernel index of the coding block is "0", that is, the coding block does not use the LFNST transform kernel.
[0069] It should be noted that, as shown in Table 1, when the LFNST transform core is not used in the coding block, the transform core index of the coding block has only one bit. In other words, the electronic device does not need to represent the index value of the second sign bit in the transform core index with the number of non-zero coefficients of the first quantization coefficient block.
[0070] In step S206, if the current transform kernel index is different from the actual transform kernel index of the coding block, the number of non-zero coefficients in the quantization coefficient block is adjusted to obtain the adjusted quantization coefficient block.
[0071] The parity of the number of non-zero coefficients in the adjusted quantization coefficient block is used to represent the actual transform kernel index.
[0072] In specific implementation, the electronic device can obtain the actual transform kernel index of the coding block and determine whether the actual transform kernel index is the same as the current transform kernel index. If the current transform kernel index is the same as the actual transform kernel index of the coding block, it means that the number of non-zero coefficients nzSum corresponding to the coding block can correctly represent the actual transform kernel index of the coding block. In other words, the parity of the number of non-zero coefficients in the quantization coefficient block can be used to represent the LFNST transform kernel index, thereby hiding the transform kernel index of the coding block without having to write the LFNST transform kernel index separately into the bitstream.
[0073] If the current transform kernel index differs from the actual transform kernel index of the coding block, it indicates that the number of non-zero coefficients nzSum corresponding to the coding block cannot correctly represent the actual transform kernel index of the coding block. In other words, the electronic device determines that the number of non-zero coefficients corresponding to the coding block does not meet the condition for hiding the actual transform kernel index of the coding block; the electronic device then adjusts the number of non-zero coefficients in the quantization coefficient block until the parity of the number of non-zero coefficients can correctly represent the actual transform kernel index of the coding block, thus obtaining the adjusted quantization coefficient block.
[0074] Continuing with the previous example, the electronic device determines that the number of non-zero coefficients corresponding to the coding block, nzSum, currently represents the current transform kernel index of the coding block as "10". The electronic device obtains the actual transform kernel index of the coding block as "11". It can be seen that at this time, the number of non-zero coefficients corresponding to the coding block, nzSum, cannot correctly represent the actual transform kernel index of the coding block. The electronic device then adjusts the number of non-zero coefficients corresponding to the coding block.
[0075] It can also be seen that the number of non-zero coefficients corresponding to the coding block, nzSum, cannot correctly represent the index value of the second sign bit in the actual transform kernel index. At this time, the electronic device can adjust the number of non-zero coefficients of the second quantization coefficient block in the coding block from an even number of 6 to an odd number of 5 to obtain an adjusted quantization coefficient block, so that the number of non-zero coefficients of the adjusted quantization coefficient block can correctly represent the index value "1" of the second sign bit in the actual transform kernel index of the coding block.
[0076] It should be noted that the following text will further explain the steps for adjusting the number of non-zero coefficients in the quantization coefficient block of the electronic device to obtain the adjusted quantization coefficient block, which will not be elaborated on here.
[0077] In step S208, video encoded data of the video to which the video image frame belongs is generated based on the adjusted quantization coefficient block.
[0078] In practice, electronic devices can write the coefficients in the adjusted quantization coefficient block into the bitstream, thereby generating the video encoded data of the video to which the video image frame belongs.
[0079] The aforementioned video coding method involves obtaining coding blocks from video image frames and determining at least one quantization coefficient block within those blocks. The parity of the number of non-zero coefficients in the quantization coefficient block is then mapped to the transform kernel index of the coding block, yielding the current transform kernel index. The transform kernel index characterizes the selection status of the coefficient transform kernel for the coding block. The coefficient transform kernel performs a low-frequency, non-separable quadratic transform on the coefficients in the coding block. If the current transform kernel index differs from the actual transform kernel index of the coding block, the number of non-zero coefficients in the quantization coefficient block is adjusted to obtain the adjusted quantization coefficient block. The adjusted quantization coefficient block contains non-zero coefficients... The parity of the number of zero coefficients is used to represent the actual transform kernel index. Based on the adjusted quantization coefficient block, video coding data of the video to which the video image frame belongs is generated. Thus, when the coding block uses the LFNST algorithm for low-frequency non-separable quadratic transform, the parity of the number of non-zero coefficients in the quantization coefficient block is used to represent the LFNST transform kernel index. This hides the transform kernel index for the coding block during the video coding process, eliminating the need to write the LFNST transform kernel index into the bitstream. This effectively saves the bitrate required to represent the LFNST transform kernel index and improves video coding efficiency.
[0080] In an exemplary embodiment, after acquiring a coding block in a video image frame and determining at least one quantization coefficient block in the coding block, the method further includes: determining a first non-zero coefficient and a last non-zero coefficient in the quantization coefficient block according to a zigzag scanning order, and determining the position information of the first non-zero coefficient and the position information of the last non-zero coefficient; determining the quantization coefficient block as a usable coefficient block if the difference between the position information of the last non-zero coefficient and the position information of the first non-zero coefficient satisfies a preset difference condition; and performing a step of mapping the parity of the number of non-zero coefficients in the quantization coefficient block to the coefficient transform kernel index of the coding block if the number of usable coefficient blocks satisfies a preset quantity condition.
[0081] In specific implementation, after the electronic device divides the encoding block into multiple 4x4 quantization coefficient blocks, the electronic device can encode the coefficients within each non-zero CG block according to the zig-zag scanning order. For ease of understanding by those skilled in the art, Figure 4 An example diagram illustrating the encoding order of a quantization coefficient block is shown; please refer to [link / reference]. Figure 4 The electronic device can scan at least one quantization coefficient block in a zigzag scanning sequence to determine the position information firstNZPos of the first non-zero coefficient "3" and the position information lastNZPos of the last non-zero coefficient "1". If the difference between the position information of the last non-zero coefficient and the position information of the first non-zero coefficient meets the preset difference condition, the quantization coefficient block is determined to be a usable coefficient block.
[0082] In practical applications, the preset gap condition can be expressed as "lastNZPos – firstNZPos ≥ 4"; since a CG (i.e., a usable coefficient block) that conforms to the above method can only hide one LFNST index value, therefore for the 1 shown in Table 1... st Kernel / 2 nd In the case of Kernal, two available coefficient blocks are required to completely hide the index value of LFNST in this case.
[0083] Specifically, when the electronic device determines that the number of available coefficient blocks is greater than or equal to 1, it can perform the above-mentioned step of mapping the parity of the number of non-zero coefficients in the quantized coefficient block to the coefficient transform kernel index of the coding block, thereby hiding at least one index value in the transform kernel index of the coding block and achieving the effect of saving code rate.
[0084] Furthermore, when the electronic device determines that there is only one available coefficient block for the CU in the current frame, and selects 2... ndIn the case of Kernal, the electronic device needs to write the index values that were not hidden in the transform kernel index of the coded block into the bitstream. The same applies to other cases, which will not be elaborated here.
[0085] The technical solution of this embodiment determines the first and last non-zero coefficients in the quantization coefficient block according to the zigzag scanning order, and determines the position information of the first and last non-zero coefficients. If the difference between the position information of the last non-zero coefficient and the position information of the first non-zero coefficient meets the preset difference condition, the quantization coefficient block is determined to be a usable coefficient block. The electronic device can use the number of usable coefficient blocks to determine whether the quantization coefficient blocks in the coding block can hide at least one index value in the transform kernel index of the coding block, thereby avoiding the situation of redundantly writing the transform kernel index of the coding block to the bitstream and wasting bit rate.
[0086] In an exemplary embodiment, there are multiple quantization coefficients between the first non-zero coefficient and the last non-zero coefficient. When there is a zero coefficient among the multiple quantization coefficients, the number of non-zero coefficients in the quantization coefficient block is adjusted to obtain an adjusted quantization coefficient block, including: determining one of the zero coefficients among the multiple quantization coefficients as the target quantization coefficient; adjusting the target quantization coefficient to a non-zero coefficient to obtain the adjusted quantization coefficient; and determining the adjusted quantization coefficient block based on the adjusted quantization coefficient.
[0087] In practice, there are multiple quantization coefficients between the first and last non-zero coefficients; for example, please refer to [link to example]. Figure 4 Between the first non-zero coefficient (firstNZ) "3" and the last non-zero coefficient (lastNZ) "1", there are quantization coefficients "2", "1", "1", "1", and "0". The position information of these multiple quantization coefficients can be represented as "firstNZPos+1 to lastNZPos-1". During the process of adjusting the number of non-zero coefficients in the quantization coefficient block to obtain the adjusted quantization coefficient block, the electronic device can adjust the value of one of the multiple quantization coefficients, changing it from a non-zero coefficient to a zero coefficient or vice versa, thereby adjusting the number of non-zero coefficients in the quantization coefficient block and obtaining the adjusted quantization coefficient block.
[0088] When a zero coefficient exists among multiple quantization coefficients, the electronic device can determine one of the zero coefficients among the multiple quantization coefficients as the target quantization coefficient; adjust the target quantization coefficient to a non-zero coefficient to obtain the adjusted quantization coefficient; and determine the adjusted quantization coefficient block based on the adjusted quantization coefficient.
[0089] For example, suppose an electronic device needs to adjust the number of non-zero coefficients in a certain quantization coefficient block. The quantization coefficients between the first and last non-zero coefficients in this block are "2", "1", "1", "1", and "0". It can be seen that there is a zero coefficient among the above multiple quantization coefficients. The electronic device can take the quantization coefficient "0" among these multiple quantization coefficients as the target quantization coefficient. Then, the target quantization coefficient is adjusted to a non-zero coefficient with a value of 1 or -1, etc., to obtain the adjusted quantization coefficient. Based on the adjusted quantization coefficient, the electronic device determines the adjusted quantization coefficient block.
[0090] When there is no zero coefficient among multiple quantization coefficients, the electronic device can determine the next quantization coefficient after the first non-zero coefficient in the zigzag scanning sequence as the target quantization coefficient among multiple quantization coefficients; set the coefficient value of the target quantization coefficient to 0 to obtain the adjusted quantization coefficient; based on the adjusted quantization coefficient, the electronic device determines the adjusted quantization coefficient block, thereby achieving fast adjustment of the target quantization coefficient to a non-zero coefficient while minimizing information loss.
[0091] For another example, suppose an electronic device needs to adjust the number of non-zero coefficients in a certain quantization coefficient block. The quantization coefficients between the first and last non-zero coefficients in this block are "2", "1", "1", "1", and "1". It can be seen that there are no zero coefficients among these multiple quantization coefficients. The electronic device can then, in a zigzag scanning sequence, take the next quantization coefficient after the first non-zero coefficient, i.e., quantization coefficient "2", as the target quantization coefficient among the multiple quantization coefficients. Then, it adjusts this target quantization coefficient to a zero coefficient with a coefficient value of 0, thus obtaining the adjusted quantization coefficient. Based on the adjusted quantization coefficient, the electronic device determines the adjusted quantization coefficient block.
[0092] In this embodiment, when there are zero coefficients among multiple quantization coefficients, one of the zero coefficients is adjusted to a non-zero coefficient. When there are no zero coefficients among multiple quantization coefficients, in a zigzag scanning sequence, the next quantization coefficient after the first non-zero coefficient is adjusted from a non-zero coefficient to a zero coefficient. This effectively and quickly adjusts the number of non-zero coefficients in the quantization coefficient block, resulting in an adjusted quantization coefficient block. The parity of the number of non-zero coefficients in the adjusted quantization coefficient block can correctly represent the actual transform kernel index corresponding to the coding block.
[0093] In an exemplary embodiment, determining one of the zero coefficients among a plurality of quantization coefficients as the target quantization coefficient includes: in a zigzag scanning sequence, determining the next quantization coefficient after the first non-zero coefficient in the scanning sequence as the current quantization coefficient among the plurality of quantization coefficients; obtaining the coefficient value of the current quantization coefficient; if the coefficient value of the current quantization coefficient is not equal to 0, in the zigzag scanning sequence, re-determining the next quantization coefficient after the current quantization coefficient in the scanning sequence as the current quantization coefficient, and returning to the step of obtaining the coefficient value of the current quantization coefficient, until the coefficient value of the current quantization coefficient is equal to 0; and determining the current quantization coefficient with a coefficient value equal to 0 as the target quantization coefficient.
[0094] In practical implementation, when a zero coefficient exists among multiple quantization coefficients, the electronic device, in determining one of the zero coefficients as the target quantization coefficient, can, in a zigzag scanning sequence, identify the next quantization coefficient after the first non-zero coefficient as the current quantization coefficient and obtain its value. The electronic device can then determine if this value is equal to 0. If the value is not 0, the electronic device can, in the zigzag scanning sequence, re-identify the next quantization coefficient after the current coefficient as the current quantization coefficient and return to the step of obtaining its value, until the current value equals 0. The electronic device then uses the current quantization coefficient with a value of 0 as the target quantization coefficient. In other words, the electronic device can iterate from firstNZPos+1 to lastNZPos-1 until it finds the first current quantization coefficient with a value equal to zero, which it then uses as the target quantization coefficient.
[0095] The technical solution of this embodiment, by taking the next quantization coefficient after the first non-zero coefficient in the scanning order as the current quantization coefficient among multiple quantization coefficients, and when the coefficient value of the current quantization coefficient is not equal to 0, re-determining the next quantization coefficient after the current quantization coefficient in the scanning order as the current quantization coefficient among multiple quantization coefficients, and returning to obtain the coefficient value of the current quantization coefficient, can realize the traversal of multiple quantization coefficients in a zigzag scanning order, quickly querying the first current quantization coefficient with a coefficient value equal to zero among multiple quantization coefficients, and using it as the target quantization coefficient.
[0096] In an exemplary embodiment, adjusting the target quantization coefficient to a non-zero coefficient to obtain the adjusted quantization coefficient includes: obtaining the pre-quantization coefficient corresponding to the target quantization coefficient; and adjusting the target quantization coefficient from zero to a non-zero coefficient based on the coefficient value of the pre-quantization coefficient to obtain the adjusted quantization coefficient.
[0097] In practice, during the process of adjusting the target quantization coefficient to a non-zero coefficient to obtain the adjusted quantization coefficient, the electronic device can obtain the original coefficient corresponding to the target quantization coefficient. Based on the coefficient value valUQ of the original coefficient, the target quantization coefficient is adjusted from zero to a non-zero coefficient to obtain the adjusted quantization coefficient. Specifically, if the coefficient value of the original coefficient is greater than or equal to 0 (valUQ>=0), the coefficient value val of the target quantization coefficient is set to 1 to obtain the adjusted quantization coefficient; or, if the coefficient value of the original coefficient is less than 0 (valUQ<0), the coefficient value val of the target quantization coefficient is set to -1 to obtain the adjusted quantization coefficient.
[0098] The technical solution of this embodiment, in the process of adjusting the target quantization coefficient to a non-zero coefficient and obtaining the adjusted quantization coefficient, obtains the pre-quantization coefficient corresponding to the target quantization coefficient, and adjusts the coefficient value of the target quantization coefficient based on the sign value of the pre-quantization coefficient of the target quantization coefficient. This can achieve the adjustment of the coefficient value of the target quantization coefficient within a relatively small adjustment range, and can avoid excessive information loss and other distortions during the adjustment of the quantization coefficient block as much as possible, thereby improving the video coding effect.
[0099] Figure 5 This is a flowchart illustrating another video encoding method according to an exemplary embodiment, such as... Figure 5 As shown, this method is used Figure 1 The electronic device in the process includes the following steps.
[0100] In step S502, the coded blocks in the video image frame are obtained, and at least one quantization coefficient block in the coded blocks is determined.
[0101] In step S504, the first non-zero coefficient and the last non-zero coefficient are determined in the quantization coefficient block according to the zigzag scanning order, and the position information of the first non-zero coefficient and the position information of the last non-zero coefficient are determined.
[0102] In step S506, if the difference between the position information of the last non-zero coefficient and the position information of the first non-zero coefficient meets a preset difference condition, the quantization coefficient block is determined to be a usable coefficient block.
[0103] In step S508, when the number of available coefficient blocks meets a preset quantity condition, the parity of the number of non-zero coefficients in the quantized coefficient block is mapped to the transform kernel index of the coding block to obtain the current transform kernel index; the transform kernel index is used to characterize the selection state of the coefficient transform kernel for the coding block; the coefficient transform kernel is used to perform a low-frequency inseparable quadratic transform on the coefficients in the coding block.
[0104] In step S510, there are multiple quantization coefficients between the first non-zero coefficient and the last non-zero coefficient. If the current transform kernel index is different from the actual transform kernel index of the coding block, one of the zero coefficients among the multiple quantization coefficients is determined as the target quantization coefficient.
[0105] In step S512, the target quantization coefficient is adjusted to a non-zero coefficient to obtain the adjusted quantization coefficient.
[0106] In step S514, the adjusted quantization coefficient block is determined based on the adjusted quantization coefficients; the parity of the number of non-zero coefficients in the adjusted quantization coefficient block is used to represent the actual transform kernel index.
[0107] In step S516, video encoded data of the video to which the video image frame belongs is generated based on the adjusted quantization coefficient block.
[0108] It should be noted that the specific limitations of the above steps can be found in the specific limitations of a video coding method described above, and will not be repeated here.
[0109] It should be understood that, although Figure 2 and Figure 5 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 2 and Figure 5 At least some of the steps in the process may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but may be executed at different times. The execution order of these steps or stages is not necessarily sequential, but may be executed in turn or alternately with other steps or at least some of the steps or stages in other steps.
[0110] It is understood that the same / similar parts between the various embodiments of the methods described above in this specification can be referred to each other. Each embodiment focuses on the differences from other embodiments, and relevant parts can be referred to the description of other method embodiments.
[0111] Figure 6 This is a block diagram illustrating a video encoding apparatus according to an exemplary embodiment. (Refer to...) Figure 6 The device includes:
[0112] The acquisition unit 610 is configured to acquire coded blocks in a video image frame and determine at least one quantization coefficient block in the coded blocks.
[0113] The mapping unit 620 is configured to perform a transformation kernel index that maps the parity of the number of non-zero coefficients in the quantized coefficient block to the transform kernel index of the coding block, thereby obtaining the current transform kernel index; the transform kernel index is used to characterize the selection state of the coefficient transform kernel for the coding block; the coefficient transform kernel is used to perform a low-frequency inseparable quadratic transform on the coefficients in the coding block;
[0114] The adjustment unit 630 is configured to adjust the number of non-zero coefficients in the quantization coefficient block when the current transform kernel index is different from the actual transform kernel index of the coding block, to obtain an adjusted quantization coefficient block; the parity of the number of non-zero coefficients in the adjusted quantization coefficient block is used to represent the actual transform kernel index.
[0115] The generation unit 640 is configured to generate video encoded data of the video to which the video image frame belongs, based on the adjusted quantization coefficient block.
[0116] In an exemplary embodiment, the apparatus is further configured to perform the following steps: determining a first non-zero coefficient and a last non-zero coefficient in the quantization coefficient block in a zigzag scanning order; determining the position information of the first non-zero coefficient and the position information of the last non-zero coefficient; determining the quantization coefficient block as a usable coefficient block if the difference between the position information of the last non-zero coefficient and the position information of the first non-zero coefficient satisfies a preset difference condition; and performing the step of mapping the parity of the number of non-zero coefficients in the quantization coefficient block to the coefficient transformation kernel index of the coding block if the number of usable coefficient blocks satisfies a preset quantity condition.
[0117] In an exemplary embodiment, there are multiple quantization coefficients between the first non-zero coefficient and the last non-zero coefficient. If there is a zero coefficient among the multiple quantization coefficients, the adjustment unit 630 is configured to perform the following: determine one of the zero coefficients among the multiple quantization coefficients as a target quantization coefficient; adjust the target quantization coefficient to a non-zero coefficient to obtain an adjusted quantization coefficient; and determine the adjusted quantization coefficient block based on the adjusted quantization coefficient.
[0118] In an exemplary embodiment, the adjustment unit 630 is configured to: determine the next quantization coefficient following the first non-zero coefficient in the zigzag scanning sequence as the current quantization coefficient among the plurality of quantization coefficients; obtain the coefficient value of the current quantization coefficient; if the coefficient value of the current quantization coefficient is not equal to 0, re-determine the next quantization coefficient following the current quantization coefficient in the zigzag scanning sequence as the current quantization coefficient, and return to the step of obtaining the coefficient value of the current quantization coefficient until the coefficient value of the current quantization coefficient is equal to 0; and determine the current quantization coefficient with a coefficient value equal to 0 as the target quantization coefficient.
[0119] In an exemplary embodiment, the adjustment unit 630 is configured to perform the following: obtain the pre-quantization coefficient corresponding to the target quantization coefficient; adjust the target quantization coefficient from zero to a non-zero coefficient based on the coefficient value of the pre-quantization coefficient to obtain the adjusted quantization coefficient.
[0120] In an exemplary embodiment, the adjustment unit 630 is configured to, when the coefficient value of the pre-quantization coefficient is greater than or equal to 0, set the coefficient value of the target quantization coefficient to 1 to obtain the adjusted quantization coefficient; or, when the coefficient value of the pre-quantization coefficient is less than 0, set the coefficient value of the target quantization coefficient to -1 to obtain the adjusted quantization coefficient.
[0121] In an exemplary embodiment, when there are no zero coefficients among the plurality of quantization coefficients, the adjustment unit is configured to, in the zigzag scanning sequence, determine the next quantization coefficient after the first non-zero coefficient in the scanning sequence as the target quantization coefficient among the plurality of quantization coefficients; set the coefficient value of the target quantization coefficient to 0 to obtain the adjusted quantization coefficient; and determine the adjusted quantization coefficient block based on the adjusted quantization coefficient.
[0122] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0123] Figure 7 This is a block diagram illustrating an electronic device 700 for performing a video encoding method according to an exemplary embodiment. For example, the electronic device 700 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0124] Reference Figure 7The electronic device 700 may include one or more of the following components: processing component 702, memory 704, power supply component 706, multimedia component 708, audio component 710, input / output (I / O) interface 712, sensor component 714, and communication component 716.
[0125] Processing component 702 typically controls the overall operation of electronic device 700, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 702 may include one or more modules to facilitate interaction between processing component 702 and other components. For example, processing component 702 may include a multimedia module to facilitate interaction between multimedia component 708 and processing component 702.
[0126] Memory 704 is configured to store various types of data to support the operation of electronic device 700. Examples of such data include instructions for any application or method operating on electronic device 700, contact data, phonebook data, messages, pictures, videos, etc. Memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, optical disk, or graphene memory.
[0127] Power supply component 706 provides power to various components of electronic device 700. Power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 700.
[0128] Multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 708 includes a front-facing camera and / or a rear-facing camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0129] Audio component 710 is configured to output and / or input audio signals. For example, audio component 710 includes a microphone (MIC) configured to receive external audio signals when electronic device 700 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 704 or transmitted via communication component 716. In some embodiments, audio component 710 also includes a speaker for outputting audio signals.
[0130] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0131] Sensor assembly 714 includes one or more sensors for providing state assessments of various aspects of electronic device 700. For example, sensor assembly 714 can detect the on / off state of electronic device 700, the relative positioning of components such as the display and keypad of electronic device 700, changes in position of electronic device 700 or its components, the presence or absence of user contact with electronic device 700, orientation or acceleration / deceleration of device 700, and temperature changes of electronic device 700. Sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 714 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0132] Communication component 716 is configured to facilitate wired or wireless communication between electronic device 700 and other devices. Electronic device 700 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 716 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 716 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0133] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0134] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, which can be executed by a processor 720 of an electronic device 700 to perform the above-described method. For example, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0135] In an exemplary embodiment, a computer program product is also provided, which includes instructions that can be executed by a processor 720 of an electronic device 700 to perform the above-described method.
[0136] It should be noted that the above-mentioned apparatus, electronic equipment, computer-readable storage medium, computer program product, etc., may also include other implementation methods according to the description of the method embodiments. For specific implementation methods, please refer to the description of the relevant method embodiments, which will not be elaborated here.
[0137] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0138] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method of video coding, the method comprising: The method comprises the following steps: obtaining a coding block in a video image frame, and determining at least one quantization coefficient block in the coding block; determining a first non-zero coefficient and a last non-zero coefficient in the quantization coefficient block according to a zigzag scanning order, and determining position information of the first non-zero coefficient and position information of the last non-zero coefficient; in a case where a gap between the position information of the last non-zero coefficient and the position information of the first non-zero coefficient meets a preset gap condition, determining that the quantization coefficient block is a usable coefficient block; in a case where a quantity of the usable coefficient blocks meets a preset quantity condition, mapping parity of a quantity of non-zero coefficients in the quantization coefficient block as a transform core index of the coding block to obtain a current transform core index; the transform core index is used to represent a selection state of a coefficient transform core for the coding block; the coefficient transform core is used for low-frequency non-separable quadratic transform on coefficients in the coding block; in a case where the current transform core index is different from an actual transform core index of the coding block, adjusting the quantity of non-zero coefficients in the quantization coefficient block to obtain an adjusted quantization coefficient block; parity of the quantity of non-zero coefficients in the adjusted quantization coefficient block is used to represent the actual transform core index; generating video coding data of a video to which the video image frame belongs based on the adjusted quantization coefficient block.
2. The video coding method of claim 1, wherein, in a case where there are zero coefficients in a plurality of quantization coefficients between the first non-zero coefficient and the last non-zero coefficient, the adjusting the quantity of non-zero coefficients in the quantization coefficient block to obtain an adjusted quantization coefficient block comprises the following steps: determining one of the zero coefficients in the plurality of quantization coefficients as a target quantization coefficient; adjusting the target quantization coefficient to a non-zero coefficient to obtain an adjusted quantization coefficient; determining the adjusted quantization coefficient block based on the adjusted quantization coefficient.
3. The video coding method of claim 2, wherein, the determining one of the zero coefficients in the plurality of quantization coefficients as the target quantization coefficient comprises the following steps: in the zigzag scanning order, determining a next quantization coefficient after the first non-zero coefficient as a current quantization coefficient in the plurality of quantization coefficients; obtaining a coefficient value of the current quantization coefficient; in a case where the coefficient value of the current quantization coefficient is not equal to 0, re-determining a next quantization coefficient after the current quantization coefficient as the current quantization coefficient in the zigzag scanning order, and returning to the step of obtaining the coefficient value of the current quantization coefficient until the coefficient value of the current quantization coefficient is equal to 0; determining the current quantization coefficient with the coefficient value equal to 0 as the target quantization coefficient.
4. The video coding method of claim 2, wherein, the adjusting the target quantization coefficient to a non-zero coefficient to obtain an adjusted quantization coefficient comprises the following steps: obtaining a pre-quantization coefficient corresponding to the target quantization coefficient; adjusting the target quantization coefficient from a zero coefficient to a non-zero coefficient according to the coefficient value of the pre-quantization coefficient to obtain the adjusted quantization coefficient.
5. The video coding method of claim 4, wherein, the adjusting the target quantization coefficient from a zero coefficient to a non-zero coefficient according to the coefficient value of the pre-quantization coefficient to obtain the adjusted quantization coefficient comprises the following steps: In a case where the coefficient value of the pre-quantization coefficient is greater than or equal to 0, the coefficient value of the target quantization coefficient is set to 1 to obtain the adjusted quantization coefficient; Or, In a case where the coefficient value of the pre-quantization coefficient is less than 0, the coefficient value of the target quantization coefficient is set to -1 to obtain the adjusted quantization coefficient.
6. The video coding method of claim 2, wherein, In a case where there is no zero coefficient in the plurality of quantization coefficients, the number of non-zero coefficients in the quantization coefficient block is adjusted to obtain an adjusted quantization coefficient block, including: In the zigzag scanning order, the next quantization coefficient after the first non-zero coefficient in the scanning order is determined as a target quantization coefficient in the plurality of quantization coefficients; The coefficient value of the target quantization coefficient is set to 0 to obtain an adjusted quantization coefficient; Based on the adjusted quantization coefficient, the adjusted quantization coefficient block is determined.
7. A video encoding apparatus, comprising: Including: An acquisition unit configured to acquire an encoding block in a video image frame, and determine at least one quantization coefficient block in the encoding block; A mapping unit configured to determine a first non-zero coefficient and a last non-zero coefficient in the quantization coefficient block in a zigzag scanning order, and determine position information of the first non-zero coefficient and position information of the last non-zero coefficient; In a case where a difference between the position information of the last non-zero coefficient and the position information of the first non-zero coefficient meets a preset difference condition, the quantization coefficient block is determined as a usable coefficient block; in a case where a number of the usable coefficient blocks meets a preset number condition, a parity of the number of non-zero coefficients in the quantization coefficient block is mapped to a transform kernel index of the encoding block to obtain a current transform kernel index; The transform kernel index is used to represent a selection state of a coefficient transform kernel for the encoding block; the coefficient transform kernel is used for low-frequency non-separable quadratic transform on coefficients in the encoding block; An adjustment unit configured to, in a case where the current transform kernel index is different from an actual transform kernel index of the encoding block, adjust the number of non-zero coefficients in the quantization coefficient block to obtain an adjusted quantization coefficient block; a parity of the number of non-zero coefficients in the adjusted quantization coefficient block is used to represent the actual transform kernel index; A generation unit configured to generate video encoding data of a video to which the video image frame belongs based on the adjusted quantization coefficient block.
8. An electronic device, comprising: Including: A processor; A memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the video encoding method in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device can perform the video encoding method in any one of claims 1 to 6.