Point cloud encoding method and apparatus, point cloud decoding method and apparatus, and electronic device
This application pertains to the field of encoding and decoding technologies, and discloses a point cloud encoding method and apparatus, a point cloud decoding method and apparatus, and an electronic device. The point cloud encoding method in embodiments of this application includes: obtaining, by an encoder, a to-be-encoded node in a point cloud sequence and m encoded reference nodes in the point cloud sequence, where m is a positive integer; determining, by the encoder, a context of a to-be-encoded subnode based on occupancy information of the m reference nodes and a position of the to-be-encoded subnode in the to-be-encoded node, where the to-be-encoded subnode is any subnode obtained by partitioning the to-be-encoded node based on a structure tree; and performing, by the encoder, entropy encoding on the to-be-encoded subnode based on the context to generate a target bit stream.
1 . A point cloud encoding method, comprising:
obtaining, by an encoder, a to-be-encoded node in a point cloud sequence;
obtaining, by the encoder based on a node encoding order, k encoded nodes previous to the to-be-encoded node, wherein k is a positive integer greater than 1;
when at least one of the previous k encoded nodes has a target planar feature, obtaining, by the encoder, m encoded reference nodes in the point cloud sequence, wherein m is a positive integer;
determining, by the encoder, a context of a to-be-encoded subnode based on occupancy information of the m reference nodes and a position of the to-be-encoded subnode in the to-be-encoded node, wherein the to-be-encoded subnode is any subnode obtained by partitioning the to-be-encoded node based on a structure tree; and
performing, by the encoder, entropy encoding on the to-be-encoded subnode based on the context to generate a target bit stream;
wherein the obtaining, by an encoder, the m encoded reference nodes in the point cloud sequence comprises:
determining, by the encoder, a target coordinate system based on coordinate values of the to-be-encoded node;
determining, by the encoder, that nodes belonging to a same node partitioning level as the to-be-encoded node and having a same coordinate value on a target coordinate axis as the to-be-encoded node, in the point cloud sequence, are candidate reference nodes, wherein the target coordinate axis is any coordinate axis in the target coordinate system, and the target coordinate axis is perpendicular to a target plane; and
obtaining, by the encoder, the m reference nodes from the candidate reference nodes.
2 . The method according to claim 1 , wherein the obtaining, by the encoder, the m encoded reference nodes in the point cloud sequence when at least one of the previous k encoded nodes has a target planar feature comprises:
when the number of encoded nodes with the target planar feature among the previous k encoded nodes is greater than or equal to a first threshold, obtaining, by the encoder, the m encoded reference nodes in the point cloud sequence, wherein
the first threshold is a positive integer less than k.
3 . The method according to claim 1 , wherein the occupancy information of the m encoded reference nodes in the point cloud sequence comprises the number of occupied first subnodes and the number of occupied second subnodes in the m reference nodes; and
the method further comprises:
determining, by the encoder, a first plane and a second plane of the node, wherein the first plane and the second plane are both parallel to the target plane, the first plane overlaps the second plane in an extension direction of the target coordinate axis, the first plane is closer to a coordinate origin than the second plane, and the coordinate origin is a coordinate origin of the target coordinate system; and
obtaining, by the encoder, the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes, wherein the first subnodes are subnodes located in the first plane and the second subnodes are subnodes located in the second plane.
4 . The method according to claim 1 , wherein
the determining, by the encoder, a context of a to-be-encoded subnode based on occupancy information of the m reference nodes and a position of the to-be-encoded subnode in the to-be-encoded node comprises:
predicting, by the encoder, occupancy information of the to-be-encoded node based on the occupancy information of the m reference nodes, and determining a prediction result of the to-be-encoded node; and
determining, by the encoder, the context of the to-be-encoded subnode based on the prediction result of the to-be-encoded node and the position of the to-be-encoded subnode in the to-be-encoded node.
5 . The method according to claim 4 , wherein the predicting, by the encoder, occupancy information of the to-be-encoded node based on the occupancy information of the m reference nodes, and determining a prediction result of the to-be-encoded node comprises:
determining, by the encoder, a first plane and a second plane of the node, wherein the first plane and the second plane are both parallel to the target plane, the first plane overlaps the second plane in an extension direction of the target coordinate axis, the first plane is closer to a coordinate origin than the second plane, and the coordinate origin is a coordinate origin of the target coordinate system;
obtaining, by the encoder, the number of occupied first subnodes and the number of occupied second subnodes in the m reference nodes, wherein the first subnodes are subnodes located in the first plane and the second subnodes are subnodes located in the second plane; and
predicting, by the encoder, the occupancy information of the to-be-encoded node based on the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes, and determining the prediction result of the to-be-encoded node.
6 . The method according to claim 5 , wherein the predicting, by the encoder, the occupancy information of the to-be-encoded node based on the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes, and determining the prediction result of the to-be-encoded node comprises at least one of the following:
in a case that the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes meet a first condition, predicting, by the encoder, that at least one first subnode in the to-be-encoded node is occupied and that no second subnode in the to-be-encoded node is occupied, and determining that the prediction result of the to-be-encoded node is a first prediction result, wherein the first condition is that the number of the occupied first subnodes in the m reference nodes is greater than a second threshold and that the number of the occupied second subnodes in the m reference nodes is less than a third threshold;
in a case that the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes meet a second condition, predicting, by the encoder, that at least one second subnode in the to-be-encoded node is occupied and that no first subnode in the to-be-encoded node is occupied, and determining that the prediction result of the to-be-encoded node is a second prediction result, wherein the second condition is that the number of the occupied second subnodes in the m reference nodes is greater than the second threshold and that the number of the occupied first subnodes in the m reference nodes is less than the third threshold; or,
in a case that the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes meet neither of the first condition and the second condition, predicting, by the encoder, that at least one first subnode and at least one second subnode in the to-be-encoded node are occupied, and determining that the prediction result of the to-be-encoded node is a third prediction result.
7 . The method according to claim 6 , wherein the determining, by the encoder, the context of the to-be-encoded subnode based on the prediction result and the position of the to-be-encoded subnode in the to-be-encoded node comprises at least one of the following:
in a case that the prediction result of the to-be-encoded node is the first prediction result and that the to-be-encoded subnode is located in the second plane of the to-be-encoded node, determining, by the encoder, that a first preset model is the context of the to-be-encoded subnode;
in a case that the prediction result of the to-be-encoded node is the second prediction result and that the to-be-encoded subnode is located in the first plane of the to-be-encoded node, determining, by the encoder, that a second preset model is the context of the to-be-encoded subnode;
in a case that the prediction result of the to-be-encoded node is the first prediction result and that the to-be-encoded subnode is located in the first plane of the to-be-encoded node, obtaining, by the encoder, a neighboring node of the to-be-encoded subnode, and determining the context of the to-be-encoded subnode based on an occupancy case of the neighboring node;
in a case that the prediction result of the to-be-encoded node is the second prediction result and that the to-be-encoded subnode is located in the second plane of the to-be-encoded node, obtaining, by the encoder, a neighboring node of the to-be-encoded subnode, and determining the context of the to-be-encoded subnode based on an occupancy case of the neighboring node; and
in a case that the prediction result of the to-be-encoded node is the third prediction result, obtaining, by the encoder, a neighboring node of the to-be-encoded subnode, and determining the context of the to-be-encoded subnode based on an occupancy case of the neighboring node;
or,
wherein in a case that the first subnodes and the second subnodes in the reference nodes are obtained through partitioning based on an n-ary tree, the second threshold is a positive integer less than or equal to
n
2
×
m
-
1
,
the third threshold is a positive integer less than or equal to
n
2
×
m
,
and n is a positive integer.
8 . A point cloud decoding method, comprising:
obtaining, by a decoder, a to-be-decoded node in a point cloud sequence;
obtaining, by the decoder based on a node decoding order, k decoded nodes previous to the to-be-decoded node, wherein k is a positive integer greater than 1;
when at least one of the previous k decoded nodes has a target planar feature, obtaining, by the decoder, m decoded reference nodes in the point cloud sequence, wherein m is a positive integer;
determining, by the decoder, a context of a to-be-decoded subnode based on occupancy information of the m reference nodes and a position of the to-be-decoded subnode in the to-be-decoded node, wherein the to-be-decoded subnode is any subnode obtained by partitioning the to-be-decoded node based on a structure tree; and
performing, by the decoder, entropy decoding on the to-be-decoded subnode based on the context to generate a target bit stream;
wherein the obtaining, by the decoder, the m decoded reference nodes in the point cloud sequence comprises:
determining, by the decoder, a target coordinate system based on coordinate values of the to-be-decoded node;
determining, by the decoder, that nodes belonging to a same node partitioning level as the to-be-decoded node and having a same coordinate value on a target coordinate axis as the to-be-decoded node, in the point cloud sequence, are candidate reference nodes, wherein the target coordinate axis is any coordinate axis in the target coordinate system, and the target coordinate axis is perpendicular to a target plane; and
obtaining, by the decoder, the m reference nodes from the candidate reference nodes.
9 . The method according to claim 8 , wherein the obtaining, by the decoder, the m decoded reference nodes in the point cloud sequence when at least one of the previous k decoded nodes has a target planar feature comprises:
when the number of decoded nodes with the target planar feature among the previous k decoded nodes is greater than or equal to a first threshold, obtaining, by the decoder, the m decoded reference nodes in the point cloud sequence, wherein
the first threshold is a positive integer less than k.
10 . The method according to claim 8 , wherein the occupancy information of the m encoded reference nodes in the point cloud sequence comprises the number of occupied first subnodes and the number of occupied second subnodes in the m reference nodes; and the method further comprises:
determining, by the decoder, a first plane and a second plane of the node, wherein the first plane and the second plane are both parallel to the target plane, the first plane overlaps the second plane in an extension direction of the target coordinate axis, the first plane is closer to a coordinate origin than the second plane, and the coordinate origin is a coordinate origin of the target coordinate system; and
obtaining, by the decoder, the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes, wherein the first subnodes are subnodes located in the first plane and the second subnodes are subnodes located in the second plane.
11 . The method according to claim 10 , wherein the determining, by the decoder, a context of a to-be-decoded subnode based on occupancy information of the m reference nodes and a position of the to-be-decoded subnode in the to-be-decoded node comprises:
predicting, by the decoder, occupancy information of the to-be-decoded node based on the occupancy information of the m reference nodes, and determining a prediction result of the to-be-decoded node; and
determining, by the decoder, the context of the to-be-decoded subnode based on the prediction result of the to-be-decoded node and the position of the to-be-decoded subnode in the to-be-decoded node.
12 . The method according to claim 11 , wherein the determining, by the decoder, the context of the to-be-decoded subnode based on the prediction result of the to-be-decoded node and the position of the to-be-decoded subnode in the to-be-decoded node comprises:
determining, by the decoder, a first plane and a second plane of the node, wherein the first plane and the second plane are both parallel to the target plane, the first plane overlaps the second plane in an extension direction of the target coordinate axis, the first plane is closer to a coordinate origin than the second plane, and the coordinate origin is a coordinate origin of the target coordinate system;
obtaining, by the decoder, the number of occupied first subnodes and the number of occupied second subnodes in the m reference nodes, wherein the first subnodes are subnodes located in the first plane and the second subnodes are subnodes located in the second plane; and
predicting, by the decoder, the occupancy information of the to-be-decoded node based on the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes, and determining the prediction result of the to-be-decoded node.
13 . The method according to claim 12 , wherein the predicting, by the decoder, the occupancy information of the to-be-decoded node based on the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes, and determining the prediction result of the to-be-decoded node comprises at least one of the following:
in a case that the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes meet a first condition, predicting, by the decoder, that at least one first subnode in the to-be-decoded node is occupied and that no second subnode in the to-be-decoded node is occupied, and determining that the prediction result of the to-be-decoded node is a first prediction result, wherein the first condition is that the number of the occupied first subnodes in the m reference nodes is greater than a second threshold and that the number of the occupied second subnodes in the m reference nodes is less than a third threshold;
in a case that the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes meet a second condition, predicting, by the decoder, that at least one second subnode in the to-be-decoded node is occupied and that no first subnode in the to-be-decoded node is occupied, and determining that the prediction result of the to-be-decoded node is a second prediction result, wherein the second condition is that the number of the occupied second subnodes in the m reference nodes is greater than the second threshold and that the number of the occupied first subnodes in the m reference nodes is less than the third threshold; or
in a case that the number of the occupied first subnodes and the number of the occupied second subnodes in the m reference nodes meet neither of the first condition and the second condition, predicting, by the decoder, that at least one first subnode and at least one second subnode in the to-be-decoded node are occupied, and determining that the prediction result of the to-be-decoded node is a third prediction result.
14 . The method according to claim 13 , wherein the determining, by the decoder, the context of the to-be-decoded subnode based on the prediction result and the position of the to-be-decoded subnode in the to-be-decoded node comprises at least one of the following:
in a case that the prediction result of the to-be-decoded node is the first prediction result and that the to-be-decoded subnode is located in the second plane of the to-be-decoded node, determining, by the decoder, that a first preset model is the context of the to-be-decoded subnode;
in a case that the prediction result of the to-be-decoded node is the second prediction result and that the to-be-decoded subnode is located in the first plane of the to-be-decoded node, determining, by the decoder, that a second preset model is the context of the to-be-decoded subnode;
in a case that the prediction result of the to-be-decoded node is the first prediction result and that the to-be-decoded subnode is located in the first plane of the to-be-decoded node, obtaining, by the decoder, a neighboring node of the to-be-decoded subnode, and determining the context of the to-be-decoded subnode based on an occupancy case of the neighboring node;
in a case that the prediction result of the to-be-decoded node is the second prediction result and that the to-be-decoded subnode is located in the second plane of the to-be-decoded node, obtaining, by the decoder, a neighboring node of the to-be-decoded subnode, and determining the context of the to-be-decoded subnode based on an occupancy case of the neighboring node; and
in a case that the prediction result of the to-be-decoded node is the third prediction result, obtaining, by the decoder, a neighboring node of the to-be-decoded subnode, and determining the context of the to-be-decoded subnode based on an occupancy case of the neighboring node;
or,
wherein in a case that the first subnodes and the second subnodes in the reference nodes are obtained through partitioning based on an n-ary tree, the second threshold is a positive integer less than or equal to
n
2
×
m
-
1
,
the third threshold is a positive integer less than or equal to
n
2
×
m
,
and n is a positive integer.
15 . An electronic device, the electronic device being an encoder, comprising a processor and a memory, wherein the memory stores a program or instructions capable of running on the processor, and when the program or instructions are executed by the processor, the steps of the point cloud encoding method according to claim 1 are implemented.
16 . An electronic device, the electronic device being a decoder, comprising a processor and a memory, wherein the memory stores a program or instructions capable of running on the processor, and when the program or instructions are executed by the processor, the following steps are implemented:
obtaining a to-be-decoded node in a point cloud sequence;
obtaining, based on a node decoding order, k decoded nodes previous to the to-be-decoded node, wherein k is a positive integer greater than 1;
when at least one of the previous k decoded nodes has a target planar feature, obtaining m decoded reference nodes in the point cloud sequence, wherein m is a positive integer;
determining a context of a to-be-decoded subnode based on occupancy information of the m reference nodes and a position of the to-be-decoded subnode in the to-be-decoded node, wherein the to-be-decoded subnode is any subnode obtained by partitioning the to-be-decoded node based on a structure tree; and
performing entropy decoding on the to-be-decoded subnode based on the context to generate a target bit stream;
wherein the obtaining the m decoded reference nodes in the point cloud sequence comprises:
determining a target coordinate system based on coordinate values of the to-be-decoded node;
determining that nodes belonging to a same node partitioning level as the to-be-decoded node and having a same coordinate value on a target coordinate axis as the to-be-decoded node, in the point cloud sequence, are candidate reference nodes, wherein the target coordinate axis is any coordinate axis in the target coordinate system, and the target coordinate axis is perpendicular to a target plane; and
obtaining the m reference nodes from the candidate reference nodes.