WO2021012278A1 - Data processing method, system, encoder, and decoder - Google Patents

Data processing method, system, encoder, and decoder Download PDF

Info

Publication number
WO2021012278A1
WO2021012278A1 PCT/CN2019/097771 CN2019097771W WO2021012278A1 WO 2021012278 A1 WO2021012278 A1 WO 2021012278A1 CN 2019097771 W CN2019097771 W CN 2019097771W WO 2021012278 A1 WO2021012278 A1 WO 2021012278A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
code stream
data block
residual
block
Prior art date
Application number
PCT/CN2019/097771
Other languages
French (fr)
Chinese (zh)
Inventor
阮肇夏
赵文军
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to CN201980031021.0A priority Critical patent/CN112119593A/en
Priority to PCT/CN2019/097771 priority patent/WO2021012278A1/en
Publication of WO2021012278A1 publication Critical patent/WO2021012278A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03MCODING; DECODING; CODE CONVERSION IN GENERAL
    • H03M7/00Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits
    • H03M7/30Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction
    • H03M7/3053Block-companding PCM systems
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03MCODING; DECODING; CODE CONVERSION IN GENERAL
    • H03M7/00Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits
    • H03M7/30Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/103Selection of coding mode or of prediction mode
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • H04N19/423Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation characterised by memory arrangements
    • H04N19/426Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation characterised by memory arrangements using memory downsizing methods

Definitions

  • This application relates to the technical field of data processing, and in particular to a data processing method, system, encoder and decoder.
  • CNN Convolutional Neural Networks, convolutional neural network
  • weight data is the main parameter
  • the parameter scale is large.
  • the medium occupies high bandwidth, and requires high hardware computing and storage capabilities, which in turn limits the application of neural network models.
  • one of the objectives of the present invention is to provide a data processing method, system, encoder and decoder to achieve effective compression of the data to be encoded.
  • an embodiment of the present invention provides a data processing method, including:
  • an embodiment of the present invention provides a data processing method, including:
  • Parsing the data to be decoded determining a target encoding method corresponding to the data to be decoded among a plurality of preset first encoding methods, and determining a corresponding target decoding method according to the target encoding method;
  • the data to be decoded is decoded by the target decoding mode to generate decoded data.
  • an embodiment of the present invention provides a data processing method, including:
  • the residual value and the reference data are written into the coded stream data.
  • an embodiment of the present invention provides a data processing method, including:
  • an embodiment of the present invention provides a data processing method, which is applied to a configurator, a memory, and a processor connected in sequence, including:
  • the processor reads the compressed code stream in the memory and performs decompression processing on the compressed code stream to reduce the read bandwidth of the memory.
  • an embodiment of the present invention provides a data processing system, including: a configurator, a memory, and a processor connected in sequence;
  • the configurator is used to compress and encode a data block to be encoded formed by preset data to generate a compressed code stream, and write the compressed code stream into the memory, so as to reduce the write bandwidth to the memory;
  • the processor is configured to read the compressed code stream in the memory, and perform decompression processing on the compressed code stream, so as to reduce the read bandwidth of the memory.
  • an embodiment of the present invention provides a movable platform, and the movable platform includes:
  • a power system is provided in the body, and the power system is used to provide power to the movable platform; and, a data processing system as described in the sixth aspect.
  • an embodiment of the present invention provides an encoder, including: a selection circuit and an encoding circuit;
  • the selection circuit is configured to obtain the coding overhead of the data block to be coded by the multiple first coding modes, and determine the target coding mode with the smallest coding overhead from the multiple first coding modes;
  • the encoding circuit encodes the data block to be encoded by using the target encoding method.
  • an embodiment of the present invention provides an encoder, the encoder includes: a residual calculation circuit and an encoding circuit;
  • the residual calculation circuit is configured to use the data at a preset position in the data block to be encoded as reference data, and respectively calculate the residual value of every two adjacent data located on both sides of the reference data;
  • the coding circuit is configured to write the residual value and the reference data into the code stream data according to the code stream structure corresponding to the residual coding mode; wherein, the code stream structure corresponding to the residual coding mode Including: the reference data, the bit width occupied by the residual value, and the residual value.
  • an embodiment of the present invention provides a decoder, the decoder including: a parsing circuit and a decoding circuit;
  • the parsing circuit is configured to analyze the data to be decoded, determine a target encoding method corresponding to the data to be decoded among a plurality of preset first encoding methods, and determine a corresponding target decoding method according to the target encoding method;
  • the decoding circuit is used to decode the data to be decoded by the target decoding mode to generate decoded data.
  • an embodiment of the present invention provides a decoder, which includes: a parsing circuit and a decoding circuit;
  • the analysis circuit is used to analyze the data block to be decoded, and obtain the reference data and residual data in the data block to be decoded
  • the decoding circuit is used to perform a decrement operation or an accumulation operation on the reference data and the residual data to generate original data on both sides of the reference data.
  • a data processing method, system, encoder and decoder provided by various embodiments of the present invention
  • FIG. 1 is a schematic flowchart of a data processing method provided in an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a code stream structure corresponding to a run-length encoding method provided in an embodiment of the present invention
  • Fig. 3 is a schematic diagram of a code stream structure corresponding to an original encoding method provided in an embodiment of the present invention
  • Fig. 5 is a schematic diagram of a code stream structure corresponding to a residual coding method provided in an embodiment of the present invention
  • FIG. 6 is a schematic flowchart of a method for performing data processing according to a hybrid encoding mode provided in an embodiment of the present invention
  • Fig. 7 is a schematic diagram of residual calculation provided in an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of a code stream structure corresponding to a hybrid encoding method provided in an embodiment of the present invention.
  • FIG. 9 is a schematic flowchart of another method for performing data processing in a hybrid encoding manner provided in an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of a code stream structure corresponding to a hybrid encoding method provided in an embodiment of the present invention.
  • Figure 11 is a schematic flow chart of a method for decoding data to be decoded provided in an embodiment of the present invention.
  • FIG. 12 is a schematic flowchart of a method for processing data to be coded provided in an embodiment of the present invention.
  • FIG. 13 is a schematic flowchart of a method for processing preset data provided in an embodiment of the present invention.
  • Figure 14 is a schematic diagram of a system for processing preset data provided in an embodiment of the present invention.
  • Figure 15 is a schematic diagram of a data processing system provided in an embodiment of the present invention.
  • Figure 16 is a schematic structural diagram of a movable platform provided in an embodiment of the present invention.
  • Figure 17 is a schematic structural diagram of an encoder provided in an embodiment of the present invention.
  • Figure 18 is a schematic diagram of the functional architecture of an encoder provided in an embodiment of the present invention.
  • FIG. 19 is a schematic structural diagram of a decoder provided in an embodiment of the present invention.
  • FIG. 20 is a schematic diagram of the functional architecture of a decoder provided in an embodiment of the present invention.
  • the embodiments of the present invention provide a data processing method, system, encoder and decoder.
  • Fig. 1 is a schematic flowchart of a data processing method provided in an embodiment of the present invention. Referring to Fig. 1, the method includes the following steps S1-S2:
  • the foregoing encoding overhead refers to the bit width occupied by the code stream data generated after encoding the data block to be encoded.
  • the aforementioned target encoding method with the smallest encoding overhead refers to an encoding method with the smallest data amount of the compressed code stream obtained after compression encoding of the data to be encoded among the preset multiple first encoding methods.
  • multiple first coding modes are set, and then the coding mode with the least coding overhead is selected from the multiple first coding modes for the data block to be coded for coding, thereby achieving the best compression effect.
  • the target encoding methods determined for different data blocks to be encoded may be different, and then encoding is performed by selecting a suitable encoding method with the best compression effect for the data blocks to be encoded, so that the compression obtained after compression The data volume of the code stream is the smallest.
  • the aforementioned data block to be encoded is obtained from an original data block, and the original data block contains data to be compressed and encoded.
  • the above method further includes the following steps A10-A20:
  • Step A10 Determine whether there is a redundant data block in the original data block, and if so, encode the redundant data block according to the second coding mode.
  • the aforementioned preset value may be determined according to the accuracy of compression coding.
  • the foregoing preset value may be set to 4.
  • the redundant data block in the original data block is 22222.
  • Step A20 Use the remaining data block from the original data block except the redundant data block as the data block to be encoded.
  • the redundant data block is encoded by the second encoding method, and the remaining data block of the original data block is removed from the redundant data block
  • data processing is performed according to the above-mentioned steps S1-S2 for the data block to be encoded.
  • the above-mentioned second encoding method includes: run-length encoding; and in this embodiment, the redundant data block is encoded in a run-length encoding manner.
  • encoding the redundant data block in a run-length encoding manner includes:
  • the redundant data block is written into the coded stream data according to the code stream structure corresponding to the run-length encoding; the code stream structure corresponding to the run-length encoding includes: the flag bit of the encoding mode, the start value and the run length .
  • the data of each row in the original data block is scanned row by row, and the redundant data block is further obtained after scanning a certain row.
  • the initial value and run length of the redundant data block taking the redundant data block as 22222 as an example, the initial value of the redundant data block is 2 and the run length is 5, the initial value of the redundant data block,
  • the run length is written into the code stream structure corresponding to the run length coding, and the code stream structure also contains a coding mode flag bit, which indicates that the coding mode adopted for the data of the code stream is run length coding. After the current line scan is completed, continue to scan the next line.
  • the flag bit 00 indicates that the coding mode corresponding to the code stream is the run-length coding mode, base represents the starting value, and len represents the run length.
  • the remaining blocks are first divided according to a specified size to obtain multiple data blocks, and the obtained multiple data blocks.
  • Each data block has the same size, and then each divided data block is regarded as a data block to be coded, and each data block to be coded is processed and coded according to the above steps S1-S2 respectively.
  • the remaining data blocks before dividing the remaining data blocks according to a specified size to obtain multiple data blocks, if the data amount of the data contained in the remaining data blocks does not satisfy an integer multiple of the foregoing specified size, It is not enough to divide the remaining data blocks into multiple data blocks of the specified size. At this time, the remaining data blocks are filled with data so that the amount of data contained in the remaining data blocks after data filling is an integer multiple of the specified size.
  • the data volume of each data block obtained after division is the specified size.
  • the above-mentioned specified size is 16 data.
  • M is an integer greater than or equal to 1. Then, the remaining data block is filled with data, so that the total data of the remaining data block after filling meets to be 16M.
  • the foregoing method of filling the remaining data blocks includes:
  • the remaining data block is filled with data by using the last data in the remaining data block; optionally, the remaining data block may be filled with data by using a predetermined data.
  • the remaining data blocks are divided into one data block according to each 16-bit data starting from the first data in the first place. After dividing one or more data blocks, if the last remaining data is: 0122254 Since the number of data bits of the remaining data is 7, the data at the end of the remaining data block is used for data filling, and the filled data is 0122254444444444. After data filling, all the data blocks divided by the remaining data block can be obtained. Then, the target encoding method is determined for each data block according to the above method, and the target encoding method is applied to encode each data block.
  • the remaining data blocks are filled with data so that the obtained data blocks have the same size, which is convenient for encoding the remaining data.
  • the above-mentioned multiple first encoding methods include: original encoding, residual encoding, and hybrid encoding; wherein, the hybrid encoding is after the data block to be encoded is divided into several data sub-blocks, Perform residual coding or original coding on each data block.
  • the original coding mode is used to encode the to-be-coded data block, which specifically includes the following step B10:
  • Step B10 Write the original data in the data block to be coded into the code stream data according to the code stream structure corresponding to the original coding mode.
  • the code stream structure corresponding to the above-mentioned original coding mode includes: the flag bit of the coding mode and original data.
  • the original encoding method includes: directly writing the original data in the data block to be encoded into the encoded bitstream data according to the code stream structure corresponding to the original encoding method.
  • the above flag bit 01 is used to indicate that the coding mode corresponding to the code stream structure is the original coding mode (RAW16), and the above p0, p1,, and p15 are waiting Encode the original data in the data block.
  • encoding the data block to be coded by the target coding mode includes the following step S20:
  • the data at a preset position in the data block to be encoded is used as the reference data, and the residual values of the data on both sides of the reference data are respectively calculated. This starts from the reference data and moves to both sides of the reference data. Compared with the prior art, the calculation method can improve the efficiency of calculation.
  • the data block to be encoded may also be further divided into multiple data sub-blocks, by setting one or more reference data in each data sub-block, and calculating the two sides of each reference data The residual value of two adjacent data, which can further improve the efficiency of calculation, and further improve the efficiency of compression coding.
  • the process of calculating the residual is shown in Fig. 4, taking 16 pieces of data contained in the data block to be coded as an example, the 16 pieces of data are respectively: p0, p1, p2, p3, p4,, p14, p15.
  • the data p8 at the center of the data block to be encoded as the reference data use the following array to record the residual values of pixels other than p8:
  • the residual values of two adjacent data are calculated on both sides respectively. Compared with the data in the initial position, the residual values are calculated, which can improve the calculation efficiency.
  • the following array can be used to record the residual values of pixels other than p8:
  • calculation direction can be adjusted as needed, and is not limited to the above two methods.
  • the residual value and the corresponding reference data are written into the code stream data according to the code stream structure corresponding to the residual coding method to obtain the corresponding code stream data; the residual coding method corresponds to
  • the code stream structure includes: the flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  • the code stream structure corresponding to the residual coding method is shown in FIG. 5.
  • the above-mentioned data segment to be coded contains 16 pieces of data as an example, and the flag bit 10 is used to characterize the code used in the code stream structure.
  • the method is the residual coding method (DPCM16), p8 is the reference data, Rb is the bit width occupied by the residual value, r0-r7 is the residual value, and r10-r15 is the residual value.
  • encoding the data block to be encoded by the hybrid encoding method specifically includes the following steps:
  • the method for dividing the data block to be coded may be to obtain a plurality of data sub-blocks with the same size evenly, or it may be divided into data sub-blocks with different sizes according to a set size.
  • the two-way calculation and coding method improves coding efficiency compared with the prior art.
  • the code stream structure corresponding to the foregoing hybrid encoding method includes: a flag bit of the encoding method, the reference data, the bit width occupied by the residual value, and the residual value.
  • multiple data sub-blocks are obtained by dividing the data block to be coded, and each data sub-block is coded in a residual coding manner.
  • the data contained in the data block to be encoded is: p0, p1, p2,, p14, p15
  • the data block to be encoded is divided into two data sub-blocks, which are respectively data blocks : P0p1, p7 and data block: p8p9,,, p15.
  • For two data sub-blocks select one data at a preset position as parameter data (respectively p4, p12 in the figure), and then calculate the residual values of two adjacent data on both sides of the reference data. And write the code stream data according to the coding structure of the hybrid coding.
  • the encoding structure corresponding to the hybrid encoding mode is shown in FIG. 8, where, in the hybrid encoding mode, the above-mentioned flag bit 10 is used to indicate that the encoding method adopted by the code stream structure is the residual encoding method (DPCM8_1&DPCM8_2), p4 and p12 are reference data respectively, Rb is the bit width occupied by the residual value, r0-r7 is the residual value, and r8-r14 is the residual value.
  • the above-mentioned flag bit 10 is used to indicate that the encoding method adopted by the code stream structure is the residual encoding method (DPCM8_1&DPCM8_2)
  • p4 and p12 are reference data respectively
  • Rb is the bit width occupied by the residual value
  • r0-r7 is the residual value
  • r8-r14 is the residual value.
  • the aforementioned target encoding method includes: a hybrid encoding method.
  • encoding the data block to be encoded by the hybrid encoding method specifically includes the following steps S21'-S23':
  • the method for dividing the data block to be coded may be to obtain a plurality of data sub-blocks with the same size evenly, or it may be divided into data sub-blocks with different sizes.
  • the first data sub-block is coded according to the above residual coding method, and then the obtained residual
  • the value and reference data are written into the coded code stream data according to the code stream structure corresponding to the hybrid coding mode.
  • the original data in the second data sub-block is written into the coded stream data directly according to the code stream structure corresponding to the mixed coding mode according to the original coding mode.
  • the hybrid coding mode when the hybrid coding mode is adopted, after the data block to be coded is divided to obtain multiple data sub-blocks, the first data sub-block is coded according to the residual coding mode, and the second data sub-block is Encode according to the original encoding method; the first data sub-block and the second data sub-block may be obtained by dividing all the data sub-blocks equally according to the number, and the number of the first data sub-block is the same as the number of the second data sub-block ; Of course, the number of first data sub-blocks may be different from the number of second data sub-blocks.
  • the code stream structure corresponding to the above-mentioned hybrid encoding method includes: the flag bit of the encoding method, the original data of the second data block, the reference data, the bit width occupied by the residual value, and the residual value.
  • an embodiment of the present invention provides a hybrid encoding method
  • the coding structure is shown in Figure 10.
  • the above-mentioned flag bit 11 is used to characterize that the coding mode corresponding to the bitstream structure is hybrid coding;
  • the bitstream structure of mixed coding includes not only the coding mode representing "hybrid coding", but also Characterize the coding mode corresponding to each sub-data block.
  • 1 bit can be used to mark whether the code stream of the corresponding sub-data block is original coding or residual coding, for example, 0 is used to represent the original coding, and 1 is used to represent the residual coding.
  • the code stream structure in this hybrid coding mode includes: (1) The code stream structure (RAW8_1&DPCM8_2) for the original coding and residual coding of the data sub-blocks.
  • the coding mode flag bit of the code stream structure is 00, where p0- p8 is the original data, p12 is the reference data, r8-r15 is the residual value, and R'b is the bit width occupied by the residual value;
  • Perform residual coding on data sub-blocks (DPCM8_1&DPCM8_2), the coding mode flag of this coding mode is 10; among them, p4 and p12 are reference
  • the encoding overhead calculated for the same data block to be encoded by each of the foregoing encoding methods can be referred to as follows:
  • the encoding overhead for the original encoding of the data block to be encoded is: 16*8bit; where 16 is the number of data, and the space occupied by each data is 8bit.
  • the coding overhead for residual coding of the data block to be coded is: 8bit+bitlen_16*15+3bit; among them, 8bit is the bit width occupied by the reference data, bitlen_16 is the bit width occupied by a residual value, and 3bit is the bitlen 16 Occupied bit width.
  • the coding overhead for dividing the data block to be coded into two data blocks for residual coding is: 1bit+8bit+bitlen8_1*7+3bit+1bit+8bit+bitlen8_2*7+3bit, where the calculation unit is 8 data, and 1bit is used
  • 8bit is the bit width occupied by the reference data
  • bitlen8_1 and bitlen8_2 are the bit width occupied by a residual value
  • 3bit is the bit width occupied by bitlen8_1 or bitlen8_2.
  • the encoding overhead of dividing the data block to be encoded into two data blocks for original encoding and residual encoding is: 1bit+8bit*8+1bit+8bit+bitlen8_2*7+3bit; among them, the first 8 data are original data, each The space occupied by the original data is 8bit, 1bit is used to mark whether the code stream is original encoding or residual encoding, the second 8bit is the bit width occupied by the reference data, and bitlen8_2 is the bit width occupied by a residual value. 3bit is the bit width occupied by bitlen8_2.
  • the coding overhead of dividing the data block to be coded into two data blocks for residual coding and original coding is: 1bit+8bit+bitlen8_1*7+3bit+1bit+8*8bit; for the definition of the calculation formula, please refer to the above coding overhead Calculation.
  • all the data blocks to be encoded contain 16-bit data as an example; but in practice, the data blocks to be encoded may also contain data such as 32 bits, 64 bits, etc.; The present invention does not limit this.
  • both the first encoding method and the second encoding method are lossless encoding, which can ensure the accuracy of the data to be encoded after compression and decompression.
  • the data processing method provided in the foregoing embodiment of the present invention can be applied to compress the weight data of a neural network, which can greatly reduce bandwidth overhead.
  • the embodiment of the present invention does not reduce the convergence speed of the network, nor does it need to fine-tune hyperparameters, and has high efficiency; in addition, the embodiment of the present invention does not cause a loss of the accuracy of the weight data, and ensures that the weight parameters will not introduce additional errors. And there is no need to retrain the network, and the system bandwidth can be reduced to a large extent. It also does not exist that after the weight data is compressed by the method provided in the foregoing embodiment of the present invention, the convergence speed of the network will not be reduced, and the efficiency is high. And it will not cause the loss of the accuracy of the weight data.
  • an embodiment of the present invention also provides a data processing method to decode the encoded data data (as data to be decoded).
  • an embodiment of the invention provides a data processing method, which includes the following steps S41-S42:
  • the above-mentioned data to be decoded includes the coding mode flag bit; the above-mentioned analysis of the data to be decoded can obtain the value of the flag bit contained in the decoded data, and then according to the preset mapping relationship between the value of the flag bit and the first coding mode,
  • the target encoding method corresponding to the data to be decoded is determined, and the corresponding target decoding method can be determined according to the target encoding method; for example, the target decoding method is the inverse operation of the target encoding method.
  • the flag bit 00 in the code stream structure is obtained, and the corresponding encoding method is determined to be run-length coding according to the flag bit 00. Then obtain the corresponding target decoding mode as run-length decoding.
  • the corresponding target decoding method can be determined, and the target decoding method may be the inverse operation of the encoding method.
  • the above-mentioned first encoding method includes one or more of run-length encoding, original data encoding, residual encoding, and hybrid encoding;
  • the hybrid coding is to divide a data block to be coded to generate multiple data sub-blocks, and perform residual coding or original data coding on each of the data blocks.
  • the above-mentioned residual coding is to use the data at the preset position in the data block to be coded as reference data, respectively calculate the residual value of each two adjacent data located on both sides of the reference data, and combine the residual value and the
  • the reference data is written into the coded code stream data according to the code stream structure corresponding to the residual coding mode.
  • the foregoing target decoding mode includes one or more of run-length decoding, original data copy, residual decoding, and hybrid decoding;
  • the above-mentioned hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks.
  • the division method may be divided according to flag bits, and residual decoding or original data copy is performed on each data block. .
  • the above-mentioned residual decoding is to read the corresponding reference data, the bit length occupied by the residual value and the residual value from the bit stream structure of the data to be decoded, according to the bit length occupied by the reference data and the residual value Perform the inverse operation of the residual calculation with the residual value to generate decoded data.
  • using the residual decoding method to decode the data to be decoded includes: reading the corresponding reference data from the code stream structure of the data to be decoded and the residual value The bit length and residual value of, perform the inverse operation of residual calculation according to the reference data and residual value to obtain the original data.
  • using run-length decoding to decode the data to be decoded includes:
  • the start value and the run length are read from the code stream structure of the data to be decoded, and the data to be decoded is decoded and restored according to the start value and the run length to obtain decoded data.
  • using the original data copy mode to decode the data to be decoded includes:
  • the part of the data exceeding the preset data volume is discarded to generate The decoded data.
  • another embodiment of the present invention also provides a data processing method, including the following steps S51-S52:
  • the 16 data are: p0, p1, p2, p3, p4, ,,, p14, p15.
  • the reference data p8 Take the data p8 at the center of the data block to be encoded as the reference data, start with the reference data p8, calculate the residual values of the two adjacent data to both sides, and calculate the residuals relative to the data at the initial position Value, can improve the efficiency of calculation.
  • the intermediate data and residual data can be accumulated or decremented to both ends during decoding, which improves the parallelism of decoding.
  • the foregoing data block to be encoded may be obtained in the following two ways:
  • Manner 1 Divide the original data block according to a specified size to obtain multiple data sub-blocks, and use each of the data sub-blocks as the data block to be encoded.
  • Manner 2 Divide the original data block according to the specified size to obtain multiple data sub-blocks, and use the first data block of the multiple data blocks as the data block to be encoded.
  • part of the data sub-blocks (that is, the first data block) of the multiple data sub-blocks is used as the above-mentioned data block to be coded, and the data in the preset position in the data block to be coded is used as For reference data, calculate the residual values of every two adjacent data located on both sides of the reference data.
  • the first data block is used as the data block to be encoded
  • the data blocks other than the first data block among the multiple data sub-blocks obtained are based on the code stream structure corresponding to the original encoding method , Write the coded stream data;
  • the code stream structure corresponding to the original coding mode includes: the flag bit of the coding mode and the original data.
  • the above-mentioned residual value and reference data are written into the coded stream data according to the code stream structure corresponding to the residual coding mode, and the code stream structure corresponding to the residual coding mode includes: reference data, residual value And the bit width occupied by the residual value.
  • the two-way calculation method can improve the efficiency of calculation.
  • the data sub-block can also be further divided into multiple data blocks, by setting one or more reference data in each data block, and calculating the phases on both sides of each reference data.
  • the residual value of the adjacent two data can further improve the calculation efficiency and thus the coding efficiency.
  • the data block to be decoded when parsing the encoded data obtained by the above method as the data block to be decoded in an embodiment of the present invention, first obtain the reference data and residual data in the data block to be decoded; wherein, the data block to be decoded
  • the data block is encoded and generated; the reference data is data at a preset position in the original data; the residual data is the residual value of every two adjacent data located on both sides of the reference data during the encoding process.
  • the reference data and the residual data are decremented or accumulated to generate the original data on both sides of the reference data.
  • the data block to be encoded contains 16 data
  • the 16 data are: p0, p1, p2, p3, p4, ,, p14, p15.
  • the data p8 at the center of the data block to be encoded as the reference data use the following array to record the residual values of pixels other than p8:
  • p8 and diff[8] to diff[14] are used for decrement operations to obtain p9-p14 data respectively.
  • p8 and diff[0] to diff[7] are used for decrement operations.
  • the data of p7-p0 can be obtained separately.
  • decrement operations with r0 to r7 can respectively obtain data p7-p0
  • decrement operations with r9 to r15 can respectively obtain data p9-p14.
  • p8-diff[0] can get p7
  • p8-diff[0]-diff[1] can get p6, and other things are the same.
  • the following array can be used to record the residual values of pixels other than p8:
  • p8 and diff[8] to diff[14] are used for accumulation operation to obtain the data of p9-p14 respectively.
  • p8 and diff[0] to diff[7] are used for accumulation operation
  • the data of p7-p0 can be obtained separately.
  • the data of p7-p0 can be obtained by accumulating operations with r0 to r7
  • the data of p9-p14 can be obtained by accumulating operations with r9 to r15 respectively.
  • p8+diff[0] can get p7
  • p8+diff[0]+diff[1] can get p6, and the others are the same.
  • two-way simultaneous decoding operations can be performed on the data block to be decoded from both sides of the reference data, which has the positive effect of high decoding efficiency.
  • this embodiment provides a data processing method, which is applied to a configurator, a memory, and a processor connected in sequence, and the method includes the following steps S61-S62:
  • S61 Perform compression encoding on the data block to be encoded formed by the preset data by the configurator to generate a compressed code stream, and write the compressed code stream into the memory, so as to reduce the write bandwidth to the memory.
  • the above-mentioned configurator is provided with an encoder, and the configurator specifically compresses and encodes the data block to be encoded by the encoder to generate a code stream.
  • S62 Read the compressed code stream in the memory by the processor, and perform decompression processing on the compressed code stream to reduce the read bandwidth of the memory.
  • a decoder is provided on the aforementioned processor, and the processor specifically decompresses the aforementioned compressed code stream through the decoder.
  • the above-mentioned preset data is weight data based on a convolutional neural network; and in this embodiment, the configurator is used to allocate the weight data and compress and encode the weight data by an encoder.
  • the compressed code stream is written into the memory; the processor is used to read the compressed code stream corresponding to the weight data from the memory, decompress the compressed code stream through the decoder to generate weight data, and run the convolution based on the weight data Neural Networks.
  • the foregoing processor further includes a static random-access memory (Static Random-Access Memory, SRAM), which is used to read the compressed code stream corresponding to the weight data from the memory, so that the processor can pass through
  • SRAM static random-access memory
  • the decoder performs decompression processing on the compressed code stream in the SRAM to generate weight data, and runs the convolutional neural network based on the weight data.
  • FIG. 14 shows a schematic diagram of the relationship between the configurator, the memory and the processor; referring to FIG. 14, the above-mentioned configurator is connected to the memory, and the memory is connected to the processor.
  • the above-mentioned memory may be a double data rate synchronous dynamic random access memory (Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM); in this embodiment, an encoder is provided in the configurator, and the configurator is specifically coded
  • the processor compresses and encodes the data block to be encoded to generate a compressed code stream; the processor is provided with a decoder and a static random access memory, and the static random access memory is used to read the compressed code stream corresponding to the weight data from the memory.
  • a decoder is used to decompress the compressed code stream in the SRAM to generate weight data, and run a convolutional neural network based on the weight data.
  • the encoder in order to reduce the bandwidth overhead when the weight data is read from the memory to the static random access memory in the processor, the encoder decompresses the compressed weight data; accordingly, the configurator will Before the weight data is written into the memory, the encoder will compress the weight data.
  • This process uses encoders and decoders to losslessly compress and decompress the weight data, ensuring that the weight data does not introduce additional errors and does not require retraining the network. At the same time, the system bandwidth can be reduced to a large extent.
  • the encoder performs lossless compression processing on the weight data to ensure that the weight parameters do not introduce additional errors and do not need to retrain the network.
  • the specific process of the configurator performing compression encoding on the data block to be encoded to generate a compressed code stream includes: acquiring the encoding overhead of multiple first encoding methods for the data block to be encoded, In the encoding method, determine the target encoding method with the least encoding overhead; then use the target encoding method to compress and encode the data block to be encoded formed by the preset data to generate a compressed code stream; the preset data may be the weight of the convolutional neural network data.
  • the aforementioned encoding overhead is the bit width occupied by the code stream data generated after the data block to be encoded is encoded.
  • an encoding method with the least encoding overhead is selected for encoding, which can achieve effective compression of the data blocks to be encoded.
  • the above-mentioned configurator first determines whether there is a redundant data block in the original data block, and if so, the redundant data block is encoded according to the second encoding method.
  • the second encoding method includes: run-length encoding.
  • the specific configurator writes the redundant data block into the code stream data according to the code stream structure corresponding to the run-length encoding; the code stream corresponding to the run-length encoding
  • the structure includes: the flag bit of the encoding method, the starting value and the run length.
  • the remaining data blocks can be used as the data blocks to be encoded, and the encoding method with the least encoding overhead is selected for encoding.
  • the remaining data blocks may be divided according to a specified size to obtain multiple data blocks, each data block is used as the data block to be encoded, and the encoding method with the least encoding overhead is selected for encoding; in this embodiment, if the remaining data block If the amount of data does not satisfy an integer multiple of the specified size, then the remaining data blocks are first filled with data so that the size of each data block obtained after division is the specified size.
  • the above-mentioned configurator determines whether there is a redundant data block in the original data block in the following manner:
  • the configurator searches the original data block to see whether there is data that continuously appears and the number of repetitions is greater than a preset value, and if so, determines that there is a redundant data block, and uses the continuous data as the redundant data block; if not , It is determined that there is no redundant data block.
  • the above-mentioned multiple first encoding methods include: an original encoding method, a residual encoding method, and a hybrid encoding method; wherein the hybrid encoding method is to divide the data block to be encoded into several data After sub-blocks, residual coding or original coding is performed on each of the data blocks.
  • encoding the data block to be coded by the target coding mode includes:
  • the code stream structure corresponding to the original coding mode includes: a flag bit of the coding mode and original data.
  • the encoding the data block to be coded by the target coding mode includes:
  • the residual values of each two adjacent data located on both sides of the reference data are calculated respectively, and the residual value and the reference data are calculated according to
  • the code stream structure corresponding to the residual coding method is written into the coded code stream data;
  • the code stream structure corresponding to the residual coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  • encoding the data block to be coded by the target coding mode includes:
  • the residual value calculated for each of the data sub-blocks and the reference data are respectively written into the coded code stream data according to the code stream structure corresponding to the hybrid coding mode.
  • the code stream structure corresponding to the above-mentioned hybrid coding mode includes: the flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  • encoding the data block to be coded by the target coding mode includes:
  • the residual values of each two adjacent data located on both sides of the reference data are respectively calculated, and the residual value and the reference data Write the encoded code stream data according to the code stream structure corresponding to the hybrid encoding method; write the original data in the second data sub-block into the code stream structure corresponding to the hybrid encoding method Stream data;
  • the code stream structure corresponding to the hybrid encoding method in this embodiment includes: the flag bit of the encoding method, the original data of the second data block, the residual value, the reference data, and the residual value The occupied bit width and the residual value.
  • the processor reading the compressed code stream in the memory and decompressing the compressed code stream includes:
  • the processor parses the compressed code stream, determines a target encoding method corresponding to the compressed code stream among a plurality of preset first encoding methods, and determines a corresponding target decoding method according to the target encoding method;
  • the compressed code stream is decoded by the target decoding method to obtain the preset data.
  • the code stream structure of the aforementioned compressed code stream includes a flag bit; the processor determines that it corresponds to the compressed code stream according to a preset mapping relationship between the value of the flag bit and the first encoding mode The target encoding method.
  • the foregoing target decoding methods include: any one or more of run-length decoding, original data copy, residual decoding, and hybrid decoding;
  • the hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks, and perform residual decoding or original data copy on each of the data word blocks.
  • the using the target decoding mode to decode and restore the compressed code stream includes:
  • the initial value and the run length are read from the code stream structure of the compressed code stream, and the compressed code stream is decoded and restored according to the initial value and the run length to obtain corresponding preset data.
  • the decoding and restoring the compressed code stream using the target decoding mode includes:
  • the using the target decoding mode to decode and restore the compressed code stream includes:
  • the decoding and restoring the compressed code stream using the target decoding method to obtain the preset data includes:
  • the data volume of the data obtained by decoding and restoring the compressed code stream by the target decoding method is greater than the preset data volume, discarding part of the data exceeding the preset data volume to obtain the preset data.
  • a data processing system including: a configurator 81, a memory 80, and a processor 82 connected in sequence.
  • the configurator 81 is configured to compress and encode a data block to be encoded formed by preset data to generate a compressed code stream, and write the compressed code stream into the memory 80 to reduce the write bandwidth to the memory 80.
  • the processor 82 is configured to read the compressed code stream in the memory 80, and decompress the compressed code stream, so as to reduce the read bandwidth of the memory 80.
  • an encoder is provided on the configurator 81, and a decoder is provided on the processor 82;
  • the configurator is used to compress and encode the data block to be encoded by the encoder to generate a compressed code stream, and the processor is used to perform decompression processing on the compressed code stream by the decoder.
  • the aforementioned preset data is weight data based on a convolutional neural network;
  • the configurator is used to allocate the weight data, and write the compressed code stream obtained by compressing and encoding the weight data into the memory;
  • the processor is configured to read the compressed code stream corresponding to the weight data from the memory, decompress the compressed code stream to generate the weight data, and run the convolutional neural network based on the weight data The internet.
  • the configurator, memory, and processor constitute the system architecture of the convolutional neural network.
  • the problem of the processor repeatedly reading weight data from the memory to the processor is solved. Bandwidth pressure.
  • the aforementioned processor 82 further includes a static random access memory, and the static random access memory is used to read the compressed code stream corresponding to the weight data from the memory, so that the processor can The compressed code stream is decompressed to generate the weight data, and the convolutional neural network is run based on the weight data.
  • the foregoing memory may be a double data rate synchronous dynamic random access memory (Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM); in this embodiment, an encoder is provided in the configurator, and the configurator is specifically The encoder is used to compress and encode the data block to be encoded to generate a code stream; the processor is provided with a decoder and a static random access memory, and the static random access memory is used to read the compression code corresponding to the preset data from the memory Stream, the processor decompresses the compressed code stream in the SRAM through the decoder to generate the original preset data.
  • DDR SDRAM Double Data Rate Synchronous Dynamic Random Access Memory
  • the aforementioned data processing system is a calculation system of a convolutional neural network
  • the aforementioned preset data is weight data of a convolutional neural network
  • the aforementioned processor is used to run the convolutional neural network based on the weight data.
  • the encoder in order to reduce the bandwidth overhead when the weight data is read from the memory to the static random access memory in the processor, the encoder decompresses the compressed weight data; accordingly, the configurator will Before the weight data is written into the memory, the encoder will compress the weight data.
  • This process uses encoders and decoders to losslessly compress and decompress the weight data, ensuring that the weight data will not introduce additional errors and do not need to retrain the neural network, while reducing the system bandwidth to a large extent. It reduces the hardware resource requirements for the operation of the convolutional neural network.
  • the above-mentioned configurator 81 is specifically configured to compress and encode the to-be-coded data block formed by the preset data in the following manner to generate a compressed code stream:
  • the configurator obtains the coding overhead of the plurality of preset first coding modes for the data block to be coded, and determines the target coding mode with the smallest coding overhead from the plurality of first coding modes;
  • the foregoing encoding overhead is the bit width occupied by the code stream data generated after encoding the data block to be encoded.
  • the above-mentioned configurator 81 is further configured to: determine whether there is a redundant data block in the original data block, and if so, encode the redundant data block according to the second coding mode;
  • the above-mentioned configurator 81 is further configured to generate the data block to be encoded in the following manner:
  • the above-mentioned configurator 81 is specifically configured to determine whether there is a redundant data block in the original data block in the following manner:
  • the foregoing second encoding manner includes run-length encoding
  • the configurator 81 is specifically configured to encode the redundant data block according to the second encoding manner in the following manner:
  • the redundant data block is written into the coded stream data according to the code stream structure corresponding to the run-length encoding; the code stream structure corresponding to the run-length encoding includes: the flag bit of the encoding mode, the start value and the run length .
  • the above-mentioned multiple first coding modes include: an original coding mode, a residual coding mode, and a mixed coding mode; wherein, the mixed coding mode is after the data block to be coded is divided into several data sub-blocks , Perform residual coding or original coding on each of the data blocks.
  • the configurator 81 is specifically configured to:
  • the original data in the data block to be coded is written into the coded stream data according to the code stream structure corresponding to the original coding mode; the code stream structure corresponding to the original coding mode includes: the flag bit of the coding mode and Raw data.
  • the configurator 81 is specifically configured to:
  • the residual values of each two adjacent data located on both sides of the reference data are calculated respectively, and the residual value and the reference data are calculated according to
  • the code stream structure corresponding to the residual coding mode is written into the coded code stream data; wherein the code stream structure corresponding to the residual coding mode includes: a flag bit of the coding mode, the reference data, and the residual The bit width occupied by the value and the residual value.
  • the configurator 81 is specifically configured to:
  • the residual value calculated for each data sub-block and the reference data are written into the coded stream data according to the code stream structure corresponding to the hybrid encoding mode; wherein the code corresponding to the hybrid encoding mode
  • the stream structure includes: a flag bit of an encoding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  • the configurator is specifically configured to:
  • the residual values of each two adjacent data located on both sides of the reference data are respectively calculated, and the residual value and the reference data Write the encoded code stream data according to the code stream structure corresponding to the hybrid encoding method; write the original data in the second data sub-block into the code stream structure corresponding to the hybrid encoding method Stream data;
  • the code stream structure corresponding to the hybrid coding mode includes: the flag bit of the coding mode, the original data of the second data block, the residual value, the reference data, and the residual value Bit width and the residual value.
  • the above-mentioned configurator 81 is further configured to: before the dividing the remaining data blocks according to a specified size to obtain multiple data blocks, if the data amount of the remaining data blocks does not satisfy an integer of the specified size Times, the remaining data blocks are filled with data, so that the size of each data block obtained after division is the specified size.
  • the performing data filling on the remaining data blocks includes:
  • the foregoing processor 82 is specifically configured to read the compressed code stream in the memory in the following manner, and perform decompression processing on the compressed code stream:
  • the processor parses the compressed code stream, determines a target encoding method corresponding to the compressed code stream among a plurality of preset first encoding methods, and determines a corresponding target decoding method according to the target encoding method;
  • the compressed code stream is decoded by the target decoding method to obtain the preset data.
  • the code stream structure of the compressed code stream includes a flag bit
  • the processor is specifically configured to parse the compressed code stream in the following manner, and determine a target encoding method corresponding to the compressed code stream among a plurality of preset first encoding methods:
  • the target coding mode corresponding to the compressed code stream is obtained.
  • the target decoding mode includes any one of run-length decoding, original data copy, residual decoding, and hybrid decoding;
  • the hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks, and perform residual decoding or original data copy on each of the data word blocks.
  • the processor when the target decoding mode is run-length decoding, the processor is specifically configured to:
  • the initial value and the run length are read from the code stream structure of the compressed code stream, and the compressed code stream is decoded and restored according to the initial value and the run length to obtain corresponding preset data.
  • the processor is specifically configured to:
  • the processor is specifically configured to:
  • the processor is specifically configured to decode and restore the compressed code stream by using the target decoding mode in the following manner to obtain the preset data, including:
  • the data volume of the data obtained by decoding and restoring the compressed code stream by the target decoding method is greater than the preset data volume, discarding part of the data exceeding the preset data volume to obtain the preset data.
  • the movable platform includes: a body 900, a power system 91, and the data processing system 92 described in the foregoing embodiment; the power system 91 is located at The body 900 and the power system 91 are used to provide power for the movable platform.
  • the aforementioned data processing system 92 may be applied to a functional system of a movable platform such as a power system, an operating system, and the like.
  • the data processing system 92 uses a convolutional neural network for data processing, it can achieve lossless compression and decompression of weight data, ensuring that the weight data will not introduce additional errors and do not need to retrain the neural network , And reduce system bandwidth overhead. It can meet the use of hardware resources with lower conditions to realize the operation of convolutional neural networks.
  • an encoder 1000 is provided in this embodiment, including: a selection circuit 101 and an encoding circuit 102;
  • the selection circuit is configured to obtain the coding overhead of the data block to be coded by the multiple first coding modes, and determine the target coding mode with the smallest coding overhead from the multiple first coding modes;
  • the encoding circuit encodes the data block to be encoded by using the target encoding method.
  • the encoder provided in the embodiment of the present invention can effectively compress data and has the advantage of high compression efficiency.
  • the foregoing encoding overhead is the bit width occupied by the code stream data generated after the data block to be encoded is encoded.
  • the above selection circuit is also used for:
  • the data block to be encoded is generated in the following manner:
  • the foregoing determining whether there is a redundant data block in the original data block includes:
  • the second encoding manner includes run-length encoding
  • encoding the redundant data block according to the second encoding manner includes:
  • the redundant data block is written into the coded stream data according to the code stream structure corresponding to the run-length encoding; the code stream structure corresponding to the run-length encoding includes: the flag bit of the encoding mode, the start value and the run length .
  • the multiple first coding modes include: an original coding mode, a residual coding mode, and a mixed coding mode; wherein the mixed coding mode is dividing the data block to be coded into several data sub-blocks Afterwards, residual coding or original coding is performed on each of the data blocks.
  • the encoding the data block to be coded by the target coding mode includes:
  • the code stream structure corresponding to the original coding mode includes: a flag bit of the coding mode and original data.
  • the encoding the data block to be coded by the target coding mode includes:
  • the code stream structure corresponding to the residual coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  • encoding the data block to be coded by the target coding mode includes:
  • the code stream structure corresponding to the hybrid coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  • encoding the data block to be coded by the target coding mode includes:
  • the residual values of each two adjacent data located on both sides of the reference data are respectively calculated, and the residual value and the reference data Write the coded code stream data according to the code stream structure corresponding to the hybrid coding mode;
  • the code stream structure corresponding to the hybrid coding mode includes: the flag bit of the coding mode, the original data of the second data block, the reference data, the bit width occupied by the residual value, and the residual value. Difference.
  • the method before dividing the remaining data blocks according to a specified size to obtain multiple data blocks, the method includes:
  • data padding is performed on the remaining data block so that the size of each data block obtained after division is the specified size.
  • the performing data filling on the remaining data blocks includes:
  • Another embodiment of the present invention also provides an encoder, which includes a residual calculation circuit and an encoding circuit.
  • the residual calculation circuit is configured to use the data in the preset position in the data block to be encoded as reference data, and respectively calculate the residual value of every two adjacent data located on both sides of the reference data;
  • the coding circuit is configured to write the residual value and the reference data into the code stream data according to the code stream structure corresponding to the residual coding mode; wherein, the code stream structure corresponding to the residual coding mode Including: the reference data, the bit width occupied by the residual value, and the residual value.
  • the data block to be encoded is generated in the following manner:
  • the original data block is divided according to a specified size to obtain multiple data sub-blocks, and each of the data sub-blocks is used as the data block to be encoded.
  • the data block to be encoded is generated in the following manner:
  • the original data block is divided according to a specified size to obtain multiple data sub-blocks, and the first data block of the multiple data blocks is used as the data block to be encoded.
  • the encoding circuit is also used for:
  • the other data blocks of the multiple data sub-blocks except the first data block are written into the code stream data according to the code stream structure corresponding to the original coding mode;
  • the code stream structure corresponding to the original coding mode includes : Flag bit and original data of encoding method.
  • Figure 18 also shows a schematic diagram of the encoder architecture.
  • the encoder architecture mainly includes four functional modules: run-length encoding module, encoding overhead calculation module, mode selection module (used to determine the target encoding method with the smallest encoding overhead) and The remaining data block encoding module (used to encode the remaining data blocks except for the redundant data block); it should be noted that this embodiment is only an example for illustration and should not be regarded as a limitation of the present invention.
  • this embodiment provides a decoder 1100, and the decoder 1100 includes: an analysis circuit 111 and a decoding circuit 112;
  • the parsing circuit 111 is configured to analyze the data to be decoded, determine a target encoding method corresponding to the data to be decoded among a plurality of preset first encoding methods, and determine a corresponding target decoding method according to the target encoding method;
  • the decoding circuit 112 is configured to decode the data to be decoded in the target decoding mode to generate decoded data.
  • the data to be decoded includes a flag bit; the analyzing the data to be decoded and determining the target encoding method corresponding to the data to be decoded among the plurality of preset first encoding methods includes:
  • the target coding mode corresponding to the data to be decoded is determined.
  • the first coding mode includes one or more of run-length coding, original data coding, residual coding, and hybrid coding;
  • the hybrid coding is to divide the data block to be coded to generate multiple data sub-blocks, and perform residual coding or original data coding on each of the data blocks.
  • the residual coding is using data at a preset position in the data block to be coded as reference data, respectively calculating the residual values of every two adjacent data on both sides of the reference data, and calculating The residual value and the reference data are written into the coded stream data according to the code stream structure corresponding to the residual coding mode.
  • the target decoding mode includes one or more of run-length decoding, original data copy, residual decoding, and hybrid decoding;
  • the hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks, and perform residual decoding or original data copy on each of the data word blocks.
  • the residual decoding is to read the corresponding reference data, the bit length occupied by the residual value, and the residual value from the code stream structure of the data to be decoded, according to the reference data and the residual value
  • the occupied bit length and residual value perform the inverse operation of residual calculation to generate decoded data.
  • the using the target decoding mode to decode the data to be decoded includes:
  • the start value and the run length are read from the code stream structure of the data to be decoded, and the data to be decoded is decoded and restored according to the start value and the run length to obtain decoded data.
  • the using the target decoding mode to decode the data to be decoded includes:
  • the using the target decoding mode to decode the data to be decoded includes:
  • the decoding multiple pieces of to-be-decoded data to generate decoded data using the target decoding manner includes:
  • the data amount of the data obtained by decoding the data to be decoded by the target decoding method is greater than the preset data amount, discarding part of the data exceeding the preset data amount to generate the decoded data.
  • Figure 20 also shows a schematic diagram of the architecture of a decoder.
  • the decoder mainly includes the following functional modules: a pattern analysis module (used to determine the target decoding method), a run-length decoding module, a residual decoding module, and an original data decoding module. It should be noted that this embodiment is only an example and should not be regarded as a limitation of the present invention.
  • Another embodiment of the present invention also provides a decoder, which includes: a parsing circuit and a decoding circuit.
  • the parsing circuit is used to analyze the data block to be decoded to obtain reference data and residual data in the data block to be decoded; wherein the data block to be decoded is generated by encoding the original data block; and the reference data is all The data at a preset position in the original data; the residual data is the residual value of every two adjacent data located on both sides of the reference data during the encoding process.
  • the decoding circuit is used to decrement or accumulate the reference data and the residual data to generate original data on both sides of the reference data
  • the relevant part can refer to the part of the description of the method embodiment.
  • the device embodiments described above are merely illustrative.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network units.
  • Some or all of the modules may be selected according to actual needs to achieve the objectives of the solutions of the embodiments. Those of ordinary skill in the art can understand and implement it without creative work.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

