Coding and decoding method, encoder, decoder and storage medium

CN118985132APending Publication Date: 2024-11-19GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202280094513.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-04-11
Publication Date
2024-11-19

AI Technical Summary

Technical Problem

In video coding, with the improvement of compression efficiency requirements, the proportion of syntax elements in the code stream is getting higher and higher, making it difficult to improve the overall system compression efficiency. It is difficult for the existing technology to effectively match the syntax elements of the current block to a higher level. Suitable context model.

Method used

By selecting multiple related blocks of the current block from a larger predetermined area, the context model index parameters of the current block are determined based on the reference information of these related blocks, thereby more accurately matching the syntax elements of the current block to a more suitable context model.

Benefits of technology

By making full use of the spatial correlation of image blocks, the compression efficiency of syntax elements is improved, thereby improving the compression efficiency of the entire system and avoiding the impact of accidental events on context model selection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118985132A_ABST
    Figure CN118985132A_ABST
Patent Text Reader

Abstract

The invention discloses a coding and decoding method, a coder, a decoder and a storage medium. The coding and decoding method comprises the following steps: selecting a plurality of coded related blocks corresponding to a current block from a predetermined area; wherein the predetermined region comprises a region having correlation with the current block; determining a context model index parameter of a first syntax element of the current block based on reference information of the plurality of related blocks; and encoding a first syntax element of the current block based on a context model corresponding to the context model index parameter. Therefore, more related blocks are selected for the current block by setting a larger predetermined area, the spatial correlation of the image blocks is fully utilized, a more suitable context model can be matched for the first syntax element of the current block, the compression efficiency of the syntax element is improved, and the compression efficiency of the whole system is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

A coding and decoding method, encoder, decoder and storage medium Technical Field

[0001] The present application relates to the field of video image processing technology, and in particular to a coding and decoding method, an encoder, a decoder, and a storage medium. Background Art

[0002] Context-based Adaptive Binary Arithmetic Coding (CABAC) is a commonly used entropy coding method. High Efficiency Video Coding (HEVC) and Versatile Video Coding (VVC) both use CABAC for entropy coding. CABAC is used to perform entropy encoding and decoding of syntax elements.

[0003] CABAC uses a context model to improve compression efficiency. As the demand for compression efficiency continues to increase, various new prediction modes and transform modes are added, and with them more syntax elements are used to control the selection of these modes. As a result, the proportion of syntax elements used to control various modes in the bitstream is increasing. Therefore, in order to further improve the compression efficiency of the entire system, it is becoming increasingly important to improve the compression efficiency of syntax elements.

[0004] Summary of the Invention

[0005] To solve the above technical problems, the embodiments of the present application provide a coding and decoding method, an encoder, a decoder and a storage medium, which can match the first syntax element of the current block to a more suitable context model and improve the compression efficiency of the syntax element.

[0006] In a first aspect, an embodiment of the present application provides an encoding method, applied to an encoder, comprising:

[0007] Selecting a plurality of encoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block;

[0008] Determining a context model index parameter of a first syntax element of the current block based on reference information of the multiple related blocks;

[0009] The first syntax element of the current block is encoded based on the context model corresponding to the context model index parameter.

[0010] In a second aspect, an embodiment of the present application provides a decoding method, applied to a decoder, comprising:

[0011] Decode the code stream to obtain the to-be-decoded information of the first syntax element of the current block;

[0012] Selecting a plurality of decoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block;

[0013] Determining a context model index parameter of a first syntax element of the current block based on reference information of the multiple related blocks;

[0014] The information to be decoded is decoded based on the context model corresponding to the context model index parameter to obtain a first syntax element of the current block.

[0015] In a third aspect, an embodiment of the present application provides an encoder, including:

[0016] A first selection unit is configured to select a plurality of encoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block;

[0017] A first determining unit, configured to determine a context model index parameter of a first syntax element of the current block based on reference information of the multiple related blocks;

[0018] An encoding unit is configured to encode a first syntax element of the current block based on a context model corresponding to the context model index parameter.

[0019] In a fourth aspect, an embodiment of the present application provides a decoder, wherein the decoder includes:

[0020] A first decoding unit, configured to decode a bitstream and obtain information to be decoded of a first syntax element of a current block;

[0021] A second selection unit is configured to select a plurality of decoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block;

[0022] a second determining unit, configured to determine a context model index parameter of a first syntax element of the current block based on the reference information of the multiple related blocks;

[0023] The second decoding unit is configured to decode the information to be decoded based on the context model corresponding to the context model index parameter to obtain a first syntax element of the current block.

[0024] In a fifth aspect, an embodiment of the present application further provides an encoder, comprising: a first memory and a first processor; the first memory stores a computer program that can be run on the first processor, and the first processor implements the encoding method of the encoder when executing the program.

[0025] In a sixth aspect, an embodiment of the present application further provides a decoder comprising: a second memory and a second processor; the second memory stores a computer program that can be run on the second processor, and the second processor implements the decoding method of the decoder when executing the program.

[0026] In the seventh aspect, an embodiment of the present application provides a storage medium, comprising: a computer program stored thereon, which, when executed by a first processor, implements the encoding method of the encoder; or, when executed by a second processor, implements the decoding method of the decoder.

[0027] The embodiment of the present application selects more relevant blocks for the current block by setting a larger predetermined area, thereby fully utilizing the spatial correlation of image blocks, and can match a more suitable context model for the first syntax element of the current block, thereby improving the compression efficiency of the syntax element and further improving the compression efficiency of the entire system. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] FIG1 is a video coding system;

[0029] FIG2 is a video decoding system;

[0030] FIG3 is a schematic diagram of a flow chart of an encoding method provided in an embodiment of the present application;

[0031] FIG4 is a first schematic diagram of the selection position of related blocks in an embodiment of the present application;

[0032] FIG5 is a second schematic diagram of the selection position of related blocks in an embodiment of the present application;

[0033] FIG6 is a third schematic diagram of the selection position of related blocks in an embodiment of the present application;

[0034] FIG7 is a fourth schematic diagram of the selection position of related blocks in an embodiment of the present application;

[0035] FIG8 is a fifth schematic diagram of the selection position of related blocks in an embodiment of the present application;

[0036] FIG9 is a sixth schematic diagram of the selection positions of related blocks in an embodiment of the present application;

[0037] FIG10 is a diagram illustrating the entire arithmetic decoding process of a binary symbol in an embodiment of the present application;

[0038] FIG11 is a decoding decision process of a binary symbol in an embodiment of the present application;

[0039] FIG12 is a diagram illustrating the renormalization process in an embodiment of the present application;

[0040] FIG13 is a bypass decoding process of a binary symbol in an embodiment of the present application;

[0041] FIG14 shows the termination decoding process in an embodiment of the present application;

[0042] FIG15 is a schematic diagram of a flow chart of a decoding method provided in an embodiment of the present application;

[0043] FIG16 is a schematic diagram of a first component structure of an encoder provided in an embodiment of the present application;

[0044] FIG17 is a schematic diagram of a second structural component of an encoder provided in an embodiment of the present application;

[0045] FIG18 is a schematic diagram of a first component structure of a decoder provided in an embodiment of the present application;

[0046] FIG19 is a schematic diagram of the second component structure of the decoder provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below with reference to the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.

[0048] Currently, common video codec standards (such as VVC) all use block-based hybrid coding and decoding. Each frame in the video is divided into square largest coding units (LCUs) or coding tree units (CTUs) of the same size (such as 128x128, 64x64, etc.). Each largest coding unit can be divided into rectangular coding units (CUs) according to rules. Coding units may also be divided into prediction units (PUs), transform units (TUs), etc.

[0049] At the encoding end, a frame of image is divided into blocks, and intra-frame prediction or inter-frame prediction is used for the current block (CU) to generate a predicted block of the current block. The original block of the current block is subtracted from the predicted block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix, and the quantization coefficient matrix is ​​entropy coded and output to the bitstream.

[0050] FIG1 is an exemplary video coding system. As shown in FIG1 , the video coding system 11 includes a transform unit 111, a quantization unit 112, a mode selection and coding control logic unit 113, an intra-frame prediction unit 114, an inter-frame prediction unit 115 (including motion compensation and motion estimation), an inverse quantization unit 116, an inverse transform unit 117, a loop filter unit 118, a coding unit 119, and a decoded image buffer unit 110. For an input original video signal, a frame of an image is divided into blocks. The mode selection and coding control logic unit 113 determines a coding mode. Intra-frame prediction or inter-frame prediction is used for the current block to generate a prediction block for the current block. Due to the strong correlation between adjacent pixels in a video frame, intra-frame prediction is used in video coding and decoding technology to eliminate spatial redundancy between adjacent pixels. Due to the strong similarity between adjacent frames in a video, inter-frame prediction is used in video coding and decoding technology to eliminate temporal redundancy between adjacent frames, thereby improving coding efficiency. The original block of the current block is subtracted from the predicted block to obtain a residual block. The residual block is then passed through the transform unit 111 and the quantization unit 112 to obtain a quantization coefficient matrix. The quantization coefficient matrix is ​​entropy-encoded by the encoding unit 119 and output to the bitstream. In addition, the quantization coefficient matrix is ​​passed through the inverse quantization unit 116 and the inverse transform unit 117 to obtain a reconstructed residual block. The reconstructed residual block is then removed from the block effect artifacts by the loop filter unit 118. This reconstructed residual block is then added to a prediction block in the frame of the decoded image buffer unit 111 to generate a reconstructed video reconstructed block. The decoded image buffer unit 110 is used to store the reconstructed video reconstructed block for prediction reference. As the video image encoding progresses, new reconstructed video reconstructed blocks are continuously generated, and these reconstructed video reconstructed blocks are all stored in the decoded image buffer unit 110.

[0051] The decoding end determines the same block division information, prediction, transformation, quantization, entropy coding, loop filtering and other mode information or parameter information as the encoding end by parsing and analyzing the existing information, thereby ensuring that the decoded image obtained by the encoding end is the same as the decoded image obtained by the decoding end.

[0052] Exemplarily, FIG2 is a video decoding system, FIG2 is a schematic diagram of the composition structure of the video encoding system of an embodiment of the present application, as shown in FIG2, the video encoding system 21 includes: a decoding unit 211, an inverse transform unit 212, an inverse quantization unit 213, an intra-frame prediction unit 214, a motion compensation unit 215, a loop filter unit 216 and a decoded image cache unit 217; after the input video signal is encoded by the video encoding system 11, the code stream of the video signal is output; the code stream is input to the video decoding system 21, and first passes through the decoding unit 211 to obtain a decoded quantization coefficient matrix; the quantization coefficient matrix is ​​processed by the inverse transform unit 212 and the inverse quantization unit 213 to generate a residual block in the pixel domain; the intra-frame prediction unit 214 can be used to generate a residual block based on the determined intra-frame prediction direction and the A prediction block for the current visual block is generated from data of a previously decoded block of the current frame or picture; the motion compensation unit 215 determines prediction information for the current block by parsing the motion vector and other associated syntax elements, and uses the prediction information to generate a prediction block for the current block; a decoded reconstructed block is formed by summing the residual block from the inverse transform unit 212 and the inverse quantization unit 213 with the corresponding prediction block generated by the intra-frame prediction unit 214 or the motion compensation unit 215; the decoded reconstructed block passes through the loop filter unit 216 to remove blocking artifacts, thereby improving video quality; the decoded reconstructed block is then stored in the decoded image cache unit 217, which stores reference images for subsequent intra-frame prediction or motion compensation, and is also used for outputting the video signal to obtain the restored original video signal.

