Search

US-12621472-B2 - Encoding method, decoding method, and electronic device

US12621472B2US 12621472 B2US12621472 B2US 12621472B2US-12621472-B2

Abstract

An encoding method includes obtaining a to-be-encoded frame, where the to-be-encoded frame is a P-frame, determining, from M preset network parameter sets, a network parameter set corresponding to the to-be-encoded frame, where the M preset network parameter sets respectively correspond to different compression performance information, and M is an integer greater than one, and encoding, by an encoding network, and based on the network parameter set corresponding to the to-be-encoded frame, the to-be-encoded frame to obtain a bitstream representative of the to-be-encoded frame.

Inventors

  • Yibo Shi
  • Yunying Ge
  • Jing Wang

Assignees

  • HUAWEI TECHNOLOGIES CO., LTD.

Dates

Publication Date
20260505
Application Date
20240830
Priority Date
20220307

Claims (20)

  1. 1 . An encoding method comprising: obtaining a to-be-encoded frame, wherein the to-be-encoded frame is a P-frame; selecting, from M preset network parameter sets, a preset network parameter set corresponding to the to-be-encoded frame, wherein the M preset network parameter sets respectively correspond to different compression performance information, wherein M is an integer greater than one, and wherein selecting the preset network parameter set corresponding to the to-be-encoded frame comprises: selecting, according to a preset rule and when the M preset network parameter sets corresponding to N previous frames are the same as a network parameter set of the to-be-encoded frame, a first preset network parameter set other than a second network parameter set corresponding to a previous frame adjacent to the to-be-encoded frame as the network parameter set corresponding to the to-be-encoded frame; and selecting, when the M preset network parameter sets corresponding to the N previous frames differ from the network parameter set of the to-be-encoded frame, the second network parameter set as the network parameter set corresponding to the to-be-encoded frame, wherein N is an integer greater than one; and encoding the to-be-encoded frame based on the preset network parameter set to obtain a bitstream.
  2. 2 . The encoding method of claim 1 , wherein M is equal to two, wherein the M preset network parameter sets comprise a first preset network parameter set and a second preset network parameter set, wherein the encoding method further comprises: selecting the first preset network parameter set as the network parameter set corresponding to the to-be-encoded frame when a frame identifier of the to-be-encoded frame is an odd number; and selecting the second preset network parameter set as the network parameter set corresponding to the to-be-encoded frame when the frame identifier of the to-be-encoded frame is an even number.
  3. 3 . The encoding method of claim 2 , wherein first compression performance information corresponding to the first preset network parameter set is higher than second compression performance information corresponding to the second preset network parameter set, or wherein the second compression performance information is higher than the first compression performance information.
  4. 4 . The encoding method of claim 1 , wherein selecting the preset network parameter set corresponding to the to-be-encoded frame comprises: selecting the compression performance information respectively corresponding to the M preset network parameter sets; and selecting, based on the compression performance information respectively corresponding to the M preset network parameter sets, the network parameter set corresponding to the to-be-encoded frame.
  5. 5 . The encoding method of claim 4 , wherein selecting the preset network parameter set corresponding to the to-be-encoded frame comprises: using a preset network parameter set whose corresponding compression performance information is lower than a threshold as the network parameter set corresponding to the to-be-encoded frame when compression performance information corresponding to previous K frames of the to-be-encoded frame is higher than the threshold, wherein K is a positive integer; and using a preset network parameter set whose corresponding compression performance information is higher than the threshold as the network parameter set corresponding to the to-be-encoded frame when the compression performance information corresponding to previous K frames of the to-be-encoded frame is lower than the threshold.
  6. 6 . The encoding method of claim 5 , wherein selecting the preset network parameter set corresponding to the to-be-encoded frame further comprises: using a preset network parameter set whose corresponding compression performance information is lower than the threshold as the network parameter set corresponding to the to-be-encoded frame when compression performance information corresponding to a previous frame adjacent to the to-be-encoded frame is lower than the threshold; and using a preset network parameter set whose corresponding compression performance information is higher than the threshold as the network parameter set corresponding to the to-be-encoded frame when the compression performance information corresponding to the previous frame adjacent to the to-be-encoded frame is higher than the threshold.
  7. 7 . The encoding method of claim 1 , wherein each of the M preset network parameter sets comprises a plurality of preset network parameter groups, wherein the plurality of preset network parameter groups corresponds to a plurality of subnets of an encoding network, and wherein some preset network parameter groups in any two preset network parameter sets in the M preset network parameter sets differ.
  8. 8 . The encoding method of claim 1 , wherein the bitstream comprises a set identifier of the preset network parameter set corresponding to the to-be-encoded frame.
  9. 9 . A decoding method comprising: obtaining a bitstream of a to-be-decoded frame, wherein the to-be-decoded frame is a P-frame; selecting, from M preset network parameter sets, a network parameter set corresponding to the to-be-decoded frame, wherein the M preset network parameter sets respectively correspond to different compression performance information, wherein M is equal to two, wherein the M preset network parameter sets comprise a first preset network parameter set and a second preset network parameter set, and wherein selecting a network parameter set corresponding to the to-be-decoded frame comprises: selecting the first preset network parameter set as a network parameter set corresponding to the to-be-decoded frame when a frame identifier of the to-be-decoded frame is an odd number; and selecting the second preset network parameter set as the network parameter set corresponding to the to-be-decoded frame when the frame identifier of the to-be-decoded frame is an even number; and decoding, by a decoding network, and based on the network parameter set corresponding to the to-be-decoded frame, the bitstream, to obtain a reconstructed image of the to-be-decoded frame.
  10. 10 . The decoding method of claim 9 , wherein compression performance information corresponding to the first preset network parameter set is higher than compression performance information corresponding to the second preset network parameter set; or compression performance information corresponding to the second preset network parameter set is higher than compression performance information corresponding to the first preset network parameter set.
  11. 11 . The decoding method of claim 9 , wherein selecting a network parameter set corresponding to the to-be-decoded frame comprises: parsing the bitstream of the to-be-decoded frame to obtain a set identifier; and matching the set identifier as the network parameter set corresponding to the to-be-decoded frame.
  12. 12 . The decoding method of claim 9 , wherein selecting a network parameter set corresponding to the to-be-decoded frame comprises: selecting, according to a preset rule, and when the network parameter sets corresponding to N previous frames are the same as the network parameter set of the to-be-decoded frame, a first preset network parameter set other than a network parameter set corresponding to a previous frame adjacent to the to-be-decoded frame as the network parameter set corresponding to the to-be-decoded frame; and selecting, when the network parameter sets corresponding to the N previous frames differ from the network parameter set of the to-be-decoded frame, a network parameter set corresponding to a previous frame adjacent to the to-be-decoded frame as the network parameter set corresponding to the to-be-decoded frame, and wherein N is an integer greater than one.
  13. 13 . The decoding method of claim 12 , wherein the preset rule is adaptively updated based on decoding-performance information determined for a plurality of previously decoded frames.
  14. 14 . The decoding method of claim 9 , wherein determining the network parameter set corresponding to the to-be-decoded frame further comprises: obtaining compression performance information corresponding to previously decoded frames; and further selecting the network parameter set based on the compression performance information.
  15. 15 . A decoding system comprising: a selector configured to determine, from M preset network parameter sets, a network parameter set corresponding to a bitstream of a to-be-decoded frame, wherein the to-be-decoded frame is a P-frame, the M preset network parameter sets respectively correspond to different compression performance information, wherein M is equal to two, wherein the M preset network parameter sets comprise a first preset network parameter set and a second preset network parameter set, and wherein the selector is further configured to select the first preset network parameter set as the network parameter set corresponding to the to-be-decoded frame when a frame identifier of the to-be-decoded frame is an odd number; and a decoding network configured to decode the bitstream of the to-be-decoded frame based on the network parameter set corresponding to the to-be-decoded frame, to obtain a reconstructed image of the to-be-decoded frame.
  16. 16 . The decoding system of claim 15 , wherein the selector is further configured to select the second preset network parameter set as the network parameter set corresponding to the to-be-decoded frame when a frame identifier of the to-be-decoded frame is an even number.
  17. 17 . The decoding system of claim 15 , wherein: compression performance information corresponding to a first preset network parameter set is higher than compression performance information corresponding to a second preset network parameter set; or compression performance information corresponding to the second preset network parameter set is higher than compression performance information corresponding to the first preset network parameter set.
  18. 18 . The decoding system of claim 15 , wherein the selector is further configured to: parse the bitstream of the to-be-decoded frame to obtain a set identifier; and match the set identifier as the network parameter set corresponding to the to-be-decoded frame.
  19. 19 . The decoding system of claim 15 , wherein the selector is further configured to select, according to a preset rule and when network parameter sets respectively corresponding to N previous frames of the to-be-decoded frame are the same, a preset network parameter set other than a network parameter set corresponding to a previous frame adjacent to the to-be-decoded frame as the network parameter set corresponding to the to-be-decoded frame, and wherein N is an integer greater than one.
  20. 20 . The decoding system of claim 15 , wherein the selector is further configured to select, when network parameter sets respectively corresponding to previous N frames of the to-be-decoded frame differ, a network parameter set corresponding to a previous frame adjacent to the to-be-decoded frame as the network parameter set corresponding to the to-be-decoded frame, and wherein N is an integer greater than one.

