CN110691247A - Decoding and encoding method and device - Google Patents

Decoding and encoding method and device Download PDF

Info

Publication number
CN110691247A
CN110691247A CN201810738280.4A CN201810738280A CN110691247A CN 110691247 A CN110691247 A CN 110691247A CN 201810738280 A CN201810738280 A CN 201810738280A CN 110691247 A CN110691247 A CN 110691247A
Authority
CN
China
Prior art keywords
image block
motion vector
template
motion information
candidate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810738280.4A
Other languages
Chinese (zh)
Other versions
CN110691247B (en
Inventor
陈方栋
王莉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN201810738280.4A priority Critical patent/CN110691247B/en
Priority to PCT/CN2019/094433 priority patent/WO2020007306A1/en
Publication of CN110691247A publication Critical patent/CN110691247A/en
Application granted granted Critical
Publication of CN110691247B publication Critical patent/CN110691247B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/136Incoming video signal characteristics or properties
    • H04N19/137Motion inside a coding unit, e.g. average field, frame or block difference
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/136Incoming video signal characteristics or properties
    • H04N19/137Motion inside a coding unit, e.g. average field, frame or block difference
    • H04N19/139Analysis of motion vectors, e.g. their magnitude, direction, variance or reliability
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • H04N19/149Data rate or code amount at the encoder output by estimating the code amount by means of a model, e.g. mathematical model or statistical model
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock

Abstract

The application provides a decoding and encoding method and equipment, wherein the method comprises the following steps: acquiring motion information of candidate image blocks of a current image block; acquiring a template of the current image block according to the motion information of the candidate image block; obtaining target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template; determining final motion information of the current image block according to the target motion information; and decoding the current image block according to the final motion information. By the technical scheme, the coding efficiency, the coding time delay and the decoding efficiency can be improved, and the decoding time delay is reduced.

Description

Decoding and encoding method and device
Technical Field
The present application relates to the field of video encoding and decoding technologies, and in particular, to a decoding method, an encoding method, and an encoding apparatus.
Background
In order to achieve the purpose of saving space, video images are transmitted after being coded, and the complete video coding method can comprise the processes of prediction, transformation, quantization, entropy coding, filtering and the like. The predictive coding comprises intra-frame coding and inter-frame coding, wherein the inter-frame coding is to use the correlation of a video time domain and use the pixels adjacent to a coded image to predict the pixels of a current image so as to achieve the aim of effectively removing the video time domain redundancy.
In inter-frame coding, a Motion Vector (MV) may be used to represent a relative displacement between a current image block of a current frame video image and a reference image block of a reference frame video image. For example, when a video image a of the current frame has a strong temporal correlation with a video image B of the reference frame, and an image block a1 (current image block) of the video image a needs to be transmitted, a motion search may be performed in the video image B to find an image block B1 (i.e., reference image block) that best matches image block a1, and determine a relative displacement between image block a1 and image block B1, which is also a motion vector of image block a 1.
The encoding side may send the motion vector to the decoding side, instead of sending the image block a1 to the decoding side, and the decoding side may obtain the image block a1 according to the motion vector and the image block B1. Obviously, this can save a lot of bits, since the motion vector occupies a smaller number of bits than the image block a 1.
However, when the video image a is divided into a large number of image blocks, a relatively large number of bits are also consumed when transmitting the motion vector for each image block. To further save bits, the motion vectors of the image block a1 may also be predicted using spatial correlation between candidate image blocks. For example, the motion vector of image block a2 adjacent to image block a1 may be determined as the motion vector of image block a 1. Based on this, the encoding side may send the index value of the image block a2 to the decoding side, and the decoding side may determine the motion vector of the image block a2, which is the motion vector of the image block a1, based on the index value. This may result in further bit savings, since the index value of the image block a2 occupies a smaller number of bits than the motion vector.
Since the motion of the image block a1 may be different from the motion of the image block a2, that is, the motion vector of the image block a2 may not be consistent with the motion vector of the image block a1, determining the motion vector of the image block a2 as the motion vector of the image block a1 has problems of low prediction quality, erroneous prediction, and the like.
Disclosure of Invention
The application provides a decoding and encoding method and equipment, which solve the problems of low prediction quality, prediction error and the like, can improve the precision of motion vectors, and improve the encoding performance and the decoding performance.
The application provides a decoding method, which is applied to a decoding end and comprises the following steps:
acquiring motion information of candidate image blocks of a current image block;
acquiring a template of the current image block according to the motion information of the candidate image block;
obtaining target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template;
determining final motion information of the current image block according to the target motion information;
and decoding the current image block according to the final motion information.
The application provides a coding method, which is applied to a coding end, and the method comprises the following steps:
acquiring motion information of candidate image blocks of a current image block;
acquiring a template of the current image block according to the motion information of the candidate image block;
obtaining target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template;
determining final motion information of the current image block according to the original motion information and the target motion information; and coding the current image block according to the final motion information to obtain a coded bit stream.
The application provides a decoding side device, including: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor is configured to execute machine-executable instructions to implement the decoding method steps described above.
The application provides a coding end device, including: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor is configured to execute machine executable instructions to implement the encoding method steps described above.
According to the technical scheme, the target motion information can be obtained according to the original motion information, the final motion information of the current image block is determined according to the target motion information, and the final motion information of the current image block is not determined according to the original motion information, so that the precision of the motion information is improved, and the coding performance is improved. And when the target motion information is obtained according to the original motion information, the template of the current image block can be obtained according to the motion information of the candidate image block, and the target motion information is obtained according to the template of the current image block. For example, before the reconstruction stage of decoding, a template of the current image block may be obtained, and the object motion information may be obtained according to the template.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments of the present application or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art according to the drawings of the embodiments of the present application.
FIG. 1 is a flow chart of an encoding method in one embodiment of the present application;
FIGS. 2A-2O are schematic diagrams of a template of a current image block according to an embodiment of the present application;
FIG. 3 is a flow chart of an encoding method in another embodiment of the present application;
FIGS. 4A-4C are flow diagrams of an encoding method in another embodiment of the present application;
FIG. 5 is a flow chart of a decoding method in another embodiment of the present application;
FIGS. 6A and 6B are flow diagrams of a decoding method in another embodiment of the present application;
fig. 7 is a block diagram of a decoding apparatus according to an embodiment of the present application;
fig. 8 is a block diagram of an encoding device according to another embodiment of the present application;
fig. 9 is a hardware configuration diagram of a decoding-side device according to an embodiment of the present application;
fig. 10 is a hardware configuration diagram of an encoding-side device according to an embodiment of the present application.
Detailed Description
The terminology used in the embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein is meant to encompass any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in the embodiments of the present application to describe various information, the information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. Depending on the context, moreover, the word "if" as used may be interpreted as "at … …" or "when … …" or "in response to a determination".
The embodiment of the application provides an encoding and decoding method, which can relate to the following concepts:
motion Vector (MV): in the inter-frame coding, a motion vector is used to represent the relative displacement between a current image block of a current frame video image and a reference image block of a reference frame video image, and each divided image block has a corresponding motion vector transmitted to a decoding end. If the motion vectors of each image block are encoded and transmitted independently, especially if divided into a large number of image blocks of small size, a considerable number of bits are consumed. In order to reduce the bit number for encoding the motion vector, the spatial correlation between adjacent image blocks can be utilized to predict the motion vector of the current image block to be encoded according to the motion vector of the adjacent encoded image block, and then the prediction difference is encoded, so that the bit number representing the motion vector can be effectively reduced.
Motion Information (Motion Information): since the motion vector indicates the position offset of the current image block from a certain reference image block, in order to accurately acquire information pointing to the image block, index information of the reference frame image is required in addition to the motion vector to indicate which reference frame image is used. In the video coding technology, for a current frame image, a reference frame image list may be generally established, and the reference frame image index information indicates that the current image block adopts the several reference frame images in the reference frame image list. In the video encoding technology, motion-related encoding information such as a motion vector and a reference frame index may be collectively referred to as motion information.
Template (Template): in video coding techniques, the coding process is performed on an image block-by-image block basis, and when the current image block is coded, the reconstruction information of the surrounding coded image blocks is available. The template refers to the decoding information of a fixed shape around the current image block (adjacent region in the time domain or the space domain). The templates are identical at the encoding end and the decoding end, so that some operations performed by the templates at the encoding end can obtain completely consistent results at the decoding end, that is, information derived by the encoding end based on the templates can be recovered at the decoding end without loss, without transferring additional information, thereby further reducing the number of transmission bits.
Rate-Distortion principle (Rate-Distortion Optimized): there are two major indicators for evaluating coding efficiency: code rate and Peak Signal to Noise Ratio (PSNR), the smaller the bit stream, the larger the compression rate, and the larger the PSNR, the better the reconstructed image quality, and in the mode selection, the discrimination formula is essentially the comprehensive evaluation of the two. For example, the cost for a mode: j (mode) ═ D + λ R, where D denotes Distortion, which can be generally measured using SSE metric, SSE refers to the mean square sum of the differences between the reconstructed image block and the source image; and λ is a lagrange multiplier, and R is the actual number of bits required for encoding the image block in the mode, including the sum of bits required for encoding mode information, motion information, residual errors and the like.
Intra and inter prediction (intra and inter): the intra-frame prediction refers to performing predictive coding by using reconstructed pixel values of spatial adjacent image blocks (for example, in the same frame as the current image block) of the current image block, and the inter-frame prediction refers to performing predictive coding by using reconstructed pixel values of temporal adjacent image blocks (for example, in a different frame from the current image block) of the current image block.
The decoding method and the encoding method will be described in detail below with reference to specific embodiments.
The first embodiment is as follows:
referring to fig. 1, a flow chart of an encoding method is shown, and the method may include the following steps:
step 101, a coding end acquires motion information of a candidate image block of a current image block.
The candidate image blocks of the current image block may include, but are not limited to: a spatial domain candidate image block of the current image block; or, a time domain candidate image block of the current image block; the candidate image block is not limited.
When the current image block is encoded, since the candidate image block of the current image block has already been encoded, that is, the motion information of the candidate image block is known, the encoding end may directly obtain the motion information of the candidate image block, such as a motion vector and a reference frame index of the candidate image block, which is not limited thereto.
The motion information of the candidate image block may include, but is not limited to: original motion information corresponding to the candidate image block, such as an original motion vector, or an original motion vector and an original reference frame. And final motion information corresponding to the candidate image block, such as a final motion vector, or the final motion vector and a final reference frame.
In one example, the final motion information of the current image block is only used for encoding of the current image block (encoding processes such as generation and reconstruction of a prediction value of the current image block), and is not used for prediction of an adjacent image block, i.e., the motion information obtained from the candidate image block is the original motion information of the candidate block, but not the final motion information of the candidate image block. After the encoding of the current image block is finished, the final motion information is not stored, but the original motion information is stored, that is, the motion information of the current image block is restored to the original motion information.
In the following embodiments, the obtaining manner of the final motion information of the current image block is described, and the obtaining manner of the final motion information corresponding to the candidate image block is similar to the obtaining manner of the final motion information of the current image block, that is, the candidate image block obtains the final motion information when serving as the current image block, which is not described herein again.
In one example, the encoding end may store motion information corresponding to the candidate image block, for example, original motion information corresponding to the candidate image block is stored as motion information of the candidate block or final motion information corresponding to the candidate image block is stored as motion information of the candidate block, so that, in step 101, the original motion information corresponding to the candidate image block may be directly queried locally from the encoding end.
In another example, the encoding end may obtain original motion information (e.g., an original motion vector and an original reference frame) corresponding to the candidate image block, for example, select a motion vector from a motion vector list of the candidate image block, where the selected motion vector is an original motion vector. For another example, the motion information of an image block adjacent to the candidate image block may be determined as the original motion information corresponding to the candidate image block.
The above manner is merely an example of obtaining the original motion information of the candidate image block, and is not limited to this.
And 102, the encoding end acquires a template of the current image block according to the motion information of the candidate image block.
The processing procedure in step 102 may refer to the following embodiments, which are not described herein again.
And 103, the encoding end obtains target motion information based on the template according to the original motion information corresponding to the current image block and the acquired template. Wherein the original motion information comprises an original motion vector and the target motion information comprises a target motion vector. Or, the original motion information includes an original motion vector and an original reference frame, and the target motion information includes a target motion vector and a target reference frame.
When the original motion information includes an original motion vector and the target motion information includes a target motion vector, the encoding end obtains the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template, and the method includes: determining the original motion vector as a central motion vector; determining an edge motion vector corresponding to the center motion vector, the edge motion vector being different from the center motion vector; obtaining the coding performance of the central motion vector and the coding performance of the edge motion vector according to the template; and determining the target motion vector from the central motion vector and the edge motion vector according to the coding performance of the central motion vector and the coding performance of the edge motion vector.
When the original motion information comprises an original motion vector and an original reference frame, and the target motion information comprises a target motion vector and a target reference frame, the encoding end obtains the target motion information based on the template according to the original motion information corresponding to the current image block and the acquired template, and the method comprises the following steps: based on the template of the current image block, obtaining a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to the candidate reference frames according to the initial motion vectors; obtaining a candidate motion vector corresponding to the candidate reference frame according to the initial motion vector; selecting a candidate motion vector with optimal coding performance from the candidate motion vectors corresponding to the original reference frame and the candidate motion vectors corresponding to the candidate reference frames; and determining the candidate motion vector with the optimal coding performance as the target motion vector, and determining a reference frame corresponding to the candidate motion vector with the optimal coding performance as the target reference frame.
The detailed processing procedure in step 103 may refer to the following embodiments, which are not described herein again.
And step 104, the encoding end determines the final motion information of the current image block according to the original motion information and the target motion information.
When the original motion information includes an original motion vector, the target motion information includes a target motion vector, and the final motion information includes a final motion vector, the encoding end determines the final motion information of the current image block according to the original motion information and the target motion information, which may include: acquiring the coding performance of an original motion vector and the coding performance of a target motion vector; when the coding performance of the target motion vector is superior to that of the original motion vector, determining the final motion vector of the current image block as the target motion vector; and when the encoding performance of the original motion vector is better than that of the target motion vector, determining the final motion vector of the current image block as the original motion vector.
The encoding performance of obtaining the original motion vector includes: determining the encoding performance of an original motion vector according to the parameter information of a template of a current image block and the parameter information of a first target reference block, wherein the first target reference block is an image block obtained after a reference image block corresponding to the template is subjected to offset based on the original motion vector; the obtaining of the coding performance of the target motion vector comprises: and determining the coding performance of the target motion vector according to the parameter information of the template of the current image block and the parameter information of a second target reference block, wherein the second target reference block is an image block obtained after the reference image block corresponding to the template is subjected to offset based on the target motion vector.
The detailed processing procedure in step 104 may refer to the following embodiments, which are not described herein again.
And 105, the coding end codes the current image block according to the final motion information to obtain a coded bit stream. Then, the encoding side may also transmit the encoded bitstream to the decoding side.
And 106, storing the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block by the encoding terminal. In this way, in the processing process of other image blocks, if the current image block is selected as a candidate image block of another image block, in step 101, the motion information of the candidate image block, that is, the original motion information or the final motion information corresponding to the candidate image block, may be obtained as the template according to the original motion information or the final motion information corresponding to the candidate image block.
In one example, storing the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block may include: when the original motion information of the current image block is obtained according to the motion information of the spatial neighboring block (or the spatial neighboring block), storing the original motion information corresponding to the current image block as the motion information of the current image block. And when the original motion information of the current image block is not obtained according to the motion information of the spatial adjacent block (or the spatial adjacent block), storing the final motion information corresponding to the current image block as the motion information of the current image block. For example, when the original motion information corresponding to the current image block is obtained according to the motion information of the time domain adjacent block, storing the final motion information corresponding to the current image block as the motion information of the current image block; in a default case, the final motion information corresponding to the current image block may also be stored as the motion information of the current image block.
Further, in some embodiments, the original motion information at least includes an original motion vector, and when the original motion vector of the current image block is obtained according to the motion vectors of the spatial neighboring blocks, the original motion vector corresponding to the current image block is stored as the motion vector of the current image block. And when the original motion information of the current image block is not obtained according to the motion vector of the spatial domain adjacent block, storing the final motion vector corresponding to the current image block as the motion vector of the current image block. For example, when the original motion vector corresponding to the current image block is obtained according to the motion vectors of the time-domain neighboring blocks, the final motion vector corresponding to the current image block is stored as the motion vector of the current image block; by default, the final motion vector corresponding to the current image block may also be stored as the motion vector of the current image block.
In one example, the motion information includes a motion vector, and the original motion vector of the current image block is stored as the motion vector of the current image block after encoding, or in another example, the final motion vector of the current image block is stored as the motion vector of the current image block after encoding.
In one example, the final motion information of the current image block is only used for encoding of the current image block (encoding processes such as generation and reconstruction of a prediction value of the current image block), and is not used for prediction of an adjacent image block, i.e., the motion information obtained from the candidate image block is the original motion information of the candidate block, but not the final motion information of the candidate image block. After the encoding of the current image block is finished, the final motion information is not stored, but the original motion information is stored, that is, the motion information of the current image block is restored to the original motion information.
In one example, the motion information of the candidate image block in step 101 may be an original motion vector of the candidate image block, and in step 106, the encoding end stores the original motion vector corresponding to the current image block as the motion vector of the current image block.
In one example, the motion information of the candidate image block in step 101 may be a final motion vector of the candidate image block, and in step 106, the encoding end stores an original motion vector corresponding to the current image block as the motion vector of the current image block.
In one example, the motion information of the candidate image block in step 101 may be an original motion vector of the candidate image block, and in step 106, the encoding end stores a final motion vector corresponding to the current image block as a motion vector of the current image block.
In an example, the motion information of the candidate image block in step 101 may be a final motion vector of the candidate image block, and in step 106, the encoding end stores the final motion vector corresponding to the current image block as the motion vector of the current image block.
Of course, the motion information includes the reference image frame, the motion direction, and the like, in addition to the motion vector.
In one example, the encoding end may further obtain an index value of the original motion vector in the motion vector list; also, the coded bitstream may carry the index value, which is described in the following embodiments.
In an example, if the final motion vector of the current image block is the target motion vector, the encoded bitstream may further carry first indication information, where the first indication information is used to indicate that the final motion information of the current image block is determined based on the template. In addition, if the final motion vector of the current image block is the original motion vector, the coded bitstream may further carry second indication information, where the second indication information is used to indicate that the final motion information of the current image block is determined based on the original motion information corresponding to the current image block.
In practical application, the first indication information or the second indication information may also be notified in an implicit manner, that is, the first indication information or the second indication information is not carried in the coded bitstream. Specifically, the encoding end and the decoding end may also negotiate a decision policy or define a policy in a standard, and store the policy in the encoding end and the decoding end, where the decision policy may be default first policy information, and the first policy information is used to indicate that final motion information of the current image block is determined based on the template; or defaulting second strategy information, wherein the second strategy information is used for indicating that final motion information of the current image block is determined based on original motion information corresponding to the current image block; or, the third policy information is defaulted, and the third policy information is the same policy information as that adopted by the adjacent image block of the current image block.
On this basis, when the decision policy is the default first policy information and the encoding end encodes the bitstream according to the target motion information, the encoded bitstream may not carry the first indication information and the second indication information. When the decision policy is the default second policy information and the encoding end encodes the bitstream according to the original motion information, the encoded bitstream may not carry the first indication information and the second indication information. When the decision strategy is the default third strategy information and the adjacent image block adopts the first strategy information, the coding end may not carry the first indication information and the second indication information when coding the bit stream according to the target motion information; when the adjacent image block uses the second policy information and the encoding end encodes the bitstream according to the original motion information, the encoded bitstream may not carry the first indication information and the second indication information.
According to the technical scheme, in the embodiment of the application, the template of the current image block can be obtained according to the motion information of the candidate image block of the current image block, and the bit stream is encoded according to the template of the current image block to obtain the encoded bit stream. The method can quickly obtain the template of the current image block, solves the problems of low coding efficiency, large coding delay and the like, can improve the coding efficiency, reduce the coding delay and improve the coding performance.
Furthermore, the encoding end can encode a plurality of image blocks in parallel, so that the encoding speed is further increased, the encoding efficiency is increased, the encoding time delay is reduced, and the encoding performance is improved.
In one example, the final motion information of the current image block is only used for encoding of the current image block (encoding processes such as generation and reconstruction of a prediction value of the current image block), and is not used for prediction of an adjacent image block, that is, candidate motion information obtained by the adjacent image block is original motion information, but not final motion information. After the encoding of the current image block is finished, the final motion information is not stored, but the original motion information is stored, that is, the motion information of the current image block is restored to the original motion information.
Example two:
in the process of video coding, each image block is coded one by one, and when the current image block is coded, if the adjacent image blocks around the current image block are completely reconstructed, the current image block can be reconstructed by using the decoded information of the adjacent image blocks, so that the template of the current image block can be obtained by using the decoded information of the adjacent image blocks of the current image block. The decoded information may include, but is not limited to: reconstruction information of neighboring image blocks and/or prediction information of neighboring image blocks. The reconstruction information may include, but is not limited to, luminance values, chrominance values, and the like; the prediction information may be an intermediate value from which the reconstruction information can be obtained, and for example, if the luminance value can be obtained using the intermediate value a, the intermediate value a is the prediction information, and this prediction information is not limited.
However, if the decoded information is reconstruction information, the generation of the template of the current image block needs to wait for the decoding reconstruction stage, which greatly reduces the decoding efficiency and brings decoding delay; and the decoding information is prediction information, the generation of the template of the current image block also needs to wait for the decoding reconstruction stage, so that the decoding efficiency is greatly reduced, and the decoding time delay is brought. Therefore, the above method may cause the parallelism of decoding to be greatly affected.
In view of the above findings, in this embodiment, a better template generating manner is provided, and unlike a manner in which a template is generated by using reconstruction information and prediction information, a method for obtaining the template of the current image block according to motion information (such as a motion vector and a reference frame index) of a candidate image block of the current image block and obtaining the template of the current image block according to the motion information of the candidate image block may be applied to both the encoding side and the decoding side.
The obtaining the template of the current image block according to the motion information of the candidate image block may include: when the motion information comprises a motion vector and a reference frame index of the candidate image block, determining a reference frame image corresponding to the candidate image block according to the reference frame index; and acquiring a reference image block corresponding to the candidate image block from the reference frame image according to the motion vector, and acquiring a template of the current image block according to the reference image block.
For example, referring to FIG. 2A, assume tile A1 is the current tile and tile A2 and tile A3 are candidate tiles for tile A1. For tile a2, if the reference frame index of tile a2 is the index of video image B, it may be determined that the reference frame image corresponding to tile a2 is video image B according to the reference frame index; then, an image block B2 corresponding to the image block A2 is selected from the video image B, namely the position of the image block B2 in the video image B is the same as the position of the image block A2 in the video image A; then, the image block B2 may be moved according to the motion vector of the image block a2, for example, the image block B2 is moved by using the motion vector (3, 3), so as to obtain the image block B2 '(e.g., moving 3 pixels rightward and moving 3 pixels upward) corresponding to the image block B2, and the image block B2' is a reference image block corresponding to the image block a 2. Likewise, the reference image block corresponding to image block a3 may be determined to be image block B3'. Further, a template for tile A2 may be determined from tile B2 'and tile B3', as illustrated in FIG. 2A.
In one example, the candidate image blocks may include M first candidate image blocks and N second candidate image blocks, where M is a natural number greater than or equal to 1 and N is a natural number greater than or equal to 0, or M is a natural number greater than or equal to 0 and N is a natural number greater than or equal to 1. The first candidate image block is a candidate image block on the upper side of the current image block, and the second candidate image block is a candidate image block on the left side of the current image block.
Obtaining the template of the current image block according to the motion information of the candidate image block may include, but is not limited to: determining a first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks; and determining a second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks. Then, determining the first template as the template of the current image block; or, determining the second template as the template of the current image block; or determining the first template and the second template as the template of the current image block after splicing.
For example, when M is a natural number greater than or equal to 1 and N is 0, the first template may be determined according to the motion vector prediction modes and the motion information of the M first candidate image blocks, and the first template may be determined as the template of the current image block. When N is a natural number greater than or equal to 1 and M is 0, the second template may be determined according to the motion vector prediction modes and the motion information of the N second candidate image blocks, and the second template may be determined as the template of the current image block. When M is a natural number greater than or equal to 1 and N is a natural number greater than or equal to 1, determining a first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks, determining a second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks, and determining the first template as the template of the current image block; or determining the second template as the template of the current image block; or determining the first template and the second template as the template of the current image block after splicing.
The first candidate image block comprises an adjacent image block and/or a secondary adjacent image block on the upper side of the current image block; the prediction mode of the adjacent image block is an inter mode or an intra mode; the prediction mode of the secondary adjacent image block is an inter mode. For example, the first candidate image block may include at least one neighboring image block whose prediction mode is an inter mode, e.g., all neighboring image blocks on an upper side of the current image block, or a first neighboring image block on an upper side of the current image block, or any one or more neighboring image blocks on an upper side of the current image block. In addition, when the adjacent image blocks on the upper side of the current image block are both in intra mode, the first candidate image block may further include at least one secondary adjacent image block whose prediction mode is in inter mode, for example, all secondary adjacent image blocks on the upper side of the current image block, or the first secondary adjacent image block on the upper side of the current image block, or any one or more secondary adjacent image blocks on the upper side of the current image block. Furthermore, when there are neighboring image blocks in intra mode on the top side of the current image block, then the first candidate image block may also include neighboring image blocks in intra mode, for example, a neighboring image block in first intra mode on the top side of the current image block, neighboring image blocks in all intra modes on the top side of the current image block, and so on. Of course, the above is only an example of the first candidate image block, and the method is not limited thereto.
The second candidate image block comprises an adjacent image block on the left side of the current image block and/or a secondary adjacent image block; the prediction mode of the adjacent image block is an inter mode or an intra mode; the prediction mode of the secondary adjacent image block is an inter mode. For example, the second candidate image block may include at least one neighboring image block whose prediction mode is an inter mode, e.g., all neighboring image blocks on the left side of the current image block, or a first neighboring image block on the left side of the current image block, or any one or more neighboring image blocks on the left side of the current image block. Furthermore, when the adjacent image blocks on the left side of the current image block are all in intra mode, the second candidate image block may further include at least one secondary adjacent image block of which the prediction mode is in inter mode, for example, all secondary adjacent image blocks on the left side of the current image block, or the first secondary adjacent image block on the left side of the current image block, or any one or more secondary adjacent image blocks on the left side of the current image block. Furthermore, when there is an intra-mode neighboring image block on the left side of the current image block, then the first candidate image block may also include intra-mode neighboring image blocks, e.g., the first intra-mode neighboring image block on the left side of the current image block, all intra-mode neighboring image blocks on the left side of the current image block, etc. Of course, the above is only an example of the second candidate image block, and the method is not limited thereto.
Wherein, the neighboring image blocks of the current image block include but are not limited to: spatial adjacent image blocks of the current image block (i.e. adjacent image blocks in the same frame of video image); or temporally neighboring image blocks of the current image block (i.e., neighboring image blocks in a different frame of the video image). The secondary neighboring image blocks of the current image block include, but are not limited to: the spatial domain secondary adjacent image blocks of the current image block (namely the secondary adjacent image blocks in the same frame of video image); or a temporal secondary neighboring image block of the current image block (i.e., a secondary neighboring image block in a different frame of video image).
In an example, when M is greater than 1, the first template may include M sub-templates or P sub-templates, and the M sub-templates or the P sub-templates are spliced, where P may be the number of first candidate image blocks in the inter mode, and P is less than or equal to M. For example, when the M first candidate image blocks are all candidate image blocks in the inter mode, the first template may include M sub-templates, and the M sub-templates are spliced together. For another example, when the M first candidate image blocks include candidate image blocks in P inter modes and include candidate image blocks in M-P intra modes, the first template may include M sub-templates (i.e., one sub-template for each candidate image block) and is formed by splicing the M sub-templates, or the first template may include P sub-templates (i.e., P sub-templates for the candidate image blocks in P inter modes) and is formed by splicing the P sub-templates.
Furthermore, when M is equal to 1, the first template may include a first sub-template, which may be determined according to the motion vector prediction mode and the motion information of the first candidate image block on the upper side of the current image block; alternatively, the first sub-template may be determined according to the motion vector prediction mode and the motion information of any candidate image block on the upper side of the current image block. Since the first candidate image block includes at least one adjacent image block or a sub-adjacent image block whose prediction mode is the inter mode, when M is equal to 1, the first template includes a first sub-template corresponding to the adjacent image block or the sub-adjacent image block in the inter mode.
In one example, the motion information may include a motion vector and a reference frame index of the first candidate image block, based on which the first template is determined according to the motion vector prediction modes and the motion information of the M first candidate image blocks, which may include but is not limited to:
in the first case, for an ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter-frame mode, a reference frame image corresponding to the ith candidate image block is determined according to a reference frame index; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block; then, image blocks with the sizes of the first transverse length and the first longitudinal length may be obtained as the ith sub-template included in the first template according to the determined reference image block.
And secondly, for the ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be the intra-frame mode, filling the ith candidate image block according to a default value (such as a default pixel value, which may be an empirically preconfigured brightness value), and acquiring the image blocks with the sizes of the first transverse length and the first longitudinal length as the ith sub-template included in the first template based on the image block filled with the default value.
Determining a reference frame image corresponding to the ith candidate image block according to a reference frame index corresponding to the ith candidate image block when the motion vector prediction mode of the ith candidate image block is determined to be the intra-frame mode; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with (equal to or approximately equal to) the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a first transverse length and a first longitudinal length as an ith sub-template included in the first template; and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of the image block adjacent to the ith candidate image block.
The first lateral length and the lateral length of the first candidate image block satisfy a first proportional relationship (e.g., 1: 1, 1: 2, 2: 1, etc., which is not limited), or satisfy a second proportional relationship (e.g., 1: 1, 1: 2, 2: 1, etc.) with the lateral length of the current image block, or are equal to a first preset length (configured empirically).
The first vertical length and the vertical length of the first candidate image block satisfy a third proportional relationship (e.g., 1: 1, 1: 2, 2: 1, etc.), or satisfy a fourth proportional relationship (e.g., 1: 1, 1: 2, 2: 1, etc.) with the vertical length of the current image block, or equal to a second preset length (i.e., a length configured empirically).
The first proportional relationship, the second proportional relationship, the third proportional relationship and the fourth proportional relationship may be the same or different. The first preset length and the second preset length may be set to be the same or different.
In an example, when N is greater than 1, the second template may include N sub-templates or R sub-templates, and the N sub-templates or R sub-templates are spliced, where R may be the number of second candidate image blocks in the inter mode, and R is less than or equal to N. For example, when the N second candidate image blocks are all candidate image blocks in the inter mode, the second template may include N sub-templates, and the N sub-templates are spliced together. For another example, when the N second candidate image blocks include candidate image blocks in R inter modes and include candidate image blocks in N-R intra modes, the second template may include N sub-templates (i.e., one sub-template for each candidate image block) and is formed by splicing the N sub-templates, or the second template may include R sub-templates (i.e., R sub-templates for the candidate image blocks in R inter modes) and is formed by splicing the R sub-templates.
Furthermore, when N is equal to 1, the second template may include a second sub-template, which may be determined according to the motion vector prediction mode and the motion information of the first candidate image block on the left side of the current image block; alternatively, the second sub-template may be determined according to the motion vector prediction mode and the motion information of any candidate image block on the left side of the current image block. The second candidate image block includes at least one adjacent image block or a second adjacent image block of which the prediction mode is the inter mode, and therefore when N is equal to 1, the second template includes a second sub-template corresponding to the adjacent image block or the second adjacent image block of the inter mode.
In one example, the motion information may include a motion vector and a reference frame index of the second candidate image block, based on which the second template is determined according to the motion vector prediction modes and the motion information of the N second candidate image blocks, which may include but is not limited to:
in case one, for an ith candidate image block in the N second candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter-frame mode, determining a reference frame image corresponding to the ith candidate image block according to a reference frame index; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block; then, image blocks having the sizes of the second transverse length and the second longitudinal length may be obtained as the ith sub-template included in the second template according to the determined reference image block.
And in a second case, for an ith candidate image block in the N second candidate image blocks, when it is determined that the motion vector prediction mode of the ith candidate image block is the intra-frame mode, filling the ith candidate image block according to a default value (for example, a default pixel value, which may be a luminance value configured in advance according to experience), and acquiring image blocks with the sizes of a second transverse length and a second longitudinal length as an ith sub-template included in the second template based on the image block filled with the default value.
Determining a reference frame image corresponding to the ith candidate image block according to a reference frame index corresponding to the ith candidate image block when the motion vector prediction mode of the ith candidate image block is determined to be the intra-frame mode; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with (equal to or approximately equal to) the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a second transverse length and a second longitudinal length as an ith sub-template included in the first template; and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of the image block adjacent to the ith candidate image block.
The second horizontal length and the horizontal length of the second candidate image block satisfy a fifth proportional relationship (e.g., 1: 1, 1: 2, 2: 1, etc., which is not limited), or satisfy a sixth proportional relationship (e.g., 1: 1, 1: 2, 2: 1, etc.) with the horizontal length of the current image block, or are equal to a third preset length (configured empirically).
The second vertical length and the vertical length of the second candidate image block satisfy a seventh proportional relationship (e.g., 1: 1, 1: 2, 2: 1, etc.), or satisfy an eighth proportional relationship (e.g., 1: 1, 1: 2, 2: 1, etc.) with the vertical length of the current image block, or are equal to a fourth preset length (i.e., a length configured empirically).
The fifth proportional relation, the sixth proportional relation, the seventh proportional relation and the eighth proportional relation may be the same or different. The third preset length and the fourth preset length may be set to be the same or different.
In an example, obtaining the template of the current image block according to the motion information of the candidate image block may further include, but is not limited to: when the current image block corresponds to a plurality of pieces of motion information, a template corresponding to the motion information is obtained according to each piece of motion information, and the obtaining mode of each template refers to the above embodiment. Then, a weight parameter corresponding to each piece of motion information is obtained, and a template of the current image block is obtained according to the weight parameter corresponding to each piece of motion information and the template corresponding to the motion information. For example, the template of the current image block is obtained based on a weighted average method based on the weight parameter corresponding to each piece of motion information and the template corresponding to the piece of motion information.
For example, the current image block corresponds to motion information a and motion information B, the template a corresponding to the motion information a is obtained by using the above embodiment, and the template B corresponding to the motion information B is obtained by using the above embodiment.
Then, the weight parameter 1 of the motion information a and the weight parameter 2 of the motion information B may be obtained, so that the template of the current image block may be (template a × weight parameter 1+ template B × weight parameter 2)/2.
The template of the current image block is described in detail below with reference to several specific cases.
The first condition is as follows: referring to fig. 2B, the candidate image blocks may include all inter-mode neighboring image blocks on the upper side of the current image block and all inter-mode neighboring image blocks on the left side of the current image block.
For the current block a1, if there are neighboring blocks of the inter mode, such as block A3 and block a4, on the left side, the block A3 and block a4 of the inter mode may be determined as candidate blocks for the current block a 1. Similarly, if there are neighboring tiles of the inter mode, such as tile a2, on the upper side, the tile a2 of the inter mode may be determined as a candidate tile for the current tile a 1.
If there is no available image block on the left side, or if the available image blocks are all in intra mode although there is an available image block on the left side, it may indicate that there is no candidate image block on the left side of the current image block a 1. Similarly, if there is no available image block on the upper side, or if the available image blocks are all in intra mode although there is an available image block on the upper side, it may indicate that there is no candidate image block on the upper side of the current image block a 1. If neither the left side nor the top side has a candidate image block, it may indicate that the current image block a1 has no candidate image block.
In addition, if the current image block a1 has no candidate image block, the technical solution of the present embodiment is not adopted, but a conventional manner is adopted, which is not described again. If there are candidate image blocks in the current image block a1, such as a left candidate image block and/or an upper candidate image block, the technical solution of the present embodiment is adopted.
In an example, after determining that the candidate image block is the image block a2, the image block A3, and the image block a4, the template of the current image block a1 may be obtained according to the motion information of the image block a2, the motion information of the image block A3, and the motion information of the image block a 4. For example, for the tile a2, a reference frame image corresponding to the tile a2 may be determined according to the reference frame index, the tile B2 corresponding to the tile a2 is selected from the reference frame image, and the tile B2 is moved according to the motion vector of the tile a2 to obtain a reference tile B2 ' corresponding to the tile a2, and similarly, a reference tile B3 ' corresponding to the tile A3 and a reference tile B4 ' corresponding to the tile a4 may be obtained, as shown in fig. 2C. The template for the current tile A1 may then be obtained from reference tile B2 ', reference tile B3 ', and reference tile B4 '.
In an example, assuming that the lateral length of the upper template of the current image block a1 is W, the longitudinal length is S, the value of W may be configured empirically, the value of S may be configured empirically, and the values of W and S are not limited. For example, W may be the lateral length of the current image block A1, the lateral length of the candidate image block A2, 2 times the lateral length of the current image block A1, or the like, S may be the longitudinal length of the candidate image block A2, 1/3 the longitudinal length of the candidate image block A2, or the like. On the basis, refer to fig. 2D, which is a schematic diagram of a template corresponding to the reference image block B2'. In fig. 2D, W is taken as the lateral length of candidate image block a2 as an example, i.e. W is the lateral length of reference image block B2'; s is taken as 1/3, the longitudinal length of candidate image block a2, i.e., S is 1/3, the longitudinal length of reference image block B2'.
Assuming that the transverse length of the left template of the current image block a1 is R, the longitudinal length is H, the value of R may be configured according to experience, the value of H may be configured according to experience, and the values of R and H are not limited. For example, H may be the longitudinal length of the current image block A1, the longitudinal length of the candidate image block A3, R may be the lateral length of the candidate image block A3, 1/3 which is the lateral length of the candidate image block A3, or the like. On this basis, referring to fig. 2D, a template diagram corresponding to the reference image block B3' is shown, where H is taken as the longitudinal length of the candidate image block A3, and R is taken as the 1/3 of the transverse length of the candidate image block A3.
Similarly, the template page corresponding to the reference image block B4' can be seen in fig. 2D, and is not described herein again.
In one example, assuming that there are M candidate image blocks with different modes on the top side of the current image block, for the ith candidate image block, its lateral length is assumed to be wiThen, the prediction mode of the candidate image block is determined.
In the case of the intra mode, the sub-template is not generated any more, or is filled in by a default value (for example, a default pixel value, which may be a luminance value configured in advance according to experience) as the ith sub-template of the upper template.
If the image is in the inter-frame mode, motion information (such as a motion vector and a reference frame index) of the ith candidate image block is acquired, and a horizontal length w is generated based on the motion vector and the reference frame indexiThe template with the longitudinal length S is used as the ith sub-template of the upper template. Specifically, if the motion vector is MV and the reference frame index is idx, the idx-th reference in the current frame is foundFinding the transverse length w of the image with the relative position offset MViAnd the rectangular block with the longitudinal length of S is used as the ith sub-template of the upper template.
Assuming that there are N candidate image blocks with different modes on the left side of the current image block, for the ith candidate image block, assuming that the longitudinal length is hiAnd if the transverse length is R, judging the prediction mode of the candidate image block.
In the intra mode, no sub-template is generated, or the left side template is filled with default values (e.g., default pixel values, which may be empirically pre-configured luminance values) as the ith sub-template.
If the image is in the inter-frame mode, motion information (such as a motion vector, a reference frame index and the like) of the ith candidate image block is acquired, and a horizontal length R and a vertical length h are generated based on the motion vector and the reference frame indexiAs the ith sub-template of the left template. Specifically, if the motion vector is MV and the reference frame index is idx, find the horizontal length R and the vertical length h with the relative position offset of MV in the idx reference image of the current frameiAs the ith sub-template of the left template.
Further, the upper side template can be formed by splicing all the sub-templates on the upper side, the left side template can be formed by splicing all the sub-templates on the left side, and the upper side template and the left side template are spliced into the template of the current image block.
Case two: referring to fig. 2E, the candidate image blocks may include a first inter-mode adjacent image block on the upper side of the current image block and a first inter-mode adjacent image block on the left side of the current image block.
For the current tile A1, if the first tile A3 on the left is inter mode, then tile A3 may be determined to be a candidate tile for the current tile A1. If the first tile A2 on the upper side is in inter mode, then tile A2 may be determined to be a candidate tile for the current tile A1.
Wherein if no image block is available on the left side, or if the first image block on the left side is in intra mode, then there is no candidate image block on the left side of the current image block a 1. If there is no available image block on the upper side, or the first image block on the upper side is in intra mode, there is no candidate image block on the upper side of the current image block a 1. If neither the left nor the top side has a candidate image block, the current image block a1 has no candidate image block.
Further, if the current image block a1 has no candidate image block, the technical solution of the present embodiment is not adopted, but a conventional method is adopted, which is not described again. If there are candidate image blocks in the current image block a1, such as a left candidate image block and/or an upper candidate image block, the technical solution of the present embodiment is adopted.
After determining that the candidate image blocks are the image block a2 and the image block A3, the template of the current image block a1 may be obtained according to the motion information of the image block a2 and the motion information of the image block A3. For example, the reference frame image corresponding to the image block a2 may be determined according to the reference frame index, the image block B2 corresponding to the image block a2 is selected from the reference frame image, the image block B2 is moved according to the adjacent motion vector of the image block a2 to obtain the reference image block B2 'corresponding to the image block a2, and similarly, the reference image block B3' corresponding to the image block A3 may be obtained, and the template may be obtained according to the reference image block B2 'and the reference image block B3'.
In an example, assuming that the lateral length of the upper template of the current image block a1 is W, the longitudinal length is S, the value of W may be configured empirically, the value of S may be configured empirically, and the values of W and S are not limited. For example, W may be the lateral length of the current image block A1, the lateral length of the candidate image block A2, S may be the longitudinal length of the candidate image block A2, 1/3 which is the longitudinal length of the candidate image block A2, or the like. Referring to fig. 2F, it is a schematic diagram of a template corresponding to the reference image block B2'.
Assuming that the transverse length of the left template of the current image block a1 is R, the longitudinal length is H, the value of R may be configured according to experience, the value of H may be configured according to experience, and the values of R and H are not limited. For example, H may be the longitudinal length of the current image block A1, the longitudinal length of the candidate image block A3, or the like, and R may be the lateral length of the candidate image block A3, 1/3 which is the lateral length of the candidate image block A3, or the like. On the basis, refer to fig. 2F, which is a schematic diagram of a template corresponding to the reference image block B3'.
In one example, assuming that there are M candidate image blocks with different modes on the upper side of the current image block, the prediction mode of the candidate image block is determined for the first candidate image block on the upper side, assuming that the lateral length is w. In the intra mode, no template is generated, or the template is filled in with default values (e.g., default pixel values, which may be empirically pre-configured luminance values) as the upper template. If the image block is in the inter-frame mode, motion information (such as a motion vector, a reference frame index and the like) of the candidate image block is acquired, and a template with a horizontal length w and a vertical length S is generated as an upper template based on the motion vector and the reference frame index.
And (2) assuming that N candidate image blocks with different modes exist on the left side of the current image block, and for the first candidate image block on the left side, assuming that the longitudinal length is h and the transverse length is R, judging the prediction mode of the candidate image block. If the mode is the intra-frame mode, no template is generated, or the template is filled according to a default value to be used as a left template. If the image block is in the inter-frame mode, motion information (such as a motion vector and a reference frame index) of the candidate image block is acquired, and a template with the transverse length of R and the longitudinal length of h is generated as a left template based on the motion vector and the reference frame index.
Case three: referring to fig. 2G, the candidate image blocks may include a first inter-mode adjacent image block on the upper side of the current image block and a first inter-mode adjacent image block on the left side of the current image block.
Compared with fig. 2F in the second case, in the third case, the horizontal length W of the upper template of the current image block a1 is taken as the horizontal length of the current image block a1, and the vertical length H of the left template of the current image block a1 is taken as the vertical length of the current image block a1, which are similar to those in the second case and are not repeated.
Case four: referring to fig. 2H, the candidate image blocks may include an inter-mode adjacent image block on the upper side of the current image block, a sub-adjacent image block on the upper side of the current image block (i.e., when the adjacent image block is in the intra-frame mode, the image block corresponding to the adjacent image block is selected to be the sub-adjacent image block to the current image block), an inter-mode adjacent image block on the left side of the current image block, and a sub-adjacent image block on the left side of the current image block.
For example, for the current block a1, there are neighboring blocks in the inter mode on the left side, such as block A3 and block a4, the blocks A3 and a4 in the inter mode may be determined as candidate blocks for the current block a 1. Similarly, if there is an adjacent image block in the inter mode, such as the image block a2, on the upper side, the image block a2 in the inter mode may be determined as a candidate image block for the current image block a 1.
Further, an adjacent image block in intra mode, such as image block a7, exists on the left, and image block a7 has image block A8 in inter mode on the left, i.e., image block A8 is the next adjacent image block to the left of the current image block a1, and thus, image block A8 in inter mode may be determined as a candidate image block for the current image block a 1.
Similarly, an adjacent image block in intra mode, such as image block a5, exists on the upper side, and image block a5 has image block a6 in inter mode on the upper side, i.e., image block a6 is the next adjacent image block on the upper side of the current image block a1, and thus, image block a6 in inter mode may be determined as a candidate image block for the current image block a 1.
After determining that the candidate image block is the image block a2, the image block A3, the image block a4, the image block A6, and the image block A8, a template of the current image block a1 is obtained according to the motion information of the image block a2, the motion information of the image block A3, the motion information of the image block a4, the motion information of the image block A6, and the motion information of the image block A8, where the specific obtaining manner is as in the case one, only obtaining the template according to the motion information of the image block A6 and the motion information of the image block A8 is needed, and is not described herein, and the template is finally shown in fig. 2I.
Case five: referring to fig. 2J, if the first adjacent image block on the upper side of the current image block is in the intra mode and the image block on the upper side of the first adjacent image block is in the inter mode, the candidate image blocks may include a second adjacent image block in the inter mode on the upper side of the current image block. In addition, if the first adjacent image block on the left side of the current image block is in the intra mode and the image block on the left side of the first adjacent image block is in the inter mode, the candidate image blocks may include a second adjacent image block in the inter mode on the left side of the current image block.
For the current block a1, if the first block a2 in the upper side is in intra mode and there is an inter-mode block a4 in the upper side of block a2, i.e., block a4 is the next adjacent block in the upper side of the current block a1, then block a4 in inter mode may be determined as a candidate block for the current block a 1.
Further, if the first tile A3 on the left is in intra mode and there is a tile A5 in inter mode on the left of tile A3, i.e., tile A5 is the next adjacent tile to the left of the current tile A1, then tile A5 in inter mode may be determined to be a candidate tile for the current tile A1.
After determining that the candidate image blocks are the image block a4 and the image block a5, a template of the current image block a1 may be obtained according to the motion information of the image block a4 and the motion information of the image block a5, where the specific obtaining manner is referred to as case two and case three, which is not described herein again, and the template is finally referred to as shown in fig. 2K or fig. 2L.
Case six: referring to fig. 2H, the candidate image blocks may include neighboring image blocks of an inter mode on an upper side of the current image block, neighboring image blocks of an intra mode on an upper side of the current image block, neighboring image blocks of an inter mode on a left side of the current image block, and neighboring image blocks of an intra mode on a left side of the current image block.
For example, for the current block a1, there are neighboring blocks in the inter mode on the left side, such as block A3 and block a4, the blocks A3 and a4 in the inter mode may be determined as candidate blocks for the current block a 1. Similarly, if there is an adjacent image block in the inter mode, such as the image block a2, on the upper side, the image block a2 in the inter mode may be determined as a candidate image block for the current image block a 1.
The neighboring tile of the left side in intra mode, such as tile a7, may determine tile a7 in intra mode as a candidate tile for current tile a 1. The neighboring image block having the intra mode at the upper side, such as the image block a5, may determine the image block a5 of the intra mode as a candidate image block of the current image block a 1.
After determining that the candidate image block is the image block a2, the image block A3, the image block a4, the image block a5, and the image block a7, a template of the current image block a1 is obtained according to the motion information of the image block a2, the motion information of the image block A3, the motion information of the image block a4, the motion information of the image block a5, and the motion information of the image block a7, where the specific obtaining manner is as in the case one, only obtaining the template according to the motion information of the image block a5 and the motion information of the image block a7 is needed, and is not described herein, and the template is finally shown in fig. 2M.
It should be noted that, when the template is obtained according to the motion information of the image block a5, since the image block a5 is in intra mode and has no motion information, the motion information of an adjacent image block (i.e., the image block a6) of the image block a5 may be determined as the motion information of the image block a5, and after the motion information of the image block a5 is obtained, the template may be obtained according to the motion information of the image block a5, as shown in the case one.
Similarly, when the template is acquired based on the motion information of the image block a7, since the image block a7 is in intra mode and has no motion information, it is possible to determine the motion information of an adjacent image block to the image block a7 (i.e., the image block A8) as the motion information of the image block a5 and acquire the template using the motion information of the image block a 5.
Case seven: referring to fig. 2J, if the first adjacent image block on the upper side of the current image block is in the intra mode and the image block on the upper side of the first adjacent image block is in the inter mode, the candidate image blocks may include the adjacent image block in the first intra mode on the upper side of the current image block. In addition, if the first neighboring image block on the left side of the current image block is in intra mode and the image block on the left side of the first neighboring image block is in inter mode, the candidate image blocks may include the neighboring image block on the left side of the current image block in the first intra mode.
For the current block a1, if the first block a2 on the top side is in intra mode, block a4 in inter mode exists on the top side of block a2, and block a2 in intra mode is determined to be a candidate block for the current block a 1. If the first image block A3 on the left is in intra mode, there is an image block A5 in inter mode on the left side of image block A3, and the image block A3 in intra mode is determined to be a candidate image block for the current image block A1.
After determining that the candidate image blocks are the image block a2 and the image block A3, a template of the current image block a1 may be obtained according to the motion information of the image block a2 and the motion information of the image block A3, where the specific obtaining manner is referred to as case two and case three, which is not described herein again, and the template is finally referred to as shown in fig. 2N or fig. 2O.
It is to be noted that, when acquiring the template from the motion information of the image block a2, since the image block a2 is in intra mode and has no motion information, it is possible to determine the motion information of an adjacent image block of the image block a2 (i.e., the image block a4) as the motion information of the image block a2 and acquire the template using the motion information of the image block a 2. When the template is acquired from the motion information of the image block A3, since the image block A3 is in intra mode and has no motion information, it is possible to determine the motion information of an adjacent image block of the image block A3, that is, the image block a5, as the motion information of the image block A3 and acquire the template using the motion information of the image block A3.
Example three:
in the inter-frame coding technique, a relative displacement between a current image block of a current frame video image and a reference image block of a reference frame video image may be represented using a motion vector. For example, video image A is a current frame video image, tile A1 is a current tile, video image B is a reference frame video image for video image A, and tile B1 is a reference tile for tile A1. Due to the strong temporal correlation between video image a and video image B, when image block a1 of video image a needs to be transmitted, a motion search may be performed in video image B to find image block B1 that best matches image block a1, and determine the relative displacement between image block a1 and image block B1, which is also the motion vector of image block a 1.
For example, the motion vector is (-6, 4), which indicates that image block B1 is shifted by 6 pixels to the left in the horizontal direction and by 4 pixels to the top in the vertical direction, compared to image block a 1.
When the encoding end sends the encoded bitstream to the decoding end, the encoded bitstream carries the motion vector (-6, 4) of the image block a1, instead of the image block a 1. The motion vector (-6, 4) for image block a1 may be obtained by the decoder after receiving the encoded bitstream, and the position of image block B1 is determined in video picture B based on the position of image block a1 and the motion vector (-6, 4), i.e.: at the position of the image block a1, 6 pixel points are moved to the left, 4 pixel points are moved upwards, the position of the image block B1 is obtained, the image block B1 is read from the position of the image block B1, and the image block a1 is reconstructed by using the image block B1. Since the similarity between the image block B1 and the image block a1 is high, an image with high similarity can be reconstructed by reconstructing the image block a1 using the image block B1. Since the number of bits occupied by the motion vector is smaller than the number of bits occupied by image block a1, a significant amount of bits is saved by carrying the motion vector in the encoded bitstream instead of carrying image block a 1.
Further, if the video image a includes a large number of image blocks, the motion vector of each image block also occupies relatively many bits, and therefore, in order to further save the number of bits, in the embodiment of the present application, the motion vector of the image block a1 may also be determined by using the motion vectors of adjacent image blocks. For example, in video image A, the image blocks adjacent to image block A1 may include: the image block a2 and the image block A3 may include the motion vector a21 of the image block a2 and the motion vector a31 of the image block A3 in the motion vector list.
When the encoding end sends the encoded bitstream to the decoding end, the encoded bitstream carries the index value of the original motion vector a21 (i.e., the index value in the motion vector list), instead of the motion vector (-6, 4) of image block a1, and even instead of image block a 1. The decoding end receives the encoded bitstream, obtains the index value of the original motion vector a21, and obtains the original motion vector a21 from the motion vector list according to the index value. Since the number of bits occupied by the index value is smaller than the number of bits occupied by the motion vector, bits can be further saved.
In the present embodiment, instead of directly using the original motion vector a21 as the final motion vector of the image block a1, a target motion vector different from the original motion vector a21 is obtained from the original motion vector a21, and the target motion vector is closest to the motion vector of the image block a1, and therefore, the target motion vector can be used as the final motion vector of the image block a 1. Obviously, compared with the mode of directly taking the original motion vector a21 as the final motion vector of the image block a1, the mode of taking the target motion vector as the final motion vector of the image block a1 can solve the problems of low prediction quality, prediction error and the like.
In this embodiment, the original motion information is an original motion vector of a current image block, and the target motion information is a target motion vector of the current image block, which is shown in fig. 3 and is a flow diagram of the encoding method.
Step 301, the encoding end obtains the motion information of the candidate image block of the current image block.
Step 302, the encoding end obtains a template of the current image block according to the motion information of the candidate image block.
Step 303, the encoding end obtains a target motion vector based on the template according to the original motion vector corresponding to the current image block and the obtained template, where the target motion vector may be different from the original motion vector.
Before step 303, the original motion vector of the current image block may be obtained, for example, if the current image block is the image block a1, and the motion vector list at the encoding end sequentially includes the motion vector a21, the motion vector a31, the motion vector a41, and the motion vector a51, a motion vector may be selected from the motion vector list, and the selected motion vector is the original motion vector of the image block a 1. Of course, the above manner is only an example, and is not limited to this, for example, the default motion vector may be directly determined as the original motion vector.
Wherein, the selecting, by the encoding end, a motion vector from the motion vector list may include: the encoding end selects a first motion vector from the motion vector list; or, selecting the last motion vector from the motion vector list; or, randomly selecting a first motion vector from the motion vector list; alternatively, a hash algorithm is used to select the first motion vector from the motion vector list. Of course, the above-described modes are only examples, and the modes are not limited thereto as long as a motion vector can be selected from the motion vector list.
The motion vector list is used for recording motion vectors of image blocks adjacent to the current image block. For example, after obtaining the motion vector a21 of the image block a2, the motion vector a21 may be recorded in the motion vector list, after obtaining the motion vector a31 of the image block A3, the motion vector a31 may be recorded in the motion vector list, and so on, and finally, the motion vector list of the image block a1 may be obtained.
And step 304, the encoding end determines a final motion vector of the current image block according to the original motion vector and the target motion vector, and encodes the current image block according to the final motion vector to obtain an encoded bit stream.
Specifically, the encoding end may obtain the encoding performance of the original motion vector and the encoding performance of the target motion vector. When the coding performance of the target motion vector is better than that of the original motion vector, the coding end determines that the final motion vector of the current image block is the target motion vector, and sends a coding bit stream carrying the first indication information to the decoding end. And when the encoding performance of the original motion vector is better than that of the target motion vector, the encoding end determines that the final motion vector of the current image block is the original motion vector, and sends the encoding bit stream carrying the second indication information to the decoding end.
In practical application, the first indication information or the second indication information may also be notified in an implicit manner, that is, the first indication information or the second indication information is not carried in the coded bitstream. Specifically, the encoding end and the decoding end may also negotiate a motion vector decision policy or define a policy in a standard, and store the policy in the encoding end and the decoding end, for example, the motion vector decision policy may be default first policy information, or default second policy information, or default third policy information.
When the motion vector decision policy is the default first policy information and the coding performance of the target motion vector is better than that of the original motion vector, the coded bit stream may not carry the first indication information and the second indication information. When the motion vector decision policy is the default second policy information and the encoding performance of the original motion vector is better than that of the target motion vector, the encoded bitstream may not carry the first indication information and the second indication information. For another example, when the motion vector decision policy is the third policy information and the adjacent image block adopts the first policy information, the coding performance of the target motion vector is better than that of the original motion vector, and the coded bitstream may not carry the first indication information and the second indication information; when the adjacent image blocks adopt the second policy information, and the encoding performance of the original motion vector is better than that of the target motion vector, the encoded bitstream may not carry the first indication information and the second indication information.
In one example, the encoding end may further obtain an index value of the original motion vector in the motion vector list; and sending the coded bit stream carrying the index value to a decoding end. For example, if the original motion vector is motion vector a21 and motion vector a21 is the first motion vector in the motion vector list, the index value is 1.
The process of the encoding end obtaining the encoding performance of the original motion vector and the encoding performance of the target motion vector may refer to the subsequent embodiments, which are not described in detail in this embodiment.
Step 305, the encoding end stores the original motion vector or the final motion vector corresponding to the current image block as the motion information of the current image block.
According to the technical scheme, the target motion vector can be obtained according to the original motion vector, the final motion vector of the current image block is determined according to the target motion vector, and the final motion vector of the current image block is not determined according to the original motion vector, so that the precision of the motion vector is improved, and the coding performance is improved. And when the target motion vector is obtained according to the original motion vector, the template of the current image block can be obtained according to the motion information of the candidate image block, and the target motion vector is obtained according to the template of the current image block. For example, before the reconstruction stage of decoding, the template of the current image block may be obtained, and the target motion vector may be obtained according to the template of the current image block.
Example four:
on the basis of the third embodiment, a target motion vector based on a template is obtained according to an original motion vector corresponding to a current image block and an obtained template, and an implementation flow thereof may be shown in fig. 4A and may include:
in step 401, the encoding end determines the original motion vector as the central motion vector.
In step 402, the encoding end determines an edge motion vector corresponding to the center motion vector.
Wherein the edge motion vector may be different from the center motion vector.
The determining, by the encoding end, the edge motion vector corresponding to the center motion vector may include: and shifting the central motion vector (x, y) to different directions by S, thereby obtaining edge motion vectors (x-S, y), edge motion vectors (x + S, y), edge motion vectors (x, y + S) and edge motion vectors (x, y-S) in different directions. For example, in the horizontal direction, the center motion vector (x, y) may be shifted to the left by S, resulting in an edge motion vector (x-S, y); in the horizontal direction, the central motion vector (x, y) may be shifted to the right by S, resulting in an edge motion vector (x + S, y); in the vertical direction, the central motion vector (x, y) may be shifted upwards by S, resulting in an edge motion vector (x, y + S); in the vertical direction, the center motion vector (x, y) may be shifted downward by S, resulting in an edge motion vector (x, y-S).
The initial value of S may be empirically configured, and may be 2, 4, 8, 16, etc.
Assuming that the center motion vector is (3, 3) and S is 4, the edge motion vectors are edge motion vector (7, 3), edge motion vector (3, 7), edge motion vector (-1, 3), edge motion vector (3, -1).
And 403, the encoding end obtains the encoding performance of the central motion vector according to the template of the current image block and obtains the encoding performance of the edge motion vector according to the template of the current image block.
In the first case, the encoding end obtains the encoding performance of the central motion vector according to the template of the current image block, which may include but is not limited to: and determining the coding performance of the central motion vector according to the parameter information of the template of the current image block and the parameter information of the first target reference block, wherein the first target reference block can be an image block obtained after the reference image block corresponding to the template is subjected to offset based on the central motion vector. Specifically, the encoding end may determine the prediction performance of the central motion vector according to the parameter information of the template and the parameter information of the first target reference block, and determine the encoding performance of the central motion vector according to the prediction performance of the central motion vector; for example, the encoding performance of the center motion vector may be determined according to the prediction performance and the actual number of bits required for encoding.
Wherein, the parameter information may be a brightness value; alternatively, there may be luminance values and chrominance values.
Assuming that the parameter information is a luminance value, in order to determine the encoding performance of the central motion vector, a luminance value of a template of the current image block and a luminance value of the first target reference block may be obtained first. For example, after obtaining the template of the current image block, the luminance value of each pixel point of the template may be obtained, and a reference image block of the template may be obtained, assuming that the central motion vector is (3, 3), the reference image block may be moved by using the central motion vector (3, 3), and an image block X corresponding to the reference image block is obtained (for example, the reference image block is moved rightward by 3 pixel points, the processed image block is recorded as the image block X, and the image block X is the first target reference block, and the luminance value of each pixel point of the image block X may be obtained.
Based on the brightness value of each pixel point of the template and the brightness value of each pixel point of the image block X, the prediction performance of the central motion vector can be determined by adopting the following formula:
Figure BDA0001722594470000291
SAD is the sum of the available absolute differences for representing the prediction performance of the central motion vector. TMiThe brightness value, TMP, of the ith pixel point of the templateiAnd the brightness value of the ith pixel point of the image block X is represented, and M represents the total number of the pixel points.
Assuming that the parameter information is a luminance value and a chrominance value, the following formula is usedDetermining the brightness value prediction performance SAD of the central motion vector, and determining the chroma value prediction performance of the central motion vector by adopting the following formula:
Figure BDA0001722594470000293
the average of the luminance value prediction performance SAD and the chrominance value prediction performance CSAD is the prediction performance of the central motion vector. Where CSAD is the sum of available absolute differences for representing chroma value prediction performance, CTM, of the central motion vectoriExpressing the chroma value, CTMP, of the ith pixel point of the templateiExpressing the colorimetric value, M, of the ith pixel point of the image block XcIndicating the total number of pixels.
Further, after the prediction performance of the central motion vector is obtained, the coding performance of the central motion vector may be determined according to the prediction performance and the actual number of bits required for coding. For example, RDO (Rate distortion optimized) may be used to determine the coding performance of the center motion vector, and RDO generally determines the coding performance of the center motion vector by using the following formula: j ═ D + λ R. Wherein J represents the coding performance, D represents the prediction performance, λ is a lagrange multiplier, which is a value configured according to experience, and R is the actual number of bits required for image block coding, i.e., the sum of bits of the coded bitstream carrying information.
In case two, the encoding end obtains the encoding performance of the edge motion vector according to the template of the current image block, which may include but is not limited to: and determining the encoding performance of the edge motion vector according to the parameter information of the template of the current image block and the parameter information of the second target reference block, wherein the second target reference block can be an image block obtained after the reference image block corresponding to the template is subjected to offset based on the edge motion vector. Specifically, the encoding end may determine the prediction performance of the edge motion vector according to the parameter information of the template and the parameter information of the second target reference block, and determine the encoding performance of the central motion vector according to the prediction performance of the edge motion vector; for example, the encoding performance of the edge motion vector may be determined according to the prediction performance and the actual number of bits required for encoding.
Wherein, the parameter information may be a brightness value; alternatively, there may be luminance values and chrominance values.
Case two is similar to case one, with the difference that: in case one, the reference image block of the template is moved by using the edge motion vector to obtain a second target reference block, and the coding performance of the edge motion vector is obtained by using the second target reference block, while in case two, the reference image block of the template is moved by using the center motion vector to obtain a first target reference block, and the coding performance of the center motion vector is obtained by using the first target reference block.
In step 404, the encoding end determines a target motion vector from the center motion vector and the edge motion vector according to the encoding performance of the center motion vector and the encoding performance of the edge motion vector.
Specifically, the encoding end may select a motion vector with the optimal encoding performance from the center motion vector and the edge motion vector; when the motion vector with the optimal coding performance is not the original motion vector, the motion vector with the optimal coding performance can be determined as a target motion vector; when the motion vector with the optimal coding performance is the original motion vector, the coding end can select a motion vector with the suboptimal coding performance from the central motion vector and the edge motion vector, and determine the motion vector with the suboptimal coding performance as the target motion vector.
For example, if the motion vector with the best encoding performance is the edge motion vector (7, 3), the encoding end may determine the edge motion vector (7, 3) as the target motion vector. If the motion vector with the best coding performance is the central motion vector (3, 3), that is, the original motion vector, the coding end may also determine the motion vector with the suboptimal coding performance (such as the edge motion vector (7, 3), etc.) as the target motion vector.
Example five:
on the basis of the third embodiment, a target motion vector based on a template is obtained according to an original motion vector corresponding to a current image block and an obtained template, and an implementation flow thereof may be shown in fig. 4B and may include:
in step 411, the encoding end determines the original motion vector as the central motion vector.
In step 412, the encoding end determines an edge motion vector corresponding to the center motion vector.
Wherein the edge motion vector may be different from the center motion vector.
Step 413, the encoding end obtains the encoding performance of the central motion vector according to the template of the current image block, and obtains the encoding performance of the edge motion vector according to the template of the current image block.
For steps 411 to 413, refer to steps 401 to 403, which are not described herein again.
In step 414, the encoding end determines whether the iteration end condition of the target motion vector is satisfied.
If so, step 416 may be performed; if not, step 415 may be performed.
Wherein, the iteration end condition may include but is not limited to: the number of iterations reaches a threshold number, or the execution time reaches a time threshold, or the parameter S has been modified to a preset value, such as 1.
Of course, the above is only a few examples of the iteration end condition, and the iteration end condition is not limited.
In step 415, the encoding end selects a motion vector with the best encoding performance from the central motion vector and the edge motion vector, determines the motion vector with the best encoding performance as the central motion vector, and returns to step 412.
For example, if the motion vector with the best coding performance is the edge motion vector (7, 3), the edge motion vector (7, 3) may be determined as the center motion vector, and step 412 may be performed again, and so on.
When step 412 is performed for the first time, the value of the parameter S may be an initial value, such as 16. When step 412 is executed again, the value of the parameter S is first adjusted, for example, to be the last parameter S minus 2, or to be half of the last parameter S, and the like, which is not limited to this, as long as it is smaller than the last parameter S, and then the adjustment to be half of the last parameter S is taken as an example. Therefore, when step 412 is performed for the second time, the value of the parameter S is 8; when step 412 is executed for the third time, the value of the parameter S is 4; and so on.
After the value of the parameter S is adjusted, it is first determined whether the adjusted parameter S is less than or equal to a preset value, such as 1. If not, step 412 may be executed based on the adjusted parameter S, and details of this process are not repeated. If so, the value of the parameter S may be set to 1, and step 412 is executed based on the parameter S (i.e., the value of 1), and when the step 414 is executed, the iteration end condition is satisfied.
In step 416, the encoding end determines the target motion vector from the center motion vector and the edge motion vector according to the encoding performance of the center motion vector and the encoding performance of the edge motion vector.
The processing of step 416 may refer to step 404, and is not repeated here.
Example six:
in the third embodiment, the encoding performance of the original motion vector and the encoding performance of the target motion vector may be obtained, and the encoding end obtains the encoding performance of the original motion vector, which may include but is not limited to: and determining the encoding performance of the original motion vector according to the parameter information of the template of the current image block and the parameter information of a third target reference block, wherein the third target reference block is an image block obtained after the reference image block corresponding to the template is subjected to offset based on the original motion vector. Specifically, the prediction performance of the original motion vector may be determined according to the parameter information of the template and the parameter information of the third target reference block, and the encoding performance of the original motion vector may be determined according to the prediction performance; for example, the encoding performance of the original motion vector is determined according to the prediction performance and the actual number of bits required for encoding. Wherein, the parameter information may be a brightness value; or luminance values and chrominance values.
The encoding performance of the encoding end for obtaining the target motion vector may include, but is not limited to: and determining the coding performance of the target motion vector according to the parameter information of the template of the current image block and the parameter information of a fourth target reference block, wherein the fourth target reference block is an image block obtained after the reference image block corresponding to the template is subjected to offset based on the target motion vector. Specifically, the prediction performance of the target motion vector may be determined according to the parameter information of the template and the parameter information of the fourth target reference block, and the encoding performance of the target motion vector may be determined according to the prediction performance; for example, the encoding performance of the target motion vector is determined based on the prediction performance and the actual number of bits required for encoding. Wherein, the parameter information may be a brightness value; or luminance values and chrominance values.
The above process is similar to the third embodiment, except that: when the third target reference block or the fourth target reference block is obtained, the original motion vector or the target motion vector is used to move the reference image block of the template, instead of the reference image block of the central motion vector moving template, and the details are not repeated here.
Example seven:
in this embodiment, the original motion information is an original motion vector and an original reference frame of the current image block, and the target motion information is a target motion vector and a target reference frame of the current image block. Based on this, the encoding end may obtain an original motion vector and an original reference frame corresponding to the current image block, and obtain a target motion vector (which may be different from the original motion vector) and a target reference frame based on the template according to the original motion vector, the original reference frame, and the obtained template. Then, the bitstream can be encoded according to the target motion vector and the target reference frame to obtain an encoded bitstream, and the encoded bitstream is sent to a decoding end.
In an example, the encoding end may first obtain an original motion vector of the current image block, and assuming that the current image block is the image block a1, the motion vector list at the encoding end sequentially includes the motion vector a21, the motion vector a31, the motion vector a41, and the motion vector a51, and then one motion vector is selected from the motion vector list, and the selected motion vector is the original motion vector of the image block a 1. Of course, the above manner is only an example, and is not limited to this, for example, the default motion vector may be directly determined as the original motion vector.
In an example, in a process of acquiring an original reference frame of a current image block, for the current image block, there may be one or more reference frames (video frames with strong temporal correlation), one of the reference frames may be used as the original reference frame, and the remaining reference frames are candidate reference frames.
In an example, the process of obtaining, by the encoding end, the target motion vector and the target reference frame based on the template according to the original motion vector, the original reference frame, and the obtained template may refer to the subsequent embodiments, and details are not described herein. For example, if the motion vector a21 is determined as an original motion vector, the reference frame 1 is determined as an original reference frame, and the reference frames 2 and 3 are determined as candidate reference frames, then the original motion vector a21, the reference frame 1, the reference frame 2, and the reference frame 3 are used to obtain a target motion vector and a target reference frame, the target motion vector is used as a final motion vector of the current image block, the target reference frame may be one of the reference frame 1, the reference frame 2, and the reference frame 3, and the target reference frame is used as a final reference frame of the current image block.
In an example, the process of encoding, by the encoding end, the bitstream according to the target motion vector and the target reference frame to obtain an encoded bitstream, and sending the encoded bitstream to the decoding end may include, but is not limited to: after obtaining the target motion vector and the target reference frame, the encoding end may encode the current image block by using the target motion vector and the target reference frame, the encoding method is not limited, and after the encoding is completed, the encoding end may obtain an encoded bit stream and send the encoded bit stream to the decoding end.
Wherein, the encoding end can send the encoded bit stream to the decoding end according to the original motion vector and the target motion vector. Specifically, the encoding performance of the original motion vector and the encoding performance of the target motion vector can be obtained. And when the coding performance of the target motion vector is better than that of the original motion vector, sending the coding bit stream carrying the first indication information to a decoding end. And when the encoding performance of the original motion vector is better than that of the target motion vector, transmitting the encoding bit stream carrying the second indication information to a decoding end.
For the process of acquiring the encoding performance of the original motion vector and the encoding performance of the target motion vector, reference may be made to the sixth embodiment described above, and details of this process are not described in this embodiment again.
In practical application, the first indication information or the second indication information may also be notified in an implicit manner, that is, the first indication information or the second indication information is not carried in the coded bit stream, specifically, the coding end and the decoding end may also negotiate a decision policy or define a policy in a standard, and store the policy in the coding end and the decoding end, for example, the decision policy may be the default first policy information; or defaulting the second policy information; or, the third policy information is defaulted, and the third policy information is the same policy information as that adopted by the adjacent image block of the current image block. Then, it may be determined, based on the decision policy, in which case the first indication information or the second indication information may not be carried in the coded bitstream, and the detailed processing is referred to as embodiment three and is not described herein again.
In one example, the transmitting, by the encoding end, the encoded bitstream to the decoding end according to the original motion vector and the target motion vector may further include: acquiring an index value of an original motion vector in a motion vector list; and sending the coded bit stream carrying the index value to a decoding end. For example, if the original motion vector is motion vector a21 and motion vector a21 is the first motion vector of the motion vector list, the index value may be 1.
According to the technical scheme, the target motion vector and the target reference frame can be obtained according to the original motion vector and the original reference frame, the final motion vector of the current image block is determined according to the target motion vector, the final reference frame of the current image block is determined according to the target reference frame instead of directly determining the final motion vector of the current image block according to the original motion vector, and the final reference frame of the current image block is determined by using the original reference frame, so that the precision of the motion vector is improved, and the coding performance is improved. Moreover, the template of the current image block can be obtained according to the motion information of the candidate image block, the template of the current image block can be quickly obtained, the coding efficiency can be improved, and the coding delay can be reduced.
Example eight:
on the basis of the seventh embodiment, the encoding end obtains a target motion vector and a target reference frame based on the template according to the original motion vector, the original reference frame and the template, and the implementation flow can be shown in fig. 4C.
In step 421, the encoding end obtains a candidate motion vector corresponding to the original reference frame according to the original motion vector based on the template of the current image block, where the candidate motion vector may be different from the original motion vector.
In an example, the encoding end obtains a candidate motion vector corresponding to the original reference frame according to the original motion vector based on the template of the current image block, which may include but is not limited to: the encoding end determines the original motion vector as a central motion vector and determines an edge motion vector corresponding to the central motion vector, wherein the edge motion vector is different from the central motion vector; the encoding end obtains the encoding performance of the central motion vector according to the template of the current image block and obtains the encoding performance of the edge motion vector according to the template of the current image block; then, the encoding end can determine a candidate motion vector corresponding to the original reference frame from the center motion vector and the edge motion vector according to the encoding performance of the center motion vector and the encoding performance of the edge motion vector.
For the process of obtaining the candidate motion vector of the original reference frame by the encoding end according to the original motion vector, reference may be made to embodiment four or embodiment five, but only the target motion vector in embodiment four or embodiment five is replaced by the candidate motion vector of the original reference frame, and details are not repeated here.
In step 422, the encoding end obtains an initial motion vector corresponding to each candidate reference frame (e.g., each candidate reference frame in one or more candidate reference frames) according to the original motion vector.
In an example, the obtaining, by the encoding end, an initial motion vector corresponding to each candidate reference frame according to the original motion vector may include: the first candidate reference frame is any one of candidate reference frames, and for the first candidate reference frame, an initial motion vector of the first candidate reference frame may be obtained according to a distance between a frame where the current image block is located and the original reference frame (for example, the distance may be a number of frames between the frame where the current image block is located and the original reference frame), a distance between the frame where the current image block is located and the first candidate reference frame, and the original motion vector.
For example, assuming that the original motion vector is motion vector 1, the original reference frame is reference frame 1, the candidate reference frames are reference frame 2 and reference frame 3, the distance between the frame where the current image block is located (hereinafter referred to as the current frame) and reference frame 1 is d1, the distance between the current frame and reference frame 2 is d2, and the distance between the current frame and reference frame 3 is d3, then: the initial motion vector corresponding to the reference frame 2 is the motion vector 1 x (d2/d1) and is subsequently denoted as the motion vector 2, and the initial motion vector corresponding to the reference frame 3 is the motion vector 1 x (d3/d1) and is subsequently denoted as the motion vector 3.
In step 423, the encoding end obtains a candidate motion vector corresponding to the candidate reference frame according to the initial motion vector.
In an example, the encoding end obtains a candidate motion vector corresponding to the candidate reference frame according to the initial motion vector, which may include but is not limited to: the first candidate reference frame may be any one of candidate reference frames, and for the first candidate reference frame, the encoding end may determine an initial motion vector of the first candidate reference frame as a central motion vector, and determine an edge motion vector corresponding to the central motion vector, where the edge motion vector is different from the central motion vector; the encoding end can obtain the encoding performance of the central motion vector according to the template of the current image block and obtain the encoding performance of the edge motion vector according to the template of the current image block; then, the encoding end may determine a candidate motion vector corresponding to the first candidate reference frame from the center motion vector and the edge motion vector according to the encoding performance of the center motion vector and the encoding performance of the edge motion vector.
For each candidate reference frame, the candidate motion vector of the candidate reference frame may be obtained according to the initial motion vector of the candidate reference frame, that is, each candidate reference frame corresponds to one candidate motion vector.
For a process of obtaining the candidate motion vector of the candidate reference frame by the encoding end according to the initial motion vector of the candidate reference frame, reference may be made to embodiment four or embodiment five, where only the target motion vector in embodiment four or embodiment five is replaced by the candidate motion vector of the candidate reference frame, and the original motion vector in embodiment four or embodiment five is replaced by the initial motion vector of the candidate reference frame, which is not described herein again.
Step 424, the encoding end selects a candidate motion vector with the best encoding performance from the candidate motion vectors corresponding to the original reference frame and the candidate motion vectors corresponding to the candidate reference frames.
For example, after obtaining the candidate motion vector corresponding to the original reference frame and the candidate motion vectors corresponding to the candidate reference frames, the encoding end may obtain the encoding performance of each candidate motion vector, and the specific obtaining manner refers to the fourth embodiment, and it is sufficient to replace the center motion vector of the fourth embodiment with the candidate motion vector, which is not described herein again. After the encoding end obtains the encoding performance of each candidate motion vector, the encoding end can select the candidate motion vector with the optimal encoding performance, and the selection process is not repeated.
Step 425, the encoding end determines the candidate motion vector with the best encoding performance as the target motion vector, and determines the reference frame corresponding to the candidate motion vector with the best encoding performance as the target reference frame.
For example, when the candidate motion vector with the best coding performance corresponds to the original reference frame, the coding end may determine the original reference frame as the target reference frame, and when the candidate motion vector with the best coding performance corresponds to the candidate reference frame, the coding end may determine the candidate reference frame as the target reference frame.
In this embodiment, a target reference frame needs to be selected from the original reference frame and all candidate reference frames, and the target reference frame is the final reference frame of the current image block. A target motion vector (i.e., a candidate motion vector with the best coding performance) needs to be selected from candidate motion vectors corresponding to an original reference frame and candidate motion vectors corresponding to all candidate reference frames, and the target motion vector is a final motion vector of a current image block.
Example nine:
referring to fig. 5, a flow chart of a motion vector determination method is schematically shown, where the method may include:
step 501, a decoding end obtains motion information of a candidate image block of a current image block.
The candidate image blocks of the current image block may include, but are not limited to: a spatial domain candidate image block of the current image block; or, a time domain candidate image block of the current image block; the candidate image block is not limited.
The motion information of the candidate image block may include, but is not limited to: original motion information corresponding to the candidate image block, such as an original motion vector, or an original motion vector and an original reference frame. And final motion information corresponding to the candidate image block, such as a final motion vector, or the final motion vector and a final reference frame.
In one example, the final motion information of the current image block is only used for decoding of the current image block (decoding processes of prediction value generation, reconstruction, and the like of the current image block), and is not used for prediction of the neighboring image block, that is, the motion information obtained from the candidate image block is the original motion information of the candidate block, but not the final motion information of the candidate image block. After the decoding of the current image block is finished, the final motion information is not stored, but the original motion information is stored, that is, the motion information of the current image block is restored to the original motion information.
In one example, the decoding end may store motion information corresponding to the candidate image block, such as storing original motion information corresponding to the candidate image block as the motion information of the candidate block or storing final motion information corresponding to the candidate image block as the motion information of the candidate block, so that, in step 501, the original motion information corresponding to the candidate image block may be directly queried locally from the decoding end.
In another example, the decoding end may obtain original motion information (e.g., an original motion vector and an original reference frame) corresponding to the candidate image block, for example, select a motion vector from a motion vector list of the candidate image block, where the selected motion vector is an original motion vector. For another example, the motion information of an image block adjacent to the candidate image block may be determined as the original motion information corresponding to the candidate image block.
The above manner is merely an example of obtaining the original motion information of the candidate image block, and is not limited to this.
Step 502, the decoding end obtains the template of the current image block according to the motion information of the candidate image block.
The method for acquiring the template of the current image block by the decoding end according to the motion information of the candidate image block is the same as that of the encoding end, and reference may be specifically made to the related contents of embodiment two, which is not described herein again.
Step 503, the decoding end obtains target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template. Wherein the original motion information comprises an original motion vector and the target motion information comprises a target motion vector. Or, the original motion information includes an original motion vector and an original reference frame, and the target motion information includes a target motion vector and a target reference frame.
When the original motion information includes an original motion vector and the target motion information includes a target motion vector, the decoding end obtains the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template, and the method includes the following steps: determining the original motion vector as a central motion vector; determining an edge motion vector corresponding to the center motion vector, the edge motion vector being different from the center motion vector; obtaining the coding performance of the central motion vector and the coding performance of the edge motion vector according to the template; and determining the target motion vector from the central motion vector and the edge motion vector according to the coding performance of the central motion vector and the coding performance of the edge motion vector.
When the original motion information comprises an original motion vector and an original reference frame, and the target motion information comprises a target motion vector and a target reference frame, the decoding end obtains the target motion information based on the template according to the original motion information corresponding to the current image block and the acquired template, and the method comprises the following steps: based on the template of the current image block, obtaining a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to the candidate reference frames according to the initial motion vectors; obtaining a candidate motion vector corresponding to the candidate reference frame according to the initial motion vector; selecting a candidate motion vector with optimal coding performance from the candidate motion vectors corresponding to the original reference frame and the candidate motion vectors corresponding to the candidate reference frames; and determining the candidate motion vector with the optimal coding performance as the target motion vector, and determining a reference frame corresponding to the candidate motion vector with the optimal coding performance as the target reference frame.
In an example, before the decoding end obtains the motion information of the candidate image block of the current image block, the decoding end may further obtain a coded bit stream, where the coded bit stream may be sent by the encoding end, or obtained after the decoding end codes the bit stream, and this is not limited, and the example is that the encoding end sends the coded bit stream.
The decoding end may receive the encoded bitstream from the encoding end, when the encoded bitstream carries the first indication information, the first indication information is used to indicate that the final motion information of the current image block is determined based on the template, the motion information of the candidate image block of the current image block may be obtained according to the first indication information, and the template of the current image block is obtained according to the motion information of the candidate image block, that is, the above step 501 and step 503 are performed.
The decoding end can receive the coded bit stream from the encoding end, and when the coded bit stream carries second indication information which is used for indicating that final motion information of the current image block is determined based on original motion information corresponding to the current image block, the decoding end obtains the original motion information corresponding to the current image block according to the second indication information, and determines the final motion information of the current image block according to the original motion information.
In practical application, the encoding end may also use an implicit method to notify, that is, the encoded bitstream does not carry the first indication information or the second indication information. Based on the above, the decoding end may obtain motion information of a candidate image block of the current image block according to locally preset first policy information, and obtain a template of the current image block according to the motion information of the candidate image block, where the first policy information is used to instruct that final motion information of the current image block is determined based on the template; or, the original motion information corresponding to the current image block may be acquired according to second policy information preset locally; determining final motion information of the current image block according to the original motion information, wherein the second strategy information is used for indicating that the final motion information of the current image block is determined based on the original motion information corresponding to the current image block; or, third policy information may be obtained, where the third policy information is the final motion information of the current image block determined by using the same policy information as that of an adjacent image block of the current image block; and then, determining final motion information of the current image block according to the third strategy information.
Specifically, the encoding end and the decoding end may also negotiate a motion vector decision policy or define a policy in a standard, and store the policy in the encoding end and the decoding end, for example, the motion vector decision policy may be default first policy information; or default second policy information; or default third policy information.
When the motion vector decision strategy is the default first strategy information, obtaining the motion information of the candidate image block of the current image block according to the locally preset first strategy information, and obtaining the template of the current image block according to the motion information of the candidate image block; when the motion vector decision strategy is the default second strategy information, acquiring the original motion information corresponding to the current image block according to the second strategy information preset locally; determining final motion information of the current image block according to the original motion information; when the motion vector decision strategy is third strategy information, if the strategy information of the adjacent image block is first strategy information, obtaining the motion information of a candidate image block of the current image block, and obtaining a template of the current image block according to the motion information of the candidate image block; if the strategy information of the adjacent image block is second strategy information, acquiring original motion information corresponding to the current image block; and determining final motion information of the current image block according to the original motion information.
In an example, before obtaining target motion information based on a template according to original motion information corresponding to a current image block and an obtained template, a decoding end may further receive a coded bit stream from an encoding end, where the coded bit stream carries an index value of an original motion vector in a motion vector list; the decoding end can select the motion vector corresponding to the index value from the motion vector list; and determining the selected motion vector as the original motion vector corresponding to the current image block. If the index value is 1, the first motion vector of the motion vector list is obtained, and the motion vector is the original motion vector of the current image block. The motion vector list is used for recording motion vectors of image blocks adjacent to the current image block, and the motion vector list maintained by the decoding end is the same as the motion vector list maintained by the encoding end. Of course, the above-mentioned manner is only an example, and for example, the motion vector of the candidate image block of the current image block may be determined as the original motion vector corresponding to the current image block.
The processing procedure of obtaining the target motion information based on the template by the decoding end according to the original motion information corresponding to the current image block and the obtained template may refer to the subsequent embodiments, and is not described herein again.
In step 504, the decoding end determines final motion information of the current image block according to the target motion information, for example, the target motion information may be determined as the final motion information of the current image block.
For example, the target motion information includes a target motion vector, and the final motion information includes a final motion vector, in one example, the original motion vector of the current image block and the target original motion vector may be compared in coding performance, and a motion vector with better performance is used as the final motion vector.
And 505, the decoding end decodes the current image block according to the final motion information, and stores the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block.
In the processing process of other image blocks, if the current image block is selected as a candidate image block of another image block, in step 501, the motion information of the candidate image block, that is, the original motion information or the final motion information corresponding to the candidate image block, may be obtained as the template according to the original motion information or the final motion information corresponding to the candidate image block.
In one example, storing the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block may include: when the original motion information of the current image block is obtained according to the motion information of the spatial neighboring block (or the spatial neighboring block), storing the original motion information corresponding to the current image block as the motion information of the current image block. And when the original motion information of the current image block is not obtained according to the motion information of the spatial adjacent block (or the spatial adjacent block), storing the final motion information corresponding to the current image block as the motion information of the current image block. For example, when the original motion information corresponding to the current image block is obtained according to the motion information of the time domain adjacent block, storing the final motion information corresponding to the current image block as the motion information of the current image block; in a default case, the final motion information corresponding to the current image block may also be stored as the motion information of the current image block.
Further, in some embodiments, the original motion information at least includes an original motion vector, and when the original motion vector of the current image block is obtained according to the motion vectors of the spatial neighboring blocks, the original motion vector corresponding to the current image block is stored as the motion vector of the current image block. And when the original motion information of the current image block is not obtained according to the motion vector of the spatial domain adjacent block, storing the final motion vector corresponding to the current image block as the motion vector of the current image block. For example, when the original motion vector corresponding to the current image block is obtained according to the motion vectors of the time-domain neighboring blocks, the final motion vector corresponding to the current image block is stored as the motion vector of the current image block; by default, the final motion vector corresponding to the current image block may also be stored as the motion vector of the current image block.
In one example, the original motion vector of the current image block is stored as the motion vector of the current image block after decoding, or in another example, the final motion vector of the current image block is stored as the motion vector of the current image block after decoding.
In one example, the motion information of the candidate image block in step 501 may be an original motion vector of the candidate image block, and in step 505, the decoding end stores the original motion vector corresponding to the current image block as the motion vector of the current image block.
In one example, the motion information of the candidate image block in step 501 may be a final motion vector of the candidate image block, and in step 505, the decoding end stores an original motion vector corresponding to the current image block as the motion vector of the current image block.
In one example, the motion information of the candidate image block in step 501 may be an original motion vector of the candidate image block, and in step 505, the decoding end stores a final motion vector corresponding to the current image block as the motion vector of the current image block.
In one example, the motion information of the candidate image block in step 501 may be a final motion vector of the candidate image block, and in step 505, the decoding end stores the final motion vector corresponding to the current image block as the motion vector of the current image block.
According to the technical scheme, the target motion vector can be obtained according to the original motion vector, the final motion vector of the current image block is determined according to the target motion vector, and the final motion vector of the current image block is not directly determined according to the original motion vector, so that the precision of the motion vector is improved, and the decoding performance is improved. Moreover, when the target motion vector is obtained according to the original motion vector, the template of the current image block can be obtained according to the motion information of the candidate image block, and the target motion vector is obtained according to the original motion vector based on the template of the current image block; the method can quickly obtain the template of the current image block, and then obtain the target motion vector according to the template, thereby improving the decoding efficiency and reducing the decoding time delay. For example, before the reconstruction stage of decoding, a template of the current image block may be obtained, and the target motion vector may be obtained according to the template.
Furthermore, the decoding end can simultaneously perform parallel decoding on a plurality of image blocks, so that the decoding speed is further increased, the decoding efficiency is increased, the decoding time delay is reduced, and the decoding performance is improved.
In one example, the final motion information of the current image block is only used for decoding of the current image block (decoding processes of prediction value generation, reconstruction, and the like of the current image block), and is not used for prediction of the neighboring image block, that is, the candidate motion information obtained by the neighboring image block is the original motion information, but not the final motion information. After the decoding of the current image block is finished, the final motion information is not stored, but the original motion information is stored, that is, the motion information of the current image block is restored to the original motion information.
Example ten:
in this embodiment, unlike the manner of generating the template by using the reconstruction information and the prediction information, the template of the current image block may be obtained according to the motion information (such as a motion vector and a reference frame index) of the candidate image block of the current image block. Specifically, the decoding end may determine a reference frame image corresponding to the candidate image block according to the reference frame index; and acquiring a reference image block corresponding to the candidate image block from the reference frame image according to the motion vector, and acquiring a template of the current image block according to the reference image block.
The candidate image blocks may include M first candidate image blocks and N second candidate image blocks, where M is a natural number greater than or equal to 1 and N is a natural number greater than or equal to 0, or M is a natural number greater than or equal to 0 and N is a natural number greater than or equal to 1. The first candidate image block is a candidate image block on the upper side of the current image block, and the second candidate image block is a candidate image block on the left side of the current image block. The first candidate image block comprises an adjacent image block and/or a secondary adjacent image block on the upper side of the current image block; the prediction mode of the adjacent image block is an inter mode or an intra mode; the prediction mode of the secondary adjacent image block is an inter mode. The second candidate image block comprises an adjacent image block on the left side of the current image block and/or a secondary adjacent image block; the prediction mode of the adjacent image block is an inter mode or an intra mode; the prediction mode of the secondary adjacent image block is an inter mode.
Obtaining the template of the current image block according to the motion information of the candidate image block may include, but is not limited to: determining a first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks; and determining a second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks. Then, determining the first template as the template of the current image block; or, determining the second template as the template of the current image block; or determining the first template and the second template as the template of the current image block after splicing.
In an example, when M is greater than 1, the first template may include M sub-templates or P sub-templates, and the M sub-templates or the P sub-templates are spliced to form the first template, where P is the number of first candidate image blocks in the inter mode; when M is equal to 1, the first template may comprise a first sub-template determined according to the motion vector prediction mode and the motion information of the first candidate image block on the upper side of the current image block. When N is greater than 1, the second template may include N sub-templates or R sub-templates, and the N sub-templates or R sub-templates are spliced to form the second template, where R is the number of second candidate image blocks in the inter mode; when N is equal to 1, the second template may comprise a second sub-template determined according to the motion vector prediction mode and the motion information of the first candidate image block on the left side of the current image block.
In an example, obtaining the template of the current image block according to the motion information of the candidate image block may further include, but is not limited to: and when the current image block corresponds to a plurality of pieces of motion information, obtaining a template corresponding to the motion information according to each piece of motion information. And acquiring a weight parameter corresponding to each piece of motion information, and acquiring a template of the current image block according to the weight parameter corresponding to each piece of motion information and the template corresponding to the motion information.
Example eleven:
when the original motion information includes an original motion vector and the target motion information includes a target motion vector, the decoding end obtains the target motion vector based on the template according to the original motion vector corresponding to the current image block and the obtained template, and an implementation process thereof may be shown in fig. 6A and may include:
step 601, the decoding end determines the original motion vector as the central motion vector.
In step 602, the decoding end determines an edge motion vector corresponding to the center motion vector.
Wherein the edge motion vector may be different from the center motion vector.
Wherein determining the edge motion vector corresponding to the center motion vector may include: and shifting the central motion vector (x, y) to different directions by S to obtain edge motion vectors (x-S, y), edge motion vectors (x + S, y), edge motion vectors (x, y + S) and edge motion vectors (x, y-S) in different directions.
Step 603, the decoding end obtains the coding performance of the central motion vector according to the template of the current image block, and obtains the coding performance of the edge motion vector according to the template of the current image block.
The decoding end obtains the coding performance of the central motion vector according to the template of the current image block, which may include but is not limited to: the decoding end may determine the encoding performance of the central motion vector according to the parameter information of the template of the current image block and the parameter information of the first target reference block, where the first target reference block is an image block obtained after the reference image block corresponding to the template is shifted based on the central motion vector.
The decoding end obtains the encoding performance of the edge motion vector according to the template of the current image block, which may include but is not limited to: the decoding end may determine the encoding performance of the edge motion vector according to the parameter information of the template of the current image block and the parameter information of the second target reference block, where the second target reference block is an image block obtained after the reference image block corresponding to the template is shifted based on the edge motion vector.
Step 604, the decoding end determines the target motion vector from the center motion vector and the edge motion vector according to the coding performance of the center motion vector and the coding performance of the edge motion vector.
Specifically, the decoding end may select a motion vector with the best coding performance from the center motion vector and the edge motion vector; when the motion vector with the optimal coding performance is not the original motion vector, the motion vector with the optimal coding performance can be determined as a target motion vector; when the motion vector with the optimal coding performance is the original motion vector, the decoding end can select a motion vector with the suboptimal coding performance from the central motion vector and the edge motion vector, and determine the motion vector with the suboptimal coding performance as the target motion vector.
Example twelve:
when the original motion information includes an original motion vector and the target motion information includes a target motion vector, the decoding end obtains the target motion vector based on the template according to the original motion vector corresponding to the current image block and the obtained template, and an implementation process thereof may be shown in fig. 6B and may include:
in step 611, the decoding end determines the original motion vector as the central motion vector.
In step 612, the decoding end determines an edge motion vector corresponding to the center motion vector.
Wherein the edge motion vector may be different from the center motion vector.
Step 613, the decoding end obtains the coding performance of the central motion vector according to the template of the current image block, and obtains the coding performance of the edge motion vector according to the template of the current image block.
In step 614, the decoding end determines whether the iteration end condition of the target motion vector is satisfied.
If so, step 616 may be performed; if not, step 615 may be performed.
Step 615, the decoding end selects the motion vector with the best coding performance from the central motion vector and the edge motion vector, determines the motion vector with the best coding performance as the central motion vector, and returns to step 612.
In step 616, the decoding end determines the target motion vector from the center motion vector and the edge motion vector according to the coding performance of the center motion vector and the coding performance of the edge motion vector.
The detailed processing flow of steps 611 to 616 can be seen in the fourth embodiment, except that the execution main body is changed from the encoding end to the decoding end, and other processing flows are the same, and are not repeated herein.
Example thirteen:
when the original motion information includes an original motion vector and an original reference frame, and the target motion information includes a target motion vector and a target reference frame, the decoding end may obtain the original motion vector and the original reference frame corresponding to the current image block, and based on the template of the current image block, the decoding end may obtain a target motion vector (the target motion vector may be different from the original motion vector) and a target reference frame based on the template according to the original motion vector and the original reference frame corresponding to the current image block.
The decoding end obtains a target motion vector and a target reference frame based on the template according to the original motion vector corresponding to the current image block and the original reference frame based on the template of the current image block, which may include but is not limited to: based on the template of the current image block, obtaining a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to the candidate reference frames according to the initial motion vectors; obtaining a candidate motion vector corresponding to the candidate reference frame according to the initial motion vector; then, a candidate motion vector with the optimal coding performance can be selected from the candidate motion vectors corresponding to the original reference frame and the candidate motion vectors corresponding to the candidate reference frames; and determining the candidate motion vector with the optimal coding performance as a target motion vector, and determining a reference frame corresponding to the candidate motion vector with the optimal coding performance as a target reference frame.
The obtaining of the initial motion vector corresponding to each candidate reference frame according to the initial motion vector may include, but is not limited to: the first candidate reference frame is any one of the candidate reference frames, and aiming at the first candidate reference frame, the initial motion vector of the first candidate reference frame is obtained according to the distance between the frame of the current image block and the original reference frame, the distance between the frame of the current image block and the first candidate reference frame and the original motion vector.
In an example, based on the template of the current image block, obtaining the candidate motion vector corresponding to the original reference frame according to the original motion vector may include, but is not limited to: determining the original motion vector as a central motion vector, and determining an edge motion vector corresponding to the central motion vector, wherein the edge motion vector is different from the central motion vector; then, obtaining the coding performance of the central motion vector according to the template of the current image block, and obtaining the coding performance of the edge motion vector according to the template of the current image block; then, a candidate motion vector corresponding to the original reference frame may be determined from the center motion vector and the edge motion vector according to the encoding performance of the center motion vector and the encoding performance of the edge motion vector.
In one example, obtaining the candidate motion vector corresponding to the candidate reference frame according to the initial motion vector may include, but is not limited to: a first candidate reference frame is any one of candidate reference frames, and aiming at the first candidate reference frame, an initial motion vector of the first candidate reference frame is determined as a central motion vector, and an edge motion vector corresponding to the central motion vector is determined, wherein the edge motion vector is different from the central motion vector; obtaining the coding performance of a central motion vector and the coding performance of an edge motion vector according to a template of a current image block; and determining a candidate motion vector corresponding to the first candidate reference frame from the central motion vector and the edge motion vector according to the coding performance of the central motion vector and the coding performance of the edge motion vector.
Example fourteen:
based on the same application concept as the method, an embodiment of the present application further provides a decoding apparatus applied to a decoding end, as shown in fig. 7, which is a structural diagram of the apparatus, and the apparatus includes:
an obtaining module 71, configured to obtain motion information of a candidate image block of a current image block; acquiring a template of the current image block according to the motion information of the candidate image block; obtaining target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template;
a determining module 72, configured to determine final motion information of the current image block according to the target motion information; decoding the current image block according to the final motion information; and storing the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block.
In an example, when the determining module 72 stores the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block, the determining module is specifically configured to: and when the original motion information of the current image block is obtained according to the motion information of the spatial domain adjacent block, storing the original motion information corresponding to the current image block as the motion information of the current image block.
In an example, when the determining module 72 stores the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block, the determining module is specifically configured to: and when the original motion information of the current image block is not obtained according to the motion information of the spatial domain adjacent block, storing the final motion information corresponding to the current image block as the motion information of the current image block.
The obtaining module 71 is further configured to: receiving a coded bit stream from a coding end, wherein the coded bit stream carries first indication information, and the first indication information is used for indicating that final motion information of the current image block is determined based on a template; and acquiring the motion information of a candidate image block of the current image block according to the first indication information, and acquiring the template of the current image block according to the motion information of the candidate image block.
The obtaining module 71 is further configured to: receiving a coded bit stream from a coding end, wherein the coded bit stream carries second indication information, and the second indication information is used for indicating that final motion information of a current image block is determined based on original motion information corresponding to the current image block;
acquiring original motion information corresponding to the current image block according to the second indication information;
and determining final motion information of the current image block according to the original motion information.
The obtaining module 71 is further configured to: acquiring motion information of candidate image blocks of a current image block according to locally preset first strategy information, and acquiring a template of the current image block according to the motion information of the candidate image blocks; the first strategy information is used for indicating that final motion information of the current image block is determined based on a template; or acquiring original motion information corresponding to the current image block according to second strategy information preset locally; determining final motion information of the current image block according to the original motion information; the second strategy information is used for indicating that final motion information of the current image block is determined based on original motion information corresponding to the current image block; or acquiring third strategy information, wherein the third strategy information is the final motion information of the current image block determined by adopting the same strategy information as the adjacent image block of the current image block; and determining the final motion information of the current image block according to the third strategy information.
The original motion information comprises an original motion vector; the obtaining module 71 is further configured to: receiving a coded bit stream from a coding end, wherein the coded bit stream carries an index value of an original motion vector in a motion vector list; selecting a motion vector corresponding to the index value from a motion vector list; determining the selected motion vector as an original motion vector corresponding to the current image block; or, determining the motion vector of the candidate image block of the current image block as the original motion vector corresponding to the current image block.
The candidate image blocks comprise M first candidate image blocks and N second candidate image blocks, wherein M is a natural number which is greater than or equal to 1, N is a natural number which is greater than or equal to 0, or M is a natural number which is greater than or equal to 0, and N is a natural number which is greater than or equal to 1; the first candidate image block is a candidate image block on the upper side of the current image block, and the second candidate image block is a candidate image block on the left side of the current image block; the obtaining module 71 is specifically configured to, when obtaining the template of the current image block according to the motion information of the candidate image block: determining a first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks; determining a second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks; determining the first template as the template of the current image block; or, determining the second template as the template of the current image block; or, determining the first template and the second template as the template of the current image block after splicing.
In one example, the first candidate image block includes an adjacent image block and/or a sub-adjacent image block on an upper side of the current image block; the prediction mode of the adjacent image block is an inter-frame mode or an intra-frame mode; the prediction mode of the secondary adjacent image block is an inter-frame mode; the second candidate image block comprises an adjacent image block on the left side of the current image block and/or a secondary adjacent image block; the prediction mode of the adjacent image block is an inter-frame mode or an intra-frame mode; and the prediction mode of the secondary adjacent image block is an inter-frame mode.
In an example, when M is greater than 1, the first template includes M sub-templates or P sub-templates, and is formed by splicing the M sub-templates or the P sub-templates, where P is the number of first candidate image blocks in the inter mode; and when M is equal to 1, the first template comprises a first sub-template which is determined according to the motion vector prediction mode and the motion information of the first candidate image block on the upper side of the current image block.
The motion information includes a motion vector and a reference frame index of the first candidate image block, and the obtaining module 71 is specifically configured to, when determining the first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks: for an ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter mode, determining a reference frame image corresponding to the ith candidate image block according to the reference frame index; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block; and acquiring image blocks with the sizes of a first transverse length and a first longitudinal length as the ith sub-template included in the first template according to the determined reference image block.
The obtaining module 71, according to the motion vector prediction modes and the motion information of the M first candidate image blocks, is specifically configured to: for an ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an intra-frame mode, filling the ith candidate image block according to a default value, and acquiring image blocks with the sizes of a first transverse length and a first longitudinal length as an ith sub-template included by the first template; or determining a reference frame image corresponding to the ith candidate image block according to the reference frame index corresponding to the ith candidate image block; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to a motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a first transverse length and a first longitudinal length as an ith sub-template included by the first template; and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of an image block adjacent to the ith candidate image block.
The first transverse length and the transverse length of the first candidate image block meet a first proportional relation, or the first transverse length and the transverse length of the current image block meet a second proportional relation, or the first transverse length and the transverse length of the current image block are equal to a first preset length;
the first longitudinal length and the longitudinal length of the first candidate image block meet a third proportional relation, or the first longitudinal length and the longitudinal length of the current image block meet a fourth proportional relation, or the first longitudinal length and the longitudinal length of the first candidate image block are equal to a second preset length.
In an example, when N is greater than 1, the second template includes N sub-templates or R sub-templates, and is formed by splicing the N sub-templates or the R sub-templates, where R is the number of second candidate image blocks in the inter mode; and when N is equal to 1, the second template comprises a second sub-template which is determined according to the motion vector prediction mode and the motion information of the first candidate image block on the left side of the current image block.
The motion information includes a motion vector and a reference frame index of the second candidate image block, and the obtaining module 71 is specifically configured to, when determining the second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks: for an ith candidate image block in the N second candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter mode, determining a reference frame image corresponding to the ith candidate image block according to the reference frame index; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block; and acquiring image blocks with the sizes of a second transverse length and a second longitudinal length as the ith sub-template included by the second template according to the determined reference image block.
The obtaining module 71, according to the motion vector prediction modes and the motion information of the N second candidate image blocks, is specifically configured to: for an ith candidate image block in the N second candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an intra-frame mode, filling the ith candidate image block according to a default value, and acquiring image blocks with the sizes of a second transverse length and a second longitudinal length as an ith sub-template included by the second template; or determining a reference frame image corresponding to the ith candidate image block according to the reference frame index corresponding to the ith candidate image block; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to a motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a second transverse length and a second longitudinal length as an ith sub-template included by the first template; and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of an image block adjacent to the ith candidate image block.
The second transverse length and the transverse length of the second candidate image block meet a fifth proportional relation, or the second transverse length and the transverse length of the current image block meet a sixth proportional relation, or the second transverse length and the transverse length of the current image block are equal to a third preset length;
the second vertical length and the vertical length of the second candidate image block satisfy a seventh proportional relationship, or satisfy an eighth proportional relationship with the vertical length of the current image block, or are equal to a fourth preset length.
The obtaining module 71 is specifically configured to, when obtaining the template of the current image block according to the motion information of the candidate image block: when the current image block corresponds to a plurality of pieces of motion information, obtaining a template corresponding to the motion information according to each piece of motion information; and acquiring a weight parameter corresponding to each piece of motion information, and acquiring a template of the current image block according to the weight parameter corresponding to each piece of motion information and the template corresponding to the motion information.
The original motion information includes an original motion vector, the target motion information includes a target motion vector, and the obtaining module 71 is specifically configured to, when obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template: determining the original motion vector as a central motion vector; determining an edge motion vector corresponding to the center motion vector, the edge motion vector being different from the center motion vector; obtaining the coding performance of the central motion vector and the coding performance of the edge motion vector according to the template; and determining the target motion vector from the central motion vector and the edge motion vector according to the coding performance of the central motion vector and the coding performance of the edge motion vector.
The original motion information includes an original motion vector and an original reference frame, the target motion information includes a target motion vector and a target reference frame, and the obtaining module 71 is specifically configured to, when obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template: based on the template of the current image block, obtaining a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to the candidate reference frames according to the initial motion vectors; obtaining a candidate motion vector corresponding to the candidate reference frame according to the initial motion vector; selecting a candidate motion vector with optimal coding performance from the candidate motion vectors corresponding to the original reference frame and the candidate motion vectors corresponding to the candidate reference frames; and determining the candidate motion vector with the optimal coding performance as the target motion vector, and determining a reference frame corresponding to the candidate motion vector with the optimal coding performance as the target reference frame.
Based on the same application concept as the method, an embodiment of the present application further provides an encoding apparatus applied to an encoding end, which is shown in fig. 8 and is a structural diagram of the apparatus, where the apparatus includes:
an obtaining module 81, configured to obtain motion information of a candidate image block of a current image block; acquiring a template of the current image block according to the motion information of the candidate image block; obtaining target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template;
a processing module 82, configured to determine final motion information of the current image block according to the original motion information and the target motion information; coding the current image block according to the final motion information to obtain a coded bit stream; and storing the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block.
When the processing module 82 stores the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block, the processing module is specifically configured to: and when the original motion information of the current image block is obtained according to the motion information of the spatial domain adjacent block, storing the original motion information corresponding to the current image block as the motion information of the current image block.
When the processing module 82 stores the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block, the processing module is specifically configured to: and when the original motion information of the current image block is not obtained according to the motion information of the spatial domain adjacent block, storing the final motion information corresponding to the current image block as the motion information of the current image block.
The candidate image blocks comprise M first candidate image blocks and N second candidate image blocks, wherein M is a natural number which is greater than or equal to 1, N is a natural number which is greater than or equal to 0, or M is a natural number which is greater than or equal to 0, and N is a natural number which is greater than or equal to 1; the first candidate image block is a candidate image block on the upper side of the current image block, and the second candidate image block is a candidate image block on the left side of the current image block; the obtaining module 81 is specifically configured to, when obtaining the template of the current image block according to the motion information of the candidate image block: determining a first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks; determining a second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks; determining the first template as the template of the current image block; or, determining the second template as the template of the current image block; or, determining the first template and the second template as the template of the current image block after splicing.
In one example, the first candidate image block includes an adjacent image block and/or a sub-adjacent image block on an upper side of the current image block; the prediction mode of the adjacent image block is an inter-frame mode or an intra-frame mode; the prediction mode of the secondary adjacent image block is an inter-frame mode; the second candidate image block comprises an adjacent image block on the left side of the current image block and/or a secondary adjacent image block; the prediction mode of the adjacent image block is an inter-frame mode or an intra-frame mode; and the prediction mode of the secondary adjacent image block is an inter-frame mode.
In an example, when M is greater than 1, the first template includes M sub-templates or P sub-templates, and is formed by splicing the M sub-templates or the P sub-templates, where P is the number of first candidate image blocks in the inter mode; and when M is equal to 1, the first template comprises a first sub-template which is determined according to the motion vector prediction mode and the motion information of the first candidate image block on the upper side of the current image block.
The motion information includes a motion vector and a reference frame index of the first candidate image block, and the obtaining module 81 is specifically configured to, when determining the first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks: for an ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter mode, determining a reference frame image corresponding to the ith candidate image block according to the reference frame index; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block; and acquiring image blocks with the sizes of a first transverse length and a first longitudinal length as the ith sub-template included in the first template according to the determined reference image block.
The obtaining module 81 is specifically configured to, when determining the first template, according to the motion vector prediction modes and the motion information of the M first candidate image blocks: for an ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an intra-frame mode, filling the ith candidate image block according to a default value, and acquiring image blocks with the sizes of a first transverse length and a first longitudinal length as an ith sub-template included by the first template; or determining a reference frame image corresponding to the ith candidate image block according to the reference frame index corresponding to the ith candidate image block; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to a motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a first transverse length and a first longitudinal length as an ith sub-template included by the first template; and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of an image block adjacent to the ith candidate image block.
The first transverse length and the transverse length of the first candidate image block meet a first proportional relation, or the first transverse length and the transverse length of the current image block meet a second proportional relation, or the first transverse length and the transverse length of the current image block are equal to a first preset length; the first longitudinal length and the longitudinal length of the first candidate image block meet a third proportional relation, or the first longitudinal length and the longitudinal length of the current image block meet a fourth proportional relation, or the first longitudinal length and the longitudinal length of the first candidate image block are equal to a second preset length.
In an example, when N is greater than 1, the second template includes N sub-templates or R sub-templates, and is formed by splicing the N sub-templates or the R sub-templates, where R is the number of second candidate image blocks in the inter mode; and when N is equal to 1, the second template comprises a second sub-template which is determined according to the motion vector prediction mode and the motion information of the first candidate image block on the left side of the current image block.
The motion information includes a motion vector and a reference frame index of the second candidate image block, and the obtaining module 81 is specifically configured to, when determining the second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks: for an ith candidate image block in the N second candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter mode, determining a reference frame image corresponding to the ith candidate image block according to the reference frame index; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block; and acquiring image blocks with the sizes of a second transverse length and a second longitudinal length as the ith sub-template included by the second template according to the determined reference image block.
The obtaining module 81 is specifically configured to, when determining the second template, according to the motion vector prediction modes and the motion information of the N second candidate image blocks: for an ith candidate image block in the N second candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an intra-frame mode, filling the ith candidate image block according to a default value, and acquiring image blocks with the sizes of a second transverse length and a second longitudinal length as an ith sub-template included by the second template; or determining a reference frame image corresponding to the ith candidate image block according to the reference frame index corresponding to the ith candidate image block; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to a motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a second transverse length and a second longitudinal length as an ith sub-template included by the first template; and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of an image block adjacent to the ith candidate image block.
The second transverse length and the transverse length of the second candidate image block meet a fifth proportional relation, or the second transverse length and the transverse length of the current image block meet a sixth proportional relation, or the second transverse length and the transverse length of the current image block are equal to a third preset length;
the second vertical length and the vertical length of the second candidate image block satisfy a seventh proportional relationship, and the second vertical length and the vertical length of the current image block satisfy an eighth proportional relationship, or equal to a fourth preset length.
The obtaining module 81 is specifically configured to, when obtaining the template of the current image block according to the motion information of the candidate image block: when the current image block corresponds to a plurality of pieces of motion information, obtaining a template corresponding to the motion information according to each piece of motion information; and acquiring a weight parameter corresponding to each piece of motion information, and acquiring a template of the current image block according to the weight parameter corresponding to each piece of motion information and the template corresponding to the motion information.
The original motion information includes an original motion vector, the target motion information includes a target motion vector, and the obtaining module 81 is specifically configured to, when obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template: determining the original motion vector as a central motion vector; determining an edge motion vector corresponding to the center motion vector, the edge motion vector being different from the center motion vector; obtaining the coding performance of the central motion vector and the coding performance of the edge motion vector according to the template; and determining the target motion vector from the central motion vector and the edge motion vector according to the coding performance of the central motion vector and the coding performance of the edge motion vector.
The original motion information includes an original motion vector and an original reference frame, the target motion information includes a target motion vector and a target reference frame, and the obtaining module 81 is specifically configured to, when obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template: based on the template of the current image block, obtaining a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to the candidate reference frames according to the initial motion vectors; obtaining a candidate motion vector corresponding to the candidate reference frame according to the initial motion vector; selecting a candidate motion vector with optimal coding performance from the candidate motion vectors corresponding to the original reference frame and the candidate motion vectors corresponding to the candidate reference frames; and determining the candidate motion vector with the optimal coding performance as the target motion vector, and determining a reference frame corresponding to the candidate motion vector with the optimal coding performance as the target reference frame.
The original motion information includes an original motion vector, the destination motion information includes a destination motion vector, the processing module 82 includes the original motion vector, and when the destination motion information includes the destination motion vector, the processing module is specifically configured to: acquiring the coding performance of the original motion vector and the coding performance of the target motion vector; when the coding performance of the target motion vector is better than that of the original motion vector, determining the final motion vector of the current image block as the target motion vector;
wherein the coded bitstream carries first indication information indicating that final motion information of the current image block is determined based on a template.
The original motion information includes an original motion vector, the destination motion information includes a destination motion vector, and the processing module 82 is specifically configured to, when determining the final motion information of the current image block according to the original motion information and the destination motion information: acquiring the coding performance of the original motion vector and the coding performance of the target motion vector; when the encoding performance of the original motion vector is better than that of the target motion vector, determining the final motion vector of the current image block as the original motion vector;
the coded bit stream carries second indication information, where the second indication information is used to indicate that final motion information of the current image block is determined based on original motion information corresponding to the current image block.
The processing module 82 obtains the index value of the original motion vector in the motion vector list; the coded bitstream carries the index value.
The processing module 82, when obtaining the encoding performance of the original motion vector, is specifically configured to: determining the encoding performance of the original motion vector according to the parameter information of the template of the current image block and the parameter information of a first target reference block, wherein the first target reference block is an image block obtained after a reference image block corresponding to the template is subjected to offset based on the original motion vector;
when the processing module 82 obtains the coding performance of the target motion vector, the processing module is specifically configured to: and determining the coding performance of the target motion vector according to the parameter information of the template of the current image block and the parameter information of a second target reference block, wherein the second target reference block is an image block obtained after the reference image block corresponding to the template is subjected to offset based on the target motion vector.
In terms of hardware, the hardware architecture diagram of the decoding-side device provided in the embodiment of the present application may specifically refer to fig. 9. The method comprises the following steps: a processor 91 and a machine-readable storage medium 92, wherein: the machine-readable storage medium 92 stores machine-executable instructions executable by the processor 91; the processor 91 is configured to execute machine-executable instructions to implement the decoding method disclosed in the above example.
Based on the same application concept as the method, embodiments of the present application further provide a machine-readable storage medium, where several computer instructions are stored, and when the computer instructions are executed by a processor, the decoding method disclosed in the above example of the present application can be implemented.
In terms of hardware, the hardware architecture diagram of the encoding end device provided in the embodiment of the present application may specifically refer to fig. 10. The method comprises the following steps: a processor 93 and a machine-readable storage medium 94, the machine-readable storage medium 94 storing machine-executable instructions executable by the processor 93; the processor 93 is configured to execute machine-executable instructions to implement the encoding methods disclosed in the above examples.
Based on the same application concept as the method, embodiments of the present application further provide a machine-readable storage medium, where several computer instructions are stored, and when the computer instructions are executed by a processor, the encoding method disclosed in the above example of the present application can be implemented.
The machine-readable storage medium may be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, and the like. For example, the machine-readable storage medium may be: a RAM (random Access Memory), a volatile Memory, a non-volatile Memory, a flash Memory, a storage drive (e.g., a hard drive), a solid state drive, any type of storage disk (e.g., an optical disk, a dvd, etc.), or similar storage medium, or a combination thereof.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Furthermore, these computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (43)

1. A decoding method, applied to a decoding end, comprising:
acquiring motion information of candidate image blocks of a current image block;
acquiring a template of the current image block according to the motion information of the candidate image block;
obtaining target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template;
determining final motion information of the current image block according to the target motion information;
and decoding the current image block according to the final motion information.
2. The method of claim 1, wherein after the decoding the current image block according to the final motion information, the method further comprises:
and storing the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block.
3. The method according to claim 2, wherein the storing the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block comprises:
when the original motion information of the current image block is obtained according to the motion information of the spatial domain adjacent block, storing the original motion information corresponding to the current image block as the motion information of the current image block; alternatively, the first and second electrodes may be,
and when the original motion information of the current image block is not obtained according to the motion information of the spatial domain adjacent block, storing the final motion information corresponding to the current image block as the motion information of the current image block.
4. The method of claim 1,
before the obtaining the motion information of the candidate image block of the current image block, the method further includes:
receiving a coded bit stream from a coding end, wherein the coded bit stream carries first indication information, and the first indication information is used for indicating that final motion information of the current image block is determined based on a template;
and acquiring the motion information of a candidate image block of the current image block according to the first indication information, and acquiring the template of the current image block according to the motion information of the candidate image block.
5. The method of claim 1, further comprising:
receiving a coded bit stream from a coding end, wherein the coded bit stream carries second indication information, and the second indication information is used for indicating that final motion information of a current image block is determined based on original motion information corresponding to the current image block;
acquiring original motion information corresponding to the current image block according to the second indication information;
and determining final motion information of the current image block according to the original motion information.
6. The method of claim 1, further comprising:
acquiring motion information of candidate image blocks of a current image block according to locally preset first strategy information, and acquiring a template of the current image block according to the motion information of the candidate image blocks; the first strategy information is used for indicating that final motion information of the current image block is determined based on a template; alternatively, the first and second electrodes may be,
acquiring original motion information corresponding to the current image block according to second strategy information preset locally; determining final motion information of the current image block according to the original motion information; the second strategy information is used for indicating that final motion information of the current image block is determined based on original motion information corresponding to the current image block; alternatively, the first and second electrodes may be,
acquiring third strategy information, wherein the third strategy information is the final motion information of the current image block determined by adopting the same strategy information as the adjacent image block of the current image block;
and determining the final motion information of the current image block according to the third strategy information.
7. The method according to any of claims 1 to 6, wherein the original motion information comprises an original motion vector; before obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template, the method further includes:
receiving a coded bit stream from a coding end, wherein the coded bit stream carries an index value of an original motion vector in a motion vector list; selecting a motion vector corresponding to the index value from a motion vector list;
and determining the selected motion vector as an original motion vector corresponding to the current image block.
8. The method according to any of claims 1 to 6, wherein the original motion information comprises an original motion vector; before obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template, the method further includes:
and determining the motion vector of the candidate image block of the current image block as the original motion vector corresponding to the current image block.
9. The method according to any one of claims 1 to 8, wherein the candidate image blocks comprise M first candidate image blocks and N second candidate image blocks, M being a natural number greater than or equal to 1, N being a natural number greater than or equal to 0, or M being a natural number greater than or equal to 0, N being a natural number greater than or equal to 1; the first candidate image block is a candidate image block on the upper side of the current image block, and the second candidate image block is a candidate image block on the left side of the current image block;
the obtaining the template of the current image block according to the motion information of the candidate image block includes:
determining a first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks;
determining a second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks;
determining the first template as the template of the current image block; alternatively, the first and second electrodes may be,
determining the second template as the template of the current image block; alternatively, the first and second electrodes may be,
and determining the first template and the second template as the template of the current image block after splicing.
10. The method of claim 9,
the first candidate image block comprises an adjacent image block and/or a secondary adjacent image block on the upper side of the current image block; the prediction mode of the adjacent image block is an inter-frame mode or an intra-frame mode; the prediction mode of the secondary adjacent image block is an inter-frame mode; the second candidate image block comprises an adjacent image block on the left side of the current image block and/or a secondary adjacent image block; the prediction mode of the adjacent image block is an inter-frame mode or an intra-frame mode; and the prediction mode of the secondary adjacent image block is an inter-frame mode.
11. The method according to claim 9, wherein when M is greater than 1, the first template includes M sub-templates or P sub-templates, and is formed by splicing the M sub-templates or the P sub-templates, where P is the number of first candidate image blocks in the inter mode;
and when M is equal to 1, the first template comprises a first sub-template which is determined according to the motion vector prediction mode and the motion information of the first candidate image block on the upper side of the current image block.
12. The method according to claim 11, wherein the motion information comprises a motion vector and a reference frame index of the first candidate image block, and the determining the first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks comprises:
for an ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter mode, determining a reference frame image corresponding to the ith candidate image block according to the reference frame index;
determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block;
and acquiring image blocks with the sizes of a first transverse length and a first longitudinal length as the ith sub-template included in the first template according to the determined reference image block.
13. The method as claimed in claim 11, wherein determining the first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks comprises:
for an ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an intra-frame mode, filling the ith candidate image block according to a default value, and acquiring image blocks with the sizes of a first transverse length and a first longitudinal length as an ith sub-template included by the first template; alternatively, the first and second electrodes may be,
determining a reference frame image corresponding to the ith candidate image block according to the reference frame index corresponding to the ith candidate image block; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to a motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a first transverse length and a first longitudinal length as an ith sub-template included by the first template;
and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of an image block adjacent to the ith candidate image block.
14. The method according to claim 12 or 13,
the first transverse length and the transverse length of the first candidate image block meet a first proportional relation, or the first transverse length and the transverse length of the current image block meet a second proportional relation, or the first transverse length and the transverse length of the current image block are equal to a first preset length;
the first longitudinal length and the longitudinal length of the first candidate image block meet a third proportional relation, or the first longitudinal length and the longitudinal length of the current image block meet a fourth proportional relation, or the first longitudinal length and the longitudinal length of the first candidate image block are equal to a second preset length.
15. The method according to claim 9, wherein when N is greater than 1, the second template includes N sub-templates or R sub-templates, and is formed by splicing the N sub-templates or the R sub-templates, where R is the number of second candidate image blocks in the inter mode;
and when N is equal to 1, the second template comprises a second sub-template which is determined according to the motion vector prediction mode and the motion information of the first candidate image block on the left side of the current image block.
16. The method according to claim 15, wherein the motion information comprises a motion vector and a reference frame index of the second candidate image block, and the determining the second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks comprises:
for an ith candidate image block in the N second candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter mode, determining a reference frame image corresponding to the ith candidate image block according to the reference frame index;
determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block;
and acquiring image blocks with the sizes of a second transverse length and a second longitudinal length as the ith sub-template included by the second template according to the determined reference image block.
17. The method as claimed in claim 15, wherein determining the second template according to the motion vector prediction mode and the motion information of the N second candidate image blocks comprises:
for an ith candidate image block in the N second candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an intra-frame mode, filling the ith candidate image block according to a default value, and acquiring image blocks with the sizes of a second transverse length and a second longitudinal length as an ith sub-template included by the second template; alternatively, the first and second electrodes may be,
determining a reference frame image corresponding to the ith candidate image block according to the reference frame index corresponding to the ith candidate image block; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to a motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a second transverse length and a second longitudinal length as an ith sub-template included by the first template;
and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of an image block adjacent to the ith candidate image block.
18. The method of claim 16 or 17,
the second transverse length and the transverse length of the second candidate image block meet a fifth proportional relation, or the second transverse length and the transverse length of the current image block meet a sixth proportional relation, or the second transverse length and the transverse length of the current image block are equal to a third preset length;
the second vertical length and the vertical length of the second candidate image block satisfy a seventh proportional relationship, or satisfy an eighth proportional relationship with the vertical length of the current image block, or are equal to a fourth preset length.
19. The method according to any one of claims 1 to 18,
the obtaining the template of the current image block according to the motion information of the candidate image block includes:
when the current image block corresponds to a plurality of pieces of motion information, obtaining a template corresponding to the motion information according to each piece of motion information;
and acquiring a weight parameter corresponding to each piece of motion information, and acquiring a template of the current image block according to the weight parameter corresponding to each piece of motion information and the template corresponding to the motion information.
20. The method according to claim 1, wherein the original motion information includes an original motion vector, the target motion information includes a target motion vector, and obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template includes:
determining the original motion vector as a central motion vector;
determining an edge motion vector corresponding to the center motion vector, the edge motion vector being different from the center motion vector;
obtaining the coding performance of the central motion vector and the coding performance of the edge motion vector according to the template;
and determining the target motion vector from the central motion vector and the edge motion vector according to the coding performance of the central motion vector and the coding performance of the edge motion vector.
21. The method according to claim 1, wherein the original motion information includes an original motion vector and an original reference frame, the target motion information includes a target motion vector and a target reference frame, and obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template includes:
based on the template of the current image block, obtaining a candidate motion vector corresponding to the original reference frame according to the original motion vector;
acquiring initial motion vectors corresponding to the candidate reference frames according to the initial motion vectors;
obtaining a candidate motion vector corresponding to the candidate reference frame according to the initial motion vector;
selecting a candidate motion vector with optimal coding performance from the candidate motion vectors corresponding to the original reference frame and the candidate motion vectors corresponding to the candidate reference frames;
and determining the candidate motion vector with the optimal coding performance as the target motion vector, and determining a reference frame corresponding to the candidate motion vector with the optimal coding performance as the target reference frame.
22. An encoding method applied to an encoding end includes:
acquiring motion information of candidate image blocks of a current image block;
acquiring a template of the current image block according to the motion information of the candidate image block;
obtaining target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template;
determining final motion information of the current image block according to the original motion information and the target motion information;
and coding the current image block according to the final motion information to obtain a coded bit stream.
23. The method according to claim 22, wherein after said encoding said current image block according to said final motion information to obtain an encoded bitstream, said method further comprises:
and storing the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block.
24. The method according to claim 23, wherein storing the original motion information or the final motion information corresponding to the current image block as the motion information of the current image block comprises:
when the original motion information of the current image block is obtained according to the motion information of the spatial domain adjacent block, storing the original motion information corresponding to the current image block as the motion information of the current image block; alternatively, the first and second electrodes may be,
and when the original motion information of the current image block is not obtained according to the motion information of the spatial domain adjacent block, storing the final motion information corresponding to the current image block as the motion information of the current image block.
25. The method according to claim 22, wherein the candidate image blocks comprise M first candidate image blocks and N second candidate image blocks, M being a natural number greater than or equal to 1 and N being a natural number greater than or equal to 0, or M being a natural number greater than or equal to 0 and N being a natural number greater than or equal to 1; the first candidate image block is a candidate image block on the upper side of the current image block, and the second candidate image block is a candidate image block on the left side of the current image block;
the obtaining the template of the current image block according to the motion information of the candidate image block includes:
determining a first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks;
determining a second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks;
determining the first template as the template of the current image block; alternatively, the first and second electrodes may be,
determining the second template as the template of the current image block; alternatively, the first and second electrodes may be,
and determining the first template and the second template as the template of the current image block after splicing.
26. The method of claim 25,
the first candidate image block comprises an adjacent image block and/or a secondary adjacent image block on the upper side of the current image block; the prediction mode of the adjacent image block is an inter-frame mode or an intra-frame mode; the prediction mode of the secondary adjacent image block is an inter-frame mode; the second candidate image block comprises an adjacent image block on the left side of the current image block and/or a secondary adjacent image block; the prediction mode of the adjacent image block is an inter-frame mode or an intra-frame mode; and the prediction mode of the secondary adjacent image block is an inter-frame mode.
27. The method according to claim 25, wherein when M is greater than 1, the first template includes M sub-templates or P sub-templates, and is formed by splicing the M sub-templates or the P sub-templates, where P is the number of first candidate image blocks in the inter mode;
and when M is equal to 1, the first template comprises a first sub-template which is determined according to the motion vector prediction mode and the motion information of the first candidate image block on the upper side of the current image block.
28. The method of claim 27, wherein the motion information comprises a motion vector and a reference frame index of the first candidate tile, and wherein determining the first template according to the motion vector prediction modes and the motion information of the M first candidate tiles comprises:
for an ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter mode, determining a reference frame image corresponding to the ith candidate image block according to the reference frame index;
determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block;
and acquiring image blocks with the sizes of a first transverse length and a first longitudinal length as the ith sub-template included in the first template according to the determined reference image block.
29. The method as claimed in claim 27, wherein said determining the first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks comprises:
for an ith candidate image block in the M first candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an intra-frame mode, filling the ith candidate image block according to a default value, and acquiring image blocks with the sizes of a first transverse length and a first longitudinal length as an ith sub-template included by the first template; alternatively, the first and second electrodes may be,
determining a reference frame image corresponding to the ith candidate image block according to the reference frame index corresponding to the ith candidate image block; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to a motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a first transverse length and a first longitudinal length as an ith sub-template included by the first template;
and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of an image block adjacent to the ith candidate image block.
30. The method of claim 28 or 29,
the first transverse length and the transverse length of the first candidate image block meet a first proportional relation, or the first transverse length and the transverse length of the current image block meet a second proportional relation, or the first transverse length and the transverse length of the current image block are equal to a first preset length;
the first longitudinal length and the longitudinal length of the first candidate image block meet a third proportional relation, or the first longitudinal length and the longitudinal length of the current image block meet a fourth proportional relation, or the first longitudinal length and the longitudinal length of the first candidate image block are equal to a second preset length.
31. The method according to claim 25, wherein when N is greater than 1, the second template comprises N sub-templates or R sub-templates, and is formed by splicing the N sub-templates or the R sub-templates, where R is the number of second candidate image blocks in the inter mode;
and when N is equal to 1, the second template comprises a second sub-template which is determined according to the motion vector prediction mode and the motion information of the first candidate image block on the left side of the current image block.
32. The method according to claim 31, wherein the motion information comprises a motion vector and a reference frame index of the second candidate image block, and the determining the second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks comprises:
for an ith candidate image block in the N second candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an inter mode, determining a reference frame image corresponding to the ith candidate image block according to the reference frame index;
determining a reference image block corresponding to the ith candidate image block from the reference frame image according to the motion vector of the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector of the ith candidate image block;
and acquiring image blocks with the sizes of a second transverse length and a second longitudinal length as the ith sub-template included by the second template according to the determined reference image block.
33. The method as claimed in claim 31, wherein determining the second template according to the motion vector prediction mode and the motion information of the N second candidate image blocks comprises:
for an ith candidate image block in the N second candidate image blocks, when the motion vector prediction mode of the ith candidate image block is determined to be an intra-frame mode, filling the ith candidate image block according to a default value, and acquiring image blocks with the sizes of a second transverse length and a second longitudinal length as an ith sub-template included by the second template; alternatively, the first and second electrodes may be,
determining a reference frame image corresponding to the ith candidate image block according to the reference frame index corresponding to the ith candidate image block; determining a reference image block corresponding to the ith candidate image block from the reference frame image according to a motion vector corresponding to the ith candidate image block, wherein the relative position offset of the reference image block and the ith candidate image block is matched with the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with the size of a second transverse length and a second longitudinal length as an ith sub-template included by the first template;
and the reference frame index and the motion vector corresponding to the ith candidate image block are the reference frame index and the motion vector of an image block adjacent to the ith candidate image block.
34. The method of claim 32 or 33,
the second transverse length and the transverse length of the second candidate image block meet a fifth proportional relation, or the second transverse length and the transverse length of the current image block meet a sixth proportional relation, or the second transverse length and the transverse length of the current image block are equal to a third preset length;
the second vertical length and the vertical length of the second candidate image block satisfy a seventh proportional relationship, or satisfy an eighth proportional relationship with the vertical length of the current image block, or are equal to a fourth preset length.
35. The method of any one of claims 24 to 34,
the obtaining the template of the current image block according to the motion information of the candidate image block includes:
when the current image block corresponds to a plurality of pieces of motion information, obtaining a template corresponding to the motion information according to each piece of motion information;
and acquiring a weight parameter corresponding to each piece of motion information, and acquiring a template of the current image block according to the weight parameter corresponding to each piece of motion information and the template corresponding to the motion information.
36. The method of claim 22, wherein the original motion information includes an original motion vector, the target motion information includes a target motion vector, and obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template comprises:
determining the original motion vector as a central motion vector;
determining an edge motion vector corresponding to the center motion vector, the edge motion vector being different from the center motion vector;
obtaining the coding performance of the central motion vector and the coding performance of the edge motion vector according to the template;
and determining the target motion vector from the central motion vector and the edge motion vector according to the coding performance of the central motion vector and the coding performance of the edge motion vector.
37. The method of claim 22, wherein the original motion information includes an original motion vector and an original reference frame, the target motion information includes a target motion vector and a target reference frame, and obtaining the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template includes:
based on the template of the current image block, obtaining a candidate motion vector corresponding to the original reference frame according to the original motion vector;
acquiring initial motion vectors corresponding to the candidate reference frames according to the initial motion vectors;
obtaining a candidate motion vector corresponding to the candidate reference frame according to the initial motion vector;
selecting a candidate motion vector with optimal coding performance from the candidate motion vectors corresponding to the original reference frame and the candidate motion vectors corresponding to the candidate reference frames;
and determining the candidate motion vector with the optimal coding performance as the target motion vector, and determining a reference frame corresponding to the candidate motion vector with the optimal coding performance as the target reference frame.
38. The method of claim 22, wherein the original motion information comprises an original motion vector, the destination motion information comprises a target motion vector, and the determining the final motion information of the current image block according to the original motion information and the target motion information comprises:
acquiring the coding performance of the original motion vector and the coding performance of the target motion vector;
when the coding performance of the target motion vector is better than that of the original motion vector, determining the final motion vector of the current image block as the target motion vector;
wherein the coded bitstream carries first indication information indicating that final motion information of the current image block is determined based on a template.
39. The method of claim 22, wherein the original motion information comprises an original motion vector, the destination motion information comprises a target motion vector, and the determining the final motion information of the current image block according to the original motion information and the target motion information comprises:
acquiring the coding performance of the original motion vector and the coding performance of the target motion vector;
when the encoding performance of the original motion vector is better than that of the target motion vector, determining the final motion vector of the current image block as the original motion vector;
the coded bit stream carries second indication information, where the second indication information is used to indicate that final motion information of the current image block is determined based on original motion information corresponding to the current image block.
40. The method of claim 22, further comprising: acquiring an index value of an original motion vector in a motion vector list; the coded bitstream carries the index value.
41. The method of claim 38 or 39,
acquiring the encoding performance of the original motion vector, comprising:
determining the encoding performance of the original motion vector according to the parameter information of the template of the current image block and the parameter information of a first target reference block, wherein the first target reference block is an image block obtained after a reference image block corresponding to the template is subjected to offset based on the original motion vector;
acquiring the coding performance of the target motion vector, wherein the coding performance comprises the following steps:
and determining the coding performance of the target motion vector according to the parameter information of the template of the current image block and the parameter information of a second target reference block, wherein the second target reference block is an image block obtained after the reference image block corresponding to the template is subjected to offset based on the target motion vector.
42. A decoding-side apparatus, comprising: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor is configured to execute machine executable instructions to perform the method steps of any of claims 1-21.
43. An encoding side device, comprising: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor is configured to execute machine executable instructions to perform the method steps of any of claims 22 to 41.
CN201810738280.4A 2018-07-06 2018-07-06 Decoding and encoding method and device Active CN110691247B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201810738280.4A CN110691247B (en) 2018-07-06 2018-07-06 Decoding and encoding method and device
PCT/CN2019/094433 WO2020007306A1 (en) 2018-07-06 2019-07-02 Decoding and encoding method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810738280.4A CN110691247B (en) 2018-07-06 2018-07-06 Decoding and encoding method and device

Publications (2)

Publication Number Publication Date
CN110691247A true CN110691247A (en) 2020-01-14
CN110691247B CN110691247B (en) 2023-04-28

Family

ID=69060771

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810738280.4A Active CN110691247B (en) 2018-07-06 2018-07-06 Decoding and encoding method and device

Country Status (2)

Country Link
CN (1) CN110691247B (en)
WO (1) WO2020007306A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5619268A (en) * 1995-01-17 1997-04-08 Graphics Communication Laboratories Motion estimation method and apparatus for calculating a motion vector
CN101686393A (en) * 2008-09-28 2010-03-31 华为技术有限公司 Fast-motion searching method and fast-motion searching device applied to template matching
CN102611886A (en) * 2011-01-22 2012-07-25 华为技术有限公司 Method for predicting or compensating motion
CN102640495A (en) * 2009-09-10 2012-08-15 Sk电信有限公司 Motion vector encoding/decoding method and device and image encoding/decoding method and device using same

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102611887B (en) * 2011-01-21 2015-08-05 华为技术有限公司 The coordinate figure of non-Integer Pel position motion vector rounds method and apparatus

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5619268A (en) * 1995-01-17 1997-04-08 Graphics Communication Laboratories Motion estimation method and apparatus for calculating a motion vector
CN101686393A (en) * 2008-09-28 2010-03-31 华为技术有限公司 Fast-motion searching method and fast-motion searching device applied to template matching
CN102640495A (en) * 2009-09-10 2012-08-15 Sk电信有限公司 Motion vector encoding/decoding method and device and image encoding/decoding method and device using same
CN102611886A (en) * 2011-01-22 2012-07-25 华为技术有限公司 Method for predicting or compensating motion

Also Published As

Publication number Publication date
CN110691247B (en) 2023-04-28
WO2020007306A1 (en) 2020-01-09

Similar Documents

Publication Publication Date Title
CN110933426B (en) Decoding and encoding method and device thereof
TWI692246B (en) Image prediction decoding method
US20120027092A1 (en) Image processing device, system and method
CN111698500B (en) Encoding and decoding method, device and equipment
CN115348443A (en) Motion information determination method, device and equipment
CN110662033B (en) Decoding and encoding method and device thereof
CN112118451B (en) Encoding and decoding method, device and equipment
CN110662074B (en) Motion vector determination method and device
CN113055684A (en) Encoding and decoding method, device and equipment
CN112449180B (en) Encoding and decoding method, device and equipment
CN112565747B (en) Decoding and encoding method, device and equipment
CN110691247B (en) Decoding and encoding method and device
CN110365987B (en) Motion vector determination method, device and equipment
CN113794884A (en) Encoding and decoding method, device and equipment
CN113422951B (en) Decoding and encoding method, device and equipment
CN113709486B (en) Encoding and decoding method, device and equipment
KR101525325B1 (en) Intra prediction mode determination method and apparatus
CN112073734A (en) Encoding and decoding method, device and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant