An encoding and decoding method and device based on bounded integer sequence and data stream fusion
By employing an encoding and decoding method that integrates bounded integer sequences and data streams, the optimal compression scheme is selected and combined for encoding. This solves the problems of wasted storage space in fixed-length encoding and wasted transmission bandwidth in variable-length encoding, achieving efficient encoding utilization and expanding the application scope.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENG MICROELECTRONICS (SUZHOU) CO LTD
- Filing Date
- 2026-02-05
- Publication Date
- 2026-04-24
AI Technical Summary
In existing technologies, fixed-length encoding wastes storage space when storing integer type encoded data that is not in the range of powers of two, while it has low storage efficiency when storing integer type encoded data in the range of powers of two. Variable-length encoding also wastes transmission bandwidth when storing encoded data with large frequency differences.
An encoding and decoding method based on the fusion of bounded integer sequences and data streams is adopted. The optimal scheme is selected through multiple compression methods. The compression method selection flag is fused with the bounded integer sequence and the bounded integers are combined and encoded to reduce storage space waste. The compression method selection flag field is used to distinguish each encoding method.
It achieves improved overall compression performance with a smaller storage space, avoids confusion between different compression algorithms, improves encoding utilization and signal-to-noise ratio, and expands the application scope of bounded integer sequence encoding.
Smart Images