Description

CROSS-REFERENCE TO RELATED APPLICATIONS This is a continuation of International Patent Application No. PCT/CN2023/077117, filed on Feb. 20, 2023, which claims priority to Chinese Patent Application No. 202210224692.2, filed on Mar. 7, 2022. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties. TECHNICAL FIELD Embodiments of this disclosure relate to the data processing field, and in particular, to an encoding method, a decoding method, and an electronic device. BACKGROUND Development of a neural network in the image compression field and performance surpassing some compression methods drive gradually wide application of a deep learning-based video compression method. In a deep learning-based video compression/decompression process, because a reconstructed image of a previous frame participates in reconstruction of a next frame, quality of the reconstructed image of the previous frame affects quality of a reconstructed image of the next frame. When quality of a frame degrades, an accumulative error in time sequence is formed as time increases. Consequently, a chain reaction is formed, and compression performance of all frames after the frame degrades. SUMMARY To resolve the foregoing technical problem, this disclosure provides an encoding method, a decoding method, and an electronic device. In this method, an accumulative error can be reduced, and compression performance can be improved. According to a first aspect, an embodiment provides an encoding method. The method includes first obtaining a to-be-encoded frame, where the to-be-encoded frame is a P-frame (Predictive-frame), then determining, from M preset network parameter sets, a network parameter set corresponding to the to-be-encoded frame, where the M preset network parameter sets respectively correspond to different compression performance information, and M is an integer greater than 1, and then encoding, by an encoding network, the to-be-encoded frame based on the network parameter set corresponding to the to-be-encoded frame to obtain a bitstream of the to-be-encoded frame. In this way, in an encoding procedure, the encoding network can encode a plurality of adjacent frames by using different network parameters, so that the plurality of adjacent frames have high/low alternating compression performance, and adversarial compression performance is constructed in time sequence, thereby reducing an accumulative error in a structure, and improving compression performance. For example, the M preset network parameter sets are obtained in M different training manners. For example, the compression performance information may include image quality and/or a compression rate. According to the first aspect, M is equal to 2, and the M preset network parameter sets include a first preset network parameter set and a second preset network parameter set and the determining, from M preset network parameter sets, a network parameter set corresponding to the to-be-encoded frame includes, when a frame identifier of the to-be-encoded frame is an odd number, determining the first preset network parameter set as the network parameter set corresponding to the to-be-encoded frame and when a frame identifier of the to-be-encoded frame is an even number, determining the second preset network parameter set as the network parameter set corresponding to the to-be-encoded frame. In this way, two adjacent frames can be encoded by using different network parameter sets. It should be understood that, when the frame identifier of the to-be-encoded frame is an odd number, the second preset network parameter set may alternatively be determined as the network parameter set corresponding to the to-be-encoded frame and when the frame identifier of the to-be-encoded frame is an even number, the first preset network parameter set may alternatively be determined as the network parameter set corresponding to the to-be-encoded frame. Whether the encoding network encodes the to-be-encoded frame whose frame identifier is an odd number by using the first preset network parameter set or encodes the to-be-encoded frame whose frame identifier is an odd number by using the second preset network parameter set is not limited in this disclosure. For example, the frame identifier of the to-be-encoded frame may be a POC (Picture Order Count) value, or may be a frame sequence number of the to-be-encoded frame. This is not limited in this disclosure. According to any one of the first aspect or the foregoing implementations of the first aspect, compression performance information corresponding to the first preset network parameter set is higher than compression performance information corresponding to the second preset network parameter set′ or compression performance information corresponding to the second preset network parameter set is higher than compression performance information corresponding to the first preset network parameter set. For example,