Video encoding method and device, video decoding method and device, code stream, decoder, encoder and storage medium

CN119452658APending Publication Date: 2025-02-14GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202280097613.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-07-01
Filing Date
2022-08-24
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In existing technologies, further improving video encoding and decoding performance, especially by improving the construction and sorting methods of the merged candidate list, and increasing encoding efficiency and inter-frame prediction accuracy, remains a challenge.

Method used

By constructing an initial motion information candidate list containing first-class and second-class motion information candidates and partially sorting it, N second-class motion information candidates are ensured to participate in the sorting, thereby reducing the number of encoded bits and improving the accuracy of inter-frame prediction.

Benefits of technology

It effectively reduces the number of encoding bits, improves encoding efficiency, enhances the accuracy of inter-frame prediction, and improves video encoding and decoding performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119452658A_ABST
    Figure CN119452658A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an encoding method and device, a decoding method and device, a code stream, a decoder, an encoder and a storage medium, the decoding method comprises the following steps: determining an initial motion information candidate list of a current block, the initial motion information candidate list comprising a first type of motion information candidate and a second type of motion information candidate, determining the first type of motion information candidates according to the motion information of the adjacent block and / or the non-adjacent block of the current block, and constructing the second type of motion information candidates according to a reference image index set by using a preset rule and a motion vector with a preset value; sorting partial motion information candidates in the initial motion information candidate list, and determining a motion information candidate list of the current block; wherein the partial motion information candidates comprise at least one first type of motion information candidate and N second type of motion information candidates, and N is a positive integer; decoding a code stream, and determining a motion information candidate index of the current block; determining an inter-frame prediction value of the current block according to the motion information candidate index of the current block and the motion information candidate list; decoding a code stream, and determining a residual value of the current block; and determining a reconstruction value of the current block according to the residual value of the current block and the inter-frame prediction value.
Need to check novelty before this filing date? Find Prior Art

Description

Video encoding and decoding method and device, code stream, decoder, encoder, storage medium

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application is based on the PCT patent application with application number PCT / CN2022 / 103418 and application date July 1, 2022, and claims the priority of the PCT patent application. The entire content of the PCT patent application is hereby introduced into this application in its entirety. Technical Field

[0003] The embodiments of the present application relate to the field of coding and decoding, and more specifically, to video coding and decoding methods and devices, bit streams, decoders and encoders. Background Art

[0004] Merge mode refers to an inter-frame coding mode that directly uses the reference image index and motion vector (MV) of the motion vector prediction (MVP) as the motion vector information of the current block. Merge mode requires the establishment of a merge candidate list. The encoder selects a merge candidate from the merge candidate list as the optimal merge candidate for the current block through rate-distortion optimization, and encodes the index value of the selected optimal merge candidate in the merge candidate list into the bitstream to represent the MV and reference image index of the current block. The decoder parses the syntax elements to determine whether to use merge mode. In merge mode, the syntax elements are further parsed to obtain the index value of the optimal merge candidate for the current block in the merge candidate list. The optimal merge candidate for the current block is obtained by combining the merge candidate list, and then the prediction block of the current block can be obtained. The residual block is then decoded and transformed, quantized, and entropy encoded to complete the reconstruction of the current block.

[0005] In addition, Adaptive Reordering of Merge Candidates with Template Matching (ARMC) is a technology that reorders the initial merge candidate list according to the template matching cost. Based on this, after the merge candidate list is constructed, the ARMC technology will sort the merge candidates in the merge candidate list in ascending order of template matching cost. ARMC technology can usually make the order of the optimal merge candidate finally selected by the encoding end as early as possible in the merge candidate list, thereby improving the encoding and decoding efficiency of the index value of the optimal merge candidate, thereby improving the encoding and decoding efficiency. However, with the development of technology, how to use ARMC technology to further improve encoding and decoding performance is still a technical problem that needs to be solved urgently in this field.

[0006] Summary of the Invention

[0007] The embodiments of the present application provide a video encoding and decoding method and device, bit stream, decoder, encoder, and storage medium, which can further improve encoding and decoding performance.

[0008] In a first aspect, an embodiment of the present application provides a video decoding method, which is applied to a decoder, comprising: determining an initial motion information candidate list for a current block, the initial motion information candidate list comprising first-category motion information candidates and second-category motion information candidates, wherein the first-category motion information candidates are determined based on motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second-category motion information candidates are constructed based on a reference image index set using a preset rule and a motion vector with a preset value; sorting some of the motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer; decoding a code stream to determine a motion information candidate index for the current block; determining an inter-frame prediction value for the current block based on the motion information candidate index for the current block and the motion information candidate list; decoding the code stream to determine a residual value for the current block; and determining a reconstructed value for the current block based on the residual value and the inter-frame prediction value of the current block.

[0009] In this way, since some of the motion information candidates participating in the sorting in the initial motion information candidate list of the current block include not only at least one first-category motion information candidate, but also N second-category motion information candidates; therefore, on the one hand, for the encoding end, this situation is avoided: if all second-category motion information candidates in the initial motion information candidate list of the current block participate in the sorting, when a candidate in the second-category motion information candidate is selected as the motion information candidate for the current block, the number of bits required for the corresponding candidate index value increases. In other words, in the embodiment of the present application, the N second-category motion information candidates in the initial motion information candidate list of the current block are also sorted. If one of the sorted second-category motion information candidates is selected as the motion information candidate for the current block, the index value of the candidate may be small, thereby reducing the number of bits required for encoding and improving encoding efficiency. On the other hand, for the decoding end, this also avoids the following situation: because all the second-category motion information candidates in the initial motion information candidate list of the current block are at the end of the list, due to the large rate-distortion cost, none of these motion information candidates are selected as the motion information candidate for the current block, while the reference block corresponding to one of these motion information candidates has a high degree of match with the current block, and the accuracy of inter-frame prediction is reduced due to its non-selection. In other words, in the embodiment of the present application, the N second-category motion information candidates in the initial motion information candidate list of the current block are also sorted. This gives the second-category motion information candidate corresponding to the reference block with a high degree of match with the current block the opportunity to be ranked higher, thereby increasing the chance of the motion information candidate being selected as the motion information candidate for the current block, increasing the probability of improving the accuracy of inter-frame prediction, and thus improving decoding performance.

[0010] In a second aspect, an embodiment of the present application provides a video encoding method for an encoder, comprising: determining an initial motion information candidate list for a current block, the initial motion information candidate list comprising first-category motion information candidates and second-category motion information candidates, wherein the first-category motion information candidates are determined based on motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second-category motion information candidates are constructed based on a reference image index set using a preset rule and a motion vector with a preset value; sorting some of the motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer; determining a motion information candidate index for the current block based on the motion information candidate list determined for the current block; encoding the motion information candidate index for the current block, and writing the encoded bits into a bitstream.

[0011] In a third aspect, an embodiment of the present application provides a video decoding device for a decoder, comprising: a first determination module, configured to determine an initial motion information candidate list for a current block, wherein the initial motion information candidate list includes a first type of motion information candidate and a second type of motion information candidate, wherein the first type of motion information candidate is determined based on motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second type of motion information candidate is constructed based on a reference image index set using a preset rule and a motion vector with a preset value; a first sorting module, configured to sort some of the motion information candidates in the initial motion information candidate list, and determine The motion information candidate list of the current block; wherein the partial motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer; a decoding module, configured to decode a code stream and determine a motion information candidate index of the current block; a second determination module, configured to determine an inter-frame prediction value of the current block according to the motion information candidate index of the current block and the motion information candidate list; the decoding module, further configured to decode the code stream and determine a residual value of the current block; a third determination module, configured to determine a reconstructed value of the current block according to the residual value of the current block and the inter-frame prediction value.

[0012] In a fourth aspect, an embodiment of the present application provides a video encoding device for an encoder, comprising: a fourth determination module, configured to determine an initial motion information candidate list of a current block, the initial motion information candidate list comprising first-category motion information candidates and second-category motion information candidates, wherein the first-category motion information candidates are determined based on the motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second-category motion information candidates are constructed based on a reference image index set using a preset rule and a motion vector with a preset value; a second sorting module, configured to sort part of the motion information candidates in the initial motion information candidate list to determine the motion information candidate list of the current block; wherein the part of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer; a fifth determination module, configured to determine the motion information candidate index of the current block based on the determined motion information candidate list of the current block; and an encoding module, configured to encode the motion information candidate index of the current block and write the encoded bits into the bitstream.

[0013] In a fifth aspect, an embodiment of the present application provides a decoder comprising a first memory and a first processor; wherein the first memory is used to store a computer program that can be run on the first processor; and the first processor is used to execute the video decoding method as described in the embodiment of the present application when running the computer program.

[0014] In a sixth aspect, an embodiment of the present application provides an encoder comprising a second memory and a second processor; wherein the second memory is used to store a computer program that can be run on the second processor; and the second processor is used to execute the video encoding method as described in the embodiment of the present application when running the computer program.

[0015] In a seventh aspect, an embodiment of the present application provides a code stream, which is generated by bit-encoding the motion information candidate index of the current block; wherein the motion information candidate index of the current block is obtained by the video encoding method described in the embodiment of the present application.

[0016] In an eighth aspect, an embodiment of the present application provides an electronic device, comprising: a processor, suitable for executing a computer program; a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the video decoding method as described in the embodiment of the present application is implemented, or when the computer program is executed by the processor, the video encoding method as described in the embodiment of the present application is implemented.

[0017] In a ninth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, it implements the video decoding method as described in the embodiment of the present application, or implements the video encoding method as described in the embodiment of the present application.

[0018] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings herein are incorporated into and constitute a part of this specification. These drawings illustrate embodiments consistent with the present application and, together with the specification, serve to illustrate the technical solutions of the present application. Obviously, the drawings described below are merely some embodiments of the present application. Those skilled in the art can, without inventive effort, derive other drawings from these drawings.

[0020] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.

[0021] FIG1 is a schematic block diagram of a coding framework provided in an embodiment of the present application.

[0022] FIG2 is a schematic block diagram of a decoding framework provided in an embodiment of the present application.

[0023] FIG3 is a schematic diagram of the MV prediction process of the merge mode provided in an embodiment of the present application.

[0024] FIG4 is a schematic flowchart of a method for constructing a merge candidate list provided in an embodiment of the present application.

[0025] FIG5 is a schematic flowchart of spatial merging candidates provided in an embodiment of the present application.

[0026] FIG6 is a schematic diagram of a reference position provided in an embodiment of the present application.

[0027] FIG7 is a schematic diagram of the relationship between the MV of a co-located image block and the MV of a time-domain merging candidate provided in an embodiment of the present application.

[0028] FIG8 is a schematic diagram of the positions of non-adjacent blocks used to construct non-adjacent spatial merging candidates provided in an embodiment of the present application.

[0029] FIG9 is a schematic diagram of a template of a reference block and a template of a current block of a merging candidate provided in an embodiment of the present application.

[0030] FIG10 is another schematic diagram of merging a template of a candidate reference block and a template of a current block provided by an embodiment of the present application.

[0031] FIG11 is a schematic diagram of reordering the entire merge candidate list based on template matching cost using ARMC technology provided in an embodiment of the present application.

[0032] FIG12 is a schematic diagram of performing ARMC sorting on the merge candidates in the merge candidate list except for the zero motion vector merge candidate using the ARMC technology provided in an embodiment of the present application.

[0033] FIG13 is a schematic flow chart of the sorting method provided in an embodiment of the present application.

[0034] FIG14 is a schematic diagram of performing ARMC sorting on the first merge candidate list based on the first quantity provided in an embodiment of the present application.

[0035] FIG15 is a schematic diagram of a detection process for performing redundancy detection on zero motion vector merge candidates after adding zero motion vector merge candidates to the first merge candidate list, provided by an embodiment of the present application.

[0036] FIG16 is a schematic diagram of a detection process for performing redundancy detection on zero motion vector merge candidates while adding zero motion vector merge candidates to the first merge candidate list, provided by an embodiment of the present application.

[0037] FIG17 is a schematic block diagram of a video encoding device according to an embodiment of the present application.

[0038] FIG18 is a schematic block diagram of a video decoding device according to an embodiment of the present application.

[0039] Figure 19 is a schematic block diagram of the decoder provided in an embodiment of the present application.

[0040] Figure 20 is a schematic structural diagram of the encoder provided in an embodiment of the present application. DETAILED DESCRIPTION

[0041] To make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the specific technical solutions of the present application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application but are not intended to limit the scope of the present application.

[0042] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.

[0043] In the following description, references to “some embodiments,” “this embodiment,” “embodiments of the present application,” and examples, etc., describe a subset of all possible embodiments. However, it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.

[0044] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.

[0045] The solution provided in the embodiment of the present application can be applied to the field of digital video coding technology, for example, including but not limited to: image coding and decoding field, video coding and decoding field, hardware video coding and decoding field, dedicated circuit video coding and decoding field and real-time video coding and decoding field. In addition, the solution provided in the embodiment of the present application can be combined with the audio and video coding standard (Audio Video Coding Standard, AVS), the second generation AVS standard (AVS2) or the third generation AVS standard (AVS3). For example, including but not limited to: H.264 / Audio Video Coding (AVC) standard, H.265 / High Efficiency Video Coding (HEVC) standard and H.266 / Versatile Video Coding (VVC) standard. In addition, the solution provided in the embodiment of the present application can be used for lossy compression of images, and can also be used for lossless compression of images. The lossless compression can be visually lossless compression or mathematically lossless compression.

[0046] The video codec standard adopts a block-based hybrid coding framework. Specifically, each image 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 or coding tree unit can be divided into rectangular coding units (CUs) according to rules. Coding units may also be divided into prediction units (PUs) and transform units (TUs). The hybrid coding framework includes modules such as prediction, transform, quantization, entropy coding, and in-loop filtering. The prediction module includes intra prediction and inter prediction. Inter prediction includes motion estimation and motion compensation. Since there is a strong correlation between adjacent pixels in a video image, intra prediction is used in video codec technology to eliminate spatial redundancy between adjacent pixels. Intra-frame prediction only references information from the same image to predict pixel information within the current block. Due to the strong similarities between adjacent images in a video, inter-frame prediction is used in video coding and decoding to eliminate temporal redundancy between adjacent images, thereby improving coding efficiency. Inter-frame prediction can reference image information from different frames and use motion estimation to search for the motion vector information that best matches the current block. Transformation converts the predicted image block to the frequency domain, redistributing the energy. Combined with quantization, it removes information that is insensitive to the human eye, eliminating visual redundancy. Entropy coding can eliminate character redundancy based on the current context model and the probabilistic information of the binary bitstream.

[0047] During digital video encoding, the encoder may first read a black-and-white or color image from the original video sequence and then encode the black-and-white or color image. A black-and-white image may include pixels of the luminance component, while a color image may include pixels of the chrominance component. Optionally, the color image may also include pixels of the luminance component. The color format of the original video sequence may be a luminance-chrominance (YCbCr, YUV) format or a red-green-blue (RGB) format. Specifically, after reading the black-and-white or color image, the encoder divides it into blocks and uses intra-frame prediction or inter-frame prediction on the current block to generate a prediction block for the current block. The prediction block is subtracted from the original block of the current block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix. The quantization coefficient matrix is ​​entropy encoded and output to the bitstream. During digital video decoding, the decoder uses intra-frame prediction or inter-frame prediction on the current block to generate a prediction block for the current block. Furthermore, the decoder decodes the bitstream to obtain a quantization coefficient matrix, dequantizes and inversely transforms the quantization coefficient matrix to obtain a residual block. The prediction block and the residual block are added together to obtain a reconstructed block. The reconstructed blocks can be used to compose a reconstructed image. The decoding end performs loop filtering on the reconstructed image based on an image or a block to obtain a decoded image.

[0048] The current block may be a current coding unit (CU) or a current prediction unit (PU), etc.

[0049] It should be noted that the encoder also requires similar operations as the decoder to obtain a decoded image. The decoded image can serve as a reference image for inter-frame prediction of subsequent images. The block division information, prediction, transform, quantization, entropy coding, loop filtering, and other mode or parameter information determined by the encoder need to be output to the bitstream if necessary. The decoder determines the same block division information, prediction, transform, quantization, entropy coding, loop filtering, and other mode or parameter information as the encoder by parsing and analyzing existing information, thereby ensuring that the decoded image obtained by the encoder and the decoder are identical. The decoded image obtained by the encoder is also commonly called a reconstructed image. During prediction, the current block can be divided into prediction units, and during transform, the current block can be divided into transform units. The division of prediction units and transform units can be the same or different. Of course, the above is only the basic process of a video codec within a block-based hybrid coding framework. With technological advancement, some modules of the framework or some steps of the process may be optimized. This application applies to the basic process of a video codec within this block-based hybrid coding framework.

[0050] To facilitate understanding, the coding framework provided in this application is briefly introduced first.

[0051] FIG1 is a schematic block diagram of a coding framework 100 provided in an embodiment of the present application.

[0052] As shown in FIG1 , the coding framework 100 may include an intra-frame prediction unit 180, an inter-frame prediction unit 170, a residual unit 110, a transform and quantization unit 120, an entropy coding unit 130, an inverse transform and inverse quantization unit 140, and a loop filter unit 150. Optionally, the coding framework 100 may further include a decoded image buffer unit 160. The coding framework 100 may also be referred to as a hybrid framework coding mode.

[0053] The intra-frame prediction unit 180 or the inter-frame prediction unit 170 may predict the image block to be encoded and output a prediction block. The residual unit 110 may calculate a residual block based on the prediction block and the image block to be encoded, i.e., the difference between the prediction block and the image block to be encoded. The transform and quantization unit 120 is configured to perform operations such as transform and quantization on the residual block to remove information that is insensitive to the human eye, thereby eliminating visual redundancy. Optionally, the residual block before transformation and quantization by the transform and quantization unit 120 may be referred to as a time-domain residual block, and the time-domain residual block after transformation and quantization by the transform and quantization unit 120 may be referred to as a frequency residual block or a frequency-domain residual block. After receiving the transform and quantization coefficients output by the transform and quantization unit 120, the entropy coding unit 130 may output a bitstream based on the transform and quantization coefficients. For example, the entropy coding unit 130 may eliminate character redundancy based on a target context model and probability information of the binary bitstream. For example, the entropy coding unit 130 may be configured for context-based adaptive binary arithmetic entropy coding (CABAC). The entropy coding unit 130 may also be referred to as a header information coding unit. Optionally, in this application, the image block to be encoded may also be referred to as an original image block or a target image block, the prediction block may also be referred to as a prediction image block or an image prediction block, or may also be referred to as a prediction signal or prediction information, and the reconstruction block may also be referred to as a reconstructed image block or an image reconstruction block, or may also be referred to as a reconstruction signal or reconstruction information. In addition, for the encoding end, the image block to be encoded may also be referred to as a coding block or a coding image block, and for the decoding end, the image block to be encoded may also be referred to as a decoding block or a decoding image block. The image block to be encoded may be a CTU or a CU.