[0053] Among them, block division information, various modes and parameter information of prediction, transformation, and quantization, coefficients, etc. are written into the bitstream through entropy coding. Assuming that the probabilities of different elements are different, shorter codewords are assigned to elements with a higher probability of occurrence, and longer codewords are assigned to elements with a lower probability of occurrence, which can achieve higher coding efficiency than fixed-length coding. However, if the probabilities of different elements are similar or basically the same, the compression space of entropy coding is limited. Context-based adaptive binary arithmetic coding (CABAC) is a commonly used entropy coding method. HEVC and VVC both use CABAC for entropy coding. CABAC uses a context model to improve compression efficiency. The context model provides an estimated probability for the current syntax element. The system encodes and decodes the current syntax element based on this estimated probability, and updates the context model based on the value of the current syntax element.

[0054] The embodiment of the present application provides an encoding method that is mainly used in the encoding unit 119 of the video encoding system 11 to encode syntax elements. The embodiment of the present application provides a decoding method that is mainly used in the decoding unit 211 of the video decoding system 21 to decode syntax elements.

[0055] Based on this, the technical solution of this application is further described in detail below with reference to the accompanying drawings and embodiments. Before proceeding with the detailed description, it should be noted that the terms "first", "second", "third", etc. mentioned throughout the specification are only used to distinguish different features and do not have the function of defining priority, sequence, size relationship, etc.

[0056] The present application provides an encoding method for use in a video encoding device, i.e., an encoder. The functions implemented by the method can be implemented by a processor in the video encoding device calling program code. The program code can also be stored in a computer storage medium. Therefore, the video encoding device includes at least a processor and a storage medium.

[0057] FIG3 is a flow chart of an encoding method provided in an embodiment of the present application. The method is applied to an encoder. As shown in FIG3 , the method includes:

[0058] Step 301: Selecting a plurality of encoded related blocks corresponding to a current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block;

[0059] In the embodiment of the present application, the multiple related blocks refer to at least three related blocks. The related blocks can be understood as image blocks that are spatially correlated with the current block and are used to determine the context model of the syntax elements of the current block. The encoded related blocks can also be understood as reconstructed blocks reconstructed by the encoder.

[0060] In practical applications, the size of the related blocks may be consistent with or inconsistent with the size of the current block, depending on the image block division method. FIG4 is a first schematic diagram of the selection position of the related blocks in an embodiment of the present application. As shown in FIG4 , the related blocks are the adjacent blocks on the left, upper, and upper-left sides of the current block, and the sizes of the related blocks and the current block are consistent. FIG5 is a second schematic diagram of the selection position of the related blocks in an embodiment of the present application. As shown in FIG5 , the related blocks are the adjacent blocks on the left, upper, and upper-left sides of the current block, and the sizes of the related blocks and the current block are inconsistent.

[0061] In some embodiments, the predetermined area includes adjacent areas of the current block and / or non-adjacent areas of the current block; when the predetermined area includes adjacent areas of the current block, the related blocks include adjacent blocks of the current block; when the predetermined area includes non-adjacent areas of the current block, the related blocks include non-adjacent blocks of the current block. It should be noted that not only adjacent blocks are spatially correlated with the current block, but also closely spaced non-adjacent blocks. This is also easy to understand, as all content within the predetermined area is correlated. That is, in addition to using spatially adjacent blocks, closely spaced non-adjacent blocks can also be used, or both adjacent and non-adjacent blocks can be used, to reference a sufficient number of relevant blocks to select a context model for the current block. In this way, by setting a larger predetermined area to select more relevant blocks for the current block, the spatial correlation of image blocks is fully utilized. A more suitable context model is matched to the first syntax element of the current block based on more relevant blocks, thus preventing accidental influences on the context model selection. To give an extreme example, a large area around the current block uses mode 1, but mode 2 is selected in some adjacent blocks. If some adjacent blocks are selected to determine the context model of the current block, then the current block will not know that many related areas have selected mode 1, which will affect the mode selection of the current block.

[0062] Specifically, multiple adjacent blocks may be selected as related blocks of the current block, multiple non-adjacent blocks may be selected as related blocks of the current block, or multiple adjacent blocks and non-adjacent blocks may be selected as related blocks of the current block.

[0063] FIG6 is a third schematic diagram of the selection position of the relevant blocks in an embodiment of the present application. In addition to the left adjacent block and the upper adjacent block, adjacent blocks determined by other positions may also be used. An example is shown in FIG6 . The current block is a block containing reference coordinates (x0, y0). Taking the reference coordinates (x0, y0) as the coordinates of the upper left corner of the current block as an example, block0 is a neighboring block containing reference coordinates (x0-1, y0), block1 is a neighboring block containing reference coordinates (x0, y0-1), and block2 is a neighboring block containing reference coordinates (x0-1, y0-1). block3 is the adjacent block containing the reference coordinates (x0-1, y0+cbHeight-1), block4 is the adjacent block containing the reference coordinates (x0+cbWidth-1, y0-1), block5 is the adjacent block containing the reference coordinates (x0+cbWidth-1, y0-1), and block6 is the adjacent block containing the reference coordinates (x0+cbWidth, y0-1), where (x0, y0) is the coordinate of the upper left corner of the current block, cbWidth is the width of the current block, and cbHeight is the height of the current block.

[0064] Figure 7 is a fourth schematic diagram of the selection position of relevant blocks in an embodiment of the present application. Furthermore, more spatial adjacent blocks can be used, that is, in addition to selecting adjacent blocks from the 7 adjacent blocks shown in Figure 6, one or more adjacent blocks between block1 and block5 in Figure 7 (that is, the area indicated by "...") and one or more adjacent blocks between block0 and block3 (that is, the area indicated by "...") can also be selected to determine the context model of the current block syntax element.

[0065] FIG8 is a fifth schematic diagram of the selection position of related blocks in an embodiment of the present application. Further, more spatially non-adjacent blocks can be used to select related blocks from the non-adjacent areas shown in FIG8 , or related blocks can be selected from both non-adjacent areas and adjacent areas. The selection position of the related blocks can be pre-set.

[0066] In practice, a search range and search conditions can be set to determine the predetermined area. For example, a variable named searchRange can be set, with the search range being from x0-searchRange to x0+searchRange for the horizontal coordinate and from y0-searchRange to y0+searchRange for the vertical coordinate. The search condition is an encoded block, with (x0, y0) being the coordinates of the upper left corner of the current block. The predetermined area is searched for encoded blocks as related blocks of the current block. This means that the predetermined area can include both encoded and bit-encoded areas.

[0067] In actual applications, the correlation strength between the relevant block and the current block is the same or different. Exemplarily, the method further includes: configuring the weight of the relevant block according to the strength of the correlation between the relevant block and the current block; determining the context model index parameter based on the weight of the relevant block and the reference information of the relevant block. For example, for adjacent blocks, the closer to the upper left corner of the current block, the stronger the correlation, and vice versa. For adjacent blocks and non-adjacent blocks, the closer to the current block, the stronger the correlation, and vice versa. If the relevant block uses non-adjacent blocks, one method is to set different weights for the non-adjacent blocks. In this way, considering the strength of spatial correlation, the accuracy of context model selection can be further improved by setting the weight of the relevant blocks.

[0068] In some embodiments, the method further comprises: configuring a weight of the related block based on a distance between the related block and the current block. In practical applications, the distance may be a horizontal distance, a vertical distance, or a straight-line distance.

[0069] In some embodiments, the method further comprises: configuring a weight of the related block based on a reference coordinate of the related block and a reference coordinate of the current block.

[0070] In some embodiments, the method further includes: determining a first sub-region where the relevant block is located; wherein the first sub-region is at least one of at least two second sub-regions contained in the predetermined region; and configuring the weight of the relevant block based on the first sub-region where the relevant block is located.

[0071] Specifically, the method further includes: dividing the predetermined area into at least two second sub-areas; and configuring a weight for each second sub-area.

[0072] Exemplarily, configuring the weight of the related block based on the first sub-region in which the related block is located includes: when the first sub-region contains two or more second sub-regions, performing a fusion operation on the weights of the second sub-regions to obtain the weight of the first sub-region; and configuring the weight of the related block as the weight of the first sub-region. Exemplarily, the fusion operation may be a weighted operation, an averaging operation, etc.

[0073] Exemplarily, configuring the weight of the relevant block based on the first sub-region in which the relevant block is located includes: when the first sub-region contains a second sub-region, configuring the weight of the first region as the weight of the second sub-region; and configuring the weight of the relevant block as the weight of the first sub-region. That is, configuring the weight of the relevant block as the weight of the second sub-region.

[0074] Exemplarily, the predetermined area can be divided into at least two sub-areas using at least two concentric rings. Specifically, the position information of each ring is pre-set, and based on the position information of the relevant block x, it is determined that the position information of the Lith ring matches the position information of the relevant block x, and the relevant block X is determined to be located in the Lith ring.

[0075] Here, the position information matches, which may be that the position information of the Li-th ring includes the position information of the related block x, or the distance between the Li-th ring and the related block x is less than a preset distance threshold.

[0076] Figure 9 is a fifth schematic diagram of the selected positions of related blocks in an embodiment of the present application. Blocks 0 to 6 are adjacent blocks, and blocks numbered greater than 6 are non-adjacent blocks. One method for locating these blocks is to configure the spacing of concentric rings using the current block size as the interval length to set the position information of each ring. Taking Figure 9 as an example, concentric rings L0-L4 are represented. When the position information of the Lith ring includes the position information of the related block x, the related block X is determined to be located in the Lith ring. The position information of the related block x is the reference coordinate. The position information of each ring includes coordinate information used to describe the edges of the rectangle. The position information of each ring includes: a first horizontal coordinate and its corresponding vertical coordinate value range, a second horizontal coordinate and its corresponding vertical coordinate value range, a first vertical coordinate and its corresponding horizontal coordinate value range, and a second horizontal coordinate and its corresponding horizontal coordinate value range. The four sides of each ring are formed by two lines with a left and right distance of n*cbWidth from the current block, and two lines with a top and bottom distance of n*cbHeight from the current block. For example, block 9 in the figure is determined by the coordinates (x0-cuWidth, y0-cuHeight), the n corresponding to the first ring L1 is 1, and the n corresponding to the second ring L2 is 2. Block 14 in the figure is determined by the coordinates (x0-2*cuWidth, y0-2*cuHeight).

