Video encoding method, computer device, and computer-readable storage medium
By performing sub-block division and sequential scanning of the two-dimensional TU blocks in H.265 video encoding, combined with AH(N) and Golomb-Rice encoding, the problem of high CABAC complexity is solved, and efficient video encoding is achieved in resource-constrained scenarios.
Patent Information
- Application Number
- CN202210391810.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-14
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2042-04-14
AI Technical Summary
In the existing video encoding standard H.265, the entropy encoding scheme CABAC has a high complexity, resulting in limited application in scenarios with resource limitations.
One-dimensional CG is obtained by dividing the two-dimensional TU blocks of video pixels into multiple sub-blocks of preset sizes and scanning the multiple sub-blocks in sequence. Then AH(N) encoding is used to encode the row number and column number of the last non-zero coefficient, and the preset type encoding coefficient is based on the CG preset type, and finally the coefficient encoding is completed using Golomb-Rice encoding.
It significantly reduces the complexity of video encoding, improves encoding efficiency, and can be effectively applied in resource-constrained scenarios.
Smart Images

Figure CN114827613B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and in particular, to a video encoding method, a computer device, and a computer-readable storage medium. Background Art
[0002] The currently dominant video encoding standard is H.265, and its entropy encoding scheme is CABAC (Context Based Adaptive Arithmetic Coding). Although CABAC is efficient, the encoding information must be first binary-coded into multiple bits and then processed bit by bit serially, so the throughput is low. Coupled with the complex context operations and the complex state transitions involved in arithmetic coding, the complexity is very high. As the code rate increases, the complexity ratio of CABAC can be as high as more than 30% of the entire decoder, which limits the application of H.265 in resource-constrained scenarios.
[0003] Therefore, how to reduce the video encoding complexity and ensure the encoding efficiency has become an urgent problem to be solved. Summary of the Invention
[0004] This application provides a video encoding method, a computer device, and a computer-readable storage medium, which can reduce the video encoding complexity, ensure the encoding efficiency, and solve the restricted application of CABAC in resource-constrained scenarios.
[0005] In a first aspect, this application provides a video encoding method, and the video encoding method includes:
[0006] Dividing a two-dimensional TU block of video pixels into multiple sub-blocks of a preset size, and sequentially scanning the multiple sub-blocks to obtain a corresponding one-dimensional multiple sequentially arranged CGs;
[0007] Encoding the row number last_x and column number last_y of the corresponding last non-zero coefficient in the two-dimensional TU block by using AH(N); where the AH(N) represents a CAVLC encoding for encoding N symbols;
[0008] Based on the CG to which the positions corresponding to the last_x and the last_y belong, encoding the preset type corresponding to each CG, where the preset type includes a T0 type, and the T0 type represents no non-zero coefficient;
[0009] According to the preset type corresponding to each CG, encoding the preset type of each coefficient of the CGs that are not of the T0 type;
[0010] Based on the preset type of each coefficient, determining the absolute value of each coefficient, and completing the coefficient encoding by using Golomb-Rice encoding to perform a video bitstream generation operation according to the coefficient encoding.
[0011] In a second aspect, the present application further provides a computer device, which includes a memory and a processor;
[0012] The memory is used to store a computer program;
[0013] The processor is used to execute the computer program and implement the video encoding method as described above when executing the computer program.
[0014] In a third aspect, the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the processor is enabled to implement the video encoding method as described above.
[0015] The present application discloses a video encoding method, a computer device, and a computer-readable storage medium. By dividing a two-dimensional TU block of video pixels into multiple sub-blocks of a preset size and scanning the multiple sub-blocks in sequence to obtain a corresponding one-dimensional multiple ordered CGs, then, using AH(N) (representing the CAVLC encoding for encoding N symbols) to encode the row number last_x and column number last_y of the corresponding last non-zero coefficient in the two-dimensional TU block, and based on the CG to which the position corresponding to last_x and last_y belongs, encoding the preset type corresponding to each CG, where the preset type includes type T0 (indicating no non-zero coefficients), encoding the preset type of each coefficient of the CGs that are not of type T0 according to the preset type corresponding to each CG, determining the absolute value of each coefficient based on the preset type of each coefficient, and finally using Golomb-Rice encoding to complete the coefficient encoding, and then generating a video bitstream according to the coefficient encoding. Compared with CABAC, the encoding complexity is greatly reduced, and the video encoding efficiency is improved, and it can be applied to resource-constrained scenarios. Description of the Drawings
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0017] Figure 1 It is a schematic flowchart of a video encoding method provided by an embodiment of the present application;
[0018] Figure 2 It is a schematic diagram of a two-dimensional TU block;
[0019] Figure 3 It is a schematic diagram of a one-dimensional CG;
[0020] Figure 4 It is a schematic block diagram of the structure of a computer device provided by an embodiment of the present application. Specific embodiments
[0021] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0022] The flowcharts shown in the accompanying drawings are only illustrative, and do not necessarily include all the contents and operations / steps, nor do they necessarily need to be executed in the described order. For example, some operations / steps can also be decomposed, combined or partially merged. Therefore, the actual execution order may be changed according to the actual situation.
[0023] It should be understood that the terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification of the present application and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include the plural forms.
[0024] It should also be understood that the term "and / or" used in the specification of the present application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0025] The currently dominant video coding standard is H.265, and its entropy coding scheme is CABAC (Context Based Adaptive Arithmetic Coding). Although CABAC is efficient, the coding information must be first binary-coded into multiple bits and then processed bit by bit serially, so the throughput is low. Coupled with the complex context operations and the complex state transitions involved in arithmetic coding, the complexity is very high. As the code rate increases, the complexity ratio of CABAC can be as high as more than 30% of the entire decoder, which limits the application of H.265 in resource-constrained scenarios.
[0026] To solve the above problems, an embodiment of the present application provides a video coding method, a computer device, and a computer-readable storage medium, which can reduce the video coding complexity, ensure the coding efficiency, and solve the limited application of CABAC in resource-constrained scenarios.
[0027] Please refer to Figure 1 , Figure 1FIG. 0 is a schematic flowchart of a video encoding method provided by an embodiment of the present application. This video encoding method can be applied to a computer device. It should be noted that this video encoding method can also be applied to other electronic products with video encoding functions other than computer devices, and no specific limitations are made in the present application. In the following, taking the application of this video encoding method in a computer device as an example, this video encoding method will be introduced and described.
[0028] As Figure 1 shown, this video encoding method may include steps S10 to S50.
[0029] Step S10: Divide a two-dimensional TU block of video pixels into multiple sub-blocks of a preset size, and scan the multiple sub-blocks in sequence to obtain a corresponding one-dimensional multiple ordered CGs.
[0030] Generally, the prediction residual of video pixels is divided into blocks called TUs (Transform Units). Exemplarily, the sizes of two-dimensional TU blocks include but are not limited to various sizes such as 4x4, 8x8, 16x16, 32x32, etc. For example, as Figure 2 shown, Figure 2 is a two-dimensional TU block of 8x8 size.
[0031] Among them, TU4x4, TU8x8, TU16x16 may be either luminance or chrominance, and TU32x32 can only be luminance. Each TU becomes integer quantization coefficients (Coefficients) after transformation and quantization.
[0032] Exemplarily, the preset size is pre-set to 4x4. Divide the two-dimensional TU block of video pixels into multiple 4x4-sized sub-blocks called CGs (Coefficient Groups), and scan the multiple sub-blocks in a certain order to obtain a corresponding one-dimensional multiple ordered CGs.
[0033] For example, taking the Figure 2 shown TU8x8 as an example, divide TU8x8 into 4 4x4 sub-blocks, and scan the CGs in the order of upper left - lower left - upper right - lower right. The coefficients within each CG are also scanned in a certain order to obtain a corresponding one-dimensional multiple ordered CGs. As Figure 3 shown, they are CG(0), CG(1), CG(2), and CG(3) in sequence.
[0034] Step S20: Encode the row number last_x and column number last_y of the corresponding last non-zero coefficient in the two-dimensional TU block using AH(N); where AH(N) represents a CAVLC encoding for encoding N symbols.
[0035] Among them, the complexity of CAVLC (Context Based Variable Length Coding) is much lower than that of arithmetic coding, and AH(N) represents the CAVLC coding of N symbols.
[0036] According to the size of the two-dimensional TU block, code the row number last_x and column number last_y of the last non-zero coefficient in the two-dimensional TU block. For example, assuming the position corresponding to the last non-zero coefficient is last_pos, determine the row number last_x and column number last_y of last_pos in the two-dimensional TU block. For example, as Figure 3 shown, last_pos is located in CG(2).
[0037] Exemplarily, using AH(N) to code the row number last_x and column number last_y corresponding to the last non-zero coefficient in the two-dimensional TU block may include:
[0038] If the two-dimensional TU block is TU4x4, use AH(16) to code the last_x and the last_y;
[0039] If the two-dimensional TU block is TU8x8, use AH(8) to code the last_x and the last_y;
[0040] If the two-dimensional TU block is TU16x16, use AH(16) to code the last_x and the last_y;
[0041] If the two-dimensional TU block is TU32x32, use AH(16) to code the last_x and the last_y.
[0042] Exemplarily, for TU4x4, the corresponding range of last_x and last_y is 0 - 3, with a total of 16 combinations, using AH(16) coding, and the luminance and chrominance are coded separately.
[0043] Exemplarily, for TU8x8, the corresponding range of last_x and last_y is 0 - 7, using AH(8) coding, and the luminance and chrominance are coded separately.
[0044] Exemplarily, for TU16x16, the corresponding range of last_x and last_y is 0 - 15, using AH(16) coding, and the luminance and chrominance are coded separately.
[0045] Exemplarily, for TU32x32, the corresponding range of last_x and last_y is 0 - 31, using AH(16) coding. Since TU32x32 can only be luminance, chrominance does not need to be considered.
[0046] In some embodiments, if the two-dimensional TU block is TU32x32, encoding the last_x and the last_y using AH(16) may include:
[0047] If the two-dimensional TU block is TU32x32, map the range 0 - 31 of the last_x and the last_y to 0 - 15 according to a preset mapping relationship, and encode them respectively using AH(16).
[0048] Exemplarily, in the preset mapping relationship, 0 - 9 is mapped to 0 - 9, 10 - 11 is mapped to 10, 12 - 13 is mapped to 11, 14 - 15 is mapped to 12, 16 - 19 is mapped to 13, 20 - 23 is mapped to 14, and 24 - 31 is mapped to 15.
[0049] Exemplarily, the preset mapping relationship includes but is not limited to a mapping table. For example, the mapping table is shown in Table 1:
[0050] Table 1
[0051] 0-9 10-11 12-13 14-15 16-19 20-23 24-31 0-9 10 11 12 13 14 15
[0052] As can be seen from the table, the mapping values 10 / 11 / 12 respectively correspond to two values of 10 - 11 / 12 - 13 / 14 - 15, the mapping values 13 / 14 respectively correspond to four values of 16 - 19 / 20 - 23, and the mapping value 15 corresponds to eight values of 24 - 31. Based on this mapping relationship, the mapping values 10 / 11 / 12 respectively correspond to two values of 10 - 11 / 12 - 13 / 14 - 15, and an additional 1-bit encoding is used to distinguish the two values; the mapping values 13 / 14 respectively correspond to four values of 16 - 19 / 20 - 23, and an additional 2-bit encoding is used to distinguish the four values, and the mapping value 15 corresponds to eight values of 24 - 31, and an additional 3-bit encoding is used to distinguish the eight values.
[0053] Step S30: Based on the CG to which the corresponding positions of the last_x and the last_y belong, encode the preset type corresponding to each CG, where the preset type includes the T0 type, and the T0 type indicates no non-zero coefficients.
[0054] Exemplarily, preset types T are pre-set to include the T0 type, the T1 type, the T2 type, and the T3 type. Among them, the T0 type indicates no non-zero coefficients, the T1 type indicates having non-zero coefficients and the absolute value is 1, the T2 type indicates having non-zero coefficients and the maximum absolute value is 2, and the T3 type indicates having non-zero coefficients and the maximum absolute value is greater than 2.
[0055] Encode which type among the T0 type, the T1 type, the T2 type, and the T3 type each CG belongs to. For example, still taking Figure 3Taking CG(0), CG(1), CG(2), and CG(3) shown as examples, determine which type among T0 type, T1 type, T2 type, and T3 type the encodings CG(0), CG(1), CG(2), and CG(3) belong to.
[0056] In some embodiments, encoding the preset type corresponding to each of the CGs may include:
[0057] If the CG(i) to which the last non-zero coefficient belongs is not CG(0), use AH(12) to encode the type combination of CG(i) and the remaining CGs, where the remaining CGs are CG(i - 1) to CG(0);
[0058] If there are multiple remaining CGs and their corresponding preset type is not T0 type, divide the remaining CGs into CG(1)' and CG(0), encode the type combination of CG(1)' and CG(0), and repeat the operation until there is only one remaining CG.
[0059] Assume that the last non-zero coefficient is in CG(i). If i!= 0, encode the type combination of CG(i) and the remaining CGs, where the remaining CGs are CG(i - 1), …, CG(0). There are 3 possible preset types for CG(i), namely T1 / T2 / T3, and 4 possible preset types for the remaining CGs, namely T0 / T1 / T2 / T3. So there are 12 possible combinations in total. Use AH(12) for encoding, with luminance and chrominance separated.
[0060] If there is more than one remaining CG and their corresponding preset type T is not T0 type, divide the remaining CGs into the last CG(0) and the other CG(1)', and encode the possible type combinations of CG(1)' and CG(0) according to the preset type.
[0061] Repeat this operation until there is only one CG left, so that the preset type T of all CGs is determined.
[0062] In some embodiments, encoding the type combination of CG(1)' and CG(0) may include:
[0063] If the preset type is T1 type, use AH(3) to encode the type combination of CG(1)' and CG(0), including T1T1, T1T0, T0T1;
[0064] If the preset type is T2 type, use AH(5) to encode the type combination of CG(1)' and CG(0), including T2T2, T2T1, T2T0, T1T2, T0T2;
[0065] If the preset type is of type T3, then the type combination of the CG(1)' and the CG(0) is encoded using AH(7), including T3T3, T3T2, T3T1, T3T0, T0T3, T1T3, T2T3.
[0066] That is:
[0067] If T == T1, then there are 3 possible type combinations: T1T1, T1T0, T0T1. The type combination of the current CG and the remaining CG is encoded using AH(3);
[0068] If T == T2, then there are 5 possible type combinations: T2T2, T2T1, T2T0, T1T2, T0T2. The type combination of the current CG and the remaining CG is encoded using AH(5);
[0069] If T == T3, then there are 7 possible type combinations: T3T3, T3T2, T3T1, T3T0, T0T3, T1T3, T2T3. The type combination of the current CG and the remaining CG is encoded using AH(7).
[0070] Step S40: According to the preset type corresponding to each CG, encode the preset type of each coefficient of the CG that is not of type T0.
[0071] Exemplarily, the preset types of the coefficients of the CG include type T0, type T1, type T2, type T3. Among them, type T0 indicates no non-zero coefficients, type T1 indicates having non-zero coefficients and the absolute value is 1, type T2 indicates having non-zero coefficients and the maximum absolute value is 2, and type T3 indicates having non-zero coefficients and the maximum absolute value is greater than 2.
[0072] For each CG whose corresponding preset type among all CGs is not of type T0, encode the preset type of each coefficient of this CG.
[0073] In some embodiments, encoding the preset type of each coefficient of the CG that is not of type T0 may include:
[0074] Encode the type combination of the current coefficient and the remaining coefficients of the CG in the reverse order until the last coefficient.
[0075] Encoding the preset type of each coefficient of the CG is similar to the operation in step S30, except that the object changes from the CG to the coefficients of the CG. Process the coefficients of the CG one by one in the reverse order, and encode the type combination of the current coefficient and the remaining coefficients of the CG until the last coefficient.
[0076] If the position last_pos corresponding to the last non-zero coefficient is in CG(0), and whether the preset type T corresponding to CG(0) is of type T1, type T2, or type T3 is not encoded, so the preset type of the coefficient at last_pos may be one of the 3 possibilities of T1 / T2 / T3, and the preset type of the remaining coefficients may be one of the 4 possibilities of T0 / T1 / T2 / T3. Therefore, there are a total of 12 possible combinations, and AH(12) coding is used, with luminance and chrominance separated.
[0077] If the preset type T of the remaining coefficients is not of type T0, the remaining coefficients are divided into the last one and the other two parts, and the possible type combinations of the last one and the other two parts of the coefficients are encoded according to the type of T.
[0078] Exemplarily, if T == T1, there are 3 possible type combinations: T1T1, T1T0, and T0T1, and AH(3) is used to code the type combination of the current coefficient and the remaining coefficients;
[0079] If T == T2, there are 5 possible type combinations: T2T2, T2T1, T2T0, T1T2, and T0T2, and AH(5) is used to code the type combination of the current coefficient and the remaining coefficients;
[0080] If T == T3, there are 7 possible type combinations: T3T3, T3T2, T3T1, T3T0, T0T3, T1T3, and T2T3, and AH(7) is used to code the type combination of the current coefficient and the remaining coefficients.
[0081] Repeat this step of operation until only one coefficient remains, so that the preset types of all coefficients are determined.
[0082] Step S50: Based on the preset type of each coefficient, determine the absolute value of each coefficient, and use Golomb-Rice coding to complete the coefficient coding, so as to perform video bitstream generation operations according to the coefficient coding.
[0083] Once the preset type of the coefficient is determined, the absolute value of the coefficient is correspondingly determined. For example, if the preset type of a certain coefficient is of type T0, the absolute value of this coefficient is 0. Another example, if the preset type of a certain coefficient is of type T1, the absolute value of this coefficient is 1. Another example, if the preset type of a certain coefficient is of type T2, the absolute value of this coefficient is 2. Another example, if the preset type of a certain coefficient is of type T3, the absolute value of this coefficient is greater than 2. For coefficients with an absolute value greater than 2 (assuming base = 3), the Golomb-Rice (adaptive run-length) coding algorithm is used to perform coefficient coding to complete the coefficient coding. Furthermore, video bitstream generation operations can be performed according to the completed coefficient coding. Correspondingly, the generated video bitstream is output to complete video coding.
[0084] The complexity of the above video encoding method is less than one-fourth of that of CABAC encoding. Correspondingly, through experiments, the loss of the bit rate generally does not exceed 2%. That is, compared with CABAC encoding, the complexity is greatly reduced and the video encoding efficiency is improved, which can be applied to resource-constrained scenarios.
[0085] The video encoding method provided by the above embodiment divides the two-dimensional TU block of video pixels into multiple sub-blocks of a preset size, and scans the multiple sub-blocks in order to obtain a corresponding one-dimensional multiple ordered CGs. Then, AH(N) (representing the CAVLC encoding for encoding N symbols) is used to encode the row number last_x and column number last_y of the last non-zero coefficient in the two-dimensional TU block. Based on the CG to which the position corresponding to last_x and last_y belongs, the preset type corresponding to each CG is encoded, where the preset type includes the T0 type (indicating no non-zero coefficients). According to the preset types corresponding to each CG, the preset type of each coefficient of the CGs that are not of the T0 type is encoded. Based on the preset type of each coefficient, the absolute value of each coefficient is determined. Finally, Golomb-Rice encoding is used to complete the coefficient encoding, and then the video bitstream generation operation is performed according to the coefficient encoding. Compared with CABAC encoding, the complexity is greatly reduced and the video encoding efficiency is improved, which can be applied to resource-constrained scenarios.
[0086] An embodiment of the present application also provides a computer device. As Figure 4 shown, Figure 4 is a schematic block diagram of the structure of the computer device. In Figure 4 this, the computer device 10 includes a processor 11 and a memory 12. Among them, the processor 11 and the memory 12 are connected by a bus, and this bus is, for example, an I2C (Inter-integrated Circuit) bus.
[0087] Among them, the memory 12 may include a non-volatile storage medium and an internal memory. The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any one of the video encoding methods.
[0088] The processor 11 is used to provide computing and control capabilities to support the operation of the entire computer device 10.
[0089] Among them, the processor 11 may be a Central Processing Unit (CPU), and this processor may also be other general-purpose processors, Digital Signal Processors (DSPs), application specific integrated circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or this processor may also be any conventional processor, etc.
[0090] Among them, the processor 11 is used to run the computer program stored in the memory 12 and implement the following steps when executing the computer program:
[0091] Divide the two-dimensional TU block of video pixels into multiple sub-blocks of a preset size, and sequentially scan the multiple sub-blocks to obtain a corresponding one-dimensional multiple sequentially arranged CGs;
[0092] Encode the row number last_x and column number last_y of the corresponding last non-zero coefficient in the two-dimensional TU block using AH(N); where the AH(N) represents the CAVLC encoding for encoding N symbols;
[0093] Based on the CG to which the corresponding positions of the last_x and the last_y belong, encode the preset type corresponding to each CG, and the preset type includes the T0 type, and the T0 type indicates that there are no non-zero coefficients;
[0094] According to the preset type corresponding to each CG, encode the preset type of each coefficient of the CG that is not of the T0 type;
[0095] Based on the preset type of each coefficient, determine the absolute value of each coefficient, and complete the coefficient encoding using Golomb-Rice encoding to perform video bitstream generation operations according to the coefficient encoding.
[0096] In some embodiments, the preset type further includes the T1 type, the T2 type, and the T3 type. The T1 type indicates that there are non-zero coefficients and the absolute value is 1. The T2 type indicates that there are non-zero coefficients and the maximum absolute value is 2. The T3 type indicates that there are non-zero coefficients and the maximum absolute value is greater than 2.
[0097] In some embodiments, when the processor 11 implements encoding the row number last_x and column number last_y of the corresponding last non-zero coefficient in the two-dimensional TU block using AH(N), it is used to implement:
[0098] If the two-dimensional TU block is TU4x4, then encode the last_x and the last_y using AH(16).
[0099] If the two-dimensional TU block is TU8x8, then encode the last_x and the last_y using AH(8).
[0100] If the two-dimensional TU block is TU16x16, then encode the last_x and the last_y using AH(16).
[0101] If the two-dimensional TU block is TU32x32, then encode the last_x and the last_y using AH(16).
[0102] In some embodiments, when the processor 11 implements that if the two-dimensional TU block is TU32x32, then encode the last_x and the last_y using AH(16), it is used to implement:
[0103] If the two-dimensional TU block is TU32x32, map the range 0-31 of the last_x and the last_y to 0-15 according to a preset mapping relationship, and encode them respectively using AH(16).
[0104] In some embodiments, in the preset mapping relationship, 0-9 is mapped to 0-9, 10-11 is mapped to 10, 12-13 is mapped to 11, 14-15 is mapped to 12, 16-19 is mapped to 13, 20-23 is mapped to 14, 24-31 is mapped to 15. Among them, the mapping value 10 / 11 / 12 corresponds to two values of 10-11 / 12-13 / 14-15 respectively, and an additional 1-bit code is used to distinguish the two values; the mapping value 13 / 14 corresponds to four values of 16-19 / 20-23 respectively, and an additional 2-bit code is used to distinguish the four values, and the mapping value 15 corresponds to eight values of 24-31, and an additional 3-bit code is used to distinguish the eight values.
[0105] In some embodiments, when the processor 11 implements the preset type corresponding to each CG during encoding, it is used to implement:
[0106] If the CG(i) to which the last non-zero coefficient belongs is not CG(0), encode the type combination of CG(i) and the remaining CGs, where the remaining CGs are CG(i-1) to CG(0), using AH(12).
[0107] If there are multiple remaining CGs and the corresponding preset type is not the T0 type, then divide the remaining CGs into CG(1)' and CG(0), encode the type combination of CG(1)' and CG(0), and repeat the operation until there is only one remaining CG.
[0108] In some embodiments, when the processor 11 implements the type combination of the encodings CG(1)' and CG(0), it is configured to implement:
[0109] If the preset type is the T1 type, then use AH(3) to encode the type combination of the CG(1)' and the CG(0), including T1T1, T1T0, T0T1;
[0110] If the preset type is the T2 type, then use AH(5) to encode the type combination of the CG(1)' and the CG(0), including T2T2, T2T1, T2T0, T1T2, T0T2;
[0111] If the preset type is the T3 type, then use AH(7) to encode the type combination of the CG(1)' and the CG(0), including T3T3, T3T2, T3T1, T3T0, T0T3, T1T3, T2T3.
[0112] In some embodiments, when the processor 11 implements the preset type of each coefficient of the CG that is not of the T0 type, it is configured to implement:
[0113] Encode the type combination of the current coefficient of the CG and the remaining coefficients in reverse order until the last coefficient.
[0114] An embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. The computer program includes program instructions. The processor executes the program instructions to implement any one of the video encoding methods provided by the embodiments of the present application. For example, when the computer program is loaded by the processor, the following steps can be executed:
[0115] Divide the two-dimensional TU block of video pixels into a plurality of sub-blocks of a preset size, and scan the plurality of sub-blocks in order to obtain a corresponding one-dimensional plurality of CGs arranged in order;
[0116] Use AH(N) to encode the row number last_x and the column number last_y of the corresponding last non-zero coefficient in the two-dimensional TU block; where the AH(N) represents a CAVLC encoding for encoding N symbols;
[0117] Based on the CG to which the position corresponding to the last_x and the last_y belongs, encode the preset type corresponding to each CG. The preset type includes the T0 type, and the T0 type indicates that there are no non-zero coefficients;
[0118] According to the preset type corresponding to each CG, encode the preset type of each coefficient of the CG that is not of the T0 type;
[0119] Based on the preset type of each coefficient, determine the absolute value of each coefficient, and use CABAC coding for the signs of non-zero coefficients to complete the coefficient coding, so as to perform video bitstream generation operations according to the coefficient coding.
[0120] For the specific implementation of each of the above operations, reference may be made to the previous embodiments, which will not be elaborated herein.
[0121] Among them, the computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a SmartMedia Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the computer device.
[0122] As described above, the above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A video encoding method, characterized in that, the video encoding method includes: dividing a two-dimensional TU block of video pixels into a plurality of sub-blocks of a preset size, and sequentially scanning the plurality of sub-blocks to obtain a corresponding one-dimensional plurality of sequentially arranged CGs; encoding the row number last_x and column number last_y corresponding to the last non-zero coefficient in the two-dimensional TU block by using AH(N); wherein, the AH(N) represents a CAVLC encoding for encoding N symbols; encoding a preset type corresponding to each CG based on the CG to which the last_x and the last_y correspond, the preset type including T0 type, T1 type, T2 type, T3 type, the T0 type indicating no non-zero coefficients, the T1 type indicating having non-zero coefficients and the absolute value being 1, the T2 type indicating having non-zero coefficients and the maximum absolute value being 2, and the T3 type indicating having non-zero coefficients and the maximum absolute value being greater than 2; encoding a preset type of each coefficient of the CGs that are not of the T0 type according to the preset types corresponding to the respective CGs; determining the absolute value of each coefficient based on the preset type of each coefficient, and completing coefficient encoding by using Golomb-Rice encoding to perform a video bitstream generation operation according to the coefficient encoding; wherein, the encoding the preset type corresponding to each CG includes: if the CG(i) to which the last non-zero coefficient belongs is not CG(0), encoding the type combination of CG(i) and the remaining CGs by using AH(12), and the remaining CGs are CG(i - 1) to CG(0); if there are multiple remaining CGs and the corresponding preset types are not of the T0 type, dividing the remaining CGs into CG(1)' and CG(0), encoding the type combination of CG(1)' and CG(0), and repeating the operation until there is only one remaining CG; the encoding the type combination of CG(1)' and CG(0) includes: if the preset type is the T1 type, encoding the type combination of CG(1)' and CG(0) by using AH(3), including T1T1, T1T0, T0T1; if the preset type is the T2 type, encoding the type combination of CG(1)' and CG(0) by using AH(5), including T2T2, T2T1, T2T0, T1T2, T0T2; if the preset type is the T3 type, encoding the type combination of CG(1)' and CG(0) by using AH(7), including T3T3, T3T2, T3T1, T3T0, T0T3, T1T3, T2T3; the encoding the preset type of each coefficient of the CGs that are not of the T0 type includes: encoding the type combination of the current coefficient and the remaining coefficients of the CG in a reverse order until the last coefficient.
2. The video encoding method according to claim 1, characterized in that, the encoding the row number last_x and column number last_y corresponding to the last non-zero coefficient in the two-dimensional TU block by using AH(N) includes: If the two-dimensional TU block is TU4x4, then AH(16) is used to encode the last_x and the last_y; If the two-dimensional TU block is TU8x8, then AH(8) is used to encode the last_x and the last_y; If the two-dimensional TU block is TU16x16, then AH(16) is used to encode the last_x and the last_y; If the two-dimensional TU block is TU32x32, then AH(16) is used to encode the last_x and the last_y.
3. The video coding method according to claim 2, wherein, if the two-dimensional TU block is TU32x32, using AH(16) to encode the last_x and the last_y includes: if the two-dimensional TU block is TU32x32, the ranges 0 - 31 of the last_x and the last_y are mapped to 0 - 15 according to a preset mapping relationship, and AH(16) is used for encoding respectively.
4. The video coding method according to claim 3, wherein, in the preset mapping relationship, 0 - 9 is mapped to 0 - 9, 10 - 11 is mapped to 10, 12 - 13 is mapped to 11, 14 - 15 is mapped to 12, 16 - 19 is mapped to 13, 20 - 23 is mapped to 14, 24 - 31 is mapped to 15. Among them, the mapping values 10 / 11 / 12 respectively correspond to two values of 10 - 11 / 12 - 13 / 14 - 15, and an additional 1-bit code is used to distinguish the two values; the mapping values 13 / 14 respectively correspond to four values of 16 - 19 / 20 - 23, and an additional 2-bit code is used to distinguish the four values, and the mapping value 15 corresponds to eight values of 24 - 31, and an additional 3-bit code is used to distinguish the eight values.
5. A computer device, wherein, the computer device includes a memory and a processor; the memory is used for storing a computer program; the processor is used for executing the computer program and implementing the video coding method according to any one of claims 1 to 4 when executing the computer program.
6. A computer-readable storage medium, wherein, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to implement the video coding method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Video coding and decoding method and device, computer readable medium and electronic equipment
CN112995671A
Method and apparatus for encoding / decoding image signal
CN113810707A