[0054] The coding framework 100 calculates the residual between the prediction block and the image block to be coded, generates a residual block, and transmits the residual block to the decoder through processes such as transformation and quantization. Correspondingly, the decoder receives and decodes the bitstream, then performs inverse transformation and inverse quantization to obtain a residual block. The predicted block, obtained by the decoder, is then superimposed on the residual block to create a reconstructed block.

[0055] It should be noted that the inverse transform and inverse quantization unit 140, the loop filter unit 150, and the decoded image buffer unit 160 in the coding framework 100 can be used to form a decoder. This means that the intra-frame prediction unit 180 or the inter-frame prediction unit 170 can predict the image block to be coded based on the existing reconstructed block, thereby ensuring that the encoder and decoder have a consistent understanding of the reference image. In other words, the encoder can replicate the decoder's processing loop, thereby generating the same prediction as the decoder. Specifically, the quantized transform coefficients are inversely transformed and inversely quantized by the inverse transform and inverse quantization unit 140 to replicate the approximate residual block at the decoder. This approximate residual block, after adding the prediction block, can pass through the loop filter unit 150 to smooth out block artifacts caused by block-based processing and quantization. The image block output by the loop filter unit 150 can be stored in the decoded image buffer unit 160 for use in subsequent image prediction.

[0056] It should be understood that FIG1 is merely an example of the present application and should not be construed as limiting the present application.

[0057] For example, the loop filtering unit 150 in the coding framework 100 may include a deblocking filter (DBF) and a sample adaptive offset (SAO) filter. The function of DBF is to remove the blocking effect, and the function of SAO is to remove the ringing effect. In other embodiments of the present application, the coding framework 100 may adopt a neural network-based loop filtering algorithm to improve the compression efficiency of the video. In other words, the coding framework 100 may be a video coding hybrid framework based on a deep learning neural network. In one implementation, a convolutional neural network-based model may be used to calculate the result of pixel filtering on the basis of the deblocking filter and the sample adaptive offset filter. The network structure of the loop filtering unit 150 on the luminance component and the chrominance component may be the same or different. Considering that the luminance component contains more visual information, the luminance component may also be used to guide the filtering of the chrominance component to improve the reconstruction quality of the chrominance component.

[0058] The following describes the intra-frame prediction and inter-frame prediction.

[0059] For inter-frame prediction, inter-frame prediction can refer to image information of different frames and use motion estimation to search for motion vector information that best matches the image block to be encoded to eliminate temporal redundancy; the frames used for inter-frame prediction can be P frames and / or B frames, P frames refer to forward prediction frames, and B frames refer to bidirectional prediction frames.

[0060] Intra-frame prediction only references information from the same image, predicting pixel information within the image block to be encoded to eliminate spatial redundancy. The frame used for intra-frame prediction can be an I-frame. For example, based on the left-to-right, top-to-bottom encoding order, the image block to be encoded can reference the upper left image block, the upper image block, and the left image block as reference information to predict the image block to be encoded. The image block to be encoded then serves as reference information for the next image block. In this way, the entire image can be predicted. If the input digital video is in a color format, such as YUV 4:2:0, each four pixels in each image frame of the digital video are composed of four Y components and two UV components. The encoding framework can encode the Y component (i.e., the luminance block) and the UV component (i.e., the chrominance block) separately. Similarly, the decoding end can also perform decoding according to the format.

[0061] Intra-frame prediction uses both angular and non-angular prediction modes to predict the image block to be coded. This generates a prediction block. Based on the rate-distortion information calculated between the prediction block and the image block to be coded, the optimal prediction mode for the image block to be coded is selected and transmitted to the decoder via the bitstream. The decoder parses the prediction mode, predicts the prediction block for the target decoding block, and then overlays it with the time-domain residual block obtained via the bitstream to reconstruct the block.

[0062] Throughout the development of digital video codec standards, non-angular prediction modes have remained relatively stable, including the mean and planar modes. Angular prediction modes have continued to increase with the evolution of digital video codec standards. For example, the H-series of international digital video coding standards, H.264 / AVC, has only eight angular prediction modes and one non-angular prediction mode; H.265 / HEVC has expanded this to 33 angular prediction modes and two non-angular prediction modes. In H.266 / VVC, intra-frame prediction modes have been further expanded, with a total of 67 traditional prediction modes and a non-traditional prediction mode, matrix-weighted intra-frame prediction (MIP), for luma blocks. These 67 traditional prediction modes include planar and DC modes, and 65 angular prediction modes. Planar modes are typically used for blocks with gradual texture changes, while DC modes, as the name suggests, are typically used for flat areas. Angular prediction modes are typically used for blocks with pronounced angular texture.

[0063] It should be noted that, in this application, the current block used for intra-frame prediction can be a square block or a rectangular block.

[0064] Furthermore, since intra-frame prediction blocks are all square, the probability of using each angle prediction mode is equal. When the length and width of the current block are unequal, the probability of using the reference pixel on the top of a horizontal block (width greater than height) is greater than the probability of using the reference pixel on the left, and the probability of using the reference pixel on the top of a vertical block (height greater than width) is less than the probability of using the reference pixel on the left. When predicting a rectangular block, the traditional angle prediction mode is converted to a wide-angle prediction mode. When the wide-angle prediction mode is used to predict the rectangular block, the prediction angle range of the current block is greater than the prediction angle range when the traditional angle prediction mode is used to predict the rectangular block. Optionally, when using the wide-angle prediction mode, the index of the traditional angle prediction mode can still be used to send a signal. Accordingly, the decoding end can convert the traditional angle prediction mode back to the wide-angle prediction mode after receiving the signal. As a result, the total number of intra-frame prediction modes and the encoding method of the intra-frame mode can remain unchanged.

[0065] Furthermore, the intra-frame prediction mode to be performed can be determined or selected based on the size of the current block; for example, a wide-angle prediction mode can be determined or selected based on the size of the current block to perform intra-frame prediction on the current block; for example, when the current block is a rectangular block (with different sizes in width and height), the wide-angle prediction mode can be used to perform intra-frame prediction on the current block. Among them, the aspect ratio of the current block can be used to determine the angular prediction mode replaced by the wide-angle prediction mode and the angular prediction mode after the replacement. For example, when predicting the current block, any intra-frame prediction mode with an angle that does not exceed the diagonal angle of the current block (from the lower left corner to the upper right corner of the current block) can be selected as the angular prediction mode after the replacement.

[0066] FIG2 is a schematic block diagram of a decoding framework 200 provided in an embodiment of the present application.

[0067] As shown in FIG2 , the decoding framework 200 may include an entropy decoding unit 210, an inverse transform and dequantization unit 220, a residual unit 230, an intra-frame prediction unit 240, an inter-frame prediction unit 250, a loop filter unit 260, and a decoded image buffer unit 270. The entropy decoding unit 210 receives and parses the bitstream to obtain a prediction block and a frequency domain residual block. The frequency domain residual block is inversely transformed and dequantized by the inverse transform and dequantization unit 220 to obtain a time domain residual block. The residual unit 230 superimposes the prediction block obtained by the intra-frame prediction unit 240 or the inter-frame prediction unit 250 onto the time domain residual block that has been inversely transformed and dequantized by the inverse transform and dequantization unit 220 to obtain a reconstructed block.

[0068] In order to facilitate understanding of the technical solution of this application, the relevant contents are explained below.

[0069] (1) MV prediction process of the merged mode.

[0070] Merge mode refers to an inter-frame coding mode that directly uses the reference image index and motion vector (MV) of the motion vector prediction (MVP) as the motion vector information of the current block. Merge mode requires the establishment of a merge candidate list. The encoder selects a merge candidate from the merge candidate list as the optimal merge candidate for the current block through rate-distortion optimization, and encodes the index value of the selected optimal merge candidate in the merge candidate list into the bitstream to represent the MV and reference image index of the current block. The decoder parses the syntax elements to determine whether to use merge mode. In merge mode, the syntax elements are further parsed to obtain the index value of the optimal merge candidate for the current block in the merge candidate list. The optimal merge candidate for the current block is obtained by combining the merge candidate list, and then the prediction block of the current block can be obtained. The residual block is then decoded and transformed, quantized, and entropy encoded to complete the reconstruction of the current block.

[0071] In addition, Adaptive Reordering of Merge Candidates with Template Matching (ARMC) is a technology that reorders the initial merge candidate list based on template matching cost. Based on this, after the merge candidate list is constructed, ARMC technology will sort the merge candidates in the merge candidate list in ascending order of template matching cost. ARMC technology can usually make the optimal merge candidate ultimately selected by the encoder as early as possible in the merge candidate list, improving the encoding and decoding efficiency of the optimal merge candidate index value, thereby improving encoding and decoding efficiency.

[0072] FIG3 is a schematic diagram of an MV prediction process 310 in a merge mode according to an embodiment of the present application.

[0073] As shown in FIG3 , the MV prediction process 310 in the merge mode may include:

[0074] S311, construct a merge candidate list.

[0075] Exemplarily, constructing a merge candidate list includes constructing an input of the merge candidate list and constructing an output of the merge candidate list. Taking the current block as the current luminance coding block as an example, the input of the merge candidate list includes: the position (xCb, yCb) of the upper left corner sample of the current luminance coding block relative to the upper left corner luminance sample of the current picture, the width cbWidth of the current luminance coding block, and the height cbHeight of the current luminance coding block; the output of the merge candidate list includes: the merge candidate list mergeCandList, and the number of merge candidates in the merge candidate list numOrigMergeCand before the zero motion vector merge candidate is filled.

[0076] Exemplarily, the merge candidate list may include at least one of the following: a spatial merge candidate, a temporal merge candidate, a non-adjacent spatial merge candidate, a history-based merge candidate, a pairwise average merge candidate, and a zero motion vector merge candidate. It should be noted that all or only some of the above merge candidates may be involved in the construction of the merge candidate list, and this application does not impose any specific restrictions on this.

[0077] Exemplarily, the number of merge candidates in the merge candidate list is recorded by three parameters, namely numCurrMergeCand, numOrigMergeCand and MaxNumMergeCand. Among them, MaxNumMergeCand represents the maximum number of merge candidates allowed to be accommodated in the merge candidate list, numCurrMergeCand represents the number of merge candidates that have been added to the list recorded during the construction of the merge candidate list, and numOrigMergeCand represents the number of merge candidates in the merge candidate list before zero motion vector merge candidates are filled.

[0078] S312: Reorder the merge candidate list using the ARMC technology.

[0079] For the current merge candidates to be sorted, the template matching cost of the current merge candidates can be first calculated by calculating the template matching cost, and then the current merge candidates can be sorted according to the template matching cost of the current merge candidates. For example, the template matching costs of numSortMVP merge candidates in the merge candidate list are used to sort the numSortMVP merge candidates.

[0080] S313: Determine the optimal merge candidate according to the candidate index parsed by the decoding end.

[0081] On the encoder side, the encoder selects the optimal merge candidate from the reordered merge candidate list based on rate-distortion optimization and transmits the candidate index corresponding to the optimal merge candidate in the bitstream. On the decoder side, the decoder parses the candidate index corresponding to the optimal merge candidate transmitted in the bitstream, namely merge_idx[xCb][yCb], and selects the optimal merge candidate N from the reordered merge candidate list based on the candidate index corresponding to the optimal merge candidate. Taking the current block as the current luma coding block as an example, xCb, yCb) represents the position of the current luma coding block, and N = mergeCandList[merge_idx[xCb][yCb]].

[0082] S314: Refine the optimal merging candidate using Template Matching (TM) technology or Multi-pass Decoder-side Motion Vector Refinement (DMVR) technology.

[0083] S315: Perform motion compensation on the current block using the refined optimal merging candidate.

[0084] For example, the refined optimal MVP is used to find the best matching block in the reference image, and the pixel values ​​of the best matching block are processed and used as the predicted pixel values ​​of the current block. Using the refined optimal merge candidate for motion compensation of the current block can improve the compensation effect. Of course, S314 can also be an optional step, that is, the decoder can also directly use the optimal merge candidate for motion compensation of the current block without refining the optimal merge candidate. This application does not specifically limit this.

[0085] (2) Method for constructing the merged candidate list.

[0086] FIG4 is a schematic flowchart of a method 320 for constructing a merge candidate list provided in an embodiment of the present application.

[0087] As shown in FIG4 , the method 320 for constructing a merge candidate list may include:

[0088] S321, adding spatial domain merging candidates.

[0089] When building the merge candidate list, first add the spatial merge candidates.

[0090] Exemplarily, a spatial merging candidate may be constructed using indices and MVs of reference images of image blocks adjacent to the left side of the current block and / or image blocks adjacent to the top side of the current block.

[0091] FIG5 is a schematic flowchart of spatial merging candidates provided in an embodiment of the present application.

[0092] As shown in Figure 5, the image block where B1 is located represents the rightmost image block directly above the current block, the image block where A1 is located represents the image block directly below the left of the current block, the image blocks where B0 and A0 are located represent the image blocks closest to the upper right and lower left of the current block, respectively, and the image block where B2 is located represents the image block closest to the upper left of the current block. The merge candidate list is checked and added in the order of B1→A1→B0→A0→B2, and a maximum of 4 spatial merge candidates are selected. When image blocks B1, A1, B0, A0, or B2 are unavailable, for example, if they are all in intra-frame coding mode or the redundancy check is a duplicate MV, they are not added to the merge candidate list.

[0093] It is worth noting that since the image blocks adjacent to the left side of the current block and / or the image blocks adjacent to the top side of the current block are image blocks that have been encoded or decoded, spatial merging candidates can be constructed directly based on the index of the reference image of the encoded or decoded image blocks and the MV used.

[0094] Exemplarily, the redundancy check method can be performed in two ways:

[0095] The first redundancy check method:

[0096] A spatial merge candidate is considered redundant only if its MV value and reference image index are identical to those of a merge candidate already in the merge candidate list. In this case, the candidate is not added to the merge candidate list. Alternatively, the regular merge mode typically uses this method to check for redundancy.

[0097] The second redundancy check method:

[0098] If a spatial merge candidate has the same reference image index as an existing merge candidate in the merge candidate list, and its MV is very close to that of the existing merge candidate, it is considered redundant and is not added to the merge candidate list. Optionally, TM merge mode typically uses this method to check for redundancy.

[0099] Exemplarily, when the index of the reference image of the spatial merge candidate is the same as that of a certain merge candidate already existing in the merge candidate list, and the difference between the MV of the spatial merge candidate and the MV of the certain merge candidate is less than or equal to a preset threshold, it is determined that the spatial merge candidate and the certain merge candidate are redundant. Optionally, the preset threshold can be set according to the number of pixels S of the current block. For example, when S < 64, the threshold is set to 1 << 4; when 64 <= S < 256, the threshold is set to 2 << 4; when S >= 256, the threshold is set to 4 << 4; where x << y means shifting x to the left by y bits in binary form. Specifically, the high bits are shifted out and the empty positions in the low bits are filled with zeros. <= means less than or equal to, < means less than, and >= means greater than or equal to.

[0100] Exemplarily, the spatial merge candidate can be a merge candidate including a bidirectional MV.

[0101] When the spatial merge candidate includes a bidirectional MV (such as a first MV and a second MV), the index of the reference image of the first MV of the spatial merge candidate is the same as the index of the reference image of the first MV of the certain merge candidate, the index of the reference image of the second MV of the spatial merge candidate is the same as the index of the reference image of the second MV of the certain merge candidate, and the horizontal and vertical differences between the first MV of the spatial merge candidate and the first MV of the certain merge candidate, and the horizontal and vertical differences between the second MV of the spatial merge candidate and the second MV of the certain merge candidate are all less than the preset threshold, it is determined that the spatial merge candidate and the certain merge candidate are redundant. In other words, when there is a certain merge candidate in the merge candidate list whose horizontal and vertical differences from the first MV of the spatial merge candidate and from the second MV of the spatial merge candidate are both less than the preset threshold, and whose indexes of the reference images of the first MV and the second MV are the same as those of the spatial merge candidate, it can be determined that the spatial merge candidate and the certain merge candidate are redundant.

[0102] Exemplarily, the spatial merge candidate can be a merge candidate including a first MV (or a second MV).

[0103] When a spatial merge candidate includes a first MV (or a second MV), the index of the reference image of the first MV (or the second MV) of the spatial merge candidate is the same as the index of the reference image of the first MV (or the second MV) of the certain merge candidate, and the horizontal difference and vertical difference between the first MV (or the second MV) of the spatial merge candidate and the first MV (or the second MV) of the certain merge candidate are both less than a preset threshold, the spatial merge candidate and the certain merge candidate are determined to be redundant. In other words, when there is a merge candidate in the merge candidate list whose horizontal difference and vertical difference with the first MV (or the second MV) of the spatial merge candidate are both less than a preset threshold and whose reference image index value is the same, the spatial merge candidate and the certain merge candidate can be determined to be redundant.

[0104] Exemplarily, after completing the check and addition of the spatial merging candidates, the value of numCurrMergeCand may be recorded and updated, and at the same time, the value of numOrigMergeCand may also be updated.

[0105] S322: Add time domain merging candidates.

[0106] After adding spatial merge candidates, select a temporal merge candidate and add it to the merge candidate list. For example, after checking and adding spatial merge candidates, the value of numCurrMergeCand may be recorded and updated. At the same time, the value of numOrigMergeCand may also be updated. If numCurrMergeCand is less than MaxNumMergeCand, then further temporal merge candidates may be added.

[0107] Exemplarily, a preset number of time-domain merging candidates may be added to the merging candidate list.

[0108] For example, when adding a temporal merge candidate, a redundancy check is performed with the candidates already in the merge candidate list. The specific detection method can be the same as or different from the redundancy detection method for spatial merge candidates. To avoid repetition, this will not be described here.

[0109] Exemplarily, after checking and adding the time-domain merging candidates, the value of numCurrMergeCand is recorded and updated, and at the same time, the value of numOrigMergeCand may also be updated.

[0110] Exemplarily, the time-domain merging candidate may be obtained or derived from the perspective of input and output.

[0111] Input: Information about the current block.