[0077] For example, the weight of the 0th ring L0 is set to 1, that is, the weight of the adjacent blocks located in the 0th ring L0 is set to 1, the weight of the first ring L1 is set to 1 / 2, the weight of the second ring L2 is set to 1 / 4, the weight of the third ring L3 is set to 1 / 8, the weight of the fourth ring L4 is set to 1 / 16, etc. It should be noted that this is only an exemplary method for setting weights and is not intended to limit this application. In actual applications, different weights can be set for the same ring, or weights can be set in combination with video image features.

[0078] In some embodiments, selecting multiple encoded related blocks corresponding to the current block from a predetermined area includes: determining the reference coordinates of the related blocks within the predetermined area based on the reference coordinates of the current block; and obtaining reference information of the related blocks based on the reference coordinates of the related blocks.

[0079] In some embodiments, the method further includes: acquiring reference information of the relevant blocks based on a preset selection order and reference coordinates of the relevant blocks.

[0080] Here, the reference coordinates are used to locate the current block and related blocks. The reference coordinates can be at least one of the following: the coordinates of the upper left corner of the block, the coordinates of the lower left corner of the block, the coordinates of the upper right corner of the block, the coordinates of the lower right corner of the block, the coordinates of the center of the block, etc. The selection order is used to set the order in which multiple related blocks are selected. For example, the selection order can be to search from the current block as the center and radiate outward, or to search from left to right and from top to bottom within the search area according to a certain search granularity.

[0081] By using any of the above methods, more relevant blocks can be found, and the encoded information of these relevant blocks is used to select a context model for the first syntax element of the current block.

[0082] Step 302: Determine a context model index parameter of a first syntax element of the current block based on reference information of the multiple related blocks;

[0083] For example, the value of the context model index (ctxIdx) is equal to the sum of the context model index increment (ctxInc) and the context model index offset (ctxIdxOffset). It can be considered that ctxIdxOffset is used to classify context models into different groups, while ctxInc is used to select a context model within the group.

[0084] Here, the reference information of the relevant block is used to indicate the context model selected when encoding the first syntax element of the relevant block. Exemplarily, in some embodiments, the reference information of the relevant block includes: a context model index reference amount of the first syntax element of the relevant block. In other embodiments, the reference information of the relevant block also includes: an available flag of the relevant block. The available flag is used to indicate whether the context model index reference amount of the relevant block can be used to determine the context model index reference amount of the current block.

[0085] In some embodiments, determining the context model index parameter of the first syntax element of the current block based on the reference information of the multiple related blocks includes: determining the context model index offset corresponding to the first syntax element; determining the context model index increment of the first syntax element of the current block based on the reference information of the multiple related blocks; determining the context model index of the first syntax element based on the context model index increment and the context model index offset; and setting the context model index parameter to be equal to the context model index.

[0086] It should be noted that the current block includes multiple syntax elements, the first syntax element refers to one of the multiple syntax elements of the current block, the context model corresponding to the context model index can be understood as the context model corresponding to the first syntax element, each syntax element corresponds to two or more context models, and when encoding the first syntax element of the current block, a matching context model is selected for the first syntax element of the current block based on the same syntax element of the related block. In this embodiment of the present application, the number of context models can be increased to select a more matching context model for the syntax element, thereby further improving compression efficiency.

[0087] Illustratively, for the syntax elements alf_ctb_flag[cIdx][xCtb][yCtb], alf_ctb_cc_cb_idc[xCtb][yCtb], alf_ctb_cc_cr_idc[xCtb][yCtb], split_qt_flag, split_cu_flag, cu_skip_flag[x0][y0], pred_mode_ibc_flag[x0][y0], intra_mip_flag, inter_affine_flag[x0][y0] and merge_subblock_flag[x0][y0], VVC has 3 context models or a group has 3 context models, and for the syntax elements pred_mode_flag[x0][y0] and non_inter_flag, VVC has 2 context models.

[0088] Exemplarily, in some embodiments, the method further includes: determining a first context model list used when selecting the context model of the first grammatical element; and setting the context model index parameter to an index of the first context model list.

[0089] When multiple context model lists are preset to map context models, each context model list contains multiple context models. ctxTable is used to represent the context model list used when selecting a context model, and ctxIdx is used to index a context model in the context model list.

[0090] When parsing different syntax elements, it is necessary to use the context model corresponding to the syntax element, that is, the corresponding ctxTable and ctxIdx. Table 1 defines that syntax elements (syntax element) encoded using the context model can find the corresponding ctxTable in this table. Among them, ctxIdxOffset is the minimum value of ctxIdx in the current initType in Table 1. initType is related to the slice type (I slice, P slice, B slice) and some flags, which will not be repeated here. It can be considered that ctxIdxOffset is to first classify the context models into different groups, and ctxInc is to select a context model within the group.

[0091] For example, for the syntax element alf_ctb_flag[][][] in Table 1, the index of the corresponding first context model list is Table 52 (Table52), and for the syntax element alf_use_aps_flag, the index of the corresponding first context model list is Table 53 (Table53).

[0092] Table 1

[0093]

[0094] Step 303: Encode the first syntax element of the current block based on the context model corresponding to the context model index parameter.

[0095] It should be noted that a syntax element may have one or more binary symbols (bin), and generally a flag has only one binary symbol because a flag usually has only two options. Each binary symbol may have one or more context models, that is, corresponding to one or more ctxIdx. When a binary symbol has multiple context models, it is necessary to select the most matching context model from multiple context models for encoding, thereby improving encoding efficiency. The premise of selecting a context model in the embodiment of the present application is that the binary symbol is encoded using a context model. In the embodiment of the present application, unless otherwise specified, the binary symbols refer to binary symbols encoded by the context model.

[0096] The following is a further example illustrating the method for determining the context model index increment.

[0097] The syntax elements of the relevant blocks refer to the encoded syntax elements of the relevant blocks. Since the encoding end includes encoding and decoding processes, the encoded syntax elements can also be understood as decoded syntax elements.

[0098] In some embodiments, determining the context model index increment of the first grammatical element of the current block based on the reference information of the multiple related blocks includes: determining a first intermediate quantity based on the reference information of the multiple related blocks; converting the first intermediate quantity based on a preset conversion algorithm to obtain the context model index increment of the first grammatical element of the current block.

[0099] In some embodiments, the reference information of the relevant block includes: an available identifier of the first grammatical element of the relevant block and a context model index reference quantity, and determining the first intermediate quantity based on the reference information of the multiple relevant blocks includes: performing an AND operation on the available identifier and the context model index reference quantity of each relevant block to obtain an AND operation result; and obtaining the first intermediate quantity based on the AND operation result of each relevant block.

[0100] Furthermore, a preset conversion algorithm is used to convert the first intermediate variable into a matching context index increment. In some embodiments, the preset conversion algorithm includes one of the following: setting the first intermediate variable equal to the context model index increment; dividing the first intermediate variable by a first reference variable to obtain the context model index increment; right-shifting the first intermediate variable by a second reference variable to obtain the context model index increment; determining a first value range within which the first intermediate variable falls, and using the index increment corresponding to the first value range as the context model index increment.

[0101] Exemplarily, taking the VVC format as an example, the context model index reference amount can be expressed by the judgment condition for selecting the context model. In the embodiment of the present application, availableN is used to indicate whether the Nth related block is available and the judgment condition, and conditionN (abbreviated as condN) is used to indicate the judgment condition of the Nth related block corresponding to the first syntax element.

[0102] Exemplarily, a first intermediate quantity (tempValue) is set. tempValue is initialized to 0. The coded syntax elements of the xth related block are availablex and condx, where x ranges from 0 to N. The following operation is performed from 0 to N: tempValue += availablex && condx, where N is 6 as shown in FIG6 . When using a different number of related blocks, the corresponding value can be replaced. tempValue can be understood as an intermediate variable in the accumulation process. When x=N, tempValue is the final first intermediate quantity.

[0103] Specifically, the current block coordinates (xCurr, yCurr) are set to (x0, y0), and the coordinates of the left adjacent block (xNbL, yNbL) are set to (x0-1, y0). Based on (xNbL, yNbL), (x0, y0), and cIdx, the availability of the left adjacent block is deduced and the result is assigned to availableL. AvailableL indicates whether the left adjacent block is available.

[0104] The coordinates of the upper neighboring block (xNbA, yNbA) are set to (x0, y0-1). Based on (xNbA, yNbA), (x0, y0), and cIdx, the availability of the upper neighboring block is deduced and the result is assigned to availableA. AvailableA indicates whether the upper neighboring block is available.

[0105] Set the coordinates (xNbN, yNbN) of the Nth relevant block to (x0 - Nx, y0 - Ny). Based on (x0 - Nx, y0 - Ny), (x0, y0), and the current block coordinates (xCurr, yCurr) as the input of cIdx, cIdx derives whether the left - hand relevant block is available and assigns the result to availableN. AvailableN indicates whether the Nth relevant block is available.

[0106] Table 2 defines the specification of determining ctxInc for the left - hand adjacent block and the upper - hand adjacent block's syntax elements. In Table 2, the judgment conditions corresponding to each syntax element for the left - hand adjacent block and the upper - hand adjacent block are defined. It should be noted that in the embodiments of this application, in addition to using the left - hand adjacent block and the upper - hand adjacent block, other relevant blocks are added, that is, sufficient relevant blocks with spatial correlation to the current block are used for context model selection. It is necessary to add the judgment conditions (condN) for more relevant blocks based on Table 2. If there are multiple context model groups, the context model group index (ctxSetIdx) also needs to be added.

[0107] In a possible implementation, when encoding the first syntax element, after determining that the relevant block is available, the judgment conditions of the relevant block are determined by looking up a table. After determining that the relevant block is unavailable, there is no need to obtain the judgment conditions of the relevant block.

[0108] Table 2 [[ID=eleven]]

[0109]

[0110] Then match ctxInc. A possible method is ctxInc = tempValue. Or ctxInc = tempValue / M1, where M1 is an integer. For example, M1 is configured as 1, 2, 3, 4, or 5 according to the context model. Or ctxInc = tempValue >> M2, where >> represents right - shift. Because in hardware implementation, the cost of right - shift is much smaller than that of division. Or it can be written in the form of ctxInc = tempValue < THR0? 0 : (tempValue < THR1? 1 : 2). THR0 and THR1 are thresholds. Using 2 thresholds divides tempValue into three value ranges, that is, tempValue < THR0, THR0 ≤ tempValue < THR1, THR1 ≤ tempValue. In practical applications, one threshold can be used to divide tempValue into two value ranges, or multiple thresholds can be used to subdivide tempValue into more value ranges.

[0111] In some embodiments, the reference information of the relevant block includes: the availability flag of the first syntax element of the relevant block and the context model index reference quantity.