Figure CN121644825B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image compression encoding and decoding, and relates to an encoding and decoding method and apparatus based on the fusion of bounded integer sequences and data streams. Background Technology
[0002] In graphics processing or image enhancement technology, especially in scenarios that require high-quality visual effects and high performance, compression coding is required. Compression coding is generally divided into fixed-length coding and variable-length coding. Fixed-length coding refers to converting data units into binary sequences of fixed length. Fixed-length coding is more efficient when the frequency of encoded data is evenly distributed. However, if the frequency of encoded data varies greatly, there will be problems with wasted storage space or transmission bandwidth. Fixed-length coding is usually used for data types with high randomness, such as those with coding errors.
[0003] The core of variable-length coding is to dynamically adjust the coding length of each piece of coded data (such as Huffman coding), using shorter codes for high-frequency coded data and longer codes for low-frequency coded data to optimize the overall coding length.
[0004] The problem with fixed-length encoding is that it wastes some storage space when storing integer data in the range of powers of two, but it is more efficient when storing integer data in the range of powers of two.
[0005] To address these issues, this invention proposes an encoding and decoding method and apparatus based on the fusion of bounded integer sequences and data streams, which further expands the range of bounded integer sequences and broadens the application scope. Summary of the Invention
[0006] An encoding and decoding method based on the fusion of bounded integer sequences and data streams, characterized in that the encoding part includes:
[0007] S1.1 Try multiple compression methods on the object to be compressed, and select the optimal compression scheme based on the error magnitude;
[0008] S1.2 Under the optimal compression scheme, the bounded integer sequence in the encoded content is encoded as a bounded integer sequence;
[0009] S1.3 Encode the compression method selection flag in the encoded content under the optimal compression scheme;
[0010] S1.4 Merge the compression method selection flag with the bounded integer sequence into a data stream;
[0011] S1.5 outputs the actual compressed data stream;
[0012] The decoding part includes:
[0013] S2.1 Identify compression method flags in compressed data streams;
[0014] S2.2 According to the identified compression method, the remaining part of the fixed-length compressed data is decoded as a bounded integer sequence.
[0015] Furthermore, the method for comparing the magnitude of the error in S1.1 is as follows:
[0016] Assume the average error and maximum error of different units in the compressed object are respectively and The final comparison error is:
[0017] ;
[0018] in, These are the weighting coefficients;
[0019] The compression method with the smallest final comparison error is selected as the compression method to be encoded.
[0020] Furthermore, the bounded integer sequence encoding in S1.2 is used to handle the problem of encoding data reduction for data within a fixed range. When the number of bounded integers to be encoded increases, storage space is wasted significantly. The length of the bounded integer encoding field is reduced by combining and encoding several bounded integers.
[0021] Furthermore, assume that the bounded integer to be encoded is... By considering every five bounded integers By using combined encoding, the storage space utilization is improved, and the encoding bit width is reduced from 10 bits to 8 bits: .
[0022] Furthermore, assume that the bounded integer to be encoded is... By considering every three bounded integers By using combined encoding, the storage space utilization is improved, and the encoding bit width is reduced from 9 bits to 7 bits:
[0023] .
[0024] Furthermore, assume that the bounded integer to be encoded is... By considering every two bounded integers By using combined encoding, the storage space utilization is improved, and the encoding bit width is reduced from 8 bits to 7 bits:
[0025] .
[0026] Furthermore, assume a bounded integer with encoding. By considering every three bounded integers Combinatorial encoding is used to improve storage space utilization, reducing the encoding bit width from 12 bits to 10 bits.
[0027] ;
[0028] .
[0029] Furthermore, in S1.3, since the compression method selection flag field and the bounded integer encoding field form a compressed data stream of fixed size N bits, the length of the compression method selection flag field is equal to N minus the length of the bounded integer encoding field, and the remaining field has a length of 1. The binary number of bits occupied by the remaining field length of 1 is used to distinguish each compression method.
[0030] S1.4 Then, the compression method selection flag field is merged into the remaining fields of the bounded integer sequence, thus completing the splicing of all data streams;
[0031] S1.5 Assuming the compression objects are 1 to M, and the compressed data stream of each compression object is maintained at N bits, the compressed data stream is output in the order of compression objects 1 to M.
[0032] Furthermore, S2.1 decomposes the compressed data stream into N-bit units, parses the compression method selection flag field of each N-bit data stream, and obtains the compression method used by the compressed object;
[0033] S2.2 Since the compression method selection flag field and the bounded integer encoding field form a compressed data stream of fixed size N bits, the length of the bounded integer encoding field is equal to N minus the length of the compression method selection flag field, resulting in a remaining field length of two. The data in the remaining field length two is parsed for the data required by the compression method, including the decoding of each bounded integer. Bounded integer decoding is the inverse operation of bounded integer encoding.
[0034] The present invention also provides an encoding and decoding apparatus based on the fusion of bounded integer sequences and data streams, comprising:
[0035] Compression method selection unit: The compression method selection unit selects the optimal compression method for the compression object and transmits the compression method to the compression method encoding unit. At the same time, it compresses the object under the compression method to obtain several bounded integers that need to be encoded and transmits them to the bounded integer encoding unit.
[0036] Compression method encoding unit: The compression method encoding unit encodes the selected compression method into binary data and transmits it to the compressed data stream splicing unit;
[0037] Bounded Integer Encoding Unit: The bounded integer encoding unit encodes several bounded integers that need to be encoded into a bounded integer encoding format and transmits it to the compressed data stream splicing unit;
[0038] Compressed data stream splicing unit: The compressed data stream splicing unit splices the binary data encoded by the compression method and the bounded integer encoding into a complete compressed data stream, and at the same time splices the complete compressed data streams of different compression objects sequentially;
[0039] Compressed data stream segmentation unit: Divides the complete compressed data streams of different compressed objects into equal-length segments to obtain the complete compressed data stream of a single compressed object;
[0040] Compression method identification unit: identifies the compression method encoding field in the complete compressed data stream of a single compressed object, and transmits the identified compression method and the remaining undecoded compressed data stream to the bounded integer decoding unit;
[0041] Bounded integer decoding unit: According to the identified compression method, the remaining undecoded compressed data is decoded multiple times using bounded integers to obtain all the information required by the decompression method, and then the decompressed and restored compressed object is obtained.
[0042] The compression coding algorithm of this invention effectively solves the problem of data stream fusion. For lossy compression, if a single compression method is used to compress the target object, the final compression error depends heavily on the compression effect of the single compression method. Therefore, using the multiple compression combinations proposed in this invention can achieve better compression results. This invention proposes an unambiguous encoding and decoding combination method, which can not only avoid confusion between different compression algorithms during decoding, but also improve the overall compression effect with a smaller storage space. Attached Figure Description
[0043] Figure 1 The diagram shown is a flowchart of the coding portion of this invention;
[0044] Figure 2 The following is a flowchart of the decoding part of the present invention;
[0045] Figure 3 The diagram shows that the compression method of this invention uses a 3-bit selection flag field to distinguish 8 encoding methods;
[0046] Figure 4 The diagram illustrates how the present invention combines the selection of a compression method with the data stream fusion of a bounded integer sequence.
[0047] Figure 5 The image shows the compressed data stream of this invention output in the order of compression objects 1 to M;
[0048] Figure 6 The diagram shown is a structural schematic of the encoding and decoding device of the present invention. Detailed Implementation
[0049] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0050] Please see Figure 1-5 This invention provides an encoding and decoding method based on the fusion of bounded integer sequences and data streams, wherein the encoding part includes:
[0051] S1.1 Try multiple compression methods on the object to be compressed, and select the optimal compression scheme based on the error magnitude;
[0052] S1.2 Under the optimal compression scheme, the bounded integer sequence in the encoded content is encoded as a bounded integer sequence;
[0053] S1.3 Encode the compression method selection flag in the encoded content under the optimal compression scheme;
[0054] S1.4 Merge the compression method selection flag with the bounded integer sequence into a data stream;
[0055] S1.5 outputs the actual compressed data stream;
[0056] The decoding part includes:
[0057] S2.1 Identify compression method flags in compressed data streams;
[0058] S2.2 According to the identified compression method, the remaining part of the fixed-length compressed data is decoded as a bounded integer sequence.
[0059] This invention does not limit the actual compression method used. Assuming that for the same object to be compressed, compression method one, compression method two, ... can all be used, and all compression methods can compress the object, the error magnitudes under different compression methods are compared to select the optimal compression scheme. The error magnitude comparison method is as follows:
[0060] Assume the average error and maximum error of different units in the compressed object are respectively and The final comparison error is:
[0061] ;
[0062] in, These are the weighting coefficients;
[0063] The compression method with the smallest final comparison error is selected as the compression method to be encoded.
[0064] S1.2 Bounded integer sequence encoding is used to handle the problem of encoding data reduction for data within a fixed range. When the number of bounded integers to be encoded increases, storage space is wasted significantly. The length of the bounded integer encoding field is reduced by combining and encoding several bounded integers.
[0065] The following are four examples:
[0066] Assume the bounded integer to be encoded Encoding typically uses 2 bits, resulting in wasted storage space. This waste becomes more pronounced when the number of bounded integers to be encoded is large. This can be mitigated by encoding every five bounded integers... By using combined encoding, the storage space utilization is improved, and the encoding bit width is reduced from 10 bits to 8 bits: .
[0067] Similarly, assume the bounded integer to be encoded Encoding typically uses 2 bits, resulting in wasted storage space. This waste becomes more pronounced when the number of bounded integers to be encoded is large. This can be mitigated by encoding every three bounded integers... By using combined encoding, the storage space utilization is improved, and the encoding bit width is reduced from 9 bits to 7 bits:
[0068] .
[0069] The above are two optimized encoding methods mentioned for bounded integers. In addition, this encoding method can be extended to any prime number. For example, suppose the bounded integer to be encoded... Encoding typically uses 4 bits, resulting in wasted storage space. This waste becomes more pronounced when the number of bounded integers to be encoded is large. This can be mitigated by encoding every two bounded integers... By using combined encoding, the storage space utilization is improved, and the encoding bit width is reduced from 8 bits to 7 bits:
[0070] .
[0071] Furthermore, bounded integer encoding can also be applied to composite numbers using prime factorization. For example, suppose a bounded integer is encoded. Encoding typically uses 4 bits, resulting in wasted storage space. This waste becomes more pronounced when the number of bounded integers to be encoded is large. This can be mitigated by encoding every three bounded integers... Combinatorial encoding is used to improve storage space utilization, reducing the encoding bit width from 12 bits to 10 bits.
[0072] ;
[0073] .
[0074] Typically, compression methods select flag fields that use fixed-width encoding, such as... Figure 3 The compression method selection flag field shown occupies 3 bits and can distinguish 8 encoding methods:
[0075] Since the compression method selection flag field and the bounded integer encoding field form a compressed data stream of fixed size N bits, the length of the compression method selection flag field is equal to N minus the length of the bounded integer encoding field, resulting in a remaining field length of 1. The binary number of bits occupied by this remaining field length 1 is used to distinguish each compression method. For example, if compression methods 1 to 5 need to be encoded, the remaining field length 1 of compression method 1 occupies 1 bit, and the remaining field length 1 of compression methods 2 to 5 occupies 3 bits. Then, 1 bit of binary 0 is used to distinguish compression method 1, and 3 bits of binary 100, 101, 110, 111 are used to distinguish compression methods 2 to 5, thus fixing the entire compressed data stream to N bits.
[0076] Then use the compression method selection flag field. Figure 4 The method shown integrates the remaining fields of the bounded integer sequence to concatenate all data streams. It is essential to ensure that the length of the remaining encoded segment plus the length of the compression method selection flag field equals the target compressed data volume. If the remaining encoded segment length is long, the length of the compression method selection flag field should be appropriately reduced; if the remaining encoded segment length is short, the length of the compression method selection flag field should be appropriately increased. Simultaneously, the uniqueness of the compression method selection flag field during reverse parsing must be guaranteed.
[0077] Assuming the number of compressed objects is 1 to M, and the compressed data stream for each object remains at N bits, then the compressed data stream follows the following... Figure 5 The compressed objects 1 to M shown are output sequentially.
[0078] The compressed data stream is decomposed into N-bit units, and the compression method selection flag field of each N-bit data stream is parsed to obtain the compression method used by the compressed object.
[0079] Since the compression method selection flag field and the bounded integer encoding field form a compressed data stream of fixed size N bits, the length of the bounded integer encoding field is equal to N minus the length of the compression method selection flag field, resulting in a remaining field of length two. The data in this remaining field of length two is then parsed to obtain the data required by the compression method, including the decoding of each bounded integer. Bounded integer decoding is the inverse operation of bounded integer encoding. For example, five bounded integers can be obtained by decoding. ,
[0080] .
[0081] Figure 6 The diagram shows an encoding and decoding apparatus based on the fusion of bounded integer sequences and data streams according to the present invention, comprising:
[0082] Compression method selection unit: The compression method selection unit selects the optimal compression method for the compression object and transmits the compression method to the compression method encoding unit. At the same time, it compresses the object under the compression method to obtain several bounded integers that need to be encoded and transmits them to the bounded integer encoding unit.
[0083] Compression method encoding unit: The compression method encoding unit encodes the selected compression method into binary data and transmits it to the compressed data stream splicing unit;
[0084] Bounded Integer Encoding Unit: The bounded integer encoding unit encodes several bounded integers that need to be encoded into a bounded integer encoding format and transmits it to the compressed data stream splicing unit;
[0085] Compressed data stream splicing unit: The compressed data stream splicing unit splices the binary data encoded by the compression method and the bounded integer encoding into a complete compressed data stream, and at the same time splices the complete compressed data streams of different compression objects sequentially;
[0086] Compressed data stream segmentation unit: Divides the complete compressed data streams of different compressed objects into equal-length segments to obtain the complete compressed data stream of a single compressed object;
[0087] Compression method identification unit: identifies the compression method encoding field in the complete compressed data stream of a single compressed object, and transmits the identified compression method and the remaining undecoded compressed data stream to the bounded integer decoding unit;
[0088] Bounded integer decoding unit: According to the identified compression method, the remaining undecoded compressed data is decoded multiple times using bounded integers to obtain all the information required by the decompression method, and then the decompressed and restored compressed object is obtained.
[0089] The encoding and decoding method mentioned in this invention is simple in its encoding and decoding process, has high encoding utilization, can further compress storage space, can effectively combine multiple compression methods to improve compression effect and signal-to-noise ratio, and also expands the usable range of bounded integer sequence encoding methods, making it more widely applicable.
[0090] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0091] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is limited by the appended claims and their equivalents.
Claims
1. An encoding and decoding method based on the fusion of bounded integer sequences and data streams, characterized in that, The encoding part includes: S1.1 Try multiple compression methods on the object to be compressed, and select the optimal compression scheme based on the error magnitude; S1.2 Under the optimal compression scheme, the bounded integer sequence in the encoded content is encoded as a bounded integer sequence; S1.3 Encode the compression method selection flag in the encoded content under the optimal compression scheme; S1.4 Merge the compression method selection flag with the bounded integer sequence into a data stream; S1.5 outputs the actual compressed data stream; The decoding part includes: S2.1 Identify compression method flags in compressed data streams; S2.2 According to the identified compression method, the remaining part of the fixed-length compressed data is decoded using a bounded integer sequence; S1.2 Bounded integer sequence encoding reduces the length of the bounded integer encoding field by combining and encoding several bounded integers. Assume the bounded integer to be encoded By considering every five bounded integers By using combined encoding, the storage space utilization is improved, and the encoding bit width is reduced from 10 bits to 8 bits: ; Assume the bounded integer to be encoded By considering every three bounded integers By using combined encoding, the storage space utilization is improved, and the encoding bit width is reduced from 9 bits to 7 bits: ; Assume the bounded integer to be encoded By considering every two bounded integers By using combined encoding, the storage space utilization is improved, and the encoding bit width is reduced from 8 bits to 7 bits: ; Assume a bounded integer with encoding By considering every three bounded integers Combinatorial encoding is used to improve storage space utilization, reducing the encoding bit width from 12 bits to 10 bits. ; ; S1.3 Since the compression method selection flag field and the bounded integer encoding field form a compressed data stream of fixed size N bits, the length of the compression method selection flag field is equal to N minus the length of the bounded integer encoding field, and the remaining field has a length of 1. The binary number of bits occupied by the remaining field length of 1 is used to distinguish each compression method. S1.4 Then, the compression method selection flag field is merged into the remaining fields of the bounded integer sequence, thus completing the splicing of all data streams; S1.5 Assuming the compression objects are 1 to M, and the compressed data stream of each compression object is maintained at N bits, the compressed data stream is output in the order of compression objects 1 to M.
2. The encoding and decoding method based on the fusion of bounded integer sequences and data streams according to claim 1, characterized in that, The method for comparing the magnitude of errors in S1.1 is as follows: Assume the average error and maximum error of different units in the compressed object are respectively and The final comparison error is: ; in, These are the weighting coefficients; The compression method with the smallest final comparison error is selected as the compression method to be encoded.
3. The encoding and decoding method based on the fusion of bounded integer sequences and data streams according to claim 2, characterized in that: S2.1 Decompose the compressed data stream into N-bit units, parse the compression method selection flag field of each N-bit data stream, and obtain the compression method used by the compressed object; S2.2 Since the compression method selection flag field and the bounded integer encoding field form a compressed data stream of fixed size N bits, the length of the bounded integer encoding field is equal to N minus the length of the compression method selection flag field, resulting in a remaining field length of two. The data in the remaining field length two is parsed for the data required by the compression method, including the decoding of each bounded integer. Bounded integer decoding is the inverse operation of bounded integer encoding.
4. An encoding and decoding apparatus based on the fusion of bounded integer sequences and data streams, employing any one of the encoding and decoding methods based on the fusion of bounded integer sequences and data streams as described in claims 1-3, comprising: Compression method selection unit: The compression method selection unit selects the optimal compression method for the compression object and transmits the compression method to the compression method encoding unit. At the same time, it compresses the object under the compression method to obtain several bounded integers that need to be encoded and transmits them to the bounded integer encoding unit. Compression method encoding unit: The compression method encoding unit encodes the selected compression method into binary data and transmits it to the compressed data stream splicing unit; Bounded Integer Encoding Unit: The bounded integer encoding unit encodes several bounded integers that need to be encoded into a bounded integer encoding format and transmits it to the compressed data stream splicing unit; Compressed data stream splicing unit: The compressed data stream splicing unit splices the binary data encoded by the compression method and the bounded integer encoding into a complete compressed data stream, and at the same time splices the complete compressed data streams of different compression objects sequentially; Compressed data stream segmentation unit: Divides the complete compressed data streams of different compressed objects into equal-length segments to obtain the complete compressed data stream of a single compressed object; Compression method identification unit: identifies the compression method encoding field in the complete compressed data stream of a single compressed object, and transmits the identified compression method and the remaining undecoded compressed data stream to the bounded integer decoding unit; Bounded integer decoding unit: According to the identified compression method, the remaining undecoded compressed data is decoded multiple times using bounded integers to obtain all the information required by the decompression method, and then the decompressed and restored compressed object is obtained.
Citation Information
Patent Citations
Method for generating multi-dimensional integer chaotic pseudo-random sequence with uniform distribution characteristics
CN112272091A
Apparatus for encoding and decoding sequence of integer values, method for encoding and decoding sequence of integer values, and computer program for implementing these methods
CN116018758A