[0112] Taking the current block as a luma coding block as an example, the information may also include the position of the luma coding block (xCb, yCb), the width cbWidth of the luma coding block, the height cbHeight of the luma coding block, and the index of the reference image refIdxLXCol, where X is 0 or 1.

[0113] Output: Temporal merge candidates.

[0114] The index of the reference image of the temporal merging candidate is the index of the input reference image.

[0115] It is worth noting that when adding a temporal merge candidate, a merge candidate list without the temporal merge candidate added can also be input, and the temporal merge candidate after the temporal merge candidate is added can be output, that is, the temporal merge candidate can be added from the input and output perspectives. The input merge candidate list may include the following information: the reference image index refIdxL0N (index of reference image L0) and refIdxL1N (index of reference image L1) corresponding to each merge candidate in the merge candidate list, the prediction list usage flag predFlagL0N (used to indicate whether reference image L0 is used) and predFlagL1N (used to indicate whether reference image L1 is used) corresponding to each merge candidate, the motion vector mvL0N (MV of the merge candidate relative to the reference block in reference image L0) and mvL1N (MV of the merge candidate relative to the reference block in reference image L1) corresponding to each merge candidate, and the number of merge candidates in the input merge candidate list numCurrMergeCand.

[0116] Exemplarily, the MV of the temporal merging candidate may be constructed using the MV of the co-located image block in the co-located image of the current image.

[0117] The collocated image of the current image may be an encoded image that is adjacent to the current image in the time domain. Optionally, the collocated image of the current image or the encoded image that is adjacent to the current image in the time domain may be indicated by the syntax element collocated_ref_idx in the header information of the current image. Accordingly, the collocated image block may be an image block in the collocated image that corresponds to the reference position of the current block; for example, the collocated image block may be an image block in the collocated image that includes the reference position of the current block.

[0118] FIG6 is a schematic diagram of a reference position provided in an embodiment of the present application.

[0119] As shown in FIG6 , if the image block at position C0 in the collocated image of the current image is unavailable or the coding mode of the image block at position C0 does not meet the requirements, the image block at position C1 in the collocated image of the current image is used as the collocated image block.

[0120] It should be understood that the present application does not specifically limit the method of adding time domain merge candidates. For example, the C0 position and the C1 position in Figure 6 are only examples of the present application and should not be understood as limitations on the present application. For example, in other alternative embodiments, the reference position may include other positions or multiple positions. Accordingly, when adding time domain merge candidates, the motion vector information of several preset positions (i.e., merge candidates) can be used for addition, or the motion vector information within the preset candidate range can be used to sort by template matching cost, and several motion vector information with smaller template matching cost can be selected for addition; or there is no need to sort, but the motion vector information within the preset candidate range can be used to compare the template matching cost first, and directly select several motion vector information with the smallest template matching cost, the second smallest template matching cost, etc. for addition.

[0121] Since the time interval between the current image and its reference image is often different from the time interval between the collocated image and its reference image, the temporal merging candidate cannot directly use the MV of the collocated image block. Instead, it must be scaled accordingly based on its positional relationship with the reference image.

[0122] FIG7 is a schematic diagram of the relationship between the MV of a co-located image block and the MV of a time-domain merging candidate provided in an embodiment of the present application.

[0123] As shown in Figure 7, assume that the time interval between the current image and its reference image is tb, and the time interval between the collocated image and its reference image is td. For example, tb and td can both be the difference in picture order count (POC). The temporal merge candidate for the current block is calculated as follows:

[0124]

[0125] Among them, MV col is the MV of the same image block. MVP cur Indicates the MV of the temporal merging candidate of the current block.

[0126] Exemplarily, when the current image in which the current block is located is a P frame, a unidirectional prediction time domain merge candidate can be constructed and added to the merge candidate list; when the current image is a B frame, a bidirectional prediction time domain merge candidate is constructed and added to the merge candidate list. It is worth noting that the unidirectional prediction time domain merge candidate includes a first MV (or a second MV), and the bidirectional prediction time domain merge candidate may include a bidirectional MV. The derivation method of the first MV (or the second MV) and the MV of the bidirectional MV in each direction can refer to the derivation method of the MV of the above-mentioned time domain merge candidate. To avoid repetition, it will not be repeated here.

[0127] S323, adding non-adjacent spatial domain merging candidates.

[0128] Exemplarily, after completing the check and addition of temporal merge candidates, the value of numCurrMergeCand is recorded and updated. At the same time, the value of numOrigMergeCand can also be updated. If numCurrMergeCand is less than MaxNumMergeCand, continue to add non-adjacent spatial merge candidates. Among them, the spatial merge candidate only uses the motion information of the neighboring blocks of the current block (i.e., MV and reference image index), and the non-adjacent spatial merge candidate can use the motion information of representative non-adjacent blocks in the surrounding positions of the current block (i.e., MV and reference image index).

[0129] Exemplarily, a preset number of non-adjacent spatial domain merging candidates may be added to the merging candidate list.

[0130] For example, when adding non-adjacent spatial merging candidates, a redundancy check is performed with the candidates already in the merging candidate list. The specific detection method can be the same as or different from the redundancy detection method for spatial merging candidates. To avoid repetition, this will not be described here.

[0131] Exemplarily, after completing the check and addition of non-adjacent spatial domain merging candidates, the value of numCurrMergeCand is recorded and updated, and at the same time, the value of numOrigMergeCand may also be updated.

[0132] FIG8 is a schematic diagram of the positions of non-adjacent blocks used to construct non-adjacent spatial merging candidates provided in an embodiment of the present application.

[0133] As shown in Figure 8, the adjacent blocks used to construct spatial merging candidates may include the image block at position 1 to the image block at position 5, and the non-adjacent blocks used to construct non-adjacent spatial merging candidates may include the image block at position 6 to the image block at position 23.

[0134] It should be understood that the present application does not specifically limit the method of adding non-adjacent spatial merging candidates. For example, positions 1 to 23 in Figure 8 are only examples of the present application and should not be understood as limiting the present application. For example, in other alternative embodiments, the positions of the non-adjacent blocks used to construct non-adjacent spatial merging candidates may include other positions. Accordingly, when adding non-adjacent spatial merging candidates, the motion vector information of several preset positions can be used for addition, or the motion vector information within the preset candidate range can be used to sort by template matching cost, and several motion vector information with smaller template matching cost can be selected for addition; or rather than sorting all of them, the motion vector information within the preset candidate range can be used to first compare the template matching cost, and directly select several motion vector information with the smallest template matching cost, the second smallest template matching cost, etc. for addition.

[0135] S324, adding history-based merge candidates.

[0136] For example, after completing the check and addition of non-adjacent spatial domain merge candidates, the value of numCurrMergeCand is recorded and updated, and the value of numOrigMergeCand is updated. If numCurrMergeCand is less than MaxNumMergeCand, the history-based merge candidates are continued to be added.

[0137] Exemplarily, history-based merge candidates store the motion information (i.e., MV and reference image index) of previously coded blocks in a list of a specified maximum length to construct the history-based merge candidate list. The history-based merge candidate list is continuously updated during the encoding process. After each inter-coded image block is encoded or decoded, its motion information (i.e., MV and reference image index) is added as a new candidate to the end of the history-based merge candidate list. Existing candidates in the history-based merge candidate list are then checked for redundancy. If the newly inserted candidate duplicates an existing candidate in the list, the existing candidate is deleted. Finally, the maximum length of the history-based merge candidate list is maintained according to the first-in, first-out principle. That is, if the number of candidates in the history-based merge candidate list exceeds the maximum length after adding a new candidate, the first candidate is deleted. The lifecycle of the history-based merge candidate list is each coding tree unit row, meaning that the history-based merge candidate list is cleared each time a new coding tree unit row is reached.

[0138] Based on this, after the non-adjacent airspace merge candidate check is completed, if there are still vacant positions in the merge candidate list, the candidates in the history-based merge candidate list are checked one by one through redundancy check starting from the end (latest) and adding non-redundant candidates to the subsequent vacant positions in the merge candidate list until the options in the history-based merge candidate list are exhausted or the merge candidate list is filled.

[0139] Exemplarily, after completing the check and addition of non-adjacent spatial domain merging candidates, the value of numCurrMergeCand is recorded and updated, and the value of numOrigMergeCand is updated at the same time.

[0140] S325, adding pairwise average merging candidates.

[0141] For example, after completing the check and addition of H merge candidates, the value of numCurrMergeCand is recorded and updated, and the value of numOrigMergeCand can also be updated. If numCurrMergeCand is less than MaxNumMergeCand, pairwise average merge candidates are continued to be added. In other words, after completing the check and addition of non-adjacent spatial merge candidates, if there are still vacancies in the merge candidate list, pairwise average merge candidates are continued to be used to supplement the merge candidate list.

[0142] For example, when adding a pairwise average merge candidate, a redundancy check is performed with the candidates already in the merge candidate list. The specific detection method can be the same as or different from the redundancy detection method for spatial merge candidates. To avoid repetition, this will not be described here.

[0143] Exemplarily, the pairwise average merge candidate is obtained by the first two candidates in the merge candidate list.

[0144] If both Cand0 and Cand1 exist, the MV of the pairwise average merge candidate is:

[0145] mvAvgLX=(mvCand0LX+mvCand1LX+(1,1))>>1;

[0146] Among them, mvAvgLX represents the pairwise average merge candidate, LX represents the index of the reference image, X is 0 or 1, mvCand0LX and mvCand1LX are the MV of the merge candidate with the index LX of the first reference image in the merge candidate list and the MV of the merge candidate with the index LX of the second reference image in the merge candidate list, respectively, + represents a vector addition operation, and >> represents a right shift operation.

[0147] If only Cand0 exists, the MV of the pairwise average merge candidate is:

[0148] mvAvgLX=mvCand0LX;

[0149] If only Cand1 exists, the MV of the pairwise average merge candidate is:

[0150] mvAvgLX=mvCand1LX

[0151] For example, when the current image in which the current block is located is a P frame, a unidirectional prediction average merge candidate is constructed, and when the current image is a B frame, a bidirectional prediction average merge candidate is constructed. It is worth noting that the unidirectional prediction average merge candidate includes a first MV (or a second MV), and the bidirectional prediction average merge candidate may include a bidirectional MV. The derivation method of the first MV (or the second MV) and the MV of the bidirectional MV in each direction can be referred to the derivation method of the MV of the above-mentioned average merge candidate. To avoid repetition, it is not repeated here.

[0152] For example, after completing the check and addition of the pairwise average merge candidates, the value of numCurrMergeCand is recorded and updated, and the value of numOrigMergeCand is also updated. At this point, the final value of numOrigMergeCand is obtained, which records the number of merge candidates in the merge candidate list before the zero motion vector merge candidate is filled.

[0153] S326, adding a zero motion vector merge candidate.

[0154] For example, after completing the check and addition of the pairwise average merge candidates, the value of numCurrMergeCand is recorded and updated, and the value of numOrigMergeCand is also updated. If numCurrMergeCand is still less than MaxNumMergeCand, continue to add zero motion vector merge candidates.

[0155] Exemplarily, a zero motion vector merge candidate may be added from the perspective of input and output.

[0156] Input: merge candidate list, index of the reference image refIdxL0N (index of reference image L0) and refIdxL1N (index of reference image L1) corresponding to each merge candidate in the merge candidate list, prediction list usage flag predFlagL0N (used to identify whether reference image L0 is used) and predFlagL1N (used to identify whether reference image L1 is used) corresponding to each merge candidate, motion vector mvL0N (MV of the merge candidate relative to the reference block in reference image L0) and mvL1N (MV of the merge candidate relative to the reference block in reference image L1) corresponding to each merge candidate, number of merge candidates in the merge candidate list numCurrMergeCand.

[0157] Output: merge candidate list, the number of merge candidates in the merge candidate list numCurrMergeCand, the index of the reference image refIdxL0zeroCandm (index of reference image L0) and refIdxL1zeroCandm (index of reference image L1) corresponding to each zero motion vector merge candidate newly added to the merge candidate list, the prediction list usage flag predFlagL0zeroCandm (used to identify whether reference image L0 is used) and predFlagL1zeroCandm (used to identify whether reference image L1 is used) corresponding to each zero motion vector merge candidate, the motion vector mvL0zeroCandm (the MV of each zero motion vector merge candidate relative to the reference block in the reference image L0) and mvL1zeroCandm (the MV of each zero motion vector merge candidate relative to the reference block in the reference image L0) corresponding to each zero motion vector merge candidate.

[0158] Exemplarily, if numCurrMergeCand is less than MaxNumMergeCand, the unidirectional or bidirectional zero motion vector merge candidates with a value of (0,0) are filled into the merge candidate list. The reference image index corresponding to the first zero motion vector merge candidate is 0, and then zero motion vector merge candidates are constructed corresponding to each reference image in L0 or L1 in the ascending direction of the reference image index until the number of merge candidates in the merge candidate list reaches the specified number. When the index of the reference image is in ascending order to the maximum index value, if the number of merge candidates in the merge candidate list has not reached the specified number, the index of the reference image of the subsequently added zero motion vector merge candidate is 0 or is restarted from 0 and in ascending order to the maximum index value.

[0159] It is worth noting that no redundancy check is performed during the process of adding zero motion vector merge candidates. The purpose is to fill the merge candidate list with enough candidates to be MaxNumMergeCand. The number of zero motion vector merge candidates filled is numZeroMergeCand which is equal to numCurrMergeCand - numOrigMergeCand.

[0160] (3) Use ARMC technology to reorder the merge candidate list.

[0161] ARMC reorders the merge candidates in the merge candidate list based on the template matching cost. ARMC is applicable to regular merge mode, Affine merge mode, or TM merge mode. For TM merge mode, ARMC can be performed before TM refines the candidates.

[0162] After constructing the merge candidate list, when the merge candidate list is reordered using the ARMC technology, the merge candidates in the merge candidate list can be divided into several subgroups. For example, for the normal merge mode and the TM merge mode, the size of the subgroup is set to 5; for the Affine merge mode, the size of the subgroup is set to 3. The merge candidates in each subgroup are sorted from small to large according to the template matching cost. The template matching cost is the SAD value between the template of the current block and the template of the reference block of the merge candidate. Of course, its matching cost is not limited to the sum of absolute differences (SAD). In order to improve the matching accuracy, the sum of absolute transformed differences (SATD), the sum of squares for error (SSE), the mean square error (MSE) or other more complex costs can also be used. This application does not make specific limitations on this.

[0163] Exemplarily, the template of the current block includes reconstructed samples in an upper row and a left column of the current block.

[0164] Exemplarily, when a merge candidate uses bidirectional prediction, the template of the reference block of the merge candidate is also found through bidirectional prediction.

[0165] FIG9 is a schematic diagram of a template of a reference block and a template of a current block of a merging candidate provided in an embodiment of the present application.

[0166] As shown in Figure 9, the template of the current block includes the reconstructed samples of the previous row and the left column of the current block. When the merge candidate uses bidirectional prediction, the first reference block template includes the reconstructed samples of the previous row and the left column of the first reference block in the first reference image, and the second reference block template includes the reconstructed samples of the previous row and the left column of the second reference block in the second reference image. When calculating the template matching cost of the merge candidate, the first reference block template and the second reference block template can be averaged first, and then the SAD value can be calculated based on the obtained average value and the template of the current block, and the obtained SAD value is used as the template matching cost of the merge candidate.

[0167] Exemplarily, for each sub-block-based merge candidate with a sub-block size equal to Wsub×Hsub, the template of the reference block of the merge candidate may include an upper reference template and a left reference template, wherein the upper reference template includes a template of Wsub×1 reference sub-blocks and the left reference template includes a template of 1×Hsub reference sub-blocks.

[0168] FIG10 is another schematic diagram of merging a template of a candidate reference block and a template of a current block provided by an embodiment of the present application.

[0169] As shown in Figure 10, the template of the current block includes the reconstructed samples of the previous row and the left column of the current block. For each subblock-based merge candidate with a subblock size of 4×4, the template of the reference block of the merge candidate may include an upper reference template and a left reference template, where the upper reference template includes the template of the 4×1 reference subblocks and the left reference template includes the template of the 1×4 reference subblocks. The template of the 4×1 reference subblocks includes the reference subblock of subblock A (i.e., A ref), the reference subblock of subblock B (i.e., B ref), the reference subblock of subblock C (i.e., C ref), and the reference subblock of subblock D (i.e., D ref). The template of the 1×4 reference subblocks includes the reference subblock of subblock A (i.e., A ref), the reference subblock of subblock E (i.e., E ref), the reference subblock of subblock F (i.e., F ref), and the reference subblock of subblock G (i.e., G ref). For example, the upper reference template is the template obtained by splicing the upper templates of 4×1 reference sub-blocks, and the left reference template is the template obtained by splicing the left templates of 1×4 reference sub-blocks. Based on this, after splicing together the template of the reference block, the SAD of the template of the reference block and the template of the current block can be calculated and used as the template matching cost of the merge candidate.

[0170] Of course, in other alternative embodiments, the template matching cost of the merged candidate may be calculated in other ways, and this application does not make any specific limitation on this.

[0171] It is worth noting that in other alternative embodiments, the ARMC technology can also be extended to the Combined Inter and Intra Prediction (CIIP) mode, the Bilateral Matching (BM) merge mode, and the Intra Block Copy (IBC) mode, which is not specifically limited in this application.

[0172] The following is an exemplary description of the derivation algorithm related to ARMC.

[0173] 1. The derivation algorithm of the number of candidates participating in ARMC sorting.

[0174] For example, the implementation of the derivation algorithm of the number of candidates numSortMVP participating in ARMC sorting can be as follows:

[0175] Input: numOrigMergeCand, the number of merge candidates in the merge candidate list before filling with zero motion vector merge candidates.

[0176] Output: The number of merge candidates participating in ARMC sorting numSortMVP.

[0177] The value of numSortMVP is set equal to numOrigMergeCand output when constructing the merge candidate list, which records the number of merge candidates in the merge candidate list before zero motion vector merge candidates are filled.

[0178] 2. Derivation algorithm for the reordered merge candidate list.

[0179] For example, the implementation of the derivation algorithm of the reordered merge candidate list may be as follows:

[0180] Input to the ARMC module: information about the current block, the merge candidate list before sorting, and the number of merge candidates numOrigMergeCand in the merge candidate list before filling with zero motion vector merge candidates.

[0181] Taking the current block as the current luminance coding block as an example, the input of the ARMC may include: the position (xCb, yCb) of the current luminance coding block, the width cbWidth of the luminance coding block, and the height cbHeight of the luminance coding block.