[0112] The method of determining the first intermediate quantity based on the reference information of the multiple related blocks includes: obtaining the weights of the multiple related blocks; performing an AND operation on the available identifier of each related block and the context model index reference quantity to obtain an AND operation result; performing a weighted operation on the AND operation result of each related block based on the weights of the multiple related blocks; and obtaining the first intermediate quantity based on the weighted result of each related block.

[0113] In practical applications, the first intermediate quantity is obtained by performing a sum operation on the weighted results, performing an OR operation on the weighted results, and performing an AND operation on the weighted results.

[0114] Exemplarily, a first intermediate value (tempValue) is set. tempValue is initialized to 0, and the coded syntax elements of the x-th related block are availablex and condx, where x ranges from 0 to N. The following operation is performed from 0 to N: tempValue += (availablex && condx) * weightx. Taking FIG9 as an example, N is 24, and can be replaced with a corresponding value when using a different number of blocks. Weightx can be determined based on the position of the related block x, such as by determining the ring in which the related block x is located, as mentioned above.

[0115] Exemplarily, the position information of each ring is pre-set, and based on the position information of the related block x, it is determined that the position information of the Li-th ring matches the position information of the related block x, and the related block X is determined to be located in the Li-th ring. Taking FIG9 as an example, when the position information of the Li-th ring includes the position information of the related block x, the related block X is determined to be located in the Li-th ring, where the position information of the related block x is the reference coordinate, and the position information of each ring includes coordinate information used to describe the sides of the rectangle, and the position information of each ring includes: a first horizontal coordinate and its corresponding vertical coordinate value range, a second horizontal coordinate and its corresponding vertical coordinate value range, a first vertical coordinate and its corresponding horizontal coordinate value range, and a second horizontal coordinate and its corresponding horizontal coordinate value range.

[0116] Then match ctxInc. A possible method is ctxInc = tempValue. Or ctxInc = tempValue / M1, where M1 is an integer. For example, M1 is configured as 1, 2, 3, 4, or 5 according to the context model. Or ctxInc = tempValue >> M2, where >> represents a right shift, because the cost of a right shift is much lower than that of division in hardware implementation. Or it can be written in the form of ctxInc = tempValue < THR0? 0 : (tempValue < THR1? 1 : 2). THR0 and THR1 are thresholds. By using two thresholds, tempValue is divided into three value ranges, namely tempValue < THR0, THR0 ≤ tempValue < THR1, and THR1 ≤ tempValue. In practical applications, tempValue can be divided into two value ranges by using one threshold, or be subdivided into more value ranges by using multiple thresholds.

[0117] In some embodiments, when the first syntax element corresponds to multiple context model groups, determining the context model index increment of the first syntax element of the current block based on the reference information of the multiple related blocks includes: determining a first intermediate quantity based on the reference information of the multiple related blocks; determining a second intermediate quantity based on the context model group index corresponding to the first syntax element and the number of context models in each context model group; obtaining a third intermediate quantity by converting the first intermediate quantity based on a preset conversion algorithm; and obtaining the context model index increment of the first syntax element of the current block based on the second intermediate quantity and the third intermediate quantity.

[0118] That is to say, a syntax element can directly correspond to one or more context models, or correspond to one or more context model groups, and each context model group includes multiple context models. When the first syntax element corresponds to multiple context model groups, the third intermediate quantity is used to index a context model in a certain context model group. Therefore, it is also necessary to determine the second intermediate quantity according to the context model group index and the number of context models. The second intermediate quantity serves as the offset of the context model group and is used to index the first context model in the context model group. The sum of the second intermediate quantity and the third intermediate quantity is the context model index increment, which is used to determine a context model in a context model group.

[0119] Exemplarily, when setting context model groups for some syntax elements, ctxInc += ctxSetIdx * P, where ctxSetIdx is the index of the context model group, ctxSetIdx can take values such as 0, 1, 2, 3, etc., and P is the number of context models in the context model group, and P can take values such as 2, 3, 4, 5, etc.

[0120] Illustratively, for the syntax elements alf_ctb_flag[cIdx][xCtb][yCtb], alf_ctb_cc_cb_idc[xCtb][yCtb], alf_ctb_cc_cr_idc[xCtb][yCtb], split_qt_flag, split_cu_flag, cu_skip_flag[x0][y0], pred_mode_ibc_flag[x0][y0], intra_mip_flag, inter_affine_flag[x0][y0] and merge_subblock_flag[x0][y0], VVC has 3 context model groups, with one group having 3 context models.

[0121] By adopting the above technical solution, by setting a larger predetermined area to select more relevant blocks for the current block, the spatial correlation of the image blocks is fully utilized, and a more suitable context model can be matched for the first syntax element of the current block, thereby improving the compression efficiency of the syntax element and thus improving the compression efficiency of the entire system.

[0122] The following is an introduction using CABAC in VVC as an example. The processing of CABAC mainly includes binarization, context modeling and binary arithmetic coding. Among them, binarization refers to binary processing of the input non-binary syntax element value, and converting it uniquely into a binary sequence (i.e., binary string); context modeling refers to determining the context model of each bit in the binary string according to the context information (for example, the coding information in the reconstructed area around the corresponding node of the syntax element); binary arithmetic coding refers to encoding the corresponding bit according to the probability value in the context model, and updating the probability value in the context model according to the value of the bit. The embodiment of the present application is used to implement the selection of the context model of each bit in the binary string of the first syntax element, and determine the corresponding context model according to the determined context model index.

[0123] After determining the context model, the parameters of the context model are used as input to call the arithmetic decoding process of the binary symbol.

[0124] The input of the arithmetic decoding process of a binary symbol is the parameters of the context model (ctxTable and ctxIdx), the bypass decoding flag (bypassFlag), and the state variables ivlCurrRange and ivlOffset of the arithmetic decoding engine. The output of this process is the value of this binary symbol (bin).

[0125] Figure 10 shows the entire arithmetic decoding process for a binary symbol in an embodiment of the present application. To decode the value of this bin, ctxTable, ctxIdx, and bypassFlag are passed as input to the binary symbol decoding part DecodeBin(ctxTable, ctxIdx, bypassFlag), as follows:

[0126] If the value of bypassFlag is 1, call bypass decoding DecodeBypass();

[0127] The value of bypassFlag is 0. If the value of bypassFlag is 0, the value of ctxTable is 0, and the value of ctxIdx is 0, call DecodeTerminate() to terminate decoding;

[0128] If the value of bypassFlag is 0 and the value of ctxTable is not 0, call the decoding decision DecodeDecision(ctxTable,ctxIdx).

[0129] Figure 11 shows the decoding decision process of a binary symbol in an embodiment of the present application. The input of the decoding decision DecodeDecision(ctxTable, ctxIdx) process is the variables ctxTable, ctxIdx, ivlCurrRange, and ivlOffset. The output of this process is the decoded value binVal, and the updated variables ivlCurrRange and ivlOffset.

[0130] 1. The value of the variable ivlLpsRange is derived as follows:

[0131] Given the current value of ivlCurrRange, the variable qRangeIdx is derived as follows:

[0132] qRangeIdx=ivlCurrRange>>5

[0133] Given qRangeIdx, ctxTable and pStateIdx0 and pStateIdx1 corresponding to ctxIdx, where ctxTable is the table used when selecting the context mode, ctxIdx is the context model index, and pStateIdx0 and pStateIdx1 are the two states of the current context model. valMps and ivlLpsRange are derived as follows:

[0134] pState=pStateIdx1+16*pStateIdx0

[0135] valMps=pState>>14

[0136] ivlLpsRange=(qRangeIdx*((valMps?32767-pState:pState)>>9)>>1)+4

[0137] 2. Set the value of the variable ivlCurrRange to ivlCurrRange – ivlLpsRange and perform the following operations:

[0138] If ivlOffset is greater than or equal to ivlCurrRange, the value of the variable binVal is 1–valMps, ivlOffset is less than or equal to ivlCurrRange, and the value of ivlCurrRange is ivlLpsRange.

[0139] Otherwise, the value of the variable binVal is valMps

[0140] Performs a state transition given the value of binVal. Performs a renormalization based on the current value of ivlCurrRange.

[0141] The state transition process takes the current pStateIdx0 and pStateIdx1 as input, and the solved value binVal as output. The output of this process is the updated ctxTable and the context variables pStateIdx0 and pStateIdx1 corresponding to ctxIdx.

[0142] The variables shift0 and shift1 are derived from shiftIdx, and shiftIdx is determined by the correspondence between shiftIdx, ctxTable, and ctxIdx.

[0143] shift0=(shiftIdx>>2)+2

[0144] shift1=(shiftIdx&3)+3+shift0

[0145] Based on the solved value binVal, the two variables pStateIdx0 and pStateIdx1 corresponding to ctxTable and ctxIdx are updated as follows

[0146] pStateIdx0=pStateIdx0-(pStateIdx0>>shift0)+(1023*binVal>>shift0)

[0147] pStateIdx1=pStateIdx1-(pStateIdx1>>shift1)+(16383*binVal>>shift1)

[0148] FIG12 shows a renormalization process in an embodiment of the present application. The input of this process is the bits in the slice data and the variables ivlCurrRange and ivlOffset. The output of this process is the updated variables ivlCurrRange and ivlOffset.

[0149] The current value of ivlCurrRange is first compared to 256, and the subsequent steps are as follows:

[0150] If ivlCurrRange is greater than or equal to 256, no renormalization is required and the renormalization process ends;

[0151] Otherwise (ivlCurrRange is less than 256), enter the renormalization loop. In this loop, the value of ivlCurrRange is multiplied by 2, that is, it is shifted left by one bit. The value of ivlOffset is multiplied by 2, that is, it is shifted left by one bit. The bit obtained by read_bits(1) is transferred to ivlOffset.

[0152] During this process, the data in the codestream should not cause ivlOffset to be greater than or equal to ivlCurrRange.

[0153] Figure 13 shows the bypass decoding DecodeBypass() process of a binary symbol in an embodiment of the present application. The input of this process is the bits of the slice data, the variables ivlCurrRange and ivlOffset, and the output of this process is the updated variable ivlOffset and the solved value binVal.

[0154] When bypassFlag is 1, the bypass decoding process is called. The bypass decoding process is as follows:

[0155] First, the value of ivlOffset is multiplied by 2, which is a left shift. The bit obtained by read_bits(1) is then transferred to ivlOffset. The value of ivlOffset is then compared with the value of ivlCurrRange. The subsequent steps are as follows:

[0156] If ivlOffset is greater than or equal to ivlCurrRange, the value of binVal is set to 1, and ivlOffset is subtracted from or equal to ivlCurrRange.

[0157] Otherwise (ivlOffset is less than ivlCurrRange), the value of binVal is set to 0.

[0158] During this process, the data in the codestream should not cause ivlOffset to be greater than or equal to ivlCurrRange.