A data processing method, a system, an encoder, and a decoder. The method comprises: obtaining the encoding overhead of multiple first encoding modes for a data block to be encoded, and determining a target encoding mode with the smallest encoding overhead from the multiple first encoding modes; and encoding said data block in the target encoding mode . In this way, effective compression and encoding of data to be encoded can be implemented.

Description

一种数据的处理方法、系统、编码器及解码器Data processing method, system, encoder and decoder 技术领域Technical field
本申请涉及数据处理技术领域,具体而言,涉及一种数据的处理方法、系统、编码器及解码器。This application relates to the technical field of data processing, and in particular to a data processing method, system, encoder and decoder.
背景技术Background technique
随着神经网络技术的发展,神经网络模型的规模越来越庞大;以CNN(Convolutional Neural Networks,卷积神经网络)网络为例,其中权重数据为主要参数,参数规模大,在参数读写过程中占用带宽高,对硬件的计算和存储能力要求较高,进而限制了神经网络模型的应用。With the development of neural network technology, the scale of neural network models is getting larger and larger; take CNN (Convolutional Neural Networks, convolutional neural network) network as an example, in which weight data is the main parameter, and the parameter scale is large. The medium occupies high bandwidth, and requires high hardware computing and storage capabilities, which in turn limits the application of neural network models.
因此,如何在不影响网络卷积神经网络模型的计算准确率的前提下,减小卷积神经网络模型的运算规模,对加快硬件设备的计算处理速度和节省存储资源以及扩大卷积神经网络的应用范围,具有重要的意义。Therefore, how to reduce the calculation scale of the convolutional neural network model without affecting the calculation accuracy of the network convolutional neural network model, which will speed up the calculation and processing speed of hardware devices, save storage resources and expand the convolutional neural network The scope of application is of great significance.
发明内容Summary of the invention
有鉴于此,本发明的目的之一是提供一种数据的处理方法、系统、编码器及解码器,以实现对待编码数据进行有效压缩。In view of this, one of the objectives of the present invention is to provide a data processing method, system, encoder and decoder to achieve effective compression of the data to be encoded.
第一方面,本发明实施例中提供了一种数据处理的方法,包括:In the first aspect, an embodiment of the present invention provides a data processing method, including:
获取多个第一编码方式对于待编码数据块的编码开销,从所述多个第一编码方式中确定编码开销最小的目标编码方式;Acquiring the coding overhead of the multiple first coding modes for the data block to be coded, and determining the target coding mode with the smallest coding overhead from the multiple first coding modes;
通过所述目标编码方式对所述待编码数据块进行编码。Encoding the data block to be encoded by the target encoding method.
第二方面,本发明实施例提供了一种数据处理方法,包括:In the second aspect, an embodiment of the present invention provides a data processing method, including:
对待解码数据进行解析,确定多个预设的第一编码方式中与所述待解码数据对应的目标编码方式,根据所述目标编码方式确定对应的目标解码 方式;Parsing the data to be decoded, determining a target encoding method corresponding to the data to be decoded among a plurality of preset first encoding methods, and determining a corresponding target decoding method according to the target encoding method;
通过所述目标解码方式对所述待解码数据进行解码,生成解码数据。The data to be decoded is decoded by the target decoding mode to generate decoded data.
第三方面,本发明实施例提供了一种数据处理的方法,包括:In the third aspect, an embodiment of the present invention provides a data processing method, including:
以待编码数据块中处于预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in the data block to be encoded as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
将所述残差值和所述参考数据写入编码后的码流数据。The residual value and the reference data are written into the coded stream data.
第四方面,本发明实施例提供了一种数据处理方法,包括:In a fourth aspect, an embodiment of the present invention provides a data processing method, including:
对待解码数据块进行解析,获取待解码数据块中的参考数据和残差数据Analyze the data block to be decoded and obtain the reference data and residual data in the data block to be decoded
将所述参考数据和所述残差数据进行递减运算或累加运算,生成所述参考数据两侧的原始数据。Performing a decrement operation or an accumulation operation on the reference data and the residual data to generate original data on both sides of the reference data.
第五方面,本发明实施例提供了一种数据处理方法,应用于依次连接的配置器、存储器和处理器,包括:In a fifth aspect, an embodiment of the present invention provides a data processing method, which is applied to a configurator, a memory, and a processor connected in sequence, including:
通过所述配置器对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流,并将所述压缩码流写入所述存储器,以降低对所述存储器的写带宽;Performing compression encoding on the data block to be encoded formed by the preset data by the configurator to generate a compressed code stream, and writing the compressed code stream into the memory, so as to reduce the write bandwidth to the memory;
通过所述处理器读取所述存储器内的压缩码流,并对所述压缩码流进行解压缩处理,以降低对所述存储器的读带宽。The processor reads the compressed code stream in the memory and performs decompression processing on the compressed code stream to reduce the read bandwidth of the memory.
第六方面,本发明实施例提供了一种数据处理系统,包括:依次连接的配置器、存储器和处理器;In a sixth aspect, an embodiment of the present invention provides a data processing system, including: a configurator, a memory, and a processor connected in sequence;
所述配置器用于对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流,并将所述压缩码流写入所述存储器,以降低对所述存储器的写带宽;The configurator is used to compress and encode a data block to be encoded formed by preset data to generate a compressed code stream, and write the compressed code stream into the memory, so as to reduce the write bandwidth to the memory;
所述处理器用于读取所述存储器内的压缩码流,并对所述压缩码流进行解压缩处理,以降低对所述存储器的读带宽。The processor is configured to read the compressed code stream in the memory, and perform decompression processing on the compressed code stream, so as to reduce the read bandwidth of the memory.
第七方面,本发明实施例提供了一种可移动平台,所述可移动平台包括:In a seventh aspect, an embodiment of the present invention provides a movable platform, and the movable platform includes:
机体;Body
动力系统,设于所述机体,所述动力系统用于为所述可移动平台提供动力;以及,如第六方面所述的一种数据处理系统。A power system is provided in the body, and the power system is used to provide power to the movable platform; and, a data processing system as described in the sixth aspect.
第八方面,本发明实施例提供了一种编码器,包括:选择电路和编码电路;In an eighth aspect, an embodiment of the present invention provides an encoder, including: a selection circuit and an encoding circuit;
所述选择电路用于获取多个第一编码方式对于待编码数据块的编码开销,从所述多个第一编码方式中确定编码开销最小的目标编码方式;The selection circuit is configured to obtain the coding overhead of the data block to be coded by the multiple first coding modes, and determine the target coding mode with the smallest coding overhead from the multiple first coding modes;
所述编码电路通过所述目标编码方式对所述待编码数据块进行编码。The encoding circuit encodes the data block to be encoded by using the target encoding method.
第九方面,本发明实施例提供了一种编码器,所述编码器包括:残差计算电路和编码电路;In a ninth aspect, an embodiment of the present invention provides an encoder, the encoder includes: a residual calculation circuit and an encoding circuit;
所述残差计算电路,用于以待编码数据块中处于预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;The residual calculation circuit is configured to use the data at a preset position in the data block to be encoded as reference data, and respectively calculate the residual value of every two adjacent data located on both sides of the reference data;
所述编码电路,用于将所述残差值和所述参考数据按照残差编码方式对应的码流结构写入编码后的码流数据;其中,所述残差编码方式对应的码流结构包括:所述参考数据、所述残差值所占的位宽和所述残差值。The coding circuit is configured to write the residual value and the reference data into the code stream data according to the code stream structure corresponding to the residual coding mode; wherein, the code stream structure corresponding to the residual coding mode Including: the reference data, the bit width occupied by the residual value, and the residual value.
第十方面,本发明实施例提供了一种解码器,所述解码器包括:解析电路和解码电路;In a tenth aspect, an embodiment of the present invention provides a decoder, the decoder including: a parsing circuit and a decoding circuit;
所述解析电路用于对待解码数据进行解析,确定多个预设的第一编码方式中与所述待解码数据对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;The parsing circuit is configured to analyze the data to be decoded, determine a target encoding method corresponding to the data to be decoded among a plurality of preset first encoding methods, and determine a corresponding target decoding method according to the target encoding method;
所述解码电路用于通过所述目标解码方式对所述待解码数据进行解码,生成解码数据。The decoding circuit is used to decode the data to be decoded by the target decoding mode to generate decoded data.
第十一方面,本发明实施例提供了一种解码器,所述解码器包括:解析电路和解码电路;In an eleventh aspect, an embodiment of the present invention provides a decoder, which includes: a parsing circuit and a decoding circuit;
所述解析电路用于对待解码数据块进行解析,获取待解码数据块中的参考数据和残差数据The analysis circuit is used to analyze the data block to be decoded, and obtain the reference data and residual data in the data block to be decoded
所述解码电路用于将所述参考数据和所述残差数据进行递减运算或累 加运算,生成所述参考数据两侧的原始数据。The decoding circuit is used to perform a decrement operation or an accumulation operation on the reference data and the residual data to generate original data on both sides of the reference data.
本发明各实施例所提供的一种数据处理方法、系统、编码器及解码器,A data processing method, system, encoder and decoder provided by various embodiments of the present invention,
附图说明Description of the drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly describe the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative labor.
图1是本发明一个实施例中所提供的一种数据处理的方法的流程示意图;FIG. 1 is a schematic flowchart of a data processing method provided in an embodiment of the present invention;
图2是本发明一个实施例中所提供的一种游程编码方式对应的码流结构示意图;2 is a schematic diagram of a code stream structure corresponding to a run-length encoding method provided in an embodiment of the present invention;
图3是本发明一个实施例中所提供的一种原始编码方式对应的码流结构示意图;Fig. 3 is a schematic diagram of a code stream structure corresponding to an original encoding method provided in an embodiment of the present invention;
图4是本发明一个实施例中所提供的一种残差计算示意图;4 is a schematic diagram of residual calculation provided in an embodiment of the present invention;
图5是本发明一个实施例中所提供的一种残差编码方式对应的码流结构示意图;Fig. 5 is a schematic diagram of a code stream structure corresponding to a residual coding method provided in an embodiment of the present invention;
图6是本发明一个实施例中所提供的一种按照混合编码方式进行数据处理的方法的流程示意图;FIG. 6 is a schematic flowchart of a method for performing data processing according to a hybrid encoding mode provided in an embodiment of the present invention;
图7是本发明一个实施例中所提供的一种残差计算示意图;Fig. 7 is a schematic diagram of residual calculation provided in an embodiment of the present invention;
图8是本发明一个实施例中所提供的一种混合编码方式对应的码流结构示意图;FIG. 8 is a schematic diagram of a code stream structure corresponding to a hybrid encoding method provided in an embodiment of the present invention;
图9是本发明一个实施例中所提供的另一种按照混合编码方式进行数据处理的方法的流程示意图;FIG. 9 is a schematic flowchart of another method for performing data processing in a hybrid encoding manner provided in an embodiment of the present invention;
图10是本发明一个实施例中所提供的一种混合编码方式对应的码流结构示意图;FIG. 10 is a schematic diagram of a code stream structure corresponding to a hybrid encoding method provided in an embodiment of the present invention;
图11是本发明一个实施例中所提供的对待解码数据进行解码的方法流程示意图;Figure 11 is a schematic flow chart of a method for decoding data to be decoded provided in an embodiment of the present invention;
图12是本发明一个实施例中所提供的对待编码数据进行处理的方法流程示意图;FIG. 12 is a schematic flowchart of a method for processing data to be coded provided in an embodiment of the present invention;
图13是本发明一个实施例中所提供的对预设数据进行处理的方法流程示意图;FIG. 13 is a schematic flowchart of a method for processing preset data provided in an embodiment of the present invention;
图14是本发明一个实施例中所提供的对预设数据进行处理的系统的示意图;Figure 14 is a schematic diagram of a system for processing preset data provided in an embodiment of the present invention;
图15是本发明一个实施例中所提供的数据处理的系统的示意图;Figure 15 is a schematic diagram of a data processing system provided in an embodiment of the present invention;
图16是本发明一个实施例中所提供的一种可移动平台的结构示意图;Figure 16 is a schematic structural diagram of a movable platform provided in an embodiment of the present invention;
图17是本发明一个实施例中所提供的一种编码器的结构示意图;Figure 17 is a schematic structural diagram of an encoder provided in an embodiment of the present invention;
图18是本发明一个实施例中所提供的一种编码器的功能架构示意图;Figure 18 is a schematic diagram of the functional architecture of an encoder provided in an embodiment of the present invention;
图19是本发明一个实施例中所提供的一种解码器的结构示意图;FIG. 19 is a schematic structural diagram of a decoder provided in an embodiment of the present invention;
图20是本发明一个实施例中所提供的一种解码器的功能架构示意图。FIG. 20 is a schematic diagram of the functional architecture of a decoder provided in an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of this application.
现有技术中,对神经网络模型的中的庞大数据量限制了神经网络模型的应用;基于此,本发明实施例提供了一种数据的处理方法、系统、编码器及解码器。In the prior art, the huge amount of data in the neural network model limits the application of the neural network model; based on this, the embodiments of the present invention provide a data processing method, system, encoder and decoder.
图1是本发明一个实施例中所提供的一种数据处理的方法的流程示意图。参照图1所示,该方法包括如下步骤S1-S2:Fig. 1 is a schematic flowchart of a data processing method provided in an embodiment of the present invention. Referring to Fig. 1, the method includes the following steps S1-S2:
S1、获取多个第一编码方式对于待编码数据块的编码开销,从所述多个第一编码方式中确定编码开销最小的目标编码方式。S1. Obtain the coding overhead of the multiple first coding modes for the data block to be coded, and determine the target coding mode with the smallest coding overhead from the multiple first coding modes.
上述编码开销是指对待编码数据块进行编码后所生成的码流数据所占的位宽。The foregoing encoding overhead refers to the bit width occupied by the code stream data generated after encoding the data block to be encoded.
进而,本发明实施例中上述编码开销最小的目标编码方式是指预设的多个第一编码方式中的对待编码数据进行压缩编码后得到的压缩码流的数据量最小的编码方式。Furthermore, in the embodiment of the present invention, the aforementioned target encoding method with the smallest encoding overhead refers to an encoding method with the smallest data amount of the compressed code stream obtained after compression encoding of the data to be encoded among the preset multiple first encoding methods.
S2、通过所述目标编码方式对所述待编码数据块进行编码。S2. Encode the data block to be encoded by using the target encoding method.
本发明实施例中,通过设置多个第一编码方式,然后针对于待编码数据块从该多个第一编码方式中选择编码开销最小的编码方式进行编码,进而使压缩效果达到最佳。In the embodiment of the present invention, multiple first coding modes are set, and then the coding mode with the least coding overhead is selected from the multiple first coding modes for the data block to be coded for coding, thereby achieving the best compression effect.
本实施例中针对不同的待编码数据块所确定出的目标编码方式可能是不同的,进而通过为待编码数据块选择合适的、压缩效果最优的编码方式进行编码,使压缩后得到的压缩码流的数据量最小。In this embodiment, the target encoding methods determined for different data blocks to be encoded may be different, and then encoding is performed by selecting a suitable encoding method with the best compression effect for the data blocks to be encoded, so that the compression obtained after compression The data volume of the code stream is the smallest.
本发明一实施例中,上述的待编码数据块是由原始数块得到的,该原始数据块中包含有待压缩编码的数据。本实施例中,上述方法还包括如下步骤A10-A20:In an embodiment of the present invention, the aforementioned data block to be encoded is obtained from an original data block, and the original data block contains data to be compressed and encoded. In this embodiment, the above method further includes the following steps A10-A20:
步骤A10、确定原始数据块中是否存在冗余数据块,若是,则对所述冗余数据块按照第二编码方式进行编码。Step A10: Determine whether there is a redundant data block in the original data block, and if so, encode the redundant data block according to the second coding mode.
本实施例中首先确定原始数据块中是否存在冗余数据,可选的,通过以下方式确定原始数据快中是否存在冗余数据块:In this embodiment, it is first determined whether there is redundant data in the original data block. Optionally, it is determined whether there is a redundant data block in the original data block in the following manner:
查找原始数据块中的是否有连续出现且重复次数大于预设值的数据,若有,则确定存在冗余数据块,并将该连续的数据作为冗余数据块;若否,则确定不存在冗余数据块。Find out whether there is data in the original data block that appears continuously and the number of repetitions is greater than the preset value. If so, it is determined that there is a redundant data block, and the continuous data is regarded as a redundant data block; if not, it is determined that it does not exist Redundant data block.
上述的预设值可以是根据压缩编码的精度确定。示例性的,上述的预设值可以是设置为4,此时,以原始数据块为01222223416为例,该原始数据块中的重复且连续出现的数据为2,且连续出现的次数为5(大于4), 则该原始数据块中的冗余数据块为22222。The aforementioned preset value may be determined according to the accuracy of compression coding. Exemplarily, the foregoing preset value may be set to 4. At this time, taking the original data block as 01222223416 as an example, the repeated and consecutive data in the original data block is 2, and the number of consecutive occurrences is 5 ( Greater than 4), the redundant data block in the original data block is 22222.
步骤A20、将所述原始数据块中除掉所述冗余数据块的剩余数据块作为所述待编码数据块。Step A20: Use the remaining data block from the original data block except the redundant data block as the data block to be encoded.
本发明一实施例中在确定原始数据块中包含有冗余数据块以后,通过第二编码方式对该冗余数据块进行编码,并将原始数据块中除掉冗余数据块的剩余数据块作为上述的待编码数据块,然后针对于该待编码数据块按照上述步骤S1-S2进行数据处理。In an embodiment of the present invention, after it is determined that the original data block contains the redundant data block, the redundant data block is encoded by the second encoding method, and the remaining data block of the original data block is removed from the redundant data block As the above-mentioned data block to be encoded, data processing is performed according to the above-mentioned steps S1-S2 for the data block to be encoded.
本发明一实施例中,上述的第二编码方式包括:游程编码;进而本实施例中,按照游程编码的方式对冗余数据块进行编码。In an embodiment of the present invention, the above-mentioned second encoding method includes: run-length encoding; and in this embodiment, the redundant data block is encoded in a run-length encoding manner.
具体的,该按照游程编码的方式对冗余数据块进行编码,包括:Specifically, encoding the redundant data block in a run-length encoding manner includes:
将所述冗余数据块按照游程编码所对应的码流结构,写入编码后的码流数据;所述游程编码所对应的码流结构包括:编码方式的标志位、起始值和游程长度。The redundant data block is written into the coded stream data according to the code stream structure corresponding to the run-length encoding; the code stream structure corresponding to the run-length encoding includes: the flag bit of the encoding mode, the start value and the run length .
示例性的,在使用游程编码的方式对冗余数据块进行编码过程中,通过逐行扫描原始数据块中的每一行的数据,当在某一行中扫描到冗余数据块后,进一步得到该冗余数据块的起始值和游程长度,以冗余数据块为22222为例,该冗余数据块的起始值为2,游程长度为5,将该冗余数据块的起始值、游程长度写入游程编码对应的码流结构,该码流结构中还包含有编码方式的标志位,该编码方式的标志位表征该码流的数据所采用的编码方式为游程编码。在当前行扫描完成以后继续进行对下一行的扫描,可选的,为提高编码的准确度,设置不进行跨行扫描。Exemplarily, in the process of encoding the redundant data block using the run-length coding method, the data of each row in the original data block is scanned row by row, and the redundant data block is further obtained after scanning a certain row. The initial value and run length of the redundant data block, taking the redundant data block as 22222 as an example, the initial value of the redundant data block is 2 and the run length is 5, the initial value of the redundant data block, The run length is written into the code stream structure corresponding to the run length coding, and the code stream structure also contains a coding mode flag bit, which indicates that the coding mode adopted for the data of the code stream is run length coding. After the current line scan is completed, continue to scan the next line. Optionally, in order to improve the encoding accuracy, set not to perform cross-line scan.
例如,游程编码对应的码流结构如图2所示:For example, the code stream structure corresponding to run-length coding is shown in Figure 2:
其中,标志位00位表征该码流对应的编码方式为游程编码方式,base表示起始值,len表示游程长度。Among them, the flag bit 00 indicates that the coding mode corresponding to the code stream is the run-length coding mode, base represents the starting value, and len represents the run length.
本发明另一实施例中,在从原始数据块中除掉冗余数据块得到剩余数据块后,首先将该剩余数块按照指定大小划分得到多个数据块,该得到的多个数据块中每个数据块的大小相同,然后将划分得到的每一数据块均作 为待编码数据块,将每一待编码数据块分别按照上述的步骤S1-S2进行处理编码。In another embodiment of the present invention, after the redundant data blocks are removed from the original data blocks to obtain the remaining data blocks, the remaining blocks are first divided according to a specified size to obtain multiple data blocks, and the obtained multiple data blocks Each data block has the same size, and then each divided data block is regarded as a data block to be coded, and each data block to be coded is processed and coded according to the above steps S1-S2 respectively.
可选的,本发明实施例中在将该剩余数块进行按照指定大小划分得到多个数据块之前,如果该剩余数据块中所包含的数据的数据量不满足为上述指定大小的整数倍,则无法满足将剩余数据块平均划分得到多个指定大小的数据块,此时对该剩余数据块进行数据填充,使经过数据填充后的剩余数据块中包含的数据量为指定大小的整数倍,以使经过划分后得到的每个数据块的数据量为指定大小。Optionally, in this embodiment of the present invention, before dividing the remaining data blocks according to a specified size to obtain multiple data blocks, if the data amount of the data contained in the remaining data blocks does not satisfy an integer multiple of the foregoing specified size, It is not enough to divide the remaining data blocks into multiple data blocks of the specified size. At this time, the remaining data blocks are filled with data so that the amount of data contained in the remaining data blocks after data filling is an integer multiple of the specified size. The data volume of each data block obtained after division is the specified size.
例如,上述的指定大小为16个数据,当剩余数据块中所包含的数据总数不为16的整数倍时,即剩余数据块中的数据综述不为16M时,M为大于等于1的整数,则对该剩余数据块进行数据填充,使得填充后的剩余数据块的数据总数满足为16M。For example, the above-mentioned specified size is 16 data. When the total number of data contained in the remaining data block is not an integer multiple of 16, that is, when the data summary in the remaining data block is not 16M, M is an integer greater than or equal to 1. Then, the remaining data block is filled with data, so that the total data of the remaining data block after filling meets to be 16M.
本发明一实施例中,上述对剩余数据块进行填充的方式,包括:In an embodiment of the present invention, the foregoing method of filling the remaining data blocks includes:
复制N个剩余数据块中的末尾数据,利用复制得到的N个数据对剩余数据块进行填充,以使得该剩余数据块的数据量为上述指定大小的整数倍;其中,该N为大于等于1的整数。Copy the last data in the N remaining data blocks, and use the copied N data to fill the remaining data blocks so that the data volume of the remaining data blocks is an integer multiple of the above specified size; where N is greater than or equal to 1 The integer.
本实施例中,通过使用剩余数据块中的末尾数据对该剩余数据块进行数据填充;可选,也可以是通过使用一个预先约定的数据对该剩余数据块进行数据填充。In this embodiment, the remaining data block is filled with data by using the last data in the remaining data block; optionally, the remaining data block may be filled with data by using a predetermined data.
示例性的,将剩余数据块从排在首位的第一个数据开始,依次按照每16位数据划分为一个数据块,在划分得到一个或多个数据块以后,如果最后剩余的数据为:0122254,由于该剩余的数据的数据位数为7,则利用该剩余数据块的末尾数据进行数据填充,则填充后的数据为0122254444444444。在数据填充以后可以得到该剩余数据块所划分得到的所有数据块。然后按照上述的方法对每个数据块进行确定目标编码方式,应用该目标编码方式对每个数据块进行编码。Exemplarily, the remaining data blocks are divided into one data block according to each 16-bit data starting from the first data in the first place. After dividing one or more data blocks, if the last remaining data is: 0122254 Since the number of data bits of the remaining data is 7, the data at the end of the remaining data block is used for data filling, and the filled data is 0122254444444444. After data filling, all the data blocks divided by the remaining data block can be obtained. Then, the target encoding method is determined for each data block according to the above method, and the target encoding method is applied to encode each data block.
本发明实施例中,对剩余数据块进行数据填充,使得到的数据块具有 相同的大小,便于对剩余数据进行编码。In the embodiment of the present invention, the remaining data blocks are filled with data so that the obtained data blocks have the same size, which is convenient for encoding the remaining data.
本发明一实施例中,上述的多个第一编码方式,包括:原始编码方式、残差编码方式以及混合编码方式;其中,混合编码方式为对待编码数据块进行划分分成若干数据子块后,对每一数据字块进行残差编码或原始编码。In an embodiment of the present invention, the above-mentioned multiple first encoding methods include: original encoding, residual encoding, and hybrid encoding; wherein, the hybrid encoding is after the data block to be encoded is divided into several data sub-blocks, Perform residual coding or original coding on each data block.
本发明一实施例中,当上述确定出的目标编发方式为原始编码方式时,则使用该原始编码方式对待编码数据块进行编码,具体包括如下步骤B10:In an embodiment of the present invention, when the determined target editing mode is the original coding mode, the original coding mode is used to encode the to-be-coded data block, which specifically includes the following step B10:
步骤B10、将所述待编码数据块中的原始数据按照所述原始编码方式对应的码流结构,写入编码后的码流数据。Step B10: Write the original data in the data block to be coded into the code stream data according to the code stream structure corresponding to the original coding mode.
其中,上述原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。Wherein, the code stream structure corresponding to the above-mentioned original coding mode includes: the flag bit of the coding mode and original data.
本发明实施例中,原始编码方式包括:将待编码数据块中原始数据按照该原始编码方式对应的码流结构直接写入至编码后的码流数据。In the embodiment of the present invention, the original encoding method includes: directly writing the original data in the data block to be encoded into the encoded bitstream data according to the code stream structure corresponding to the original encoding method.
示例性的,该原始编码方式对应的码流结构如图3所示,Exemplarily, the code stream structure corresponding to the original encoding method is shown in Figure 3.
本实施例中,以待编码数据块包含16个数据为例,上述标志位01用于表征该码流结构对应的编码方式为原始编码方式(RAW16),上述p0、p1、、、p15为待编码数据块中的原始数据。In this embodiment, taking the data block to be coded containing 16 data as an example, the above flag bit 01 is used to indicate that the coding mode corresponding to the code stream structure is the original coding mode (RAW16), and the above p0, p1,, and p15 are waiting Encode the original data in the data block.
本发明另一实施例中,当上述的目标编码方式为残差编码方式时,则通过该目标编码方式对待编码数据块进行编码,包括如下步骤S20:In another embodiment of the present invention, when the above-mentioned target coding mode is the residual coding mode, encoding the data block to be coded by the target coding mode includes the following step S20:
S20、以所述待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据。S20. Using the data at a preset position in the data block to be encoded as reference data, respectively calculate the residual value of each two adjacent data located on both sides of the reference data; compare the residual value with the reference The data is written into the coded stream data according to the code stream structure corresponding to the residual coding method.
本实施例中,通过将在待编码数据块中处于预设位置的数据作为参考数据,分别计算该参考数据两侧的数据的残差值,该从参考数据开始,同时向参考数据两侧双向进行计算的方式,相对于现有技术可以提高计算的效率。In this embodiment, the data at a preset position in the data block to be encoded is used as the reference data, and the residual values of the data on both sides of the reference data are respectively calculated. This starts from the reference data and moves to both sides of the reference data. Compared with the prior art, the calculation method can improve the efficiency of calculation.
本发明可选的实施例中,也可以是将待编码数据块进一步划分成多个 数据子块,通过在每个数据子块中设置一个或多个参考数据,并计算每个参考数据两侧的相邻两个数据的残差值,如此可以进一步提高计算的效率,进而提高压缩编码效率。In an optional embodiment of the present invention, the data block to be encoded may also be further divided into multiple data sub-blocks, by setting one or more reference data in each data sub-block, and calculating the two sides of each reference data The residual value of two adjacent data, which can further improve the efficiency of calculation, and further improve the efficiency of compression coding.
计算残差的过程如图4所示,以待编码数据块中包含有16个数据为例,该16个数据分别为:p0、p1、p2、p3、p4、、、p14、p15。以位于该待编码数据块的中心位置的数据p8作为参考数据,使用以下数组记录除p8以外像素的残差值:The process of calculating the residual is shown in Fig. 4, taking 16 pieces of data contained in the data block to be coded as an example, the 16 pieces of data are respectively: p0, p1, p2, p3, p4,, p14, p15. Using the data p8 at the center of the data block to be encoded as the reference data, use the following array to record the residual values of pixels other than p8:
左侧:diff[0]=p8-p7,diff[1]=p7-p6,…,diff[7]=p1-p0;Left side: diff[0]=p8-p7, diff[1]=p7-p6,..., diff[7]=p1-p0;
右侧:diff[8]=p8-p9,diff[9]=p9-p10,…,diff[14]=p14-p15;Right side: diff[8]=p8-p9, diff[9]=p9-p10,..., diff[14]=p14-p15;
本实施例中,以参考数据p8开始,分别向两侧计算相邻两个数据的残差值,相对于处于从初始位置的数据开始计算残差值,可以提高计算的效率。In this embodiment, starting with the reference data p8, the residual values of two adjacent data are calculated on both sides respectively. Compared with the data in the initial position, the residual values are calculated, which can improve the calculation efficiency.
在另一实施例中,以可以使用以下数组记录除p8以外像素的残差值:In another embodiment, the following array can be used to record the residual values of pixels other than p8:
左侧:diff[0]=p7-p8,diff[1]=p6-p7,…,diff[7]=p0-p1;Left side: diff[0]=p7-p8, diff[1]=p6-p7,..., diff[7]=p0-p1;
右侧:diff[8]=p9-p8,diff[9]=p10-p9,…,diff[14]=p15-p14。Right side: diff[8]=p9-p8, diff[9]=p10-p9,..., diff[14]=p15-p14.
需要说明的是,计算的方向可以根据需要进行调整,并不限于以上两种方式。It should be noted that the calculation direction can be adjusted as needed, and is not limited to the above two methods.
上述在计算得到残差以后,将残差值和对应的参考数据按照残差编码方式对应的码流结构,写入码流数据得到对应的编码后的码流数据;该残差编码方式对应的码流结构包括:编码方式的标志位、参考数据、残差值所占的位宽和残差值。After the residual is calculated, the residual value and the corresponding reference data are written into the code stream data according to the code stream structure corresponding to the residual coding method to obtain the corresponding code stream data; the residual coding method corresponds to The code stream structure includes: the flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
示例性的,残差编码方式对应的码流结构如图5所示,本实施例中,上述以待编码数据段包含16个数据为例,标志位10用于表征该码流结构采用的编码方式为残差编码方式(DPCM16),p8为参考数据,Rb为残差值所占的位宽,r0-r7为残差值,r10-r15为残差值。Exemplarily, the code stream structure corresponding to the residual coding method is shown in FIG. 5. In this embodiment, the above-mentioned data segment to be coded contains 16 pieces of data as an example, and the flag bit 10 is used to characterize the code used in the code stream structure. The method is the residual coding method (DPCM16), p8 is the reference data, Rb is the bit width occupied by the residual value, r0-r7 is the residual value, and r10-r15 is the residual value.
本发明一实施例中,参照图6所示,上述的目标编码方式为混合编码时,通过该混合编码方式对待编码数据块进行编码,具体包括如下步骤:In an embodiment of the present invention, referring to FIG. 6, when the above-mentioned target encoding method is hybrid encoding, encoding the data block to be encoded by the hybrid encoding method specifically includes the following steps:
S21、将所述待编码数据块划分得到至少两个数据子块。S21. Divide the to-be-coded data block to obtain at least two data sub-blocks.
本实施例中,将待编码数据块进行划分的方式可以是平均划分得到多个具有相同大小的数据子块,也可以是按照设定的大小进行划分成具有不同大小的数据子块。In this embodiment, the method for dividing the data block to be coded may be to obtain a plurality of data sub-blocks with the same size evenly, or it may be divided into data sub-blocks with different sizes according to a set size.
S22、以任一所述数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值。S22: Using data at a preset position in any of the data sub-blocks as reference data, respectively calculate residual values of every two adjacent data located on both sides of the reference data.
本实施例中,通过将在待编码数据块中处于预设位置的数据作为参考数据,分别计算该参考数据两侧的相邻两个数据的残差值,进而实现从参考数据开始,向参考数据两侧分别进行计算、编码,该双向计算编码的方式相对于现有技术提高了编码的效率。In this embodiment, by using the data in the preset position in the data block to be encoded as the reference data, the residual values of the two adjacent data on both sides of the reference data are respectively calculated, and then the reference data is started from the reference data and the reference data Calculation and coding are performed on both sides of the data respectively, and the two-way calculation and coding method improves coding efficiency compared with the prior art.
S23、分别将每个所述数据子块计算得到的残差值和所述参考数据按照所述混合编码方式对应的码流结构写入编码后的码流数据。S23: Write the residual value calculated for each of the data sub-blocks and the reference data into the coded stream data according to the code stream structure corresponding to the hybrid coding mode.
本实施例中,上述的混合编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。In this embodiment, the code stream structure corresponding to the foregoing hybrid encoding method includes: a flag bit of the encoding method, the reference data, the bit width occupied by the residual value, and the residual value.
进而,本实施例中所提供的混合编码方式,通过将待编码数据块进行划分得到多个数据子块,对每个数据子块均按照残差编码的方式进行编码。Furthermore, in the hybrid coding method provided in this embodiment, multiple data sub-blocks are obtained by dividing the data block to be coded, and each data sub-block is coded in a residual coding manner.
示例性的,以将待编码数据块划分得到两个数据子块为例,对两个数据子均进行残差编码的计算方式如图7所示。Exemplarily, taking the data block to be coded into two data sub-blocks as an example, the calculation method of performing residual coding on both data sub-blocks is shown in FIG. 7.
参照图7所示,本实施例中,待编码数据块包含的数据为:p0、p1、p2、、、p14、p15,将该待编码数据块划分得到两个数据子块,分别为数据块:p0p1、、p7和数据块:p8p9、、、p15。对两个数据子块,分别选择一个处于预设位置的数据作为参数数据(图中分别为p4、p12),然后分别计算该参考数据两侧的相邻两个数据的残差值。并按照该混合编码的编码结构写入码流数据。Referring to FIG. 7, in this embodiment, the data contained in the data block to be encoded is: p0, p1, p2,, p14, p15, and the data block to be encoded is divided into two data sub-blocks, which are respectively data blocks : P0p1, p7 and data block: p8p9,,, p15. For two data sub-blocks, select one data at a preset position as parameter data (respectively p4, p12 in the figure), and then calculate the residual values of two adjacent data on both sides of the reference data. And write the code stream data according to the coding structure of the hybrid coding.
示例性的,该混合编码方式对应的编码结构如图8所示,其中,在混合编码方式下,上述标志位10用于表征该码流结构采用的编码方式为残差编码方式(DPCM8_1&DPCM8_2),p4、p12分别为参考数据,Rb为残差 值所占的位宽,r0-r7为残差值,r8-r14为残差值。Exemplarily, the encoding structure corresponding to the hybrid encoding mode is shown in FIG. 8, where, in the hybrid encoding mode, the above-mentioned flag bit 10 is used to indicate that the encoding method adopted by the code stream structure is the residual encoding method (DPCM8_1&DPCM8_2), p4 and p12 are reference data respectively, Rb is the bit width occupied by the residual value, r0-r7 is the residual value, and r8-r14 is the residual value.
本发明另一实施例中,上述的目标编码方式包括:混合编码方式。本实施例中,参照图9所示,通过该混合编码方式对待编码数据块进行编码,具体包括如下步骤S21’-S23’:In another embodiment of the present invention, the aforementioned target encoding method includes: a hybrid encoding method. In this embodiment, referring to FIG. 9, encoding the data block to be encoded by the hybrid encoding method specifically includes the following steps S21'-S23':
S21’、将所述待编码数据块划分得到至少两个数据子块;其中,所述至少两个数据字块包括第一数据子块和第二数据子块。S21', dividing the data block to be encoded to obtain at least two data sub-blocks; wherein the at least two data word blocks include a first data sub-block and a second data sub-block.
本实施例中,将待编码数据块进行划分的方式可以是平均划分得到多个具有相同大小的数据子块,也可以是划分成具有不同大小的数据子块。In this embodiment, the method for dividing the data block to be coded may be to obtain a plurality of data sub-blocks with the same size evenly, or it may be divided into data sub-blocks with different sizes.
S22’、以所述第一数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据。S22', using the data at a preset position in the first data sub-block as reference data, respectively calculating the residual value of each two adjacent data located on both sides of the reference data, and combining the residual value with the The reference data is written into the coded stream data according to the code stream structure corresponding to the hybrid coding mode.
本实施例中,以划分得到的数据子块包括:第一数据子块和第二数据子块为例,对第一数据子块按照上述残差编码的方式进行编码,然后将得到的残差值和参考数据按照该混合编码方式对应的码流结构写入编码后的码流数据。In this embodiment, taking the divided data sub-blocks as an example: the first data sub-block and the second data sub-block, the first data sub-block is coded according to the above residual coding method, and then the obtained residual The value and reference data are written into the coded code stream data according to the code stream structure corresponding to the hybrid coding mode.
S23’、将所述第二数据子块中的原始数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据。S23'. Write the original data in the second data sub-block into the coded code stream data according to the code stream structure corresponding to the hybrid coding mode.
本实施例中,将第二数据子块中的原始数据按照原始编码的方式,直接按照该混合编码方式对应的码流结构写入编码后的码流数据。In this embodiment, the original data in the second data sub-block is written into the coded stream data directly according to the code stream structure corresponding to the mixed coding mode according to the original coding mode.
进而,本发明实施例中,在采用混合编码方式时,将待编码数据块划分得到多个数据子块以后,将第一数据子块按照残差编码的方式进行编码,将第二数据子块按照原始编码的方式进行编码;该第一数据子块与第二数据子块可以是将所有数据子块按照数量平均划分得到的,第一数据子块的数量与第二数据子块的数量相同;当然也可以是第一数据子块的数量与第二数据子块的数量不同。Furthermore, in the embodiment of the present invention, when the hybrid coding mode is adopted, after the data block to be coded is divided to obtain multiple data sub-blocks, the first data sub-block is coded according to the residual coding mode, and the second data sub-block is Encode according to the original encoding method; the first data sub-block and the second data sub-block may be obtained by dividing all the data sub-blocks equally according to the number, and the number of the first data sub-block is the same as the number of the second data sub-block ; Of course, the number of first data sub-blocks may be different from the number of second data sub-blocks.
本实施例中,上述混合编码方式所对应的码流结构包括:编码方式的 标志位、所述第二数据块的原始数据、参考数据、残差值所占的位宽和残差值。In this embodiment, the code stream structure corresponding to the above-mentioned hybrid encoding method includes: the flag bit of the encoding method, the original data of the second data block, the reference data, the bit width occupied by the residual value, and the residual value.
示例性的,以待编码数据块均包含16位数据,然后将该待编码数据块划分得到两个具有8位数据的数据块为例进行说明,本发明一实施例中给出了混合编码方式的编码结构,如图10所示。Exemplarily, taking the data block to be encoded each containing 16-bit data, and then dividing the data block to be encoded to obtain two data blocks with 8-bit data as an example for description, an embodiment of the present invention provides a hybrid encoding method The coding structure is shown in Figure 10.
参照图10所示,本实施例中,上述的标志位11用于表征该码流结构对应的编码方式为混合编码;混合编码的码流结构除了包括表征“混合编码”的编码模式,还包括表征每一子数据块对应的编码模式。优选地,可采用1比特来标记对应的子数据块的码流是原始编码还是残差编码,例如采用0来表征采用原始编码,采用1来表征残差编码。另外,也可以采用2比特及其以上共同标记组合编码的组合方式,例如,采用00表征原始编码和残差编码的组合方式,01表征残差编码和原始编码的组合方式,10表征残差编码和残差编码的组合方式。10, in this embodiment, the above-mentioned flag bit 11 is used to characterize that the coding mode corresponding to the bitstream structure is hybrid coding; the bitstream structure of mixed coding includes not only the coding mode representing "hybrid coding", but also Characterize the coding mode corresponding to each sub-data block. Preferably, 1 bit can be used to mark whether the code stream of the corresponding sub-data block is original coding or residual coding, for example, 0 is used to represent the original coding, and 1 is used to represent the residual coding. In addition, it is also possible to use a combination of 2 bits or more of the common mark combination coding, for example, using 00 to represent the combination of original coding and residual coding, 01 to represent the combination of residual coding and original coding, and 10 to represent residual coding And the combination of residual coding.
在该混合编码方式下的码流结构包括了:(1)对数据子块进行原始编码和残差编码的码流结构(RAW8_1&DPCM8_2),该码流结构的编码方式标志位为00,其中p0-p8为原始数据,p12为参考数据,r8-r15为残差值,R’b为残差值所占的位宽;(2)对数据子块进行残差编码和原始编码对应的码流结构(DPCM8_1&RAW8),该编码方式的编码方式标志位为01,其中,p4为参考数据,p8-p15为原始数据,R’b为残差值所占的位宽,r8-r15为残差值;(3)对数据子块分块进行残差编码(DPCM8_1&DPCM8_2),该编码方式的编码方式标志位为10;其中,p4、p12分别为参考数据,R’b为残差值所占的位宽,r0-r7为残差值,r8-r14为残差值。The code stream structure in this hybrid coding mode includes: (1) The code stream structure (RAW8_1&DPCM8_2) for the original coding and residual coding of the data sub-blocks. The coding mode flag bit of the code stream structure is 00, where p0- p8 is the original data, p12 is the reference data, r8-r15 is the residual value, and R'b is the bit width occupied by the residual value; (2) Perform residual coding on the data sub-block and the code stream structure corresponding to the original coding (DPCM8_1&RAW8), the coding mode flag bit of this coding mode is 01, where p4 is the reference data, p8-p15 is the original data, R'b is the bit width occupied by the residual value, and r8-r15 is the residual value; (3) Perform residual coding on data sub-blocks (DPCM8_1&DPCM8_2), the coding mode flag of this coding mode is 10; among them, p4 and p12 are reference data respectively, and R'b is the bit width occupied by the residual value , R0-r7 are residual values, and r8-r14 are residual values.
本发明一实施例中,以待编码数据块中包含有16位数据为例,上述每种编码方式对于同一待编码数据块计算的编码开销可以参照如下:In an embodiment of the present invention, taking 16-bit data contained in a data block to be encoded as an example, the encoding overhead calculated for the same data block to be encoded by each of the foregoing encoding methods can be referred to as follows:
对待编码数据块进行原始编码的编码开销为:16*8bit;其中,16为数据个数,每个数据所占的空间为8bit。The encoding overhead for the original encoding of the data block to be encoded is: 16*8bit; where 16 is the number of data, and the space occupied by each data is 8bit.
对待编码数据块进行残差编码的编码开销为:8bit+bitlen_16*15+3bit;其中,8bit为参考数据所占的位宽,bitlen_16为一个残差值所占的位宽,3bit为bitlen 16所占的位宽。The coding overhead for residual coding of the data block to be coded is: 8bit+bitlen_16*15+3bit; among them, 8bit is the bit width occupied by the reference data, bitlen_16 is the bit width occupied by a residual value, and 3bit is the bitlen 16 Occupied bit width.
对待编码数据块划分成两个数据块进行残差编码的编码开销为:1bit+8bit+bitlen8_1*7+3bit+1bit+8bit+bitlen8_2*7+3bit,其中,计算单位为8个数据,1bit用于标记码流是原始编码或者残差编码,8bit为参考数据所占的位宽,bitlen8_1与bitlen8_2为一个残差值所占的位宽,3bit为bitlen8_1或bitlen8_2所占的位宽。The coding overhead for dividing the data block to be coded into two data blocks for residual coding is: 1bit+8bit+bitlen8_1*7+3bit+1bit+8bit+bitlen8_2*7+3bit, where the calculation unit is 8 data, and 1bit is used When the mark code stream is original coding or residual coding, 8bit is the bit width occupied by the reference data, bitlen8_1 and bitlen8_2 are the bit width occupied by a residual value, and 3bit is the bit width occupied by bitlen8_1 or bitlen8_2.
对待编码数据块划分成两个数据块进行原始编码和残差编码的编码开销为:1bit+8bit*8+1bit+8bit+bitlen8_2*7+3bit;其中,前8个数据为原始数据,每个原始数据所占的空间为8bit,1bit用于标记码流是原始编码或者残差编码,第二次出现的8bit为参考数据所占的位宽,bitlen8_2为一个残差值所占的位宽,3bit为bitlen8_2所占的位宽。The encoding overhead of dividing the data block to be encoded into two data blocks for original encoding and residual encoding is: 1bit+8bit*8+1bit+8bit+bitlen8_2*7+3bit; among them, the first 8 data are original data, each The space occupied by the original data is 8bit, 1bit is used to mark whether the code stream is original encoding or residual encoding, the second 8bit is the bit width occupied by the reference data, and bitlen8_2 is the bit width occupied by a residual value. 3bit is the bit width occupied by bitlen8_2.
对待编码数据块划分成两个数据块进行残差编码和原始编码的编码开销为:1bit+8bit+bitlen8_1*7+3bit+1bit+8*8bit;该计算公式的释义可以参见上述各编码开销的计算方式。The coding overhead of dividing the data block to be coded into two data blocks for residual coding and original coding is: 1bit+8bit+bitlen8_1*7+3bit+1bit+8*8bit; for the definition of the calculation formula, please refer to the above coding overhead Calculation.
需要说明的是,本实施例中,均是以待编码数据块均包含16位数据为例进行说明的;但实际中,待编码数据块也可以是包含有比如32位、64位等数据;本发明对此不做限定。It should be noted that, in this embodiment, all the data blocks to be encoded contain 16-bit data as an example; but in practice, the data blocks to be encoded may also contain data such as 32 bits, 64 bits, etc.; The present invention does not limit this.
本发明上述实施例中,第一编码方式和第二编码方式均为无损编码,能够保证待编码数据经过压缩和解压缩后的准确率。In the foregoing embodiment of the present invention, both the first encoding method and the second encoding method are lossless encoding, which can ensure the accuracy of the data to be encoded after compression and decompression.
本发明上述实施例中所提供的数据处理方法,可以是应用于对神经网络的权重数据进行压缩,如此可以大幅度减少带宽开销。The data processing method provided in the foregoing embodiment of the present invention can be applied to compress the weight data of a neural network, which can greatly reduce bandwidth overhead.
现有技术中使用权重剪枝和共享对权重数据以减少参数规模的方式,会降低网络的收敛速度。而且剪枝需要手动设置层的敏感度,即需要精调超参数,在某些应用中会显得很冗长繁重。In the prior art, the use of weight pruning and sharing of pair weight data to reduce the parameter scale will reduce the convergence speed of the network. In addition, pruning requires manual setting of layer sensitivity, that is, fine-tuning of hyperparameters, which can be tedious and burdensome in some applications.
现有技术中也有采用对权重参数进行有损压缩的方法,如K均值标量 量化、定点表示法、二元网络,这些方法的缺陷是可能带来准确率的损失。无损算法中也有使用文本压缩的方法,但是文本压缩根据信源的分布、概率进行的,特别是通过构建字典,来减少信息冗余。这套方法直接使用在模型上,效果往往不好,一个最重要的原因就是参数分布中两个相同的参数的概率较低。另外,上述方法的吞吐率降低,限制了计算核的性能。In the prior art, there are also methods for lossy compression of weight parameters, such as K-means scalar quantization, fixed-point representation, and binary networks. The disadvantage of these methods is that they may cause loss of accuracy. Lossless algorithms also use text compression methods, but text compression is based on the distribution and probability of the source, especially by building a dictionary to reduce information redundancy. This method is directly used in the model, and the effect is often not good. One of the most important reasons is that the probability of two identical parameters in the parameter distribution is low. In addition, the throughput rate of the above method is reduced, which limits the performance of the computing core.
因此,本发明实施例不会降低网络的收敛速度,也无需精调超参数,效率高;另外,本发明实施例不会造成权重数据的准确率的损失,保证权重参数不会引入额外的误差且不需要重新训练网络,同时较大程度上能够降低系统带宽。其也不存在通过本发明上述实施例中所提供的方法对权重数据进行压缩后,不会降低网络的收敛速度,效率高。并且不会造成权重数据的准确率的损失。Therefore, the embodiment of the present invention does not reduce the convergence speed of the network, nor does it need to fine-tune hyperparameters, and has high efficiency; in addition, the embodiment of the present invention does not cause a loss of the accuracy of the weight data, and ensures that the weight parameters will not introduce additional errors. And there is no need to retrain the network, and the system bandwidth can be reduced to a large extent. It also does not exist that after the weight data is compressed by the method provided in the foregoing embodiment of the present invention, the convergence speed of the network will not be reduced, and the efficiency is high. And it will not cause the loss of the accuracy of the weight data.
针对于经过上述实施例所述的数据处理方式处理后得到的编码数据,本发明实施例还提供了一种数据处理方法,以对该编码数据数据(作为待解码数据)进行解码。Regarding the encoded data processed by the data processing method described in the foregoing embodiment, an embodiment of the present invention also provides a data processing method to decode the encoded data data (as data to be decoded).
参照图11所示,发明实施例中提供了一种数据处理方法,包括如下步骤S41-S42:Referring to FIG. 11, an embodiment of the invention provides a data processing method, which includes the following steps S41-S42:
S41、对待解码数据进行解析,确定多个预设的第一编码方式中与所述待解码数据对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式。S41. Analyze the data to be decoded, determine a target encoding method corresponding to the data to be decoded among a plurality of preset first encoding methods, and determine a corresponding target decoding method according to the target encoding method.
上述待解码数据包括编码方式标志位;上述对待解码数据进行解析,可以得到解码数据中所包含的标志位的数值,然后根据预设的所述标志位的数值和第一编码方式的映射关系,确定出与所述待解码数据对应的目标编码方式,根据该目标编码方式可以确定对应的目标解码方式;示例性的,该目标解码方式为目标编码方式的逆运算。The above-mentioned data to be decoded includes the coding mode flag bit; the above-mentioned analysis of the data to be decoded can obtain the value of the flag bit contained in the decoded data, and then according to the preset mapping relationship between the value of the flag bit and the first coding mode, The target encoding method corresponding to the data to be decoded is determined, and the corresponding target decoding method can be determined according to the target encoding method; for example, the target decoding method is the inverse operation of the target encoding method.
例如,再次以图2所示的实施例进行说明,首先获得该码流结构中的标志位00,根据该标志位00确定对应的编码方式为游程编码。然后获得对应的目标解码方式为游程解码。For example, once again the embodiment shown in FIG. 2 is used for description. First, the flag bit 00 in the code stream structure is obtained, and the corresponding encoding method is determined to be run-length coding according to the flag bit 00. Then obtain the corresponding target decoding mode as run-length decoding.
S42、通过所述目标解码方式对所述待解码数据进行解码,生成解码数据。S42. Decode the data to be decoded by using the target decoding mode to generate decoded data.
本发明实施例中,在根据待解码数据的编码方式以后,可以确定出对应的目标解码方式,该目标解码方式可以是编码方式的逆运算。In the embodiment of the present invention, after the encoding method of the data to be decoded, the corresponding target decoding method can be determined, and the target decoding method may be the inverse operation of the encoding method.
本发明一实施例中,上述第一编码方式包括游程编码、原始数据编码、残差编码和混合编码中的一种或多种;In an embodiment of the present invention, the above-mentioned first encoding method includes one or more of run-length encoding, original data encoding, residual encoding, and hybrid encoding;
其中,该混合编码为对待编码数据块进行划分生成多个数据子块,对每一所述数据字块进行残差编码或原始数据编码。Wherein, the hybrid coding is to divide a data block to be coded to generate multiple data sub-blocks, and perform residual coding or original data coding on each of the data blocks.
上述残差编码为以待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据。The above-mentioned residual coding is to use the data at the preset position in the data block to be coded as reference data, respectively calculate the residual value of each two adjacent data located on both sides of the reference data, and combine the residual value and the The reference data is written into the coded code stream data according to the code stream structure corresponding to the residual coding mode.
可选的,对应于上述的编码方式,上述目标解码方式包括:游程解码、原始数据拷贝、残差解码和混合解码中的一种或多种;Optionally, corresponding to the foregoing encoding mode, the foregoing target decoding mode includes one or more of run-length decoding, original data copy, residual decoding, and hybrid decoding;
其中,上述混合解码为对所述待解码数据块进行划分生成多个数据子块,该划分的方式可以是按标志位进行划分,对每一所述数据字块进行残差解码或原始数据拷贝。Wherein, the above-mentioned hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks. The division method may be divided according to flag bits, and residual decoding or original data copy is performed on each data block. .
下面对每一种解码方式分别进行介绍:The following describes each decoding method:
上述残差解码为从所述待解码数据的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据、残差值所占的位长和残差值执行残差计算的逆运算,生成解码数据。The above-mentioned residual decoding is to read the corresponding reference data, the bit length occupied by the residual value and the residual value from the bit stream structure of the data to be decoded, according to the bit length occupied by the reference data and the residual value Perform the inverse operation of the residual calculation with the residual value to generate decoded data.
当目标解码方式为残差解码时,使用残差解码的方式对所述待解码数据进行解码,包括:从所述待解码数据的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据和残差值执行残差计算的逆运算,得到原数据。When the target decoding method is residual decoding, using the residual decoding method to decode the data to be decoded includes: reading the corresponding reference data from the code stream structure of the data to be decoded and the residual value The bit length and residual value of, perform the inverse operation of residual calculation according to the reference data and residual value to obtain the original data.
当目标解码方式为游程解码时,使用游程解码对所述待解码数据进行解码,包括:When the target decoding mode is run-length decoding, using run-length decoding to decode the data to be decoded includes:
从所述待解码数据的码流结构中读取起始值和游程长度,根据所述起始值和游程长度将所述待解码数据进行解码还原,得到解码数据。The start value and the run length are read from the code stream structure of the data to be decoded, and the data to be decoded is decoded and restored according to the start value and the run length to obtain decoded data.
当所述目标解码方式为原数据拷贝时,使用原数据拷贝方式对待解码数据进行解码,包括:When the target decoding mode is the original data copy, using the original data copy mode to decode the data to be decoded includes:
从所述待解码数据的码流结构中读取对应的编码后的数据,将所述编码后的数据进行拷贝,得到解码数据。Reading the corresponding encoded data from the code stream structure of the data to be decoded, and copying the encoded data to obtain decoded data.
本发明上述实施例中,若通过所述目标解码方式对所述待解码数据进行解码得到的数据的数据量大于预设数据量时,将超出所述预设数据量的部分数据丢弃,生成所述解码数据。In the foregoing embodiment of the present invention, if the data volume of the data obtained by decoding the data to be decoded by the target decoding method is greater than the preset data volume, the part of the data exceeding the preset data volume is discarded to generate The decoded data.
参照图12所示,本发明又一实施例中还提供了一种数据处理的方法,包括如下步骤S51-S52:Referring to FIG. 12, another embodiment of the present invention also provides a data processing method, including the following steps S51-S52:
S51、以待编码数据块中处于预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值。S51: Using data at a preset position in the data block to be encoded as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data.
再次参照图4所示,仍以待编码数据块中包含有16个数据为例,该16个数据分别为:p0、p1、p2、p3、p4、、、p14、p15。以位于该待编码数据块的中心位置的数据p8作为参考数据,以参考数据p8开始,分别向两侧计算相邻两个数据的残差值,相对于处于从初始位置的数据开始计算残差值,可以提高计算的效率。而且,在解码的时候可以从中间数据与残差数据向两端累加或者递减,提高了解码的并行度。Referring again to FIG. 4, still taking as an example that the data block to be encoded contains 16 data, the 16 data are: p0, p1, p2, p3, p4, ,,, p14, p15. Take the data p8 at the center of the data block to be encoded as the reference data, start with the reference data p8, calculate the residual values of the two adjacent data to both sides, and calculate the residuals relative to the data at the initial position Value, can improve the efficiency of calculation. Moreover, the intermediate data and residual data can be accumulated or decremented to both ends during decoding, which improves the parallelism of decoding.
可选的,上述的待编码数据块可以是通过以下两种方式得到:Optionally, the foregoing data block to be encoded may be obtained in the following two ways:
方式一、将原始数据块按照指定大小进行划分得到多个数据子块,将每一所述数据子块作为所述待编码数据块。Manner 1: Divide the original data block according to a specified size to obtain multiple data sub-blocks, and use each of the data sub-blocks as the data block to be encoded.
方式二、将原始数据块按照指定大小进行划分得到多个数据子块,将所述多个数据块中的第一数据块作为所述待编码数据块。Manner 2: Divide the original data block according to the specified size to obtain multiple data sub-blocks, and use the first data block of the multiple data blocks as the data block to be encoded.
进而在方式二实施例中,是将多个数据子块中的部分数据子块(即第一数据块)作为上述的待编码数据块,以该待编码数据块中处于预设位置的数据作为参考数据,分别计算位于参考数据两侧的每相邻两个数据的残 差值。Furthermore, in the second embodiment, part of the data sub-blocks (that is, the first data block) of the multiple data sub-blocks is used as the above-mentioned data block to be coded, and the data in the preset position in the data block to be coded is used as For reference data, calculate the residual values of every two adjacent data located on both sides of the reference data.
S52、将所述残差值和所述参考数据写入编码后的码流数据。S52. Write the residual value and the reference data into the coded stream data.
当按照上述方式二,将第一数据块作为待编码数据块的实施例中,将得到的多个数据子块中除第一数据块外的其他数据块,按照原始编码方式对应的码流结构,写入编码后的码流数据;该原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。When according to the above method two, the first data block is used as the data block to be encoded, the data blocks other than the first data block among the multiple data sub-blocks obtained are based on the code stream structure corresponding to the original encoding method , Write the coded stream data; the code stream structure corresponding to the original coding mode includes: the flag bit of the coding mode and the original data.
可选的,上述将残差值和参考数据按照残差编码方式对应的码流结构写入编码后的码流数据中,该残差编码方式对应的码流结构包括:参考数据、残差值和残差值所占的位宽。Optionally, the above-mentioned residual value and reference data are written into the coded stream data according to the code stream structure corresponding to the residual coding mode, and the code stream structure corresponding to the residual coding mode includes: reference data, residual value And the bit width occupied by the residual value.
本实施例中,通过将位于待编码数据块中预设位置的数据作为参考数据,分别计算该参考数据两侧的相邻两个数据的残差值,该从参考数据开始,同时向参考数据两侧双向进行计算的方式,相对于现有技术可以提高计算的效率。In this embodiment, by using the data located at the preset position in the data block to be encoded as the reference data, the residual values of the two adjacent data on both sides of the reference data are respectively calculated. Compared with the prior art, the two-way calculation method can improve the efficiency of calculation.
本发明一可选的实施例中,也可以是将数据子块进一步划分成多个数据块,通过在每个数据块中设置一个或多个参考数据,并计算每个参考数据两侧的相邻两个数据的残差值,如此可以进一步提高计算的效率,进而提高编码效率。In an optional embodiment of the present invention, the data sub-block can also be further divided into multiple data blocks, by setting one or more reference data in each data block, and calculating the phases on both sides of each reference data. The residual value of the adjacent two data can further improve the calculation efficiency and thus the coding efficiency.
对应的,本发明一实施例中将由上述方法得到的编码数据作为待解码数据块进行解析时,首先获取待解码数据块中的参考数据和残差数据;其中,该待解码数据块由对原始数据块进行编码生成;参考数据为所述原始数据中预设位置的数据;所述残差数据为在编码过程中,位于所述参考数据两侧的每相邻两个数据的残差值。Correspondingly, when parsing the encoded data obtained by the above method as the data block to be decoded in an embodiment of the present invention, first obtain the reference data and residual data in the data block to be decoded; wherein, the data block to be decoded The data block is encoded and generated; the reference data is data at a preset position in the original data; the residual data is the residual value of every two adjacent data located on both sides of the reference data during the encoding process.
然后将所述参考数据和所述残差数据进行递减运算或累加运算,生成所述参考数据两侧的原始数据。Then, the reference data and the residual data are decremented or accumulated to generate the original data on both sides of the reference data.
例如,参见图4以待编码数据块中包含有16个数据为例,该16个数据分别为:p0、p1、p2、p3、p4、、、p14、p15。以位于该待编码数据块的中心位置的数据p8作为参考数据,使用以下数组记录除p8以外像素的 残差值:For example, referring to FIG. 4, taking as an example the data block to be encoded contains 16 data, the 16 data are: p0, p1, p2, p3, p4, ,, p14, p15. Using the data p8 at the center of the data block to be encoded as the reference data, use the following array to record the residual values of pixels other than p8:
左侧:diff[0]=p8-p7,diff[1]=p7-p6,…,diff[7]=p1-p0;Left side: diff[0]=p8-p7, diff[1]=p7-p6,..., diff[7]=p1-p0;
右侧:diff[8]=p8-p9,diff[9]=p9-p10,…,diff[14]=p14-p15。Right side: diff[8]=p8-p9, diff[9]=p9-p10,..., diff[14]=p14-p15.
而在解码过程中,以p8与diff[8]至diff[14]进行递减运算可分别获得p9-p14的数据,在解码过程中,以p8与diff[0]至diff[7]进行递减运算可分别获得p7-p0的数据。例如,如图5,分别与r0至r7进行递减运算可分别获得p7-p0的数据,分别与r9至r15进行递减运算可分别获得p9-p14的数据。示例性的,p8-diff[0]可得到p7,p8-diff[0]-diff[1]可得到p6,其他同理。In the decoding process, p8 and diff[8] to diff[14] are used for decrement operations to obtain p9-p14 data respectively. In the decoding process, p8 and diff[0] to diff[7] are used for decrement operations. The data of p7-p0 can be obtained separately. For example, as shown in Figure 5, decrement operations with r0 to r7 can respectively obtain data p7-p0, and decrement operations with r9 to r15 can respectively obtain data p9-p14. Exemplarily, p8-diff[0] can get p7, p8-diff[0]-diff[1] can get p6, and other things are the same.
在另一实施例中,以可以使用以下数组记录除p8以外像素的残差值:In another embodiment, the following array can be used to record the residual values of pixels other than p8:
左侧:diff[0]=p7-p8,diff[1]=p6-p7,…,diff[7]=p0-p1;Left side: diff[0]=p7-p8, diff[1]=p6-p7,..., diff[7]=p0-p1;
右侧:diff[8]=p9-p8,diff[9]=p10-p9,…,diff[14]=p15-p14。Right side: diff[8]=p9-p8, diff[9]=p10-p9,..., diff[14]=p15-p14.
而在解码过程中,以p8与diff[8]至diff[14]进行累加运算可分别获得p9-p14的数据,在解码过程中,以p8与diff[0]至diff[7]进行累加运算可分别获得p7-p0的数据。例如,如图5,分别与r0至r7进行累加运算可分别获得p7-p0的数据,分别与r9至r15进行累加运算可分别获得p9-p14的数据。示例性的,p8+diff[0]可得到p7,p8+diff[0]+diff[1]可得到p6,其他同理。In the decoding process, p8 and diff[8] to diff[14] are used for accumulation operation to obtain the data of p9-p14 respectively. In the decoding process, p8 and diff[0] to diff[7] are used for accumulation operation The data of p7-p0 can be obtained separately. For example, as shown in Figure 5, the data of p7-p0 can be obtained by accumulating operations with r0 to r7, and the data of p9-p14 can be obtained by accumulating operations with r9 to r15 respectively. Exemplarily, p8+diff[0] can get p7, p8+diff[0]+diff[1] can get p6, and the others are the same.
进而,本发明实施例中可以从参考数据的两侧开始对待解码数据块进行双向同时解码操作,具有解码效率高的积极效果。Furthermore, in the embodiment of the present invention, two-way simultaneous decoding operations can be performed on the data block to be decoded from both sides of the reference data, which has the positive effect of high decoding efficiency.
参照图13所示的实施例,本实施例中提供了一种数据处理方法,应用于依次连接的配置器、存储器和处理器,该方法包括如下步骤S61-S62:Referring to the embodiment shown in FIG. 13, this embodiment provides a data processing method, which is applied to a configurator, a memory, and a processor connected in sequence, and the method includes the following steps S61-S62:
S61、通过所述配置器对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流,并将所述压缩码流写入所述存储器,以降低对所述存储器的写带宽。S61: Perform compression encoding on the data block to be encoded formed by the preset data by the configurator to generate a compressed code stream, and write the compressed code stream into the memory, so as to reduce the write bandwidth to the memory.
本发明一实施例中,上述的配置器上设有编码器,该配置器具体是通过该编码器对待编码数据块进行压缩编码生成码流。In an embodiment of the present invention, the above-mentioned configurator is provided with an encoder, and the configurator specifically compresses and encodes the data block to be encoded by the encoder to generate a code stream.
S62、通过所述处理器读取所述存储器内的压缩码流,并对所述压缩 码流进行解压缩处理,以降低对所述存储器的读带宽。S62. Read the compressed code stream in the memory by the processor, and perform decompression processing on the compressed code stream to reduce the read bandwidth of the memory.
本发明一实施例中,上述的处理器上设有解码器,该处理器具体是通过该解码器对上述的压缩码流进行解压缩处理。In an embodiment of the present invention, a decoder is provided on the aforementioned processor, and the processor specifically decompresses the aforementioned compressed code stream through the decoder.
本发明一实施例中,上述的预设数据为基于一卷积神经网络的权重数据;进而本实施例中,配置器用于分配该权重数据,并将该权重数据经过编码器压缩编码后得到的压缩码流写入存储器中;上述处理器用于从存储器中读取权重数据对应的压缩码流,通过解码器对压缩码流进行解压缩处理生成权重数据,并基于该权重数据运行所述卷积神经网络。In an embodiment of the present invention, the above-mentioned preset data is weight data based on a convolutional neural network; and in this embodiment, the configurator is used to allocate the weight data and compress and encode the weight data by an encoder. The compressed code stream is written into the memory; the processor is used to read the compressed code stream corresponding to the weight data from the memory, decompress the compressed code stream through the decoder to generate weight data, and run the convolution based on the weight data Neural Networks.
可选的,上述处理器还包括静态随机存取存储器(Static Random-Access Memory,SRAM),该静态随机存取存储器用于从存储器中读取权重数据对应的压缩码流,以使得处理器通过解码器对静态随机存储器中的压缩码流进行解压缩处理生成权重数据,并基于该权重数据运行所述卷积神经网络。Optionally, the foregoing processor further includes a static random-access memory (Static Random-Access Memory, SRAM), which is used to read the compressed code stream corresponding to the weight data from the memory, so that the processor can pass through The decoder performs decompression processing on the compressed code stream in the SRAM to generate weight data, and runs the convolutional neural network based on the weight data.
图14所示的实施例中示出了配置器、存储器和处理器之间的关系示意图;参照图14所示,上述的配置器与存储器相连接,该存储器和处理器相连接,该实施中,上述的存储器可以是双倍数据率同步动态随机存取存储器(Double Data Rate Synchronous Dynamic Random Access Memory,DDR SDRAM);本实施例中,配置器中设有编码器,该配置器具体是通过编码器对待编码数据块进行压缩编码生成压缩码流;处理器中设置有解码器和静态随机存取存储器,该静态随机存取存储器用于从存储器中读取权重数据对应的压缩码流,处理器通过解码器对静态随机存储器中的压缩码流进行解压缩处理生成权重数据,并基于该权重数据运行卷积神经网络。The embodiment shown in FIG. 14 shows a schematic diagram of the relationship between the configurator, the memory and the processor; referring to FIG. 14, the above-mentioned configurator is connected to the memory, and the memory is connected to the processor. In this implementation The above-mentioned memory may be a double data rate synchronous dynamic random access memory (Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM); in this embodiment, an encoder is provided in the configurator, and the configurator is specifically coded The processor compresses and encodes the data block to be encoded to generate a compressed code stream; the processor is provided with a decoder and a static random access memory, and the static random access memory is used to read the compressed code stream corresponding to the weight data from the memory. A decoder is used to decompress the compressed code stream in the SRAM to generate weight data, and run a convolutional neural network based on the weight data.
本发明上述实施例中,为减少权重数据在从存储器读取到处理器中的静态随机存取存储器时的带宽开销,编码器对压缩后的权重数据进行解压缩处理;相应地,配置器将权重数据写入存储器前,编码器会对该权重数据进行压缩处理。该过程使用编码器、解码器对权重数据进行无损压缩和解压,保证权重数据不会引入额外的误差且不需要重新训练网络,同时较 大程度上能够降低系统带宽。In the above-mentioned embodiment of the present invention, in order to reduce the bandwidth overhead when the weight data is read from the memory to the static random access memory in the processor, the encoder decompresses the compressed weight data; accordingly, the configurator will Before the weight data is written into the memory, the encoder will compress the weight data. This process uses encoders and decoders to losslessly compress and decompress the weight data, ensuring that the weight data does not introduce additional errors and does not require retraining the network. At the same time, the system bandwidth can be reduced to a large extent.
优选地,编码器对该权重数据进行无损压缩处理,保证权重参数不会引入额外的误差且不需要重新训练网络。Preferably, the encoder performs lossless compression processing on the weight data to ensure that the weight parameters do not introduce additional errors and do not need to retrain the network.
本发明一实施例中,上述方法中,配置器对待编码数据块进行压缩编码生成压缩码流的具体过程包括:获取多个第一编码方式对于待编码数据块的编码开销,从多个第一编码方式中确定编码开销最小的目标编码方式;然后通过该目标编码方式对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流;该预设数据可以是卷积神经网络的权重数据。In an embodiment of the present invention, in the foregoing method, the specific process of the configurator performing compression encoding on the data block to be encoded to generate a compressed code stream includes: acquiring the encoding overhead of multiple first encoding methods for the data block to be encoded, In the encoding method, determine the target encoding method with the least encoding overhead; then use the target encoding method to compress and encode the data block to be encoded formed by the preset data to generate a compressed code stream; the preset data may be the weight of the convolutional neural network data.
其中,上述编码开销为待编码数据块进行编码后生成的码流数据所占的位宽。Wherein, the aforementioned encoding overhead is the bit width occupied by the code stream data generated after the data block to be encoded is encoded.
本实施例中,针对不同的待编码数据块选择编码开销最小的编码方式进行编码,能够实现对该待编码数据块进行有效的压缩。In this embodiment, for different data blocks to be encoded, an encoding method with the least encoding overhead is selected for encoding, which can achieve effective compression of the data blocks to be encoded.
本发明一实施例中,上述配置器首先确定原始数据块中是否存在冗余数据块,若是,则对该冗余数据块按照第二编码方式进行编码。可选的,该第二编码方式包括:游程编码,具体的配置器将冗余数据块按照游程编码所对应的码流结构,写入编码后的码流数据;该游程编码所对应的码流结构包括:编码方式的标志位、起始值和游程长度。In an embodiment of the present invention, the above-mentioned configurator first determines whether there is a redundant data block in the original data block, and if so, the redundant data block is encoded according to the second encoding method. Optionally, the second encoding method includes: run-length encoding. The specific configurator writes the redundant data block into the code stream data according to the code stream structure corresponding to the run-length encoding; the code stream corresponding to the run-length encoding The structure includes: the flag bit of the encoding method, the starting value and the run length.
在将原始数据块中除掉冗余数据块以后,可以是将剩余数据块作为待编码数据块,选择编码开销最小的编码方式进行编码。After the redundant data blocks are removed from the original data blocks, the remaining data blocks can be used as the data blocks to be encoded, and the encoding method with the least encoding overhead is selected for encoding.
或者,可以是将剩余数据块按照指定大小划分得到多个数据块,将每一数据块作为待编码数据块,选择编码开销最小的编码方式进行编码;该实施例中,如果所述剩余数据块的数据量不满足为所述指定大小的整数倍,则先对所述剩余数据块进行数据填充,以使划分后得到每个数据块的大小为均为指定大小。Alternatively, the remaining data blocks may be divided according to a specified size to obtain multiple data blocks, each data block is used as the data block to be encoded, and the encoding method with the least encoding overhead is selected for encoding; in this embodiment, if the remaining data block If the amount of data does not satisfy an integer multiple of the specified size, then the remaining data blocks are first filled with data so that the size of each data block obtained after division is the specified size.
本发明一实施例中,上述配置器通过以下方式确定原始数据块中是否存在冗余数据块:In an embodiment of the present invention, the above-mentioned configurator determines whether there is a redundant data block in the original data block in the following manner:
配置器查找所述原始数据块中是否有连续出现且重复次数大于预设值 的数据,若有,则确定存在冗余数据块,并将该连续的数据作为所述冗余数据块;若否,则确定不存在冗余数据块。The configurator searches the original data block to see whether there is data that continuously appears and the number of repetitions is greater than a preset value, and if so, determines that there is a redundant data block, and uses the continuous data as the redundant data block; if not , It is determined that there is no redundant data block.
本发明一实施例中,上述多个第一编码方式,包括:原始编码方式、残差编码方式以及混合编码方式;其中,所述混合编码方式为对所述待编码数据块进行划分分成若干数据子块后,对每一所述数据字块进行残差编码或原始编码。In an embodiment of the present invention, the above-mentioned multiple first encoding methods include: an original encoding method, a residual encoding method, and a hybrid encoding method; wherein the hybrid encoding method is to divide the data block to be encoded into several data After sub-blocks, residual coding or original coding is performed on each of the data blocks.
可选的,当所述目标编码方式为原始编码方式时,通过所述目标编码方式对所述待编码数据块进行编码,包括:Optionally, when the target coding mode is the original coding mode, encoding the data block to be coded by the target coding mode includes:
将所述待编码数据块中的原始数据按照所述原始编码方式对应的码流结构,写入编码后的码流数据;Writing the original data in the data block to be coded into the coded code stream data according to the code stream structure corresponding to the original coding mode;
其中,所述原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。Wherein, the code stream structure corresponding to the original coding mode includes: a flag bit of the coding mode and original data.
可选的,当所述目标编码方式为所述残差编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:Optionally, when the target coding mode is the residual coding mode, the encoding the data block to be coded by the target coding mode includes:
以所述待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据;Using the data at a preset position in the data block to be encoded as reference data, the residual values of each two adjacent data located on both sides of the reference data are calculated respectively, and the residual value and the reference data are calculated according to The code stream structure corresponding to the residual coding method is written into the coded code stream data;
其中,所述残差编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the residual coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
可选的,当所述目标编码方式为混合编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:Optionally, when the target coding mode is a hybrid coding mode, encoding the data block to be coded by the target coding mode includes:
将所述待编码数据块划分得到至少两个数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks;
以任一所述数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in any of the data sub-blocks as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
分别将每个所述数据子块计算得到的残差值和所述参考数据按照所述混合编码方式对应的码流结构写入编码后的码流数据。The residual value calculated for each of the data sub-blocks and the reference data are respectively written into the coded code stream data according to the code stream structure corresponding to the hybrid coding mode.
其中,本实施例中,上述混合编码方式对应的码流结构包括:编码方 式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, in this embodiment, the code stream structure corresponding to the above-mentioned hybrid coding mode includes: the flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
可选的,当所述目标编码方式为混合编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:Optionally, when the target coding mode is a hybrid coding mode, encoding the data block to be coded by the target coding mode includes:
将所述待编码数据块划分得到至少两个数据子块;其中,所述至少两个数据字块包括第一数据子块和第二数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks; wherein the at least two data word blocks include a first data sub-block and a second data sub-block;
以所述第一数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据;将所述第二数据子块中的原始数据按照所述混合编码方式所对应的码流结构,写入编码后的码流数据;Using the data at a preset position in the first data sub-block as reference data, the residual values of each two adjacent data located on both sides of the reference data are respectively calculated, and the residual value and the reference data Write the encoded code stream data according to the code stream structure corresponding to the hybrid encoding method; write the original data in the second data sub-block into the code stream structure corresponding to the hybrid encoding method Stream data;
其中,本实施例中的混合编码方式所对应的码流结构包括:编码方式的标志位、所述第二数据块的原始数据、所述残差值、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the hybrid encoding method in this embodiment includes: the flag bit of the encoding method, the original data of the second data block, the residual value, the reference data, and the residual value The occupied bit width and the residual value.
可选的,所述处理器读取所述存储器内的压缩码流,并对所述压缩码流进行解压缩处理,包括:Optionally, the processor reading the compressed code stream in the memory and decompressing the compressed code stream includes:
所述处理器对所述压缩码流进行解析,确定多个预设的第一编码方式中与所述压缩码流对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;The processor parses the compressed code stream, determines a target encoding method corresponding to the compressed code stream among a plurality of preset first encoding methods, and determines a corresponding target decoding method according to the target encoding method;
通过所述目标解码方式对所述压缩码流进行解码,得到所述预设数据。The compressed code stream is decoded by the target decoding method to obtain the preset data.
可选的,上述的压缩码流的码流结构中包括标志位;处理器根据预设的所述标志位的数值和所述第一编码方式的映射关系,确定出与所述压缩码流对应的目标编码方式。Optionally, the code stream structure of the aforementioned compressed code stream includes a flag bit; the processor determines that it corresponds to the compressed code stream according to a preset mapping relationship between the value of the flag bit and the first encoding mode The target encoding method.
上述目标解码方式包括:游程解码、原始数据拷贝、残差解码和混合解码中的任意一种或多种;The foregoing target decoding methods include: any one or more of run-length decoding, original data copy, residual decoding, and hybrid decoding;
其中,所述混合解码为对所述待解码数据块进行划分生成多个数据子块,对每一所述数据字块进行残差解码或原始数据拷贝。Wherein, the hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks, and perform residual decoding or original data copy on each of the data word blocks.
下面介绍当目标解码方式为游程解码、原始数据拷贝和残差解码时的 计算过程:The following describes the calculation process when the target decoding method is run-length decoding, original data copy and residual decoding:
当所述目标解码方式为游程解码时,所述使用所述目标解码方式对所述压缩码流进行解码还原,包括:When the target decoding mode is run-length decoding, the using the target decoding mode to decode and restore the compressed code stream includes:
从所述压缩码流的码流结构中读取起始值和游程长度,根据所述起始值和游程长度将所述压缩码流进行解码还原,得到对应的预设数据。The initial value and the run length are read from the code stream structure of the compressed code stream, and the compressed code stream is decoded and restored according to the initial value and the run length to obtain corresponding preset data.
当所述目标解码方式为原数据拷贝时,所述使用所述目标解码方式对所述压缩码流进行解码还原,包括:When the target decoding mode is the original data copy, the decoding and restoring the compressed code stream using the target decoding mode includes:
从所述压缩码流的码流结构中读取对应的编码后的数据,将所述编码后的数据进行拷贝,得到对应的预设数据。Reading the corresponding coded data from the code stream structure of the compressed code stream, and copying the coded data to obtain corresponding preset data.
当所述目标解码方式为残差解码时,所述使用所述目标解码方式对所述压缩码流进行解码还原,包括:When the target decoding mode is residual decoding, the using the target decoding mode to decode and restore the compressed code stream includes:
从所述压缩码流的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据、残差值所占的位长和残差值执行残差计算的逆运算,得到对应的预设数据。Read the corresponding reference data, the bit length occupied by the residual value and the residual value from the bit stream structure of the compressed bit stream, and execute according to the reference data, the bit length occupied by the residual value and the residual value The inverse operation of the residual calculation obtains the corresponding preset data.
所述使用所述目标解码方式对所述压缩码流进行解码还原,得到所述预设数据,包括:The decoding and restoring the compressed code stream using the target decoding method to obtain the preset data includes:
若通过所述目标解码方式对所述压缩码流进行解码还原得到的数据的数据量大于预设数据量时,将超出所述预设数据量的部分数据丢弃,得到所述预设数据。If the data volume of the data obtained by decoding and restoring the compressed code stream by the target decoding method is greater than the preset data volume, discarding part of the data exceeding the preset data volume to obtain the preset data.
需要说明的,本发明上述的实施例中配置器和处理器的的具体执行步骤可以参照上述的第一方面至第四方面的中的各实施例中的方法的介绍。It should be noted that, for the specific execution steps of the configurator and the processor in the foregoing embodiment of the present invention, reference may be made to the introduction of the method in each of the foregoing first to fourth aspects.
本发明一实施例中,参照图15所示,还提供了一种数据处理系统,包括:依次连接的配置器81、存储器80和处理器82。In an embodiment of the present invention, referring to FIG. 15, a data processing system is also provided, including: a configurator 81, a memory 80, and a processor 82 connected in sequence.
配置器81用于对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流,并将所述压缩码流写入所述存储器80,以降低对所述存储器80的写带宽。The configurator 81 is configured to compress and encode a data block to be encoded formed by preset data to generate a compressed code stream, and write the compressed code stream into the memory 80 to reduce the write bandwidth to the memory 80.
处理器82用于读取所述存储器80内的压缩码流,并对所述压缩码流 进行解压缩处理,以降低对所述存储器80的读带宽。The processor 82 is configured to read the compressed code stream in the memory 80, and decompress the compressed code stream, so as to reduce the read bandwidth of the memory 80.
可选的,上述配置器81上设有编码器,上述处理器82上设有解码器;Optionally, an encoder is provided on the configurator 81, and a decoder is provided on the processor 82;
所述配置器用于通过所述编码器对所述待编码数据块进行压缩编码生成压缩码流,所述处理器用于通过所述解码器对所述压缩码流进行解压缩处理。The configurator is used to compress and encode the data block to be encoded by the encoder to generate a compressed code stream, and the processor is used to perform decompression processing on the compressed code stream by the decoder.
可选的,上述预设数据为基于一卷积神经网络的权重数据;所述配置器用于分配所述权重数据,并将对所述权重数据进行压缩编码得到的压缩码流写入存储器中;所述处理器用于从所述存储器中读取所述权重数据对应的压缩码流,对所述压缩码流进行解压缩处理生成所述权重数据,并基于所述权重数据运行所述卷积神经网络。Optionally, the aforementioned preset data is weight data based on a convolutional neural network; the configurator is used to allocate the weight data, and write the compressed code stream obtained by compressing and encoding the weight data into the memory; The processor is configured to read the compressed code stream corresponding to the weight data from the memory, decompress the compressed code stream to generate the weight data, and run the convolutional neural network based on the weight data The internet.
本实施例中,配置器、存储器和处理器构成了卷积神经网络的系统架构,通过在该系统架构中增加编码器和解码器,解决了处理器从存储器反复读取权重数据到处理器的带宽压力。In this embodiment, the configurator, memory, and processor constitute the system architecture of the convolutional neural network. By adding an encoder and a decoder to the system architecture, the problem of the processor repeatedly reading weight data from the memory to the processor is solved. Bandwidth pressure.
可选的,上述处理器82还包括静态随机存取存储器,所述静态随机存取存储器用于从所述存储器中读取所述权重数据对应的压缩码流,以使得所述处理器能够对所述压缩码流进行解压缩处理生成所述权重数据,并基于所述权重数据运行所述卷积神经网络。Optionally, the aforementioned processor 82 further includes a static random access memory, and the static random access memory is used to read the compressed code stream corresponding to the weight data from the memory, so that the processor can The compressed code stream is decompressed to generate the weight data, and the convolutional neural network is run based on the weight data.
上述实施中,上述的存储器可以是双倍数据率同步动态随机存取存储器(Double Data Rate Synchronous Dynamic Random Access Memory,DDR SDRAM);本实施例中,配置器中设有编码器,该配置器具体是通过该编码器对待编码数据块进行压缩编码生成码流;处理器中设置有解码器和静态随机存取存储器,该静态随机存取存储器用于从存储器中读取预设数据对应的压缩码流,处理器通过解码器对静态随机存储器中的压缩码流进行解压缩处理生成原预设数据。可选的,上述的数据处理系统为卷积神经网络的计算系统,上述的预设数据为卷积神经网络的权重数据,上述处理器用于并基于该权重数据运行卷积神经网络。In the foregoing implementation, the foregoing memory may be a double data rate synchronous dynamic random access memory (Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM); in this embodiment, an encoder is provided in the configurator, and the configurator is specifically The encoder is used to compress and encode the data block to be encoded to generate a code stream; the processor is provided with a decoder and a static random access memory, and the static random access memory is used to read the compression code corresponding to the preset data from the memory Stream, the processor decompresses the compressed code stream in the SRAM through the decoder to generate the original preset data. Optionally, the aforementioned data processing system is a calculation system of a convolutional neural network, the aforementioned preset data is weight data of a convolutional neural network, and the aforementioned processor is used to run the convolutional neural network based on the weight data.
本发明上述实施例中,为减少权重数据在从存储器读取到处理器中的 静态随机存取存储器时的带宽开销,编码器对压缩后的权重数据进行解压缩处理;相应地,配置器将权重数据写入存储器前,编码器会对该权重数据进行压缩处理。该过程使用编码器、解码器对权重数据进行无损压缩和解压,保证权重数据不会引入额外的误差且不需要重新训练神经网络,同时较大程度上能够降低系统带宽。降低了卷积神经网络的运行对硬件资源的要求。In the above-mentioned embodiment of the present invention, in order to reduce the bandwidth overhead when the weight data is read from the memory to the static random access memory in the processor, the encoder decompresses the compressed weight data; accordingly, the configurator will Before the weight data is written into the memory, the encoder will compress the weight data. This process uses encoders and decoders to losslessly compress and decompress the weight data, ensuring that the weight data will not introduce additional errors and do not need to retrain the neural network, while reducing the system bandwidth to a large extent. It reduces the hardware resource requirements for the operation of the convolutional neural network.
可选的,上述配置器81具体用于通过以下方式对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流:Optionally, the above-mentioned configurator 81 is specifically configured to compress and encode the to-be-coded data block formed by the preset data in the following manner to generate a compressed code stream:
所述配置器获取预设的多个第一编码方式对于所述待编码数据块的编码开销,从所述多个第一编码方式中确定编码开销最小的目标编码方式;The configurator obtains the coding overhead of the plurality of preset first coding modes for the data block to be coded, and determines the target coding mode with the smallest coding overhead from the plurality of first coding modes;
通过所述目标编码方式对所述待编码数据块进行编码,得到压缩码流。Encoding the data block to be encoded by the target encoding method to obtain a compressed code stream.
其中,上述编码开销为所述待编码数据块进行编码后生成的码流数据所占的位宽。Wherein, the foregoing encoding overhead is the bit width occupied by the code stream data generated after encoding the data block to be encoded.
可选的,上述配置器81还用于:确定原始数据块中是否存在冗余数据块,若是,则对所述冗余数据块按照第二编码方式进行编码;Optionally, the above-mentioned configurator 81 is further configured to: determine whether there is a redundant data block in the original data block, and if so, encode the redundant data block according to the second coding mode;
将所述原始数据块中除掉所述冗余数据块的剩余数据块作为所述待编码数据块。Use the remaining data blocks in the original data blocks except for the redundant data blocks as the data blocks to be encoded.
可选的,上述配置器81还用于通过以下方式生成待编码数据块:Optionally, the above-mentioned configurator 81 is further configured to generate the data block to be encoded in the following manner:
确定原始数据块中是否存在冗余数据块,若是,则获取所述原始数据块中除掉所述冗余数据块的剩余数据块;Determine whether there is a redundant data block in the original data block, and if so, obtain the remaining data block in the original data block excluding the redundant data block;
将所述剩余数据块按照指定大小划分得到多个数据块,将每一数据块作为所述待编码数据块。Divide the remaining data blocks according to a specified size to obtain multiple data blocks, and use each data block as the data block to be encoded.
可选的,上述配置器81具体用于通过以下方式确定原始数据块中是否存在冗余数据块:Optionally, the above-mentioned configurator 81 is specifically configured to determine whether there is a redundant data block in the original data block in the following manner:
查找所述原始数据块中是否有连续出现且重复次数大于预设值的数据,若有,则确定存在冗余数据块,并将该连续的数据作为所述冗余数据 块;若否,则确定不存在冗余数据块。Find out whether there is data that continuously appears in the original data block and the number of repetitions is greater than a preset value, if so, determine that there is a redundant data block, and use the continuous data as the redundant data block; if not, then Make sure that there are no redundant data blocks.
可选的,上述第二编码方式包括游程编码,所述配置器81具体用于通过以下方式对所述冗余数据块按照第二编码方式进行编码:Optionally, the foregoing second encoding manner includes run-length encoding, and the configurator 81 is specifically configured to encode the redundant data block according to the second encoding manner in the following manner:
将所述冗余数据块按照游程编码所对应的码流结构,写入编码后的码流数据;所述游程编码所对应的码流结构包括:编码方式的标志位、起始值和游程长度。The redundant data block is written into the coded stream data according to the code stream structure corresponding to the run-length encoding; the code stream structure corresponding to the run-length encoding includes: the flag bit of the encoding mode, the start value and the run length .
可选的,上述多个第一编码方式,包括:原始编码方式、残差编码方式以及混合编码方式;其中,所述混合编码方式为对所述待编码数据块进行划分分成若干数据子块后,对每一所述数据字块进行残差编码或原始编码。Optionally, the above-mentioned multiple first coding modes include: an original coding mode, a residual coding mode, and a mixed coding mode; wherein, the mixed coding mode is after the data block to be coded is divided into several data sub-blocks , Perform residual coding or original coding on each of the data blocks.
可选的,当所述目标编码方式为原始编码方式时,所述配置器81具体用于:Optionally, when the target coding mode is the original coding mode, the configurator 81 is specifically configured to:
将所述待编码数据块中的原始数据按照所述原始编码方式对应的码流结构,写入编码后的码流数据;所述原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。The original data in the data block to be coded is written into the coded stream data according to the code stream structure corresponding to the original coding mode; the code stream structure corresponding to the original coding mode includes: the flag bit of the coding mode and Raw data.
可选的,当所述目标编码方式为所述残差编码方式时,所述配置器81具体用于:Optionally, when the target coding mode is the residual coding mode, the configurator 81 is specifically configured to:
以所述待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据;其中,所述残差编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Using the data at a preset position in the data block to be encoded as reference data, the residual values of each two adjacent data located on both sides of the reference data are calculated respectively, and the residual value and the reference data are calculated according to The code stream structure corresponding to the residual coding mode is written into the coded code stream data; wherein the code stream structure corresponding to the residual coding mode includes: a flag bit of the coding mode, the reference data, and the residual The bit width occupied by the value and the residual value.
可选的,当所述目标编码方式为混合编码方式时,所述配置器81具体用于:Optionally, when the target coding mode is a hybrid coding mode, the configurator 81 is specifically configured to:
将所述待编码数据块划分得到至少两个数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks;
以任一所述数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in any of the data sub-blocks as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
分别将每个所述数据子块计算得到的残差值和所述参考数据按照所述混合编码方式对应的码流结构写入编码后的码流数据;其中,所述混合编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。The residual value calculated for each data sub-block and the reference data are written into the coded stream data according to the code stream structure corresponding to the hybrid encoding mode; wherein the code corresponding to the hybrid encoding mode The stream structure includes: a flag bit of an encoding mode, the reference data, the bit width occupied by the residual value, and the residual value.
可选的,当所述目标编码方式为混合编码方式时,所述配置器具体用于:Optionally, when the target coding mode is a hybrid coding mode, the configurator is specifically configured to:
将所述待编码数据块划分得到至少两个数据子块;其中,所述至少两个数据字块包括第一数据子块和第二数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks; wherein the at least two data word blocks include a first data sub-block and a second data sub-block;
以所述第一数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据;将所述第二数据子块中的原始数据按照所述混合编码方式所对应的码流结构,写入编码后的码流数据;Using the data at a preset position in the first data sub-block as reference data, the residual values of each two adjacent data located on both sides of the reference data are respectively calculated, and the residual value and the reference data Write the encoded code stream data according to the code stream structure corresponding to the hybrid encoding method; write the original data in the second data sub-block into the code stream structure corresponding to the hybrid encoding method Stream data;
其中,所述混合编码方式所对应的码流结构包括:编码方式的标志位、所述第二数据块的原始数据、所述残差值、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the hybrid coding mode includes: the flag bit of the coding mode, the original data of the second data block, the residual value, the reference data, and the residual value Bit width and the residual value.
可选的,上述配置器81还用于:在所述将所述剩余数据块按照指定大小划分得到多个数据块之前,如果所述剩余数据块的数据量不满足为所述指定大小的整数倍,则对所述剩余数据块进行数据填充,以使划分后得到每个数据块的大小为均为指定大小。Optionally, the above-mentioned configurator 81 is further configured to: before the dividing the remaining data blocks according to a specified size to obtain multiple data blocks, if the data amount of the remaining data blocks does not satisfy an integer of the specified size Times, the remaining data blocks are filled with data, so that the size of each data block obtained after division is the specified size.
可选的,所述对所述剩余数据块进行数据填充,包括:Optionally, the performing data filling on the remaining data blocks includes:
复制N个所述剩余数据块中的末尾数据,利用复制的N个数据对所述剩余数据块进行填充,以使得所述剩余数据块的数据量为所述指定大小的整数倍;其中,所述N大于等于1。Copy the last data in the N remaining data blocks, and fill the remaining data blocks with the copied N data so that the data amount of the remaining data blocks is an integer multiple of the specified size; wherein, Said N is greater than or equal to 1.
可选的,上述处理器82具体用于通过以下方式读取所述存储器内的压缩码流,并对所述压缩码流进行解压缩处理:Optionally, the foregoing processor 82 is specifically configured to read the compressed code stream in the memory in the following manner, and perform decompression processing on the compressed code stream:
所述处理器对所述压缩码流进行解析,确定多个预设的第一编码方式 中与所述压缩码流对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;The processor parses the compressed code stream, determines a target encoding method corresponding to the compressed code stream among a plurality of preset first encoding methods, and determines a corresponding target decoding method according to the target encoding method;
通过所述目标解码方式对所述压缩码流进行解码,得到所述预设数据。The compressed code stream is decoded by the target decoding method to obtain the preset data.
可选的,所述压缩码流的码流结构中包括标志位;Optionally, the code stream structure of the compressed code stream includes a flag bit;
所述处理器具体用于通过以下方式对所述压缩码流进行解析,确定多个预设的第一编码方式中与所述压缩码流对应的目标编码方式:The processor is specifically configured to parse the compressed code stream in the following manner, and determine a target encoding method corresponding to the compressed code stream among a plurality of preset first encoding methods:
根据预设的所述标志位的数值和所述第一编码方式的映射关系,获取与所述压缩码流对应的目标编码方式。According to the preset mapping relationship between the value of the flag bit and the first coding mode, the target coding mode corresponding to the compressed code stream is obtained.
可选的,所述目标解码方式包括:游程解码、原始数据拷贝、残差解码和混合解码中的任意一种;Optionally, the target decoding mode includes any one of run-length decoding, original data copy, residual decoding, and hybrid decoding;
其中,所述混合解码为对所述待解码数据块进行划分生成多个数据子块,对每一所述数据字块进行残差解码或原始数据拷贝。Wherein, the hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks, and perform residual decoding or original data copy on each of the data word blocks.
可选的,当所述目标解码方式为游程解码时,所述处理器具体用于:Optionally, when the target decoding mode is run-length decoding, the processor is specifically configured to:
从所述压缩码流的码流结构中读取起始值和游程长度,根据所述起始值和游程长度将所述压缩码流进行解码还原,得到对应的预设数据。The initial value and the run length are read from the code stream structure of the compressed code stream, and the compressed code stream is decoded and restored according to the initial value and the run length to obtain corresponding preset data.
可选的,当所述目标解码方式为原数据拷贝时,所述处理器具体用于:Optionally, when the target decoding mode is original data copy, the processor is specifically configured to:
从所述压缩码流的码流结构中读取对应的编码后的数据,将所述编码后的数据进行拷贝,得到对应的预设数据。Reading the corresponding coded data from the code stream structure of the compressed code stream, and copying the coded data to obtain corresponding preset data.
可选的,当所述目标解码方式为残差解码时,所述处理器具体用于:Optionally, when the target decoding mode is residual decoding, the processor is specifically configured to:
从所述压缩码流的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据、残差值所占的位长和残差值执行残差计算的逆运算,得到对应的预设数据。Read the corresponding reference data, the bit length occupied by the residual value and the residual value from the bit stream structure of the compressed bit stream, and execute according to the reference data, the bit length occupied by the residual value and the residual value The inverse operation of the residual calculation obtains the corresponding preset data.
可选的,所述处理器具体用于通过以下方式使用所述目标解码方式对所述压缩码流进行解码还原,得到所述预设数据,包括:Optionally, the processor is specifically configured to decode and restore the compressed code stream by using the target decoding mode in the following manner to obtain the preset data, including:
若通过所述目标解码方式对所述压缩码流进行解码还原得到的数据的数据量大于预设数据量时,将超出所述预设数据量的部分数据丢弃,得到所述预设数据。If the data volume of the data obtained by decoding and restoring the compressed code stream by the target decoding method is greater than the preset data volume, discarding part of the data exceeding the preset data volume to obtain the preset data.
参照图16所示的实施例,本实施例中提供了一种可移动平台,该可移动平台包括:机体900、动力系统91和上述实施例所述的数据处理系统92;动力系统91设于所述机体900,所述动力系统91用于为所述可移动平台提供动力。Referring to the embodiment shown in FIG. 16, a movable platform is provided in this embodiment. The movable platform includes: a body 900, a power system 91, and the data processing system 92 described in the foregoing embodiment; the power system 91 is located at The body 900 and the power system 91 are used to provide power for the movable platform.
示例性的,上述的数据处理系统92可以是应用于动力系统、作业系统等等可移动平台的功能系统中。Exemplarily, the aforementioned data processing system 92 may be applied to a functional system of a movable platform such as a power system, an operating system, and the like.
本实施例中所述提供的数据处理系统92在使用卷积神经网络进行数据处理时,能够实现对权重数据进行无损压缩和解压,保证权重数据不会引入额外的误差且不需要重新训练神经网络,并且降低系统带宽开销。能够满足使用条件较低的硬件资源实现卷积神经网络的运行。When the data processing system 92 provided in this embodiment uses a convolutional neural network for data processing, it can achieve lossless compression and decompression of weight data, ensuring that the weight data will not introduce additional errors and do not need to retrain the neural network , And reduce system bandwidth overhead. It can meet the use of hardware resources with lower conditions to realize the operation of convolutional neural networks.
参照图17所示的实施例,本实施例中提供了一种编码器1000,包括:选择电路101和编码电路102;Referring to the embodiment shown in FIG. 17, an encoder 1000 is provided in this embodiment, including: a selection circuit 101 and an encoding circuit 102;
所述选择电路用于获取多个第一编码方式对于待编码数据块的编码开销,从所述多个第一编码方式中确定编码开销最小的目标编码方式;The selection circuit is configured to obtain the coding overhead of the data block to be coded by the multiple first coding modes, and determine the target coding mode with the smallest coding overhead from the multiple first coding modes;
所述编码电路通过所述目标编码方式对所述待编码数据块进行编码。The encoding circuit encodes the data block to be encoded by using the target encoding method.
本发明实施例中所提供的一种编码器能够对数据进行有效的压缩,具有压缩效率高的优点。The encoder provided in the embodiment of the present invention can effectively compress data and has the advantage of high compression efficiency.
上述编码开销为所述待编码数据块进行编码后生成的码流数据所占的位宽。The foregoing encoding overhead is the bit width occupied by the code stream data generated after the data block to be encoded is encoded.
可选的,上述选择电路还用于:Optionally, the above selection circuit is also used for:
确定原始数据块中是否存在冗余数据块,若是,则对所述冗余数据块按照第二编码方式进行编码;Determine whether there is a redundant data block in the original data block, and if so, encode the redundant data block according to the second encoding mode;
将所述原始数据块中除掉所述冗余数据块的剩余数据块作为所述待编码数据块。Use the remaining data blocks in the original data blocks except for the redundant data blocks as the data blocks to be encoded.
可选的,所述待编码数据块通过以下方式生成:Optionally, the data block to be encoded is generated in the following manner:
确定原始数据块中是否存在冗余数据块,若是,则获取所述原始数据块中除掉所述冗余数据块的剩余数据块;Determine whether there is a redundant data block in the original data block, and if so, obtain the remaining data block in the original data block excluding the redundant data block;
将所述剩余数据块按照指定大小划分得到多个数据块,将每一数据块作为所述待编码数据块。Divide the remaining data blocks according to a specified size to obtain multiple data blocks, and use each data block as the data block to be encoded.
可选的,上述确定原始数据块中是否存在冗余数据块,包括:Optionally, the foregoing determining whether there is a redundant data block in the original data block includes:
查找所述原始数据块中是否有连续出现且重复次数大于预设值的数据,若有,则确定存在冗余数据块,并将该连续的数据作为所述冗余数据块;若否,则确定不存在冗余数据块。Find out whether there is data that continuously appears in the original data block and the number of repetitions is greater than a preset value, if so, determine that there is a redundant data block, and use the continuous data as the redundant data block; Make sure that there are no redundant data blocks.
可选的,所述第二编码方式包括游程编码,所述对所述冗余数据块按照第二编码方式进行编码,包括:Optionally, the second encoding manner includes run-length encoding, and encoding the redundant data block according to the second encoding manner includes:
将所述冗余数据块按照游程编码所对应的码流结构,写入编码后的码流数据;所述游程编码所对应的码流结构包括:编码方式的标志位、起始值和游程长度。The redundant data block is written into the coded stream data according to the code stream structure corresponding to the run-length encoding; the code stream structure corresponding to the run-length encoding includes: the flag bit of the encoding mode, the start value and the run length .
可选的,所述多个第一编码方式,包括:原始编码方式、残差编码方式以及混合编码方式;其中,所述混合编码方式为对所述待编码数据块进行划分分成若干数据子块后,对每一所述数据字块进行残差编码或原始编码。Optionally, the multiple first coding modes include: an original coding mode, a residual coding mode, and a mixed coding mode; wherein the mixed coding mode is dividing the data block to be coded into several data sub-blocks Afterwards, residual coding or original coding is performed on each of the data blocks.
可选的,当所述目标编码方式为原始编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:Optionally, when the target coding mode is the original coding mode, the encoding the data block to be coded by the target coding mode includes:
将所述待编码数据块中的原始数据按照所述原始编码方式对应的码流结构,写入编码后的码流数据;Writing the original data in the data block to be coded into the coded code stream data according to the code stream structure corresponding to the original coding mode;
其中,所述原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。Wherein, the code stream structure corresponding to the original coding mode includes: a flag bit of the coding mode and original data.
可选的,当所述目标编码方式为所述残差编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:Optionally, when the target coding mode is the residual coding mode, the encoding the data block to be coded by the target coding mode includes:
以所述待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in the data block to be encoded as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据;Writing the residual value and the reference data into the coded stream data according to the code stream structure corresponding to the residual coding mode;
其中,所述残差编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the residual coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
可选的,当所述目标编码方式为混合编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:Optionally, when the target coding mode is a hybrid coding mode, encoding the data block to be coded by the target coding mode includes:
将所述待编码数据块划分得到至少两个数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks;
以任一所述数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in any of the data sub-blocks as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
分别将每个所述数据子块计算得到的残差值和所述参考数据按照所述混合编码方式对应的码流结构写入编码后的码流数据;Respectively writing the residual value calculated for each of the data sub-blocks and the reference data into the coded code stream data according to the code stream structure corresponding to the hybrid coding mode;
其中,所述混合编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the hybrid coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
可选的,当所述目标编码方式为混合编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:Optionally, when the target coding mode is a hybrid coding mode, encoding the data block to be coded by the target coding mode includes:
将所述待编码数据块划分得到至少两个数据子块;其中,所述至少两个数据字块包括第一数据子块和第二数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks; wherein the at least two data word blocks include a first data sub-block and a second data sub-block;
以所述第一数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据;Using the data at a preset position in the first data sub-block as reference data, the residual values of each two adjacent data located on both sides of the reference data are respectively calculated, and the residual value and the reference data Write the coded code stream data according to the code stream structure corresponding to the hybrid coding mode;
将所述第二数据子块中的原始数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据;Writing the original data in the second data sub-block into the coded stream data according to the code stream structure corresponding to the hybrid coding mode;
其中,所述混合编码方式所对应的码流结构包括:编码方式的标志位、所述第二数据块的原始数据、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the hybrid coding mode includes: the flag bit of the coding mode, the original data of the second data block, the reference data, the bit width occupied by the residual value, and the residual value. Difference.
可选的,在将所述剩余数据块按照指定大小划分得到多个数据块之前,包括:Optionally, before dividing the remaining data blocks according to a specified size to obtain multiple data blocks, the method includes:
如果所述剩余数据块的数据量不满足为所述指定大小的整数倍,则对所述剩余数据块进行数据填充,以使划分后得到每个数据块的大小为均为 指定大小。If the data amount of the remaining data block does not satisfy an integer multiple of the specified size, data padding is performed on the remaining data block so that the size of each data block obtained after division is the specified size.
可选的,所述对所述剩余数据块进行数据填充,包括:Optionally, the performing data filling on the remaining data blocks includes:
复制N个所述剩余数据块中的末尾数据,利用复制的N个数据对所述剩余数据块进行填充,以使得所述剩余数据块的数据量为所述指定大小的整数倍;其中,所述N大于等于1Copy the last data in the N remaining data blocks, and fill the remaining data blocks with the copied N data so that the data amount of the remaining data blocks is an integer multiple of the specified size; wherein, Said N is greater than or equal to 1
本发明又一实施例中也提供了一种编码器,该编码器包括:残差计算电路和编码电路。Another embodiment of the present invention also provides an encoder, which includes a residual calculation circuit and an encoding circuit.
其中,残差计算电路,用于以待编码数据块中处于预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Wherein, the residual calculation circuit is configured to use the data in the preset position in the data block to be encoded as reference data, and respectively calculate the residual value of every two adjacent data located on both sides of the reference data;
所述编码电路,用于将所述残差值和所述参考数据按照残差编码方式对应的码流结构写入编码后的码流数据;其中,所述残差编码方式对应的码流结构包括:所述参考数据、所述残差值所占的位宽和所述残差值。The coding circuit is configured to write the residual value and the reference data into the code stream data according to the code stream structure corresponding to the residual coding mode; wherein, the code stream structure corresponding to the residual coding mode Including: the reference data, the bit width occupied by the residual value, and the residual value.
所述待编码数据块通过以下方式生成:The data block to be encoded is generated in the following manner:
将原始数据块按照指定大小进行划分得到多个数据子块,将每一所述数据子块作为所述待编码数据块。The original data block is divided according to a specified size to obtain multiple data sub-blocks, and each of the data sub-blocks is used as the data block to be encoded.
可选的,所述待编码数据块通过以下方式生成:Optionally, the data block to be encoded is generated in the following manner:
将原始数据块按照指定大小进行划分得到多个数据子块,将所述多个数据块中的第一数据块作为所述待编码数据块。The original data block is divided according to a specified size to obtain multiple data sub-blocks, and the first data block of the multiple data blocks is used as the data block to be encoded.
可选的,编码电路还用于:Optionally, the encoding circuit is also used for:
将所述多个数据子块除所述第一数据块外的其他数据块按照原始编码方式对应的码流结构,写入编码后的码流数据;所述原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。The other data blocks of the multiple data sub-blocks except the first data block are written into the code stream data according to the code stream structure corresponding to the original coding mode; the code stream structure corresponding to the original coding mode includes : Flag bit and original data of encoding method.
图18也给出了一种编码器的架构示意图,编码器架构中主要包括四个功能模块:游程编码模块、编码开销计算模块、模式选择模块(用于确定编码开销最小的目标编码方式)和剩余数据块编码模块(用于对除冗余数据块之外的剩余数据块进行编码);需要说明的是,本实施例中仅为举例说明,不应当看作是本发明的限定。Figure 18 also shows a schematic diagram of the encoder architecture. The encoder architecture mainly includes four functional modules: run-length encoding module, encoding overhead calculation module, mode selection module (used to determine the target encoding method with the smallest encoding overhead) and The remaining data block encoding module (used to encode the remaining data blocks except for the redundant data block); it should be noted that this embodiment is only an example for illustration and should not be regarded as a limitation of the present invention.
参照图19所示的实施例,本实施例中提供了一种解码器1100,所述解码器1100包括:解析电路111和解码电路112;Referring to the embodiment shown in FIG. 19, this embodiment provides a decoder 1100, and the decoder 1100 includes: an analysis circuit 111 and a decoding circuit 112;
所述解析电路111用于对待解码数据进行解析,确定多个预设的第一编码方式中与所述待解码数据对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;The parsing circuit 111 is configured to analyze the data to be decoded, determine a target encoding method corresponding to the data to be decoded among a plurality of preset first encoding methods, and determine a corresponding target decoding method according to the target encoding method;
所述解码电路112用于通过所述目标解码方式对所述待解码数据进行解码,生成解码数据。The decoding circuit 112 is configured to decode the data to be decoded in the target decoding mode to generate decoded data.
所述待解码数据包括标志位;所述对待解码数据进行解析,确定多个预设的第一编码方式中与所述待解码数据对应的目标编码方式包括:The data to be decoded includes a flag bit; the analyzing the data to be decoded and determining the target encoding method corresponding to the data to be decoded among the plurality of preset first encoding methods includes:
根据预设的所述标志位的数值和所述第一编码方式的映射关系,确定出与所述待解码数据对应的目标编码方式。According to the preset mapping relationship between the value of the flag bit and the first coding mode, the target coding mode corresponding to the data to be decoded is determined.
可选的,所述第一编码方式包括游程编码、原始数据编码、残差编码和混合编码中的一种或多种;Optionally, the first coding mode includes one or more of run-length coding, original data coding, residual coding, and hybrid coding;
其中,所述混合编码为对待编码数据块进行划分生成多个数据子块,对每一所述数据字块进行残差编码或原始数据编码。Wherein, the hybrid coding is to divide the data block to be coded to generate multiple data sub-blocks, and perform residual coding or original data coding on each of the data blocks.
可选的,所述残差编码为以所述待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据。Optionally, the residual coding is using data at a preset position in the data block to be coded as reference data, respectively calculating the residual values of every two adjacent data on both sides of the reference data, and calculating The residual value and the reference data are written into the coded stream data according to the code stream structure corresponding to the residual coding mode.
可选的,所述目标解码方式包括:游程解码、原始数据拷贝、残差解码和混合解码中的一种或多种;Optionally, the target decoding mode includes one or more of run-length decoding, original data copy, residual decoding, and hybrid decoding;
其中,所述混合解码为对所述待解码数据块进行划分生成多个数据子块,对每一所述数据字块进行残差解码或原始数据拷贝。Wherein, the hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks, and perform residual decoding or original data copy on each of the data word blocks.
可选的,所述残差解码为从所述待解码数据的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据、残差值所占的位长和残差值执行残差计算的逆运算,生成解码数据。Optionally, the residual decoding is to read the corresponding reference data, the bit length occupied by the residual value, and the residual value from the code stream structure of the data to be decoded, according to the reference data and the residual value The occupied bit length and residual value perform the inverse operation of residual calculation to generate decoded data.
可选的,当所述目标解码方式为游程解码时,所述使用所述目标解码 方式对所述待解码数据进行解码,包括:Optionally, when the target decoding mode is run-length decoding, the using the target decoding mode to decode the data to be decoded includes:
从所述待解码数据的码流结构中读取起始值和游程长度,根据所述起始值和游程长度将所述待解码数据进行解码还原,得到解码数据。The start value and the run length are read from the code stream structure of the data to be decoded, and the data to be decoded is decoded and restored according to the start value and the run length to obtain decoded data.
可选的,当所述目标解码方式为原数据拷贝时,所述使用所述目标解码方式对所述待解码数据进行解码,包括:Optionally, when the target decoding mode is a copy of the original data, the using the target decoding mode to decode the data to be decoded includes:
从所述待解码数据的码流结构中读取对应的编码后的数据,将所述编码后的数据进行拷贝,得到解码数据。Reading the corresponding encoded data from the code stream structure of the data to be decoded, and copying the encoded data to obtain decoded data.
可选的,当所述目标解码方式为残差解码时,所述使用所述目标解码方式对所述待解码数据进行解码,包括:Optionally, when the target decoding mode is residual decoding, the using the target decoding mode to decode the data to be decoded includes:
从所述待解码数据的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据和残差值执行残差计算的逆运算,得到原数据。Read the corresponding reference data, the bit length occupied by the residual value and the residual value from the code stream structure of the data to be decoded, and perform the inverse operation of the residual calculation according to the reference data and the residual value to obtain the original data.
可选的,所述使用所述目标解码方式对多所述待解码数据进行解码,生成解码数据,包括:Optionally, the decoding multiple pieces of to-be-decoded data to generate decoded data using the target decoding manner includes:
若通过所述目标解码方式对所述待解码数据进行解码得到的数据的数据量大于预设数据量时,将超出所述预设数据量的部分数据丢弃,生成所述解码数据。If the data amount of the data obtained by decoding the data to be decoded by the target decoding method is greater than the preset data amount, discarding part of the data exceeding the preset data amount to generate the decoded data.
图20也给出了一种解码器的架构示意图,该解码器中主要包括以下功能模块:模式解析模块(用于确定目标解码方式)、游程解码模块,残差解码模块和原始数据解码模块。需要说明的是,本实施例中仅为举例说明,不应当看作是本发明的限定。Figure 20 also shows a schematic diagram of the architecture of a decoder. The decoder mainly includes the following functional modules: a pattern analysis module (used to determine the target decoding method), a run-length decoding module, a residual decoding module, and an original data decoding module. It should be noted that this embodiment is only an example and should not be regarded as a limitation of the present invention.
本发明又一实施例中也提供了一种解码器,该解码器包括:解析电路和解码电路。Another embodiment of the present invention also provides a decoder, which includes: a parsing circuit and a decoding circuit.
其中,解析电路用于对待解码数据块进行解析,获取待解码数据块中的参考数据和残差数据;其中,所述待解码数据块由对原始数据块进行编码生成;所述参考数据为所述原始数据中预设位置的数据;所述残差数据为在编码过程中,位于所述参考数据两侧的每相邻两个数据的残差值。解 码电路用于将所述参考数据和所述残差数据进行递减运算或累加运算,生成所述参考数据两侧的原始数据Wherein, the parsing circuit is used to analyze the data block to be decoded to obtain reference data and residual data in the data block to be decoded; wherein the data block to be decoded is generated by encoding the original data block; and the reference data is all The data at a preset position in the original data; the residual data is the residual value of every two adjacent data located on both sides of the reference data during the encoding process. The decoding circuit is used to decrement or accumulate the reference data and the residual data to generate original data on both sides of the reference data
对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。For the device embodiment, since it basically corresponds to the method embodiment, the relevant part can refer to the part of the description of the method embodiment. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the objectives of the solutions of the embodiments. Those of ordinary skill in the art can understand and implement it without creative work.
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply one of these entities or operations. There is any such actual relationship or order between. The terms "include", "include", or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements that are not explicitly listed. Elements, or also include elements inherent to such processes, methods, articles, or equipment. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other same elements in the process, method, article, or equipment including the element.
以上对本发明实施例所提供的方法和装置进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。The methods and devices provided by the embodiments of the present invention are described in detail above. Specific examples are used in this article to illustrate the principles and implementations of the present invention. The descriptions of the above embodiments are only used to help understand the methods and methods of the present invention. Core idea; At the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation and the scope of application. In summary, the content of this specification should not be construed as a limitation of the present invention .