[0182] Output of the ARMC module: reordered merge candidate list mergeCandList.

[0183] 3. Derivation algorithm for the reordered merge candidate list.

[0184] For example, the implementation of the derivation algorithm of the reordered merge candidate list may be as follows:

[0185] Input to the ARMC module: information about the current block, the merge candidate list before sorting, and the number of merge candidates numSortMVP participating in ARMC sorting.

[0186] Taking the current block as the current luminance coding block as an example, the input of the ARMC may include: the position (xCb, yCb) of the current luminance coding block, the width cbWidth of the luminance coding block, and the height cbHeight of the luminance coding block.

[0187] Output of the ARMC module: reordered merge candidate list mergeCandList.

[0188] It is worth noting that assigning a specific value to numSortMVP can have different choices in different scenarios. If all merge candidates are sorted, numSortMVP is set to be equal to MaxNumMergeCand; if only the merge candidates in the merge candidate list before the zero motion vector merge candidate is filled are sorted, numSortMVP is set to be equal to numOrigMergeCand; if a specified number of merge candidates are specified in all merge candidate lists to be sorted, numSortMVP can be set to other preset values. This embodiment of the application does not specifically limit this.

[0189] That is, in one implementation, the number of candidates participating in ARMC sorting can be first determined based on an algorithm for deriving the number of candidates participating in ARMC sorting, and then the re-sorted merge candidate list can be derived based on an algorithm for deriving the re-sorted merge candidate list. In another implementation, the step of deriving the number of candidates participating in ARMC sorting, numSortMVP, can also be weakened or made an optional step, that is, the re-sorted merge candidate list can be derived. In this case, the number of merge candidates participating in ARMC sorting, numSortMVP, can be used as an input parameter, and it can be directly set to be equal to numOrigMergeCand or other corresponding values.

[0190] 4. Algorithm for deriving the template matching cost of the current merge candidate.

[0191] For example, the implementation of the algorithm for deriving the template matching cost of the current merge candidate may be as follows:

[0192] Input: information about the current block and the current merge candidate.

[0193] Taking the current block as the current luminance coding block as an example, the input of the ARMC may include: the position (xCb, yCb) of the current luminance coding block, the width cbWidth of the luminance coding block, and the height cbHeight of the luminance coding block.

[0194] Output: Template matching cost of the current merge candidate.

[0195] In a specific implementation, the preset areas above and to the left of the current block can be used as the template of the current block; the template of the reference block is determined based on the index and MV of the reference image indicated by the current merge candidate and combined with xCb and yCb; then, the template matching cost between the template of the reference block and the template of the current block is calculated, such as the sum of absolute differences (SAD). In order to improve the matching accuracy, the sum of absolute transformed differences (SATD), sum of squares for error (SSE), mean square error (MSE) or other more complex costs can also be used, and the calculated template matching cost of the current merge candidate is returned.

[0196] (4) The embodiments of the present application improve the ARMC technology.

[0197] In order to ensure the construction effect of the merge candidate list, ARMC technology can be extended to the construction process of the merge candidate list. Before adding time domain merge candidates, ARMC technology can be used to select several candidates with relatively small template matching costs from multiple time domain merge candidates and then add them to the merge candidate list. Similarly, before adding non-adjacent spatial domain merge candidates, ARMC technology can be used to select several candidates with relatively small template matching costs from multiple non-adjacent time domain merge candidates and then add them to the merge candidate list.

[0198] In addition, after constructing the merge candidate list, when re-sorting the merge candidate list using the ARMC technology, the grouping idea can be abandoned and the entire merge candidate list can be directly sorted to obtain the merge candidate list sorted by ARMC.

[0199] FIG11 is a schematic diagram of reordering the entire merge candidate list based on template matching cost using ARMC technology provided in an embodiment of the present application.

[0200] As shown in Figure 11, assume that the merge candidate list includes merge candidate 0 to merge candidate 9 in sequence, where merge candidate 0 to merge candidate 4 are merge candidates added before the zero motion vector merge candidate is added, and merge candidate 5 to merge candidate 9 are the last zero motion vector merge candidates added. If the entire merge candidate list is directly sorted, the merge candidate list after ARMC sorting includes: merge candidate 0, merge candidate 5 to merge candidate 9, merge candidate 1, merge candidate 2, merge candidate 4, and merge candidate 3.

[0201] However, since the end of the merge candidate list is filled with zero motion vector merge candidates, after the entire merge candidate list is ARMC sorted using ARMC technology, multiple zero motion vector merge candidates may be ranked at the front of the list. However, multiple zero motion vector merge candidates being ranked at the front of the list will affect the coding efficiency of the candidate index of the optimal merge candidate. In view of this, the present application considers that the zero motion vector merge candidates filled at the end of the merge candidate list may not participate in the ARMC sorting, that is, only the merge candidates other than the zero motion vector merge candidates in the merge candidate list are ARMC sorted. In this way, it can not only avoid the possibility that multiple zero motion vector merge candidates may be ranked at the front of the re-sorted list, thereby reducing their impact on the coding efficiency of the candidate index of the optimal merge candidate; in addition, the template acquisition and calculation operations are no longer performed on the last few zero motion vector merge candidates, thereby reducing the computational complexity of the ARMC technology.

[0202] FIG12 is a schematic diagram of performing ARMC sorting on the merge candidates in the merge candidate list except for the zero motion vector merge candidate using the ARMC technology provided in an embodiment of the present application.

[0203] As shown in Figure 12, assume that the merge candidate list includes merge candidate 0 to merge candidate 9 in sequence, where merge candidate 0 to merge candidate 4 are merge candidates added before the zero motion vector merge candidate is added, and merge candidate 5 to merge candidate 9 are the zero motion vector merge candidates added last. If only merge candidate 0 to merge candidate 4 in the merge candidate list are ARMC sorted, the merge candidate list after ARMC sorting includes: merge candidate 0, merge candidate 1, merge candidate 2, merge candidate 4, merge candidate 3, and merge candidate 5 to merge candidate 9 in sequence.

[0204] However, only ARMC sorting is performed on the merge candidates in the merge candidate list except for the zero motion vector merge candidate, and the following Technical issues:

[0205] 1. When constructing a merge candidate list, if the merge candidate list does not contain a zero motion vector merge candidate in the merge candidates added before filling the zero motion vector merge candidate, then after ARMC sorting by this method, the zero motion vector merge candidate does not participate in the ARMC sorting. If the encoder selects the zero motion vector merge candidate as the optimal MVP based on the merge candidate list after ARMC sorting, the number of bits required to encode the candidate index corresponding to the optimal merge candidate will increase, resulting in a decrease in encoding performance.

[0206] 2. If the reference block corresponding to the zero motion vector merge candidate and the current block have a high degree of match, but the zero motion vector merge candidate filled in the merge candidate list does not participate in the ARMC sorting, that is, the zero motion vector merge candidate will be at the end of the merge candidate list after ARMC sorting, resulting in the zero motion vector merge candidate not being selected as the best MVP, which reduces the prediction accuracy of the MV of the current block, which may cause a large deviation between the predicted value and the original value of the current block, resulting in a decrease in coding performance.

[0207] In view of this, the embodiment of the present application provides a video encoding method and a video decoding method. In the video encoding method, the following steps 101 to 104 are included:

[0208] Step 101: The encoder determines an initial motion information candidate list for a current block, the initial motion information candidate list comprising a first category of motion information candidates and a second category of motion information candidates, wherein the first category of motion information candidates is determined based on motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second category of motion information candidates is constructed based on a reference image index set using a preset rule and a motion vector with a preset value.

[0209] Step 102: The encoder sorts some of the motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer.

[0210] Step 103: The encoder determines a motion information candidate index of the current block according to the motion information candidate list of the current block;

[0211] Step 104: The encoder encodes the motion information candidate index of the current block and writes the encoded bits into a bitstream.

[0212] In the embodiment of the present application, since some of the motion information candidates participating in the sorting in the initial motion information candidate list of the current block include not only at least one first-category motion information candidate, but also N second-category motion information candidates, the following situation is avoided: if all second-category motion information candidates in the initial motion information candidate list of the current block participate in the sorting, when a candidate in the second-category motion information candidate is selected as the motion information candidate for the current block, the number of bits required for the corresponding candidate index value increases. In other words, in the embodiment of the present application, the N second-category motion information candidates in the initial motion information candidate list of the current block also participate in the sorting. If a candidate in the second-category motion information candidate participating in the sorting is selected as the motion information candidate for the current block, then since the index value of the candidate may be smaller, the number of bits required for encoding is reduced, thereby improving encoding efficiency.

[0213] The video decoding method includes the following steps 111 to 116:

[0214] Step 111: The decoder determines an initial motion information candidate list for the current block, the initial motion information candidate list comprising a first category of motion information candidates and a second category of motion information candidates, wherein the first category of motion information candidates is determined based on motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second category of motion information candidates is constructed based on a reference image index set using a preset rule and a motion vector with a preset value.

[0215] Step 112: The decoder sorts some of the motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer;

[0216] Step 113: The decoder decodes the bitstream and determines a candidate motion information index of the current block;

[0217] Step 114: The decoder determines an inter-frame prediction value of the current block according to the motion information candidate index of the current block and the motion information candidate list;

[0218] Step 115: The decoder decodes the bitstream to determine the residual value of the current block;

[0219] Step 116: The decoder determines a reconstructed value of the current block according to the residual value of the current block and the inter-frame prediction value.

[0220] In the embodiment of the present application, since some of the motion information candidates participating in the sorting in the initial motion information candidate list of the current block include not only at least one first-category motion information candidate but also N second-category motion information candidates, the following situation is avoided: since all second-category motion information candidates in the initial motion information candidate list of the current block are located at the end of the list, due to the large rate-distortion cost, none of these motion information candidates are selected as motion information candidates for the current block, while the reference block corresponding to one of these motion information candidates has a high degree of match with the current block, and the accuracy of inter-frame prediction is reduced due to its non-selection. In other words, in the embodiment of the present application, the N second-category motion information candidates in the initial motion information candidate list of the current block are also involved in the sorting, which gives the second-category motion information candidate corresponding to the reference block with a high degree of match with the current block the opportunity to be ranked in a front position, thereby increasing the chance of the motion information candidate being selected as the motion information candidate for the current block, increasing the probability of improving the accuracy of inter-frame prediction, that is, improving decoding performance.

[0221] The following describes further optional implementations and related terms of each of the above steps.

[0222] In the embodiment of the present application, the first type of motion information candidate is not limited to any type, and may be at least one of a spatial motion information candidate, a temporal motion information candidate, a non-adjacent spatial motion information candidate, a history-based motion information candidate, and a pairwise average motion information candidate. Motion information candidates are also called merge candidates.

[0223] In some embodiments, the values ​​of the two components of the motion vector with the preset value are both equal to 0. Accordingly, the second type of motion information candidate can be called a zero motion vector merge candidate.

[0224] In some embodiments, the N second-category motion information candidates included in the partial motion information candidates are the N second-category motion information candidates that are sequentially added to the initial motion information candidate list during the process of constructing the initial motion information candidate list.

[0225] Further, in some embodiments, the N second-category motion information candidates included in the partial motion information candidates are the N second-category motion information candidates that are sorted after the first-category motion information candidates in the initial motion information candidate list.

[0226] In some embodiments, the partial motion information candidates include all first-category motion information candidates in the initial motion information candidate list.

[0227] In some embodiments, N is a preset value. For example, the value of N is equal to 1, 2, or 3. In another example, the value of N is less than or equal to the number of reference images allowed for use. In another example, the value of N is less than the number of second-category motion information candidates included in the initial motion information candidate list; wherein the number of second-category motion information candidates is greater than or equal to 2.

[0228] In some embodiments, the N second-category motion information candidates are non-redundant with the first-category motion information candidates, and the N second-category motion information candidates in the partial motion information candidates are second-category motion information candidates that do not meet the first condition in the initial motion information candidate list. Further, in some embodiments, the first condition is that the motion vector and reference image index of the second-category motion information candidate are equal to the motion vector and reference image index of the first-category motion information candidate; or, in other embodiments, the first condition is that the second-category motion information candidate is close to the first-category motion information candidate included in the partial motion information candidates, including: the reference image index of the second motion information candidate is equal to the reference image index of the first motion information candidate, and at least one of the following conditions is met: the absolute value of the difference between the vertical component of the motion vector of the second motion information candidate and the vertical component of the motion vector of the first motion information candidate is less than a first threshold; the absolute value of the difference between the horizontal component of the motion vector of the second motion information candidate and the horizontal component of the motion vector of the first motion information candidate is less than a second threshold.

[0229] From another perspective, the N second-category motion information candidates in the partial motion information candidates are second-category motion information candidates in the initial motion information candidate list that meet a fourth condition. In some embodiments, the fourth condition is that the second-category motion information candidates are different from the first-category motion information candidates included in the partial motion information candidates, including: a motion vector of the second-category motion information candidate is not equal to a motion vector of the first-category motion information candidate; or a reference image index of the second-category motion information candidate is not equal to a reference image index of the first-category motion information candidate; or both a motion vector and a reference image index of the second-category motion information candidate are not equal to those of the first-category motion information candidate.

[0230] In other embodiments, the fourth condition is that the second-category motion information candidate is not close to the first-category motion information candidate included in the partial motion information candidates, including: the reference image index of the second motion information candidate is equal to the reference image index of the first motion information candidate, and at least one of the following conditions is met: the absolute value of the difference between the vertical component of the motion vector of the second motion information candidate and the vertical component of the motion vector of the first motion information candidate is greater than a first threshold; the absolute value of the difference between the horizontal component of the motion vector of the second motion information candidate and the horizontal component of the motion vector of the first motion information candidate is greater than a second threshold.

[0231] In some other embodiments, the N second-category motion information candidates in the partial motion information candidates are second-category motion information candidates in the initial motion information candidate list that meet the second condition.

[0232] Furthermore, in some embodiments, the second condition includes: after adaptively reordering the second-category motion information candidates in the initial motion information candidate list, selecting the first second-category motion information candidate in the newly ordered order.

[0233] In some other embodiments, the second condition includes: a second type of motion information candidate having a minimum template matching error in the initial motion information candidate list.

[0234] In some embodiments, the current block contains at least a first number of sample values. Further, in some embodiments, the first number is 16.

[0235] In some other embodiments, the size of the current block meets a preset third condition.

[0236] Furthermore, in some embodiments, the third condition is that the width and height of the current block are less than or equal to a first preset size value, for example, the first preset size value is 128x128.

[0237] Furthermore, in some other embodiments, the third condition is that the width and height of the current block are greater than or equal to a second preset size value. For example, the second preset size value is 4x4.

[0238] Furthermore, in some other embodiments, the third condition is that the width and height of the current block are less than or equal to a first preset size value, and the width and height of the current block are greater than or equal to a second preset size value. For example, the first preset size value is 128x128, and the second preset size value is 4x4.

[0239] In some embodiments, sorting some motion information candidates in the initial motion information candidate list to determine the motion information candidate list of the current block includes: determining the template matching error of the some motion information candidates; and sorting the some motion information candidates according to the template matching error.

[0240] Further, in some embodiments, determining the template matching error of the partial motion information candidate includes: determining the template of the current block; determining the corresponding template of the template in the reference image indicated by the reference image index of the partial motion candidate based on the motion vector of the partial motion information candidate; and determining the template matching error based on the template and the corresponding template.

[0241] Furthermore, in some embodiments, determining the template matching error based on the template and the corresponding template includes: calculating the error between the template and the corresponding template based on a preset error criterion.

[0242] For example, the error criterion is one of the following: SAD, STAD, MSE, SSD; accordingly, the partial motion information candidates are sorted according to the template matching error, including: sorting the partial motion information candidates in order from small to large according to the template matching error.

[0243] For another example, the error criterion is one of the following: PSNR, SSIM. Accordingly, sorting the partial motion information candidates according to the template matching error includes sorting the partial motion information candidates in descending order of the template matching error.

[0244] In some embodiments, the partial motion information candidates are M motion information candidates, where M is an integer greater than 1. Accordingly, determining the motion information candidate list for the current block includes: the sorted partial motion information candidates correspond to motion information candidate indexes 0 to M-1 in the motion information candidate list for the current block.

[0245] In some embodiments, the method further includes: determining other motion information candidates in a motion information candidate list of the current block except the sorted partial motion information.

[0246] In some embodiments, the motion information candidate index corresponding to the unsorted other motion information candidates or the sorted other motion information candidates in the motion information candidate list of the current block is greater than the motion information candidate index corresponding to the sorted partial motion information candidates.

[0247] In some embodiments, the method further comprises: sorting the other motion information candidates using the same sorting method as that used for sorting the partial motion information candidates.

[0248] FIG13 is a schematic flow chart of a sorting method 400 provided in an embodiment of the present application. It should be understood that the sorting method 400 can be performed by a sorting device. For example, when the sorting device is a decoder or a unit module in a decoding framework, the sorting method 400 can be performed by a decoder or the decoding framework 200 shown in FIG2 . For another example, when the sorting device is an encoder or a unit module in an encoding framework, the sorting method can be performed by an encoder or the encoding framework 100 shown in FIG1 . For ease of description, the following description will be made using a sorting device as an example.

[0249] As shown in FIG13 , the sorting method 400 may include some or all of the following:

[0250] S410: Based on the zero motion vector merge candidate in the first merge candidate list, determine a first number of merge candidates participating in sorting in the first merge candidate list:

[0251] S420: Sort the merging candidates in the first merging candidate list based on the first number to obtain a second merging candidate list.

[0252] By considering the zero motion vector merge candidates in the first merge candidate list, the first number of merge candidates participating in the sorting in the first merge candidate list is determined, which is equivalent to determining the first number from the zero motion vector merge candidates in the first merge candidate list; instead of directly determining the first number from the perspective of all merge candidates in the first merge candidate list or from the perspective of non-zero motion vector merge candidates in the first merge candidate list, which is beneficial to avoid the situation where all zero motion vector merge candidates in the first merge candidate list participate in the sorting or do not participate in the sorting, thereby improving the accuracy of the second merge candidate list, and thus improving the encoding and decoding performance.

[0253] It should be understood that in an embodiment of the present application, the first merge candidate list may be the merge candidate list mentioned above, and the second merge candidate list may be the merge candidate list after sorting the merge candidate list. Accordingly, the specific implementation method of the merge candidate list can refer to the relevant content involved in S320 above; in addition, the present application aims to improve the number of merge candidates participating in the sorting when sorting the merge candidates in the first merge candidate list. The rest of the principles related to sorting (such as the derivation of the matching cost algorithm and the derivation of the sorted merge candidate list) can refer to the relevant content involved in S312; in addition, after obtaining the second merge candidate list, the application of the second merge candidate list can refer to the relevant content involved in S314 and S315 above. In order to avoid repetition, it will not be repeated here.