[0159] Figure 14 shows the DecodeTerminate() process in an embodiment of the present invention. The input of this process is bits in the slice data and the variables ivlCurrRange and ivlOffsel. The output of this process is the updated ivlCurrRange and ivlOffsel, as well as the decoded value binVal.

[0160] First, the value of ivlCurrRange is reduced by 2;

[0161] If ivlOffset is greater than or equal to ivlCurrRange, the value of binVal is set to 1.

[0162] Otherwise (ivlOffset is less than ivlCurrRange), the value of binVal is set to 0 and the renormalization process is performed.

[0163] The present application also provides a decoding method. FIG15 is a flowchart of the decoding method provided by the present application embodiment, which is applied to a decoder. As shown in FIG15 , the method includes:

[0164] Step 1501: Decode the code stream to obtain information to be decoded of the first syntax element of the current block;

[0165] Step 1502: Selecting multiple decoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block;

[0166] In the embodiment of the present application, the multiple related blocks refer to at least three related blocks. The related blocks can be understood as image blocks that are spatially correlated with the current block and are used to determine the context model of the syntax elements of the current block. The decoded related blocks can also be understood as reconstructed blocks reconstructed by the decoding end.

[0167] In practical applications, the size of the related blocks may be consistent with or inconsistent with the size of the current block, depending on the image block division method. FIG4 is a first schematic diagram of the selection position of the related blocks in an embodiment of the present application. As shown in FIG4 , the related blocks are the adjacent blocks on the left, upper, and upper-left sides of the current block, and the sizes of the related blocks and the current block are consistent. FIG5 is a second schematic diagram of the selection position of the related blocks in an embodiment of the present application. As shown in FIG5 , the related blocks are the adjacent blocks on the left, upper, and upper-left sides of the current block, and the sizes of the related blocks and the current block are inconsistent.

[0168] In some embodiments, the predetermined area includes adjacent areas of the current block and / or non-adjacent areas of the current block; when the predetermined area includes adjacent areas of the current block, the related blocks include adjacent blocks of the current block; when the predetermined area includes non-adjacent areas of the current block, the related blocks include non-adjacent blocks of the current block. It should be noted that not only adjacent blocks are spatially correlated with the current block, but also closely spaced non-adjacent blocks. This is also easy to understand, as all content within the predetermined area is correlated. That is, in addition to using spatially adjacent blocks, closely spaced non-adjacent blocks can also be used, or both adjacent and non-adjacent blocks can be used, to reference a sufficient number of relevant blocks to select a context model for the current block. In this way, by setting a larger predetermined area to select more relevant blocks for the current block, the spatial correlation of image blocks is fully utilized. A more suitable context model is matched to the first syntax element of the current block based on more relevant blocks, thus preventing accidental influences on the context model selection.

[0169] Specifically, multiple adjacent blocks may be selected as related blocks of the current block, multiple non-adjacent blocks may be selected as related blocks of the current block, or multiple adjacent blocks and non-adjacent blocks may be selected as related blocks of the current block, as shown in FIG6-FIG8.

[0170] In actual applications, the correlation strength between the relevant block and the current block is the same or different. Exemplarily, the method further includes: configuring the weight of the relevant block according to the strength of the correlation between the relevant block and the current block; determining the context model index parameter based on the weight of the relevant block and the reference information of the relevant block. For example, for adjacent blocks, the closer to the upper left corner of the current block, the stronger the correlation, and vice versa. For adjacent blocks and non-adjacent blocks, the closer to the current block, the stronger the correlation, and vice versa. If the relevant block uses non-adjacent blocks, one method is to set different weights for the non-adjacent blocks. In this way, considering the strength of spatial correlation, the accuracy of context model selection can be further improved by setting the weight of the relevant blocks.

[0171] In some embodiments, the method further comprises: configuring a weight of the related block based on a distance between the related block and the current block. In practical applications, the distance may be a horizontal distance, a vertical distance, or a straight-line distance.

[0172] In some embodiments, the method further comprises: configuring a weight of the related block based on a reference coordinate of the related block and a reference coordinate of the current block.

[0173] In some embodiments, the method further includes: determining a first sub-region where the relevant block is located; wherein the first sub-region is at least one of at least two second sub-regions contained in the predetermined region; and configuring the weight of the relevant block based on the first sub-region where the relevant block is located.

[0174] Specifically, the method further includes: dividing the predetermined area into at least two second sub-areas; and configuring a weight for each second sub-area.

[0175] Exemplarily, configuring the weight of the related block based on the first sub-region in which the related block is located includes: when the first sub-region contains two or more second sub-regions, performing a fusion operation on the weights of the second sub-regions to obtain the weight of the first sub-region; and configuring the weight of the related block as the weight of the first sub-region. Exemplarily, the fusion operation may be a weighted operation, an averaging operation, etc.

[0176] Exemplarily, configuring the weight of the relevant block based on the first sub-region in which the relevant block is located includes: when the first sub-region contains a second sub-region, configuring the weight of the first region as the weight of the second sub-region; and configuring the weight of the relevant block as the weight of the first sub-region. That is, configuring the weight of the relevant block as the weight of the second sub-region.

[0177] Exemplarily, the predetermined area can be divided into at least two sub-areas using at least two concentric rings. Specifically, the position information of each ring is pre-set, and based on the position information of the relevant block x, it is determined that the position information of the Lith ring matches the position information of the relevant block x, and the relevant block X is determined to be located in the Lith ring.

[0178] Here, the position information matches, which may be that the position information of the Li-th ring includes the position information of the related block x, or the distance between the Li-th ring and the related block x is less than a preset distance threshold.

[0179] Figure 9 is a fifth schematic diagram of the selected positions of related blocks in an embodiment of the present application. Blocks 0 to 6 are adjacent blocks, and blocks numbered greater than 6 are non-adjacent blocks. One method for locating these blocks is to configure the spacing of concentric rings using the current block size as the interval length to set the position information of each ring. Taking Figure 9 as an example, concentric rings L0-L4 are represented. When the position information of the Lith ring includes the position information of the related block x, the related block X is determined to be located in the Lith ring. The position information of the related block x is the reference coordinate. The position information of each ring includes coordinate information used to describe the edges of the rectangle. The position information of each ring includes: a first horizontal coordinate and its corresponding vertical coordinate value range, a second horizontal coordinate and its corresponding vertical coordinate value range, a first vertical coordinate and its corresponding horizontal coordinate value range, and a second horizontal coordinate and its corresponding horizontal coordinate value range. The four sides of each ring are formed by two lines with a left and right distance of n*cbWidth from the current block, and two lines with a top and bottom distance of n*cbHeight from the current block. For example, block 9 in the figure is determined by the coordinates (x0-cuWidth, y0-cuHeight), the n corresponding to the first ring L1 is 1, and the n corresponding to the second ring L2 is 2. Block 14 in the figure is determined by the coordinates (x0-2*cuWidth, y0-2*cuHeight).

[0180] For example, the weight of the 0th ring L0 is set to 1, that is, the weight of the adjacent blocks located in the 0th ring L0 is set to 1, the weight of the first ring L1 is set to 1 / 2, the weight of the second ring L2 is set to 1 / 4, the weight of the third ring L3 is set to 1 / 8, the weight of the fourth ring L4 is set to 1 / 16, etc. It should be noted that this is only an exemplary method for setting weights and is not intended to limit this application. In actual applications, different weights can be set for the same ring, or weights can be set in combination with video image features.

[0181] In some embodiments, selecting multiple decoded related blocks corresponding to the current block from a predetermined area includes: determining the reference coordinates of the related blocks within the predetermined area based on the reference coordinates of the current block; and obtaining reference information of the related blocks based on the reference coordinates of the related blocks.

[0182] In some embodiments, the method further includes: acquiring reference information of the relevant blocks based on a preset selection order and reference coordinates of the relevant blocks.

[0183] Here, the reference coordinates are used to locate the current block and related blocks. The reference coordinates can be at least one of the following: the coordinates of the upper left corner of the block, the coordinates of the lower left corner of the block, the coordinates of the upper right corner of the block, the coordinates of the lower right corner of the block, the coordinates of the center of the block, etc. The selection order is used to set the order in which multiple related blocks are selected. For example, the selection order can be to search from the current block as the center and radiate outward, or to search from left to right and from top to bottom within the search area according to a certain search granularity.

[0184] Step 1503: Determine a context model index parameter of a first syntax element of the current block based on the reference information of the multiple related blocks;

[0185] For example, the value of the context model index (ctxIdx) is equal to the sum of the context model index increment (ctxInc) and the context model index offset (ctxIdxOffset). It can be considered that ctxIdxOffset is used to classify context models into different groups, while ctxInc is used to select a context model within the group.

[0186] Here, the reference information of the relevant block is used to indicate the context model selected when encoding the first syntax element of the relevant block. Exemplarily, in some embodiments, the reference information of the relevant block includes: a context model index reference amount of the first syntax element of the relevant block. In other embodiments, the reference information of the relevant block also includes: an available flag of the relevant block. The available flag is used to indicate whether the context model index reference amount of the relevant block can be used to determine the context model index reference amount of the current block.

[0187] In some embodiments, determining the context model index parameter of the first syntax element of the current block based on the reference information of the multiple related blocks includes: determining the context model index offset corresponding to the first syntax element; determining the context model index increment of the first syntax element of the current block based on the reference information of the multiple related blocks; determining the context model index of the first syntax element based on the context model index increment and the context model index offset; and setting the context model index parameter to be equal to the context model index.

[0188] It should be noted that the current block includes multiple syntax elements, the first syntax element refers to one of the multiple syntax elements of the current block, the context model corresponding to the context model index can be understood as the context model corresponding to the first syntax element, each syntax element corresponds to two or more context models, and when encoding the first syntax element of the current block, a matching context model is selected for the first syntax element of the current block based on the same syntax element of the related block. In this embodiment of the present application, the number of context models can be increased to select a more matching context model for the syntax element, thereby further improving compression efficiency.

[0189] Illustratively, for the syntax elements alf_ctb_flag[cIdx][xCtb][yCtb], alf_ctb_cc_cb_idc[xCtb][yCtb], alf_ctb_cc_cr_idc[xCtb][yCtb], split_qt_flag, split_cu_flag, cu_skip_flag[x0][y0], pred_mode_ibc_flag[x0][y0], intra_mip_flag, inter_affine_flag[x0][y0] and merge_subblock_flag[x0][y0], VVC has 3 context models or a group has 3 context models, and for the syntax elements pred_mode_flag[x0][y0] and non_inter_flag, VVC has 2 context models.

[0190] Exemplarily, in some embodiments, the method further includes: determining a first context model list used when selecting the context model of the first grammatical element; and setting the context model index parameter to an index of the first context model list.

[0191] When multiple context model lists are preset to map context models, each context model list contains multiple context models. ctxTable is used to represent the context model list used when selecting a context model, and ctxIdx is used to index a context model in the context model list.