Claims (81)

  1. 一种数据处理的方法,其特征在于,包括:A data processing method, characterized in that it comprises:
    获取多个第一编码方式对于待编码数据块的编码开销,从所述多个第一编码方式中确定编码开销最小的目标编码方式;Acquiring the coding overhead of the multiple first coding modes for the data block to be coded, and determining the target coding mode with the smallest coding overhead from the multiple first coding modes;
    通过所述目标编码方式对所述待编码数据块进行编码。Encoding the data block to be encoded by the target encoding method.
  2. 根据权利要求1所述的方法,其特征在于,所述编码开销为所述待编码数据块进行编码后生成的码流数据所占的位宽。The method according to claim 1, wherein the encoding overhead is the bit width occupied by the code stream data generated after the data block to be encoded is encoded.
  3. 根据权利要求1所述的方法,其特征在于,所述方法,还包括:The method according to claim 1, wherein the method further comprises:
    确定原始数据块中是否存在冗余数据块,若是,则对所述冗余数据块按照第二编码方式进行编码;Determine whether there is a redundant data block in the original data block, and if so, encode the redundant data block according to the second encoding mode;
    将所述原始数据块中除掉所述冗余数据块的剩余数据块作为所述待编码数据块。Use the remaining data blocks in the original data blocks except for the redundant data blocks as the data blocks to be encoded.
  4. 根据权利要求1所述的方法,其特征在于,所述待编码数据块通过以下方式生成:The method according to claim 1, wherein the data block to be encoded is generated in the following manner:
    确定原始数据块中是否存在冗余数据块,若是,则获取所述原始数据块中除掉所述冗余数据块的剩余数据块;Determine whether there is a redundant data block in the original data block, and if so, obtain the remaining data block in the original data block excluding the redundant data block;
    将所述剩余数据块按照指定大小划分得到多个数据块,将每一数据块作为所述待编码数据块。Divide the remaining data blocks according to a specified size to obtain multiple data blocks, and use each data block as the data block to be encoded.
  5. 根据权利要求3或4所述的方法,其特征在于,所述确定原始数据块中是否存在冗余数据块,包括:The method according to claim 3 or 4, wherein the determining whether there is a redundant data block in the original data block comprises:
    查找所述原始数据块中是否有连续出现且重复次数大于预设值的数据,若有,则确定存在冗余数据块,并将该连续的数据作为所述冗余数据块;若否,则确定不存在冗余数据块。Find out whether there is data that continuously appears in the original data block and the number of repetitions is greater than a preset value, if so, determine that there is a redundant data block, and use the continuous data as the redundant data block; Make sure that there are no redundant data blocks.
  6. 根据权利要求3所述的方法,其特征在于,所述第二编码方式包括游程编码,所述对所述冗余数据块按照第二编码方式进行编码,包括:The method according to claim 3, wherein the second coding mode comprises run-length coding, and the coding of the redundant data block according to the second coding mode comprises:
    将所述冗余数据块按照游程编码所对应的码流结构,写入编码后的码流数据;所述游程编码所对应的码流结构包括:编码方式的标志位、起始值和游程长度。The redundant data block is written into the coded stream data according to the code stream structure corresponding to the run-length encoding; the code stream structure corresponding to the run-length encoding includes: the flag bit of the encoding mode, the start value and the run length .
  7. 根据权利要求1所述的方法,其特征在于,所述多个第一编码方式,包括:原始编码方式、残差编码方式以及混合编码方式;其中,所述混合编码方式为对所述待编码数据块进行划分分成若干数据子块后,对每一所述数据字块进行残差编码或原始编码。The method according to claim 1, wherein the multiple first coding modes include: an original coding mode, a residual coding mode, and a mixed coding mode; wherein, the mixed coding mode is for the to-be-coded After the data block is divided into several data sub-blocks, residual coding or original coding is performed on each data block.
  8. 根据权利要求7所述的方法,其特征在于,当所述目标编码方式为原始编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:8. The method according to claim 7, wherein when the target coding mode is an original coding mode, the encoding the data block to be coded by the target coding mode comprises:
    将所述待编码数据块中的原始数据按照所述原始编码方式对应的码流结构,写入编码后的码流数据;Writing the original data in the data block to be coded into the coded code stream data according to the code stream structure corresponding to the original coding mode;
    其中,所述原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。Wherein, the code stream structure corresponding to the original coding mode includes: a flag bit of the coding mode and original data.
  9. 根据权利要求7所述的方法,其特征在于,当所述目标编码方式为所述残差编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:8. The method according to claim 7, wherein when the target coding mode is the residual coding mode, the encoding the data block to be coded by the target coding mode comprises:
    以所述待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in the data block to be encoded as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
    将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据;Writing the residual value and the reference data into the coded stream data according to the code stream structure corresponding to the residual coding mode;
    其中,所述残差编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the residual coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  10. 根据权利要求7所述的方法,其特征在于,当所述目标编码方式为混合编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:8. The method according to claim 7, wherein when the target encoding method is a hybrid encoding method, the encoding the data block to be encoded by the target encoding method comprises:
    将所述待编码数据块划分得到至少两个数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks;
    以任一所述数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in any of the data sub-blocks as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
    分别将每个所述数据子块计算得到的残差值和所述参考数据按照所述混合编码方式对应的码流结构写入编码后的码流数据;Respectively writing the residual value calculated for each of the data sub-blocks and the reference data into the coded code stream data according to the code stream structure corresponding to the hybrid coding mode;
    其中,所述混合编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the hybrid coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  11. 根据权利要求7所述的方法,其特征在于,当所述目标编码方式为混合编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:8. The method according to claim 7, wherein when the target encoding method is a hybrid encoding method, the encoding the data block to be encoded by the target encoding method comprises:
    将所述待编码数据块划分得到至少两个数据子块;其中,所述至少两个数据字块包括第一数据子块和第二数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks; wherein the at least two data word blocks include a first data sub-block and a second data sub-block;
    以所述第一数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据;=将所述第二数据子块中的原始数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据;Using the data at a preset position in the first data sub-block as reference data, the residual values of each two adjacent data located on both sides of the reference data are respectively calculated, and the residual value and the reference data Write the encoded code stream data according to the code stream structure corresponding to the hybrid encoding method; = write the original data in the second data sub-block into the code stream structure corresponding to the hybrid encoding method Stream data;
    其中,所述混合编码方式所对应的码流结构包括:编码方式的标志位、所述第二数据块的原始数据、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the hybrid coding mode includes: the flag bit of the coding mode, the original data of the second data block, the reference data, the bit width occupied by the residual value, and the residual value. Difference.
  12. 根据权利要求4所述的方法,其特征在于,在所述将所述剩余数据块按照指定大小划分得到多个数据块之前,包括:The method according to claim 4, wherein before the dividing the remaining data blocks according to a specified size to obtain multiple data blocks, the method comprises:
    如果所述剩余数据块的数据量不满足为所述指定大小的整数倍,则对所述剩余数据块进行数据填充,以使划分后得到每个数据块的大小为均为指定大小。If the data amount of the remaining data block does not satisfy an integer multiple of the specified size, data padding is performed on the remaining data block so that the size of each data block obtained after division is the specified size.
  13. 根据权利要求12所述的方法,其特征在于,所述对所述剩余数据块进行数据填充,包括:The method according to claim 12, wherein the performing data filling on the remaining data block comprises:
    复制N个所述剩余数据块中的末尾数据,利用复制的N个数据对所述剩余数据块进行填充,以使得所述剩余数据块的数据量为所述指定大小的整数倍;其中,所述N大于等于1。Copy the last data in the N remaining data blocks, and fill the remaining data blocks with the copied N data so that the data amount of the remaining data blocks is an integer multiple of the specified size; wherein, Said N is greater than or equal to 1.
  14. 一种数据处理方法,其特征在于,包括:A data processing method, characterized by comprising:
    对待解码数据进行解析,确定多个预设的第一编码方式中与所述待解码数据对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;Parsing the data to be decoded, determining a target encoding method corresponding to the data to be decoded among a plurality of preset first encoding methods, and determining a corresponding target decoding method according to the target encoding method;
    通过所述目标解码方式对所述待解码数据进行解码,生成解码数据。The data to be decoded is decoded by the target decoding mode to generate decoded data.
  15. 根据权利要求14所述的方法,其特征在于,所述待解码数据包括标志位;所述对待解码数据进行解析,确定多个预设的第一编码方式中与所述待解码数据对应的目标编码方式包括:The method according to claim 14, wherein the data to be decoded includes a flag bit; the data to be decoded is parsed to determine a target corresponding to the data to be decoded in a plurality of preset first encoding methods Encoding methods include:
    根据预设的所述标志位的数值和所述第一编码方式的映射关系,确定出与所述待解码数据对应的目标编码方式。According to the preset mapping relationship between the value of the flag bit and the first coding mode, the target coding mode corresponding to the data to be decoded is determined.
  16. 根据权利要求14所述的方法,其特征在于,所述第一编码方式包括游程编码、原始数据编码、残差编码和混合编码中的一种或多种;The method according to claim 14, wherein the first coding mode comprises one or more of run-length coding, original data coding, residual coding and hybrid coding;
    其中,所述混合编码为对待编码数据块进行划分生成多个数据子块,对每一所述数据字块进行残差编码或原始数据编码。Wherein, the hybrid coding is to divide the data block to be coded to generate multiple data sub-blocks, and perform residual coding or original data coding on each of the data blocks.
  17. 根据权利要求16所述的方法,其特征在于,所述残差编码为以所述待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据。The method according to claim 16, wherein the residual coding is to use data at a preset position in the data block to be coded as reference data, and respectively calculate every two adjacent ones located on both sides of the reference data. The residual value of each data, the residual value and the reference data are written into the coded code stream data according to the code stream structure corresponding to the residual coding mode.
  18. 根据权利要求16所述的方法,其特征在于,所述目标解码方式包括:游程解码、原始数据拷贝、残差解码和混合解码中的一种或多种;The method according to claim 16, wherein the target decoding mode comprises one or more of run-length decoding, original data copy, residual decoding and hybrid decoding;
    其中,所述混合解码为对所述待解码数据块进行划分生成多个数据子块,对每一所述数据字块进行残差解码或原始数据拷贝。Wherein, the hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks, and perform residual decoding or original data copy on each of the data word blocks.
  19. 根据权利要求18所述的方法,其特征在于,所述残差解码为从所述待解码数据的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据、残差值所占的位长和残差值执行残差计算的逆运算,生成解码数据。The method according to claim 18, wherein the residual decoding comprises reading the corresponding reference data, the bit length occupied by the residual value and the residual value from the code stream structure of the data to be decoded, Perform the inverse operation of the residual calculation according to the reference data, the bit length occupied by the residual value and the residual value to generate decoded data.
  20. 根据权利要求18所述的方法,其特征在于,当所述目标解码方式为游程解码时,所述使用所述目标解码方式对所述待解码数据进行解码,包括:The method according to claim 18, wherein when the target decoding mode is run-length decoding, the using the target decoding mode to decode the data to be decoded comprises:
    从所述待解码数据的码流结构中读取起始值和游程长度,根据所述起始值和游程长度将所述待解码数据进行解码还原,得到解码数据。The start value and the run length are read from the code stream structure of the data to be decoded, and the data to be decoded is decoded and restored according to the start value and the run length to obtain decoded data.
  21. 根据权利要求18所述的方法,其特征在于,当所述目标解码方式为原数据拷贝时,所述使用所述目标解码方式对所述待解码数据进行解码,包括:The method according to claim 18, wherein when the target decoding mode is a copy of the original data, the decoding the data to be decoded using the target decoding mode comprises:
    从所述待解码数据的码流结构中读取对应的编码后的数据,将所述编码后的数据进行拷贝,得到解码数据。Reading the corresponding encoded data from the code stream structure of the data to be decoded, and copying the encoded data to obtain decoded data.
  22. 根据权利要求19所述的方法,其特征在于,当所述目标解码方式为残差解码时,所述使用所述目标解码方式对所述待解码数据进行解码,包括:The method according to claim 19, wherein when the target decoding mode is residual decoding, the decoding the data to be decoded using the target decoding mode comprises:
    从所述待解码数据的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据和残差值执行残差计算的逆运算,得到原数据。Read the corresponding reference data, the bit length occupied by the residual value and the residual value from the code stream structure of the data to be decoded, and perform the inverse operation of the residual calculation according to the reference data and the residual value to obtain the original data.
  23. 根据权利要求14所述的方法,其特征在于,所述使用所述目标解码方式对多所述待解码数据进行解码,生成解码数据,包括:The method according to claim 14, wherein said using said target decoding mode to decode a plurality of said data to be decoded to generate decoded data comprises:
    若通过所述目标解码方式对所述待解码数据进行解码得到的数据的数据量大于预设数据量时,将超出所述预设数据量的部分数据丢弃,生成所述解码数据。If the data amount of the data obtained by decoding the data to be decoded by the target decoding method is greater than the preset data amount, discarding part of the data exceeding the preset data amount to generate the decoded data.
  24. 一种数据处理的方法,其特征在于,包括:A data processing method, characterized in that it comprises:
    以待编码数据块中处于预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in the data block to be encoded as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
    将所述残差值和所述参考数据写入编码后的码流数据。The residual value and the reference data are written into the coded stream data.
  25. 根据权利要求24所述的方法,其特征在于,所述待编码数据块通过以下方式生成:The method according to claim 24, wherein the data block to be encoded is generated in the following manner:
    将原始数据块按照指定大小进行划分得到多个数据子块,将每一所述数据子块作为所述待编码数据块。The original data block is divided according to a specified size to obtain multiple data sub-blocks, and each of the data sub-blocks is used as the data block to be encoded.
  26. 根据权利要求24所述的方法,其特征在于,所述待编码数据块通 过以下方式生成:The method according to claim 24, wherein the data block to be encoded is generated in the following manner:
    将原始数据块按照指定大小进行划分得到多个数据子块,将所述多个数据块中的第一数据块作为所述待编码数据块。The original data block is divided according to a specified size to obtain multiple data sub-blocks, and the first data block of the multiple data blocks is used as the data block to be encoded.
  27. 根据权利要求26所述的方法,其特征在于,还包括:The method according to claim 26, further comprising:
    将所述多个数据子块除所述第一数据块外的其他数据块按照原始编码方式对应的码流结构,写入编码后的码流数据;所述原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。The other data blocks of the multiple data sub-blocks except the first data block are written into the code stream data according to the code stream structure corresponding to the original coding mode; the code stream structure corresponding to the original coding mode includes : Flag bit and original data of encoding method.
  28. 一种数据处理方法,其特征在于,包括:A data processing method, characterized by comprising:
    对待解码数据块进行解析,获取待解码数据块中的参考数据和残差数据;;Analyze the data block to be decoded, and obtain the reference data and residual data in the data block to be decoded;
    将所述参考数据和所述残差数据进行递减运算或累加运算,对所述待解码数据块进行解码操作,生成所述参考数据两侧的原始数据。Perform a decrement operation or an accumulation operation on the reference data and the residual data, perform a decoding operation on the data block to be decoded, and generate original data on both sides of the reference data.
  29. 一种数据处理方法,其特征在于,应用于依次连接的配置器、存储器和处理器,包括:A data processing method, characterized in that it is applied to a configurator, a memory and a processor connected in sequence, and includes:
    通过所述配置器对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流,并将所述压缩码流写入所述存储器,以降低对所述存储器的写带宽;Performing compression encoding on the data block to be encoded formed by the preset data by the configurator to generate a compressed code stream, and writing the compressed code stream into the memory, so as to reduce the write bandwidth to the memory;
    通过所述处理器读取所述存储器内的压缩码流,并对所述压缩码流进行解压缩处理,以降低对所述存储器的读带宽。The processor reads the compressed code stream in the memory and performs decompression processing on the compressed code stream to reduce the read bandwidth of the memory.
  30. 根据权利要求29所述的方法,其特征在于,所述配置器上设有编码器,所述处理器上设有解码器;The method according to claim 29, wherein an encoder is provided on the configurator, and a decoder is provided on the processor;
    所述配置器通过所述编码器对所述待编码数据块进行压缩编码生成压缩码流,所述处理器通过所述解码器对所述压缩码流进行解压缩处理。The configurator compresses and encodes the data block to be encoded by the encoder to generate a compressed code stream, and the processor performs decompression processing on the compressed code stream through the decoder.
  31. 根据权利要求29所述的方法,其特征在于,所述预设数据为基于一卷积神经网络的权重数据;所述配置器用于分配所述权重数据,并将对所述权重数据进行压缩编码得到的压缩码流写入存储器中;所述处理器用于从所述存储器中读取所述权重数据对应的压缩码流,对所述压缩码流进行解压缩处理生成所述权重数据,并基于所述权重数据运行所述卷积神经网络。The method according to claim 29, wherein the preset data is weight data based on a convolutional neural network; the configurator is used to allocate the weight data, and compress and encode the weight data The obtained compressed code stream is written into the memory; the processor is used to read the compressed code stream corresponding to the weight data from the memory, decompress the compressed code stream to generate the weight data, and generate the weight data based on The weight data runs the convolutional neural network.
  32. 根据权利要求31所述的方法,其特征在在于,所述处理器还包括静态随机存取存储器,所述静态随机存取存储器用于从所述存储器中读取所述权重数据对应的压缩码流,以使得所述处理器能够对所述压缩码流进行解压缩处理生成所述权重数据,并基于所述权重数据运行所述卷积神经网络。The method according to claim 31, wherein the processor further comprises a static random access memory, and the static random access memory is used to read the compression code corresponding to the weight data from the memory Flow, so that the processor can decompress the compressed code stream to generate the weight data, and run the convolutional neural network based on the weight data.
  33. 根据权利要求29所述的方法,其特征在于,所述配置器对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流,包括:The method according to claim 29, wherein the configurator compresses and encodes the to-be-encoded data block composed of preset data to generate a compressed code stream, comprising:
    所述配置器获取多个第一编码方式对于所述待编码数据块的编码开销,从所述多个第一编码方式中确定编码开销最小的目标编码方式;The configurator obtains the coding overhead of the plurality of first coding modes for the data block to be coded, and determines a target coding mode with the smallest coding overhead from the plurality of first coding modes;
    通过所述目标编码方式对所述待编码数据块进行编码,得到压缩码流。Encoding the data block to be encoded by the target encoding method to obtain a compressed code stream.
  34. 根据权利要求33所述方法,其特征在于,所述编码开销为所述待编码数据块进行编码后生成的码流数据所占的位宽。The method according to claim 33, wherein the encoding overhead is the bit width occupied by the code stream data generated after the data block to be encoded is encoded.
  35. 根据权利要求33所述的方法,其特征在于,所述方法,还包括:The method of claim 33, wherein the method further comprises:
    所述配置器确定原始数据块中是否存在冗余数据块,若是,则对所述冗余数据块按照第二编码方式进行编码;The configurator determines whether there is a redundant data block in the original data block, and if so, encodes the redundant data block according to the second encoding mode;
    将所述原始数据块中除掉所述冗余数据块的剩余数据块作为所述待编码数据块。Use the remaining data blocks in the original data blocks except for the redundant data blocks as the data blocks to be encoded.
  36. 根据权利要求33所述的方法,其特征在于,所述待编码数据块通过以下方式生成:The method according to claim 33, wherein the data block to be encoded is generated in the following manner:
    所述配置器确定原始数据块中是否存在冗余数据块,若是,则获取所述原始数据块中除掉所述冗余数据块的剩余数据块;The configurator determines whether there is a redundant data block in the original data block, and if so, obtains the remaining data block in the original data block excluding the redundant data block;
    将所述剩余数据块按照指定大小划分得到多个数据块,将每一数据块作为所述待编码数据块。Divide the remaining data blocks according to a specified size to obtain multiple data blocks, and use each data block as the data block to be encoded.
  37. 根据权利要求35或36所述的方法,其特征在于,所述配置器确定原始数据块中是否存在冗余数据块,包括:The method according to claim 35 or 36, wherein the configurator determining whether there is a redundant data block in the original data block comprises:
    所述配置器查找所述原始数据块中是否有连续出现且重复次数大于预设值的数据,若有,则确定存在冗余数据块,并将该连续的数据作为所述冗余数据块;若否,则确定不存在冗余数据块。The configurator searches the original data block whether there is data that continuously appears and the number of repetitions is greater than a preset value, if so, determines that there is a redundant data block, and uses the continuous data as the redundant data block; If not, it is determined that there is no redundant data block.
  38. 根据权利要求35所述的方法,其特征在于,所述第二编码方式包括游程编码,所述对所述冗余数据块按照第二编码方式进行编码,包括:The method according to claim 35, wherein the second coding mode comprises run-length coding, and the coding of the redundant data block according to the second coding mode comprises:
    将所述冗余数据块按照游程编码所对应的码流结构,写入编码后的码流数据;所述游程编码所对应的码流结构包括:编码方式的标志位、起始值和游程长度。The redundant data block is written into the coded stream data according to the code stream structure corresponding to the run-length encoding; the code stream structure corresponding to the run-length encoding includes: the flag bit of the encoding mode, the start value and the run length .
  39. 根据权利要求33所述的方法,其特征在于,所述多个第一编码方式,包括:原始编码方式、残差编码方式以及混合编码方式;其中,所述混合编码方式为对所述待编码数据块进行划分分成若干数据子块后,对每一所述数据字块进行残差编码或原始编码。The method according to claim 33, wherein the multiple first coding modes include: an original coding mode, a residual coding mode, and a mixed coding mode; wherein, the mixed coding mode is for the to-be-coded After the data block is divided into several data sub-blocks, residual coding or original coding is performed on each data block.
  40. 根据权利要求39所述的方法,其特征在于,当所述目标编码方式为原始编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:The method according to claim 39, wherein when the target coding mode is an original coding mode, the encoding the data block to be coded by the target coding mode comprises:
    将所述待编码数据块中的原始数据按照所述原始编码方式对应的码流结构,写入编码后的码流数据;Writing the original data in the data block to be coded into the coded code stream data according to the code stream structure corresponding to the original coding mode;
    其中,所述原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。Wherein, the code stream structure corresponding to the original coding mode includes: a flag bit of the coding mode and original data.
  41. 根据权利要求39所述的方法,其特征在于,当所述目标编码方式为所述残差编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:The method according to claim 39, wherein when the target coding mode is the residual coding mode, the encoding the data block to be coded by the target coding mode comprises:
    以所述待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据;Using the data at a preset position in the data block to be encoded as reference data, the residual values of each two adjacent data located on both sides of the reference data are calculated respectively, and the residual value and the reference data are calculated according to The code stream structure corresponding to the residual coding method is written into the coded code stream data;
    其中,所述残差编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the residual coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  42. 根据权利要求39所述的方法,其特征在于,当所述目标编码方式为混合编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:The method according to claim 39, wherein when the target coding mode is a hybrid coding mode, the encoding the data block to be coded by the target coding mode comprises:
    将所述待编码数据块划分得到至少两个数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks;
    以任一所述数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in any of the data sub-blocks as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
    分别将每个所述数据子块计算得到的残差值和所述参考数据按照所述混合编码方式对应的码流结构写入编码后的码流数据;Respectively writing the residual value calculated for each of the data sub-blocks and the reference data into the coded code stream data according to the code stream structure corresponding to the hybrid coding mode;
    其中,所述混合编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the hybrid coding mode includes: a flag bit of the coding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  43. 根据权利要求39所述的方法,其特征在于,当所述目标编码方式为混合编码方式时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:The method according to claim 39, wherein when the target coding mode is a hybrid coding mode, the encoding the data block to be coded by the target coding mode comprises:
    将所述待编码数据块划分得到至少两个数据子块;其中,所述至少两个数据字块包括第一数据子块和第二数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks; wherein the at least two data word blocks include a first data sub-block and a second data sub-block;
    以所述第一数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据;将所述第二数据子块中的原始数据按照所述混合编码方式所对应的码流结构,写入编码后的码流数据;Using the data at a preset position in the first data sub-block as reference data, the residual values of each two adjacent data located on both sides of the reference data are respectively calculated, and the residual value and the reference data Write the encoded code stream data according to the code stream structure corresponding to the hybrid encoding method; write the original data in the second data sub-block into the code stream structure corresponding to the hybrid encoding method Stream data;
    其中,所述混合编码方式所对应的码流结构包括:编码方式的标志位、所述第二数据块的原始数据、所述残差值、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the hybrid coding mode includes: the flag bit of the coding mode, the original data of the second data block, the residual value, the reference data, and the residual value Bit width and the residual value.
  44. 根据权利要求36所述的方法,其特征在于,在所述将所述剩余数据块按照指定大小划分得到多个数据块之前,包括:The method according to claim 36, wherein before the dividing the remaining data blocks according to a specified size to obtain multiple data blocks, the method comprises:
    如果所述剩余数据块的数据量不满足为所述指定大小的整数倍,则对所述剩余数据块进行数据填充,以使划分后得到每个数据块的大小为均为指定大小。If the data amount of the remaining data block does not satisfy an integer multiple of the specified size, data padding is performed on the remaining data block so that the size of each data block obtained after division is the specified size.
  45. 根据权利要求44所述的方法,其特征在于,所述对所述剩余数据块进行数据填充,包括:The method according to claim 44, wherein the performing data padding on the remaining data block comprises:
    复制N个所述剩余数据块中的末尾数据,利用复制的N个数据对所述剩余数据块进行填充,以使得所述剩余数据块的数据量为所述指定大小的整数倍;其中,所述N大于等于1。Copy the last data in the N remaining data blocks, and fill the remaining data blocks with the copied N data so that the data amount of the remaining data blocks is an integer multiple of the specified size; wherein, Said N is greater than or equal to 1.
  46. 根据权利要求29所述的方法,其特征在于,所述处理器读取所述存储器内的压缩码流,并对所述压缩码流进行解压缩处理,包括:The method according to claim 29, wherein the processor reads the compressed code stream in the memory, and performs decompression processing on the compressed code stream, comprising:
    所述处理器对所述压缩码流进行解析,确定多个预设的第一编码方式中与所述压缩码流对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;The processor parses the compressed code stream, determines a target encoding method corresponding to the compressed code stream among a plurality of preset first encoding methods, and determines a corresponding target decoding method according to the target encoding method;
    通过所述目标解码方式对所述压缩码流进行解码,得到所述预设数据。The compressed code stream is decoded by the target decoding method to obtain the preset data.
  47. 根据权利要求46所述的方法,其特征在于,所述压缩码流的码流结构中包括标志位;The method of claim 46, wherein the bit stream structure of the compressed bit stream includes a flag bit;
    所述对所述压缩码流进行解析,确定多个预设的第一编码方式中与所述压缩码流对应的目标编码方式,包括:The parsing the compressed code stream to determine the target encoding method corresponding to the compressed code stream among the plurality of preset first encoding methods includes:
    根据预设的所述标志位的数值和所述第一编码方式的映射关系,确定出与所述压缩码流对应的目标编码方式。According to the preset mapping relationship between the value of the flag bit and the first coding mode, the target coding mode corresponding to the compressed code stream is determined.
  48. 根据权利要求46所述的方法,其特征在于,所述目标解码方式包括:游程解码、原始数据拷贝、残差解码和混合解码中的任意一种或多种;The method according to claim 46, wherein the target decoding mode comprises any one or more of run-length decoding, original data copy, residual decoding, and hybrid decoding;
    其中,所述混合解码为对所述待解码数据块进行划分生成多个数据子块,对每一所述数据字块进行残差解码或原始数据拷贝。Wherein, the hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks, and perform residual decoding or original data copy on each of the data word blocks.
  49. 根据权利要求48所述的方法,其特征在于,当所述目标解码方式为游程解码时,所述使用所述目标解码方式对所述压缩码流进行解码还原,包括:The method according to claim 48, wherein when the target decoding mode is run-length decoding, the using the target decoding mode to decode and restore the compressed code stream comprises:
    从所述压缩码流的码流结构中读取起始值和游程长度,根据所述起始值和游程长度将所述压缩码流进行解码还原,得到对应的预设数据。The initial value and the run length are read from the code stream structure of the compressed code stream, and the compressed code stream is decoded and restored according to the initial value and the run length to obtain corresponding preset data.
  50. 根据权利要求48所述的方法,其特征在于,当所述目标解码方式为原数据拷贝时,所述使用所述目标解码方式对所述压缩码流进行解码还 原,包括:The method according to claim 48, wherein when the target decoding mode is an original data copy, the using the target decoding mode to decode and restore the compressed code stream comprises:
    从所述压缩码流的码流结构中读取对应的编码后的数据,将所述编码后的数据进行拷贝,得到对应的预设数据。Reading the corresponding coded data from the code stream structure of the compressed code stream, and copying the coded data to obtain corresponding preset data.
  51. 根据权利要求48所述的方法,其特征在于,当所述目标解码方式为残差解码时,所述使用所述目标解码方式对所述压缩码流进行解码还原,包括:The method according to claim 48, wherein when the target decoding mode is residual decoding, the using the target decoding mode to decode and restore the compressed code stream comprises:
    从所述压缩码流的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据、残差值所占的位长和残差值执行残差计算的逆运算,得到对应的预设数据。Read the corresponding reference data, the bit length occupied by the residual value and the residual value from the bit stream structure of the compressed bit stream, and execute according to the reference data, the bit length occupied by the residual value and the residual value The inverse operation of the residual calculation obtains the corresponding preset data.
  52. 根据权利要求44所述的方法,其特征在于,所述使用所述目标解码方式对所述压缩码流进行解码还原,得到所述预设数据,包括:The method according to claim 44, wherein the decoding and restoring the compressed code stream using the target decoding method to obtain the preset data comprises:
    若通过所述目标解码方式对所述压缩码流进行解码还原得到的数据的数据量大于预设数据量时,将超出所述预设数据量的部分数据丢弃,得到所述预设数据。If the data volume of the data obtained by decoding and restoring the compressed code stream by the target decoding method is greater than the preset data volume, discarding part of the data exceeding the preset data volume to obtain the preset data.
  53. 一种数据处理系统,其特征在于,包括:依次连接的配置器、存储器和处理器;A data processing system, characterized by comprising: a configurator, a memory, and a processor connected in sequence;
    所述配置器用于对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流,并将所述压缩码流写入所述存储器,以降低对所述存储器的写带宽;The configurator is used to compress and encode a data block to be encoded formed by preset data to generate a compressed code stream, and write the compressed code stream into the memory, so as to reduce the write bandwidth to the memory;
    所述处理器用于读取所述存储器内的压缩码流,并对所述压缩码流进行解压缩处理,以降低对所述存储器的读带宽。The processor is configured to read the compressed code stream in the memory, and perform decompression processing on the compressed code stream, so as to reduce the read bandwidth of the memory.
  54. 根据权利要求53所述的系统,其特征在于,所述配置器上设有编码器,所述处理器上设有解码器;The system of claim 53, wherein the configurator is provided with an encoder, and the processor is provided with a decoder;
    所述配置器用于通过所述编码器对所述待编码数据块进行压缩编码生成压缩码流,所述处理器用于通过所述解码器对所述压缩码流进行解压缩处理。The configurator is used to compress and encode the data block to be encoded by the encoder to generate a compressed code stream, and the processor is used to perform decompression processing on the compressed code stream by the decoder.
  55. 根据权利要求53所述的系统,其特征在于,所述预设数据为基于一卷积神经网络的权重数据;所述配置器用于分配所述权重数据,并将对所述权重数据进行压缩编码得到的压缩码流写入存储器中;所述处理器用于从所述存储器中读取所述权重数据对应的压缩码流,对所述压缩码流进行解压缩处理生成所述权重数据,并基于所述权重数据运行所述卷积神经网络。The system according to claim 53, wherein the preset data is weight data based on a convolutional neural network; the configurator is used to allocate the weight data and compress and encode the weight data The obtained compressed code stream is written into the memory; the processor is used to read the compressed code stream corresponding to the weight data from the memory, perform decompression processing on the compressed code stream to generate the weight data, and based on The weight data runs the convolutional neural network.
  56. 根据权利要求55所述的系统,其特征在于,所述处理器还包括静态随机存取存储器,所述静态随机存取存储器用于从所述存储器中读取所述权重数据对应的压缩码流,以使得所述处理器能够对所述压缩码流进行解压缩处理生成所述权重数据,并基于所述权重数据运行所述卷积神经网络。The system according to claim 55, wherein the processor further comprises a static random access memory, and the static random access memory is used to read the compressed code stream corresponding to the weight data from the memory , So that the processor can decompress the compressed code stream to generate the weight data, and run the convolutional neural network based on the weight data.
  57. 根据权利要求53所述的系统,其特征在在于,所述配置器具体用于通过以下方式对由预设数据所构成的待编码数据块进行压缩编码生成压缩码流:The system according to claim 53, wherein the configurator is specifically configured to compress and encode the to-be-encoded data block composed of preset data to generate a compressed code stream in the following manner:
    所述配置器获取预设的多个第一编码方式对于所述待编码数据块的编码开销,从所述多个第一编码方式中确定编码开销最小的目标编码方式;The configurator obtains the coding overhead of the plurality of preset first coding modes for the data block to be coded, and determines the target coding mode with the smallest coding overhead from the plurality of first coding modes;
    通过所述目标编码方式对所述待编码数据块进行编码,得到压缩码流。Encoding the data block to be encoded by the target encoding method to obtain a compressed code stream.
  58. 根据权利要求57所述的系统,其特征在于,所述编码开销为所述待编码数据块进行编码后生成的码流数据所占的位宽。The system according to claim 57, wherein the encoding overhead is a bit width occupied by code stream data generated after encoding the data block to be encoded.
  59. 根据权利要求57所述的系统,其特征在于,所述配置器还用于:确定原始数据块中是否存在冗余数据块,若是,则对所述冗余数据块按照第二编码方式进行编码;The system according to claim 57, wherein the configurator is further configured to determine whether there is a redundant data block in the original data block, and if so, to encode the redundant data block according to the second encoding method ;
    将所述原始数据块中除掉所述冗余数据块的剩余数据块作为所述待编码数据块。Use the remaining data blocks in the original data blocks except for the redundant data blocks as the data blocks to be encoded.
  60. 根据权利要求57所述的系统,其特征在于,所述配置器还用于通过以下方式生成待编码数据块:The system according to claim 57, wherein the configurator is further configured to generate the data block to be encoded in the following manner:
    确定原始数据块中是否存在冗余数据块,若是,则获取所述原始数据块中除掉所述冗余数据块的剩余数据块;Determine whether there is a redundant data block in the original data block, and if so, obtain the remaining data block in the original data block excluding the redundant data block;
    将所述剩余数据块按照指定大小划分得到多个数据块,将每一数据块作为所述待编码数据块。Divide the remaining data blocks according to a specified size to obtain multiple data blocks, and use each data block as the data block to be encoded.
  61. 根据权利要求59或60所述的系统,其特征在于,所述配置器具体用于通过以下方式确定原始数据块中是否存在冗余数据块:The system according to claim 59 or 60, wherein the configurator is specifically configured to determine whether there is a redundant data block in the original data block in the following manner:
    查找所述原始数据块中是否有连续出现且重复次数大于预设值的数据,若有,则确定存在冗余数据块,并将该连续的数据作为所述冗余数据块;若否,则确定不存在冗余数据块。Find out whether there is data that continuously appears in the original data block and the number of repetitions is greater than a preset value, if so, determine that there is a redundant data block, and use the continuous data as the redundant data block; Make sure that there are no redundant data blocks.
  62. 根据权利要求59所述的系统,其特征在于,所述第二编码方式包括游程编码,所述配置器具体用于通过以下方式对所述冗余数据块按照第二编码方式进行编码:The system according to claim 59, wherein the second encoding method comprises run-length encoding, and the configurator is specifically configured to encode the redundant data block according to the second encoding method in the following manner:
    将所述冗余数据块按照游程编码所对应的码流结构,写入编码后的码流数据;所述游程编码所对应的码流结构包括:编码方式的标志位、起始值和游程长度。The redundant data block is written into the coded stream data according to the code stream structure corresponding to the run-length encoding; the code stream structure corresponding to the run-length encoding includes: the flag bit of the encoding mode, the start value and the run length .
  63. 根据权利要求57所述的系统,其特征在于,所述多个第一编码方式,包括:原始编码方式、残差编码方式以及混合编码方式;其中,所述混合编码方式为对所述待编码数据块进行划分分成若干数据子块后,对每一所述数据字块进行残差编码或原始编码。The system according to claim 57, wherein the plurality of first coding modes include: an original coding mode, a residual coding mode, and a mixed coding mode; wherein, the mixed coding mode is for the to-be-coded After the data block is divided into several data sub-blocks, residual coding or original coding is performed on each data block.
  64. 根据权利要求63所述的系统,其特征在于,当所述目标编码方式为原始编码方式时,所述配置器具体用于:The system according to claim 63, wherein when the target encoding mode is the original encoding mode, the configurator is specifically configured to:
    将所述待编码数据块中的原始数据按照所述原始编码方式对应的码流结构,写入编码后的码流数据;所述原始编码方式对应的码流结构包括:编码方式的标志位和原始数据。The original data in the data block to be coded is written into the coded stream data according to the code stream structure corresponding to the original coding mode; the code stream structure corresponding to the original coding mode includes: the flag bit of the coding mode and Raw data.
  65. 根据权利要求63所述的系统,其特征在于,当所述目标编码方式为所述残差编码方式时,所述配置器具体用于:The system according to claim 63, wherein when the target coding mode is the residual coding mode, the configurator is specifically configured to:
    以所述待编码数据块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述残差编码方式对应的码流结构写入编码后的码流数据;其中,所述残差编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残差值所占的位宽和所述残差值。Using the data at a preset position in the data block to be encoded as reference data, the residual values of each two adjacent data located on both sides of the reference data are calculated respectively, and the residual value and the reference data are calculated according to The code stream structure corresponding to the residual coding mode is written into the coded code stream data; wherein the code stream structure corresponding to the residual coding mode includes: a flag bit of the coding mode, the reference data, and the residual The bit width occupied by the value and the residual value.
  66. 根据权利要求63所述的系统,其特征在于,当所述目标编码方式为混合编码方式时,所述配置器具体用于:The system according to claim 63, wherein when the target coding mode is a hybrid coding mode, the configurator is specifically configured to:
    将所述待编码数据块划分得到至少两个数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks;
    以任一所述数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;Using data at a preset position in any of the data sub-blocks as reference data, respectively calculating residual values of every two adjacent data located on both sides of the reference data;
    分别将每个所述数据子块计算得到的残差值和所述参考数据按照所述混合编码方式对应的码流结构写入编码后的码流数据;其中,所述混合编码方式对应的码流结构包括:编码方式的标志位、所述参考数据、所述残 差值所占的位宽和所述残差值。The residual value calculated for each data sub-block and the reference data are written into the coded stream data according to the code stream structure corresponding to the hybrid encoding mode; wherein the code corresponding to the hybrid encoding mode The stream structure includes: a flag bit of an encoding mode, the reference data, the bit width occupied by the residual value, and the residual value.
  67. 根据权利要求63所述的系统,其特征在于,当所述目标编码方式为混合编码方式时,所述配置器具体用于:The system according to claim 63, wherein when the target coding mode is a hybrid coding mode, the configurator is specifically configured to:
    将所述待编码数据块划分得到至少两个数据子块;其中,所述至少两个数据字块包括第一数据子块和第二数据子块;Dividing the data block to be encoded to obtain at least two data sub-blocks; wherein the at least two data word blocks include a first data sub-block and a second data sub-block;
    以所述第一数据子块中预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值,将所述残差值和所述参考数据按照所述混合编码方式所对应的码流结构写入编码后的码流数据;将所述第二数据子块中的原始数据按照所述混合编码方式所对应的码流结构,写入编码后的码流数据;Using the data at a preset position in the first data sub-block as reference data, the residual values of each two adjacent data located on both sides of the reference data are respectively calculated, and the residual value and the reference data Write the encoded code stream data according to the code stream structure corresponding to the hybrid encoding method; write the original data in the second data sub-block into the code stream structure corresponding to the hybrid encoding method Stream data;
    其中,所述混合编码方式所对应的码流结构包括:编码方式的标志位、所述第二数据块的原始数据、所述残差值、所述参考数据、所述残差值所占的位宽和所述残差值。Wherein, the code stream structure corresponding to the hybrid coding mode includes: the flag bit of the coding mode, the original data of the second data block, the residual value, the reference data, and the residual value Bit width and the residual value.
  68. 根据权利要求60所述的系统,其特征在于,所述配置器还用于:在所述将所述剩余数据块按照指定大小划分得到多个数据块之前,如果所述剩余数据块的数据量不满足为所述指定大小的整数倍,则对所述剩余数据块进行数据填充,以使划分后得到每个数据块的大小为均为指定大小。The system according to claim 60, wherein the configurator is further configured to: before dividing the remaining data block according to a specified size to obtain multiple data blocks, if the data amount of the remaining data block is If it is not an integer multiple of the specified size, data padding is performed on the remaining data blocks, so that the size of each data block obtained after division is the specified size.
  69. 根据权利要求68所述的系统,其特征在于,所述对所述剩余数据块进行数据填充,包括:The system according to claim 68, wherein said performing data filling on said remaining data block comprises:
    复制N个所述剩余数据块中的末尾数据,利用复制的N个数据对所述剩余数据块进行填充,以使得所述剩余数据块的数据量为所述指定大小的整数倍;其中,所述N大于等于1。Copy the last data in the N remaining data blocks, and fill the remaining data blocks with the copied N data so that the data amount of the remaining data blocks is an integer multiple of the specified size; wherein, Said N is greater than or equal to 1.
  70. 根据权利要求53所述的系统,其特征在于,所述处理器具体用于 通过以下方式读取所述存储器内的压缩码流,并对所述压缩码流进行解压缩处理:The system according to claim 53, wherein the processor is specifically configured to read the compressed code stream in the memory in the following manner, and perform decompression processing on the compressed code stream:
    所述处理器对所述压缩码流进行解析,确定多个预设的第一编码方式中与所述压缩码流对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;The processor parses the compressed code stream, determines a target encoding method corresponding to the compressed code stream among a plurality of preset first encoding methods, and determines a corresponding target decoding method according to the target encoding method;
    通过所述目标解码方式对所述压缩码流进行解码,得到所述预设数据。The compressed code stream is decoded by the target decoding method to obtain the preset data.
  71. 根据权利要求70所述的系统,其特征在于,所述压缩码流的码流结构中包括标志位;The system according to claim 70, wherein the bit stream structure of the compressed bit stream includes a flag bit;
    所述处理器具体用于通过以下方式对所述压缩码流进行解析,确定多个预设的第一编码方式中与所述压缩码流对应的目标编码方式:The processor is specifically configured to parse the compressed code stream in the following manner, and determine a target encoding method corresponding to the compressed code stream among a plurality of preset first encoding methods:
    根据预设的所述标志位的数值和所述第一编码方式的映射关系,获取与所述压缩码流对应的目标编码方式。According to the preset mapping relationship between the value of the flag bit and the first coding mode, the target coding mode corresponding to the compressed code stream is obtained.
  72. 根据权利要求70所述的系统,其特征在于,所述目标解码方式包括:游程解码、原始数据拷贝、残差解码和混合解码中的任意一种;The system according to claim 70, wherein the target decoding mode comprises any one of run-length decoding, original data copy, residual decoding and hybrid decoding;
    其中,所述混合解码为对所述待解码数据块进行划分生成多个数据子块,对每一所述数据字块进行残差解码或原始数据拷贝。Wherein, the hybrid decoding is to divide the data block to be decoded to generate multiple data sub-blocks, and perform residual decoding or original data copy on each of the data word blocks.
  73. 根据权利要求72所述的系统,其特征在于,当所述目标解码方式为游程解码时,所述处理器具体用于:The system according to claim 72, wherein when the target decoding mode is run-length decoding, the processor is specifically configured to:
    从所述压缩码流的码流结构中读取起始值和游程长度,根据所述起始值和游程长度将所述压缩码流进行解码还原,得到对应的预设数据。The initial value and the run length are read from the code stream structure of the compressed code stream, and the compressed code stream is decoded and restored according to the initial value and the run length to obtain corresponding preset data.
  74. 根据权利要求72所述的系统,其特征在于,当所述目标解码方式为原数据拷贝时,所述处理器具体用于:The system according to claim 72, wherein, when the target decoding mode is original data copy, the processor is specifically configured to:
    从所述压缩码流的码流结构中读取对应的编码后的数据,将所述编码 后的数据进行拷贝,得到对应的预设数据。Read the corresponding coded data from the code stream structure of the compressed code stream, and copy the coded data to obtain the corresponding preset data.
  75. 根据权利要求72所述的系统,其特征在于,当所述目标解码方式为残差解码时,所述处理器具体用于:The system according to claim 72, wherein when the target decoding mode is residual decoding, the processor is specifically configured to:
    从所述压缩码流的码流结构中读取对应的参考数据、残差值所占的位长和残差值,根据所述参考数据、残差值所占的位长和残差值执行残差计算的逆运算,得到对应的预设数据。Read the corresponding reference data, the bit length occupied by the residual value and the residual value from the bit stream structure of the compressed bit stream, and execute according to the reference data, the bit length occupied by the residual value and the residual value The inverse operation of the residual calculation obtains the corresponding preset data.
  76. 根据权利要求72所述的系统,其特征在于,所述处理器具体用于通过以下方式使用所述目标解码方式对所述压缩码流进行解码还原,得到所述预设数据,包括:The system according to claim 72, wherein the processor is specifically configured to decode and restore the compressed code stream using the target decoding mode in the following manner to obtain the preset data, comprising:
    若通过所述目标解码方式对所述压缩码流进行解码还原得到的数据的数据量大于预设数据量时,将超出所述预设数据量的部分数据丢弃,得到所述预设数据。If the data volume of the data obtained by decoding and restoring the compressed code stream by the target decoding method is greater than the preset data volume, discarding part of the data exceeding the preset data volume to obtain the preset data.
  77. 一种可移动平台,其特征在于,所述可移动平台包括:A movable platform, characterized in that, the movable platform includes:
    机体;Body
    动力系统,设于所述机体,所述动力系统用于为所述可移动平台提供动力;以及,The power system is provided in the body, and the power system is used to provide power to the movable platform; and,
    如权利要求53-76任一所述的一种数据处理系统。A data processing system according to any one of claims 53-76.
  78. 一种编码器,其特征在于,包括:选择电路和编码电路;An encoder, which is characterized by comprising: a selection circuit and an encoding circuit;
    所述选择电路用于获取多个第一编码方式对于待编码数据块的编码开销,从所述多个第一编码方式中确定编码开销最小的目标编码方式;The selection circuit is configured to obtain the coding overhead of the data block to be coded by the multiple first coding modes, and determine the target coding mode with the smallest coding overhead from the multiple first coding modes;
    所述编码电路通过所述目标编码方式对所述待编码数据块进行编码。The encoding circuit encodes the data block to be encoded by using the target encoding method.
  79. 一种编码器,其特征在于,所述编码器包括:残差计算电路和编 码电路;An encoder, characterized in that the encoder includes: a residual calculation circuit and an encoding circuit;
    所述残差计算电路,用于以待编码数据块中处于预设位置的数据作为参考数据,分别计算位于所述参考数据两侧的每相邻两个数据的残差值;The residual calculation circuit is configured to use the data at a preset position in the data block to be encoded as reference data, and respectively calculate the residual value of every two adjacent data located on both sides of the reference data;
    所述编码电路,用于将所述残差值和所述参考数据按照残差编码方式对应的码流结构写入编码后的码流数据;其中,所述残差编码方式对应的码流结构包括:所述参考数据、所述残差值所占的位宽和所述残差值。The coding circuit is configured to write the residual value and the reference data into the code stream data according to the code stream structure corresponding to the residual coding mode; wherein, the code stream structure corresponding to the residual coding mode Including: the reference data, the bit width occupied by the residual value, and the residual value.
  80. 一种解码器,其特征在于,所述解码器包括:解析电路和解码电路;A decoder, characterized in that the decoder includes: an analysis circuit and a decoding circuit;
    所述解析电路用于对待解码数据进行解析,确定多个预设的第一编码方式中与所述待解码数据对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;The parsing circuit is configured to analyze the data to be decoded, determine a target encoding method corresponding to the data to be decoded among a plurality of preset first encoding methods, and determine a corresponding target decoding method according to the target encoding method;
    所述解码电路用于通过所述目标解码方式对所述待解码数据进行解码,生成解码数据。The decoding circuit is used to decode the data to be decoded by the target decoding mode to generate decoded data.
  81. 一种解码器,其特征在于,所述解码器包括:解析电路和解码电路;A decoder, characterized in that the decoder includes: an analysis circuit and a decoding circuit;
    所述解析电路用于对待解码数据块进行解析,获取待解码数据块中的参考数据和残差数据;将所述参考数据和所述残差数据进行递减运算或累加运算,生成所述参考数据两侧的原始数据。The parsing circuit is used to analyze the data block to be decoded to obtain the reference data and residual data in the data block to be decoded; perform a decrement operation or an accumulation operation on the reference data and the residual data to generate the reference data Raw data on both sides.