[0254] In some embodiments, the S410 may include:

[0255] The first number is determined based on whether there is redundancy between an N-th zero motion vector merge candidate in the first merge candidate list and a merge candidate located before the N-th zero motion vector merge candidate in the first merge candidate list.

[0256] Exemplarily, when introducing redundancy detection for the zero motion vector merge candidate in the first merge candidate list, N can be determined first, and then redundancy detection is performed only on the Nth zero motion vector merge candidate, and then the first number is determined based on whether there is redundancy between the Nth zero motion vector merge candidate in the first merge candidate list and the merge candidate in the first merge candidate list that is located before the Nth zero motion vector merge candidate.

[0257] Exemplarily, the value of N is an integer greater than or equal to 1.

[0258] Exemplarily, the value of N is less than the total number of zero motion vector merge candidates in the first merge candidate list, that is, the Nth zero motion vector merge candidate is the zero motion vector merge candidate in the first merge candidate list except the last zero motion vector merge candidate.

[0259] Exemplarily, whether to consider the 1st zero motion vector merge candidate to the Nth zero motion vector merge candidate, or whether to participate in the sorting of the 1st zero motion vector merge candidate to the Nth zero motion vector merge candidate, can be determined based on whether there is redundancy between the Nth zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the Nth zero motion vector merge candidate.

[0260] Of course, in other alternative embodiments, it can also be determined whether to consider the 1st zero motion vector merge candidate to the N-1th zero motion vector merge candidate, or whether to participate in the sorting of the 1st zero motion vector merge candidate to the N-1th zero motion vector merge candidate based on whether there is redundancy between the Nth zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the Nth zero motion vector merge candidate; it can also be determined whether to consider the Nth zero motion vector merge candidate, or whether to participate in the sorting of the Nth zero motion vector merge candidate based on whether there is redundancy between the Nth zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the Nth zero motion vector merge candidate.

[0261] Exemplarily, the implementation of the derivation algorithm of the first quantity may be as follows:

[0262] Input: the first merge candidate list and the Nth zero motion vector merge candidate.

[0263] Output: the number of merge candidates participating in the sorting, that is, the first number.

[0264] The value of the first number is set to be equal to M+N-1 or M+N. M represents the number of merge candidates included in the first merge candidate list before adding the zero motion vector merge candidate.

[0265] It is worth noting that N can be chosen differently, for example, 1, 2, or other values.

[0266] In some embodiments, if there is redundancy between the Nth zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the Nth zero motion vector merge candidate, M+N-1 is determined as the first number; otherwise, M+N is determined as the first number; wherein M represents the number of merge candidates included in the first merge candidate list before the zero motion vector merge candidate is added.

[0267] Exemplarily, the Nth zero motion vector merge candidate may also be referred to as the M+Nth merge candidate in the first merge candidate list.

[0268] Exemplarily, M represents the number of merge candidates included in the first merge candidate list before the zero motion vector merge candidate is added. More specifically, the number before the zero motion vector merge candidate is added may refer to: after the spatial merge candidate, temporal merge candidate, non-adjacent spatial merge candidate, history-based merge candidate, and pairwise average merge candidate are added, and before the zero motion vector merge candidate is added. In other words, M may be the number of merge candidates in the first merge candidate list after the spatial merge candidate, temporal merge candidate, non-adjacent spatial merge candidate, history-based merge candidate, and pairwise average merge candidate are added.

[0269] Exemplarily, M may also be referred to as the numOrigMergeCand mentioned above, and the first number may also be referred to as the number of merge candidates involved in the sorting mentioned above, numSortMVP. When performing a redundancy check on the numOrigMergeCand+Nth merge candidate in the first merge candidate list (i.e., the Nth zero motion vector merge candidate), a redundancy check may be performed on the first numOrigMergeCand+N-1 merge candidates and the numOrigMergeCand+Nth merge candidate in the first merge candidate list: if redundancy exists, numSortMVP is set to be equal to numOrigMergeCand+N-1. If redundancy does not exist, numSortMVP is set to be equal to numOrigMergeCand+N.

[0270] Exemplarily, taking N=1 as an example, if there is redundancy between the first zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the first zero motion vector merge candidate, M is determined as the first number; otherwise, M+1 is determined as the first number; wherein M represents the number of merge candidates included in the first merge candidate list before the zero motion vector merge candidate is added.

[0271] In this embodiment, if the Nth zero motion vector merge candidate has no redundancy with the merge candidate before the Nth zero motion vector merge candidate in the first merge candidate list, the Nth zero motion vector merge candidate is sorted together with the merge candidate before the Nth zero motion vector merge candidate in the first merge candidate list to obtain a second merge candidate list. This is not only beneficial for avoiding the undesirable situation caused by involving all zero motion vector merge candidates in the sorting, but also can ensure that the zero motion vector merge candidate has the opportunity to participate in the sorting, so that there is an opportunity to use the zero motion vector merge candidate as the best merge candidate for post-processing and motion compensation, which can improve the quality to a certain extent, and thus improve the encoding and decoding performance.

[0272] FIG14 is a schematic diagram of performing ARMC sorting on the first merge candidate list based on the first quantity provided in an embodiment of the present application.

[0273] As shown in Figure 14, assume that the first merge candidate list includes merge candidate 0 to merge candidate 9 in sequence, among which merge candidate 0 to merge candidate 4 are merge candidates added before the zero motion vector merge candidate is added, and merge candidate 5 to merge candidate 9 are the last added zero motion vector merge candidates.

[0274] If the Nth zero motion vector merge candidate is the first zero motion vector merge candidate, that is, N=1; then based on whether there is redundancy between the first zero motion vector merge candidate in the first merge candidate list and the merge candidate located before the first zero motion vector merge candidate in the first merge candidate list, the number of merge candidates participating in the sorting, numSortMVP, is determined. For example, if there is redundancy between the first zero motion vector merge candidate and the merge candidate located before the first zero motion vector merge candidate in the first merge candidate list, numSortMVP is determined to be 5+1-1=5; otherwise, numSortMVP is determined to be 5+1=6. If numSortMVP is 6, ARMC sorting is performed on merge candidates 0 to 5. As shown in Figure 14, the second merge candidate list after ARMC sorting includes, in sequence: merge candidate 0, merge candidate 5, merge candidate 1, merge candidate 2, merge candidate 4, merge candidate 3, merge candidate 6 to merge candidate 9.

[0275] In this embodiment, if the first merge candidate list already has a merge candidate with no redundancy with the first zero motion vector merge candidate, the first filled zero motion vector merge candidate and the previously added non-zero motion vector merge candidate are ARMC sorted together to obtain the final second merge candidate list, that is, the first filled zero motion vector merge candidate (merge candidate 5) and the added non-zero motion vector merge candidates in the first merge candidate list (that is, merge candidate 0 to merge candidate 4) are sorted from small to large based on the template matching cost. As a result, not only can the zero motion vector merge candidate filled in the first merge candidate list be utilized, but also all zero motion vector merge candidates in the first merge candidate list can be avoided from participating in the ARMC sorting, thereby improving the accuracy of MV prediction of the current block, and thus improving the encoding and decoding performance of the current block.

[0276] In some embodiments, if M+N is less than or equal to K, the first number is determined based on whether there is redundancy between the Nth zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the Nth zero motion vector merge candidate; wherein K represents the maximum number of merge candidates that the first merge candidate list is allowed to accommodate.

[0277] Exemplarily, M can also be referred to as the numOrigMergeCand mentioned above, the first number can also be referred to as the number of merge candidates participating in the sorting mentioned above, numSortMVP, the maximum number of merge candidates in the first merge candidate list can also be recorded as MaxNumMergeCand, and the total number of zero motion vector merge candidates in the first merge candidate list can also be recorded as numZeroMergeCand; at this time, when performing a redundancy check on the numOrigMergeCand+Nth merge candidate in the first merge candidate list (that is, the Nth zero motion vector merge candidate), if numOrigMergeCand+N is less than or equal to MaxNumMergeCand, or numZeroMergeCand is greater than or equal to N, then a redundancy check is performed on the numOrigMergeCand+Nth merge candidate in the first merge candidate list (that is, the Nth zero motion vector merge candidate); otherwise, it is determined not to perform a redundancy check on the numOrigMergeCand+Nth merge candidate in the first merge candidate list (that is, the Nth zero motion vector merge candidate).

[0278] In some embodiments, N is determined according to the number of reference images available for the current block and / or N is predefined.

[0279] Exemplarily, N is equal to the number of reference images available for the current block.

[0280] Exemplarily, the reference image indexes of the zero motion vector merging candidates involved in the sorting are different, for example, corresponding to reference image indexes 0, 1, 2, etc.

[0281] Since the reference image indexes of the zero motion vector merge candidates filled in the first merge candidate list are not necessarily the same, there are still certain differences between the zero motion vector merge candidates filled in the first merge candidate list. Here, N is designed to be determined according to the number of reference images available to the current block, so that several zero motion vector merge candidates with different reference image indices filled in the first merge candidate list can be sorted together with the non-zero motion vector merge candidates in the first merge candidate list, which can improve the accuracy of the MV prediction of the current block and thus improve the encoding and decoding performance of the current block.

[0282] Of course, in other alternative embodiments, the first number may be determined or updated by redundantly detecting some or all of the zero motion vector merge candidates in the first merge candidate list, and this application does not impose any specific limitation on this.

[0283] As an example, the zero motion vector merge candidates in the first merge candidate list can be redundantly detected based on the order of adding the zero motion vector merge candidates in the first merge candidate list until the current zero motion vector merge candidate is detected to be: the first zero motion vector merge candidate in the first merge candidate list that is before the current zero motion vector merge candidate and there is no redundancy with the merge candidates included in the first merge candidate list, and the first number is determined based on the order of the current zero motion vector merge candidate in the first merge candidate list.

[0284] For example, based on the order in which zero motion vector merge candidates are added in the first merge candidate list, redundancy detection can be performed on the zero motion vector merge candidates in the first merge candidate list until it is detected that the current zero motion vector merge candidate is: the first zero motion vector merge candidate in the first merge candidate list that is not redundant with the merge candidates included in the first merge candidate list and located before the current zero motion vector merge candidate, then M+N is determined as the first number, where M represents the number of merge candidates included in the first merge candidate list before the zero motion vector merge candidate is added, and N represents that the current zero motion vector merge candidate is the Nth zero motion vector merge candidate in the first merge candidate list. In other words, if the current zero motion vector merge candidate is: the first zero motion vector merge candidate in the first merge candidate list that is not redundant with the merge candidates included in the first merge candidate list and located before the current zero motion vector merge candidate, then the current zero motion vector merge candidate and the merge candidates included in the first merge candidate list and located before the current zero motion vector merge candidate in the first merge candidate list can both participate in the sorting. In other words, when there is redundancy between the first N-1th zero motion vector merge candidate in the first merge candidate list and the merge candidate in the first merge candidate list that is located before the Nth zero motion vector merge candidate, and there is no redundancy between the Nth zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the Nth zero motion vector merge candidate, M+N is determined as the first number, where M represents the number of merge candidates included in the first merge candidate list before the zero motion vector merge candidate is added, and N represents that the current zero motion vector merge candidate is the Nth zero motion vector merge candidate in the first merge candidate list.

[0285] For another example, based on the order of adding zero motion vector merge candidates in the first merge candidate list, redundancy detection can be performed on the zero motion vector merge candidates in the first merge candidate list. If there is redundancy between the current zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the current zero motion vector merge candidate, if there is no redundancy, the first number is updated to: the number of merge candidates included in the first merge candidate list that is located before the current zero motion vector merge candidate in the first merge candidate list plus 1, that is, all merge candidates before the current zero motion vector merge candidate and the current zero motion vector merge candidate participate in the sorting, and the update of the first number is stopped; if there is redundancy, the first number is updated to: the number of merge candidates included in the first merge candidate list before the current zero motion vector merge candidate is added to the first merge candidate list plus 1, and continue to update the first number based on the redundant detection of the next zero motion vector merge candidate of the current zero motion vector merge candidate.

[0286] As another example, the first number may be determined or updated by performing redundant detection on each zero motion vector merge candidate in the first merge candidate list.

[0287] For example, redundancy detection can be performed on each zero motion vector merge candidate in the first merge candidate list. For example, if there is no redundancy between the current zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the current zero motion vector merge candidate, then the current zero motion vector merge candidate is determined to be a zero motion vector merge candidate that does not have redundancy; otherwise, the current zero motion vector merge candidate is determined to be a zero motion vector merge candidate that does have redundancy; based on this, the total number of zero motion vector merge candidates that do not have redundancy and non-zero motion vector merge candidates in the first merge candidate list can be determined as the first number. It should be understood that in this case, the embodiment of the present application does not specifically limit the order of zero motion vector merge candidates (i.e., zero motion vector merge candidates that do not participate in the sorting) in the second merge candidate list except for the zero motion vector merge candidates that do not have redundancy in the first merge candidate list. For example, the relative order of the zero motion vector merge candidates that do not participate in the sorting in the first zero-value merge candidate list and the relative order of the zero motion vector merge candidates that do not participate in the sorting in the second zero-value merge candidate list remain unchanged, and the zero motion vector merge candidates that do not participate in the sorting are located after the merge candidates that participate in the sorting.

[0288] In some embodiments, if the merge candidate located before the N-th zero motion vector merge candidate in the first merge candidate list meets a preset condition, then there is redundancy between the N-th zero motion vector merge candidate and the merge candidate located before the N-th zero motion vector merge candidate in the first merge candidate list; otherwise, there is no redundancy between the N-th zero motion vector merge candidate and the merge candidate located before the N-th zero motion vector merge candidate in the first merge candidate list;

[0289] The preset conditions are:

[0290] The merge candidate before the Nth zero motion vector merge candidate includes at least one of the following:

[0291] A merge candidate having a reference picture index identical to that of the reference picture of the N-th zero motion vector merge candidate and a motion vector MV identical to that of the N-th zero motion vector merge candidate;

[0292] A merge candidate whose reference image index is the same as the index of the reference image of the N-th zero motion vector merge candidate and whose MV has a difference with the MV of the N-th zero motion vector merge candidate that is less than or equal to a first threshold;

[0293] A merging candidate whose reference image index is the same as the index of the reference image of the N-th zero motion vector merging candidate and whose MV reliability difference with the MV reliability of the N-th zero motion vector merging candidate is greater than or equal to the second threshold;

[0294] A merge candidate whose MV is the same as the MV of the N-th zero motion vector merge candidate;

[0295] A merge candidate whose MV has a difference with the MV of the N-th zero motion vector merge candidate that is less than or equal to the first threshold;

[0296] A merge candidate for which a difference between the reliability of the MV and the reliability of the MV of the N-th zero motion vector merge candidate is greater than or equal to the second threshold.

[0297] In other words, the redundancy check method for the Nth zero motion vector merging candidate can be performed in four ways:

[0298] The first redundancy check method:

[0299] The Nth zero motion vector merge candidate is considered redundant only if its MV value and reference image index are exactly the same as those of a merge candidate already in the first merge candidate list; otherwise, it is considered non-redundant. Optionally, the regular merge mode usually uses this method to check for redundancy.

[0300] The second redundancy check method:

[0301] If the Nth zero motion vector merge candidate has the same reference image index as a merge candidate already in the first merge candidate list, and the MV of the Nth zero motion vector merge candidate is very close to that of the merge candidate, it is considered redundant; otherwise, it is considered non-redundant. Optionally, TM merge mode usually uses this method to check for redundancy.

[0302] The third redundancy check method:

[0303] When the index of the reference image of the Nth zero motion vector merge candidate is the same as that of a merge candidate already existing in the first merge candidate list, and the reliability of the MV of the Nth zero motion vector merge candidate is very close to that of the merge candidate, it will be considered redundant; otherwise, it will be considered non-redundant.

[0304] The fourth redundancy check method:

[0305] The Nth zero motion vector merge candidate will be considered redundant only when its MV value is the same as that of a merge candidate already existing in the first merge candidate list; otherwise, it is considered non-redundant.

[0306] The fifth redundancy check method:

[0307] When the Nth zero motion vector merge candidate is very close to the MV of a merge candidate already in the first merge candidate list, it will be considered redundant; otherwise, it will be considered non-redundant.

[0308] The sixth redundancy check method:

[0309] When the reliability of the MV of the Nth zero motion vector merge candidate is very different from or very close to that of the MV of the certain merge candidate, it will be considered redundant; otherwise, it will be considered non-redundant.

[0310] It should be understood that the difference between the MV of the merge candidate preceding the N-th zero motion vector merge candidate and the MV of the N-th zero motion vector merge candidate may be the difference obtained by subtracting the MV of the N-th zero motion vector merge candidate from the MV of the merge candidate preceding the N-th zero motion vector merge candidate, or the difference obtained by subtracting the MV of the merge candidate preceding the N-th zero motion vector merge candidate from the MV of the N-th zero motion vector merge candidate. For example, when the MV of the merge candidate preceding the N-th zero motion vector merge candidate is greater than the difference between the MVs of the N-th zero motion vector merge candidate, the difference may be the difference obtained by subtracting the MV of the N-th zero motion vector merge candidate from the MV of the merge candidate preceding the N-th zero motion vector merge candidate. For another example, when the MV of the merge candidate preceding the N-th zero motion vector merge candidate is less than the difference between the MVs of the N-th zero motion vector merge candidate, the difference may be the difference obtained by subtracting the MV of the N-th zero motion vector merge candidate from the MV of the merge candidate preceding the N-th zero motion vector merge candidate. Similarly, the difference between the reliability of the MV of the merge candidate before the N-th zero motion vector merge candidate and the reliability of the MV of the N-th zero motion vector merge candidate may be the difference obtained by subtracting the reliability of the MV of the N-th zero motion vector merge candidate from the reliability of the MV of the merge candidate before the N-th zero motion vector merge candidate, or the difference obtained by subtracting the reliability of the MV of the merge candidate before the N-th zero motion vector merge candidate from the reliability of the MV of the N-th zero motion vector merge candidate. For example, when the reliability of the MV of the merge candidate before the N-th zero motion vector merge candidate is greater than the difference between the reliability of the MV of the N-th zero motion vector merge candidate, it may be the difference obtained by subtracting the reliability of the MV of the N-th zero motion vector merge candidate from the reliability of the MV of the N-th zero motion vector merge candidate. For another example, when the reliability of the MV of the merge candidate before the N-th zero motion vector merge candidate is less than the difference between the reliability of the MV of the N-th zero motion vector merge candidate, the reliability may be the difference obtained by subtracting the reliability of the MV of the merge candidate before the N-th zero motion vector merge candidate from the reliability of the MV of the N-th zero motion vector merge candidate. This embodiment of the present application is not specifically limited to this.

[0311] Of course, in other alternative embodiments, the preset conditions may also be other conditions, and this application does not make specific limitations on this.

[0312] For example, the preset condition may be: among the merge candidates before the Nth zero motion vector merge candidate, there is at least one of the following: a merge candidate whose reference image index is the same as the reference image index of the Nth zero motion vector merge candidate and the absolute value of the difference between the MV and the MV of the Nth zero motion vector merge candidate is less than or equal to the first threshold; a merge candidate whose reference image index is the same as the reference image index of the Nth zero motion vector merge candidate and the absolute value of the difference between the reliability of the MV and the reliability of the MV of the Nth zero motion vector merge candidate is greater than or equal to the second threshold; a merge candidate whose absolute value of the difference between the MV and the MV of the Nth zero motion vector merge candidate is less than or equal to the first threshold; a merge candidate whose absolute value of the difference between the reliability of the MV and the reliability of the MV of the Nth zero motion vector merge candidate is greater than or equal to the second threshold.

[0313] It should be noted that whether the Nth zero motion vector merge candidate is redundant with the MV of a certain merge candidate already existing in the first merge candidate list is only used to determine the first quantity and will not affect the construction of the first merge candidate list. That is to say, regardless of whether the Nth zero motion vector merge candidate is redundant with the MV of a certain merge candidate already existing in the first merge candidate list, the Nth zero motion vector merge candidate needs to be added to the first merge candidate list.

[0314] Exemplarily, a merge candidate with the same MV as the MV of the Nth zero motion vector merge candidate may be a merge candidate where both the component MVx and the component MVy are 0.

[0315] In some embodiments, the first threshold is determined according to the size of the current block and / or is predefined, and the second threshold is determined according to the size of the current block and / or is predefined.

[0316] Exemplarily, a preset threshold may be set according to the number of pixels S of the current block. For example, when S < 64, the first threshold is 1 << 4; when 64 <= S < 256, the first threshold is 2 << 4; when S >= 256, the first threshold is 4 << 4; where x << y means shifting x to the left by y bits in binary form. Specifically, the high bits are shifted out and the empty positions in the low bits are filled with zeros. <= means less than or equal to, < means less than, and >= means greater than or equal to.

[0317] In some embodiments, the fact that the difference between the MV and the MV of the Nth zero motion vector merge candidate is less than or equal to the first threshold includes:

[0318] If the N-th zero motion vector merge candidate includes a first MV and a second MV, a horizontal difference and a vertical difference between a first MV of a first merge candidate before the N-th zero motion vector merge candidate and the first MV of the N-th zero motion vector merge candidate are both less than or equal to the first threshold, and a horizontal difference and a vertical difference between the second MV of the first merge candidate and the second MV of the N-th zero motion vector merge candidate are both less than or equal to the first threshold;

[0319] If the N-th zero motion vector merge candidate includes a first MV, a horizontal difference and a vertical difference between the first MV of the first merge candidate and the first MV of the N-th zero motion vector merge candidate are both less than or equal to the first threshold;

[0320] If the Nth zero motion vector merge candidate includes a second MV, a horizontal difference and a vertical difference between the second MV of the first merge candidate and the second MV of the Nth zero motion vector merge candidate are both less than or equal to the first threshold.

[0321] Exemplarily, the first MV is List0MV (mvL0), and the second MV is List1MV (MVL1).

[0322] Exemplarily, when the Nth zero motion vector merge candidate includes a first MV and a second MV, the index of the reference image of the first MV of the Nth zero motion vector merge candidate is the same as the index of the reference image of the first MV of the certain merge candidate, the index of the reference image of the second MV of the Nth zero motion vector merge candidate is the same as the index of the reference image of the second MV of the certain merge candidate, and the horizontal difference and vertical difference between the first MV of the Nth zero motion vector merge candidate and the first MV of the certain merge candidate, as well as the horizontal difference and vertical difference between the second MV of the Nth zero motion vector merge candidate and the second MV of the certain merge candidate, are both less than a preset threshold, then the Nth zero motion vector merge candidate and the certain merge candidate are determined to be redundant. In other words, if there is a merge candidate in the first merge candidate list whose horizontal difference and vertical difference with the first MV of the Nth zero motion vector merge candidate and the horizontal difference and vertical difference with the second MV of the Nth zero motion vector merge candidate are both less than a preset threshold, and whose reference image index is the same as the first MV and second MV of the Nth zero motion vector merge candidate, then the Nth zero motion vector merge candidate and the certain merge candidate are determined to be redundant.

[0323] Exemplarily, when the Nth zero motion vector merge candidate includes a first MV (or a second MV), the index of the reference image of the first MV (or the second MV) of the Nth zero motion vector merge candidate is the same as the index of the reference image of the first MV (or the second MV) of the certain merge candidate, and the horizontal difference and the vertical difference between the first MV (or the second MV) of the Nth zero motion vector merge candidate and the first MV (or the second MV) of the certain merge candidate are both less than a preset threshold, it is determined that the Nth zero motion vector merge candidate and the certain merge candidate are redundant. In other words, when there is a certain merge candidate in the first merge candidate list whose horizontal difference and vertical difference with the first MV (or the second MV) of the Nth zero motion vector merge candidate are both less than the preset threshold and whose reference image index value is the same, it can be determined that the Nth zero motion vector merge candidate and the certain merge candidate are redundant.

[0324] In some embodiments, after completing the addition of the zero motion vector merge candidate to the first merge candidate list, determine whether there is redundancy between the Nth zero motion vector merge candidate and the merge candidate in the first merge candidate list that is located before the Nth zero motion vector merge candidate.

[0325] FIG15 is a schematic diagram of a detection process 510 for performing redundancy detection on zero motion vector merge candidates after adding zero motion vector merge candidates to the first merge candidate list, provided by an embodiment of the present application.

[0326] As shown in FIG15 , after adding zero motion vector merging candidates to the first merging candidate list, the process of performing redundancy detection on zero motion vector merging candidates may include:

[0327] S511, adding spatial domain merging candidates.

[0328] S512: Add time domain merging candidates.

[0329] S513, adding non-adjacent spatial domain merging candidates.

[0330] S514: Add history-based merge candidates.

[0331] S515, adding pairwise average merging candidates.

[0332] S516, adding a zero motion vector merge candidate.

[0333] It should be understood that S511 to S516 may refer to S321 to S326 mentioned above, and to avoid repetition, they will not be repeated here.

[0334] S517 , determining whether the first added zero motion vector merge candidate is redundant with the merge candidates in the first merge candidate list before the first zero motion vector merge candidate is added.

[0335] S518 : The number of merge candidates participating in the sorting is set to be equal to the number of merge candidates in the first merge candidate list before the first zero motion vector merge candidate is added.

[0336] S519 , the number of merge candidates participating in the sorting is set to be equal to the number of merge candidates in the first merge candidate list before the first zero motion vector merge candidate is added plus 1.

[0337] For S516 to S519, when adding a zero motion vector merge candidate when constructing the first merge candidate list, first add the first zero motion vector merge candidate, and then continue to add other zero motion vector merge candidates until the addition of the zero motion vector merge candidate is completed, and then perform a redundancy judgment on the first zero motion vector merge candidate and the merge candidates added before the first zero motion vector merge candidate is added to the first merge candidate list. If the first zero motion vector merge candidate and the merge candidates added before the first zero motion vector merge candidate is added to the first merge candidate list are not redundant, the number of merge candidates participating in the sorting is determined to be M+1; if the first zero motion vector merge candidate and the merge candidates added before the first zero motion vector merge candidate is added to the first merge candidate list are redundant, the number of merge candidates participating in the sorting is determined to be M.

[0338] Of course, FIG15 takes the Nth zero motion vector merge candidate as the first zero motion vector merge candidate as an example. In other alternative embodiments, N may also be other values, and this application does not limit this.

[0339] In some embodiments, while adding the Nth zero motion vector merge candidate, it is determined whether there is redundancy between the Nth zero motion vector merge candidate and a merge candidate preceding the Nth zero motion vector merge candidate in the first merge candidate list.

[0340] FIG16 is a schematic diagram of a detection process 520 for performing redundancy detection on zero motion vector merge candidates while adding zero motion vector merge candidates to the first merge candidate list, provided by an embodiment of the present application.

[0341] As shown in FIG. 16 , the detection process 510 of performing redundancy detection on zero motion vector merging candidates after adding zero motion vector merging candidates to the first merging candidate list may include:

[0342] S521, adding spatial domain merging candidates.

[0343] S522: Add time domain merging candidates.

[0344] S523, adding non-adjacent spatial domain merging candidates.

[0345] S524: Add history-based merge candidates.

[0346] S525, adding pairwise average merging candidates.

[0347] It should be understood that S521 to S525 may refer to S321 to S325 mentioned above, and will not be described again here to avoid repetition.

[0348] S526, adding the first zero motion vector merge candidate.

[0349] S527 , determining whether the first added zero motion vector merge candidate is redundant with the merge candidates in the first merge candidate list before the first zero motion vector merge candidate is added.

[0350] S528 : The number of merge candidates participating in the sorting is set to be equal to the number of merge candidates in the first merge candidate list before the first zero motion vector merge candidate is added.

[0351] S529 , the number of merge candidates participating in the sorting is set to be equal to the number of merge candidates in the first merge candidate list before the first zero motion vector merge candidate is added plus 1.

[0352] S530: Continue adding zero motion vector merging candidates.

[0353] For S526 to S530, when it is necessary to add a zero motion vector merge candidate when constructing the first merge candidate list, first add the first zero motion vector merge candidate, and then perform a redundancy check on the first zero motion vector merge candidate and the merge candidates added before the first zero motion vector merge candidate is added to the first merge candidate list. If the first zero motion vector merge candidate and the merge candidates added before the first zero motion vector merge candidate is added to the first merge candidate list are not redundant, the number of merge candidates participating in the sorting is determined to be M+1; if the first zero motion vector merge candidate and the merge candidates added before the first zero motion vector merge candidate is added to the first merge candidate list are redundant, the number of merge candidates participating in the sorting is determined to be M; then, continue to add other zero motion vector merge candidates.

[0354] Of course, FIG16 takes the Nth zero motion vector merge candidate as the first zero motion vector merge candidate as an example. In other alternative embodiments, N may also be other values, and this application does not limit this.

[0355] In some embodiments, the S410 may include:

[0356] The first number is determined based on costs of zero motion vector merge candidates in the first merge candidate list.

[0357] Exemplarily, the cost of the zero motion vector merge candidate in the first merge candidate list may be the cost when the current block is predicted using the cost of the zero motion vector merge candidate in the first merge candidate list.

[0358] For example, the zero motion vector merge candidates to be sorted may be determined based on the costs of the zero motion vector merge candidates in the first merge candidate list, and then the first number may be determined based on the number of zero motion vector merge candidates to be sorted and the number of non-zero motion vector merge candidates in the first merge candidate list. For example, the first number may be determined as the sum of the number of zero motion vector merge candidates to be sorted and the number of non-zero motion vector merge candidates in the first merge candidate list.

[0359] In some embodiments, G zero motion vector merge candidates with the lowest cost can be determined based on the cost of the zero motion vector merge candidates in the first merge candidate list; then M+G is determined as the first number; where M represents the number of merge candidates included in the first merge candidate list before the zero motion vector merge candidate is added.

[0360] Exemplarily, the cost of the zero motion vector merge candidate in the first merge candidate list may be determined based on the SAD of the zero motion vector merge candidate in the first merge candidate list. For example, the smaller the SAD of the zero motion vector merge candidate in the first merge candidate list, the smaller the cost of the zero motion vector merge candidate in the first merge candidate list.

[0361] Exemplarily, the cost of the zero motion vector merge candidate in the first merge candidate list may be determined based on the PSNR of the zero motion vector merge candidate in the first merge candidate list. For example, the greater the PSNR of the zero motion vector merge candidate in the first merge candidate list, the smaller the cost of the zero motion vector merge candidate in the first merge candidate list.

[0362] Exemplarily, based on the costs of the zero motion vector merge candidates in the first merge candidate list, the G zero motion vector merge candidates with the smallest costs can be determined as the zero motion vector merge candidates participating in the sorting, and then M+G can be determined as the first number.

[0363] Exemplarily, G zero motion vector merge candidates with the lowest cost can be determined based on the costs of zero motion vector merge candidates with different indexes of reference images in the first merge candidate list; M+G is determined as the first number; wherein M represents the number of merge candidates included in the first merge candidate list before the zero motion vector merge candidate is added.

[0364] It should be understood that the present application does not specifically limit the order of the zero motion vector merge candidates (i.e., the zero motion vector merge candidates that do not participate in the sorting) in the first merge candidate list except for the G zero motion vector merge candidates with the lowest cost in the second merge candidate list. For example, the relative order of the zero motion vector merge candidates that do not participate in the sorting in the first zero-value merge candidate list and the relative order of the zero motion vector merge candidates that do not participate in the sorting in the second zero-value merge candidate list remain unchanged, and the zero motion vector merge candidates that do not participate in the sorting are located after the merge candidates that participate in the sorting.

[0365] Exemplarily, G is predefined.

[0366] Exemplarily, the implementation of the derivation algorithm of the first quantity may be as follows:

[0367] Input: M (or M and G).

[0368] Output: the number of merge candidates participating in the sorting, that is, the first number.

[0369] The value of the first number is set to be equal to M+G, where M represents the number of merge candidates included in the first merge candidate list before adding the zero motion vector merge candidate.

[0370] In some embodiments, the zero motion vector merge candidates in the first merge candidate list are sorted based on the costs of the zero motion vector merge candidates in the first merge candidate list; if the zero motion vector merge candidates in the first merge candidate list are sorted in order of cost from small to large, the first G zero motion vector merge candidates in the sorting of the zero motion vector merge candidates in the first merge candidate list are determined as the G zero motion vector merge candidates; if the zero motion vector merge candidates in the first merge candidate list are sorted in order of cost from large to small, the last G zero motion vector merge candidates in the sorting of the zero motion vector merge candidates in the first merge candidate list are determined as the G zero motion vector merge candidates.

[0371] Exemplarily, the costs of the zero motion vector merge candidates with different indexes of the reference images in the first merge candidate list can be sorted first, and then a zero motion vector merge candidate with the smallest template matching cost can be selected. Subsequently, the zero motion vector merge candidate with the smallest matching cost and the non-zero motion vector merge candidates in the first merge candidate list can be sorted to obtain the second merge candidate list.

[0372] In some embodiments, if M+G is less than or equal to K, the first number is determined based on the cost of zero motion vector merge candidates in the first merge candidate list; wherein K represents the maximum number of merge candidates allowed to be accommodated by the first merge candidate list.

[0373] Exemplarily, M can also be referred to as the numOrigMergeCand mentioned above, the first number can also be referred to as the number of merge candidates participating in the sorting mentioned above, numSortMVP, the maximum number of merge candidates in the first merge candidate list can also be recorded as MaxNumMergeCand, and the total number of zero motion vector merge candidates in the first merge candidate list can also be recorded as numZeroMergeCand; at this time, if numOrigMergeCand+G is less than or equal to MaxNumMergeCand, or numZeroMergeCand is greater than or equal to G, then numSortMVP can be determined based on the cost of the zero motion vector merge candidate in the first merge candidate list.

[0374] In some embodiments, the S410 may include:

[0375] The first number is determined based on whether the first merge candidate list includes a zero motion vector merge candidate.

[0376] For example, the zero motion vector merge candidates to be sorted may be determined based on whether the first merge candidate list includes a zero motion vector merge candidate. Then, the first number may be determined based on the number of zero motion vector merge candidates to be sorted and the number of non-zero motion vector merge candidates in the first merge candidate list. For example, the first number may be determined as the sum of the number of zero motion vector merge candidates to be sorted and the number of non-zero motion vector merge candidates in the first merge candidate list.

[0377] In some embodiments, if M+J is less than or equal to K, then M+J is determined as the first number;

[0378] Here, M represents the number of merge candidates included in the first merge candidate list before adding the zero motion vector merge candidate, and J is a preset value.

[0379] Exemplarily, M can also be referred to as the numOrigMergeCand mentioned above, the first number can also be referred to as the number of merge candidates participating in the sorting mentioned above, numSortMVP, and the maximum number of merge candidates in the first merge candidate list can also be recorded as MaxNumMergeCand. If numOrigMergeCand+J is less than or equal to MaxNumMergeCand, or numZeroMergeCand is greater than or equal to J, numSortMVP is set to be equal to numOrigMergeCand+J. At this time, J zero motion vector merge candidates including the first zero motion vector merge candidate participate in the sorting.

[0380] Exemplarily, J is determined according to the number of reference images available for the current block and / or J is predefined.

[0381] Exemplarily, J is equal to the number of reference images available for the current block.

[0382] Exemplarily, the reference image indexes of the zero motion vector merging candidates involved in the sorting are different, for example, corresponding to reference image indexes 0, 1, 2, etc.

[0383] Since the reference image indexes of the zero motion vector merge candidates populated in the first merge candidate list are not necessarily the same, there are still certain differences between the zero motion vector merge candidates populated in the first merge candidate list. Here, J is designed to be determined based on the number of reference images available to the current block. This allows several zero motion vector merge candidates populated in the first merge candidate list with different reference image indices to be sorted together with the non-zero motion vector merge candidates in the first merge candidate list, thereby improving the accuracy of the MV prediction of the current block and, in turn, improving the encoding and decoding performance of the current block.

[0384] Exemplarily, the implementation of the derivation algorithm of the first quantity may be as follows:

[0385] Input: M (or M and J).

[0386] Output: the number of merge candidates participating in the sorting, that is, the first number.

[0387] The value of the first number is set to be equal to M+J, where M represents the number of merge candidates included in the first merge candidate list before adding the zero motion vector merge candidate.

[0388] In some embodiments, the method 400 may further include:

[0389] It is determined whether the first number is determined based on a zero motion vector merge candidate in the first merge candidate list.