[0192] When parsing different syntax elements, it is necessary to use the context model corresponding to the syntax element, that is, the corresponding ctxTable and ctxIdx. Table 1 defines that syntax elements (syntax element) encoded using the context model can find the corresponding ctxTable in this table. Among them, ctxIdxOffset is the minimum value of ctxIdx in the current initType in Table 1. initType is related to the slice type (I slice, P slice, B slice) and some flags, which will not be repeated here. It can be considered that ctxIdxOffset is to first classify the context models into different groups, and ctxInc is to select a context model within the group.

[0193] Step 1504: Decode the information to be decoded based on the context model corresponding to the context model index parameter to obtain the first syntax element of the current block.

[0194] It should be noted that a syntax element may have one or more binary symbols (bin), and generally a flag has only one binary symbol because a flag usually has only two options. Each binary symbol may have one or more context models, that is, corresponding to one or more ctxIdx. When a binary symbol has multiple context models, it is necessary to select the most matching context model from multiple context models for encoding, thereby improving encoding efficiency. The premise of selecting a context model in the embodiment of the present application is that the binary symbol is encoded using a context model. In the embodiment of the present application, unless otherwise specified, the binary symbols refer to binary symbols encoded by the context model.

[0195] The following is a further example illustrating the method for determining the context model index increment.

[0196] The syntax elements of the relevant blocks refer to the syntax elements of the decoded relevant blocks. In some embodiments, determining the context model index increment for the first syntax element of the current block based on the reference information of the multiple relevant blocks includes: determining a first intermediate quantity based on the reference information of the multiple relevant blocks; and converting the first intermediate quantity based on a preset conversion algorithm to obtain the context model index increment for the first syntax element of the current block.

[0197] In some embodiments, the reference information of the relevant block includes: an available identifier of the first grammatical element of the relevant block and a context model index reference quantity, and determining the first intermediate quantity based on the reference information of the multiple relevant blocks includes: performing an AND operation on the available identifier and the context model index reference quantity of each relevant block to obtain an AND operation result; and obtaining the first intermediate quantity based on the AND operation result of each relevant block.

[0198] Furthermore, a preset conversion algorithm is used to convert the first intermediate variable into a matching context index increment. In some embodiments, the preset conversion algorithm includes one of the following: setting the first intermediate variable equal to the context model index increment; dividing the first intermediate variable by a first reference variable to obtain the context model index increment; right-shifting the first intermediate variable by a second reference variable to obtain the context model index increment; determining a first value range within which the first intermediate variable falls, and using the index increment corresponding to the first value range as the context model index increment.

[0199] Exemplarily, taking the VVC format as an example, the context model index reference amount can be expressed by the judgment condition for selecting the context model. In the embodiment of the present application, availableN is used to indicate whether the Nth related block is available and the judgment condition, and conditionN (abbreviated as condN) is used to indicate the judgment condition of the Nth related block corresponding to the first syntax element.

[0200] Exemplarily, a first intermediate quantity (tempValue) is set. tempValue is initialized to 0. The decoded syntax elements of the xth related block are availablex and condx, where x ranges from 0 to N. The following operation is performed from 0 to N: tempValue += availablex && condx. Taking FIG6 as an example, N is 6. When using a different number of related blocks, the corresponding value can be replaced. tempValue can be understood as an intermediate variable in the accumulation process. When x = N, tempValue is the final first intermediate quantity.

[0201] Specifically, the current block coordinates (xCurr, yCurr) are set to (x0, y0), and the coordinates of the left adjacent block (xNbL, yNbL) are set to (x0-1, y0). Based on (xNbL, yNbL), (x0, y0), and cIdx, the availability of the left adjacent block is deduced and the result is assigned to availableL. AvailableL indicates whether the left adjacent block is available.

[0202] The coordinates of the upper neighboring block (xNbA, yNbA) are set to (x0, y0-1). Based on (xNbA, yNbA), (x0, y0), and cIdx, the availability of the upper neighboring block is deduced and the result is assigned to availableA. AvailableA indicates whether the upper neighboring block is available.

[0203] Set the coordinates of the Nth related block (xNbN, yNbN) to (x0-Nx, y0-Ny). Based on (x0-Nx, y0-Ny), (x0, y0), and the coordinates of the current block (xCurr, yCurr) are used as cIdx input. cIdx infers whether the left related block is available and assigns the result to availableN. AvailableN indicates whether the Nth related block is available.

[0204] Then match ctxInc. A possible method is ctxInc = tempValue. Or ctxInc = tempValue / M1, where M1 is an integer. For example, M1 is configured as 1, 2, 3, 4, or 5 according to the context model. Or ctxInc = tempValue >> M2, where >> represents a right shift, because the cost of a right shift is much smaller than that of division in hardware implementation. Or it can be written in the form of ctxInc = tempValue < THR0? 0 : (tempValue < THR1? 1 : 2). THR0 and THR1 are thresholds. Using two thresholds divides tempValue into three value ranges, namely tempValue < THR0, THR0 ≤ tempValue < THR1, and THR1 ≤ tempValue. In practical applications, tempValue can be divided into two value ranges using one threshold, or divided into more value ranges using multiple thresholds. Exemplarily, the context model increment can take values such as 0, 1, 2, 3, ….

[0205] In some embodiments, the reference information of the relevant block includes: the available identifier of the first syntax element of the relevant block and the context model index reference quantity.

[0206] Determining a first intermediate quantity based on the reference information of the multiple relevant blocks includes: obtaining the weights of the multiple relevant blocks; performing an AND operation on the available identifier and the context model index reference quantity of each relevant block to obtain an AND operation result; performing a weighted operation on the AND operation result of each relevant block based on the weights of the multiple relevant blocks; and obtaining the first intermediate quantity based on the weighted results of each relevant block.

[0207] In practical applications, the first intermediate quantity is obtained by performing a summation operation on the weighted results, an OR operation on the weighted results, an AND operation on the weighted results, etc.

[0208] Exemplarily, set the first intermediate quantity (tempValue). tempValue is initialized to 0. The syntax elements encoded in the x-th relevant block are availablex and condx, where x ranges from 0 to N. Perform the following operations from 0 to N: tempValue += (availablex && condx) * weightx. Taking the example shown in FIG. 9, N is 24, and the corresponding value can be replaced when using different numbers of blocks. weightx can be determined according to the position of the relevant block x, for example, by determining which ring the relevant block x is in as mentioned above.

[0209] Then match ctxInc. One possible method is ctxInc = tempValue. Or ctxInc = tempValue / M1, where M1 is an integer. For example, M1 is configured as 1, 2, 3, 4, or 5 according to the context model. Or ctxInc = tempValue >> M2, where >> represents right shift because the cost of right shift is much lower than that of division in hardware implementation. Or it can be written in the form of ctxInc = tempValue < THR0? 0 : (tempValue < THR1? 1 : 2). THR0 and THR1 are thresholds. Using two thresholds divides tempValue into three value ranges, namely tempValue < THR0, THR0 ≤ tempValue < THR1, and THR1 ≤ tempValue. In practical applications, tempValue can be divided into two value ranges using one threshold, or divided into more value ranges using multiple thresholds.

[0210] In some embodiments, when the first syntax element corresponds to multiple context model groups, determining the context model index increment of the first syntax element of the current block based on the reference information of the multiple related blocks includes: determining a first intermediate quantity based on the reference information of the multiple related blocks; determining a second intermediate quantity based on the context model group index corresponding to the first syntax element and the number of context models in each context model group; obtaining a third intermediate quantity by converting the first intermediate quantity based on a preset conversion algorithm; and obtaining the context model index increment of the first syntax element of the current block based on the second intermediate quantity and the third intermediate quantity.

[0211] That is to say, a syntax element can directly correspond to one or more context models, or correspond to one or more context model groups, and each context model group includes multiple context models. When the first syntax element corresponds to multiple context model groups, the third intermediate quantity is used to index a context model in a certain context model group. Therefore, it is also necessary to determine the second intermediate quantity according to the context model group index and the number of context models. The second intermediate quantity serves as the offset of the context model group and is used to index the first context model in the context model group. The sum of the second intermediate quantity and the third intermediate quantity is the context model index increment, which is used to determine a context model in a context model group.

[0212] Exemplarily, when setting context model groups for some syntax elements, ctxInc += ctxSetIdx * P, where ctxSetIdx is the index of the context model group, ctxSetIdx can take values such as 0, 1, 2, 3, etc., and P is the number of context models in the context model group, and P can take values such as 2, 3, 4, 5, etc.

[0213] Illustratively, for the syntax elements alf_ctb_flag[cIdx][xCtb][yCtb], alf_ctb_cc_cb_idc[xCtb][yCtb], alf_ctb_cc_cr_idc[xCtb][yCtb], split_qt_flag, split_cu_flag, cu_skip_flag[x0][y0], pred_mode_ibc_flag[x0][y0], intra_mip_flag, inter_affine_flag[x0][y0] and merge_subblock_flag[x0][y0], VVC has 3 context model groups, with one group having 3 context models.

[0214] By adopting the above technical solution, by setting a larger predetermined area to select more relevant blocks for the current block, the spatial correlation of the image blocks is fully utilized, and a more suitable context model can be matched for the first syntax element of the current block, thereby improving the compression efficiency of the syntax element and thus improving the compression efficiency of the entire system.

[0215] To implement the method of the embodiment of the present application, based on the same inventive concept, the embodiment of the present application further provides an encoder, as shown in FIG16 , the encoder 160 includes:

[0216] A first selection unit 1601 is configured to select a plurality of encoded related blocks corresponding to a current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block;

[0217] A first determining unit 1602 is configured to determine a context model index parameter of a first syntax element of the current block based on the reference information of the multiple related blocks;

[0218] The encoding unit 1603 is configured to encode the first syntax element of the current block based on the context model corresponding to the context model index parameter.

[0219] In some embodiments, the predetermined area includes adjacent areas of the current block and / or non-adjacent areas of the current block; when the predetermined area includes adjacent areas of the current block, the related blocks include adjacent blocks of the current block; when the predetermined area includes non-adjacent areas of the current block, the related blocks include non-adjacent blocks of the current block. It should be noted that not only adjacent blocks are spatially correlated with the current block, but also closely spaced non-adjacent blocks. This is also easy to understand, as all content within the predetermined area is correlated. That is, in addition to using spatially adjacent blocks, closely spaced non-adjacent blocks can also be used, or both adjacent and non-adjacent blocks can be used, to reference a sufficient number of relevant blocks to select a context model for the current block. In this way, by setting a larger predetermined area to select more relevant blocks for the current block, the spatial correlation of image blocks is fully utilized. A more suitable context model is matched to the first syntax element of the current block based on more relevant blocks, thus preventing accidental influences on the context model selection.

[0220] In some embodiments, the encoder further comprises: a setting unit configured to configure a weight of the relevant block based on a distance between the relevant block and the current block.

