CN110691247B - Decoding and encoding method and device - Google Patents
Decoding and encoding method and device Download PDFInfo
- Publication number
- CN110691247B CN110691247B CN201810738280.4A CN201810738280A CN110691247B CN 110691247 B CN110691247 B CN 110691247B CN 201810738280 A CN201810738280 A CN 201810738280A CN 110691247 B CN110691247 B CN 110691247B
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 125
- 239000013598 vector Substances 0.000 claims description 1103
- 239000000523 sample Substances 0.000 claims 3
- 239000000758 substrate Substances 0.000 claims 2
- 230000008569 process Effects 0.000 description 23
- 238000012545 processing Methods 0.000 description 20
- 238000010586 diagram Methods 0.000 description 19
- 230000002123 temporal effect Effects 0.000 description 11
- 238000004590 computer program Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 6
- 238000006073 displacement reaction Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 102100026278 Cysteine sulfinic acid decarboxylase Human genes 0.000 description 2
- 101000855583 Homo sapiens Cysteine sulfinic acid decarboxylase Proteins 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 102100031260 Acyl-coenzyme A thioesterase THEM4 Human genes 0.000 description 1
- 101000638510 Homo sapiens Acyl-coenzyme A thioesterase THEM4 Proteins 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 238000011156 evaluation Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000013139 quantization Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods 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/136—Incoming video signal characteristics or properties
- H04N19/137—Motion inside a coding unit, e.g. average field, frame or block difference
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods 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/136—Incoming video signal characteristics or properties
- H04N19/137—Motion inside a coding unit, e.g. average field, frame or block difference
- H04N19/139—Analysis of motion vectors, e.g. their magnitude, direction, variance or reliability
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods 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/146—Data rate or code amount at the encoder output
- H04N19/149—Data 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
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods 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/17—Methods 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/176—Methods 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
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- Algebra (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
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 the 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 acquired 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
Technical Field
The present disclosure relates to the field of video encoding and decoding technologies, and in particular, to a decoding and encoding method and apparatus.
Background
For the purpose of saving space, the video images are transmitted after being encoded, and the complete video encoding method can comprise the processes of prediction, transformation, quantization, entropy encoding, filtering and the like. The prediction coding comprises intra-frame coding and inter-frame coding, wherein the inter-frame coding utilizes the correlation of video time domains, and pixels adjacent to the coded image are used for predicting pixels of the current image so as to achieve the purpose of effectively removing video time domain redundancy.
In inter-frame coding, a Motion Vector (MV) may be 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. For example, when there is a strong temporal correlation between the video image a of the current frame and the video image B of the reference frame, and when the 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 the image block B1 (i.e., the reference image block) that is the best match with the image block A1, and determine the relative displacement between the image block A1 and the image block B1, that is, the motion vector of the image block A1.
The encoding end may send the motion vector to the decoding end instead of sending the image block A1 to the decoding end, and the decoding end may obtain the image block A1 according to the motion vector and the image block B1. Obviously, since the number of bits occupied by the motion vector is smaller than that occupied by the image block A1, the above manner can save a large number of bits.
However, if the video image a is divided into a large number of image blocks, a relatively large number of bits are occupied when transmitting the motion vector for each image block. To further save bits, the motion vector of the image block A1 may also be predicted using the spatial correlation between candidate image blocks. For example, the motion vector of the image block A2 adjacent to the image block A1 may be determined as the motion vector of the image block A1. Based on this, the encoding end may transmit the index value of the image block A2 to the decoding end, and the decoding end may determine the motion vector of the image block A2, that is, the motion vector of the image block A1, based on the index value. Since the index value of the image block A2 occupies less bits than the motion vector, the above manner can further save bits.
Since there may be a difference between the motion of the image block A1 and the motion of the image block A2, that is, the motion vector of the image block A2 may not coincide 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, solves the problems of low prediction quality, prediction error and the like, and can improve the precision of motion vectors and the encoding performance and 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 the 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 acquired 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 an encoding method, which is applied to an encoding end, and comprises the following steps:
Acquiring motion information of candidate image blocks of the 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 acquired template;
determining final motion information of the current image block according to the original motion information and the target motion information; and encoding the current image block according to the final motion information to obtain an encoded bit stream.
The application provides a decoding end device, comprising: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor is configured to execute the 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 the machine executable instructions to implement the above-described encoding method steps.
As can be seen from the above technical solutions, in the embodiments of the present application, the target motion information may be obtained according to the original motion information, and the final motion information of the current image block may be determined according to the target motion information, instead of determining the final motion information of the current image block according to the original motion information, so as to improve the accuracy of the motion information and improve the coding performance. Moreover, when the target motion information is acquired according to the original motion information, the template of the current image block can be acquired according to the motion information of the candidate image block, and the target motion information is acquired according to the template of the current image block. For example, a template for the current image block may be acquired prior to the reconstruction stage of decoding, and target motion information derived from the template.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following description will briefly describe the drawings that are required to be used in the embodiments of the present application or the description in the prior art, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings may also be obtained according to these drawings of the embodiments of the present application for a person having ordinary skill in the art.
FIG. 1 is a flow chart of an encoding method in one embodiment of the present application;
FIGS. 2A-2O are template diagrams of a current image block in one 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 flowcharts of encoding methods 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 flowcharts of a decoding method in another embodiment of the present application;
fig. 7 is a block diagram of a decoding apparatus in an embodiment of the present application;
fig. 8 is a block diagram of an encoding apparatus in another embodiment of the present application;
FIG. 9 is a hardware configuration diagram of a decoding end device in an embodiment of the present application;
Fig. 10 is a hardware configuration diagram of an encoding end device in an embodiment of the present application.
Detailed Description
The terminology used in the embodiments of the 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 refers to any or all possible combinations including one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in embodiments of the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, a first message may also be referred to as a second message, and similarly, a second message may also be referred to as a first message, without departing from the scope of the present application. Depending on the context, furthermore, the word "if" used may be interpreted as "at … …" or "at … …" 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 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 and is transmitted to a decoding end. If the motion vector of each image block is encoded and transmitted independently, in particular divided into a large number of image blocks of small size, a considerable number of bits are consumed. In order to reduce the number of bits used for encoding a motion vector, the spatial correlation between neighboring image blocks may be utilized to predict a motion vector of a current image block to be encoded from the motion vectors of neighboring encoded image blocks, and then the prediction difference may be encoded, so that the number of bits representing the motion vector may be effectively reduced.
Motion information (Motion Information): since the motion vector indicates the positional offset of the current image block from a certain reference image block, in order to accurately acquire information directed to the image block, index information of reference frame images 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 what reference frame image in the reference frame image list is adopted by the current image block. In the video coding technology, motion-related coding information such as a motion vector, a reference frame index, and the like may be collectively referred to as motion information.
Template (Template): in video coding techniques, the coding process is performed on a block-by-block basis, and the reconstruction information of surrounding coded blocks is available when coding the current block. The template refers to decoding information of a fixed shape around the current image block (adjacent region of the time domain or the space domain). At the encoding end and decoding end, the templates are identical, so that some operations performed at the encoding end using the templates can obtain completely consistent results at the decoding end, that is, information derived by the encoding end based on the templates can be recovered losslessly at the decoding end 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: the smaller the bit stream, the larger the compression ratio and the larger the PSNR, the better the reconstructed image quality, and the discrimination formula is essentially the integrated evaluation of the two in mode selection. For example, the cost of pattern correspondence: j (mode) =d+λ×r, where D represents Distortion, which can be measured generally using an SSE index, which refers to the mean square sum of the differences of the reconstructed image block and the source image; λ is the lagrangian multiplier, and R is the actual number of bits required for coding an image block in this mode, including the sum of bits required for coding mode information, motion information, residuals, etc.
Intra prediction and inter prediction (intra prediction and inter prediction): intra prediction refers to predictive coding using reconstructed pixel values of spatial neighboring image blocks of the current image block (e.g., in the same frame as the current image block), while inter prediction refers to predictive coding using reconstructed pixel values of temporal neighboring image blocks of the current image block (e.g., in a different frame from the current image block).
The above-described decoding method and encoding method will be described in detail below with reference to several specific embodiments.
Embodiment one:
referring to fig. 1, which is a schematic flow chart of an encoding method, the method may include the following steps:
Wherein the candidate image blocks of the current image block may include, but are not limited to: spatial domain candidate image blocks of the current image block; or, a temporal candidate image block of the current image block; the candidate image block is not limited.
When the current image block is encoded, the candidate image block of the current image block is already encoded, that is, the motion information of the candidate image block is known, so that the encoding end can directly obtain the motion information of the candidate image block, such as the motion vector and the reference frame index of the candidate image block, without limitation.
Wherein the motion information of the candidate image block may include, but is not limited to: the original motion information corresponding to the candidate image block, such as an original motion vector, or the original motion vector and an original reference frame. The final motion information, such as the final motion vector, or the final motion vector and the final reference frame, corresponding to the candidate image block.
In one example, the final motion information of the current image block is used only for encoding of the current image block (encoding process of prediction value generation, reconstruction, etc. of the current image block), and is not used for prediction of the neighboring image block, i.e., the motion information obtained from the candidate image block is the original motion information of the candidate block, and is 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 saved, but the original motion information is saved, namely, the motion information of the current image block is restored to the original motion information.
In the following embodiments, a method for obtaining final motion information of a current image block will be described, and a method for obtaining final motion information corresponding to a candidate image block is similar to that of the current image block, that is, the candidate image block is used as the current image block to obtain final motion information, which is not described herein.
In one example, the encoding end may store the motion information corresponding to the candidate image block, such as storing the original motion information corresponding to the candidate image block as the motion information of the candidate block or storing the final motion information corresponding to the candidate image block as the motion information of the candidate block, so that the original motion information corresponding to the candidate image block may be directly queried locally from the encoding end in step 101.
In another example, the encoding end may obtain original motion information (such as 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 the original motion vector. For another example, motion information of neighboring image blocks of the candidate image block may be determined as original motion information corresponding to the candidate image block.
The above manner is merely an example of acquiring the original motion information of the candidate image block, and is not limited thereto.
The processing in step 102 may be referred to in the following embodiments, and will not be described herein.
And step 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 includes an original motion vector and the target motion information includes a target motion vector. Alternatively, 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 comprises an original motion vector and the target motion information comprises 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 acquired template, and the method comprises the following steps: determining the original motion vector as a center 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 center motion vector and the coding performance of the edge motion vector according to the template; and determining 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.
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 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, acquiring a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to each candidate reference frame 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 candidate motion vectors corresponding to the original reference frames and 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 of the step 103 may be referred to the following embodiments, and will not be described herein.
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 destination motion information includes a target motion vector, and the final motion information includes a final motion vector, the encoding end determines final motion information of the current image block according to the original motion information and the target motion information, and 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 better than that of the original motion vector, determining the final motion vector of the current image block as the target motion vector; when the coding 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 obtaining of the coding performance of the original motion vector comprises: determining the coding 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 the reference image block corresponding to the template is offset based on the original motion vector; the obtaining the coding performance of the target motion vector comprises the following steps: and determining the coding performance of a 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 offset based on the target motion vector.
The detailed processing procedure of the step 104 may be referred to in the following embodiments, and will not be described herein.
And 105, the encoding end encodes the current image block according to the final motion information to obtain an encoded bit stream. The encoding side may then also send the encoded bit stream to the decoding side.
And 106, the encoding end 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. Thus, in the processing of other image blocks, if the current image block is selected as the candidate image block of the other image blocks, 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 obtain 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 sub-neighboring block), the original motion information corresponding to the current image block is stored 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 neighboring block (or the spatial sub-neighboring 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 from the motion information of the temporal neighboring block, the final motion information corresponding to the current image block is stored 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 includes at least an original motion vector, and when the original motion vector of the current image block is obtained according to the motion vector of the spatial neighboring block, 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 neighboring block, storing the final motion vector corresponding to the current image block as the motion vector of the current image block. For example, when an original motion vector corresponding to a current image block is obtained from a motion vector of a temporal neighboring block, a final motion vector corresponding to the current image block is stored as a motion vector of the current image block; the final motion vector corresponding to the current image block may also be stored as the motion vector of the current image block by default.
In one example, the motion information includes a motion vector, and after encoding, an original motion vector of the current image block is stored as a motion vector of the current image block, or in another example, a final motion vector of the current image block is stored as a motion vector of the current image block after encoding.
In one example, the final motion information of the current image block is used only for encoding of the current image block (encoding process of prediction value generation, reconstruction, etc. of the current image block), and is not used for prediction of the neighboring image block, i.e., the motion information obtained from the candidate image block is the original motion information of the candidate block, and is 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 saved, but the original motion information is saved, namely, 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 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 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 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 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 reference image frames, motion directions, and the like in addition to the motion vectors.
In one example, the encoding end may also obtain an index value of the original motion vector in the motion vector list; furthermore, the coded bit stream may carry the index value, a process which is described in the following embodiments.
In one 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 encoded 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.
The first indication information or the second indication information is notified in a display manner, and in practical application, the first indication information or the second indication information may be notified in an implicit manner, that is, the first indication information or the second indication information is not carried in the encoded bitstream. Specifically, the encoding end and the decoding end can also negotiate a decision strategy or define a strategy at a standard, and the strategy is stored at the encoding end and the decoding end, for example, the decision strategy can be default first strategy information, and the first strategy information is used for indicating to determine the final motion information of the current image block based on a template; or defaulting second strategy information, wherein the second strategy information is used for indicating to determine the final motion information of the current image block based on the original motion information corresponding to the current image block; or defaulting to third policy information, wherein the third policy information is policy information which is the same as that of the adjacent image block of the current image block.
On the basis, when the decision strategy is the default first strategy information and the encoding end encodes the bit stream according to the target motion information, the encoded bit stream may not carry the first indication information and the second indication information. When the decision strategy is the default second strategy information and the encoding end encodes the bit stream according to the original motion information, the encoded bit stream 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 blocks adopt the first strategy information, the encoding end encodes the bit stream according to the target motion information, and the encoding bit stream does not need to carry the first indication information and the second indication information; when the adjacent image blocks adopt the second strategy information, the encoding end encodes the bit stream according to the original motion information, and the encoding bit stream does not carry the first indication information and the second indication information.
As can be seen from the above technical solutions, in the embodiments of the present application, a template of a current image block may be obtained according to motion information of a candidate image block of the current image block, and a bitstream is encoded according to the template of the current image block to obtain an encoded bitstream. The method can quickly obtain the template of the current image block, solves the problems of low coding efficiency, large coding time delay and the like, can improve the coding efficiency, reduce the coding time delay and improve the coding performance.
Furthermore, the encoding end can simultaneously encode a plurality of image blocks in parallel, so that the encoding speed is further improved, the encoding efficiency is improved, 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 process of prediction value generation, reconstruction, etc. of the current image block), and is not used for prediction of the neighboring image block, i.e., the candidate motion information obtained by the neighboring image block is original motion information, not final motion information. After the encoding of the current image block is finished, the final motion information is not saved, but the original motion information is saved, namely, the motion information of the current image block is restored to the original motion information.
Embodiment two:
in the video coding process, each image block is coded one by one, when the current image block is coded, if adjacent image blocks around the current image block are already reconstructed, the decoded information of the adjacent image blocks can be used for reconstructing the current image block, so that the decoded information of the adjacent image blocks of the current image block can be used for obtaining the template 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 intermediate value that can acquire the reconstruction information, and for example, if the luminance value can be acquired using intermediate value a, the intermediate value a is the prediction information, and the 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 until the decoding reconstruction stage, so that the decoding efficiency is greatly reduced, and the decoding time delay is brought; and the decoding information is prediction information, so that the generation of the template of the current image block also needs to wait until the decoding reconstruction stage, thereby greatly reducing the decoding efficiency and bringing decoding time delay. Thus, the above manner may cause the parallelism of decoding to be greatly affected.
In view of the above findings, in this embodiment, a better template generation manner is provided, and different from the manner of generating the template by using the reconstruction information and the prediction information, the template of the current image block can be obtained according to the motion information (such as the motion vector and the reference frame index) of the candidate image block of the current image block, and the method of obtaining the template of the current image block according to the motion information of the candidate image block can be applied to the encoding end and the decoding end.
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 a 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, it is assumed that image block A1 is a current image block, and image block A2 and image block A3 are candidate image blocks for image block A1. For the image block A2, if the reference frame index of the image block A2 is the index of the video image B, it may be determined that the reference frame image corresponding to the image block A2 is the video image B according to the reference frame index; then, selecting an image block B2 corresponding to the image block A2 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 '(for example, 3 pixels are moved rightward and 3 pixels are moved upward), where the image block B2' is the reference image block corresponding to the image block A2. Similarly, it can be determined that the reference image block corresponding to the image block A3 is the image block B3'. Further, the template of image block A2 may be determined from image block B2 'and image block B3', as shown in fig. 2A.
In one example, the candidate image blocks may include 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 of 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, the first template and the second template are spliced and then determined as the template of the current image block.
For example, when M is a natural number greater than or equal to 1 and N is 0, a first template may be determined according to the motion vector prediction modes and the motion information of 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, a 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 motion vector prediction modes and motion information of M first candidate image blocks, determining a second template according to motion vector prediction modes and motion information of N second candidate image blocks, and determining the first template as a template of the current image block; or determining the second template as the template of the current image block; or the first template and the second template are spliced to be determined as the template of the current image block.
The first candidate image block comprises an adjacent image block and/or a next 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 next-neighbor 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 the upper side of the current image block, or the first neighboring image block on the upper side of the current image block, or any one or more neighboring image blocks on the upper side of the current image block. In addition, when the neighboring image blocks on the upper side of the current image block are all intra-mode, the first candidate image block may further include at least one sub-neighboring image block whose prediction mode is inter-mode, for example, all sub-neighboring image blocks on the upper side of the current image block, or the first sub-neighboring image block on the upper side of the current image block, or any one or more sub-neighboring image blocks on the upper side of the current image block. In addition, when there is an intra-mode neighboring image block on the upper side of the current image block, the first candidate image block may further include an intra-mode neighboring image block, for example, a first intra-mode neighboring image block on the upper side of the current image block, all intra-mode neighboring image blocks on the upper side of the current image block, and the like. Of course, the above is only an example of the first candidate image block, and is not limited thereto.
The second candidate image block comprises an adjacent image block and/or a next adjacent image block on the left 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 next-neighbor 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 to the left of the current image block, or the first neighboring image block to the left of the current image block, or any one or more neighboring image blocks to the left of the current image block. In addition, when the neighboring image blocks to the left of the current image block are all intra-mode, the second candidate image block may further include at least one sub-neighboring image block whose prediction mode is inter-mode, for example, all sub-neighboring image blocks to the left of the current image block, or the first sub-neighboring image block to the left of the current image block, or any one or more sub-neighboring image blocks to the left of the current image block. In addition, when there is an intra-mode neighboring image block to the left of the current image block, then the first candidate image block may also include an intra-mode neighboring image block, for example, a first intra-mode neighboring image block to the left of the current image block, all intra-mode neighboring image blocks to the left of the current image block, and so on. Of course, the above is only an example of the second candidate image block, and is not limited thereto.
Wherein neighboring tiles of the current tile include, but are not limited to: spatial neighboring image blocks of the current image block (i.e., neighboring image blocks in the same frame of video image); or, temporal neighboring image blocks of the current image block (i.e., neighboring image blocks in a different frame video image). The next-neighbor tiles of the current tile include, but are not limited to: spatial sub-adjacent image blocks of the current image block (i.e., sub-adjacent image blocks in the same frame of video image); or, a temporal sub-adjacent image block of the current image block (i.e., a sub-adjacent image block in a different frame video image).
In one example, when M is greater than 1, the first template may include M sub-templates or P sub-templates, and is formed by stitching M sub-templates or P sub-templates, 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 is formed by stitching the M sub-templates. For another example, when the M first candidate image blocks include P inter-mode candidate image blocks and include M-P intra-mode candidate image blocks, the first template may include M sub-templates (i.e., each candidate image block corresponds to one sub-template) and be formed by stitching the M sub-templates, or the first template may include P sub-templates (i.e., P sub-templates corresponding to the P inter-mode candidate image blocks) and be formed by stitching the P sub-templates.
Further, when M is equal to 1, then 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 one of the candidate image blocks on the upper side of the current image block. Wherein, since the first candidate image block includes at least one neighboring image block or sub-neighboring 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 neighboring image block or sub-neighboring image block of 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 a first template is determined from 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 the ith candidate image block in the M first candidate image blocks, when determining that the motion vector prediction mode of the ith candidate image block is the 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; then, an image block having a size of a first lateral length and a first longitudinal length may be acquired as an i-th sub-template included in the first template based on 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-mode, filling the ith candidate image block according to a default value (such as a default pixel value and a brightness value which can be preset according to experience), and acquiring the image block with the size 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.
Thirdly, aiming at 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 an intra-frame mode, 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; 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 (comprises equal or approximately equal to) the motion vector corresponding to the ith candidate image block; acquiring an image block with a first transverse length and a first longitudinal length as an ith sub-template included in a first template according to the determined reference image block; 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 adjacent image block of 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., without limitation), 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 longitudinal length and the longitudinal 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 longitudinal length of the current image block, or are 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 one example, when N is greater than 1, the second template may include N sub-templates or R sub-templates, and is formed by stitching N sub-templates or R sub-templates, 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 is formed by stitching the N sub-templates. For another example, when the N second candidate image blocks include R inter-mode candidate image blocks and include N-R intra-mode candidate image blocks, the second template may include N sub-templates (i.e., each candidate image block corresponds to one sub-template) and be formed by stitching the N sub-templates, or the second template may include R sub-templates (i.e., R sub-templates corresponding to R inter-mode candidate image blocks) and be formed by stitching the R sub-templates.
Further, when N is equal to 1, then 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 to the left of the current image block; alternatively, the second sub-template may be determined based on the motion vector prediction mode and motion information of any one of the candidate image blocks to the left of the current image block. Wherein, since the second candidate image block includes at least one neighboring image block or sub-neighboring image block whose prediction mode is the inter mode, when N is equal to 1, the second template includes a second sub-template corresponding to the neighboring image block or sub-neighboring 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 a second template is determined from 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 the first case, for the ith candidate image block in the N second candidate image blocks, when determining that the motion vector prediction mode of the ith candidate image block is the 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; then, an image block having a size of a second lateral length and a second longitudinal length may be acquired as an i-th sub-template included in the second template based on the determined reference image block.
And secondly, for the 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 the intra-frame mode, filling the ith candidate image block according to a default value (such as a default pixel value and a brightness value which can be preset according to experience), and acquiring the image block with the size 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.
Thirdly, aiming at the 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, 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; 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 (comprises equal or approximately equal to) the motion vector corresponding to the ith candidate image block; acquiring an image block with a second transverse length and a second longitudinal length as an ith sub-template included in the first template according to the determined reference image block; 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 adjacent image block of the ith candidate image block.
The second lateral length and the lateral length of the second candidate image block satisfy a fifth proportional relationship (such as 1:1,1:2,2:1, etc., without limitation), or satisfy a sixth proportional relationship (such as 1:1,1:2,2:1, etc.) with the lateral length of the current image block, or are equal to a third preset length (configured empirically).
The second longitudinal length and the longitudinal 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 longitudinal length of the current image block, or are equal to a fourth preset length (i.e. a length configured empirically).
The fifth ratio relationship, the sixth ratio relationship, the seventh ratio relationship, and the eighth ratio relationship 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 one example, the template of the current image block is obtained according to the motion information of the candidate image block, and 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 acquired according to each piece of motion information, and the acquisition mode of each template is as described in the above embodiment. And then, acquiring weight parameters corresponding to each piece of motion information, and acquiring a template of the current image block according to the weight parameters corresponding to each piece of motion information and the template corresponding to the motion information. For example, a template of the current image block is obtained based on a weighted average manner based on a weight parameter corresponding to each piece of motion information and a template corresponding to the motion information.
For example, the current image block corresponds to the motion information a and the 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 acquired, 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 in connection with several specific cases.
Case one: referring to fig. 2B, the candidate image block 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 image block A1, if there is an adjacent image block of the inter mode, such as the image block A3 and the image block A4, on the left side, the image block A3 and the image block A4 of the inter mode may be determined as candidate image blocks of the current image block A1. Similarly, if there is an adjacent image block of the inter mode, such as image block A2, on the upper side, the image block A2 of the inter mode may be determined as a candidate image block of the current image block A1.
If there is no available image block on the left side, or if there is an available image block on the left side, but all the available image blocks are intra-mode, it may be indicated that there is no candidate image block on the left side of the current image block A1. Similarly, if there is no available block on the upper side, or if there is an available block on the upper side, but the available blocks are all intra-modes, it may be indicated that there is no candidate block on the upper side of the current block A1. If there is no candidate block on both the left side and the upper side, it may be indicated that the current image block A1 has no candidate block.
In addition, if the current image block A1 does not have a candidate image block, the technical solution of the embodiment is not adopted, but a conventional manner is adopted, and a detailed description thereof is omitted. If the current image block A1 has a candidate image block, for example, a left candidate image block and/or an upper candidate image block, the technical solution of this embodiment is adopted.
In one 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 A4. For example, for the image block A2, a 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 may be selected from the reference frame images, the image block B2 may be moved according to the motion vector of the image block A2 to obtain a reference image block B2' corresponding to the image block A2, and similarly, the reference image block B3' corresponding to the image block A3 and the reference image block B4' corresponding to the image block A4 may be obtained, as shown in fig. 2C. Then, a template of the current image block A1 may be obtained from the reference image block B2', the reference image block B3', and the reference image block B4 '.
In one example, assuming that the lateral length of the upper template of the current image block A1 is W and the longitudinal length is S, the value of W may be empirically configured, the value of S may be empirically configured, and neither the values of W nor S are 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, etc., S may be the longitudinal length of the candidate image block A2, 1/3 of the longitudinal length of the candidate image block A2, etc. On this basis, referring to fig. 2D, a template diagram corresponding to the reference image block B2' is shown. In fig. 2D, taking W as an example of the lateral length of the candidate image block A2, that is, W is the lateral length of the reference image block B2'; taking S as an example 1/3 of the longitudinal length of the candidate image block A2, i.e. S is 1/3 of the longitudinal length of 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 can be configured empirically, the value of H can be configured empirically, 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 of the lateral length of the candidate image block A3, and so on. On this basis, referring to fig. 2D, a template diagram corresponding to the reference image block B3' is shown, where H is taken as an example of the longitudinal length of the candidate image block A3, and R is taken as an example of 1/3 of the lateral length of the candidate image block A3.
Similarly, the template page corresponding to the reference image block B4' may be shown in fig. 2D, and will not be described herein.
In one example, assuming that there are M candidate image blocks of different modes above the current image block, then for the ith candidate image block, assume its lateral length is w i The prediction mode of the candidate image block is determined.
If the mode is in the intra mode, the sub-template is not generated, or is filled according to a default value (such as a default pixel value, which may be a luminance value preset according to experience), and is used as the ith sub-template of the upper template.
In the case of inter mode, motion information (such as motion vector and reference frame index) of the ith candidate image block is obtained, and a transverse length w is generated based on the motion vector and the reference frame index i The template having a 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 transverse length w with the relative position offset MV is found in the idx-th reference image of the current frame i Rectangular blocks with a longitudinal length of S are used as the ith sub-template of the upper template.
Assuming that there are N candidate image blocks of different modes on the left side of the current image block, for the ith candidate image block, assume that the longitudinal length is h i And judging the prediction mode of the candidate image block if the transverse length is R.
If the mode is in the intra mode, the sub-template is not generated, or is filled according to a default value (such as a default pixel value, which may be a luminance value preset according to experience), and is used as the i sub-template of the left template.
If the mode is inter 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 transverse length R and a longitudinal length h are generated based on the motion vector and the reference frame index i As the ith sub-template of the left-hand template. Specifically, if the motion vector is MV and the reference frame index is idx, the transverse length R and the longitudinal length of the relative position offset MV are found in the idx-th reference image of the current frameLength h i As the ith sub-template of the left-side template.
Further, the upper template can be formed by splicing all the sub-templates on the upper side, the left template can be formed by splicing all the sub-templates on the left side, and the upper template and the left template are spliced into the template of the current image block.
And a second case: referring to fig. 2E, the candidate image block may include a neighboring image block of the first inter mode on the upper side of the current image block and a neighboring image block of the first inter mode on the left side of the current image block.
For the current image block A1, if the first image block A3 on the left is the inter mode, the image block A3 may be determined as a candidate image block for the current image block A1. If the first image block A2 on the upper side is the inter mode, the image block A2 may be determined as a candidate image block for the current image block A1.
If there is no available image block on the left side, or if the first image block on the left side is in intra mode, there is no candidate image block on the left side of the current image block A1. If there is no available image block on the upper side, or if 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 A1. If there is no candidate block on both the left side and the upper side, the current block A1 has no candidate block.
Further, if the current image block A1 does not have a candidate image block, the technical solution of the embodiment is not adopted, but a conventional manner is adopted, which is not described herein. If the current image block A1 has a candidate image block, for example, a left candidate image block and/or an upper candidate image block, the technical solution of this embodiment is adopted.
After determining that the candidate image block is 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, a 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 may be selected from the reference frame images, the image block B2 may be moved according to the neighboring motion vector of the image block A2, the reference image block B2 'corresponding to the image block A2 may be obtained, 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 one example, assuming that the lateral length of the upper template of the current image block A1 is W and the longitudinal length is S, the value of W may be empirically configured, the value of S may be empirically configured, and neither the values of W nor S are 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 of the longitudinal length of the candidate image block A2, and so on. Referring to fig. 2F, a template diagram corresponding to the reference image block B2' is shown.
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 can be configured empirically, the value of H can be configured empirically, 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, etc., R may be the lateral length of the candidate image block A3, 1/3 of the lateral length of the candidate image block A3, etc. On this basis, referring to fig. 2F, a template diagram corresponding to the reference image block B3' is shown.
In one example, assuming that there are M candidate image blocks of different modes on the upper side of the current image block, for the first candidate image block on the upper side, assuming that the lateral length is w, the prediction mode of the candidate image block is determined. If the mode is intra mode, the template is not generated again, or is filled in according to a default value (such as a default pixel value, which may be a luminance value preset according to experience), and the template is used as an upper template. And if the mode is an inter mode, acquiring motion information (such as a motion vector, a reference frame index and the like) of the candidate image block, and generating a template with the transverse length w and the longitudinal length S as an upper template based on the motion vector and the reference frame index.
Assuming that there are N candidate image blocks of different modes on the left side of the current image block, and assuming that the longitudinal length is h and the transverse length is R for the first candidate image block on the left side, judging the prediction mode of the candidate image block. If the mode is in the intra mode, the template is not generated again, or is filled according to a default value to be used as a left template. And if the mode is an inter mode, acquiring motion information (such as a motion vector and a reference frame index) of the candidate image block, and generating a template with a transverse length of R and a longitudinal length of h based on the motion vector and the reference frame index as a left template.
And a third case: referring to fig. 2G, the candidate image block may include a neighboring image block of the first inter mode on the upper side of the current image block and a neighboring image block of the first inter mode on the left side of the current image block.
Compared with fig. 2F of the second case, in the third case, the transverse length W of the upper template of the current image block A1 is valued as the transverse length of the current image block A1, the longitudinal length H of the left template of the current image block A1 is valued as the longitudinal length of the current image block A1, and other processes are similar to the second case and will not be repeated.
Case four: referring to fig. 2H, the candidate image block may include an adjacent image block of an inter mode at an upper side of the current image block, a next adjacent image block of an inter mode at an upper side of the current image block (i.e., when the adjacent image block is an intra mode, an image block corresponding to the adjacent image block is selected to be next adjacent to the current image block), an adjacent image block of an inter mode at a left side of the current image block, and a next adjacent image block at a left side of the current image block.
For example, for the current image block A1, there is an adjacent image block of the inter mode, such as image block A3 and image block A4, on the left side, and then image block A3 and image block A4 of the inter mode may be determined as candidate image blocks for the current image block A1. Similarly, if there is an adjacent image block of the inter mode on the upper side, such as image block A2, then image block A2 of the inter mode may be determined as a candidate image block for the current image block A1.
In addition, there is an adjacent image block of the intra mode, such as image block A7, on the left side, and there is an image block A8 of the inter mode on the left side of image block A7, that is, image block A8 is a next-adjacent image block on the left side of the current image block A1, and therefore, image block A8 of the inter mode can be determined as a candidate image block of the current image block A1.
Similarly, there is an adjacent image block of the intra mode at the upper side, such as image block A5, and there is an image block A6 of the inter mode at the upper side of image block A5, that is, image block A6 is a next-adjacent image block at the upper side of the current image block A1, and therefore, image block A6 of the inter mode can be determined as a candidate image block of the current image block A1.
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, the 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, and the specific obtaining mode is the case, but the template is obtained according to the motion information of the image block A6 and the motion information of the image block A8, which is not repeated herein, and finally the template is shown in fig. 2I.
Case five: referring to fig. 2J, if a first neighboring image block above a current image block is intra-mode and an image block above the first neighboring image block is inter-mode, the candidate image block may include a next neighboring image block of inter-mode above the current image block. In addition, if the first neighboring image block to the left of the current image block is in the intra mode and the image block to the left of the first neighboring image block is in the inter mode, the candidate image block may include a next neighboring image block of the inter mode to the left of the current image block.
For the current image block A1, if the first image block A2 on the upper side is an intra-frame type and there is an image block A4 of the inter-frame type on the upper side of the image block A2, that is, the image block A4 is a next-adjacent image block on the upper side of the current image block A1, the image block A4 of the inter-frame type may be determined as a candidate image block of the current image block A1.
In addition, if the first image block A3 on the left side is intra-mode, and there is an image block A5 on the left side of the image block A3 in inter-mode, that is, the image block A5 is a next-adjacent image block on the left side of the current image block A1, the image block A5 in inter-mode can be determined as a candidate image block of the current image block A1.
After determining that the candidate image block is the image block A4 and the image block A5, the 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, and specific obtaining manners refer to the second case and the third case, which are not described herein again, and the template is finally shown in fig. 2K or fig. 2L.
Case six: referring to fig. 2H, the candidate image block may include an inter-mode neighboring image block on the upper side of the current image block, an intra-mode neighboring image block on the upper side of the current image block, an inter-mode neighboring image block on the left side of the current image block, and an intra-mode neighboring image block on the left side of the current image block.
For example, for the current image block A1, there is an adjacent image block of the inter mode, such as image block A3 and image block A4, on the left side, and then image block A3 and image block A4 of the inter mode may be determined as candidate image blocks for the current image block A1. Similarly, if there is an adjacent image block of the inter mode on the upper side, such as image block A2, then image block A2 of the inter mode may be determined as a candidate image block for the current image block A1.
To the left, there is an adjacent image block of the intra mode, such as image block A7, and the image block A7 of the intra mode may be determined as a candidate image block for the current image block A1. On the upper side there is an adjacent image block of the intra mode, such as image block A5, the image block A5 of the intra mode can be determined as a candidate image block for the current image block A1.
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, the 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, and the specific obtaining mode is the case, but the template is obtained according to the motion information of the image block A5 and the motion information of the image block A7, which is not repeated herein, and finally the template is 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 intra-frame and has no motion information, the motion information of the adjacent image block (i.e., the image block A6) of the image block A5 can 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 can be obtained by using the motion information of the image block A5, for example, the specific obtaining manner is referred to in the first case.
Similarly, in acquiring the template from the motion information of the image block A7, since the image block A7 is intra-frame type and has no motion information, it is possible to determine the motion information of the neighboring image block of 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 A5.
Case seven: referring to fig. 2J, if a first neighboring image block on the upper side of the current image block is intra-mode and the image block on the upper side of the first neighboring image block is inter-mode, the candidate image block may include the neighboring image block of the first intra-mode on the upper side of the current image block. In addition, if the first neighboring image block to the left of the current image block is in the intra mode and the image block to the left of the first neighboring image block is in the inter mode, the candidate image block may include the neighboring image block of the first intra mode to the left of the current image block.
For the current image block A1, if the first image block A2 on the upper side is in the intra-frame mode, the image block A4 in the inter-frame mode exists on the upper side of the image block A2, and the image block A2 in the intra-frame mode is determined as a candidate image block of the current image block A1. If the first image block A3 on the left side is in the intra-frame mode, there is an image block A5 on the left side of the image block A3 in the inter-frame mode, and the image block A3 in the intra-frame mode is determined as a candidate image block of the current image block A1.
After determining that the candidate image block is 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, and specific obtaining manners refer to the second case and the third case, which are not described herein again, and the template is finally shown in fig. 2N or fig. 2O.
It is to be noted that, in acquiring the template from the motion information of the image block A2, since the image block A2 is intra-mode and does not have motion information, it is possible to determine the motion information of the 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 A2. In acquiring the template from the motion information of the image block A3, since the image block A3 is intra-mode and has no motion information, it is possible to determine the motion information of the adjacent image block of the image block A3 (i.e., 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.
Embodiment III:
in inter-frame coding techniques, a motion vector may be 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. For example, video image a is a current frame video image, image block A1 is a current image block, video image B is a reference frame video image of video image a, and image block B1 is a reference image block of image block A1. Because of the strong time-domain correlation between the video image a and the video image B, when the image block A1 of the video image a needs to be transmitted, a motion search can be performed in the video image B to find the image block B1 that is the best match with the image block A1, and the relative displacement between the image block A1 and the image block B1, that is, the motion vector of the image block A1, is determined.
For example, the motion vector is (-6, 4), which indicates that the image block B1 is shifted by 6 pixels to the left in the horizontal direction and by 4 pixels to the up in the vertical direction compared to the image block A1.
When the encoding end transmits the encoded bit stream to the decoding end, the encoded bit stream carries the motion vector (-6, 4) of the image block A1, and is not the image block A1. After receiving the encoded bit stream, the decoding end can obtain the motion vector (-6, 4) of the image block A1, and determine the position of the image block B1 in the video image B based on the position of the image block A1 and the motion vector (-6, 4), that is: at the position of the image block A1, 6 pixels are moved leftward, 4 pixels are moved upward, 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, the image with high similarity can be reconstructed by reconstructing the image block A1 by using the image block B1. Since the number of bits occupied by the motion vector is smaller than that occupied by the image block A1, a large number of bits are saved by carrying the motion vector in the encoded bitstream instead of carrying the image block A1.
Further, if the video image a includes a large number of image blocks, the motion vector of each image block also occupies a relatively large number of bits, so, 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 the adjacent image blocks. For example, in the video image a, the image block adjacent to the image block A1 may include: the image block A2 and the image block A3 may include a motion vector a21 of the image block A2 and a motion vector a31 of the image block A3 in the motion vector list.
When the encoding end sends the encoded bit stream to the decoding end, the encoded bit stream 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 the image block A1, and even instead of the image block A1. After receiving the encoded bit stream, the decoding end can obtain the index value of the original motion vector a21, and obtain the original motion vector a21 from the motion vector list according to the index value. Since the index value occupies a smaller number of bits than the motion vector, bits can be further saved.
In the present embodiment, instead of directly taking 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 acquired from the original motion vector a21, the target motion vector being closest to the motion vector of the image block A1, and thus the target motion vector can be taken as the final motion vector of the image block A1. Obviously, compared with the mode of 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, wrong prediction and the like.
In this embodiment, the original motion information is an original motion vector of the current image block, the target motion information is a target motion vector of the current image block, and fig. 3 is a schematic flow chart of the encoding method.
In step 301, the encoding end obtains motion information of a candidate image block of the current image block.
In 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.
Prior to step 303, the original motion vector of the current image block may be obtained, for example, assuming that 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, one motion vector may be selected from the motion vector list, and the selected motion vector is the original motion vector of the image block A1. Of course, the above manner is merely an example, and is not limited thereto, and for example, the default motion vector may be directly determined as the original motion vector.
Wherein, the encoding end selects a motion vector from the motion vector list, which may include: the encoding end selects a first motion vector from the motion vector list; alternatively, the last motion vector is selected from the motion vector list; alternatively, the first motion vector is randomly selected from the motion vector list; alternatively, a hash algorithm is used to select the first motion vector from the list of motion vectors. Of course, the above manner is just a few examples, and is not limited thereto, as long as a motion vector can be selected from a motion vector list.
Wherein the motion vector list is used for recording motion vectors of image blocks adjacent to the current image block. For example, after the motion vector a21 of the image block A2 is obtained, the motion vector a21 may be recorded to the motion vector list, after the motion vector a31 of the image block A3 is obtained, the motion vector a31 may be recorded to the motion vector list, and so on, finally, the motion vector list of the image block A1 may be obtained.
Specifically, the encoding end may acquire 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 the final motion vector of the current image block as the target motion vector, and the coding end sends a coding bit stream carrying first indication information to the decoding end. When the coding performance of the original motion vector is better than that of the target motion vector, the coding end determines that the final motion vector of the current image block is the original motion vector, and the coding end sends a coding bit stream carrying second indication information to the decoding end.
The first indication information or the second indication information is notified in a display manner, and in practical application, the first indication information or the second indication information may be notified in an implicit manner, that is, the first indication information or the second indication information is not carried in the encoded bitstream. Specifically, the encoding end and the decoding end can also negotiate a motion vector decision strategy or define a strategy at a standard, and the motion vector decision strategy is stored at the encoding end and the decoding end, for example, the motion vector decision strategy can be default first strategy information, default second strategy information or default third strategy information.
When the motion vector decision strategy is the default first strategy information and the coding performance of the target motion vector is better than that of the original motion vector, the first indication information and the second indication information can not be carried in the coded bit stream. When the motion vector decision strategy is the default second strategy information and the coding performance of the original motion vector is better than that of the target motion vector, the first indication information and the second indication information can not be carried in the coded bit stream. For another example, when the motion vector decision policy is the third policy information and the neighboring image block adopts the first policy information, the coding performance of the target motion vector is better than that of the original motion vector, the first indication information and the second indication information may not be carried in the coded bitstream; when the adjacent image block adopts the second strategy information, the coding performance of the original motion vector is better than that of the target motion vector, the first indication information and the second indication information can not be carried in the coded bit stream.
In one example, the encoding end may also 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 the motion vector a21 and the motion vector a21 is the first motion vector of 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 can be referred to the subsequent embodiment, and detailed description is omitted in this embodiment.
In 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, and the final motion vector of the current image block is determined according to the target motion vector instead of the final motion vector of the current image block, so that the accuracy of the motion vector is improved, and the coding 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 template of the current image block. For example, prior to the reconstruction stage of decoding, a template for the current image block may be obtained and the target motion vector derived from the template for the current image block.
Embodiment four:
on the basis of the third embodiment, a target motion vector based on the template is obtained according to the original motion vector corresponding to the current image block and the acquired template, and the implementation flow can be as shown in fig. 4A, and may include:
in step 401, the encoding end determines the original motion vector as a center 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.
Wherein, the determining the edge motion vector corresponding to the center motion vector by the encoding end may include: the center motion vector (x, y) is shifted by S in different directions, 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 center motion vector (x, y) can be shifted to the right by S to obtain an edge motion vector (x+s, y); in the vertical direction, the center motion vector (x, y) may be shifted upward by S to obtain 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, such as 2, 4, 8, 16, etc.
Assuming that the center motion vector is (3, 3), and S is 4, the edge motion vector is an edge motion vector (7, 3), an edge motion vector (3, 7), an edge motion vector (-1, 3), or an edge motion vector (3, -1).
In the first case, the coding end obtains the coding performance of the center 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 center 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 offset based on the center motion vector. Specifically, the encoding end can determine the prediction performance of the center 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 center motion vector according to the prediction performance of the center motion vector; for example, the coding performance of the center motion vector may be determined based on the prediction performance and the actual number of bits required for coding.
Wherein, the parameter information can be brightness value; alternatively, luminance values and chrominance values may be used.
Assuming that the parameter information is a luminance value, in order to determine the coding performance of the center motion vector, the luminance value of the template of the current image block and the luminance value of the first target reference block may be acquired first. For example, after obtaining the template of the current image block, the luminance value of each pixel of the template may be obtained, and the reference image block of the template may be obtained, and assuming that the center motion vector is (3, 3), the reference image block may be moved by using the center motion vector (3, 3), to obtain an image block X corresponding to the reference image block (for example, the reference image block is moved to the right by 3 pixels, moved up by 3 pixels, and the processed image block is referred to as an image block X), where the image block X is the first target reference block, and the luminance value of each pixel of the image block X may be obtained.
Based on the luminance value of each pixel of the template and the luminance value of each pixel of the image block X, the prediction performance of the center motion vector can be determined by adopting the following formula:SAD is the sum of available absolute differences that is used to represent the prediction performance of the center motion vector. TM (TM) i Representing the luminance value, TMP, of the ith pixel point of the template i The luminance value of the ith pixel point of the image block X is represented, and M represents the total number of pixel points.
Assuming that the parameter information is a luminance value and a chrominance value, the following formula is usedDetermining a luminance value prediction performance SAD of the center motion vector, and determining a chrominance value prediction performance of the center motion vector by adopting the following formula:luminance value prediction performance SAD and chrominance value predictionThe average value of the test performance CSAD is the predicted performance of the center motion vector. Wherein CSAD is the sum of available absolute differences for representing chroma prediction performance of a center motion vector, CTM i Representing the chromaticity value of the ith pixel point of the template, CTMP i Representing the chromaticity value, M, of the ith pixel point of an image block X c Representing the total number of pixels.
Further, after obtaining the prediction performance of the center motion vector, the coding performance of the center motion vector can be determined according to the prediction performance and the actual number of bits required for coding. For example, RDO (Rate Distortion Optimized, rate-distortion principle) may be used to determine the coding performance of the center motion vector, whereas RDO generally uses the following formula to determine the coding performance of the center motion vector: j=d+λ×r. Where J represents coding performance, D represents prediction performance, λ is a lagrangian multiplier, a value configured empirically, and R is the actual number of bits required for coding an image block, i.e. the sum of bits of the encoded bit stream carrying information.
In the second case, the coding end obtains the coding 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 coding performance of the edge 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 can be an image block obtained after the reference image block corresponding to the template is offset based on the edge motion vector. Specifically, the encoding end can 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 center motion vector according to the prediction performance of the edge motion vector; for example, the coding performance of the edge motion vector may be determined based on the prediction performance and the actual number of bits required for coding.
Wherein, the parameter information can be brightness value; alternatively, luminance values and chrominance values may be used.
Case two is similar to case one, except that: in the first case, 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, and in the second case, 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 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.
Specifically, the coding end can select a motion vector with optimal coding performance from the central 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 center motion vector and the edge motion vector and determine the motion vector with the suboptimal coding performance as a target motion vector.
For example, if the motion vector with the optimal coding performance is an edge motion vector (7, 3), the coding end may determine the edge motion vector (7, 3) as a target motion vector. If the motion vector with the optimal coding performance is the center motion vector (3, 3), that is, the original motion vector, the coding end can also determine the motion vector with the suboptimal coding performance (such as the edge motion vector (7, 3) as the target motion vector.
Fifth embodiment:
on the basis of the third embodiment, a target motion vector based on the template is obtained according to the original motion vector corresponding to the current image block and the acquired template, and the implementation flow can be shown in fig. 4B, and may include:
in step 411, the encoding end determines the original motion vector as a center 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.
In step 413, the encoding end obtains the encoding performance of the center 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.
Step 411 to step 413 may refer to step 401 to step 403, and are not described herein.
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.
The iteration end condition may include, but is not limited to: the number of iterations reaches a number threshold, 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 are just a few examples of iteration end conditions, and the iteration end conditions are not limited thereto.
In step 415, the encoding end selects a motion vector with optimal encoding performance from the center motion vector and the edge motion vector, determines the motion vector with optimal encoding performance as the center motion vector, and returns to step 412.
For example, if the motion vector with the optimal coding performance is an edge motion vector (7, 3), the edge motion vector (7, 3) may be determined as a center motion vector, step 412 may be re-performed, and so on.
When step 412 is performed for the first time, the value of the parameter S may be an initial value, for example, may be 16. When step 412 is executed again, the value of the parameter S is adjusted, for example, the value is adjusted to be the last parameter S minus 2, or to be half of the last parameter S, which is not limited to this, but only smaller than the last parameter S. 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, e.g. 1. If not, step 412 may be performed based on the adjusted parameter S, and the process will not be described again. If so, the value of the parameter S may be set to 1, and step 412 may be performed based on the parameter S (i.e., the value of 1), and when the step 414 is performed, the result is that 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 in step 416 may refer to step 404, and a detailed description thereof will not be repeated here.
Example six:
in the third embodiment, the coding performance of the original motion vector and the coding performance of the target motion vector may be obtained, and the coding end obtains the coding performance of the original motion vector, which may include, but is not limited to: and determining the coding 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 offset based on the original motion vector. Specifically, the prediction performance of the original motion vector can be determined according to the parameter information of the template and the parameter information of the third target reference block, and the coding performance of the original motion vector can be determined according to the prediction performance; for example, the coding performance of the original motion vector is determined based on the prediction performance and the actual number of bits required for coding. Wherein, the parameter information can be brightness value; or, luminance and chrominance values.
The encoding end obtains the encoding performance of the target motion vector, which 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 offset based on the target motion vector. Specifically, the prediction performance of the target motion vector can be determined according to the parameter information of the template and the parameter information of the fourth target reference block, and the coding performance of the target motion vector can be determined according to the prediction performance; for example, the coding performance of the target motion vector is determined based on the prediction performance and the actual number of bits required for coding. Wherein, the parameter information can be brightness value; or, luminance and chrominance values.
The above procedure is similar to that of embodiment three, 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 for moving the reference image block of the template, instead of using the center motion vector for moving the reference image block of the template, and the description is not repeated here.
Embodiment 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 the above, the encoding end can 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 bit stream may be encoded according to the target motion vector and the target reference frame to obtain an encoded bit stream, and the encoded bit stream may be transmitted to a decoding end.
In one example, the encoding end may first obtain the 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 A1. Of course, the above manner is merely an example, and is not limited thereto, and for example, the default motion vector may be directly determined as the original motion vector.
In one example, the process of obtaining the original reference frame of the current image block by the encoding end may have one or more reference frames (video frames with strong temporal correlation) for the current image block, one of the reference frames may be used as the original reference frame, and the remaining reference frames are candidate reference frames, where in this embodiment, the target reference frame needs to be selected from the original reference frame and all candidate reference frames, and the target reference frame, that is, the final reference frame of the current image block, is used for subsequent processing.
In an example, the process of the encoding end obtaining 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 be referred to in the following embodiments, which are not described herein. For example, the motion vector a21 is determined as an original motion vector, the reference frame 1 is determined as an original reference frame, the reference frame 2 and the reference frame 3 are determined as candidate reference frames, and then the original motion vector a21, the reference frame 1, the reference frame 2 and the reference frame 3 are used to acquire a target motion vector and a target reference frame, the target motion vector being a final motion vector of the current image block, the target reference frame being a certain reference frame among the reference frame 1, the reference frame 2 and the reference frame 3, and the target reference frame being a final reference frame of the current image block.
In one example, the encoding end encodes the bit stream according to the target motion vector and the target reference frame to obtain an encoded bit stream, and sends the encoded bit stream to the decoding end, which may include, but is not limited to: after the encoding end obtains the target motion vector and the target reference frame, the encoding end can encode the current image block by utilizing the target motion vector and the target reference frame, the encoding mode is not limited, and after the encoding is finished, the encoding end can obtain an encoding bit stream and send the encoding bit stream to the decoding end.
The encoding end may send the encoded bitstream to the decoding end according to the original motion vector and the target motion vector. Specifically, the coding performance of the original motion vector and the coding 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 a coded bit stream carrying first indication information to a decoding end. When the coding performance of the original motion vector is better than that of the target motion vector, the coding bit stream carrying the second indication information is sent to the decoding end.
The process of the encoding end obtaining the encoding performance of the original motion vector and the encoding performance of the target motion vector can be referred to the above-mentioned sixth embodiment, and in this embodiment, details are not described here.
The method adopts a display mode to inform the first indication information or the second indication information, in practical application, the first indication information or the second indication information can also be informed in an implicit mode, namely, 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 can also negotiate a decision strategy or define the strategy at a standard, and the decision strategy can be stored at the coding end and the decoding end as default first strategy information; or default second policy information; or defaulting to third policy information, wherein the third policy information is policy information which is the same as that of 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 encoded bitstream, and the detailed process is described in the third embodiment, which is not described herein.
In one example, the encoding end sends the encoded bitstream to the decoding end according to the original motion vector and the target motion vector, and 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 the motion vector a21 and the 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 utilizing the original reference frame, so that the accuracy 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 obtained quickly, the coding efficiency can be improved, the coding delay can be reduced, and the template of the current image block can be obtained before the reconstruction stage of coding.
Example eight:
on the basis of the seventh embodiment, the encoding end obtains 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 template, and the implementation flow can be seen 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 one example, the encoding end obtains, based on the template of the current image block, a candidate motion vector corresponding to the original reference frame according to the original motion vector, which may include, but is not limited to: the coding end determines the original motion vector as a center motion vector and determines an edge motion vector corresponding to the center motion vector, wherein the edge motion vector is different from the center motion vector; the coding end obtains the coding performance of the center 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; then, the encoding end may determine candidate motion vectors 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.
The process of the encoding end obtaining the candidate motion vector of the original reference frame according to the original motion vector can refer to the fourth embodiment or the fifth embodiment, and only the target motion vector in the fourth embodiment or the fifth embodiment is replaced by the candidate motion vector of the original reference frame, which is not repeated herein.
In step 422, the encoding end obtains the initial motion vector corresponding to each candidate reference frame (e.g., each candidate reference frame of the one or more candidate reference frames) according to the original motion vector.
In one example, the encoding end obtains initial motion vectors corresponding to each candidate reference frame according to the original motion vectors, which may include: the first candidate reference frame is any one of candidate reference frames, and for the first candidate reference frame, the initial motion vector of the first candidate reference frame can be obtained according to the distance between the frame where the current image block is located and the original reference frame (for example, the distance can be the frame number between the frame where the current image block is located and the original reference frame), the 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 a motion vector 1, the original reference frame is a reference frame 1, the candidate reference frames are a reference frame 2 and a reference frame 3, the distance between the frame where the current image block is located (hereinafter referred to as the current frame) and the reference frame 1 is d1, the distance between the current frame and the reference frame 2 is d2, and the distance between the current frame and the reference frame 3 is d3, then: the initial motion vector corresponding to the reference frame 2 is the motion vector 1 (d 2/d 1), which is subsequently denoted as the motion vector 2, and the initial motion vector corresponding to the reference frame 3 is the motion vector 1 (d 3/d 1), which is subsequently denoted as the motion vector 3.
In step 423, the encoding end obtains the candidate motion vector corresponding to the candidate reference frame according to the initial motion vector.
In one example, the encoding end obtains the 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, for which the encoding end may determine an initial motion vector of the first candidate reference frame as a center motion vector, and determine an edge motion vector corresponding to the center motion vector, the edge motion vector being different from the center motion vector; the coding end can obtain the coding performance of the center motion vector according to the template of the current image block and obtain the coding 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.
Wherein, for each candidate reference frame, the candidate motion vector of the candidate reference frame can be obtained according to the initial motion vector of the candidate reference frame, i.e. each candidate reference frame corresponds to one candidate motion vector.
The process that the encoding end obtains the candidate motion vector of the candidate reference frame according to the initial motion vector of the candidate reference frame may refer to the fourth embodiment or the fifth embodiment, and only the target motion vector in the fourth embodiment or the fifth embodiment is replaced by the candidate motion vector of the candidate reference frame, and the original motion vector in the fourth embodiment or the fifth embodiment is replaced by the initial motion vector of the candidate reference frame, which is not described herein.
In step 424, the encoding end selects a candidate motion vector with optimal encoding performance from the candidate motion vectors corresponding to the original reference frames and the candidate motion vectors corresponding to the candidate reference frames.
For example, after the encoding end obtains the candidate motion vectors corresponding to the original reference frames and the candidate motion vectors corresponding to the candidate reference frames, the encoding performance of each candidate motion vector may be obtained, and the specific obtaining manner refers to the fourth embodiment, and the central motion vector of the fourth embodiment is replaced by the candidate motion vector, which is not described herein again. After the coding end obtains the coding performance of each candidate motion vector, the coding end can select the candidate motion vector with the optimal coding performance, and the selection process is not repeated.
In step 425, the encoding end determines the candidate motion vector with the optimal encoding performance as the target motion vector, and determines the reference frame corresponding to the candidate motion vector with the optimal encoding performance as the target reference frame.
For example, when the candidate motion vector with the optimal 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 optimal 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. The target motion vector (i.e. the candidate motion vector with the optimal coding performance) is selected from the candidate motion vectors corresponding to the original reference frame and the candidate motion vectors corresponding to all the candidate reference frames, and the target motion vector is the final motion vector of the current image block.
Example nine:
referring to fig. 5, a flow chart of a motion vector determination method is shown, and the method may include:
in step 501, the decoding end obtains motion information of a candidate image block of the current image block.
Wherein the candidate image blocks of the current image block may include, but are not limited to: spatial domain candidate image blocks of the current image block; or, a temporal candidate image block of the current image block; the candidate image block is not limited.
Wherein the motion information of the candidate image block may include, but is not limited to: the original motion information corresponding to the candidate image block, such as an original motion vector, or the original motion vector and an original reference frame. The final motion information, such as the final motion vector, or the final motion vector and the final reference frame, corresponding to the candidate image block.
In one example, the final motion information of the current image block is only used for decoding of the current image block (decoding process of prediction value generation, reconstruction, etc. of the current image block), and is not used for prediction of the neighboring image block, i.e., the motion information obtained from the candidate image block is the original motion information of the candidate block, and is 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 saved, but the original motion information is saved, namely, the motion information of the current image block is restored to the original motion information.
In one example, the decoding end may store the motion information corresponding to the candidate image block, such as storing the original motion information corresponding to the candidate image block as the motion information of the candidate block or storing the 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 (such as 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 the original motion vector. For another example, motion information of neighboring image blocks of the candidate image block may be determined as original motion information corresponding to the candidate image block.
The above manner is merely an example of acquiring the original motion information of the candidate image block, and is not limited thereto.
The method for the decoding side to obtain the template of the current image block according to the motion information of the candidate image block is the same as that of the encoding side, and specifically, refer to the related content of the second embodiment, which is not described herein again.
In step 503, 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. Wherein the original motion information includes an original motion vector and the target motion information includes a target motion vector. Alternatively, 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 comprises an original motion vector and the target motion information comprises 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 acquired template, and the method comprises the following steps: determining the original motion vector as a center 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 center motion vector and the coding performance of the edge motion vector according to the template; and determining 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.
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 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, acquiring a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to each candidate reference frame 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 candidate motion vectors corresponding to the original reference frames and 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 one example, before the decoding end obtains the motion information of the candidate image block of the current image block, the decoding end may also obtain an encoded bitstream, where the encoded bitstream may be sent by the encoding end, or may be obtained after the encoding end encodes the bitstream, which is not limited, and the encoding end sends the encoded bitstream as an example.
The decoding end may receive the encoded bitstream from the encoding end, and when the encoded bitstream carries the first indication information, the first indication information is used to indicate that final motion information of the current image block is determined based on the template, and may obtain motion information of a candidate image block of the current image block according to the first indication information, and obtain the template of the current image block according to the motion information of the candidate image block, that is, execute the steps 501-503.
The decoding end may receive the encoded bitstream from the encoding end, and when the encoded bitstream carries second indication information, 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 original motion information corresponding to the current image block is obtained according to the second indication information, and the final motion information of the current image block is determined according to the original motion information.
In the above manner, the first indication information or the second indication information is notified by adopting a display manner, and in practical application, the encoding end may also notify by adopting an implicit manner, that is, the encoded bitstream does not carry the first indication information or the second indication information. Based on the motion information, the decoding end can acquire the motion information of the candidate image block of the current image block according to the first strategy information preset locally, and acquire the template of the current image block according to the motion information of the candidate image block, wherein the first strategy information is used for indicating to determine the final motion information of the current image block based on the template; or, according to the locally preset second strategy information, the original motion information corresponding to the current image block can be obtained; determining final motion information of the current image block according to the original motion information, wherein the second strategy information is used for indicating to determine the final motion information of the current image block based on the original motion information corresponding to the current image block; alternatively, third policy information may be acquired, where the third policy information is to determine final motion information of the current image block using the same policy information as the neighboring image blocks of the current image block; then, final motion information of the current image block is determined according to the third policy information.
Specifically, the encoding end and the decoding end can also negotiate a motion vector decision strategy or define a strategy at a standard, and the strategy is stored at the encoding end and the decoding end, for example, the motion vector decision strategy can be default first strategy information; or default second policy information; or default third policy information.
When the motion vector decision strategy is default first strategy information, acquiring motion information of candidate image blocks of the current image block according to the first strategy information preset locally, and acquiring templates of the current image block according to the motion information of the candidate image blocks; when the motion vector decision strategy is the default second strategy information, acquiring original motion information corresponding to the current image block according to the locally preset second strategy information; determining final motion information of the current image block according to the original motion information; when the motion vector decision strategy is the third strategy information, if the strategy information of the adjacent image block is the first strategy information, the motion information of the candidate image block of the current image block is obtained, and the template of the current image block is obtained according to the motion information of the candidate image block; if the strategy information of the adjacent image block is the second strategy information, acquiring the 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 one example, before the template-based target motion information is obtained according to the original motion information corresponding to the current image block and the obtained template, the decoding end may further receive an encoded bitstream from the encoding end, where the encoded bitstream carries an index value of the original motion vector in the 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 an 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 acquired, and the motion vector is the original motion vector of the current image block. The motion vector list is used for recording the motion vector of the image block 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 manner is just 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 the decoding end to obtain the target motion information based on the template according to the original motion information corresponding to the current image block and the obtained template can be referred to the subsequent embodiments, and will not be described herein.
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 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, and in one example, the original motion vector of the current image block and the target original motion vector may be compared with each other in terms of coding performance, and a motion vector with better performance may be used as the final motion vector.
In step 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 of other image blocks, if the current image block is selected as the candidate image block of the other image blocks, 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 obtain 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 sub-neighboring block), the original motion information corresponding to the current image block is stored 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 neighboring block (or the spatial sub-neighboring 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 from the motion information of the temporal neighboring block, the final motion information corresponding to the current image block is stored 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 includes at least an original motion vector, and when the original motion vector of the current image block is obtained according to the motion vector of the spatial neighboring block, 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 neighboring block, storing the final motion vector corresponding to the current image block as the motion vector of the current image block. For example, when an original motion vector corresponding to a current image block is obtained from a motion vector of a temporal neighboring block, a final motion vector corresponding to the current image block is stored as a motion vector of the current image block; the final motion vector corresponding to the current image block may also be stored as the motion vector of the current image block by default.
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 the final 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 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, and the final motion vector of the current image block is determined according to the target motion vector instead of directly determining the final motion vector of the current image block according to the original motion vector, so that the accuracy of the motion vector is improved, and the decoding performance is improved. Moreover, when the target motion vector is acquired according to the original motion vector, a template of the current image block can be acquired according to the motion information of the candidate image block, and the target motion vector is acquired 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, then obtain the target motion vector according to the template, improve the decoding efficiency and reduce the decoding time delay. For example, a template for the current image block may be obtained and the target motion vector derived from the template prior to the reconstruction stage of decoding.
Furthermore, the decoding end can simultaneously decode a plurality of image blocks in parallel, so that the decoding speed is further improved, the decoding efficiency is improved, 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 process of prediction value generation, reconstruction, etc. of the current image block), and is not used for prediction of the neighboring image block, i.e., the candidate motion information obtained by the neighboring image block is original motion information, not final motion information. After the decoding of the current image block is finished, the final motion information is not saved, but the original motion information is saved, namely, the motion information of the current image block is restored to the original motion information.
Example ten:
in this embodiment, unlike the method 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 the 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, 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 next 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 next-neighbor image block is an inter mode. The second candidate image block comprises an adjacent image block and/or a next adjacent image block on the left 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 next-neighbor image block is an inter mode.
The obtaining of 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, the first template and the second template are spliced and then determined as the template of the current image block.
In one example, when M is greater than 1, the first template may include M sub-templates or P sub-templates, where P is the number of first candidate image blocks in the inter mode, and the first candidate image blocks are formed by splicing the M sub-templates or the P sub-templates; when M is equal to 1, the first template may include a first sub-template determined according to a motion vector prediction mode and motion information of a first candidate image block on an 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 is formed by splicing N sub-templates or R sub-templates, where R is the number of second candidate image blocks in the inter-frame mode; when N is equal to 1, then the second template may include a second sub-template determined from the motion vector prediction mode and the motion information of the first candidate image block to the left of the current image block.
In one example, the template of the current image block is obtained according to the motion information of the candidate image block, and 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 acquiring weight parameters corresponding to each piece of motion information, and acquiring a template of the current image block according to the weight parameters 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 a target motion vector based on the template according to the original motion vector corresponding to the current image block and the obtained template, and the implementation flow may be as shown in fig. 6A, and may include:
in step 601, the decoding end determines the original motion vector as a center 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 an edge motion vector corresponding to the center motion vector may include: and shifting the center 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.
In step 603, the decoding end obtains the coding performance of the center 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 center motion vector according to the template of the current image block, which can include but is not limited to: the decoding end can determine the coding performance of the center 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 is the image block obtained after the reference image block corresponding to the template is offset based on the center motion vector.
The decoding end obtains the coding performance of the edge motion vector according to the template of the current image block, which can include but is not limited to: the decoding end can determine the coding performance of the edge 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 the image block obtained after the reference image block corresponding to the template is offset based on the edge motion vector.
In 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 can select a motion vector with optimal coding performance from the central 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 center motion vector and the edge motion vector and determine the motion vector with the suboptimal coding performance as a target motion vector.
Embodiment 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 a target motion vector based on the template according to the original motion vector corresponding to the current image block and the obtained template, and the implementation process may be shown in fig. 6B, and may include:
in step 611, the decoding end determines the original motion vector as a center 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.
In step 613, the decoding end obtains the coding performance of the center 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.
In step 615, the decoding end selects a motion vector with optimal coding performance from the center motion vector and the edge motion vector, determines the motion vector with optimal coding performance as the center 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 process flow of step 611-step 616 can be seen in the fourth embodiment, but the execution body is changed from the encoding end to the decoding end, and the other process flows are the same, and the detailed description is omitted here.
Embodiment 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 acquire 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 the target motion vector (the target motion vector may be different from the original motion vector) and the 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 a template based on the template of the current image block according to an original motion vector corresponding to the current image block and the original reference frame, and the target motion vector and the target reference frame can include but are not limited to: based on a template of the current image block, acquiring a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to each candidate reference frame according to the initial motion vectors; obtaining candidate motion vectors corresponding to the candidate reference frames according to the initial motion vectors; then, a candidate motion vector with optimal coding performance can be selected from candidate motion vectors corresponding to the original reference frames and 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 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 candidate reference frames, and 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 aiming at the first candidate reference frame.
In one example, based on the template of the current image block, the candidate motion vector corresponding to the original reference frame is obtained according to the original motion vector, which may include, but is not limited to: determining the original motion vector as a center motion vector, and determining an edge motion vector corresponding to the center motion vector, the edge motion vector being different from the center motion vector; then, the coding performance of the center motion vector is obtained according to the template of the current image block, and the coding performance of the edge motion vector is obtained 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 coding performance of the center motion vector and the coding performance of the edge motion vector.
In one example, the obtaining the candidate motion vector corresponding to the candidate reference frame according to the initial motion vector may include, but is not limited to: the method comprises the steps that a first candidate reference frame is any one of candidate reference frames, an initial motion vector of the first candidate reference frame is determined to be a center motion vector aiming at the first candidate reference frame, an edge motion vector corresponding to the center motion vector is determined, and the edge motion vector is different from the center motion vector; obtaining the coding performance of the center motion vector and the coding performance of the edge motion vector according to the template of the current image block; and determining a candidate motion vector corresponding to the first candidate reference frame 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.
Fourteen examples:
based on the same application concept as the above method, the embodiment of the present application further provides a decoding device, applied to a decoding end, as shown in fig. 7, which is a structural diagram of the device, where the device includes:
an obtaining module 71, configured to obtain motion information of a candidate image block of the 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 acquired 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 one 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 neighboring block, storing the original motion information corresponding to the current image block as the motion information of the current image block.
In one 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 neighboring block, storing the final motion information corresponding to the current image block as the motion information of the current image block.
The acquisition module 71 is further configured to: receiving an encoded bit stream from an encoding end, wherein the encoded bit stream carries first indication information, and the first indication information is used for indicating final motion information of the current image block determined based on a template; and acquiring motion information of a candidate image block of the current image block according to the first indication information, and acquiring a template of the current image block according to the motion information of the candidate image block.
The acquisition module 71 is further configured to: receiving an encoded bit stream from an encoding end, wherein the encoded bit stream carries second indication information, and the second indication information is used for indicating to determine final motion information of a current image block 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 acquisition module 71 is further configured to: according to first strategy information preset locally, motion information of a candidate image block of a current image block is obtained, and a template of the current image block is obtained according to the motion information of the candidate image block; the first policy information is used for indicating final motion information of the current image block based on a template; or, according to locally preset second strategy information, acquiring original motion information corresponding to the current image block; determining final motion information of the current image block according to the original motion information; the second strategy information is used for indicating to determine final motion information of the current image block based on original motion information corresponding to the current image block; or, acquiring third strategy information, wherein the third strategy information is that strategy information which is the same as that of an adjacent image block of the current image block is adopted to determine the final motion information of the current image block; and determining final motion information of the current image block according to the third strategy information.
The original motion information includes an original motion vector; the acquisition 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, M is a natural number greater than or equal to 1, 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 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 a 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 a neighboring image block and/or a next neighboring image block on an 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-frame mode; the second candidate image block comprises an adjacent image block and/or a next adjacent image block on the left 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 next-neighbor image block is an inter mode.
In one 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; when M is equal to 1, the first template includes a first sub-template determined according to a motion vector prediction mode and motion information of a first candidate image block on an upper side of the current image block.
The motion information includes motion vectors and reference frame indexes of the first candidate image blocks, and the obtaining module 71 is specifically configured to determine a 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 determining that the motion vector prediction mode of the ith candidate image block is 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 according to the determined reference image block, acquiring an image block with a first transverse length and a first longitudinal length as an ith sub-template included in the first template.
The obtaining module 71 determines a first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks, where the first template 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 an image block with a first transverse length and a first longitudinal length as an ith sub-template included in 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 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 the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with a first transverse length and a first longitudinal length as an ith sub-template included in the first template; 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 adjacent image block of 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 current image block are equal to a second preset length.
In one example, when the N is greater than 1, the second template includes N sub-templates or R sub-templates, and is formed by stitching the N sub-templates or the R sub-templates, where R is the number of second candidate image blocks in the inter-frame mode; when N is equal to 1, the second template includes a second sub-template, which is determined according to a motion vector prediction mode and motion information of a first candidate image block to the left of the current image block.
The motion information includes motion vectors and reference frame indexes of the second candidate image blocks, and the obtaining module 71 is specifically configured to determine a 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 determining that the motion vector prediction mode of the ith candidate image block is 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 according to the determined reference image block, acquiring an image block with a second transverse length and a second longitudinal length as an ith sub-template included in the second template.
The obtaining module 71 determines a second template according to the motion vector prediction modes and the motion information of the N second candidate image blocks, and 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 an image block with a second transverse length and a second longitudinal length as an ith sub-template included in 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 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 the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with a second transverse length and a second longitudinal length as an ith sub-template included in the first template; 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 adjacent image block of 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 meet a sixth proportional relation with the transverse length of the current image block, or are equal to a third preset length;
the second longitudinal length and the longitudinal length of the second candidate image block satisfy a seventh proportional relation, or satisfy an eighth proportional relation with the longitudinal 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 motion information, acquiring a template corresponding to the motion information according to each motion information; and acquiring weight parameters corresponding to each piece of motion information, and acquiring the template of the current image block according to the weight parameters 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 center 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 center motion vector and the coding performance of the edge motion vector according to the template; and determining 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 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, acquiring a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to each candidate reference frame 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 candidate motion vectors corresponding to the original reference frames and 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, the embodiment of the application further provides an encoding device, which is applied to an encoding end, and is shown in fig. 8, and is a structural diagram of the device, and the device 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 acquired 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; encoding the current image block according to the final motion information to obtain an encoded 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.
The processing module 82 is specifically configured to, when 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: and when the original motion information of the current image block is obtained according to the motion information of the spatial neighboring block, storing the original motion information corresponding to the current image block as the motion information of the current image block.
The processing module 82 is specifically configured to, when 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: and when the original motion information of the current image block is not obtained according to the motion information of the spatial neighboring 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, M is a natural number greater than or equal to 1, 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 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 a 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 a neighboring image block and/or a next neighboring image block on an 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-frame mode; the second candidate image block comprises an adjacent image block and/or a next adjacent image block on the left 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 next-neighbor image block is an inter mode.
In one 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; when M is equal to 1, the first template includes a first sub-template determined according to a motion vector prediction mode and motion information of a first candidate image block on an upper side of the current image block.
The motion information includes motion vectors and reference frame indexes of the first candidate image blocks, and the obtaining module 81 is specifically configured to determine a first template according to the motion vector prediction modes and the motion information of M first candidate image blocks: for an ith candidate image block in the M first candidate image blocks, when determining that the motion vector prediction mode of the ith candidate image block is 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 according to the determined reference image block, acquiring an image block with a first transverse length and a first longitudinal length as an ith sub-template included in the first template.
The obtaining module 81 determines a first template according to the motion vector prediction modes and the motion information of the M first candidate image blocks, where the first template is specifically used for: 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 an image block with a first transverse length and a first longitudinal length as an ith sub-template included in 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 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 the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with a first transverse length and a first longitudinal length as an ith sub-template included in the first template; 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 adjacent image block of 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 current image block are equal to a second preset length.
In one example, when the N is greater than 1, the second template includes N sub-templates or R sub-templates, and is formed by stitching the N sub-templates or the R sub-templates, where R is the number of second candidate image blocks in the inter-frame mode; when N is equal to 1, the second template includes a second sub-template, which is determined according to a motion vector prediction mode and motion information of a first candidate image block to the left of the current image block.
The motion information includes motion vectors and reference frame indexes of the second candidate image blocks, and the obtaining module 81 is specifically configured to determine a 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 determining that the motion vector prediction mode of the ith candidate image block is 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 according to the determined reference image block, acquiring an image block with a second transverse length and a second longitudinal length as an ith sub-template included in the second template.
The obtaining module 81 determines, according to the motion vector prediction modes and the motion information of the N second candidate image blocks, a second template specifically for: 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 an image block with a second transverse length and a second longitudinal length as an ith sub-template included in 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 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 the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with a second transverse length and a second longitudinal length as an ith sub-template included in the first template; 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 adjacent image block of 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 meet a sixth proportional relation with the transverse length of the current image block, or are equal to a third preset length;
the second longitudinal length and the longitudinal length of the second candidate image block satisfy a seventh proportional relationship, and the longitudinal length of the second candidate image block and the longitudinal length of the current image block satisfy an eighth proportional relationship or are 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 motion information, acquiring a template corresponding to the motion information according to each motion information; and acquiring weight parameters corresponding to each piece of motion information, and acquiring the template of the current image block according to the weight parameters 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 center 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 center motion vector and the coding performance of the edge motion vector according to the template; and determining 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 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, acquiring a candidate motion vector corresponding to the original reference frame according to the original motion vector; acquiring initial motion vectors corresponding to each candidate reference frame 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 candidate motion vectors corresponding to the original reference frames and 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 target motion vector, and the processing module 82 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 a final motion vector of the current image block as the target motion vector;
The encoding bit stream carries first indication information, wherein the first indication information is used for indicating final motion information of the current image block 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 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 coding performance of the original motion vector is better than that of the target motion vector, determining a final motion vector of the current image block as the original motion vector;
the encoded bitstream carries second indication information, where the second indication information is used to indicate that final motion information of a current image block is determined based on original motion information corresponding to the current image block.
The processing module 82 obtains an index value of the original motion vector in the motion vector list; the encoded bitstream carries the index value.
The processing module 82 is specifically configured to, when acquiring the coding performance of the original motion vector: determining the coding 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 the reference image block corresponding to the template is offset based on the original motion vector;
The processing module 82 is specifically configured to, when acquiring the coding performance of the target motion vector: 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 offset based on the target motion vector.
In the decoding side device provided in the embodiment of the present application, from a hardware level, a schematic diagram of a hardware architecture of the decoding side device may be specifically shown in fig. 9. Comprising 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 examples.
Based on the same application concept as the above method, the embodiments of the present application further provide a machine-readable storage medium, where a number of computer instructions are stored, where the computer instructions can implement the decoding method disclosed in the above example of the present application when executed by a processor.
In the encoding end device provided in the embodiment of the present application, from a hardware level, a schematic diagram of a hardware architecture of the encoding end device may be specifically shown in fig. 10. Comprising 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 examples above.
Based on the same application concept as the above method, the embodiments of the present application further provide a machine-readable storage medium, where a number of computer instructions are stored, where the computer instructions can implement the encoding method disclosed in the above examples of the present application when executed by a processor.
Wherein 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, or the like. For example, a machine-readable storage medium may be: RAM (Radom Access Memory, random access memory), volatile memory, non-volatile memory, flash memory, a storage drive (e.g., hard drive), a solid state drive, any type of storage disk (e.g., optical disk, dvd, etc.), or a similar storage medium, or a combination thereof.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email 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 functionally divided into various units, respectively. Of course, the functions of each element may be implemented in one or more software and/or hardware elements when implemented in the present application.
It will be appreciated by those skilled in the art that 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 on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) 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 flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations 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.
Moreover, 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 foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.
Claims (41)
1. A decoding method, applied to a decoding end, comprising:
acquiring motion information of candidate image blocks of the 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 acquired template;
Determining 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;
the original motion information comprises an original motion vector, the target motion information comprises a target motion vector, and the target motion information based on the template is obtained according to the original motion information corresponding to the current image block and the acquired template, and comprises the following steps: determining the original motion vector as a center 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 a cost value of the center motion vector and a cost value of the edge motion vector according to the template; and determining the target motion vector from the center motion vector and the edge motion vector according to the cost value of the center motion vector and the cost value of the edge motion vector.
2. The method of claim 1, wherein after 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 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 airspace adjacent block, storing the original motion information corresponding to the current image block as the motion information of the current image block; or,
and when the original motion information of the current image block is not obtained according to the motion information of the spatial neighboring 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, wherein the step of determining the position of the substrate comprises,
before the motion information of the candidate image block of the current image block is acquired, the method further includes:
receiving an encoded bit stream from an encoding end, wherein the encoded bit stream carries first indication information, and the first indication information is used for indicating final motion information of the current image block determined based on a template;
and acquiring motion information of a candidate image block of the current image block according to the first indication information, and acquiring a template of the current image block according to the motion information of the candidate image block.
5. The method according to claim 1, wherein the method further comprises:
receiving an encoded bit stream from an encoding end, wherein the encoded bit stream carries second indication information, and the second indication information is used for indicating to determine final motion information of a current image block 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 according to claim 1, wherein the method further comprises:
according to first strategy information preset locally, motion information of a candidate image block of a current image block is obtained, and a template of the current image block is obtained according to the motion information of the candidate image block; the first policy information is used for indicating final motion information of the current image block 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 to determine final motion information of the current image block based on original motion information corresponding to the current image block; or,
Acquiring third strategy information, wherein the third strategy information is to determine final motion information of a current image block by adopting strategy information which is the same as that of an adjacent image block of the current image block;
and determining final motion information of the current image block according to the third strategy information.
7. The method according to any one of claims 1 to 6, wherein the raw motion information comprises raw motion vectors; before the target motion information based on the template is obtained according to the original motion information corresponding to the current image block and the acquired template, the method further comprises:
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 one of claims 1 to 6, wherein the raw motion information comprises raw motion vectors; before the target motion information based on the template is obtained according to the original motion information corresponding to the current image block and the acquired template, the method further comprises:
And determining the motion vector of the candidate image block of the current image block as an original motion vector corresponding to the current image block.
9. The method according to any one of claims 1 to 6, wherein the candidate image blocks include 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 comprises the following steps:
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 a template of the current image block; or,
determining the second template as the template of the current image block; or,
and determining the first template and the second template as templates of the current image block after splicing.
10. The method of claim 9, wherein the step of determining the position of the substrate comprises,
the first candidate image block comprises an adjacent image block and/or a next 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-frame mode; the second candidate image block comprises an adjacent image block and/or a next adjacent image block on the left 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 next-neighbor image block is an inter mode.
11. The method of claim 9, wherein when M is greater than 1, the first template includes M sub-templates or P sub-templates, and is formed by stitching the M sub-templates or the P sub-templates, and P is a number of first candidate image blocks in an inter mode;
when M is equal to 1, the first template includes a first sub-template determined according to a motion vector prediction mode and motion information of a first candidate image block on an upper side of the current image block.
12. The method of claim 11, wherein the motion information comprises a motion vector and a reference frame index for the first candidate image block, wherein determining the first template based on the motion vector prediction modes and the motion information for the M first candidate image blocks comprises:
For an ith candidate image block in the M first candidate image blocks, when determining that the motion vector prediction mode of the ith candidate image block is 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 according to the determined reference image block, acquiring an image block with a first transverse length and a first longitudinal length as an ith sub-template included in the first template.
13. The method of claim 11, wherein determining the first template based on the motion vector prediction modes and the motion information for 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 an image block with a first transverse length and a first longitudinal length as an ith sub-template included in 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 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 the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with a first transverse length and a first longitudinal length as an ith sub-template included in the first template;
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 adjacent image block of the ith candidate image block.
14. The method of claim 12, wherein the step of determining the position of the probe is performed,
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 current image block are equal to a second preset length.
15. The method of claim 9, wherein when the N is greater than 1, the second template includes N sub-templates or R sub-templates, and is formed by stitching the N sub-templates or the R sub-templates, and the R is a number of second candidate image blocks in an inter mode;
when N is equal to 1, the second template includes a second sub-template, which is determined according to a motion vector prediction mode and motion information of a first candidate image block to the left of the current image block.
16. The method of claim 15, wherein the motion information comprises a motion vector and a reference frame index for the second candidate image block, wherein determining the second template based on the motion vector prediction modes and the motion information for the N second candidate image blocks comprises:
for an ith candidate image block in the N second candidate image blocks, when determining that the motion vector prediction mode of the ith candidate image block is 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 according to the determined reference image block, acquiring an image block with a second transverse length and a second longitudinal length as an ith sub-template included in the second template.
17. The method of claim 15, wherein determining the second template based on the motion vector prediction modes and the motion information for 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 an image block with a second transverse length and a second longitudinal length as an ith sub-template included in 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 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 the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with a second transverse length and a second longitudinal length as an ith sub-template included in the first template;
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 adjacent image block of the ith candidate image block.
18. The method of claim 16, wherein the step of determining the position of the probe comprises,
the second transverse length and the transverse length of the second candidate image block meet a fifth proportional relation, or meet a sixth proportional relation with the transverse length of the current image block, or are equal to a third preset length;
the second longitudinal length and the longitudinal length of the second candidate image block satisfy a seventh proportional relation, or satisfy an eighth proportional relation with the longitudinal length of the current image block, or are equal to a fourth preset length.
19. The method according to any one of claim 1 to 6, wherein,
the obtaining the template of the current image block according to the motion information of the candidate image block comprises the following steps:
when the current image block corresponds to a plurality of motion information, acquiring a template corresponding to the motion information according to each motion information;
and acquiring weight parameters corresponding to each piece of motion information, and acquiring a template of the current image block according to the weight parameters 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 and an original reference frame, the target motion information includes a target motion vector and a target reference frame, and obtaining target motion information based on the template according to the original motion information corresponding to the current image block and the acquired template includes:
based on the template of the current image block, acquiring a candidate motion vector corresponding to the original reference frame according to the original motion vector;
acquiring initial motion vectors corresponding to each candidate reference frame 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 cost value from candidate motion vectors corresponding to the original reference frames and candidate motion vectors corresponding to the candidate reference frames;
and determining the candidate motion vector with the optimal cost value as the target motion vector, and determining a reference frame corresponding to the candidate motion vector with the optimal cost value as the target reference frame.
21. A coding method, applied to a coding end, comprising:
Acquiring motion information of candidate image blocks of the 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 acquired template;
determining final motion information of the current image block according to the original motion information and the target motion information;
encoding the current image block according to the final motion information to obtain an encoded bit stream;
the original motion information comprises an original motion vector, the target motion information comprises a target motion vector, and the target motion information based on the template is obtained according to the original motion information corresponding to the current image block and the acquired template, and comprises the following steps: determining the original motion vector as a center 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 a cost value of the center motion vector and a cost value of the edge motion vector according to the template; and determining the target motion vector from the center motion vector and the edge motion vector according to the cost value of the center motion vector and the cost value of the edge motion vector.
22. The method of claim 21, wherein said encoding said current image block according to said final motion information results in an encoded bitstream, said method further comprising:
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.
23. The method of claim 22, 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 airspace adjacent block, storing the original motion information corresponding to the current image block as the motion information of the current image block; or,
and when the original motion information of the current image block is not obtained according to the motion information of the spatial neighboring block, storing the final motion information corresponding to the current image block as the motion information of the current image block.
24. The method of claim 21, 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 comprises the following steps:
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 a template of the current image block; or,
determining the second template as the template of the current image block; or,
and determining the first template and the second template as templates of the current image block after splicing.
25. The method of claim 24, wherein the step of determining the position of the probe is performed,
the first candidate image block comprises an adjacent image block and/or a next 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-frame mode; the second candidate image block comprises an adjacent image block and/or a next adjacent image block on the left 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 next-neighbor image block is an inter mode.
26. The method of claim 24, wherein when M is greater than 1, the first template comprises M sub-templates or P sub-templates, and is formed by stitching the M sub-templates or the P sub-templates, and P is a number of first candidate image blocks in inter-frame mode;
when M is equal to 1, the first template includes a first sub-template determined according to a motion vector prediction mode and motion information of a first candidate image block on an upper side of the current image block.
27. The method of claim 26, wherein the motion information comprises a motion vector and a reference frame index for the first candidate image block, wherein determining the first template based on the motion vector prediction modes and the motion information for the M first candidate image blocks comprises:
for an ith candidate image block in the M first candidate image blocks, when determining that the motion vector prediction mode of the ith candidate image block is 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 according to the determined reference image block, acquiring an image block with a first transverse length and a first longitudinal length as an ith sub-template included in the first template.
28. The method of claim 26, wherein determining the first template based on the motion vector prediction modes and the motion information for 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 an image block with a first transverse length and a first longitudinal length as an ith sub-template included in 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 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 the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with a first transverse length and a first longitudinal length as an ith sub-template included in the first template;
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 adjacent image block of the ith candidate image block.
29. The method according to claim 27 or 28, wherein,
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 current image block are equal to a second preset length.
30. The method of claim 24, wherein when the N is greater than 1, the second template includes N sub-templates or R sub-templates, and is formed by stitching the N sub-templates or the R sub-templates, and the R is a number of second candidate image blocks in an inter mode;
when N is equal to 1, the second template includes a second sub-template, which is determined according to a motion vector prediction mode and motion information of a first candidate image block to the left of the current image block.
31. The method of claim 30, wherein the motion information comprises a motion vector and a reference frame index for the second candidate image block, wherein determining the second template based on the motion vector prediction modes and the motion information for the N second candidate image blocks comprises:
for an ith candidate image block in the N second candidate image blocks, when determining that the motion vector prediction mode of the ith candidate image block is 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 according to the determined reference image block, acquiring an image block with a second transverse length and a second longitudinal length as an ith sub-template included in the second template.
32. The method of claim 30, wherein determining the second template based on the motion vector prediction modes and the motion information for 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 an image block with a second transverse length and a second longitudinal length as an ith sub-template included in 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 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 the motion vector corresponding to the ith candidate image block; according to the determined reference image block, acquiring an image block with a second transverse length and a second longitudinal length as an ith sub-template included in the first template;
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 adjacent image block of the ith candidate image block.
33. The method according to claim 31 or 32, wherein,
the second transverse length and the transverse length of the second candidate image block meet a fifth proportional relation, or meet a sixth proportional relation with the transverse length of the current image block, or are equal to a third preset length;
the second longitudinal length and the longitudinal length of the second candidate image block satisfy a seventh proportional relation, or satisfy an eighth proportional relation with the longitudinal length of the current image block, or are equal to a fourth preset length.
34. The method according to any one of claims 23 to 28, wherein,
the obtaining the template of the current image block according to the motion information of the candidate image block comprises the following steps:
when the current image block corresponds to a plurality of motion information, acquiring a template corresponding to the motion information according to each motion information;
and acquiring weight parameters corresponding to each piece of motion information, and acquiring a template of the current image block according to the weight parameters corresponding to each piece of motion information and the template corresponding to the motion information.
35. The method of claim 21, 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 target motion information based on the template according to the original motion information corresponding to the current image block and the acquired template includes:
Based on the template of the current image block, acquiring a candidate motion vector corresponding to the original reference frame according to the original motion vector;
acquiring initial motion vectors corresponding to each candidate reference frame 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 cost value from candidate motion vectors corresponding to the original reference frames and candidate motion vectors corresponding to the candidate reference frames;
and determining the candidate motion vector with the optimal cost value as the target motion vector, and determining a reference frame corresponding to the candidate motion vector with the optimal cost value as the target reference frame.
36. The method of claim 21, wherein the original motion information comprises an original motion vector and the destination motion information comprises a destination motion vector, wherein determining final motion information for the current image block based on the original motion information and the destination motion information comprises:
acquiring the cost value of the original motion vector and the cost value of the target motion vector;
when the cost value of the target motion vector is superior to the cost value of the original motion vector, determining the final motion vector of the current image block as the target motion vector;
The encoding bit stream carries first indication information, wherein the first indication information is used for indicating final motion information of the current image block determined based on a template.
37. The method of claim 21, wherein the original motion information comprises an original motion vector and the destination motion information comprises a destination motion vector, wherein determining final motion information for the current image block based on the original motion information and the destination motion information comprises:
acquiring the cost value of the original motion vector and the cost value of the target motion vector;
when the cost value of the original motion vector is superior to that of the target motion vector, determining a final motion vector of the current image block as the original motion vector;
the encoded bitstream carries second indication information, where the second indication information is used to indicate that final motion information of a current image block is determined based on original motion information corresponding to the current image block.
38. The method of claim 21, wherein the method further comprises: acquiring an index value of an original motion vector in a motion vector list; the encoded bitstream carries the index value.
39. The method according to claim 36 or 37, wherein,
obtaining the cost value of the original motion vector comprises the following steps:
determining the cost value 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 the reference image block corresponding to the template is offset based on the original motion vector;
obtaining the cost value of the target motion vector comprises the following steps:
and determining the cost value 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 offset based on the target motion vector.
40. A decoding end 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 implement the method steps of any one of claims 1-20.
41. An encoding end 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 implement the method steps of any of claims 21-39.
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 CN110691247A (en) | 2020-01-14 |
CN110691247B true 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) |
Family Cites Families (5)
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 |
CN101686393B (en) * | 2008-09-28 | 2012-10-17 | 华为技术有限公司 | Fast-motion searching method and fast-motion searching device applied to template matching |
KR101671460B1 (en) * | 2009-09-10 | 2016-11-02 | 에스케이 텔레콤주식회사 | Motion Vector Coding Method and Apparatus and Video Coding Method and Apparatus by Using Same |
CN102611887B (en) * | 2011-01-21 | 2015-08-05 | 华为技术有限公司 | The coordinate figure of non-Integer Pel position motion vector rounds method and apparatus |
CN102611886A (en) * | 2011-01-22 | 2012-07-25 | 华为技术有限公司 | Method for predicting or compensating motion |
-
2018
- 2018-07-06 CN CN201810738280.4A patent/CN110691247B/en active Active
-
2019
- 2019-07-02 WO PCT/CN2019/094433 patent/WO2020007306A1/en active Application Filing
Also Published As
Publication number | Publication date |
---|---|
CN110691247A (en) | 2020-01-14 |
WO2020007306A1 (en) | 2020-01-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114866777B (en) | A decoding and encoding method and device thereof | |
CN111698500B (en) | Encoding and decoding method, device and equipment | |
CN111064964B (en) | Encoding and decoding method, device and equipment | |
CN111263144B (en) | Motion information determination method and equipment | |
CN110662033B (en) | Decoding and encoding method and device thereof | |
CN110662074B (en) | Motion vector determination method and device | |
CN113709457B (en) | Decoding and encoding method, device and equipment | |
CN110691247B (en) | Decoding and encoding method and device | |
CN112449180B (en) | Encoding and decoding method, device and equipment | |
CN110365987B (en) | Motion vector determination method, device and equipment | |
CN114710665B (en) | Decoding and encoding method, device and equipment | |
CN113709486B (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 |