[0390] Exemplarily, when the usage conditions for determining the first number based on the zero motion vector merge candidates in the first merge candidate list are met, the first number is determined based on the zero motion vector merge candidates in the first merge candidate list; otherwise, the first number is determined by other means.

[0391] In some embodiments, based on the merge mode used by the current block, it is determined whether to determine the first number based on a zero motion vector merge candidate in the first merge candidate list.

[0392] Exemplarily, when the merge mode used by the current block satisfies the usage conditions of determining the first number based on the zero motion vector merge candidates in the first merge candidate list, the first number is determined based on the zero motion vector merge candidates in the first merge candidate list; otherwise, the first number is determined by other methods.

[0393] In some embodiments, if the merge mode used by the current block is a preset merge mode, the first number is determined based on zero motion vector merge candidates in the first merge candidate list.

[0394] Exemplarily, the preset merging mode includes but is not limited to: a normal merging mode, a TM merging mode, and a BM merging mode. Of course, in other alternative embodiments, the preset merging mode may also be other merging modes, which is not specifically limited in this application.

[0395] In some embodiments, whether to determine the first number based on a zero motion vector merge candidate in the first merge candidate list is determined based on the size of the current block.

[0396] Exemplarily, when the size of the current block satisfies the usage conditions for determining the first number based on the zero motion vector merge candidates in the first merge candidate list, the first number is determined based on the zero motion vector merge candidates in the first merge candidate list; otherwise, the first number is determined by other means.

[0397] In some embodiments, if the size of the current block is a preset size, the first number is determined based on zero motion vector merge candidates in the first merge candidate list.

[0398] For example, the preset size includes, but is not limited to, a block greater than or equal to 4×4 (or containing at least 16 pixels), a block less than or equal to 128×128, and a block greater than 4×4 and less than 128×128. Of course, in other alternative embodiments, the preset size may also be other sizes, and this application does not specifically limit this.

[0399] In some embodiments, the first number is the number of merge candidates participating in ARMC.

[0400] For example, after determining the first number, ARMC sorting can be performed on the merging candidates participating in the sorting in the first merging candidate list based on the first number to obtain the second merging candidate list. Of course, in other alternative embodiments, other techniques can also be used to perform ARMC sorting on the merging candidates participating in the sorting in the first merging candidate list to obtain the second merging candidate list, and this application does not specifically limit this.

[0401] In some embodiments, the ARMC refers to sorting the template matching costs of the merged candidates in ascending order.

[0402] Exemplarily, the template matching cost is the SAD value between the template of the current block and the template of the reference block of the merged candidate. Of course, the matching cost is not limited to the Sum of Absolute Differences (SAD). In order to improve the matching accuracy, the Sum of Absolute Transformed Difference (SATD), Sum of Squares for Error (SSE), Mean Square Error (MSE), or other more complex costs may also be used. This application does not specifically limit this. The templates of the current block and the reference block can refer to the relevant content mentioned above. To avoid repetition, they will not be described here.

[0403] According to another aspect of the present application, an embodiment of the present application further provides a decoding method, which includes:

[0404] Sorting the first merging candidate list according to the sorting method provided in the embodiment of the present application to obtain a second merging candidate list;

[0405] Parse the code stream to obtain candidate indexes;

[0406] The candidate index is used to indicate the optimal merge candidate for the current block in the second merge candidate list;

[0407] Predicting the current block based on the optimal merge candidate.

[0408] Exemplarily, the decoder parses the candidate index corresponding to the best merge candidate transmitted in the bitstream, i.e., merge_idx[xCb][yCb], and selects the best merge candidate N from the reordered merge candidate list (i.e., the second merge candidate list) based on the candidate index corresponding to the best merge candidate. For example, if the current block is the current luma coding block, (xCb, yCb) represents the position of the current luma coding block, and N = mergeCandList[merge_idx[xCb][yCb]].

[0409] According to another aspect of the present application, an embodiment of the present application further provides an encoding method, which includes:

[0410] Determining a first merge candidate list;

[0411] Sorting the first merging candidate list according to the sorting method provided in the embodiment of the present application to obtain a second merging candidate list;

[0412] Determine an optimal merge candidate for the current block based on the second merge candidate list;

[0413] The optimal merge candidate is encoded.

[0414] Exemplarily, the encoder determines, based on the rate-distortion costs of the merging candidates in the second merging candidate list, a merging candidate with the smallest cost as the optimal merging candidate.

[0415] Exemplarily, the encoder selects the optimal merge candidate from the reordered merge candidate list (i.e., the second merge candidate list) based on rate-distortion optimization, and transmits the candidate index corresponding to the optimal merge candidate in the bitstream. For example, the encoder calculates the rate-distortion cost of each merge candidate in the second merge candidate list, selects the optimal merge candidate with the smallest rate-distortion cost from the second merge candidate list, and transmits the candidate index corresponding to the optimal merge candidate in the bitstream.

[0416] It should be understood that regarding the specific implementation method of determining the first merge candidate list in the decoding method and the encoding method, reference may be made to S311 in 310 above and the relevant content involved in S320 above; regarding the specific implementation scheme of the decoder predicting the current block based on the optimal merge candidate, reference may be made to the relevant content involved in S313 to S315 in 310 above. To avoid repetition, it will not be repeated here.

[0417] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all fall within the scope of protection of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will no longer describe the various possible combinations separately. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the idea of ​​the present application, they should also be regarded as the contents disclosed in the present application. It should also be understood that in the various method embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0418] The method embodiment of the present application is described in detail above. The following describes in detail an apparatus embodiment of the present application in conjunction with Figures 17 and 18.

[0419] FIG17 is a schematic block diagram of a video encoding apparatus 170 according to an embodiment of the present application. As shown in FIG17 , the video encoding apparatus 170 includes:

[0420] a fourth determining module 1701 configured to determine an initial motion information candidate list for a current block, the initial motion information candidate list comprising first-category motion information candidates and second-category motion information candidates, wherein the first-category motion information candidates are determined based on motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second-category motion information candidates are constructed based on a reference image index set using a preset rule and a motion vector with a preset value;

[0421] A second sorting module 1702 is configured to sort some of the motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer;

[0422] A fifth determining module 1703 is configured to determine a motion information candidate index of the current block according to the motion information candidate list of the current block;

[0423] The encoding module 1704 is configured to encode the motion information candidate index of the current block and write the encoded bits into a bitstream.

[0424] FIG18 is a schematic block diagram of a video decoding device 180 according to an embodiment of the present application. As shown in FIG18 , the video decoding device 180 includes:

[0425] A first determining module 1801 is configured to determine an initial motion information candidate list for a current block, the initial motion information candidate list comprising a first category of motion information candidates and a second category of motion information candidates, wherein the first category of motion information candidates is determined based on motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second category of motion information candidates is constructed based on a reference image index set using a preset rule and a motion vector with a preset value;

[0426] A first sorting module 1802 is configured to sort some motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer;

[0427] The decoding module 1803 is configured to decode the code stream and determine the candidate motion information index of the current block;

[0428] A second determining module 1804 is configured to determine an inter-frame prediction value of the current block according to the motion information candidate index of the current block and the motion information candidate list;

[0429] The decoding module 1803 is further configured to decode the code stream and determine the residual value of the current block;

[0430] The third determining module 1805 is configured to determine a reconstructed value of the current block according to the residual value of the current block and the inter-frame prediction value.

[0431] The description of the above device embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0432] It should be noted that the division of modules in the device described in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation. In addition, the functional units in the various embodiments of the present application can be integrated into a processing unit, or they 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 in the form of software functional units. It can also be implemented in the form of a combination of software and hardware.

[0433] It should be noted that, in the embodiment of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling an electronic device to execute all or part of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.

[0434] An embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, it implements a video encoding method or a video decoding method.

[0435] An embodiment of the present application provides a decoder, as shown in FIG19 , the decoder 190 includes: a first communication interface 1901, a first memory 1902, and a first processor 1903; each component is coupled together via a first bus system 1904. It is understood that the first bus system 1904 is used to achieve connection and communication between these components. In addition to the data bus, the first bus system 1904 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in FIG19 , various buses are labeled as the first bus system 1904. Among them,

[0436] The first communication interface 1901 is used to receive and send signals when sending and receiving information with other external network elements;

[0437] A first memory 1902 is used to store computer programs that can be run on the first processor 1903;

[0438] The first processor 1903 is configured to, when running the computer program, execute:

[0439] determining an initial motion information candidate list for a current block, the initial motion information candidate list comprising first-category motion information candidates and second-category motion information candidates, wherein the first-category motion information candidates are determined based on motion information of neighboring blocks and / or non-neighboring blocks of the current block, and the second-category motion information candidates are constructed based on a reference image index set using a preset rule and a motion vector with a preset value;

[0440] sorting some of the motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer;

[0441] Decoding the code stream to determine a candidate motion information index of the current block;

[0442] Determining an inter-frame prediction value of the current block according to the motion information candidate index of the current block and the motion information candidate list;

[0443] Decoding a bitstream to determine a residual value of the current block;

[0444] A reconstructed value of the current block is determined according to the residual value of the current block and the inter-frame prediction value.

[0445] It is understood that the first memory 1902 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The first memory 1902 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0446] The first processor 1903 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in the first processor 1903. The above-mentioned first processor 1903 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of this application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the first memory 1902 , and the first processor 1903 reads the information in the first memory 1902 and completes the steps of the above method in combination with its hardware.

[0447] It is to be understood that these embodiments described in the present application can be implemented with hardware, software, firmware, middleware, microcode or its combination.For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processor (Digital Signal Processing, DSP), digital signal processing equipment (DSP Device, DSPD), programmable logic device (Programmable Logic Device, PLD), field programmable gate array (Field-Programmable Gate Array, FPGA), general-purpose processor, controller, microcontroller, microprocessor, other electronic units for performing functions described in the present application or its combination.For software implementation, the technology described in the present application can be realized by the module (such as process, function etc.) that performs functions described in the present application. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.

[0448] Optionally, as another embodiment, the first processor 1903 is further configured to execute any one of the method embodiments on the decoder 50 side when running the computer program.

[0449] The present application provides an encoder, as shown in FIG20 , wherein the encoder 200 includes: a second communication interface 2001, a second memory 2002, and a second processor 2003; each component is coupled together via a second bus system 2004. It is understood that the second bus system 2004 is used to implement connection and communication between these components. In addition to the data bus, the second bus system 2004 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in FIG20 , various buses are labeled as the second bus system 2004.

[0450] The second communication interface 2001 is used for sending and receiving signals during the process of sending and receiving information with other external network elements;

[0451] The second memory 2002 is used to store computer programs that can be run on the second processor 2003;

[0452] The second processor 2003 is configured to, when running the computer program, execute:

[0453] Sorting the samples in the first image according to differences between the samples to obtain a first list;

[0454] A sample value of the first component having the same position coordinates as the sample in the second image is obtained according to the index number of the sample in the first list and the bit depth of the first component.

[0455] Optionally, as another embodiment, the second processor 2003 is further configured to execute the aforementioned method embodiment on the encoder 20 side when running the computer program.

[0456] It can be understood that the hardware functions of the second memory 2002 are similar to those of the first memory 1902, and the hardware functions of the second processor 2003 are similar to those of the first processor 1903; they will not be described in detail here.

[0457] 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, storage medium, and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0458] The main technical plan:

[0459] Step a. Determine a subset of zero-valued MVPs with a preset number (denoted as N) from all the added zero-valued MVPs in the added zero-valued MVP candidates (N = 1 in the main scheme);

[0460] Step b. Introduce redundancy detection and sequentially determine whether there is redundancy between the MVPs in the zero-valued MVP subset and each candidate before filling the zero-valued MVP candidates in the Merge MVP candidate list. If not, increment the number of MVPs sorted by ARMC by 1. At this time, this zero-valued MVP candidate is sorted by ARMC together with the MVP candidates already existing in the list before zero-valued MVP filling; if there is redundancy, continue to determine the subsequent zero-valued MVPs in the zero-valued MVP subset until the end.

[0461] The redundancy check method can be carried out in two ways:

[0462] The first redundancy check method: A candidate is considered redundant only when the MV value and the reference image index value of the candidate MVP are exactly the same as those of an existing MVP candidate in the MVP list, and in this case, adding this candidate is abandoned. The conventional Merge mode usually uses this method to check for redundancy.

[0463] The second redundancy check method: A candidate is considered redundant when the MV of the candidate MVP is very close to the MV of an existing MVP in the MVP list, and in this case, adding this candidate is abandoned. The TM Merge mode usually uses this method to check for redundancy. A specific embodiment is as follows:

[0464] First, set a preset threshold according to the number of pixels S of the current block. For example, when S < 64, the threshold is set to 1 << 4; when 64 <= S < 256, the threshold is set to 2 << 4; when S >= 256, the threshold is set to 4 << 4;

[0465] Meaning of operators:

[0466] x << y shifts x to the left by y bits in binary form, the high bits are shifted out, and the low vacant bits are filled with zeros.

[0467] <= less than or equal to

[0468] < less than

[0469] >= greater than or equal to

[0470] Then, when the MVP candidate is bidirectional, if both the horizontal difference and the vertical difference of the forward and backward MVs are less than the preset threshold and the reference image index values are the same, the candidate is considered redundant and not added to the candidate list;

[0471] When the candidate is unidirectional, if both the horizontal difference and the vertical difference of the unidirectional MV are less than the preset threshold and the reference image index values are the same, the candidate is considered redundant and not added to the candidate list.

[0472] Step c. Perform ARMC sorting based on the finally determined number of MVP candidates participating in ARMC sorting.

[0473] To make full use of the zero-valued MVP candidates filled in the candidate list and improve the accuracy of MV prediction, the following ARMC improvement method is proposed: Before filling the zero-valued MVP candidates in the candidate list, if the zero-valued MVP candidate to be filled is not redundant with the existing options in the list, take out the first filled zero-valued MVP candidate in the list and perform ARMC sorting together with the previously added non-zero MVP candidates to obtain the final MVP candidate list. That is, if Cand0, Cand1, Cand2, Cand3, and Cand4 are all non-zero-valued MVPs, then the first filled zero-valued MVP candidate (Cand5) in the list needs to be taken out and sorted together with the previously added MVP candidates (Cand0, Cand1, Cand2, Cand3, Cand4) in the list based on the template matching cost from small to large.

[0474] If numOrigMergeCand is less than MaxNumMergeCand (or numZeroMergeCand is greater than 0), perform redundancy check on the (numOrigMergeCand + 1)-th MVP (should be the constructed zero-valued MVP) candidate in the list.

[0475] The redundancy check method can be carried out in two ways:

[0476] The first redundancy check method: A candidate MVP is considered redundant only when its MV value and reference image index value are exactly the same as those of an existing MVP candidate in the MVP list, and in this case, adding this candidate is abandoned. This method is usually used to check redundancy in the conventional Merge mode.

[0477] The second redundancy check method: A candidate MVP is considered redundant when its MV is very close to that of an existing MVP in the MVP list, and in this case, adding this candidate is abandoned. This method is usually used to check redundancy in the TM Merge mode. A specific embodiment is as follows:

[0478] First, set a preset threshold according to the number of pixels S of the current block. For example, when S < 64, the threshold is set to 1 << 4; when 64 <= S < 256, the threshold is set to 2 << 4; when S >= 256, the threshold is set to 4 << 4;

[0479] Meaning of the operator:

[0480] x << y shifts x to the left by y bits in binary form, discarding the high bits and filling the empty low bits with zeros.

[0481] <= less than or equal to

[0482] <

[0483] > = greater than or equal to

[0484] Then, when the MVP candidate is bidirectional, if both the horizontal and vertical differences of the forward and backward MVs are less than a preset threshold and the reference image index values ​​are the same, the candidate is deemed redundant and is not added to the candidate list;

[0485] When the candidate is unidirectional, and both the horizontal difference and the vertical difference of the unidirectional MV are smaller than the preset threshold and the reference image index value is the same, the candidate is deemed redundant and is not added to the candidate list.

[0486] Specifically, redundancy check is performed on the first numOrigMergeCand MVPs and the numOrigMergeCand+1 MVP in the MVP list:

[0487] If the redundancy condition is met, the variable numSortMVP is set to numOrigMergeCand.

[0488] If the redundancy condition is not met, the variable numSortMVP is set to numOrigMergeCand+1.

[0489] The above technical solution provided by the embodiment of the present application can improve the accuracy of MV prediction. Through the optimization of ARMC technology, before the candidate list is filled with zero-value MVP candidates, if the zero-value MVP candidate to be filled has no redundancy with the existing options in the list, the first zero-value MVP candidate filled in the list is taken out and ARMC sorted together with the previously added non-zero MVP candidate to obtain the final candidate list. Since the undesirable situation caused by the participation of multiple zero-value MVP candidates in ARMC sorting is fully considered, and at the same time, the zero-value MVP candidates added to the Merge candidate list have the opportunity to be ranked at the front of the list based on the template matching cost, there is a greater chance of selecting the zero-value MVP as the best MV for post-processing and motion compensation, which will improve the quality to a certain extent. This method can further improve coding efficiency.

[0490] The method further comprises the following developments 1 to 7, wherein:

[0491] In extended scheme 1, the number of zero vectors participating in ARMC sorting in the main scheme is expanded.

[0492] The implementation in the main solution selects the first zero-valued MVP candidate from the merge candidate list for ARMC sorting along with the non-zero MVP candidates at the beginning of the list. Because the reference image indices of the zero-valued MVP candidates in the candidate list may not be identical, there are still some differences between the zero-valued MVP candidates in the list. The number of zero-valued MVP candidates participating in the ARMC sorting is expanded here to N, which can be a number greater than 1.

[0493] Several zero-valued MVP candidates with different reference image indices are selected from the Merge candidate list and used for ARMC sorting together with the non-zero MVP candidates at the front of the list to obtain the final Merge candidate list. At this time, the reference image indices of the participating zero MVPs are different, corresponding to reference image indices of 0, 1, and / or 2, etc.

[0494] Furthermore, in some embodiments, the number of candidates participating in the ARMC sort, numSortMVP, can be derived: if numOrigMergeCand+N is less than or equal to MaxNumMergeCand (or numZeroMergeCand is greater than or equal to N), a redundancy check is performed on the numOrigMergeCand+Nth MVP (which should be a constructed zero-valued MVP) vector in the list. Specifically, a redundancy check is performed on the first numOrigMergeCand+N-1 MVPs and the numOrigMergeCand+Nth MVP in the MVP list:

[0495] If the redundancy condition is met, the variable numSortMVP is set to numOrigMergeCand+N-1;