[0221] In some embodiments, the setting unit is configured to configure the weight of the related block based on the reference coordinates of the related block and the reference coordinates of the current block.

[0222] In some embodiments, a setting unit is used to determine a first sub-region where the relevant block is located; wherein the first sub-region is at least one of the at least two second sub-regions contained in the predetermined region; and based on the first sub-region where the relevant block is located, the weight of the relevant block is configured.

[0223] In some embodiments, the predetermined area may include adjacent areas of the current block and non-adjacent areas of the current block. In this way, considering the strength of spatial correlation, the accuracy of context model selection can be further improved by setting weights of related blocks.

[0224] In some embodiments, the first selection unit 1601 is configured to determine the reference coordinates of the related block within the predetermined area based on the reference coordinates of the current block; and obtain reference information of the related block based on the reference coordinates of the related block.

[0225] In some embodiments, the first selection unit 1601 is configured to obtain reference information of the relevant blocks based on a preset selection order and reference coordinates of the relevant blocks.

[0226] In some embodiments, the reference information of the relevant block includes: a context model index reference amount of the first syntax element of the relevant block.

[0227] In some embodiments, the reference information of the related block further includes: an available identifier of the related block.

[0228] In some embodiments, the first determination unit 1602 is used to determine the context model index offset corresponding to the first syntax element; determine the context model index increment of the first syntax element of the current block based on the reference information of the multiple related blocks; determine the context model index of the first syntax element based on the context model index increment and the context model index offset; and set the context model index parameter to be equal to the context model index.

[0229] In some embodiments, the first determination unit 1602 is used to determine a first intermediate quantity based on the reference information of the multiple related blocks; and convert the first intermediate quantity based on a preset conversion algorithm to obtain a context model index increment of the first syntax element of the current block.

[0230] In some embodiments, when the first syntax element corresponds to multiple context model groups, the first determination unit 1602 is used to determine a first intermediate quantity based on reference information of the multiple related blocks; determine a second intermediate quantity based on the context model group index corresponding to the first syntax element and the number of context models in each context model group; convert the first intermediate quantity based on a preset conversion algorithm to obtain a third intermediate quantity; and obtain a context model index increment of the first syntax element of the current block based on the second intermediate quantity and the third intermediate quantity.

[0231] In some embodiments, the reference information of the relevant block includes: an available identifier and a context model index reference amount of the first syntax element of the relevant block, and the first determination unit 1602 is used to perform an AND operation on the available identifier and the context model index reference amount of each relevant block to obtain an AND operation result; and obtain the first intermediate amount based on the AND operation result of each relevant block.

[0232] In some embodiments, the reference information of the relevant block includes: an available identifier and a context model index reference amount of the first syntax element of the relevant block, and the first determination unit 1602 is used to obtain the weights of the multiple relevant blocks; perform an AND operation on the available identifier and the context model index reference amount of each relevant block to obtain an AND operation result; perform a weighted operation on the AND operation result of each relevant block based on the weights of the multiple relevant blocks; and obtain the first intermediate quantity based on the weighted result of each relevant block.

[0233] In some embodiments, the preset conversion algorithm includes one of the following: setting the first intermediate quantity equal to the context model index increment; dividing the first intermediate quantity by a first reference quantity to obtain the context model index increment; shifting the first intermediate quantity right by a second reference quantity to obtain the context model index increment; determining a first value range in which the first intermediate quantity is located, and using the index increment corresponding to the first value range as the context model index increment.

[0234] In some embodiments, the first determining unit 1602 is configured to determine a first context model list used when selecting a context model for the first grammatical element; and set the context model index parameter to an index of the first context model list.

[0235] In practical applications, the embodiment of the present application further provides an encoder. FIG17 is a schematic diagram of a second component structure of the encoder in the embodiment of the present application. As shown in FIG17 , the encoder 170 includes:

[0236] The first memory 1701 and the first processor 1702; the first memory 1701 stores a computer program that can be run on the first processor 1702, and the first processor 1702 executes the program when the encoding method on the encoder side is executed.

[0237] By adopting the above scheme, by setting a larger predetermined area to select more relevant blocks for the current block, the spatial correlation of the image blocks is fully utilized, and a more suitable context model can be matched for the first syntax element of the current block, thereby improving the compression efficiency of the syntax element and thus improving the compression efficiency of the entire system.

[0238] The present application provides a decoder. FIG18 is a schematic diagram of a first component structure of a decoder according to the present application. As shown in FIG18 , the decoder 180 includes:

[0239] The first decoding unit 1801 is configured to decode a bitstream and obtain information to be decoded of a first syntax element of a current block;

[0240] A second selection unit 1802 is configured to select a plurality of decoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block;

[0241] A second determining unit 1803 is configured to determine a context model index parameter of a first syntax element of the current block based on the reference information of the multiple related blocks;

[0242] The second decoding unit 1804 is configured to decode the information to be decoded based on the context model corresponding to the context model index parameter to obtain a first syntax element of the current block.

[0243] In some embodiments, the predetermined area includes adjacent areas of the current block and / or non-adjacent areas of the current block; when the predetermined area includes adjacent areas of the current block, the related blocks include adjacent blocks of the current block; when the predetermined area includes non-adjacent areas of the current block, the related blocks include non-adjacent blocks of the current block. It should be noted that not only adjacent blocks are spatially correlated with the current block, but also closely spaced non-adjacent blocks. This is also easy to understand, as all content within the predetermined area is correlated. That is, in addition to using spatially adjacent blocks, closely spaced non-adjacent blocks can also be used, or both adjacent and non-adjacent blocks can be used, to reference a sufficient number of relevant blocks to select a context model for the current block. In this way, by setting a larger predetermined area to select more relevant blocks for the current block, the spatial correlation of image blocks is fully utilized. A more suitable context model is matched to the first syntax element of the current block based on more relevant blocks, thus preventing accidental influences on the context model selection.

[0244] In some embodiments, the decoder further comprises: a setting unit configured to configure the weight of the relevant block based on the distance between the relevant block and the current block.

[0245] In some embodiments, the setting unit is configured to configure the weight of the related block based on the reference coordinates of the related block and the reference coordinates of the current block.

[0246] In some embodiments, a setting unit is used to determine a first sub-region where the relevant block is located; wherein the first sub-region is at least one of the at least two second sub-regions contained in the predetermined region; and based on the first sub-region where the relevant block is located, the weight of the relevant block is configured.

[0247] In some embodiments, the predetermined area may include adjacent areas of the current block and non-adjacent areas of the current block. In this way, considering the strength of spatial correlation, the accuracy of context model selection can be further improved by setting weights of related blocks.

[0248] In some embodiments, the second selection unit 1802 is configured to determine the reference coordinates of the related blocks within the predetermined area based on the reference coordinates of the current block; and obtain reference information of the related blocks based on the reference coordinates of the related blocks.

[0249] In some embodiments, the second selection unit 1802 is configured to obtain reference information of the relevant blocks based on a preset selection order and reference coordinates of the relevant blocks.

[0250] In some embodiments, the reference information of the relevant block includes: a context model index reference amount of the first syntax element of the relevant block.

[0251] In some embodiments, the reference information of the related block further includes: an available identifier of the related block.

[0252] In some embodiments, the second determination unit 1803 is used to determine the context model index offset corresponding to the first syntax element; determine the context model index increment of the first syntax element of the current block based on the reference information of the multiple related blocks; determine the context model index of the first syntax element based on the context model index increment and the context model index offset; and set the context model index parameter to be equal to the context model index.

[0253] In some embodiments, the second determination unit 1803 is used to determine a first intermediate quantity based on the reference information of the multiple related blocks; convert the first intermediate quantity based on a preset conversion algorithm to obtain a context model index increment of the first syntax element of the current block.

[0254] In some embodiments, when the first syntax element corresponds to multiple context model groups, the second determination unit 1803 is used to determine a first intermediate quantity based on reference information of the multiple related blocks; determine a second intermediate quantity based on the context model group index corresponding to the first syntax element and the number of context models in each context model group; convert the first intermediate quantity based on a preset conversion algorithm to obtain a third intermediate quantity; and obtain a context model index increment of the first syntax element of the current block based on the second intermediate quantity and the third intermediate quantity.

[0255] In some embodiments, the reference information of the relevant block includes: an available identifier and a context model index reference amount of the first syntax element of the relevant block, and a second determination unit 1803 is used to perform an AND operation on the available identifier and the context model index reference amount of each relevant block to obtain an AND operation result; and obtain the first intermediate amount based on the AND operation result of each relevant block.

[0256] In some embodiments, the reference information of the related blocks includes: an available identifier and a context model index reference amount of the first syntax element of the related blocks, a second determination unit 1803, for obtaining weights of the multiple related blocks; performing an AND operation on the available identifier and the context model index reference amount of each related block to obtain an AND operation result; performing a weighted operation on the AND operation result of each related block based on the weights of the multiple related blocks; and obtaining the first intermediate quantity based on the weighted result of each related block.

[0257] In some embodiments, the preset conversion algorithm includes one of the following: setting the first intermediate quantity equal to the context model index increment; dividing the first intermediate quantity by a first reference quantity to obtain the context model index increment; shifting the first intermediate quantity right by a second reference quantity to obtain the context model index increment; determining a first value range in which the first intermediate quantity is located, and using the index increment corresponding to the first value range as the context model index increment.

[0258] In some embodiments, the second determining unit 1803 is configured to determine a first context model list used when selecting the context model of the first syntax element; and set the context model index parameter to an index of the first context model list.

[0259] In practical applications, the embodiment of the present application further provides a decoder. FIG19 is a schematic diagram of a second component structure of the decoder in the embodiment of the present application. As shown in FIG19 , the decoder 190 includes:

[0260] The second memory 1901 and the second processor 1902; the second memory 1901 stores a computer program that can be run on the second processor 1902, and the second processor 1902 executes the program in accordance with the decoding method on the decoder side.

[0261] By adopting the above technical solution, by setting a larger predetermined area to select more relevant blocks for the current block, the spatial correlation of the image blocks is fully utilized, and a more suitable context model can be matched for the first syntax element of the current block, thereby improving the compression efficiency of the syntax element and thus improving the compression efficiency of the entire system.

[0262] In addition, the functional modules in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or software functional modules.

[0263] Accordingly, an embodiment of the present application provides a storage medium on which a computer program is stored. When the computer program is executed by a first processor, the encoding method of the encoder is implemented; or, when the computer program is executed by a second processor, the decoding method of the decoder is implemented.

[0264] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0265] The above are merely embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims. Industrial Applicability

[0266] The present application provides a coding and decoding method, encoder, decoder, and storage medium, comprising: selecting multiple encoded related blocks corresponding to a current block from a predetermined area; wherein the predetermined area includes an area that is correlated with the current block; determining a context model index parameter for a first syntax element of the current block based on reference information of the multiple related blocks; and encoding the first syntax element of the current block based on a context model corresponding to the context model index parameter. In this way, by setting a larger predetermined area to select more related blocks for the current block, the spatial correlation of image blocks is fully utilized, and a more suitable context model can be matched to the first syntax element of the current block, thereby improving the compression efficiency of the syntax element and, in turn, improving the compression efficiency of the entire system.