PCT/CN2019/097771 2019-07-25 2019-07-25 Data processing method, system, encoder, and decoder WO2021012278A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201980031021.0A CN112119593A (en) 2019-07-25 2019-07-25 Data processing method and system, encoder and decoder
PCT/CN2019/097771 WO2021012278A1 (en) 2019-07-25 2019-07-25 Data processing method, system, encoder, and decoder

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/097771 WO2021012278A1 (en) 2019-07-25 2019-07-25 Data processing method, system, encoder, and decoder

Publications (1)

Publication Number Publication Date
WO2021012278A1 true WO2021012278A1 (en) 2021-01-28

Family

ID=73799650

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/097771 WO2021012278A1 (en) 2019-07-25 2019-07-25 Data processing method, system, encoder, and decoder

Country Status (2)

Country Link
CN (1) CN112119593A (en)
WO (1) WO2021012278A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114071154A (en) * 2021-11-10 2022-02-18 湖南国科微电子股份有限公司 Data decoding method and device, electronic equipment and readable storage medium

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116530079A (en) * 2021-01-08 2023-08-01 深圳市大疆创新科技有限公司 Encoding method, decoding method, encoding device, and decoding device
EP4344200A1 (en) * 2021-06-04 2024-03-27 Huawei Technologies Co., Ltd. Methods and apparatus for encoding and decoding 3d map
CN113596470A (en) * 2021-06-30 2021-11-02 深圳市朗强科技有限公司 Ultra-high-definition video wireless transmitting and receiving method and device applying compression algorithm

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101783953A (en) * 2010-03-08 2010-07-21 北京空间机电研究所 JPEG-LS run length coding hardware implementation method
CN106529670A (en) * 2016-10-27 2017-03-22 中国科学院计算技术研究所 Neural network processor based on weight compression, design method, and chip
CN107995494A (en) * 2017-12-12 2018-05-04 珠海全志科技股份有限公司 The compression method of vedio data and decompressing method, computer installation, computer-readable recording medium
WO2018129614A1 (en) * 2017-01-10 2018-07-19 Blackberry Limited Methods and devices for coding motion vectors in video compression
CN108377033A (en) * 2018-04-20 2018-08-07 国网辽宁省电力有限公司沈阳供电公司 Polling transmission line based on multi-rotor unmanned aerial vehicle compares modification system with line map
CN110049321A (en) * 2018-01-16 2019-07-23 腾讯科技(深圳)有限公司 Method for video coding, device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101783953A (en) * 2010-03-08 2010-07-21 北京空间机电研究所 JPEG-LS run length coding hardware implementation method
CN106529670A (en) * 2016-10-27 2017-03-22 中国科学院计算技术研究所 Neural network processor based on weight compression, design method, and chip
WO2018129614A1 (en) * 2017-01-10 2018-07-19 Blackberry Limited Methods and devices for coding motion vectors in video compression
CN107995494A (en) * 2017-12-12 2018-05-04 珠海全志科技股份有限公司 The compression method of vedio data and decompressing method, computer installation, computer-readable recording medium
CN110049321A (en) * 2018-01-16 2019-07-23 腾讯科技(深圳)有限公司 Method for video coding, device, equipment and storage medium
CN108377033A (en) * 2018-04-20 2018-08-07 国网辽宁省电力有限公司沈阳供电公司 Polling transmission line based on multi-rotor unmanned aerial vehicle compares modification system with line map

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114071154A (en) * 2021-11-10 2022-02-18 湖南国科微电子股份有限公司 Data decoding method and device, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
CN112119593A (en) 2020-12-22