[0496] If the redundancy condition is not met, the variable numSortMVP is set to numOrigMergeCand+N.

[0497] In extended solution 2, the optimization of adding the zero vector of the main solution to the Merge MVP candidate list is as follows:

[0498] The main scheme sequentially adds zero-valued MV vectors with reference indexes Idx of 0, 1, and 2 to the Merge MVP list. This extended scheme optimizes the addition of zero-valued MVP vectors. The specific optimization algorithm is as follows: First, the zero-valued MVP candidates with different reference image indices at the end of the candidate list are sorted by ARMC based on template matching cost. Then, the zero-valued MVP candidate with the lowest template matching cost is selected. This zero-valued MVP candidate with the lowest matching cost is then ARMC-sorted with the MVP candidate at the beginning of the list to obtain the final Merge candidate list.

[0499] In extended solution 3, the redundancy judgment is extended as follows:

[0500] In the main scheme, the zero-valued MVP candidate to be involved in ARMC needs to be checked for redundancy with the candidate before the zero-valued MVP is filled in the list. If there is no redundancy, the zero-valued MVP candidate will be included in the ARMC sorting. The implementation method of this extended scheme does not perform redundancy check, as described below:

[0501] At this time, the derivation of the number of candidates participating in ARMC sorting, numSortMVP, is directly changed to: Derivation of the number of candidates participating in ARMC sorting, numSortMVP:

[0502] If numOrigMergeCand+N is less than or equal to MaxNumMergeCand (or numZeroMergeCand is greater than or equal to N), the variable numSortMVP is set to numOrigMergeCand+N, and the MVPs including the first zero-valued MVP are directly sorted by ARMC.

[0503] In extended solution 4, the redundancy judgment is extended as follows:

[0504] The redundancy check of the zero-valued MVP candidate added in S516 shown in Figure 15 can also be simplified to: no matter what the value of the reference image index is, as long as the two components MVx and MVy of the MV candidate in a certain list are both 0, it is considered that a zero-valued MVP candidate already exists, and there is no need to add zero-valued MVP candidates to participate in ARMC sorting subsequently.

[0505] In extended solution 5, the main solution, extended solutions 1 and 2 can be combined with extended solutions 3 and 4 respectively and used selectively.

[0506] In extended solution 6, the conditions for the zero-valued MVP filled in the main solution to participate in ARMC can be further tightened, for example, only used for some Merge modes, such as only used for regular Merge and / or TM merge and / or BM merge.

[0507] This condition can also limit the block size and only be used for blocks that meet the preset size conditions, for example, only for blocks with a block size greater than 4×4 (or containing at least 16 pixels); or only for blocks with a block size less than 128×128; or only for blocks with a block size greater than 4×4 and less than 128×128, etc.

[0508] In extended solution 7, the main solution can also be carried out in the following order, as shown in FIG16 .

[0509] When constructing the Merge list, when adding a zero-valued MVP candidate, the first zero-valued MVP candidate is added first. Then, a redundancy check is performed between this zero-valued MVP candidate and the candidates added before it in the list. If the zero-valued MVP candidate is not redundant, the number of candidates participating in the ARMC increases by 1. If the zero-valued MVP candidate is redundant, the number of candidates participating in the ARMC remains at the value before the zero-valued MVP candidate was added. Finally, other zero-valued MVP candidates are added. After completing the above steps, step S311 in Figure 3 is called to perform the ARMC operation.

[0510] It should be understood that "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" or "in some embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments. The above description of the various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other. For the sake of brevity, they will not be repeated here.

[0511] The term "and / or" in this article is only a description of the association relationship between associated objects, indicating that there can be three relationships. For example, object A and / or object B can mean: object A exists alone, object A and object B exist at the same time, and object B exists alone.

[0512] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0513] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be electrical, mechanical or other forms.

[0514] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed across multiple network units; some or all of the modules may be selected according to actual needs to achieve the purpose of this embodiment.

[0515] In addition, all functional modules in the embodiments of the present application can be integrated into one processing unit, or each module can be a separate unit, or two or more modules can be integrated into one unit; the above-mentioned integrated modules can be implemented in the form of hardware or in the form of hardware plus software functional units.

[0516] Those skilled in the art will understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, and other media that can store program codes.

[0517] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks or optical disks.

[0518] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0519] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0520] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.

[0521] The above is merely an embodiment 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 this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A video decoding method, used in a decoder, comprising: determining an initial motion information candidate list for a current block, the initial motion information candidate list comprising first-category motion information candidates and second-category motion information candidates, wherein the first-category motion information candidates are determined based on motion information of neighboring blocks and / or non-neighboring blocks of the current block, and the second-category motion information candidates are constructed based on a reference image index set using a preset rule and a motion vector with a preset value; sorting some of the motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer; Decoding the code stream to determine a candidate motion information index of the current block; Determining an inter-frame prediction value of the current block according to the motion information candidate index of the current block and the motion information candidate list; Decoding a bitstream to determine a residual value of the current block; A reconstructed value of the current block is determined according to the residual value of the current block and the inter-frame prediction value.

2. The method according to claim 1, wherein include: The values ​​of the two components of the motion vector of the preset value are both equal to 0.

3. The method according to claim 1, wherein include: The N second-category motion information candidates included in the partial motion information candidates are the N second-category motion information candidates that are sequentially added into the initial motion information candidate list during the process of constructing the initial motion information candidate list.

4. The method according to claim 3, wherein: include: The N second-category motion information candidates included in the partial motion information candidates are the N second-category motion information candidates that are sorted after the first-category motion information candidates in the initial motion information candidate list.

5. The method according to claim 3, wherein: Also includes: The partial motion information candidates include all first-category motion information candidates in the initial motion information candidate list.

6. The method according to claim 1, wherein N is a preset value.

7. The method according to claim 6, wherein: The value of N is 1, 2, or 3.

8. The method according to claim 6, wherein: The value of N is less than or equal to the number of reference images allowed to be used.

9. The method according to claim 6, wherein: The value of N is smaller than the number of the second-category motion information candidates included in the initial motion information candidate list.

10. The method according to claim 1, wherein The method further comprises: The N second-category motion information candidates in the partial motion information candidates are second-category motion information candidates in the initial motion information candidate list that do not meet the first condition; or The N second-category motion information candidates in the partial motion information candidates are second-category motion information candidates in the initial motion information candidate list that meet the second condition.

11. The method according to claim 10, wherein: The first condition is that the motion vector and the reference image index of the second-type motion information candidate are equal to the motion vector and the reference image index of the first-type motion information candidate.

12. The method according to claim 10, wherein: The first condition is that the second-category motion information candidate is close to the first-category motion information candidate included in the partial motion information candidate, including: The reference image index of the second motion information candidate is equal to the reference image index of the first motion information candidate, and at least one of the following conditions is met: an absolute value of a difference between a vertical component of a motion vector of the second motion information candidate and a vertical component of a motion vector of the first motion information candidate is smaller than a first threshold; An absolute value of a difference between a horizontal component of a motion vector of the second motion information candidate and a horizontal component of a motion vector of the first motion information candidate is smaller than a second threshold.

13. The method according to claim 10, wherein: The second condition includes: After adaptively reordering the second-category motion information candidates in the initial motion information candidate list, the first second-category motion information candidate in the newly ordered list is selected.

14. The method according to claim 10, wherein: The second condition includes: The second type of motion information candidate having the smallest template matching error in the initial motion information candidate list.

15. The method according to claim 1, wherein Also includes: The current block contains at least a first number of sample values; or, The size of the current block meets a preset third condition.

16. The method according to claim 15, wherein include: The first number is 16.

17. The method according to claim 15, wherein: include: The third condition is that the width and height of the current block are less than or equal to a first preset size value.

18. The method according to claim 17, wherein include: The first preset size value is 128x128.

19. The method according to claim 15, wherein include: The third condition is that the width and height of the current block are greater than or equal to a second preset size value.

20. The method according to claim 19, wherein include: The second preset size value is 4x4.

21. The method according to claim 15, wherein include: The third condition is that the width and height of the current block are smaller than or equal to a first preset size value, and the width and height of the current block are larger than or equal to a second preset size value.

22. The method according to claim 21, wherein: include: The first preset size value is 128x128, and the second preset size value is 4x4.

23. The method according to claim 1, wherein The sorting of some motion information candidates in the initial motion information candidate list to determine the motion information candidate list of the current block includes: determining a template matching error of the partial motion information candidate; The partial motion information candidates are sorted according to the template matching error.

24. The method according to claim 23, wherein The determining of the template matching error of the partial motion information candidate includes: Determining a template for the current block; Determining, according to the motion vector of the partial motion information candidate, a corresponding template of the template in a reference image indicated by a reference image index of the partial motion candidate; The template matching error is determined according to the template and the corresponding template.

25. The method according to claim 24, wherein: The determining the template matching error according to the template and the corresponding template includes: According to a preset error criterion, the error between the template and the corresponding template is calculated.

26. The method according to claim 25, wherein: Also includes: The error criterion is one of the following: SAD, STAD, MSE, SSD.

27. The method according to claim 25, wherein: Also includes: The error criterion is one of the following: PSNR, SSIM.

28. The method according to claim 23 or 26, wherein: Sorting the partial motion information candidates according to the template matching error includes: The partial motion information candidates are sorted in ascending order of the template matching errors.

29. The method according to claim 23 or 27, wherein: Sorting the partial motion information candidates according to the template matching error includes: The partial motion information candidates are sorted in descending order of the template matching errors.

30. The method according to claim 23, wherein: Also includes: The partial motion information candidates are M motion information candidates, where M is an integer greater than 1.

31. The method according to claim 30, wherein: The determining of the motion information candidate list of the current block includes: The sorted partial motion information candidates correspond to motion information candidate indexes 0 to M−1 in the motion information candidate list of the current block.

32. The method according to claim 31, wherein: Also includes: Determine other motion information candidates in the motion information candidate list of the current block except the sorted part of the motion information.

33. The method according to claim 32, wherein The motion information candidate index corresponding to the unsorted other motion information candidates or the sorted other motion information candidates in the motion information candidate list of the current block is greater than the motion information candidate index corresponding to the sorted partial motion information candidates.

34. The method according to claim 33, wherein Also includes: The other motion information candidates are sorted using the same sorting method as that used for sorting the partial motion information candidates.

35. A video encoding method, used in an encoder, comprising: determining an initial motion information candidate list for a current block, the initial motion information candidate list comprising first-category motion information candidates and second-category motion information candidates, wherein the first-category motion information candidates are determined based on motion information of neighboring blocks and / or non-neighboring blocks of the current block, and the second-category motion information candidates are constructed based on a reference image index set using a preset rule and a motion vector with a preset value; sorting some of the motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer; Determining a motion information candidate index of the current block according to the determined motion information candidate list of the current block; The motion information candidate index of the current block is encoded, and the encoded bits are written into a bitstream.

36. The method according to claim 35, wherein include: The values ​​of the two components of the motion vector of the preset value are both equal to 0.

37. The method according to claim 35, wherein include: The N second-category motion information candidates included in the partial motion information candidates are the N second-category motion information candidates that are sequentially added into the initial motion information candidate list during the process of constructing the initial motion information candidate list.

38. The method of claim 37, wherein: include: The N second-category motion information candidates included in the partial motion information candidates are the N second-category motion information candidates that are sorted after the first-category motion information candidates in the initial motion information candidate list.

39. The method of claim 37, wherein: Also includes: The partial motion information candidates include all first-category motion information candidates in the initial motion information candidate list.

40. The method of claim 35, wherein N is a preset value.

41. The method according to claim 40, wherein The value of N is 1, 2, or 3.

42. The method of claim 40, wherein: The value of N is less than or equal to the number of reference images allowed to be used.

43. The method of claim 40, wherein: The value of N is smaller than the number of the second-category motion information candidates included in the initial motion information candidate list.

44. The method of claim 35, wherein The method further comprises: The N second-category motion information candidates in the partial motion information candidates are second-category motion information candidates in the initial motion information candidate list that do not meet the first condition; or The N second-category motion information candidates in the partial motion information candidates are second-category motion information candidates in the initial motion information candidate list that meet the second condition.

45. The method of claim 44, wherein: The first condition is that the motion vector and the reference image index of the second-type motion information candidate are equal to the motion vector and the reference image index of the first-type motion information candidate.

46. ​​The method of claim 44, wherein The first condition is that the second-category motion information candidate is close to the first-category motion information candidate included in the partial motion information candidate, including: The reference image index of the second motion information candidate is equal to the reference image index of the first motion information candidate, and at least one of the following conditions is met: an absolute value of a difference between a vertical component of a motion vector of the second motion information candidate and a vertical component of a motion vector of the first motion information candidate is smaller than a first threshold; An absolute value of a difference between a horizontal component of a motion vector of the second motion information candidate and a horizontal component of a motion vector of the first motion information candidate is smaller than a second threshold.

47. The method of claim 44, wherein The second condition includes: After adaptively reordering the second-category motion information candidates in the initial motion information candidate list, the first second-category motion information candidate in the newly ordered list is selected.

48. The method of claim 44, wherein The second condition includes: The second type of motion information candidate having the smallest template matching error in the initial motion information candidate list.

49. The method of claim 35, wherein Also includes: The current block contains at least a first number of sample values; or, The size of the current block meets a preset third condition.

50. The method of claim 49, wherein include: The first number is 16.

51. The method of claim 49, wherein include: The third condition is that the width and height of the current block are less than or equal to a first preset size value.

52. The method of claim 51, wherein include: The first preset size value is 128x128.

53. The method of claim 49, wherein include: The third condition is that the width and height of the current block are greater than or equal to a second preset size value.

54. The method of claim 53, wherein: include: The second preset size value is 4x4.

55. The method of claim 49, wherein include: The third condition is that the width and height of the current block are smaller than or equal to a first preset size value, and the width and height of the current block are larger than or equal to a second preset size value.

56. The method of claim 55, wherein: include: The first preset size value is 128x128, and the second preset size value is 4x4.

57. The method of claim 35, wherein The sorting of some motion information candidates in the initial motion information candidate list to determine the motion information candidate list of the current block includes: determining a template matching error of the partial motion information candidate; The partial motion information candidates are sorted according to the template matching error.

58. The method of claim 57, wherein The determining of the template matching error of the partial motion information candidate includes: Determining a template for the current block; Determining, according to the motion vector of the partial motion information candidate, a corresponding template of the template in a reference image indicated by a reference image index of the partial motion candidate; The template matching error is determined according to the template and the corresponding template.

59. The method according to claim 58, wherein The determining the template matching error according to the template and the corresponding template includes: According to a preset error criterion, the error between the template and the corresponding template is calculated.

60. The method according to claim 59, wherein: Also includes: The error criterion is one of the following: SAD, STAD, MSE, SSD.

61. The method of claim 59, wherein: Also includes: The error criterion is one of the following: PSNR, SSIM.

62. The method according to claim 57 or 60, wherein Sorting the partial motion information candidates according to the template matching error includes: The partial motion information candidates are sorted in ascending order of the template matching errors.

63. The method according to claim 57 or 60, wherein: Sorting the partial motion information candidates according to the template matching error includes: The partial motion information candidates are sorted in descending order of the template matching errors.

64. The method according to claim 57, wherein: Also includes: The partial motion information candidates are M motion information candidates, where M is an integer greater than 1.

65. The method according to claim 64, wherein: The determining of the motion information candidate list of the current block includes: The sorted partial motion information candidates correspond to motion information candidate indexes 0 to M−1 in the motion information candidate list of the current block.

66. The method according to claim 65, wherein: Also includes: Determine other motion information candidates in the motion information candidate list of the current block except the sorted part of the motion information.

67. The method of claim 66, wherein The motion information candidate index corresponding to the unsorted other motion information candidates or the sorted other motion information candidates in the motion information candidate list of the current block is greater than the motion information candidate index corresponding to the sorted partial motion information candidates.

68. The method of claim 67, wherein Also includes: The other motion information candidates are sorted using the same sorting method as that used for sorting the partial motion information candidates.

69. A video decoding device, used in a decoder, comprising: a first determining module configured to determine an initial motion information candidate list for a current block, the initial motion information candidate list comprising a first category of motion information candidates and a second category of motion information candidates, wherein the first category of motion information candidates is determined based on motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second category of motion information candidates is constructed based on a reference image index set using a preset rule and a motion vector with a preset value; a first sorting module configured to sort some motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer; A decoding module configured to decode a code stream and determine a candidate motion information index of the current block; a second determining module configured to determine an inter-frame prediction value of the current block according to the motion information candidate index of the current block and the motion information candidate list; The decoding module is further configured to decode the code stream and determine the residual value of the current block; The third determining module is configured to determine a reconstructed value of the current block according to the residual value of the current block and the inter-frame prediction value.

70. A video encoding device, for use in an encoder, comprising: a fourth determining module configured to determine an initial motion information candidate list for a current block, the initial motion information candidate list comprising first-category motion information candidates and second-category motion information candidates, wherein the first-category motion information candidates are determined based on motion information of adjacent blocks and / or non-adjacent blocks of the current block, and the second-category motion information candidates are constructed based on a reference image index set using a preset rule and a motion vector with a preset value; a second sorting module configured to sort some of the motion information candidates in the initial motion information candidate list to determine a motion information candidate list for the current block; wherein the some of the motion information candidates include at least one first-category motion information candidate and N second-category motion information candidates, where N is a positive integer; A fifth determining module, configured to determine a motion information candidate index of the current block according to the motion information candidate list of the current block; The encoding module is configured to encode the motion information candidate index of the current block and write the encoded bits into a bitstream.

71. A decoder comprising a first memory and a first processor; wherein, The first memory is used to store a computer program that can be run on the first processor; The first processor is configured to execute the video decoding method according to any one of claims 1 to 34 when running the computer program.

72. An encoder comprising a second memory and a second processor; wherein The second memory is used to store a computer program that can be run on the second processor; The second processor is configured to execute the video encoding method according to any one of claims 35 to 68 when running the computer program.

73. A code stream, the code stream being generated by bit-coding candidate motion information indexes of a current block; wherein The candidate motion information index of the current block is obtained through any one of claims 35 to 68.

74. An electronic device comprising: a processor adapted to execute a computer program; A computer-readable storage medium having a computer program stored therein, wherein the computer program, when executed by the processor, implements the video decoding method according to any one of claims 1 to 34, or implements the video encoding method according to any one of claims 35 to 68 when the computer program is executed by the processor.

75. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, which, when executed, implements the video decoding method according to any one of claims 1 to 34, or implements the video encoding method according to any one of claims 35 to 68.