Claims

1. A coding method, applied to an encoder, wherein: include: Selecting a plurality of encoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block; Determining a context model index parameter of a first syntax element of the current block based on reference information of the multiple related blocks; The first syntax element of the current block is encoded based on the context model corresponding to the context model index parameter.

2. The method according to claim 1, wherein The predetermined area includes an adjacent area of ​​the current block and / or an area not adjacent to the current block; When the predetermined area includes an adjacent area of ​​the current block, the related blocks include adjacent blocks of the current block; When the predetermined area includes an area non-adjacent to the current block, the related blocks include non-adjacent blocks to the current block.

3. The method according to claim 1, wherein The method further comprises: The weight of the related block is configured based on the distance between the related block and the current block.

4. The method according to claim 1, wherein The method further comprises: The weight of the related block is configured based on the reference coordinates of the related block and the reference coordinates of the current block.

5. The method according to claim 1, wherein The method further comprises: Determine a first sub-region where the relevant block is located; wherein the first sub-region is at least one of the at least two second sub-regions included in the predetermined region; The weight of the relevant block is configured based on the first sub-region where the relevant block is located.

6. The method according to claim 1, wherein The step of selecting a plurality of encoded related blocks corresponding to the current block from a predetermined area includes: determining, based on the reference coordinates of the current block, the reference coordinates of the related block within the predetermined area; Based on the reference coordinates of the relevant block, reference information of the relevant block is acquired.

7. The method according to claim 6, wherein: The method further comprises: Based on a preset selection order and the reference coordinates of the relevant blocks, reference information of the relevant blocks is acquired.

8. The method according to claim 1, wherein The reference information of the relevant block includes: a context model index reference amount of the first syntax element of the relevant block.

9. The method according to claim 8, wherein The reference information of the related block also includes: an available identifier of the related block.

10. The method according to claim 1, wherein The determining, based on the reference information of the multiple related blocks, a context model index parameter of the first syntax element of the current block includes: Determining a context model index offset corresponding to the first syntax element; Determining a context model index increment for a first syntax element of the current block based on reference information of the multiple related blocks; determining the context model index of the first syntax element based on the context model index increment and the context model index offset; The context model index parameter is set equal to the context model index.

11. The method according to claim 10, wherein: The determining, based on the reference information of the multiple related blocks, a context model index increment of the first syntax element of the current block, comprises: determining a first intermediate quantity based on the reference information of the plurality of related blocks; The first intermediate quantity is converted based on a preset conversion algorithm to obtain a context model index increment of the first syntax element of the current block.

12. The method according to claim 10, wherein: When the first syntax element corresponds to multiple context model groups, determining the context model index increment of the first syntax element of the current block based on the reference information of the multiple related blocks includes: determining a first intermediate quantity based on the reference information of the plurality of related blocks; determining a second intermediate quantity based on a context model group index corresponding to the first grammatical element and the number of context models in each context model group; Convert the first intermediate quantity based on a preset conversion algorithm to obtain a third intermediate quantity; A context model index increment of the first syntax element of the current block is obtained based on the second intermediate quantity and the third intermediate quantity.

13. The method according to claim 11 or 12, wherein: The reference information of the relevant block includes: an available identifier of the first syntax element of the relevant block and a context model index reference amount, The determining of a first intermediate quantity based on the reference information of the plurality of related blocks comprises: Performing an AND operation on the available identifier of each relevant block and the context model index reference to obtain an AND operation result; The first intermediate quantity is obtained based on the AND operation result of each related block.

14. The method according to claim 11 or 12, wherein: The reference information of the relevant block includes: an available identifier of the first syntax element of the relevant block and a context model index reference amount, The determining of a first intermediate quantity based on the reference information of the plurality of related blocks comprises: Obtaining weights of the multiple related blocks; Performing an AND operation on the available identifier of each relevant block and the context model index reference to obtain an AND operation result; Performing a weighted operation on the AND operation result of each related block based on the weights of the multiple related blocks; The first intermediate quantity is obtained based on the weighted result of each relevant block.

15. The method according to claim 11 or 12, wherein: The preset conversion algorithm includes one of the following: Setting the first intermediate quantity equal to the context model index increment; Dividing the first intermediate quantity by a first reference quantity to obtain the context model index increment; Shifting the first intermediate amount right by a second reference amount to obtain the context model index increment; Determine a first value range within which the first intermediate quantity lies, and use an index increment corresponding to the first value range as the context model index increment.

16. The method according to claim 10, wherein The method further comprises: determining a first context model list to be used when selecting a context model for the first grammatical element; The context model index parameter is set to the index of the first context model list.

17. A decoding method, applied to a decoder, wherein: include Decode the code stream to obtain the to-be-decoded information of the first syntax element of the current block; Selecting a plurality of decoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block; Determining a context model index parameter of a first syntax element of the current block based on reference information of the multiple related blocks; The information to be decoded is decoded based on the context model corresponding to the context model index parameter to obtain a first syntax element of the current block.

18. The method according to claim 17, wherein The predetermined area includes an adjacent area of ​​the current block and / or an area not adjacent to the current block; When the predetermined area includes an adjacent area of ​​the current block, the related blocks include adjacent blocks of the current block; When the predetermined area includes an area non-adjacent to the current block, the related blocks include non-adjacent blocks to the current block.

19. The method according to claim 17, wherein The method further comprises: The weight of the related block is configured based on the distance between the related block and the current block.

20. The method according to claim 17, wherein The method further comprises: The weight of the related block is configured based on the reference coordinates of the related block and the reference coordinates of the current block.

21. The method according to claim 17, wherein The method further comprises: Determine a first sub-region where the relevant block is located; wherein the first sub-region is at least one of the at least two second sub-regions included in the predetermined region; The weight of the relevant block is configured based on the first sub-region where the relevant block is located.

22. The method according to claim 17, wherein The selecting, from a predetermined area, a plurality of decoded related blocks corresponding to the current block comprises: determining, based on the reference coordinates of the current block, the reference coordinates of the related block within the predetermined area; Based on the reference coordinates of the relevant block, reference information of the relevant block is acquired.

23. The method according to claim 22, wherein The method further comprises: Based on a preset selection order and the reference coordinates of the relevant blocks, reference information of the relevant blocks is acquired.

24. The method according to claim 17, wherein The reference information of the relevant block includes: a context model index reference amount of the first syntax element of the relevant block.

25. The method according to claim 24, wherein The reference information of the related block also includes: an available identifier of the related block.

26. The method according to claim 17, wherein The determining, based on the reference information of the multiple related blocks, a context model index parameter of the first syntax element of the current block includes: Determining a context model index offset corresponding to the first syntax element; Determining a context model index increment for a first syntax element of the current block based on reference information of the multiple related blocks; determining the context model index of the first syntax element based on the context model index increment and the context model index offset; The context model index parameter is set equal to the context model index.

27. The method according to claim 26, wherein The determining, based on the reference information of the multiple related blocks, a context model index increment of the first syntax element of the current block, comprises: determining a first intermediate quantity based on the reference information of the plurality of related blocks; The first intermediate quantity is converted based on a preset conversion algorithm to obtain a context model index increment of the first syntax element of the current block.

28. The method according to claim 26, wherein When the first syntax element corresponds to multiple context model groups, determining the context model index increment of the first syntax element of the current block based on the reference information of the multiple related blocks includes: determining a first intermediate quantity based on the reference information of the plurality of related blocks; determining a second intermediate quantity based on a context model group index corresponding to the first grammatical element and the number of context models in each context model group; Convert the first intermediate quantity based on a preset conversion algorithm to obtain a third intermediate quantity; A context model index increment of the first syntax element of the current block is obtained based on the second intermediate quantity and the third intermediate quantity.

29. The method according to claim 27 or 28, wherein The reference information of the relevant block includes: an available identifier of the first syntax element of the relevant block and a context model index reference amount, The determining of a first intermediate quantity based on the reference information of the plurality of related blocks comprises: Performing an AND operation on the available identifier of each relevant block and the context model index reference to obtain an AND operation result; The first intermediate quantity is obtained based on the AND operation result of each related block.

30. The method according to claim 27 or 28, wherein The reference information of the relevant block includes: an available identifier of the first syntax element of the relevant block and a context model index reference amount, The determining of a first intermediate quantity based on the reference information of the plurality of related blocks comprises: Obtaining weights of the multiple related blocks; Performing an AND operation on the available identifier of each relevant block and the context model index reference to obtain an AND operation result; Performing a weighted operation on the AND operation result of each related block based on the weights of the multiple related blocks; The first intermediate quantity is obtained based on the weighted result of each relevant block.

31. The method according to claim 27 or 28, wherein The preset conversion algorithm includes one of the following: Setting the first intermediate quantity equal to the context model index increment; Dividing the first intermediate quantity by a first reference quantity to obtain the context model index increment; Shifting the first intermediate amount right by a second reference amount to obtain the context model index increment; Determine a first value range within which the first intermediate quantity lies, and use an index increment corresponding to the first value range as the context model index increment.

32. The method of claim 26, wherein: The method further comprises: determining a first context model list to be used when selecting a context model for the first grammatical element; The context model index parameter is set to the index of the first context model list.

33. An encoder, wherein The encoder comprises: A first selection unit is configured to select a plurality of encoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block; A first determining unit, configured to determine a context model index parameter of a first syntax element of the current block based on reference information of the multiple related blocks; An encoding unit is configured to encode a first syntax element of the current block based on a context model corresponding to the context model index parameter.

34. A decoder, wherein The decoder comprises: A first decoding unit, configured to decode a bitstream and obtain information to be decoded of a first syntax element of a current block; A second selection unit is configured to select a plurality of decoded related blocks corresponding to the current block from a predetermined area; wherein the predetermined area includes an area having correlation with the current block; a second determining unit, configured to determine a context model index parameter of a first syntax element of the current block based on the reference information of the multiple related blocks; The second decoding unit is configured to decode the information to be decoded based on the context model corresponding to the context model index parameter to obtain a first syntax element of the current block.

35. An encoder, wherein The encoder comprises: a first memory and a first processor; The first memory stores a computer program that can be run on the first processor, and when the first processor executes the program, the encoding method according to any one of claims 1 to 16 is implemented.

36. A decoder, wherein The decoder comprises: a second memory and a second processor; The second memory stores a computer program that can be run on the second processor, and when the second processor executes the program, the decoding method according to any one of claims 17 to 32 is implemented.

37. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, and when the computer program is executed by a first processor, it implements the encoding method described in any one of claims 1 to 16; or, when the computer program is executed by a second processor, it implements the decoding method described in any one of claims 17 to 32.