Similar Documents

Publication Publication Date Title
WO2021012278A1 (en) Data processing method, system, encoder, and decoder
CN107565971B (en) Data compression method and device
JP2009509456A (en) Sequential improvement of lattice vector quantization
JP2006126810A (en) Lossless adaptive golomb-rice encoding, and decoding of integer data using backward-adaptive rule
CN106202213B (en) FPGA binary file compression and decompression method and device
US11139827B2 (en) Conditional transcoding for encoded data
US20220224947A1 (en) Coding method and related device
US6567781B1 (en) Method and apparatus for compressing audio data using a dynamical system having a multi-state dynamical rule set and associated transform basis function
KR101870594B1 (en) Coding and decoding of spectral peak positions
JP2003218703A (en) Data coder and data decoder
JP6246233B2 (en) Method and apparatus for vertex error correction
KR100484137B1 (en) Improved huffman decoding method and apparatus thereof
KR20190040063A (en) Quantizer with index coding and bit scheduling
CN104125475A (en) Multi-dimensional quantum data compressing and uncompressing method and apparatus
DE102011100936B4 (en) Techniques for storing and retrieving pixel data
CN112449191A (en) Method for compressing a plurality of images, method and apparatus for decompressing an image
CN116302670A (en) Encoding and decoding method, encoder and decoder, chip, hard disk and communication system
US10931303B1 (en) Data processing system
Jagadeesh et al. An approach for image compression using adaptive Huffman coding
CN111832257A (en) Conditional transcoding of encoded data
JP2001211082A (en) Pcm signal encoding and decoding method
KR100982666B1 (en) Apparatus for decoding and Table search mathod for decoding of Context Adapative Variable Length Coding
WO2014000443A1 (en) Image data compression and decompression method and device
US20240137045A1 (en) Noniterative entropy coding
KR100686354B1 (en) Huffman decoding method and device for using variable length tree

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19938171

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19938171

Country of ref document: EP

Kind code of ref document: A1