[0001] This application claims priority to Chinese Patent Application No.
201710445873.7, filed with the Chinese Patent Office on June 13, 2017 and entitled "MOTION VECTOR
PREDICTION METHOD AND DEVICE", which is incorporated herein by reference in its entirety.
TECHNICAL FIELD
[0002] This application relates to the field of picture processing technologies, and in
particular, to a motion vector prediction method and device.
BACKGROUND
[0003] A motion vector (motion vector, MV) predictive coding technology is used for inter-frame
coding in a high efficiency video coding (high efficiency video coding, HEVC) standard,
to reduce a data amount in MV-related information transmission and improve coding
efficiency. Inter-frame predictive coding in the HEVC standard is specifically divided
into two modes: an inter-frame (inter) mode and a merge (merge)/skip (skip) mode.
When the inter mode is used for a current block, a reference frame index (reference
index), a motion vector predictor index (motion vector predictor index, MVP index),
and a motion vector difference (motion vector difference, MVD) that are of an MV of
the current block are identified in a bitstream. A reference frame to which the MV
of the current block points is determined based on the reference frame index, the
motion vector predictor index indicates that a candidate in a motion vector predictor
(motion vector predictor, MVP) candidate list is used as a predictor of the MV of
the current block, and the MV of the current block is obtained by adding the MVP to
the MVD. When the merge/skip mode is used for a current block, neither of a motion
vector difference and a reference frame index is identified in a bitstream, and only
an MVP index is identified. A corresponding MV and a reference frame corresponding
to the MV are selected from an MVP candidate list based on the MVP index, and are
used as an MV of the current block and a reference frame corresponding to the MV of
the current block.
[0004] In the two solutions, a motion vector predictor list (motion vector predictor list)
needs to be constructed by using motion vectors of a spatially adjacent block and
a temporally adjacent block that are of the current block. Each of the motion vectors
is referred to as an MVP candidate (MVP candidate). Then, a corresponding MVP candidate
is found from the motion vector predictor list based on the MVP index transmitted
in the bitstream, and the corresponding MVP candidate is determined as a motion vector
predictor of the picture block. Inter-frame prediction may be performed on a current
block in the inter mode through any one of forward prediction, backward prediction,
and bidirectional prediction. Any block in the inter mode has one or two MVs, and
an MVP list needs to be constructed for each MV in the block.
[0005] When unidirectional prediction is performed on each spatially adjacent block or temporally
adjacent block of the current block, the spatially adjacent block or temporally adjacent
block contains only one MV. When bidirectional prediction is performed on the current
block, two contained MVs may be of a same type. In the inter mode, if a type of an
MV of an adjacent block is different from a type of the MV of the current block (to
be specific, one MV is a long-term motion vector and the other MV is a short-term
motion vector), the MV is not added to the MVP list. Consequently, a quantity of zero
motion vectors (zero motion vector, Zero MV) in the MVP list increases, resulting
in low MV prediction efficiency.
SUMMARY
[0006] Embodiments of this application provide a motion vector prediction method. When a
motion vector type of a motion vector of a current block is different from a motion
vector type of a motion vector of an adjacent block, the method is used to supplement
a motion vector predictor list of the current block with a motion vector having a
same motion vector type as the motion vector of the current block, to enrich the motion
vector predictor list and improve motion vector prediction efficiency.
[0007] A first aspect of the embodiments of this application provides a motion vector prediction
method, including: obtaining, by a device from a bitstream, a reference frame corresponding
to a motion vector of a current block; then determining, by the device, a reference
frame type of the reference frame, and determining a motion vector type of the motion
vector of the current block based on the reference frame type of the reference frame,
where the reference frame type of the reference frame includes a long-term reference
frame and a short-term reference frame, the motion vector type of the motion vector
of the current block includes a long-term motion vector and a short-term motion vector,
the short-term motion vector is obtained from the short-term reference frame, and
the long-term motion vector is obtained from the long-term reference frame; when at
least one spatially adjacent prediction block of the current block is an inter-frame
prediction block, obtaining, by the device, a motion vector type of a first motion
vector of the at least one spatially adjacent prediction block from the first motion
vector used to perform inter-frame prediction on the spatially adjacent prediction
block; and when the obtained motion vector type of the first motion vector is different
from all motion vector types of motion vectors of the current block, determining,
by the device, a second motion vector of a spatially adjacent pixel block of the current
block based on decoding information of the adjacent pixel block, and using the second
motion vector or a scaling value of the second motion vector as a candidate motion
vector predictor of the current block. In this embodiment of this application, when
the motion vector type of the motion vector of the current block is different from
a motion vector type of a first motion vector of an adjacent block, the motion vector
predictor of the current block is determined, that is, a motion vector predictor list
of the current block is supplemented with the second motion vector having a same motion
vector type as the motion vector of the current block, to enrich the motion vector
predictor list and improve motion vector prediction efficiency.
[0008] In a possible design, in a first implementation of the first aspect of this embodiment
of this application, the method further includes: using the at least one first motion
vector as a candidate motion vector predictor of the current block when the obtained
motion vector type of the at least one first motion vector is the same as the motion
vector type of the motion vector of the current block. In this embodiment of this
application, the at least one first motion vector is determined as the motion vector
predictor of the current block when the obtained motion vector type of the at least
one first motion vector is the same as the motion vector type of the motion vector
of the current block. This adds an implementation of this embodiment of this application.
[0009] In a possible design, in a second implementation of the first aspect of this embodiment
of this application, the method further includes: when all spatially adjacent prediction
blocks of the current block are intra-frame prediction blocks, determining, by the
device in a virtual reference frame of at least one of the spatially adjacent prediction
blocks, a virtual reference block having a slightest pixel difference from the spatially
adjacent prediction block, where a reference frame type of the virtual reference frame
is the same as the reference frame type of the reference frame corresponding to the
motion vector of the current block, and the virtual reference frame is a reconstructed
frame; and using a motion vector between the virtual reference block and the spatially
adjacent prediction block as a motion vector predictor of the current block. In this
embodiment of this application, when all the spatially adjacent prediction blocks
of the current block are intra-frame prediction blocks, a process in which the device
determines the motion vector predictor adds an implementation of this embodiment of
this application.
[0010] In a possible design, in a third implementation of the first aspect of this embodiment
of this application, the spatially adjacent pixel block of the current block includes
at least one pixel block that is spatially adjacent to the current block and that
is within a preset range, correspondingly, the decoding information of the spatially
adjacent pixel block of the current block includes a pixel reconstruction value of
the at least one pixel block that is spatially adjacent to the current block and that
is within the preset range, and correspondingly, the determining a second motion vector
of a spatially adjacent pixel block of the current block based on decoding information
of the adjacent pixel block, and using the second motion vector or a scaling value
of the second motion vector as a candidate motion vector predictor of the current
block includes: determining, by the device in a first reference frame of the spatially
adjacent pixel block, a first reference block having a slightest pixel difference
from the spatially adjacent pixel block, where a reference frame type of the first
reference frame is the same as the reference frame type of the reference frame corresponding
to the motion vector of the current block; using a motion vector between the first
reference block and the pixel block as the second motion vector; and further using
the second motion vector or the scaling value of the second motion vector as the candidate
motion vector predictor of the current block. In this embodiment of this application,
a process of determining the motion vector predictor based on the pixel block is specifically
described, so that this embodiment of this application is more operable.
[0011] In a possible design, in a fourth implementation of the first aspect of this embodiment
of this application, the determining, in a first reference frame of the spatially
adjacent pixel block, a first reference block having a slightest pixel difference
from the spatially adjacent pixel block; using a motion vector between the first reference
block and the spatially adjacent pixel block as the second motion vector, where a
reference frame type of the first reference frame is the same as the reference frame
type of the reference frame corresponding to the motion vector of the current block;
and using the second motion vector or the scaling value of the second motion vector
as the candidate motion vector predictor of the current block includes: when a first
motion vector of a spatially adjacent prediction block at a left preset location relative
to the current block has a different motion vector type from the motion vector of
the current block, and a first motion vector of a spatially adjacent prediction block
at an upper preset location relative to the current block has a different motion vector
type from the motion vector of the current block, determining, in the first reference
frame of the spatially adjacent pixel block, the first reference block having the
slightest pixel difference from the spatially adjacent pixel block; using the motion
vector between the first reference block and the spatially adjacent pixel block as
the second motion vector, where the reference frame type of the first reference frame
is the same as the reference frame type of the reference frame corresponding to the
motion vector of the current block; and using the second motion vector or the scaling
value of the second motion vector as the candidate motion vector predictor of the
current block. In this embodiment of this application, a specific process of determining
the motion vector predictor based on the pixel block is provided, so that this embodiment
of this application is more operable and executable.
[0012] In a possible design, in a fifth implementation of the first aspect of this embodiment
of this application, the spatially adjacent pixel block of the current block includes
at least one spatially adjacent prediction block of the current block, correspondingly,
the decoding information of the spatially adjacent pixel block of the current block
includes a second motion vector of the at least one spatially adjacent prediction
block of the current block, a motion vector type of the second motion vector is different
from the motion vector type of the first motion vector, and correspondingly, the determining
a second motion vector of a spatially adjacent pixel block of the current block based
on decoding information of the adjacent pixel block, and using the second motion vector
or a scaling value of the second motion vector as a candidate motion vector predictor
of the current block includes: using the second motion vector of the at least one
spatially adjacent prediction block or a scaling value of the second motion vector
of the at least one spatially adjacent prediction block as the candidate motion vector
predictor of the current block. In this embodiment of this application, a process
of determining the motion vector predictor based on the spatially adjacent prediction
block is specifically described, so that this embodiment of this application is more
operable.
[0013] In a possible design, in a sixth implementation of the first aspect of this embodiment
of this application, the using the second motion vector of the at least one spatially
adjacent prediction block or a scaling value of the second motion vector of the at
least one spatially adjacent prediction block as the candidate motion vector predictor
of the current block includes: when a first motion vector of a spatially adjacent
prediction block at a left preset location relative to the current block has a different
motion vector type from the motion vector of the current block, and at least one second
motion vector of the spatially adjacent prediction block at the left preset location
is available, using the at least one second motion vector of the spatially adjacent
prediction block at the left preset location or a scaling value of the at least one
second motion vector of the spatially adjacent prediction block at the left preset
location as the candidate motion vector predictor of the current block; and when a
first motion vector of a spatially adjacent prediction block at an upper preset location
relative to the current block has a different motion vector type from the motion vector
of the current block, and at least one second motion vector of the spatially adjacent
prediction block at the upper preset location is available, using the at least one
second motion vector of the spatially adjacent prediction block at the upper preset
location or a scaling value of the at least one second motion vector of the spatially
adjacent prediction block at the upper preset location as the candidate motion vector
predictor of the current block. In this embodiment of this application, a specific
process of determining the motion vector predictor based on the spatially adjacent
prediction block is provided, so that this embodiment of this application is more
operable and executable.
[0014] In a possible design, in a seventh implementation of the first aspect of this embodiment
of this application, the using the second motion vector of the at least one spatially
adjacent prediction block or a scaling value of the second motion vector of the at
least one spatially adjacent prediction block as the candidate motion vector predictor
of the current block includes: if a first motion vector of a spatially adjacent prediction
block at a left preset location relative to the current block has a different motion
vector type from the motion vector of the current block, and a first motion vector
of a spatially adjacent block at an upper preset location relative to the current
block has a different motion vector type from the motion vector of the current block,
when at least one second motion vector of the spatially adjacent prediction block
at the left preset location relative to the current block is available, using the
at least one second motion vector of the spatially adjacent prediction block at the
left preset location or a scaling value of the second motion vector as the candidate
motion vector predictor of the current block, or when at least one second motion vector
of the spatially adjacent prediction block at the upper preset location relative to
the current block is available, using the at least one second motion vector of the
spatially adjacent prediction block at the upper preset location or a scaling value
of the second motion vector as the candidate motion vector predictor of the current
block. In this embodiment of this application, another specific process of determining
the motion vector predictor based on the spatially adjacent prediction block is provided,
so that this embodiment of this application is more operable and executable.
[0015] In a possible design, in an eighth implementation of the first aspect of this embodiment
of this application, the method further includes: when a quantity of candidate motion
vector predictors is less than a preset value, at least one first motion vector of
a co-located block (co-located block) of the current block is available, and a motion
vector type of the at least one first motion vector of the co-located block of the
current block is the same as the motion vector type of the motion vector of the current
block, using the at least one first motion vector of the co-located block or a scaling
value of the at least one first motion vector of the co-located block as a candidate
motion vector predictor. In this embodiment of this application, when the quantity
of candidate motion vector predictors is less than the preset value, the first motion
vector of the co-located block is used as the motion vector predictor of the current
block. This adds an implementation of this embodiment of this application.
[0016] In a possible design, in a ninth implementation of the first aspect of this embodiment
of this application, after the using the at least one first motion vector of the co-located
block or a scaling value of the at least one first motion vector of the co-located
block as a candidate motion vector predictor, the method further includes: when the
quantity of candidate motion vector predictors is less than the preset value, using
at least one zero motion vector as a candidate motion vector predictor, so that the
quantity of candidate motion vector predictors reaches the preset value. In this embodiment
of this application, when the quantity of candidate motion vector predictors is less
than the preset value, the zero motion vector is used as the motion vector predictor
of the current block. This adds an implementation of this embodiment of this application.
[0017] In a possible design, in a tenth implementation of the first aspect of this embodiment
of the present invention, the method may be used in a coding method for the current
block or a decoding method for the current block.
[0018] A second aspect of the embodiments of this application provides a motion vector prediction
device, including: a first obtaining unit, configured to obtain a reference frame
corresponding to a motion vector of a current block; a determining unit, configured
to determine a motion vector type of the motion vector of the current block based
on a reference frame type of the reference frame, where the motion vector type includes
a short-term motion vector and a long-term motion vector, the short-term motion vector
is obtained from a short-term reference frame, and the long-term motion vector is
obtained from a long-term reference frame; a second obtaining unit, configured to
obtain a motion vector type of a first motion vector of at least one spatially adjacent
prediction block of the current block when the at least one spatially adjacent prediction
block is an inter-frame prediction block, where the first motion vector is used to
perform inter-frame prediction on the spatially adjacent prediction block; and a first
processing unit, configured to: when the obtained motion vector type of the first
motion vector is different from all motion vector types of motion vectors of the current
block, determine a second motion vector of a spatially adjacent pixel block of the
current block based on decoding information of the adjacent pixel block, and use the
second motion vector or a scaling value of the second motion vector as a candidate
motion vector predictor of the current block. In this embodiment of this application,
when the motion vector type of the motion vector of the current block is different
from a motion vector type of a first motion vector of an adjacent block, the motion
vector predictor of the current block is determined, that is, a motion vector predictor
list of the current block is supplemented with the second motion vector having a same
motion vector type as the motion vector of the current block, to enrich the motion
vector predictor list and improve motion vector prediction efficiency.
[0019] In a possible design, in a first implementation of the second aspect of this embodiment
of this application, the device further includes: a second processing unit, configured
to use the at least one first motion vector as a candidate motion vector predictor
of the current block when the obtained motion vector type of the at least one first
motion vector is the same as the motion vector type of the motion vector of the current
block. In this embodiment of this application, the at least one first motion vector
is determined as the motion vector predictor of the current block when the obtained
motion vector type of the at least one first motion vector is the same as the motion
vector type of the motion vector of the current block. This adds an implementation
of this embodiment of this application.
[0020] In a possible design, in a second implementation of the second aspect of this embodiment
of this application, the device further includes: a third processing unit, configured
to: when all spatially adjacent prediction blocks of the current block are intra-frame
prediction blocks, determine, in a virtual reference frame of at least one of the
spatially adjacent prediction blocks, a virtual reference block having a slightest
pixel difference from the spatially adjacent prediction block, and use a motion vector
between the virtual reference block and the spatially adjacent prediction block as
a motion vector predictor of the current block, where a reference frame type of the
virtual reference frame is the same as the reference frame type of the reference frame
corresponding to the motion vector of the current block, and the virtual reference
frame is a reconstructed frame. In this embodiment of this application, when all the
spatially adjacent prediction blocks of the current block are intra-frame prediction
blocks, a process in which the device determines the motion vector predictor adds
an implementation of this embodiment of this application.
[0021] In a possible design, in a third implementation of the second aspect of this embodiment
of this application, the spatially adjacent pixel block of the current block includes
at least one pixel block that is spatially adjacent to the current block and that
is within a preset range, correspondingly, the decoding information of the spatially
adjacent pixel block of the current block includes a pixel reconstruction value of
the at least one pixel block that is spatially adjacent to the current block and that
is within the preset range, and correspondingly, the first processing unit includes:
a first processing module, configured to: determine, in a first reference frame of
the spatially adjacent pixel block, a first reference block having a slightest pixel
difference from the spatially adjacent pixel block; use a motion vector between the
first reference block and the spatially adjacent pixel block as the second motion
vector, where a reference frame type of the first reference frame is the same as the
reference frame type of the reference frame corresponding to the motion vector of
the current block; and use the second motion vector or the scaling value of the second
motion vector as the candidate motion vector predictor of the current block. In this
embodiment of this application, a process of determining the motion vector predictor
based on the pixel block is specifically described, so that this embodiment of this
application is more operable.
[0022] In a possible design, in a fourth implementation of the second aspect of this embodiment
of this application, the first processing module includes: a first processing submodule,
configured to: when a first motion vector of a spatially adjacent prediction block
at a left preset location relative to the current block has a different motion vector
type from the motion vector of the current block, and a first motion vector of a spatially
adjacent prediction block at an upper preset location relative to the current block
has a different motion vector type from the motion vector of the current block, determine,
in the first reference frame of the spatially adjacent pixel block, the first reference
block having the slightest pixel difference from the spatially adjacent pixel block;
use the motion vector between the first reference block and the spatially adjacent
pixel block as the second motion vector, where the reference frame type of the first
reference frame is the same as the reference frame type of the reference frame corresponding
to the motion vector of the current block; and use the second motion vector or the
scaling value of the second motion vector as the candidate motion vector predictor
of the current block. In this embodiment of this application, a specific process of
determining the motion vector predictor based on the pixel block is provided, so that
this embodiment of this application is more operable and executable.
[0023] In a possible design, in a fifth implementation of the second aspect of this embodiment
of this application, the spatially adjacent pixel block of the current block includes
at least one spatially adjacent prediction block of the current block, correspondingly,
the decoding information of the spatially adjacent pixel block of the current block
includes a second motion vector of the at least one spatially adjacent prediction
block of the current block, a motion vector type of the second motion vector is different
from the motion vector type of the first motion vector, and correspondingly, the first
processing unit includes: a second processing module, configured to use the second
motion vector of the at least one spatially adjacent prediction block or a scaling
value of the second motion vector of the at least one spatially adjacent prediction
block as the candidate motion vector predictor of the current block. In this embodiment
of this application, a process of determining the motion vector predictor based on
the spatially adjacent prediction block is specifically described, so that this embodiment
of this application is more operable.
[0024] In a possible design, in a sixth implementation of the second aspect of this embodiment
of this application, the second processing module includes: a second processing submodule,
configured to: when a first motion vector of a spatially adjacent prediction block
at a left preset location relative to the current block has a different motion vector
type from the motion vector of the current block, and at least one second motion vector
of the spatially adjacent prediction block at the left preset location is available,
use the at least one second motion vector of the spatially adjacent prediction block
at the left preset location or a scaling value of the at least one second motion vector
of the spatially adjacent prediction block at the left preset location as the candidate
motion vector predictor of the current block; and a third processing submodule, configured
to: when a first motion vector of a spatially adjacent prediction block at an upper
preset location relative to the current block has a different motion vector type from
the motion vector of the current block, and at least one second motion vector of the
spatially adjacent prediction block at the upper preset location is available, use
the at least one second motion vector of the spatially adjacent prediction block at
the upper preset location or a scaling value of the at least one second motion vector
of the spatially adjacent prediction block at the upper preset location as the candidate
motion vector predictor of the current block. In this embodiment of this application,
a specific process of determining the motion vector predictor based on the spatially
adjacent prediction block is provided, so that this embodiment of this application
is more operable and executable.
[0025] In a possible design, in a seventh implementation of the second aspect of this embodiment
of this application, the second processing module includes: a fourth processing submodule,
configured to: if a first motion vector of a spatially adjacent prediction block at
a left preset location relative to the current block has a different motion vector
type from the motion vector of the current block, and a first motion vector of a spatially
adjacent block at an upper preset location relative to the current block has a different
motion vector type from the motion vector of the current block, when at least one
second motion vector of the spatially adjacent prediction block at the left preset
location relative to the current block is available, use the at least one second motion
vector of the spatially adjacent prediction block at the left preset location or a
scaling value of the second motion vector as the candidate motion vector predictor
of the current block, or when at least one second motion vector of the spatially adjacent
prediction block at the upper preset location relative to the current block is available,
use the at least one second motion vector of the spatially adjacent prediction block
at the upper preset location or a scaling value of the second motion vector as the
candidate motion vector predictor of the current block. In this embodiment of this
application, another specific process of determining the motion vector predictor based
on the spatially adjacent prediction block is provided, so that this embodiment of
this application is more operable and executable.
[0026] In a possible design, in an eighth implementation of the second aspect of this embodiment
of this application, the device further includes: a fourth processing unit, configured
to: when a quantity of candidate motion vector predictors is less than a preset value,
at least one first motion vector of a co-located block of the current block is available,
and a motion vector type of the at least one first motion vector of the co-located
block of the current block is the same as the motion vector type of the motion vector
of the current block, use the at least one first motion vector of the co-located block
or a scaling value of the at least one first motion vector of the co-located block
as a candidate motion vector predictor. In this embodiment of this application, when
the quantity of candidate motion vector predictors is less than the preset value,
the first motion vector of the co-located block is used as the motion vector predictor
of the current block. This adds an implementation of this embodiment of this application.
[0027] In a possible design, in a ninth implementation of the second aspect of this embodiment
of this application, the device further includes: a fifth processing unit, configured
to: when the quantity of candidate motion vector predictors is less than the preset
value, use at least one zero motion vector as a candidate motion vector predictor,
so that the quantity of candidate motion vector predictors reaches the preset value.
In this embodiment of this application, when the quantity of candidate motion vector
predictors is less than the preset value, the zero motion vector is used as the motion
vector predictor of the current block. This adds an implementation of this embodiment
of this application.
[0028] In a possible design, in a tenth implementation of the second aspect of this embodiment
of the present invention, the device may be used in an encoder for coding the current
block or a decoder for decoding the current block.
[0029] A third aspect of this application provides a motion vector prediction device, and
the device includes a processor and a memory coupled to the processor, where the processor
is configured to: obtain a reference frame corresponding to a motion vector of a current
block; determine a motion vector type of the motion vector of the current block based
on a reference frame type of the reference frame, where the motion vector type includes
a short-term motion vector and a long-term motion vector, the short-term motion vector
is obtained from a short-term reference frame, and the long-term motion vector is
obtained from a long-term reference frame; obtain a motion vector type of a first
motion vector of at least one spatially adjacent prediction block of the current block
when the at least one spatially adjacent prediction block is an inter-frame prediction
block, where the first motion vector is used to perform inter-frame prediction on
the spatially adjacent prediction block; and when the obtained motion vector type
of the first motion vector is different from all motion vector types of motion vectors
of the current block, determine a second motion vector of a spatially adjacent pixel
block of the current block based on decoding information of the adjacent pixel block,
and use the second motion vector or a scaling value of the second motion vector as
a candidate motion vector predictor of the current block.
[0030] In a possible design, in a first implementation of the third aspect of this embodiment
of this application, the processor is further configured to use the at least one first
motion vector as a candidate motion vector predictor of the current block when the
obtained motion vector type of the at least one first motion vector is the same as
the motion vector type of the motion vector of the current block.
[0031] In a possible design, in a second implementation of the third aspect of this embodiment
of this application, the processor is further configured to: when all spatially adjacent
prediction blocks of the current block are intra-frame prediction blocks, determine,
in a virtual reference frame of at least one of the spatially adjacent prediction
blocks, a virtual reference block having a slightest pixel difference from the spatially
adjacent prediction block, and use a motion vector between the virtual reference block
and the spatially adjacent prediction block as a motion vector predictor of the current
block, where a reference frame type of the virtual reference frame is the same as
the reference frame type of the reference frame corresponding to the motion vector
of the current block, and the virtual reference frame is a reconstructed frame.
[0032] In a possible design, in a third implementation of the third aspect of this embodiment
of this application, the spatially adjacent pixel block of the current block includes
at least one pixel block that is spatially adjacent to the current block and that
is within a preset range, correspondingly, the decoding information of the spatially
adjacent pixel block of the current block includes a pixel reconstruction value of
the at least one pixel block that is spatially adjacent to the current block and that
is within the preset range, and correspondingly, the processor is configured to: determine,
in a first reference frame of the spatially adjacent pixel block, a first reference
block having a slightest pixel difference from the spatially adjacent pixel block;
use a motion vector between the first reference block and the spatially adjacent pixel
block as the second motion vector, where a reference frame type of the first reference
frame is the same as the reference frame type of the reference frame corresponding
to the motion vector of the current block; and use the second motion vector or the
scaling value of the second motion vector as the candidate motion vector predictor
of the current block.
[0033] In a possible design, in a fourth implementation of the third aspect of this embodiment
of this application, the processor is configured to: when a first motion vector of
a spatially adjacent prediction block at a left preset location relative to the current
block has a different motion vector type from the motion vector of the current block,
and a first motion vector of a spatially adjacent prediction block at an upper preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, determine, in the first reference frame of the
spatially adjacent pixel block, the first reference block having the slightest pixel
difference from the spatially adjacent pixel block; use the motion vector between
the first reference block and the spatially adjacent pixel block as the second motion
vector, where the reference frame type of the first reference frame is the same as
the reference frame type of the reference frame corresponding to the motion vector
of the current block; and use the second motion vector or the scaling value of the
second motion vector as the candidate motion vector predictor of the current block.
[0034] In a possible design, in a fifth implementation of the fifth aspect of this embodiment
of this application, the spatially adjacent pixel block of the current block includes
at least one spatially adjacent prediction block of the current block, correspondingly,
the decoding information of the spatially adjacent pixel block of the current block
includes a second motion vector of the at least one spatially adjacent prediction
block of the current block, a motion vector type of the second motion vector is different
from the motion vector type of the first motion vector, and correspondingly, the processor
is configured to use the second motion vector of the at least one spatially adjacent
prediction block or a scaling value of the second motion vector of the at least one
spatially adjacent prediction block as the candidate motion vector predictor of the
current block.
[0035] In a possible design, in a sixth implementation of the third aspect of this embodiment
of this application, the processor is configured to: when a first motion vector of
a spatially adjacent prediction block at a left preset location relative to the current
block has a different motion vector type from the motion vector of the current block,
and at least one second motion vector of the spatially adjacent prediction block at
the left preset location is available, use the at least one second motion vector of
the spatially adjacent prediction block at the left preset location or a scaling value
of the at least one second motion vector of the spatially adjacent prediction block
at the left preset location as the candidate motion vector predictor of the current
block; and when a first motion vector of a spatially adjacent prediction block at
an upper preset location relative to the current block has a different motion vector
type from the motion vector of the current block, and at least one second motion vector
of the spatially adjacent prediction block at the upper preset location is available,
use the at least one second motion vector of the spatially adjacent prediction block
at the upper preset location or a scaling value of the at least one second motion
vector of the spatially adjacent prediction block at the upper preset location as
the candidate motion vector predictor of the current block.
[0036] In a possible design, in a seventh implementation of the third aspect of this embodiment
of this application, the processor is configured to: if a first motion vector of a
spatially adjacent prediction block at a left preset location relative to the current
block has a different motion vector type from the motion vector of the current block,
and a first motion vector of a spatially adjacent block at an upper preset location
relative to the current block has a different motion vector type from the motion vector
of the current block, when at least one second motion vector of the spatially adjacent
prediction block at the left preset location relative to the current block is available,
use the at least one second motion vector of the spatially adjacent prediction block
at the left preset location or a scaling value of the second motion vector as the
candidate motion vector predictor of the current block, or when at least one second
motion vector of the spatially adjacent prediction block at the upper preset location
relative to the current block is available, use the at least one second motion vector
of the spatially adjacent prediction block at the upper preset location or a scaling
value of the second motion vector as the candidate motion vector predictor of the
current block.
[0037] In a possible design, in an eighth implementation of the third aspect of this embodiment
of this application, the device may be used in an encoder for coding the current block
or a decoder for decoding the current block.
[0038] A fourth aspect of this application provides a computer-readable storage medium.
The computer-readable storage medium stores an instruction. When the instruction is
run on a computer, the computer is enabled to perform the method in the foregoing
aspects.
[0039] A fifth aspect of this application provides a computer program product including
an instruction. When the computer program product is run on a computer, the computer
is enabled to perform the method in the foregoing aspects.
[0040] It can be learned from the foregoing technical solutions that, the embodiments of
this application have the following advantages:
[0041] In the technical solutions provided in the embodiments of this application, the reference
frame corresponding to the motion vector of the current block is obtained; the motion
vector type of the motion vector of the current block is determined based on the reference
frame type of the reference frame, where the motion vector type includes the short-term
motion vector and the long-term motion vector, the short-term motion vector is obtained
from the short-term reference frame, and the long-term motion vector is obtained from
the long-term reference frame; the motion vector type of the first motion vector of
the at least one spatially adjacent prediction block of the current block is obtained
when the at least one spatially adjacent prediction block is the inter-frame prediction
block, where the first motion vector is used to perform inter-frame prediction on
the spatially adjacent prediction block; and when the obtained motion vector type
of the first motion vector is different from all the motion vector types of the motion
vectors of the current block, the second motion vector of the spatially adjacent pixel
block of the current block is determined based on the decoding information of the
adjacent pixel block, and the second motion vector or the scaling value of the second
motion vector is used as the candidate motion vector predictor of the current block.
In the embodiments of this application, the motion vector predictor list is enriched,
and a problem that a motion vector predictor cannot be obtained from an adjacent block
when a type of a motion vector of the adjacent block is different from the type of
the motion vector of the current block is resolved, so that motion vector prediction
efficiency is improved.
BRIEF DESCRIPTION OF DRAWINGS
[0042]
FIG. 1 is a schematic diagram of a system framework to which an embodiment of this
application is applied;
FIG. 2 is a schematic diagram of a reconstructed pixel in an adjacent L-shaped area
according to an embodiment of this application;
FIG. 3 is a schematic diagram of an embodiment of a motion vector prediction method
according to an embodiment of this application;
FIG. 4 is a schematic diagram of another embodiment of a motion vector prediction
method according to an embodiment of this application;
FIG. 5 is a schematic diagram of another embodiment of a motion vector prediction
method according to an embodiment of this application;
FIG. 6 is a schematic diagram of an embodiment of a motion vector prediction device
according to an embodiment of this application;
FIG. 7 is a schematic diagram of another embodiment of a motion vector prediction
device according to an embodiment of this application;
FIG. 8 is a schematic diagram of another embodiment of a motion vector prediction
device according to an embodiment of this application;
FIG. 9 is a schematic diagram of another embodiment of a motion vector prediction
device according to an embodiment of this application;
FIG. 10 is a schematic diagram of another embodiment of a motion vector prediction
device according to an embodiment of this application;
FIG. 11 is a schematic block diagram of a codec apparatus according to an embodiment
of this application; and
FIG. 12 is a schematic diagram of a codec apparatus according to an embodiment of
this application.
DESCRIPTION OF EMBODIMENTS
[0043] Embodiments of this application provide a motion vector prediction method. When a
motion vector type of a motion vector of a current block is different from a motion
vector type of a motion vector of an adjacent block, the method is used to supplement
a motion vector predictor list of the current block with a motion vector having a
same motion vector type as the motion vector of the current block, to enrich the motion
vector predictor list and improve motion vector prediction efficiency.
[0044] To make persons skilled in the art understand solutions in this application better,
the following describes the embodiments of this application with reference to the
accompanying drawings in the embodiments of this application.
[0045] In the specification, claims, and accompanying drawings of this application, the
terms "first", "second", "third", "fourth", and the like (if existent) are intended
to distinguish between similar objects but do not necessarily indicate a specific
order or sequence. It should be understood that the data used in such a way is interchangeable
in proper circumstances, so that the embodiments described herein can be implemented
in other orders than the order illustrated or described herein. In addition, the terms
"include", "have", and any variants thereof are intended to cover the non-exclusive
inclusion, for example, a process, method, system, product, or device that includes
a list of steps or units is not necessarily limited to those expressly listed steps
or units, but may include other steps or units not expressly listed or inherent to
such a process, method, product, or device.
[0046] The method provided in the embodiments of this application may be applied to a system
framework shown in FIG. 1. In the network framework, a motion vector predictor is
determined based on a spatially adjacent prediction block and a co-located block that
are of a current block. Spatially adjacent prediction blocks of the current block
may be classified into a left spatially adjacent prediction block and an upper spatially
adjacent prediction block. The spatially adjacent prediction blocks may be classified
in different manners, for example, may be classified as shown in FIG. 1 in which left
spatially adjacent prediction blocks include a lower left block A
0 and a directly left block A
1 that are of the current block, upper spatially adjacent prediction blocks include
an upper right block B
0, a directly upper block B
1, and an upper left block B
2 that are of the current block, and co-located blocks (co-located block) include a
lower right block C
0 and a central block C
1. When the motion vector predictor of the current block is obtained based on an adjacent
reconstructed pixel of the current block, the reconstructed pixel is selected in a
part of an adjacent area of the current block. Co-located blocks may be classified
as shown in FIG. 2, and the reconstructed pixel is selected in an L-shaped area around
the current block. In the embodiments of this application, whether a motion vector
type of a first motion vector of an adjacent block of the current block is the same
as a motion vector type of a motion vector of the current block needs to be determined,
and a motion vector of the adjacent block or a scaling value of the motion vector
is determined as a motion vector predictor of the current block based on an actual
situation, to improve motion vector prediction efficiency.
[0047] For ease of understanding, the following describes a specific procedure in the embodiments
of this application. Referring to FIG. 3, when a spatially adjacent pixel block of
the current block includes at least one spatially adjacent prediction block of the
current block, an embodiment of a motion vector prediction method according to an
embodiment of this application includes the following steps.
[0048] 301. Obtain a reference frame corresponding to a motion vector of the current block.
[0049] A device obtains the reference frame corresponding to the motion vector of the current
block. The device segments a picture into a plurality of picture blocks with a same
specification according to the H.265 video coding standard. The device first selects,
as the current block, a picture block being coded/decoded, then obtains a reference
frame index corresponding to the motion vector (motion vector, MV) of the selected
current block, and subsequently determines, based on index information, the reference
frame corresponding to the motion vector of the current block.
[0050] It should be noted that, when a picture block is predicted, a picture in which the
current block is located is referred to as a current frame, and a frame that has been
coded/decoded before the current frame is coded/decoded is referred to as a reconstructed
frame. The current frame may be a unidirectional predictive frame or a bidirectional
predictive frame. If the current frame is the unidirectional predictive frame, the
current frame has one reference frame list L0. If the current frame is the bidirectional
predictive frame, the current frame has two reference frame lists. The two lists are
respectively referred to as L0 and L1. Each list includes at least one reconstructed
frame, referred to as a reference frame of the current frame. The reference frame
provides a reference pixel for inter-frame prediction in the current frame. The device
determines, based on the reference frame index, the reference frame to which the motion
vector of the current block points.
[0051] It may be understood that inter-frame prediction may be performed on a current block
in an inter mode through forward prediction, backward prediction, or bidirectional
prediction. When the forward prediction is performed, the current block has one forward
reference frame list (L0) and one forward motion vector (L0_MV). When the backward
prediction is performed, the current block has one backward reference frame list (L1)
and one backward MV (L1_MV). When the bidirectional prediction is performed, the current
block has two reference frame lists L0 and L1, and also has one L0_MV and one L1_MV.
In other words, any block in the inter mode has one or two MVs. A motion vector predictor
(motion vector predictor, MVP) list may be constructed for each MV in the block. The
reference frame index is identified in a bitstream. For example, syntactic elements
ref_idx_l0 and ref_idx_l1 in high efficiency video coding (high efficiency video coding,
HEVC) respectively indicate reference frame indexes in the reference frame lists L0
and L1. In this embodiment of this application, each current block may be processed
to determine an MVP. Each current block may have one or two MVP lists. This is not
limited herein.
[0052] 302. Determine a motion vector type of the motion vector of the current block based
on a reference frame type of the reference frame.
[0053] After obtaining the reference frame, the device obtains related information from
the reference frame, and determines the reference frame type of the reference frame.
The reference frame type of the reference frame includes a long-term reference frame
and a short-term reference frame. Then, the device determines the motion vector type
of the motion vector of the current block based on the reference frame type of the
reference frame and a correspondence. When the reference frame is the long-term reference
frame, a motion vector that is of the current block and that corresponds to the long-term
reference frame is a long-term motion vector. When the reference frame is the short-term
reference frame, a motion vector that is of the current block and that corresponds
to the short-term reference frame is a short-term motion vector.
[0054] 303. Obtain a motion vector type of a first motion vector of at least one spatially
adjacent prediction block of the current block when the at least one spatially adjacent
prediction block is an inter-frame prediction block.
[0055] After determining the reference frame type of the reference frame and the reference
frame type of the motion vector of the current block, when the at least one spatially
adjacent prediction block of the current block is the inter-frame prediction block,
the device accesses the at least one spatially adjacent prediction block of the current
block in a preset order. The device obtains the first motion vector from the at least
one spatially adjacent prediction block of the current block, and determines the motion
vector type of the first motion vector of the spatially adjacent prediction block
of the current block, that is, determines that the first motion vector is a long-term
motion vector or a short-term motion vector.
[0056] It should be noted that the first motion vector is a motion vector used when motion
compensation is performed on a spatially adjacent block for which inter-frame predictive
coding is used. In other words, the first motion vector is used to perform inter-frame
prediction on the spatially adjacent prediction block. For example, the first motion
vector may be an L0_MV and/or an L1_MV.
[0057] It may be understood that after determining the reference frame type of the reference
frame and the reference frame type of the motion vector of the current block, when
all spatially adjacent prediction blocks of the current block are intra-frame prediction
blocks, the device first determines, in a virtual reference frame of at least one
of the spatially adjacent prediction blocks, a virtual reference block having a slightest
pixel difference from the spatially adjacent prediction block, and then uses a motion
vector between the virtual reference block and the spatially adjacent prediction block
as a motion vector predictor of the current block. A reference frame type of the virtual
reference frame is the same as the reference frame type of the reference frame corresponding
to the motion vector of the current block.
[0058] 304. When a first motion vector of a spatially adjacent prediction block at a left
preset location relative to the current block has a different motion vector type from
the motion vector of the current block, and at least one second motion vector of the
spatially adjacent prediction block at the left preset location is available, use
the at least one second motion vector of the spatially adjacent prediction block at
the left preset location or a scaling value of the at least one second motion vector
of the spatially adjacent prediction block at the left preset location as a candidate
motion vector predictor of the current block.
[0059] In a feasible implementation, the spatially adjacent prediction block at the left
preset location may be all left spatially adjacent prediction blocks.
[0060] The device determines whether at least one of first motion vectors of the left spatially
adjacent prediction blocks of the current block that has a same motion vector type
as the motion vector of the current block exists. If the at least one of the first
motion vectors exists, the device selects, from the left spatially adjacent prediction
blocks, at least one first motion vector or a scaling value of the first motion vector
as a candidate MVP, and adds the candidate MVP to an MVP list. If the at least one
of the first motion vectors does not exist, in other words, when the first motion
vectors of all the left spatially adjacent prediction blocks of the current block
have different motion vector types from the motion vector of the current block, the
device determines whether second motion vectors of the left spatially adjacent prediction
blocks are available, and when at least one second motion vector of the left spatially
adjacent prediction blocks is available, uses the at least one second motion vector
of the left spatially adjacent prediction blocks or a scaling value of the at least
one second motion vector of the left spatially adjacent prediction blocks as a candidate
motion vector predictor of the current block.
[0061] It should be noted that there may be two types in which the first motion vectors
of all the left spatially adjacent prediction blocks of the current block have different
motion vector types from the motion vector of the current block. In a type 1, the
first motion vectors of all the left spatially adjacent prediction blocks of the current
block are long-term motion vectors, and the motion vector type of the motion vector
of the current block is a short-term motion vector. In a type 2, the first motion
vectors of all the left spatially adjacent prediction blocks of the current block
are short-term motion vectors, and the motion vector type of the motion vector of
the current block is a long-term motion vector.
[0062] It may be understood that if a motion vector of a block is available, at least two
conditions need to be met. A first condition is as follows: This block is in the picture,
and this block and the current block belong to a same slice or a same slice segment.
A second condition is as follows: Inter-frame predictive coding is used for this block.
There may further be other constraints. For example, this block and the current block
belong to a same tile (tile) or the like. These constraints are different in different
standards. This is not specifically limited herein.
[0063] For example, a process in which the device determines whether the at least one of
the first motion vectors of the left spatially adjacent prediction blocks of the current
block that has the same motion vector type as the motion vector of the current block
exists includes three rounds of screening. A first round of screening is as follows:
The device successively accesses the first motion vectors of the left spatially adjacent
prediction blocks in a preset order 1, determines whether the first motion vectors
meet a condition 1 "the first motion vector is available and a reference frame of
the first motion vector has a same picture order count (picture order count, POC)
as the reference frame of the motion vector of the current block", and first uses,
as a candidate MVP, a first motion vector meeting the condition 1. A second round
of screening is as follows: The device successively accesses the first motion vectors
of the left spatially adjacent prediction blocks in the preset order 1, and determines
whether the first motion vectors meet a condition 2 "the first motion vector is available
and a reference frame of the first motion vector has a same type as the reference
frame of the motion vector of the current block". For a first motion vector meeting
the condition 2, the first motion vector or a scaling value of the first motion vector
is used as a candidate MVP. When types of the two reference frames are short-term
reference frames and are not a same frame, the first motion vector of the spatially
adjacent prediction block needs to be scaled before being used as the candidate MVP.
Scaling of the motion vector is obtained based on a ratio between differences of two
groups of POCs. For example, motion vector scaling processing in HEVC is performed.
If none of the first motion vectors meets the condition 2, a third round of screening
is performed. The third round of screening is as follows: The device successively
accesses second motion vectors of the left spatially adjacent prediction blocks in
a preset order 2, and determines whether the second motion vectors of the left spatially
adjacent prediction blocks are available. The access order 2 may be the same as or
different from the access order 1. For example, the access order 2 may be an order
from a lower left block A
0 to a directly left block A
1.
[0064] 305. When a first motion vector of a spatially adjacent prediction block at an upper
preset location relative to the current block has a different motion vector type from
the motion vector of the current block, and at least one second motion vector of the
spatially adjacent prediction block at the upper preset location is available, use
the at least one second motion vector of the spatially adjacent prediction block at
the upper preset location or a scaling value of the at least one second motion vector
of the spatially adjacent prediction block at the upper preset location as a candidate
motion vector predictor of the current block.
[0065] In a feasible implementation, the spatially adjacent prediction block at the upper
preset location may be all upper spatially adjacent prediction blocks.
[0066] The device determines whether at least one of first motion vectors of the upper spatially
adjacent prediction blocks of the current block that has a same motion vector type
as the motion vector of the current block exists. If the at least one of the first
motion vectors exists, the device selects, from the upper spatially adjacent prediction
blocks, at least one first motion vector or a scaling value of the first motion vector
as a candidate MVP, and adds the candidate MVP to an MVP list. If the at least one
of the first motion vectors does not exist, in other words, when the first motion
vectors of all the upper spatially adjacent prediction blocks of the current block
have different motion vector types from the motion vector of the current block, the
device determines whether second motion vectors of the upper spatially adjacent prediction
blocks are available, and when at least one second motion vector of the upper spatially
adjacent prediction blocks is available, uses the at least one second motion vector
of the upper spatially adjacent prediction blocks or a scaling value of the at least
one second motion vector of the upper spatially adjacent prediction blocks as a candidate
motion vector predictor of the current block.
[0067] For example, a process in which the device determines whether the at least one of
the first motion vectors of the upper spatially adjacent prediction blocks of the
current block that has the same motion vector type as the motion vector of the current
block exists includes three rounds of screening. A first round of screening is as
follows: The device successively accesses the first motion vectors of the upper spatially
adjacent prediction blocks in a preset order 3, and determines whether the first motion
vectors meet the condition 1 "the first motion vector is available and a reference
frame of the first motion vector has a same picture order count as the reference frame
of the motion vector of the current block". The device first determines, as a candidate
MVP, a first motion vector meeting the condition 1, and then determines whether the
upper spatially adjacent prediction blocks meet a condition 3 "MVs of both a directly
left block and a lower left block in left spatially adjacent prediction blocks are
unavailable". If the condition 3 is met, a second round of screening is performed.
A second round of screening is as follows: The device successively accesses the first
motion vectors of the upper spatially adjacent prediction blocks in the preset order
3, and determines whether the first motion vectors meet the condition 2 "the first
motion vector is available and a reference frame of the first motion vector has a
same type as the reference frame of the motion vector of the current block". For a
first motion vector meeting the condition 2, the first motion vector or a scaling
value of the first motion vector is used as a candidate MVP. When types of the two
reference frames are short-term reference frames and are not a same frame, the first
motion vector of the spatially adjacent prediction block needs to be scaled before
being used as the candidate MVP. Scaling of the motion vector is obtained based on
a ratio between differences of two groups of POCs. For example, motion vector scaling
processing in HEVC is performed. If none of the first motion vectors meets the condition
2, a third round of screening is performed. The third round of screening is as follows:
The device successively accesses second motion vectors of the upper spatially adjacent
prediction blocks in a preset order 4, and determines whether the second motion vectors
of the upper spatially adjacent prediction blocks are available. The access order
4 may be the same as or different from the access order 3. For example, the access
order 4 may be an order from a lower right block B
0 to a directly upper block B
1 to an upper left block B
2.
[0068] It should be noted that, when a selected second motion vector is a short-term motion
vector, and a POC difference corresponding to the second motion vector is different
from a POC difference corresponding to the motion vector of the current block, the
second motion vector is used as a candidate MVP after being scaled. When a selected
second motion vector is a long-term motion vector, or a POC difference corresponding
to the second motion vector is the same as a POC difference corresponding to the motion
vector of the current block, the second motion vector does not need to be scaled,
is directly used as a candidate MVP, and is added to an MVP list.
[0069] It may be understood that, in this case, if the MVP list includes a same candidate
MVP, the repeated candidate MVP is removed from the MVP list, and a candidate MVP
quantity is updated.
[0070] 306. When a quantity of candidate motion vector predictors is less than a preset
value, at least one first motion vector of a co-located block of the current block
is available, and a motion vector type of the at least one first motion vector of
the co-located block of the current block is the same as the motion vector type of
the motion vector of the current block, use the at least one first motion vector of
the co-located block or a scaling value of the at least one first motion vector of
the co-located block as a candidate motion vector predictor.
[0071] Optionally, when the quantity of candidate motion vector predictors is less than
the preset value, and the device determines that the first motion vector of the co-located
block of the current block is available, and the motion vector type of the first motion
vector of the co-located block of the current block is the same as the motion vector
type of the motion vector of the current block, the device uses the at least one first
motion vector of the co-located block or the scaling value of the at least one first
motion vector of the co-located block as the candidate motion vector predictor.
[0072] It should be noted that, when the quantity of candidate MVPs selected from spatially
adjacent prediction blocks is less than N (in other words, the MVP list is not fully
filled, and a length of the MVP list is N), an MVP is selected from the first motion
vector of the co-located block, and is added to the MVP list. For example, a value
of N may be that N = 2 or N = 3.
[0073] For example, the device successively accesses first motion vectors of a lower right
block C
0 and a central block C
1 in co-located blocks, and determines whether the first motion vectors obtained from
the co-located blocks meet the condition 2 "the first motion vector is available and
a reference frame of the first motion vector has a same type as the reference frame
of the motion vector of the current block". For a first motion vector meeting the
condition 2, the first motion vector or a scaling value of the first motion vector
is used as a candidate MVP.
[0074] 307. When the quantity of candidate motion vector predictors is less than the preset
value, use at least one zero motion vector as a candidate motion vector predictor,
so that the quantity of candidate motion vector predictors reaches the preset value.
[0075] If the quantity of candidate motion vector predictors is still less than the preset
value, the device uses the at least one zero motion vector as the motion vector predictor,
so that the quantity of candidate motion vector predictors of the current block reaches
the preset value.
[0076] In this embodiment of this application, when the motion vector type of the motion
vector of the current block is different from a motion vector type of a first motion
vector of an adjacent block, the candidate motion vector predictor of the current
block is determined, that is, the motion vector predictor list of the current block
is supplemented with the second motion vector having a same motion vector type as
the motion vector of the current block, to enrich the motion vector predictor list
and improve motion vector prediction efficiency.
[0077] Optionally, a method for deriving a second motion vector (and a first motion vector)
for the foregoing spatially adjacent pixel blocks is provided. After the spatially
adjacent pixel block (which is briefly referred to as an adjacent block) is reconstructed
and a reconstructed pixel is obtained, a motion search is performed in a reference
frame by using the reconstructed pixel of the adjacent block based on a predictive
coding mode of the adjacent block and a type of an MV used when motion compensation
is performed on the adjacent block, to obtain the second motion vector (and obtain
the first motion vector if the adjacent block is an intra-frame prediction block).
There may be the following four types of adjacent blocks, and processing manners of
all the types of adjacent blocks are separately provided.
- (A) If inter-frame prediction is used for the adjacent block and only a short-term
motion vector (short-term motion vector, SMV) is used for motion compensation (in
other words, the first motion vector of the adjacent block includes only the SMV),
a motion search is performed in a long-term reference frame to derive a long-term
motion vector (long-term motion vector, LMV) as the second motion vector, and the
SMV used for the motion compensation performed on the adjacent block is used as the
first motion vector. More specifically, the following processing is included: A start
point of the motion search is first determined. All LMVs in spatially adjacent prediction
blocks (optionally, a co-located block may be further included) of the adjacent block
are found (the LMVs are from first motion vectors and second motion vectors of these
blocks). In particular, when there is no available LMV, the second motion vector is
unavailable. Motion compensation is performed by using the reconstructed pixel of
the adjacent block as a template and using each LMV as a motion vector, to obtain
a difference picture (namely, a first difference picture) between a template area
in a current frame and a corresponding template area in a reference frame to which
the LMV points. A location to which an LMV corresponding to a first difference picture
with lowest energy points is used as a search start point LMV_start in a next step
of motion search. The energy of the first difference picture may be calculated in
any one of the following three manners: a sum of squared differences (sum of squared
difference, SSD) of all pixels in the difference picture, a sum of absolute differences
(sum of absolute difference, SAD) of all pixels in the difference picture, and a sum
of absolute Hadamard transformed differences (sum of absolute hadamard transformed
differences, SATD) obtained after Hadamard transform is performed on the difference
picture. The reconstructed pixel of the adjacent block may be all reconstructed pixels
of the adjacent block, may be a reconstructed pixel in an L-shaped area formed by
combining lower right rectangular pixels, pixels in a plurality of right columns,
and pixels in a plurality of lower rows, or the like. This is not specifically limited
herein.
Then, a motion search is performed based on the start point, and the derived LMV is
determined. An optimal MV is searched, by using the reconstructed pixel of the adjacent
block as a template and using LMV_start as the start point, in a search window with
a search range [-X1, X1] in a long-term reference frame corresponding to LMV_start. This optimal MV brings
lowest energy of a difference picture (namely, a second difference picture) between
the template area in the current frame and a template area corresponding to a search
location to which the MV points. This optimal MV is determined as the derived LMV.
Search precision may be 1/4 pixel precision or 1/2 pixel precision, and a search method
may be a full search, a diamond quick search (diamond search), or a hexagon quick
search (hexagon search). X1 is a positive integer greater than or equal to 1. For example, X1 is equal to 1, 2, 3, or 4. The energy of the second difference picture may be calculated
in one of the following three manners: an SAD, an SSD, and an SATD. A method for calculating
the energy of the second difference picture may be the same as or different from that
for calculating the energy of the first difference picture. Preferably, the SAD is
used for both the energy of the first difference picture and the energy of the second
difference picture. Alternatively, the SAD is used for the energy of the first difference
picture, and the SATD is used for the energy of the second difference picture.
- (B) If inter-frame prediction is used for the adjacent block and only an LMV is used
for motion compensation (in other words, the first motion vector of the adjacent block
includes only the LMV), a motion search is performed in a short-term reference frame
to derive an SMV as the second motion vector, and the LMV of the adjacent block is
used as the first motion vector. Either of the following two methods may be used for
implementation. A method 1 is as follows: A start point of the motion search in each
short-term reference frame is first determined. For each reference frame Fs in M short-frame
reference frames in a reference frame list, all SMVs in spatially adjacent prediction
blocks (optionally, a co-located block may be further included) of the adjacent block
are scaled into SMVs pointing to the reference frame Fs (the SMVs are from first motion
vectors and second motion vectors of these blocks). In particular, when there is no
available SMV, the second motion vector is unavailable. Motion compensation is performed
in the reference frame Fs by using the reconstructed pixel of the adjacent block as
a template and using each SMV as a motion vector, and an SMV corresponding to a first
difference picture with lowest energy is used as a start point SMV_start of the motion
search in the short-term reference frame Fs. The foregoing process is performed in
all short-term reference frames, to determine the start point of the motion search
in each short-term reference frame. For each reference frame in the M short-term reference
frames, an optimal MV in the short-term reference frame is determined. For each reference
frame Fs in the M reference frames, an optimal MV is searched in a search window with
a search range [-X2, X2] by using the reconstructed pixel of the adjacent block as a template and using SMV_start
corresponding to the reference frame Fs as the start point of the motion search. This
optimal MV brings lowest energy of a second difference picture between a template
area in a current frame and a template area corresponding to a search location to
which the MV points. X2 is a positive integer greater than or equal to 1. For example, X2 is equal to 1, 2, 3, or 4, or may be another value. This is not specifically limited
herein. The foregoing process is performed in all short-term reference frames, to
determine an optimal MV in each short-term reference frame. Finally, the derived SMV
is determined. Second difference energy corresponding to optimal MVs in the M short-term
reference frames is compared, and an optimal MV corresponding to lowest second difference
energy is determined as the finally derived SMV. A method 2 is as follows: A start
point of the motion search is first determined: All SMVs in spatially adjacent prediction
blocks of the adjacent block are found, motion compensation is performed, by using
the reconstructed pixel of the adjacent block as a template and using each SMV as
a motion vector, in a reference frame corresponding to each SMV, and an SMV corresponding
to a first difference picture with lowest energy is used as a start point SMV_start
of the motion search. Then, the derived SMV is determined. An optimal MV is searched,
by using the reconstructed pixel of the adjacent block as a template and using SMV_start
as the start point of the motion search, in a search window with a search range [-X2, X2] in a short-term reference frame corresponding to SMV_start. This optimal MV brings
lowest energy of a second difference picture between a template area in a current
frame and a template area corresponding to a search location to which the MV points.
- (C) If inter-frame prediction is used for the adjacent block and an SMV and an LMV
are used for motion compensation (in other words, the first motion vector of the adjacent
block includes the SMV and the LMV), the second motion vector does not need to be
derived for the adjacent block, and the second motion vector of the adjacent block
is unavailable.
- (D) If intra-frame prediction is used for the adjacent block, an LMV is derived according
to the method shown in (A), and an SMV is derived according to the method shown in
(B). Energy of second difference pictures corresponding to the SMV and the LMV is
compared, an MV corresponding to a second difference picture with lower energy is
used as the first motion vector, and an MV corresponding to a second difference picture
with higher energy is used as the second motion vector. Optionally, alternatively,
the SMV is always used as the first motion vector, and the LMV is always used as the
second motion vector.
[0078] Optionally, in an implementation, when a frame is coded/decoded, first motion vectors
of all blocks in the frame are stored in a motion vector field in a form of 4 x 4
blocks. This is similar to a motion vector storage manner in HEVC. Second motion vectors
are stored in another motion vector field in a form of 4 x 4 blocks. Therefore, two
types of MVs of spatially adjacent prediction blocks may be obtained in corresponding
motion vector fields. After coding/decoding of the frame is completed, only the first
motion vector field needs to be reserved in a memory, and the second motion vector
field may not be reserved and stored.
[0079] Optionally, to reduce calculation complexity, when an inter-frame coding mode is
used for a reconstructed block and a first motion vector of the reconstructed block
includes only one type of MV, for the reconstructed block, if all first motion vectors
of spatially adjacent prediction blocks of the reconstructed block have a same type
as the first motion vector of the reconstructed block, the foregoing processing of
performing a motion search on the reconstructed block to derive a second motion vector
of the reconstructed block is not performed, and the second motion vector of the block
is unavailable.
[0080] Optionally, to reduce calculation complexity, a coding tree unit (coding tree unit,
CTU) index Start_CTU_index may be added to a slice header, and the foregoing processing
of performing a motion search on the reconstructed block to derive a second motion
vector of the reconstructed block (and derive a first motion vector if the reconstructed
block is an intra-frame code block) is not performed on blocks in a CTU whose CTU
number is less than Start_CTU_index in a picture. Second motion vectors of these blocks
are unavailable, and a first motion vector of an intra-frame code block in these blocks
is also unavailable.
[0081] Referring to FIG. 4, when a spatially adjacent pixel block of the current block includes
at least one spatially adjacent prediction block of the current block, another embodiment
of a motion vector prediction method according to an embodiment of this application
includes the following steps.
[0082] 401. Obtain a reference frame corresponding to a motion vector of the current block.
[0083] 402. Determine a motion vector type of the motion vector of the current block based
on a reference frame type of the reference frame.
[0084] 403. Obtain a motion vector type of a first motion vector of at least one spatially
adjacent prediction block of the current block when the at least one spatially adjacent
prediction block is an inter-frame prediction block.
[0085] Step 401 to step 403 in this embodiment are similar to step 301 to step 303 in the
embodiment shown in FIG. 3. Details are not described herein again.
[0086] 404. If a first motion vector of a spatially adjacent prediction block at a left
preset location relative to the current block has a different motion vector type from
the motion vector of the current block, and a first motion vector of a spatially adjacent
block at an upper preset location relative to the current block has a different motion
vector type from the motion vector of the current block, when at least one second
motion vector of the spatially adjacent prediction block at the left preset location
relative to the current block is available, use the at least one second motion vector
of the spatially adjacent prediction block at the left preset location or a scaling
value of the second motion vector as a candidate motion vector predictor, or when
at least one second motion vector of the spatially adjacent prediction block at the
upper preset location relative to the current block is available, use the at least
one second motion vector of the spatially adjacent prediction block at the upper preset
location or a scaling value of the second motion vector as a candidate motion vector
predictor.
[0087] A device determines whether at least one of first motion vectors of left spatially
adjacent prediction blocks of the current block that has a same motion vector type
as the motion vector of the current block exists. If the at least one of the first
motion vectors exists, the device selects, from the left spatially adjacent prediction
blocks, at least one first motion vector or a scaling value of the first motion vector
as a candidate MVP, and adds the candidate MVP to an MVP list. If the at least one
of the first motion vectors does not exist, in other words, when the first motion
vectors of all the left spatially adjacent prediction blocks of the current block
have different motion vector types from the motion vector of the current block, the
device determines whether first motion vectors of all upper spatially adjacent blocks
of the current block have a same motion vector type as the motion vector of the current
block. If the first motion vectors of all the upper spatially adjacent blocks of the
current block have a same motion vector type as the motion vector of the current block,
the device determines whether second motion vectors in the left spatially adjacent
prediction blocks and the upper spatially adjacent prediction blocks of the current
block are available, and when at least one of the second motion vectors in the left
spatially adjacent prediction blocks and the upper spatially adjacent prediction blocks
of the current block is available, uses the at least one of the second motion vectors
in the left spatially adjacent prediction blocks and the upper spatially adjacent
prediction blocks or a scaling value of the at least one of the second motion vectors
in the left spatially adjacent prediction blocks and the upper spatially adjacent
prediction blocks as a candidate motion vector predictor.
[0088] For example, a process in which the device determines whether the at least one of
the first motion vectors of the left spatially adjacent prediction blocks of the current
block that has the same motion vector type as the motion vector of the current block
exists includes two rounds of screening. A first round of screening is as follows:
The device successively accesses the first motion vectors of the left spatially adjacent
prediction blocks in a preset order 1, determines whether the first motion vectors
meet a condition 1 "the first motion vector is available and a reference frame of
the first motion vector has a same picture order count (picture order count, POC)
as the reference frame of the motion vector of the current block", and first determines,
as a candidate MVP, a first motion vector meeting the condition 1. A second round
of screening is as follows: The device successively accesses the first motion vectors
of the left spatially adjacent prediction blocks in the preset order 1, and determines
whether the first motion vectors meet a condition 2 "the first motion vector is available
and a reference frame of the first motion vector has a same type as the reference
frame of the motion vector of the current block". For a first motion vector meeting
the condition 2, the first motion vector or a scaling value of the first motion vector
is used as a candidate MVP. When types of the two reference frames are short-term
reference frames and are not a same frame, the first motion vector of the spatially
adjacent prediction block needs to be scaled before being used as the candidate MVP.
Scaling of the motion vector is obtained based on a ratio between differences of two
groups of POCs. For example, motion vector scaling processing in HEVC is performed.
[0089] A process in which the device determines whether the at least one of the first motion
vectors of the upper spatially adjacent prediction blocks of the current block that
has the same motion vector type as the motion vector of the current block exists includes
two rounds of screening. A first round of screening is as follows: The device successively
accesses the first motion vectors of the upper spatially adjacent prediction blocks
in a preset order 3, determines whether the first motion vectors meet the condition
1 "the first motion vector is available and a reference frame of the first motion
vector has a same picture order count as the reference frame of the motion vector
of the current block", and first determines, as a candidate MVP, a first motion vector
meeting the condition 1. A second round of screening is as follows: The device successively
accesses the first motion vectors of the upper spatially adjacent prediction blocks
in the preset order 3, and determines whether the first motion vectors meet the condition
2 "the first motion vector is available and a reference frame of the first motion
vector has a same type as the reference frame of the motion vector of the current
block". For a first motion vector meeting the condition 2, the first motion vector
or a scaling value of the first motion vector is used as a candidate MVP. When types
of the two reference frames are short-term reference frames and are not a same frame,
the first motion vector of the adjacent block needs to be scaled before being used
as the candidate MVP. Scaling of the motion vector is obtained based on a ratio between
differences of two groups of POCs. For example, motion vector scaling processing in
HEVC is performed.
[0090] The device determines whether the second motion vectors in the left spatially adjacent
prediction blocks and the upper spatially adjacent prediction blocks of the current
block are available, and if the second motion vectors in the left spatially adjacent
prediction blocks and the upper spatially adjacent prediction blocks of the current
block are available, uses at least one of the second motion vectors in the left spatially
adjacent prediction blocks and the upper spatially adjacent prediction blocks or a
scaling value of the at least one of the second motion vectors in the left spatially
adjacent prediction blocks and the upper spatially adjacent prediction blocks as a
candidate motion vector predictor.
[0091] It should be noted that, before determining whether the second motion vectors in
the left spatially adjacent prediction blocks and the upper spatially adjacent prediction
blocks of the current block are available, the device further needs to determine whether
an MVP list is null (in other words, no first motion vector of a spatially adjacent
block of the current block has a same motion vector type as the motion vector of the
current block). When the MVP list is not null, there is at least one candidate in
the MVP list. When the MVP list is null, the device successively accesses the second
motion vectors in the left spatially adjacent prediction blocks and the upper spatially
adjacent prediction blocks in a preset order 5, and uses K available second motion
vectors in the left spatially adjacent prediction blocks and the upper spatially adjacent
prediction blocks or scaling values of the K second motion vectors as MVPs. K is a
positive integer less than or equal to a length N (namely, a preset value) of the
MVP list. For example, K = 1 or K = 2.
[0092] It may be understood that the left spatially adjacent prediction blocks and the upper
spatially adjacent prediction blocks include blocks located on a left side and an
upper side of the current block. Preferably, the left spatially adjacent prediction
blocks and the upper spatially adjacent prediction blocks include a directly left
block, a directly upper block, an upper right block B
0, and an upper left block B
2, and the access order 5 may be an order from the directly left block A
1 to the directly upper block B
1 to the lower left block A
0 to the upper right block B
0 to the upper left block B
2 or an order from the lower left block A
0 to the directly left block A
1 to the upper right block B
0 to the directly upper block B
1 to the upper left block B
2. Alternatively, preferably, the left spatially adjacent prediction blocks and the
upper spatially adjacent prediction blocks include a directly left block, a directly
upper block, and an upper left block, and the access order 5 may be an order from
the directly left block A
1 to the directly upper block B
1 to the upper left block B
2. Optionally, if the MVP list includes a same candidate MVP, the repeated candidate
MVP is removed from the MVP list, and a candidate MVP quantity is updated.
[0093] 405. When a quantity of candidate motion vector predictors is less than a preset
value, at least one first motion vector of a co-located block of the current block
is available, and a motion vector type of the at least one first motion vector of
the co-located block of the current block is the same as the motion vector type of
the motion vector of the current block, use the at least one first motion vector of
the co-located block or a scaling value of the at least one first motion vector of
the co-located block as a candidate motion vector predictor.
[0094] Optionally, when the quantity of candidate motion vector predictors is less than
the preset value, and the device determines that the first motion vector of the co-located
block of the current block is available, and the motion vector type of the first motion
vector of the co-located block of the current block is the same as the motion vector
type of the motion vector of the current block, the device uses the at least one first
motion vector of the co-located block or the scaling value of the at least one first
motion vector of the co-located block as the candidate motion vector predictor.
[0095] It should be noted that, when the quantity of candidate MVPs selected from spatially
adjacent prediction blocks is less than N (in other words, the MVP list is not fully
filled, and a length of the MVP list is N), an MVP is selected from the first motion
vector of the co-located block, and is added to the MVP list. For example, a value
of N may be that N = 2 or N = 3.
[0096] For example, the device successively accesses first motion vectors of a lower right
block C
0 and a central block C
1 in co-located blocks, and determines whether the first motion vectors obtained from
the co-located blocks meet the condition 2 "the first motion vector is available and
a reference frame of the first motion vector has a same type as the reference frame
of the motion vector of the current block". For a first motion vector meeting the
condition 2, the first motion vector or a scaling value of the first motion vector
is used as a candidate MVP.
[0097] 406. When the quantity of candidate motion vector predictors is less than the preset
value, use at least one zero motion vector as a candidate motion vector predictor,
so that the quantity of candidate motion vector predictors reaches the preset value.
[0098] If the quantity of candidate motion vector predictors is still less than the preset
value, the device uses the at least one zero motion vector as the motion vector predictor,
so that the quantity of candidate motion vector predictors of the current block reaches
the preset value.
[0099] In this embodiment of this application, when the motion vector type of the motion
vector of the current block is different from a motion vector type of a first motion
vector of an adjacent block, the candidate motion vector predictor of the current
block is determined, that is, the motion vector predictor list of the current block
is supplemented with the second motion vector having a same motion vector type as
the motion vector of the current block, to enrich the motion vector predictor list
and improve motion vector prediction efficiency.
[0100] Referring to FIG. 5, when a spatially adjacent pixel block of the current block includes
at least one pixel block that is of the current block and that is within a preset
range, another embodiment of a motion vector prediction method according to an embodiment
of this application includes the following steps.
[0101] 501. Obtain a reference frame corresponding to a motion vector of the current block.
[0102] 502. Determine a motion vector type of the motion vector of the current block based
on a reference frame type of the reference frame.
[0103] 503. Obtain a motion vector type of a first motion vector of at least one spatially
adjacent prediction block of the current block when the at least one spatially adjacent
prediction block is an inter-frame prediction block.
[0104] Step 501 to step 503 in this embodiment are similar to step 401 to step 403 in the
embodiment shown in FIG. 4. Details are not described herein again.
[0105] 504. When a first motion vector of a spatially adjacent prediction block at a left
preset location relative to the current block has a different motion vector type from
the motion vector of the current block, and a first motion vector of a spatially adjacent
prediction block at an upper preset location relative to the current block has a different
motion vector type from the motion vector of the current block, determine, in a first
reference frame of the spatially adjacent pixel block of the current block, a first
reference block having a slightest pixel difference from the spatially adjacent pixel
block of the current block; use a motion vector between the first reference block
and the spatially adjacent pixel block of the current block as a second motion vector,
where a reference frame type of the first reference frame is the same as the reference
frame type of the reference frame corresponding to the motion vector of the current
block; and use the second motion vector or a scaling value of the second motion vector
as a candidate motion vector predictor of the current block.
[0106] In a feasible implementation, when first motion vectors of all left spatially adjacent
prediction blocks of the current block have different motion vector types from the
motion vector of the current block, and first motion vectors of all upper spatially
adjacent prediction blocks of the current block have different motion vector types
from the motion vector of the current block, determine, in the first reference frame
of the pixel block, the first reference block having the slightest pixel difference
from the pixel block; use the motion vector between the first reference block and
the pixel block as the second motion vector, where the reference frame type of the
first reference frame is the same as the reference frame type of the reference frame
corresponding to the motion vector of the current block; and use the second motion
vector or the scaling value of the second motion vector as the candidate motion vector
predictor of the current block.
[0107] It should be noted that, before generating the second motion vector based on the
pixel block of the current block, whether an MVP list is null (in other words, no
first motion vector of a spatially adjacent prediction block of the current block
has a same motion vector type as the motion vector of the current block) further needs
to be determined. When the MVP list is not null, there is at least one candidate MVP
in the MVP list. When the MVP list is null, a device uses the pixel block of the current
block as a template, and finds, in a template matching manner, an optimal matching
location in the reference frame to which the motion vector of the current block points.
A displacement vector between the optimal matching location and a template area of
the current block is used as a second motion vector, and the second motion vector
is used as a candidate MVP.
[0108] For example, a process of determining the second motion vector may be specifically
divided into two steps. Step 1: MVs in a "candidate motion vector set" are compared
to determine a start point of a motion search. The candidate motion vector set includes
at least one of the following two types of MVs: a zero vector (0, 0) and a global
motion vector. Motion compensation is performed in the reference frame of the MV of
the current block by using the pixel block that is of the current block and that is
within the preset range as a template and using each MV in the candidate motion vector
set as a motion vector, to obtain a difference picture (namely, a first difference
picture) between a template area in a current frame and a corresponding template area
in the reference frame. The device uses a location to which an MV corresponding to
a first difference picture with lowest energy points as a search start point MV_start
in a next step of motion search. The energy of the first difference picture may be
calculated in any one of the following three manners: a sum of squared differences
of all pixels in the difference picture, a sum of absolute differences of all pixels
in the difference picture, and a sum of absolute Hadamard transformed differences
obtained after Hadamard transform is performed on the difference picture. An adjacent
reconstructed pixel of the current block may be an upper reconstructed pixel of the
current block, a left reconstructed pixel of the current block, a pixel in an L-shaped
area formed by combining a left reconstructed pixel and an upper reconstructed pixel
of the current block, or the like. This is not specifically limited herein.
[0109] There may be one or more global motion vectors. The global motion vector is identified
in a bitstream (for example, identified in a slice header of the current frame), and
indicates an MV pointing from the current frame to a long-term reference frame. Preferably,
one long-term reference frame may have at least one global motion vector, and a short-term
reference frame has no global motion vector. If the MV of the current block is a short-term
MV, the candidate motion vector set includes only a zero vector. If the MV of the
current block is a long-term MV, the candidate motion vector set of the current block
includes a zero vector, and may further include at least one global motion vector.
The global motion vector may be derived by an encoder by analyzing a motion vector
that is in each area in the current frame and that is relative to a long-term reference
frame. For example, one or two motion vectors with a highest occurrence frequency
in motion vectors in all areas are selected as global motion vectors. A decoding device
obtains the global motion vector of the long-term reference frame of the current frame
by parsing the bitstream (for example, the slice header). Optionally, quantity information
of the global motion vector of the long-term reference frame may be transmitted in
the bitstream. When the quantity information indicates that a global motion vector
quantity is 0, the candidate motion vector set includes no global motion vector, but
includes only a zero vector.
[0110] Step 2: Perform a motion search based on the start point, to determine the second
motion vector. An optimal MV is searched in a search window in the reference frame
of the MV of the current block by using the pixel block that is of the current block
and that is within the preset range as a template and using MV_start as the start
point. This optimal MV brings lowest energy of a difference picture (namely, a second
difference picture) between the template area in the current frame and a template
area corresponding to a search location to which the MV points. This optimal MV is
determined as the second motion vector.
[0111] Search precision may be 1/4 pixel precision or 1/2 pixel precision, and a search
method may be a full search, a diamond quick search (diamond search), or a hexagon
quick search (hexagon search). A search window size may be fixed to 8 x 8 or 16 x
16, or may be adaptively set based on a type of MV_start. For example, when MV_start
is (0, 0), the search window size is 16 x 16. When MV_start is not (0, 0), the search
window size is 8 x 8. The energy of the second difference picture may be calculated
in any one of the following three manners: a sum of squared differences of all pixels
in the difference picture, a sum of absolute differences of all pixels in the difference
picture, and a sum of absolute Hadamard transformed differences obtained after Hadamard
transform is performed on the difference picture. A method for calculating the energy
of the second difference picture is not necessarily the same as that for calculating
the energy of the first difference picture. For example, the sum of absolute differences
of all pixels in the difference picture is used for both the energy of the first difference
picture and the energy of the second difference picture. Alternatively, the sum of
absolute differences of all pixels in the difference picture is used for a first difference
energy, and the sum of squared differences of all pixels in the difference picture
is used for a second difference energy. This is not specifically limited herein.
[0112] It may be understood that, in this case, if the MVP list includes a same candidate
MVP, the repeated candidate MVP is removed from the MVP list, and a candidate MVP
quantity is updated.
[0113] 505. When a quantity of candidate motion vector predictors is less than a preset
value, at least one first motion vector of a co-located block of the current block
is available, and a motion vector type of the at least one first motion vector of
the co-located block of the current block is the same as the motion vector type of
the motion vector of the current block, use the at least one first motion vector of
the co-located block or a scaling value of the at least one first motion vector of
the co-located block as a candidate motion vector predictor.
[0114] Optionally, when the quantity of candidate motion vector predictors is less than
the preset value, and the device determines that the first motion vector of the co-located
block of the current block is available, and the motion vector type of the first motion
vector of the co-located block of the current block is the same as the motion vector
type of the motion vector of the current block, the device uses the at least one first
motion vector of the co-located block or the scaling value of the at least one first
motion vector of the co-located block as the candidate motion vector predictor.
[0115] It should be noted that, when the quantity of candidate MVPs selected from spatially
adjacent prediction blocks is less than N (in other words, the MVP list is not fully
filled, and a length of the MVP list is N), an MVP is selected from the first motion
vector of the co-located block, and is added to the MVP list. For example, a value
of N may be that N = 2 or N = 3.
[0116] For example, the device successively accesses first motion vectors of a lower right
block C
0 and a central block C
1 in co-located blocks, and determines whether the first motion vectors obtained from
the co-located blocks meet a condition 2 "the first motion vector is available and
a reference frame of the first motion vector has a same type as the reference frame
of the motion vector of the current block". For a first motion vector meeting the
condition 2, the first motion vector or a scaling value of the first motion vector
is used as a candidate MVP.
[0117] 506. When the quantity of candidate motion vector predictors is less than the preset
value, use at least one zero motion vector as a candidate motion vector predictor,
so that the quantity of candidate motion vector predictors reaches the preset value.
[0118] If the quantity of candidate motion vector predictors is still less than the preset
value, the device uses the at least one zero motion vector as the motion vector predictor,
so that the quantity of candidate motion vector predictors of the current block reaches
the preset value. In this embodiment of this application, when the motion vector type
of the motion vector of the current block is different from a motion vector type of
a first motion vector of an adjacent block, the second motion vector is derived based
on the pixel block that is of the current block and that is within the preset range,
and the second motion vector is determined as the candidate motion vector predictor
of the current block. The second motion vector has a same type as the motion vector
of the current block. Therefore, the motion vector predictor list is enriched and
motion vector prediction efficiency is improved.
[0119] It should be understood that each of the foregoing motion vector prediction methods
may be used in a coding method for the current block, or may be used in a decoding
method for the current block.
[0120] The foregoing describes the motion vector prediction methods in the embodiments of
this application, and the following describes a motion vector prediction device in
an embodiment of this application. Referring to FIG. 6, an embodiment of a motion
vector prediction device according to an embodiment of this application includes:
a first obtaining unit 601, configured to obtain a reference frame corresponding to
a motion vector of a current block;
a determining unit 602, configured to determine a motion vector type of the motion
vector of the current block based on a reference frame type of the reference frame,
where the motion vector type includes a short-term motion vector and a long-term motion
vector, the short-term motion vector is obtained from a short-term reference frame,
and the long-term motion vector is obtained from a long-term reference frame;
a second obtaining unit 603, configured to obtain a motion vector type of a first
motion vector of at least one spatially adjacent prediction block of the current block
when the at least one spatially adjacent prediction block is an inter-frame prediction
block, where the first motion vector is used to perform inter-frame prediction on
the spatially adjacent prediction block; and
a first processing unit 604, configured to: when the obtained motion vector type of
the first motion vector is different from all motion vector types of motion vectors
of the current block, determine a second motion vector of a spatially adjacent pixel
block of the current block based on decoding information of the adjacent pixel block,
and use the second motion vector or a scaling value of the second motion vector as
a candidate motion vector predictor of the current block.
[0121] Optionally, the device may further include:
a second processing unit 605, configured to use the at least one first motion vector
as a candidate motion vector predictor of the current block when the obtained motion
vector type of the at least one first motion vector is the same as the motion vector
type of the motion vector of the current block.
[0122] Optionally, the device may further include:
a third processing unit 606, configured to: when all spatially adjacent prediction
blocks of the current block are intra-frame prediction blocks, determine, in a virtual
reference frame of at least one of the spatially adjacent prediction blocks, a virtual
reference block having a slightest pixel difference from the spatially adjacent prediction
block, and use a motion vector between the virtual reference block and the spatially
adjacent prediction block as a motion vector predictor of the current block, where
a reference frame type of the virtual reference frame is the same as the reference
frame type of the reference frame corresponding to the motion vector of the current
block, and the virtual reference frame is a reconstructed frame.
[0123] Optionally, the first processing unit 604 may further include:
a first processing module 6041, configured to: determine, in a first reference frame
of the spatially adjacent pixel block, a first reference block having a slightest
pixel difference from the spatially adjacent pixel block; use a motion vector between
the first reference block and the spatially adjacent pixel block as the second motion
vector, where a reference frame type of the first reference frame is the same as the
reference frame type of the reference frame corresponding to the motion vector of
the current block; and use the second motion vector or the scaling value of the second
motion vector as the candidate motion vector predictor of the current block.
[0124] Optionally, the first processing module 6041 may further include:
a first processing submodule 60411, configured to: when a first motion vector of a
spatially adjacent prediction block at a left preset location relative to the current
block has a different motion vector type from the motion vector of the current block,
and a first motion vector of a spatially adjacent prediction block at an upper preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, determine, in the first reference frame of the
spatially adjacent pixel block, the first reference block having the slightest pixel
difference from the spatially adjacent pixel block; use the motion vector between
the first reference block and the spatially adjacent pixel block as the second motion
vector, where the reference frame type of the first reference frame is the same as
the reference frame type of the reference frame corresponding to the motion vector
of the current block; and use the second motion vector or the scaling value of the
second motion vector as the candidate motion vector predictor of the current block.
[0125] In this embodiment of this application, when the motion vector type of the motion
vector of the current block is different from a motion vector type of a first motion
vector of an adjacent block, the second motion vector having a same motion vector
type as the motion vector of the current block is used as the candidate motion vector
predictor of the current block, to enrich a motion vector predictor list and improve
motion vector prediction efficiency.
[0126] Referring to FIG. 7, another embodiment of a motion vector prediction device according
to an embodiment of this application includes the first obtaining unit 601, the determining
unit 602, the second obtaining unit 603, and the first processing unit 604 in the
embodiment corresponding to FIG. 6.
[0127] Optionally, the first processing unit 604 may further include:
a second processing module 6042, configured to use a second motion vector of the at
least one spatially adjacent prediction block or a scaling value of the second motion
vector of the at least one spatially adjacent prediction block as the candidate motion
vector predictor of the current block.
[0128] Optionally, the second processing module 6042 may further include:
a second processing submodule 60421, configured to: when a first motion vector of
a spatially adjacent prediction block at a left preset location relative to the current
block has a different motion vector type from the motion vector of the current block,
and at least one second motion vector of the spatially adjacent prediction block at
the left preset location is available, use the at least one second motion vector of
the spatially adjacent prediction block at the left preset location or a scaling value
of the at least one second motion vector of the spatially adjacent prediction block
at the left preset location as the candidate motion vector predictor of the current
block; and
a third processing submodule 60422, configured to: when a first motion vector of a
spatially adjacent prediction block at an upper preset location relative to the current
block has a different motion vector type from the motion vector of the current block,
and at least one second motion vector of the spatially adjacent prediction block at
the upper preset location is available, use the at least one second motion vector
of the spatially adjacent prediction block at the upper preset location or a scaling
value of the at least one second motion vector of the spatially adjacent prediction
block at the upper preset location as the candidate motion vector predictor of the
current block.
[0129] Referring to FIG. 8, another embodiment of a motion vector prediction device according
to an embodiment of this application includes the first obtaining unit 601, the determining
unit 602, the second obtaining unit 603, and the first processing unit 604 in the
embodiment corresponding to FIG. 6.
[0130] Optionally, the first processing unit 604 may further include:
a second processing module 6042, configured to use a second motion vector of the at
least one spatially adjacent prediction block or a scaling value of the second motion
vector of the at least one spatially adjacent prediction block as the candidate motion
vector predictor of the current block.
[0131] Optionally, the second processing module 6042 may further include:
a fourth processing submodule 60423, configured to: if a first motion vector of a
spatially adjacent prediction block at a left preset location relative to the current
block has a different motion vector type from the motion vector of the current block,
and a first motion vector of a spatially adjacent block at an upper preset location
relative to the current block has a different motion vector type from the motion vector
of the current block, when at least one second motion vector of the spatially adjacent
prediction block at the left preset location relative to the current block is available,
use the at least one second motion vector of the spatially adjacent prediction block
at the left preset location or a scaling value of the second motion vector as the
candidate motion vector predictor of the current block, or when at least one second
motion vector of the spatially adjacent prediction block at the upper preset location
relative to the current block is available, use the at least one second motion vector
of the spatially adjacent prediction block at the upper preset location or a scaling
value of the second motion vector as the candidate motion vector predictor of the
current block.
[0132] It should be understood that the foregoing motion vector prediction device may be
used in an encoder for coding the current block, or may be used in a decoder for decoding
the current block.
[0133] The foregoing separately describes in detail the motion vector prediction devices
in the embodiments of this application from a perspective of a modular function entity
in FIG. 6 to FIG. 8. The following describes in detail a motion vector prediction
device in an embodiment of this application from a perspective of hardware processing.
[0134] FIG. 9 is a schematic structural diagram of a motion vector prediction device according
to an embodiment of this application. When an integrated unit is used, FIG. 9 shows
a schematic diagram of a possible structure of the device in the foregoing embodiments.
A device 900 includes a processing unit 902 and a communications unit 903. The processing
unit 902 is configured to control and manage an action of the device. For example,
the processing unit 902 is configured to support the device in performing step 301
to step 307 in FIG. 3, and/or another process in a technology described in this specification.
The communications unit 903 is configured to support the device in communicating with
another device. The device may further include a storage unit 901, configured to store
program code and data of the device.
[0135] The processing unit 902 may be a processor or a controller, for example, may be a
central processing unit (central processing unit, CPU), a general-purpose processor,
a digital signal processor (digital signal processor, DSP), an application-specific
integrated circuit (application-specific integrated circuit, ASIC), a field programmable
gate array (field programmable gate array, FPGA) or another programmable logic device,
a transistor logic device, a hardware component, or any combination thereof. The processing
unit 902 may implement or execute various example logical blocks, modules, and circuits
described with reference to content disclosed in this application. Alternatively,
the processor may be a combination of processors implementing a computing function,
for example, a combination of one or more microprocessors, a combination of a DSP
and a microprocessor, or the like. The communications unit 903 may be a communications
interface, a transceiver, a transceiver circuit, or the like. The communications interface
is a collective term, and may include one or more interfaces such as transceiver interfaces.
The storage unit 901 may be a memory.
[0136] When the processing unit 902 is a processor, the communications unit 903 is a communications
interface, and the storage unit 901 is a memory, the device in this embodiment of
this application may be a device shown in FIG. 10.
[0137] Referring to FIG. 10, the device 1010 includes a processor 1012, a communications
interface 1013, and a memory 1011. Optionally, the device 1010 may further include
a bus 1014. The communications interface 1013, the processor 1012, and the memory
1011 may be connected to each other by using the bus 1014. The bus 1014 may be a peripheral
component interconnect (peripheral component interconnect, PCI) bus, an extended industry
standard architecture (extended industry standard architecture, EISA) bus, or the
like. The bus 1014 may be classified into an address bus, a data bus, a control bus,
and the like. For ease of representation, only one bold line is used for representation
in FIG. 10. However, this does not mean that there is only one bus or only one type
of bus.
[0138] In a feasible implementation, FIG. 11 and FIG. 12 show a codec apparatus 50 according
to an embodiment of this application. The codec apparatus 50 may be a mobile terminal
or user equipment in a wireless communications system. It should be understood that
this embodiment of this application may be implemented in any electronic device or
apparatus that may need to code and/or decode a video picture.
[0139] The codec apparatus 50 may include a housing 30 that is used to incorporate and protect
a device, a display 32 (which may be specifically a liquid crystal display), and a
keypad 34. The codec apparatus 50 may include a microphone 36 or any appropriate audio
input, and the audio input may be digital or analog signal input. The codec apparatus
50 may further include the following audio output device, and in this embodiment of
this application, the audio output device may be any one of an earphone 38, a loudspeaker,
an analog audio output connection, or a digital audio output connection. The codec
apparatus 50 may also include a battery 40. In another embodiment of this application,
the device may be powered by any appropriate mobile energy device such as a solar
cell, a fuel cell, or a clock mechanism generator. The apparatus may further include
an infrared port 42 used for short-range line-of-sight communication with another
device. In another embodiment, the codec apparatus 50 may further include any appropriate
short-range communication solution such as a Bluetooth wireless connection or a USB
wired connection.
[0140] The codec apparatus 50 may include a controller 56 or a processor configured to control
the codec apparatus 50. The controller 56 may be connected to a memory 58. In this
embodiment of this application, the memory may store data that is in a form of a picture
and data that is in a form of audio, and/or may store an instruction to be implemented
by the controller 56. The controller 56 may be further connected to a codec 54 that
is suitable for implementing audio and/or video data coding and decoding, or for aided
coding and decoding that are implemented by the controller 56.
[0141] The codec apparatus 50 may further include a card reader 48 and a smart card 46 that
are configured to provide user information and that are suitable for providing authentication
information used to perform authentication and authorization on a user in a network,
for example, an integrated circuit card (universal integrated circuit card, UICC)
and a UICC reader.
[0142] The codec apparatus 50 may further include a radio interface circuit 52. The radio
interface circuit is connected to the controller and is suitable for generating, for
example, a wireless communication signal used for communication with a cellular communications
network, a wireless communications system, or a wireless local area network. The codec
apparatus 50 may further include an antenna 44. The antenna is connected to the radio
interface circuit 52, and is configured to: send, to another apparatus (or a plurality
of apparatuses), a radio frequency signal generated in the radio interface circuit
52, and receive a radio frequency signal from the another apparatus (or the plurality
of apparatuses).
[0143] In some embodiments of this application, the codec apparatus 50 includes a camera
that can record or detect single frames, and the codec 54 or the controller receives
and processes these single frames. In some embodiments of this application, the codec
apparatus 50 may receive to-be-processed video picture data from another device before
transmission and/or storage. In some embodiments of this application, the codec apparatus
50 may receive, through a wireless or wired connection, a picture to be coded/decoded.
[0144] All or some of the foregoing embodiments may be implemented by using software, hardware,
firmware, or any combination thereof. When the software is used to implement the embodiments,
the embodiments may be implemented completely or partially in a form of a computer
program product.
[0145] The computer program product includes one or more computer instructions. When the
computer program instructions are loaded and executed on a computer, the procedure
or functions according to the embodiments of this application are all or partially
generated. The computer may be a general-purpose computer, a dedicated computer, a
computer network, or another programmable device. The computer instructions may be
stored in a computer-readable storage medium or may be transmitted from a computer-readable
storage medium to another computer-readable storage medium. For example, the computer
instructions may be transmitted from a website, computer, server, or data center to
another website, computer, server, or data center in a wired (for example, a coaxial
cable, an optical fiber, or a digital subscriber line (digital subscriber line, DSL))
or wireless (for example, infrared, radio, or microwave) manner. The computer-readable
storage medium may be any usable medium accessible by a computer, or a data storage
device, such as a server or a data center, integrating one or more usable media. The
usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or
a magnetic tape), an optical medium (for example, a DVD), a semiconductor medium (for
example, a solid-state drive (solid-state disk, SSD)), or the like.
[0146] It may be clearly understood by persons skilled in the art that, for ease of convenient
and brief description, for a detailed working process of the foregoing system, device,
and unit, refer to a corresponding process in the foregoing method embodiments. Details
are not described herein.
[0147] In the embodiments provided in this application, it should be understood that the
disclosed system, device, and method may be implemented in other manners. For example,
the described device embodiment is merely an example. For example, the unit division
is merely logical function division. There may be another division manner in actual
implementation. For example, a plurality of units or components may be combined or
integrated into another system, or some features may be ignored or not performed.
In addition, the displayed or discussed mutual couplings or direct couplings or communication
connections may be implemented by using some interfaces. The indirect couplings or
communication connections between the devices or units may be implemented in electronic,
mechanical, or other forms.
[0148] The units described as separate parts may or may not be physically separate, and
parts displayed as units may or may not be physical units, may be located in one position,
or may be distributed on a plurality of network units. Some or all of the units may
be selected based on an actual requirement to achieve an objective of a solution in
the embodiments.
[0149] In addition, function units in the embodiments of this application may be integrated
into one processing unit, or each of the units may exist alone physically, or two
or more units are integrated into one unit. The integrated unit may be implemented
in a form of hardware, or may be implemented in a form of a software function unit.
[0150] When the integrated unit is implemented in the form of a software function unit and
sold or used as an independent product, the integrated unit may be stored in a computer-readable
storage medium. Based on such an understanding, the technical solutions of this application
essentially, or the part contributing to the prior art, or all or some of the technical
solutions may be implemented in the form of a software product. The computer software
product is stored in a storage medium and includes several instructions for instructing
a computer device (which may be a personal computer, a server, or a network device)
to perform all or some of the steps of the methods described in the embodiments of
this application. The storage medium includes any medium that can store program code,
for example, a USB flash drive, a removable hard disk, a read-only memory (read-only
memory, ROM), a random access memory (random access memory, RAM), a magnetic disk,
or a compact disc.
[0151] In conclusion, the foregoing embodiments are merely intended to describe the technical
solutions of this application, but not to limit this application. Although this application
is described in detail with reference to the foregoing embodiments, persons of ordinary
skill in the art should understand that they may still make modifications to the technical
solutions recorded in the foregoing embodiments or make equivalent replacements to
some technical features thereof, without departing from the spirit and scope of the
technical solutions of the embodiments of this application.
1. A motion vector prediction method, comprising:
obtaining a reference frame corresponding to a motion vector of a current block;
determining a motion vector type of the motion vector of the current block based on
a reference frame type of the reference frame, wherein the motion vector type comprises
a short-term motion vector and a long-term motion vector, the short-term motion vector
is obtained from a short-term reference frame, and the long-term motion vector is
obtained from a long-term reference frame;
obtaining a motion vector type of a first motion vector of at least one spatially
adjacent prediction block of the current block when the at least one spatially adjacent
prediction block is an inter-frame prediction block, wherein the first motion vector
is used to perform inter-frame prediction on the spatially adjacent prediction block;
and
when the obtained motion vector type of the first motion vector is different from
all motion vector types of motion vectors of the current block, determining a second
motion vector of a spatially adjacent pixel block of the current block based on decoding
information of the adjacent pixel block, and using the second motion vector or a scaling
value of the second motion vector as a candidate motion vector predictor of the current
block.
2. The method according to claim 1, wherein the method further comprises:
using the at least one first motion vector as a candidate motion vector predictor
of the current block when the obtained motion vector type of the at least one first
motion vector is the same as the motion vector type of the motion vector of the current
block.
3. The method according to claim 1 or 2, wherein the method further comprises:
when all spatially adjacent prediction blocks of the current block are intra-frame
prediction blocks, determining, in a virtual reference frame of at least one of the
spatially adjacent prediction blocks, a virtual reference block having a slightest
pixel difference from the spatially adjacent prediction block, and using a motion
vector between the virtual reference block and the spatially adjacent prediction block
as a motion vector predictor of the current block, wherein a reference frame type
of the virtual reference frame is the same as the reference frame type of the reference
frame corresponding to the motion vector of the current block, and the virtual reference
frame is a reconstructed frame.
4. The method according to claim 1, wherein the spatially adjacent pixel block of the
current block comprises at least one pixel block that is spatially adjacent to the
current block and that is within a preset range, correspondingly, the decoding information
of the spatially adjacent pixel block of the current block comprises a pixel reconstruction
value of the at least one pixel block that is spatially adjacent to the current block
and that is within the preset range, and correspondingly, the determining a second
motion vector of a spatially adjacent pixel block of the current block based on decoding
information of the adjacent pixel block, and using the second motion vector or a scaling
value of the second motion vector as a candidate motion vector predictor of the current
block comprises:
determining, in a first reference frame of the spatially adjacent pixel block, a first
reference block having a slightest pixel difference from the spatially adjacent pixel
block; using a motion vector between the first reference block and the spatially adjacent
pixel block as the second motion vector, wherein a reference frame type of the first
reference frame is the same as the reference frame type of the reference frame corresponding
to the motion vector of the current block; and using the second motion vector or the
scaling value of the second motion vector as the candidate motion vector predictor
of the current block.
5. The method according to claim 4, wherein the determining, in a first reference frame
of the spatially adjacent pixel block, a first reference block having a slightest
pixel difference from the spatially adjacent pixel block; using a motion vector between
the first reference block and the spatially adjacent pixel block as the second motion
vector, wherein a reference frame type of the first reference frame is the same as
the reference frame type of the reference frame corresponding to the motion vector
of the current block; and using the second motion vector or the scaling value of the
second motion vector as the candidate motion vector predictor of the current block
comprises:
when a first motion vector of a spatially adjacent prediction block at a left preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, and a first motion vector of a spatially adjacent
prediction block at an upper preset location relative to the current block has a different
motion vector type from the motion vector of the current block, determining, in the
first reference frame of the spatially adjacent pixel block, the first reference block
having the slightest pixel difference from the spatially adjacent pixel block; using
the motion vector between the first reference block and the spatially adjacent pixel
block as the second motion vector, wherein the reference frame type of the first reference
frame is the same as the reference frame type of the reference frame corresponding
to the motion vector of the current block; and using the second motion vector or the
scaling value of the second motion vector as the candidate motion vector predictor
of the current block.
6. The method according to claim 1, wherein the spatially adjacent pixel block of the
current block comprises at least one spatially adjacent prediction block of the current
block, correspondingly, the decoding information of the spatially adjacent pixel block
of the current block comprises a second motion vector of the at least one spatially
adjacent prediction block of the current block, a motion vector type of the second
motion vector is different from the motion vector type of the first motion vector,
and correspondingly, the determining a second motion vector of a spatially adjacent
pixel block of the current block based on decoding information of the adjacent pixel
block, and using the second motion vector or a scaling value of the second motion
vector as a candidate motion vector predictor of the current block comprises:
using the second motion vector of the at least one spatially adjacent prediction block
or a scaling value of the second motion vector of the at least one spatially adjacent
prediction block as the candidate motion vector predictor of the current block.
7. The method according to claim 6, wherein the using the second motion vector of the
at least one spatially adjacent prediction block or a scaling value of the second
motion vector of the at least one spatially adjacent prediction block as the candidate
motion vector predictor of the current block comprises:
when a first motion vector of a spatially adjacent prediction block at a left preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, and at least one second motion vector of the spatially
adjacent prediction block at the left preset location is available, using the at least
one second motion vector of the spatially adjacent prediction block at the left preset
location or a scaling value of the at least one second motion vector of the spatially
adjacent prediction block at the left preset location as the candidate motion vector
predictor of the current block; and
when a first motion vector of a spatially adjacent prediction block at an upper preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, and at least one second motion vector of the spatially
adjacent prediction block at the upper preset location is available, using the at
least one second motion vector of the spatially adjacent prediction block at the upper
preset location or a scaling value of the at least one second motion vector of the
spatially adjacent prediction block at the upper preset location as the candidate
motion vector predictor of the current block.
8. The method according to claim 6, wherein the using the second motion vector of the
at least one spatially adjacent prediction block or a scaling value of the second
motion vector of the at least one spatially adjacent prediction block as the candidate
motion vector predictor of the current block comprises:
if a first motion vector of a spatially adjacent prediction block at a left preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, and a first motion vector of a spatially adjacent
block at an upper preset location relative to the current block has a different motion
vector type from the motion vector of the current block, when at least one second
motion vector of the spatially adjacent prediction block at the left preset location
relative to the current block is available, using the at least one second motion vector
of the spatially adjacent prediction block at the left preset location or a scaling
value of the second motion vector as the candidate motion vector predictor of the
current block, or when at least one second motion vector of the spatially adjacent
prediction block at the upper preset location relative to the current block is available,
using the at least one second motion vector of the spatially adjacent prediction block
at the upper preset location or a scaling value of the second motion vector as the
candidate motion vector predictor of the current block.
9. The method according to any one of claims 1 to 8, wherein the method may be used in
a coding method for the current block or a decoding method for the current block.
10. A motion vector prediction device, comprising:
a first obtaining unit, configured to obtain a reference frame corresponding to a
motion vector of a current block;
a determining unit, configured to determine a motion vector type of the motion vector
of the current block based on a reference frame type of the reference frame, wherein
the motion vector type comprises a short-term motion vector and a long-term motion
vector, the short-term motion vector is obtained from a short-term reference frame,
and the long-term motion vector is obtained from a long-term reference frame;
a second obtaining unit, configured to obtain a motion vector type of a first motion
vector of at least one spatially adjacent prediction block of the current block when
the at least one spatially adjacent prediction block is an inter-frame prediction
block, wherein the first motion vector is used to perform inter-frame prediction on
the spatially adjacent prediction block; and
a first processing unit, configured to: when the obtained motion vector type of the
first motion vector is different from all motion vector types of motion vectors of
the current block, determine a second motion vector of a spatially adjacent pixel
block of the current block based on decoding information of the adjacent pixel block,
and use the second motion vector or a scaling value of the second motion vector as
a candidate motion vector predictor of the current block.
11. The device according to claim 10, wherein the device further comprises:
a second processing unit, configured to use the at least one first motion vector as
a candidate motion vector predictor of the current block when the obtained motion
vector type of the at least one first motion vector is the same as the motion vector
type of the motion vector of the current block.
12. The device according to claim 10 or 11, wherein the device further comprises:
a third processing unit, configured to: when all spatially adjacent prediction blocks
of the current block are intra-frame prediction blocks, determine, in a virtual reference
frame of at least one of the spatially adjacent prediction blocks, a virtual reference
block having a slightest pixel difference from the spatially adjacent prediction block,
and use a motion vector between the virtual reference block and the spatially adjacent
prediction block as a motion vector predictor of the current block, wherein a reference
frame type of the virtual reference frame is the same as the reference frame type
of the reference frame corresponding to the motion vector of the current block, and
the virtual reference frame is a reconstructed frame.
13. The device according to claim 10, wherein the spatially adjacent pixel block of the
current block comprises at least one pixel block that is spatially adjacent to the
current block and that is within a preset range, correspondingly, the decoding information
of the spatially adjacent pixel block of the current block comprises a pixel reconstruction
value of the at least one pixel block that is spatially adjacent to the current block
and that is within the preset range, and correspondingly, the first processing unit
comprises:
a first processing module, configured to: determine, in a first reference frame of
the spatially adjacent pixel block, a first reference block having a slightest pixel
difference from the spatially adjacent pixel block; use a motion vector between the
first reference block and the spatially adjacent pixel block as the second motion
vector, wherein a reference frame type of the first reference frame is the same as
the reference frame type of the reference frame corresponding to the motion vector
of the current block; and use the second motion vector or the scaling value of the
second motion vector as the candidate motion vector predictor of the current block.
14. The device according to claim 13, wherein the first processing module comprises:
a first processing submodule, configured to: when a first motion vector of a spatially
adjacent prediction block at a left preset location relative to the current block
has a different motion vector type from the motion vector of the current block, and
a first motion vector of a spatially adjacent prediction block at an upper preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, determine, in the first reference frame of the
spatially adjacent pixel block, the first reference block having the slightest pixel
difference from the spatially adjacent pixel block; use the motion vector between
the first reference block and the spatially adjacent pixel block as the second motion
vector, wherein the reference frame type of the first reference frame is the same
as the reference frame type of the reference frame corresponding to the motion vector
of the current block; and use the second motion vector or the scaling value of the
second motion vector as the candidate motion vector predictor of the current block.
15. The device according to claim 10, wherein the spatially adjacent pixel block of the
current block comprises at least one spatially adjacent prediction block of the current
block, correspondingly, the decoding information of the spatially adjacent pixel block
of the current block comprises a second motion vector of the at least one spatially
adjacent prediction block of the current block, a motion vector type of the second
motion vector is different from the motion vector type of the first motion vector,
and correspondingly, the first processing unit comprises:
a second processing module, configured to use the second motion vector of the at least
one spatially adjacent prediction block or a scaling value of the second motion vector
of the at least one spatially adjacent prediction block as the candidate motion vector
predictor of the current block.
16. The device according to claim 15, wherein the second processing module comprises:
a second processing submodule, configured to: when a first motion vector of a spatially
adjacent prediction block at a left preset location relative to the current block
has a different motion vector type from the motion vector of the current block, and
at least one second motion vector of the spatially adjacent prediction block at the
left preset location is available, use the at least one second motion vector of the
spatially adjacent prediction block at the left preset location or a scaling value
of the at least one second motion vector of the spatially adjacent prediction block
at the left preset location as the candidate motion vector predictor of the current
block; and
a third processing submodule, configured to: when a first motion vector of a spatially
adjacent prediction block at an upper preset location relative to the current block
has a different motion vector type from the motion vector of the current block, and
at least one second motion vector of the spatially adjacent prediction block at the
upper preset location is available, use the at least one second motion vector of the
spatially adjacent prediction block at the upper preset location or a scaling value
of the at least one second motion vector of the spatially adjacent prediction block
at the upper preset location as the candidate motion vector predictor of the current
block.
17. The device according to claim 15, wherein the second processing module comprises:
a fourth processing submodule, configured to: if a first motion vector of a spatially
adjacent prediction block at a left preset location relative to the current block
has a different motion vector type from the motion vector of the current block, and
a first motion vector of a spatially adjacent block at an upper preset location relative
to the current block has a different motion vector type from the motion vector of
the current block, when at least one second motion vector of the spatially adjacent
prediction block at the left preset location relative to the current block is available,
use the at least one second motion vector of the spatially adjacent prediction block
at the left preset location or a scaling value of the second motion vector as the
candidate motion vector predictor of the current block, or when at least one second
motion vector of the spatially adjacent prediction block at the upper preset location
relative to the current block is available, use the at least one second motion vector
of the spatially adjacent prediction block at the upper preset location or a scaling
value of the second motion vector as the candidate motion vector predictor of the
current block.
18. The device according to any one of claims 10 to 17, wherein the device may be used
in an encoder for coding the current block or a decoder for decoding the current block.
19. A motion vector prediction device, wherein the device comprises a processor and a
memory coupled to the processor, wherein
the processor is configured to:
obtain a reference frame corresponding to a motion vector of a current block;
determine a motion vector type of the motion vector of the current block based on
a reference frame type of the reference frame, wherein the motion vector type comprises
a short-term motion vector and a long-term motion vector, the short-term motion vector
is obtained from a short-term reference frame, and the long-term motion vector is
obtained from a long-term reference frame;
obtain a motion vector type of a first motion vector of at least one spatially adjacent
prediction block of the current block when the at least one spatially adjacent prediction
block is an inter-frame prediction block, wherein the first motion vector is used
to perform inter-frame prediction on the spatially adjacent prediction block; and
when the obtained motion vector type of the first motion vector is different from
all motion vector types of motion vectors of the current block, determine a second
motion vector of a spatially adjacent pixel block of the current block based on decoding
information of the adjacent pixel block, and use the second motion vector or a scaling
value of the second motion vector as a candidate motion vector predictor of the current
block.
20. The device according to claim 19, wherein the processor is further configured to:
use the at least one first motion vector as a candidate motion vector predictor of
the current block when the obtained motion vector type of the at least one first motion
vector is the same as the motion vector type of the motion vector of the current block.
21. The device according to claim 19 or 20, wherein the processor is further configured
to:
when all spatially adjacent prediction blocks of the current block are intra-frame
prediction blocks, determine, in a virtual reference frame of at least one of the
spatially adjacent prediction blocks, a virtual reference block having a slightest
pixel difference from the spatially adjacent prediction block, and use a motion vector
between the virtual reference block and the spatially adjacent prediction block as
a motion vector predictor of the current block, wherein a reference frame type of
the virtual reference frame is the same as the reference frame type of the reference
frame corresponding to the motion vector of the current block, and the virtual reference
frame is a reconstructed frame.
22. The device according to claim 19, wherein the spatially adjacent pixel block of the
current block comprises at least one pixel block that is spatially adjacent to the
current block and that is within a preset range, correspondingly, the decoding information
of the spatially adjacent pixel block of the current block comprises a pixel reconstruction
value of the at least one pixel block that is spatially adjacent to the current block
and that is within the preset range, and correspondingly, the processor is configured
to:
determine, in a first reference frame of the spatially adjacent pixel block, a first
reference block having a slightest pixel difference from the spatially adjacent pixel
block; use a motion vector between the first reference block and the spatially adjacent
pixel block as the second motion vector, wherein a reference frame type of the first
reference frame is the same as the reference frame type of the reference frame corresponding
to the motion vector of the current block; and use the second motion vector or the
scaling value of the second motion vector as the candidate motion vector predictor
of the current block.
23. The device according to claim 22, wherein the processor is configured to:
when a first motion vector of a spatially adjacent prediction block at a left preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, and a first motion vector of a spatially adjacent
prediction block at an upper preset location relative to the current block has a different
motion vector type from the motion vector of the current block, determine, in the
first reference frame of the spatially adjacent pixel block, the first reference block
having the slightest pixel difference from the spatially adjacent pixel block; use
the motion vector between the first reference block and the spatially adjacent pixel
block as the second motion vector, wherein the reference frame type of the first reference
frame is the same as the reference frame type of the reference frame corresponding
to the motion vector of the current block; and use the second motion vector or the
scaling value of the second motion vector as the candidate motion vector predictor
of the current block.
24. The device according to claim 19, wherein the spatially adjacent pixel block of the
current block comprises at least one spatially adjacent prediction block of the current
block, correspondingly, the decoding information of the spatially adjacent pixel block
of the current block comprises a second motion vector of the at least one spatially
adjacent prediction block of the current block, a motion vector type of the second
motion vector is different from the motion vector type of the first motion vector,
and correspondingly, the processor is configured to:
use the second motion vector of the at least one spatially adjacent prediction block
or a scaling value of the second motion vector of the at least one spatially adjacent
prediction block as the candidate motion vector predictor of the current block.
25. The device according to claim 24, wherein the processor is configured to:
when a first motion vector of a spatially adjacent prediction block at a left preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, and at least one second motion vector of the spatially
adjacent prediction block at the left preset location is available, use the at least
one second motion vector of the spatially adjacent prediction block at the left preset
location or a scaling value of the at least one second motion vector of the spatially
adjacent prediction block at the left preset location as the candidate motion vector
predictor of the current block; and
when a first motion vector of a spatially adjacent prediction block at an upper preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, and at least one second motion vector of the spatially
adjacent prediction block at the upper preset location is available, use the at least
one second motion vector of the spatially adjacent prediction block at the upper preset
location or a scaling value of the at least one second motion vector of the spatially
adjacent prediction block at the upper preset location as the candidate motion vector
predictor of the current block.
26. The device according to claim 24, wherein the processor is configured to:
if a first motion vector of a spatially adjacent prediction block at a left preset
location relative to the current block has a different motion vector type from the
motion vector of the current block, and a first motion vector of a spatially adjacent
block at an upper preset location relative to the current block has a different motion
vector type from the motion vector of the current block, when at least one second
motion vector of the spatially adjacent prediction block at the left preset location
relative to the current block is available, use the at least one second motion vector
of the spatially adjacent prediction block at the left preset location or a scaling
value of the second motion vector as the candidate motion vector predictor of the
current block, or when at least one second motion vector of the spatially adjacent
prediction block at the upper preset location relative to the current block is available,
use the at least one second motion vector of the spatially adjacent prediction block
at the upper preset location or a scaling value of the second motion vector as the
candidate motion vector predictor of the current block.
27. The device according to any one of claims 19 to 26, wherein the device may be used
in an encoder for coding the current block or a decoder for decoding the current block.