WO2018068634A1 - 二进制数据的编码、解码方法和装置 - Google Patents

二进制数据的编码、解码方法和装置 Download PDF

Info

Publication number
WO2018068634A1
WO2018068634A1 PCT/CN2017/103429 CN2017103429W WO2018068634A1 WO 2018068634 A1 WO2018068634 A1 WO 2018068634A1 CN 2017103429 W CN2017103429 W CN 2017103429W WO 2018068634 A1 WO2018068634 A1 WO 2018068634A1
Authority
WO
WIPO (PCT)
Prior art keywords
bit
byte
data
binary data
bytes
Prior art date
Application number
PCT/CN2017/103429
Other languages
English (en)
French (fr)
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
Priority to MX2019004256A priority Critical patent/MX2019004256A/es
Priority to RU2019113976A priority patent/RU2725763C1/ru
Priority to KR1020197013004A priority patent/KR102249267B1/ko
Priority to AU2017342863A priority patent/AU2017342863B2/en
Application filed by 阿里巴巴集团控股有限公司, 徐达峰, 黎三平 filed Critical 阿里巴巴集团控股有限公司
Priority to BR112019007284A priority patent/BR112019007284A2/pt
Priority to CA3040003A priority patent/CA3040003C/en
Priority to MYPI2019001978A priority patent/MY196192A/en
Priority to JP2019519660A priority patent/JP6931050B2/ja
Priority to SG11201903176RA priority patent/SG11201903176RA/en
Priority to EP17860029.2A priority patent/EP3528389A4/en
Publication of WO2018068634A1 publication Critical patent/WO2018068634A1/zh
Priority to US16/380,643 priority patent/US10785277B2/en
Priority to PH12019500783A priority patent/PH12019500783A1/en
Priority to ZA2019/02948A priority patent/ZA201902948B/en
Priority to AU2019101588A priority patent/AU2019101588A4/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/70Media network packetisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/0001Systems modifying transmission characteristics according to link quality, e.g. power backoff
    • H04L1/0014Systems modifying transmission characteristics according to link quality, e.g. power backoff by adapting the source coding
    • 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/02Conversion to or from weighted codes, i.e. the weight given to a digit depending on the position of the digit within the block or code word
    • H03M7/04Conversion to or from weighted codes, i.e. the weight given to a digit depending on the position of the digit within the block or code word the radix thereof being two
    • 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/14Conversion to or from non-weighted codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F5/00Methods or arrangements for data conversion without changing the order or content of the data handled
    • 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
    • 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/3066Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction by means of a mask or a bit-map
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • H04L1/0041Arrangements at the transmitter end
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • H04L1/0045Arrangements at the receiver end
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/75Media network packet handling
    • H04L65/765Media network packet handling intermediate
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]

Definitions

  • the present application relates to the field of network communication technologies, and in particular, to a method and an apparatus for encoding binary data, and a method and apparatus for decoding binary data.
  • Base64 is the most commonly used binary data encoding and decoding technology.
  • Base64 encodes binary data with 64 characters. For N bytes of binary data, each of the corresponding 8*N bits is divided into 1 part, and each part has a value between 0 and 63. The value corresponds to an ASCII (American Standard Code for Information Interchange) character, and all the corresponding ASCII characters are spliced together to obtain Base64 encoding of the binary data.
  • ASCII American Standard Code for Information Interchange
  • Base64 encoded data of 3-byte binary data is 4 bytes, and the file length is increased by about 33% after converting a binary file into a Base64 encoded file.
  • the Base64 encoded binary file increases the traffic used by the transfer by about one-third.
  • reducing the interaction traffic between the server and the user's handheld device is a critical issue for all businesses.
  • Base64 encoded character files are large and difficult to meet the requirements of some demanding application scenarios.
  • the present application provides a method for encoding binary data, including:
  • the length of the binary data is k bytes, and k is a natural number;
  • the k-byte binary data is converted into 7-bit encoded data of (k+t) bytes using a predetermined encoding algorithm, and t is the smallest integer greater than or equal to k divided by 7.
  • a method for decoding binary data provided by the present application includes:
  • the length of the 7-bit encoded data is p bytes, and p is a natural number greater than 1;
  • the p-byte 7-bit encoded data is converted into (p-t) bytes of binary data using a predetermined decoding algorithm, and t is the smallest integer greater than or equal to p divided by 8.
  • the application also provides an encoding device for binary data, comprising:
  • a binary data obtaining unit configured to acquire binary data;
  • the binary data has a length of k bytes, and k is a natural number;
  • a 7-bit coding unit for converting k-byte binary data into (k+t) bytes of 7-bit encoded data using a predetermined encoding algorithm, and t is a minimum integer greater than or equal to k divided by 7.
  • a decoding device for binary data provided by the application includes:
  • a data to be decoded unit configured to acquire 7-bit encoded data to be decoded;
  • the length of the 7-bit encoded data is p bytes, and p is a natural number greater than 1;
  • a 7-bit decoding unit for converting p-bit 7-bit encoded data into (p-t) bytes of binary data using a predetermined decoding algorithm, where t is the smallest integer greater than or equal to p divided by 8.
  • the binary data is 7-bit encoded by using a predetermined encoding algorithm during encoding; when decoding, the 7-bit encoding is restored to binary data by using a predetermined decoding algorithm;
  • the binary data can be converted into 8-byte 7-bit encoded data, and the length of the binary data is increased by about 14.3% after being converted into 7-bit encoded data, so the encoded file obtained by the technical solution of the present application is smaller than the length of the Base64 encoded file. It consumes less traffic when transmitted over the network and can adapt to more demanding application scenarios.
  • FIG. 1 is a flowchart of a method for encoding binary data in an embodiment of the present application
  • FIG. 2 is a flowchart of a method for decoding binary data in an embodiment of the present application
  • FIG. 3 is a schematic diagram of an example of a first predetermined encoding algorithm in the embodiment of the present application.
  • FIG. 4 is a schematic diagram of an example of a second predetermined encoding algorithm in the embodiment of the present application.
  • FIG. 5 is a hardware structural diagram of a device running an embodiment of the present application.
  • FIG. 6 is a logical structural diagram of an apparatus for encoding binary data in an embodiment of the present application.
  • FIG. 7 is a logical structural diagram of a decoding apparatus for binary data in the embodiment of the present application.
  • the characters corresponding to decimal values 0 to 127 can be supported by various network protocols or network applications in network transmission.
  • ASCII encoding UTF-7 (Unicode Transformation Format 7, 7-bit Unicode conversion format), 7-bit monospace coding, and the like. That is to say, after the binary file is converted into the 7-bit encoded file of the above encoding modes, the file transfer can be performed in various applications and based on various protocols.
  • the 7-bit encoding is a coding method that uses the lower 7 bits of one byte to carry data.
  • 7-bit encoding can convert 7-byte binary data into 8-byte encoded data. Converting 3-byte binary data to 4-byte encoding compared to Base64 encoding, the conversion efficiency is higher, the converted encoding The file size is smaller and the transmission traffic is saved.
  • an embodiment of the present application proposes a new binary data encoding method and a corresponding binary data decoding method for converting binary data into 7-bit encoded data and 7-bit encoded data to binary data, respectively.
  • the traffic consumed by the encoded data in the network transmission is saved, thereby solving the problems in the prior art.
  • the embodiment of the present application can be applied to any device having computing and storage capabilities, such as a physical device or a logical device such as a mobile phone, a tablet computer, a PC (Personal Computer), a notebook, a server, a virtual machine, or the like;
  • the functions in the embodiments of the present application are implemented by two or more physical or logical devices that share different responsibilities.
  • the encoding method and the decoding method may be respectively run on different devices or on the same device.
  • Step 110 Obtain binary data.
  • the binary data to be converted may be a binary file or a piece of binary data that is a component of a file, and is not limited.
  • the binary data can be read from a storage location in a certain network, and the binary data to be converted can be obtained from the specified cache.
  • the embodiment of the present application is also not limited.
  • Step 120 Convert k-byte binary data into (k+t) bytes of 7-bit encoded data using a predetermined encoding algorithm, where t is the smallest integer greater than or equal to k divided by 7.
  • the one-bit binary data valid bit is 8 bits
  • the one-bit 7-bit encoded data valid bit is 7 bits. Therefore, when converting binary data into 7-bit encoded data, binary data of 1 to 7 bytes can be expressed by 2 to 8 bytes of 7-bit encoded data, respectively, and the length added after encoding is 1 byte. 8 to 14 bytes of binary data can be expressed by 10 to 16 bytes of 7-bit encoded data, and the length added after encoding is 2 bytes; and so on, k-byte binary data can be obtained by (k) +t) 7-bit encoded data of bytes, t is the smallest integer greater than or equal to k divided by 7. In other words, when converting k-byte binary data into 7-bit encoded data, the added length is t bytes.
  • Any of the algorithms that can map the k-bit binary data one-to-one to the (k+t)-byte 7-bit encoded data can be used as the predetermined encoding algorithm, which is not limited in the embodiment of the present application.
  • the flow of the decoding method of the binary data is as shown in FIG. 2.
  • Step 210 Acquire 7-bit encoded data to be decoded.
  • the 7-bit encoded data to be decoded may be an encoded file, or a 7-bit encoded data that is a component of a file, which is not limited.
  • the 7-bit encoded data can be read from the storage location in a certain network, and the 7-bit encoded data to be decoded can be obtained from the specified cache.
  • the embodiment of the present application is also not limited.
  • the length of the 7-bit encoded data to be decoded is p (p is a natural number greater than 1) bytes.
  • Step 220 converting a p-byte 7-bit encoded data into a (p-t) word by using a predetermined decoding algorithm
  • the binary data of the section, t is the smallest integer greater than or equal to p divided by 8.
  • 2 to 8 bytes of 7-bit encoded data can express 1 to 7 bytes of binary data, respectively, and the reduced length is 1 byte after decoding; 7 to 16 bytes of 7-bit encoding
  • the data can respectively express 8 to 14 bytes of binary data, and the reduced length after decoding is 2 bytes; and so on, the p-byte 7-bit encoded data can express (pt) bytes of binary data, t is greater than or equal to p is the smallest integer of 8.
  • the reduced length is t bytes.
  • An algorithm that can reverse the 7-bit encoded data of p bytes to the binary data of (pt) bytes before encoding, which is inverse to the predetermined encoding algorithm used when converting binary data into 7-bit encoded data, can be used as the algorithm.
  • the predetermined decoding algorithm in the embodiment is applied.
  • encoding can be based on the following idea: one byte of binary data consists of 8 bits, since 7-bit encoding can only use the lower 7 bits of a byte, one byte Binary data requires one byte of 7-bit encoding and one bit of an extra byte.
  • One byte of 8-bit binary data can be split into two parts, and a predetermined bit (which can be any one of bits 0 to 7) is used as 1 bit represented by an extra byte, except The remaining 7 bits outside the pre-location are represented by a one-byte 7-bit code.
  • the other 6 bits in the extra byte can be used to carry the predetermined bits of the other 6 bytes of binary data.
  • every 7 bytes of binary data is increased by 1 byte when mapped to 7-bit encoding, and less than 7 bytes of binary data is also increased by 1 byte when mapping 7-bit encoding, then k bytes Binary data will be incremented by t bytes when mapped to 7-bit encoding.
  • the predetermined encoding algorithm in this implementation may operate by extracting a predetermined bit of each byte in k-byte binary data and combining them into a combination of t-byte 7-bit encoding in a set bit order.
  • Bit data, the remaining 7 bits of each byte in the k-byte binary data are used as the remaining bit data of the k-byte 7-bit encoding; the combination of the remaining bit data of the k-byte 7-bit encoding and the t-byte 7-bit encoding
  • the bit data is arranged in the set byte order to obtain 7-bit encoded data of (k + t) bytes.
  • the predetermined decoding algorithm of this implementation can be operated as follows: Since p is equal to (k+t), the p-byte 7-bit encoded data includes the combined data of the t-byte 7-bit code and the remaining bit data of the k-byte 7-bit code arranged in the set byte order; The fixed byte order distinguishes which combination bit data of t bytes and which is the remaining bit data of k bytes, and extracts k bits from the combined bit data of t bytes according to the set bit order, and each extracted 1 bit The bit inserts a predetermined bit of k-byte remaining bit data corresponding to the set bit order of the bit, thereby obtaining k-byte binary data.
  • the set bit order and the set byte order can be arbitrarily set, as long as the predetermined encoding algorithm and the predetermined decoding algorithm adopt the same set bit order and set bytes.
  • the set bit order may be from the 0th bit to the (s-1)th bit of the bit combination bit data, or from the (s-1)th bit to the 0th bit, which in turn correspond to consecutive s(s)
  • the remaining bit data of the byte for example, the byte order may be k bytes of the remaining bit data before the t byte combined bit data, or k bytes of the remaining bit data in the t byte combination After the bit data, and the remaining data of the k bytes are arranged in accordance with the corresponding binary data.
  • the highest bit can be used as a predetermined bit, and the highest bit (bit 7) of the k-byte binary data is sequentially combined with the bit data from the first byte.
  • the set bit order of the 6th bit to the 0th bit and the 2nd bit of the 2nd bit combined bit data, the combined bit data of the t byte is generated; each of the k bytes of binary data is generated.
  • the 0th to 6th bytes of the byte are used as the remaining bit data of k bytes; the combined bit data of t bytes is arranged before the remaining bit data of k bytes, and the (k+t) word of k byte binary data is obtained.
  • Section 7-bit encoded data is used as a predetermined bit, and the highest bit (bit 7) of the k-byte binary data is sequentially combined with the bit data from the first byte.
  • the combined bit data of the section extracts k in the order of the set bit from the 6th bit to the 0th bit of the first byte combined bit data and the 6th bit to the 0th bit of the combined bit data of the second byte.
  • Pre-positioning sequentially inserting the k predetermined bits into the highest bit of the k remaining bits of data, and inserting the predetermined bits to obtain k-byte binary data.
  • the fourth bit is used as a pre- Positioning, the continuous 7-byte binary data is grouped into one group. If the last remaining less than 7 bytes is also used as a group, the k-byte binary data will form t groups. Extracting a predetermined bit of each byte in a set of binary data in units of groups, and generating one-byte combined bit data in the order of the 0th to 6th bit sets, each byte in the set is binary The 5th to 7th bits of the data are shifted to the right by one bit to obtain the remaining bit data of the 7-bit code. Before the combined bit data of each group is arranged before the remaining bit data of the group, t groups are sequentially arranged in units of groups to obtain 7-bit encoded data of (k + t) bytes.
  • the data will form t groups.
  • Set the squad (s+1) (s is a natural number not greater than 7) bytes in a group, and the first byte in the group is the combined bit data, the second to the (s+1)
  • the bytes are the remaining bit data of the s-byte; the 0th to the sth bits of the combined bit data in the group are respectively inserted into the 4th to the (s+1)th remaining bit data of the group.
  • Bit get s bytes of binary data.
  • the binary data obtained from each group is sequentially arranged, and the decoded k-byte binary data can be obtained.
  • the binary data is converted into 7-bit encoded data by using a predetermined encoding algorithm; when decoding, the 7-bit encoded data is restored to binary data by using a corresponding predetermined decoding algorithm. Since the length of the binary data is increased by 14.3% after being converted into 7-bit encoded data, which is much smaller than the length of the Base64 encoding, the encoded file obtained by applying the embodiment of the present application consumes less traffic when transmitted over the network, and can adapt to more. Requirements for demanding application scenarios.
  • an encoding algorithm is used to convert the data of the image origin.jpg into 7-bit ASCII encoded data, and a corresponding decoding algorithm restores the 7-bit ASCII encoded data to binary data.
  • JavaScript program that implements the encoding method is as follows:
  • Var buf new Buffer(1024);//Open the buffer used in encoding
  • Var data fs.readFileSync('origin.jpg');//data is the binary data of the image origin.jpg
  • Var length data.length+Math.ceil(data.length/7); //length is the length of the 7-bit encoded data after conversion
  • Var body new Buffer(length);//body is the converted 7-bit encoded data
  • the highest bit of every 7 bytes is sequentially combined into an ASCII code combination bit data, wherein the highest bit of the 7th byte binary data in every 7 bytes is Bit 0, the highest byte of the first byte of binary data is in the sixth bit; until the last byte of data; the combined bit data is written to the body one by one.
  • the lower 7 bits of each byte are sequentially generated into the remaining bit data of ASCII code, and written to the body one by one.
  • Var len temp.length-Math.ceil(temp.length/8);//len is the length of the decoded binary data
  • Var buf new Buffer(len);//buf is the decoded binary data
  • the front (temp.length-len) bytes of ⁇ //temp are combined bit data, followed by the remaining bits According to the first byte of the combined bit data, the sixth bit to the zeroth bit of each byte are sequentially extracted, and each bit extracted is sequentially inserted into the highest bit of the remaining bit data, and written into the buf.
  • the embodiment of the present application further provides an encoding device for binary data, and a decoding device for binary data.
  • Both devices can be implemented by software or by hardware or a combination of hardware and software.
  • the CPU Central Process Unit
  • the device in which the encoding device of the binary data or the decoding device of the binary data is located usually includes a chip for transmitting and receiving wireless signals, and the like.
  • Other hardware, and/or other hardware such as boards used to implement network communication functions.
  • FIG. 6 is a schematic diagram of an apparatus for encoding binary data according to an embodiment of the present disclosure, including a binary data acquiring unit and a 7-bit encoding unit, wherein: a binary data acquiring unit is configured to acquire binary data; the length of the binary data is k. Byte, k is a natural number; a 7-bit coding unit is used to convert k-byte binary data into 7-bit encoded data of (k+t) bytes using a predetermined encoding algorithm, and t is the smallest integer greater than or equal to k divided by 7. .
  • the predetermined encoding algorithm includes: extracting a predetermined bit of each byte in k-byte binary data, and combining the combined bit data of the t-byte 7-bit encoding according to the set bit order; The remaining 7 bits of each byte in the binary data are used as k-byte 7-bit encoded residual bit data; the k-byte 7-bit encoded residual bit data and the t-byte 7-bit encoded combined bit data are set according to the set word.
  • the sections are arranged in order to generate 7-bit encoded data of the binary data.
  • the setting byte order includes: the k-byte remaining bit data is arranged according to the corresponding binary data before or after the t-byte combined bit data.
  • the setting bit sequence includes: sequentially, the predetermined bits extracted from the consecutive s-byte binary data as the 0th bit to the (s-1)th bit of the byte combination bit data, or the ( S-1) to the 0th position; s is a natural number not greater than 7.
  • the predetermined bit is the highest bit of each byte.
  • FIG. 7 is a schematic diagram of a decoding device for binary data according to an embodiment of the present application, including to be solved a code data obtaining unit and a 7-bit decoding unit, wherein: the data to be decoded acquiring unit is configured to acquire 7-bit encoded data to be decoded; the length of the 7-bit encoded data is p bytes, and p is a natural number greater than 1; 7 bits
  • the decoding unit is configured to convert p-byte 7-bit encoded data into (pt) bytes of binary data using a predetermined decoding algorithm, and t is a minimum integer equal to or greater than p divided by 8.
  • the predetermined decoding algorithm includes: acquiring, according to a set byte order, k-bit remaining bit data and t-byte combined bit data from p-byte 7-bit encoded data, where k is p Subtracting the difference of t; extracting k bits from the combined data of the t-byte 7-bit code, and inserting each bit of the interpolation into a predetermined bit of the k-byte remaining bit data corresponding to the set bit order of the bit , get k bytes of binary data.
  • the setting byte order includes: the k-byte remaining bit data is arranged according to the corresponding binary data before or after the t-byte combined bit data.
  • the setting bit sequence includes: a 0th bit to a (s-1)th bit of the byte combination bit data, or a (s-1)th bit to a 0th bit, which sequentially correspond to consecutive s bytes remaining bit data; s is a natural number not greater than 7.
  • the predetermined bit is the highest bit of each byte.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • the memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory.
  • RAM random access memory
  • ROM read only memory
  • Memory is an example of a computer readable medium.
  • Computer readable media includes both permanent and non-persistent, removable and non-removable media.
  • Information storage can be implemented by any method or technology.
  • the information can be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of Machine Access Memory (RAM), Read Only Memory (ROM), EEPROM, Flash Memory or other memory technology, CD-ROM, digital A versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape storage or other magnetic storage device or any other non-transportable medium can be used to store information that can be accessed by a computing device.
  • PRAM phase change memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • RAM Read Only Memory
  • ROM Read Only Memory
  • EEPROM Electrically erasable programmable read-only memory
  • Flash Memory or other memory technology
  • CD-ROM compact disc
  • DVD digital A versatile disc
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment in combination of software and hardware.
  • the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Multimedia (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Reduction Or Emphasis Of Bandwidth Of Signals (AREA)

Abstract

本申请提供一种二进制数据的编码方法,包括:获取二进制数据;所述二进制数据的长度为k字节,k为自然数;采用预定编码算法将k字节的二进制数据转换为(k+t)字节的7位编码数据,t为大于等于k除以7的最小整数。通过本申请技术方案得到的编码文件比Base64编码文件的长度更小,在网络上传输时消耗的流量更少,能够适应更为苛刻的应用场景要求。

Description

二进制数据的编码、解码方法和装置 技术领域
本申请涉及网络通信技术领域,尤其涉及一种二进制数据的编码方法和装置、一种二进制数据的解码方法和装置。
背景技术
在计算机中很多资源以二进制数据的形式存储,例如图片、音视频流、可执行程序等,包含这些资源的文件通常都是二进制文件。但是在一些网络协议或网络应用中,能够正确传输的数据只能是通用字符,二进制数据在基于这些网络协议或网络应用进行传输时,需要先在发送端将二进制数据编码为字符数据,在传输到接收端后,再将字符数据解码为二进制数据。
现有技术中,Base64是最为常用的二进制数据编解码技术。Base64采用64个字符对二进制数据进行编码,对N字节的二进制数据,将对应的8*N位中连续的每6位分割为1个部分,每个部分的值都在0到63之间,将该值对应于1个ASCII(American Standard Code for Information Interchange,美国信息交换标准代码)字符,将所有部分对应的ASCII字符拼接起来,即可得到二进制数据的Base64编码。对应的解码过程与上述相逆,不再赘述。
可见,3字节二进制数据的Base64编码数据的长度为4字节,一个二进制文件在转换为Base64编码文件后,文件长度增加了大约33%。也就是说,Base64编码后的二进制文件在传输时要占用的流量增加了三分之一左右。在移动互联应用中,降低服务端与用户手持设备之间的交互流量对所有业务而言都是至关重要的问题。Base64编码后的字符文件较大,难以满足一些苛刻的应用场景的要求。
发明内容
有鉴于此,本申请提供一种二进制数据的编码方法,包括:
获取二进制数据;所述二进制数据的长度为k字节,k为自然数;
采用预定编码算法将k字节的二进制数据转换为(k+t)字节的7位编码数据,t为大于等于k除以7的最小整数。
本申请提供的一种二进制数据的解码方法,包括:
获取待解码的7位编码数据;所述7位编码数据的长度为p字节,p为大于1的自然数;
采用预定解码算法将p字节的7位编码数据转换为(p-t)字节的二进制数据,t为大于等于p除以8的最小整数。
本申请还提供了一种二进制数据的编码装置,包括:
二进制数据获取单元,用于获取二进制数据;所述二进制数据的长度为k字节,k为自然数;
7位编码单元,用于采用预定编码算法将k字节的二进制数据转换为(k+t)字节的7位编码数据,t为大于等于k除以7的最小整数。
本申请提供的一种二进制数据的解码装置,包括:
待解码数据获取单元,用于获取待解码的7位编码数据;所述7位编码数据的长度为p字节,p为大于1的自然数;
7位解码单元,用于采用预定解码算法将p字节的7位编码数据转换为(p-t)字节的二进制数据,t为大于等于p除以8的最小整数。
由以上技术方案可见,本申请的实施例中,在编码时,采用预定编码算法对二进制数据进行7位编码;在解码时,采用预定解码算法将7位编码恢复为二进制数据;由于7字节的二进制数据可以转换为8字节的7位编码数据,二进制数据在转换为7位编码数据后长度大约增加了14.3%,因此采用本申请技术方案得到的编码文件比Base64编码文件的长度更小,在网络上传输时消耗的流量更少,能够适应更为苛刻的应用场景要求。
附图说明
图1是本申请实施例中一种二进制数据的编码方法的流程图;
图2是本申请实施例中一种二进制数据的解码方法的流程图;
图3是本申请实施例中第一种预定编码算法示例的示意图;
图4是本申请实施例中第二种预定编码算法示例的示意图;
图5是运行本申请实施例的设备的一种硬件结构图;
图6是本申请实施例中一种二进制数据的编码装置的逻辑结构图;
图7是本申请实施例中一种二进制数据的解码装置的逻辑结构图。
具体实施方式
在绝大多数编码方式中,十进制值0到127所对应的字符在网络传输中能够被各种网络协议或网络应用支持。例如,ASCII编码、UTF-7(Unicode Transformation Format 7,7位元Unicode转换格式)、7位等宽编码等。也就是说,在将二进制文件转换为上述这些编码方式的7位编码文件后,即可在各种应用中、基于各种协议进行文件传输。
7位编码是采用一个字节的低7位来承载数据的编码方式。7位编码可以将7字节的二进制数据转换为8字节的编码数据,相比于Base64编码将3字节的二进制数据转换为4字节的编码,其转换效率更高,转换后的编码文件更小,更为节省传输流量。
因此,本申请的实施例提出一种新的二进制数据的编码方法和对应的二进制数据的解码方法,分别用来将二进制数据转换为7位编码数据、以及将7位编码数据还原为二进制数据,以减小编码数据的长度,节约编码数据在网络传输时消耗的流量,从而解决现有技术中存在的问题。
本申请的实施例可以应用在任何具有计算和存储能力的设备上,例如可以是手机、平板电脑、PC(Personal Computer,个人电脑)、笔记本、服务器、虚拟机等物理设备或逻辑设备;也可以由两个或两个以上分担不同职责的物理或逻辑设备、相互协同来实现本申请实施例中的各项功能。其中,编码方法和解码方法可以分别运行在不同的设备上,也可以运行在同一个设备上。
本申请的实施例中,二进制数据的编码方法的流程如图1所示。
步骤110,获取二进制数据。
待转换的二进制数据可以是一个二进制文件,也可以是作为一个文件组成部分的一段二进制数据,不做限定。可以从某个网络中的存储位置读取二进制数据,也可以从指定的缓存中获得待转换的二进制数据,本申请的实施例同样不做限定。
设所获取的二进制数据的长度为k(k为自然数)字节。
步骤120,采用预定编码算法将k字节的二进制数据转换为(k+t)字节的7位编码数据,t为大于等于k除以7的最小整数。
一个字节的二进制数据有效位是8位,而一个字节的7位编码数据有效位是7位。因此,在将二进制数据转换为7位编码数据时,1到7个字节的二进制数据分别可以由2到8个字节的7位编码数据来表达,编码后增加的长度为1个字节;8到14字节的二进制数据分别可以由10到16个字节的7位编码数据来表达,编码后增加的长度为2个字节;依次类推,k字节的二进制数据可以由(k+t)字节的7位编码数据来表达,t为大于等于k除以7的最小整数。换言之,在将k字节的二进制数据转换为7位编码数据时,增加的长度为t个字节。
任何一种可以将k字节二进制数据一对一映射为(k+t)字节的7位编码数据的算法都可以用作预定编码算法,本申请的实施例不做限定。
本申请的实施例中,二进制数据的解码方法的流程如图2所示。
步骤210,获取待解码的7位编码数据。
类似的,待解码的7位编码数据可以是一个编码文件,也可以是作为一个文件组成部分的一段7位编码数据,不做限定。可以从某个网络中的存储位置读取7位编码数据,也可以从指定的缓存中获得待解码的7位编码数据,本申请的实施例同样不做限定。
设待解码的7位编码数据的长度为p(p为大于1的自然数)字节。
步骤220,采用预定解码算法将p字节的7位编码数据转换为(p-t)字 节的二进制数据,t为大于等于p除以8的最小整数。
如前所述,2到8个字节的7位编码数据分别可以表达1到7个字节的二进制数据,解码后减少的长度为1个字节;10到16个字节的7位编码数据分别可以表达8到14字节的二进制数据,解码后减少的长度为2个字节;依次类推,p字节的7位编码数据可以表达(p-t)字节的二进制数据,t为大于等于p除以8的最小整数。换言之,在将p字节的7位编码数据转换为二进制数据时,减少的长度为t个字节。
与将二进制数据转换为7位编码数据时采用的预定编码算法相逆、能够将p字节的7位编码数据还原为编码前的(p-t)字节的二进制数据的算法,即可用来作为本申请实施例中的预定解码算法。
在一种实现方式中,可以基于以下思路来进行编码:一字节的二进制数据由8个位(bit)组成,由于7位编码只能使用一字节中的低7位,一字节的二进制数据需要一字节的7位编码和一个额外字节中的1位来表示。可以将一字节的8位二进制数据分拆为2个部分,将某个预定位(可以是第0位到第7位中的任何一位)作为由额外字节表示的1位,除该预定位外剩余的7位由一字节的7位编码来表示。该额外字节中的其他6位可以用于携带其他6个字节的二进制数据的预定位。这样,每7个字节的二进制数据在映射为7位编码时增加1个字节,不足7个字节的二进制数据在映射7位编码时也会增加1个字节,则k字节的二进制数据在映射为7位编码时,将增加t个字节。
具体而言,这种实现方式中的预定编码算法可以按如下方式运行:在k字节二进制数据中提取每个字节的预定位,按照设定位顺序组合为t字节7位编码的组合位数据,将k字节二进制数据中每个字节剩余的7位作为k字节7位编码的剩余位数据;将k字节7位编码的剩余位数据和t字节7位编码的组合位数据按照设定字节顺序进行排列,从而得到(k+t)字节的7位编码数据。
对应的,在解码时,这种实现方式的预定解码算法可以按如下方式运行: 由于p等于(k+t),p字节7位编码数据中包括按照设定字节顺序排列的t字节7位编码的组合位数据和k字节7位编码的剩余位数据;根据设定字节顺序区分出哪些是t字节的组合位数据、哪些是k字节的剩余位数据后,按照设定位顺序从t字节的组合位数据中提取k位,将提取的每1位***与该位的设定位顺序对应的k字节剩余位数据的预定位,从而得到k字节二进制数据。
其中,设定位顺序和设定字节顺序可以任意设置,只要预定编码算法和预定解码算法采用相同的设定位顺序和设定字节顺即可。例如,设定位顺序可以是从一个字节组合位数据的第0位到第(s-1)位、或从第(s-1)位到第0位,依次对应于连续的s(s为不大于7的自然数)字节剩余位数据;再如,设定字节顺序可以是k字节剩余位数据在t字节组合位数据之前,或k字节剩余位数据在t字节组合位数据之后,并且k字节剩余位数据按照所对应的二进制数据排列。
以下给出上述实现方式的两个具体例子:
第一个例子:请参见图3,在一种预定编码算法中,可以将最高位作为预定位,依次将k字节二进制数据的最高位(第7位)按照从第1字节组合位数据的第6位到第0位、第2字节组合位数据的第6位到第0位这样的设定位顺序,生成t字节的组合位数据;将k字节二进制数据中的每个字节第0位到第6位作为k字节的剩余位数据;将t字节的组合位数据排列在k字节的剩余位数据之前,得到k字节二进制数据的(k+t)字节7位编码数据。
在第一个例子的预定解码算法中,将p(p=k+t)字节7位编码数据的前t个字节作为组合位数据,后k个字节作为剩余位数据;从t字节的组合位数据中按照从第1字节组合位数据的第6位到第0位、第2字节组合位数据的第6位到第0位这样的设定位顺序,提取出k个预定位;将顺序提取出的k个预定位依次***到k个剩余位数据的最高位,***预定位后即可得到k字节的二进制数据。
第二个例子:请参见图4,在另一种预定编码算法中,以第4位作为预 定位,将连续7字节的二进制数据分为一组,如果最后剩余不足7字节也作为一组,则k字节二进制数据将形成t个组。以组为单位,提取一组二进制数据中每个字节的预定位,按照第0位到第6位的设定位顺序生成一字节的组合位数据,将该组中每个字节二进制数据的第5位到第7位右移一位,得到7位编码的剩余位数据。将每组的组合位数据排列在该组的剩余位数据之前,以组为单位依次排列t个组,得到(k+t)字节的7位编码数据。
在第二个例子的预定解码算法中,将连续8字节的7位编码数据分为一组,如果最后剩余不足8字节也作为一组,则p(p=k+t)字节二进制数据将形成t个组。以组为单位,设某组中共(s+1)(s为不大于7的自然数)个字节,则该组中第1个字节为组合位数据,第2到第(s+1)个字节为s字节的剩余位数据;将该组中组合位数据的第0位到第s位分别***到该组中第2到第(s+1)字节剩余位数据的第4位,得到s字节的二进制数据。将从各个组得到的二进制数据依序排列,则可得到解码后k字节的二进制数据。
可见,本申请的实施例中,在编码时,采用预定编码算法将二进制数据转换为7位编码数据;在解码时,采用对应的预定解码算法将7位编码数据还原为二进制数据。由于二进制数据在转换为7位编码数据后长度大约增加了14.3%,远小于Base64编码增加的长度,应用本申请的实施例得到的编码文件在网络上传输时消耗的流量更少,能够适应更为苛刻的应用场景要求。
在本申请的一个应用示例中,采用一种编码算法将图片origin.jpg的数据转换为7位ASCII编码数据,对应的一种解码算法将7位ASCII编码数据还原为二进制数据。
实现编码方法的JavaScript程序如下:
var buf=new Buffer(1024);//开辟编码时使用的缓冲区
var data=fs.readFileSync('origin.jpg');//data为图片origin.jpg的二进制数据
var length=data.length+Math.ceil(data.length/7);//length为转换后7位编码数据的长度
var body=new Buffer(length);//body为转换后的7位编码数据
var offset=0;
var swap=0;
var count=0;
for(var i=0;i<data.length;i++){
swap|=((data[i]&0x80)>>(i%7+1));
count++;
if(i===data.length-1||count%7===0){
body.writeUInt8(swap,++offset);
swap=0;
}
}//从data的第一个字节开始,依次将每7个字节的最高位组成一个ASCII码的组合位数据,其中每7个字节中第7个字节二进制数据的最高位在第0位,第1个字节二进制数据的最高位在第6位;直到data的最后一个字节;将组合位数据逐个写入body
for(var i=0;i<data.length;i++){
body.writeUInt8(data[i]&0x7f,++offset);
}//从data的第一个字节开始,依次将每个字节的低7位生成一个ASCII码的剩余位数据,并且逐个写入body
设temp为待解码的7位编码数据,实现解码方法的JavaScript程序如下:
var len=temp.length-Math.ceil(temp.length/8);//len为解码后二进制数据的长度
var buf=new Buffer(len);//buf为解码后的二进制数据
for(var i=0;i<buf.length;i++){
var swap=0;
swap|=((temp.readUInt8(parseInt(i/7))<<(i%7+1))&0x80);
swap|=temp.readUInt8(i+temp.length-len);
buf.writeUInt8(swap,i);
}//temp的前(temp.length-len)个字节为组合位数据,之后为剩余位数 据;从组合位数据的第一个字节开始,依次提取每个字节的第6位到第0位,所提取的每位依次***到剩余位数据的最高位,并写入buf
与上述流程实现对应,本申请的实施例还提供了一种二进制数据的编码装置,和一种二进制数据的解码装置。这两种装置均可以通过软件实现,也可以通过硬件或者软硬件结合的方式实现。以软件实现为例,作为逻辑意义上的装置,是通过所在设备的CPU(Central Process Unit,中央处理器)将对应的计算机程序指令读取到内存中运行形成的。从硬件层面而言,除了图5所示的CPU、内存以及非易失性存储器之外,二进制数据的编码装置或二进制数据的解码装置所在的设备通常还包括用于进行无线信号收发的芯片等其他硬件,和/或用于实现网络通信功能的板卡等其他硬件。
图6所示为本申请实施例提供的一种二进制数据的编码装置,包括二进制数据获取单元和7位编码单元,其中:二进制数据获取单元用于获取二进制数据;所述二进制数据的长度为k字节,k为自然数;7位编码单元用于采用预定编码算法将k字节的二进制数据转换为(k+t)字节的7位编码数据,t为大于等于k除以7的最小整数。
一种实现方式中,所述预定编码算法包括:在k字节二进制数据中提取每个字节的预定位,按照设定位顺序组合为t字节7位编码的组合位数据;将k字节二进制数据中每个字节剩余的7位作为k字节7位编码的剩余位数据;将k字节7位编码的剩余位数据和t字节7位编码的组合位数据按照设定字节顺序进行排列,生成所述二进制数据的7位编码数据。
上述实现方式中,所述设定字节顺序包括:k字节剩余位数据在t字节组合位数据之前或之后,按照所对应的二进制数据排列。
上述实现方式中,所述设定位顺序包括:将连续的s字节二进制数据中提取的预定位依次作为一个字节组合位数据的第0位到第(s-1)位、或第(s-1)位到第0位;s为不大于7的自然数。
上述实现方式中,所述预定位为每个字节的最高位。
图7所示为本申请实施例提供的一种二进制数据的解码装置,包括待解 码数据获取单元和7位解码单元,其中:待解码数据获取单元用于获取待解码的7位编码数据;所述7位编码数据的长度为p字节,p为大于1的自然数;7位解码单元用于采用预定解码算法将p字节的7位编码数据转换为(p-t)字节的二进制数据,t为大于等于p除以8的最小整数。
一种实现方式中,所述预定解码算法包括:按照设定字节顺序,从p字节的7位编码数据中获取k字节的剩余位数据和t字节的组合位数据,k为p减去t的差值;从t字节7位编码的组合位数据中提取k位,将提取的每1位***与所述位的设定位顺序对应的k字节剩余位数据的预定位,得到k字节二进制数据。
上述实现方式中,所述设定字节顺序包括:k字节剩余位数据在t字节组合位数据之前或之后,按照所对应的二进制数据排列。
上述实现方式中,所述设定位顺序包括:一个字节组合位数据的第0位到第(s-1)位、或第(s-1)位到第0位,依次对应于连续的s字节剩余位数据;s为不大于7的自然数。
上述实现方式中,所述预定位为每个字节的最高位。
以上所述仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本申请保护的范围之内。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随 机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。
本领域技术人员应明白,本申请的实施例可提供为方法、***或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。

Claims (20)

  1. 一种二进制数据的编码方法,其特征在于,包括:
    获取二进制数据;所述二进制数据的长度为k字节,k为自然数;
    采用预定编码算法将k字节的二进制数据转换为(k+t)字节的7位编码数据,t为大于等于k除以7的最小整数。
  2. 根据权利要求1所述的方法,其特征在于,所述预定编码算法包括:在k字节二进制数据中提取每个字节的预定位,按照设定位顺序组合为t字节7位编码的组合位数据;将k字节二进制数据中每个字节剩余的7位作为k字节7位编码的剩余位数据;将k字节7位编码的剩余位数据和t字节7位编码的组合位数据按照设定字节顺序进行排列,生成所述二进制数据的7位编码数据。
  3. 根据权利要求2所述的方法,其特征在于,所述设定字节顺序包括:k字节剩余位数据在t字节组合位数据之前或之后,按照所对应的二进制数据排列。
  4. 根据权利要求2所述的方法,其特征在于,所述设定位顺序包括:将连续的s字节二进制数据中提取的预定位依次作为一个字节组合位数据的第0位到第(s-1)位、或第(s-1)位到第0位;s为不大于7的自然数。
  5. 根据权利要求2所述的方法,其特征在于,所述预定位为每个字节的最高位。
  6. 一种二进制数据的解码方法,其特征在于,包括:
    获取待解码的7位编码数据;所述7位编码数据的长度为p字节,p为大于1的自然数;
    采用预定解码算法将p字节的7位编码数据转换为(p-t)字节的二进制数据,t为大于等于p除以8的最小整数。
  7. 根据权利要求6所述的方法,其特征在于,所述预定解码算法包括:按照设定字节顺序,从p字节的7位编码数据中获取k字节的剩余位数据和 t字节的组合位数据,k为p减去t的差值;从t字节7位编码的组合位数据中提取k位,将提取的每1位***与所述位的设定位顺序对应的k字节剩余位数据的预定位,得到k字节二进制数据。
  8. 根据权利要求7所述的方法,其特征在于,所述设定字节顺序包括:k字节剩余位数据在t字节组合位数据之前或之后,按照所对应的二进制数据排列。
  9. 根据权利要求7所述的方法,其特征在于,所述设定位顺序包括:一个字节组合位数据的第0位到第(s-1)位、或第(s-1)位到第0位,依次对应于连续的s字节剩余位数据;s为不大于7的自然数。
  10. 根据权利要求7所述的方法,其特征在于,所述预定位为每个字节的最高位。
  11. 一种二进制数据的编码装置,其特征在于,包括:
    二进制数据获取单元,用于获取二进制数据;所述二进制数据的长度为k字节,k为自然数;
    7位编码单元,用于采用预定编码算法将k字节的二进制数据转换为(k+t)字节的7位编码数据,t为大于等于k除以7的最小整数。
  12. 根据权利要求11所述的装置,其特征在于,所述预定编码算法包括:在k字节二进制数据中提取每个字节的预定位,按照设定位顺序组合为t字节7位编码的组合位数据;将k字节二进制数据中每个字节剩余的7位作为k字节7位编码的剩余位数据;将k字节7位编码的剩余位数据和t字节7位编码的组合位数据按照设定字节顺序进行排列,生成所述二进制数据的7位编码数据。
  13. 根据权利要求12所述的装置,其特征在于,所述设定字节顺序包括:k字节剩余位数据在t字节组合位数据之前或之后,按照所对应的二进制数据排列。
  14. 根据权利要求12所述的装置,其特征在于,所述设定位顺序包括:将连续的s字节二进制数据中提取的预定位依次作为一个字节组合位数据的 第0位到第(s-1)位、或第(s-1)位到第0位;s为不大于7的自然数。
  15. 根据权利要求12所述的装置,其特征在于,所述预定位为每个字节的最高位。
  16. 一种二进制数据的解码装置,其特征在于,包括:
    待解码数据获取单元,用于获取待解码的7位编码数据;所述7位编码数据的长度为p字节,p为大于1的自然数;
    7位解码单元,用于采用预定解码算法将p字节的7位编码数据转换为(p-t)字节的二进制数据,t为大于等于p除以8的最小整数。
  17. 根据权利要求16所述的装置,其特征在于,所述预定解码算法包括:按照设定字节顺序,从p字节的7位编码数据中获取k字节的剩余位数据和t字节的组合位数据,k为p减去t的差值;从t字节7位编码的组合位数据中提取k位,将提取的每1位***与所述位的设定位顺序对应的k字节剩余位数据的预定位,得到k字节二进制数据。
  18. 根据权利要求17所述的装置,其特征在于,所述设定字节顺序包括:k字节剩余位数据在t字节组合位数据之前或之后,按照所对应的二进制数据排列。
  19. 根据权利要求17所述的装置,其特征在于,所述设定位顺序包括:一个字节组合位数据的第0位到第(s-1)位、或第(s-1)位到第0位,依次对应于连续的s字节剩余位数据;s为不大于7的自然数。
  20. 根据权利要求17所述的装置,其特征在于,所述预定位为每个字节的最高位。
PCT/CN2017/103429 2016-10-11 2017-09-26 二进制数据的编码、解码方法和装置 WO2018068634A1 (zh)

Priority Applications (14)

Application Number Priority Date Filing Date Title
CA3040003A CA3040003C (en) 2016-10-11 2017-09-26 Methods and devices for encoding and decoding binary data
KR1020197013004A KR102249267B1 (ko) 2016-10-11 2017-09-26 2진 데이터를 인코딩 및 디코딩하기 위한 방법 및 디바이스
AU2017342863A AU2017342863B2 (en) 2016-10-11 2017-09-26 Methods and devices for encoding and decoding binary data
JP2019519660A JP6931050B2 (ja) 2016-10-11 2017-09-26 バイナリデータをエンコード及びデコードする方法及び装置
BR112019007284A BR112019007284A2 (pt) 2016-10-11 2017-09-26 métodos e dispositivos de codificação e decodificação de dados binários
RU2019113976A RU2725763C1 (ru) 2016-10-11 2017-09-26 Способы и устройства для кодирования и декодирования двоичных данных
MYPI2019001978A MY196192A (en) 2016-10-11 2017-09-26 Methods and Devices for Encoding And Decoding Binary Data
MX2019004256A MX2019004256A (es) 2016-10-11 2017-09-26 Metodos y dispositivos para codificar y decodificar datos binarios.
SG11201903176RA SG11201903176RA (en) 2016-10-11 2017-09-26 Methods and devices for encoding and decoding binary data
EP17860029.2A EP3528389A4 (en) 2016-10-11 2017-09-26 METHODS AND DEVICES FOR ENCODING AND DECODING BINARY DATA
US16/380,643 US10785277B2 (en) 2016-10-11 2019-04-10 Methods and devices for encoding and decoding binary data
PH12019500783A PH12019500783A1 (en) 2016-10-11 2019-04-11 Methods and devices for encoding and decoding binary data
ZA2019/02948A ZA201902948B (en) 2016-10-11 2019-05-10 Methods and devices for encoding and decoding binary data
AU2019101588A AU2019101588A4 (en) 2016-10-11 2019-12-13 Methods and devices for encoding and decoding binary data

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610887650.1A CN107919943B (zh) 2016-10-11 2016-10-11 二进制数据的编码、解码方法和装置
CN201610887650.1 2016-10-11

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/380,643 Continuation US10785277B2 (en) 2016-10-11 2019-04-10 Methods and devices for encoding and decoding binary data

Publications (1)

Publication Number Publication Date
WO2018068634A1 true WO2018068634A1 (zh) 2018-04-19

Family

ID=61892693

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/103429 WO2018068634A1 (zh) 2016-10-11 2017-09-26 二进制数据的编码、解码方法和装置

Country Status (16)

Country Link
US (1) US10785277B2 (zh)
EP (1) EP3528389A4 (zh)
JP (1) JP6931050B2 (zh)
KR (1) KR102249267B1 (zh)
CN (1) CN107919943B (zh)
AU (2) AU2017342863B2 (zh)
BR (1) BR112019007284A2 (zh)
CA (1) CA3040003C (zh)
MX (1) MX2019004256A (zh)
MY (1) MY196192A (zh)
PH (1) PH12019500783A1 (zh)
RU (1) RU2725763C1 (zh)
SG (1) SG11201903176RA (zh)
TW (1) TW201815074A (zh)
WO (1) WO2018068634A1 (zh)
ZA (1) ZA201902948B (zh)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110504973A (zh) * 2018-05-16 2019-11-26 北京京东尚科信息技术有限公司 文件压缩、解压方法和装置
CN110120819B (zh) * 2019-04-26 2023-07-21 矩阵元技术(深圳)有限公司 一种布尔电路编码方法、装置及***
CN110569487B (zh) * 2019-08-19 2023-07-18 积成电子股份有限公司 一种基于高频率字符替代算法的Base64扩展编码方法及***
CN112422491A (zh) * 2020-05-08 2021-02-26 上海幻电信息科技有限公司 数字编码的加密解密方法、服务器和存储介质
CN111600610B (zh) * 2020-05-26 2023-04-28 北京思特奇信息技术股份有限公司 一种变长整数的通用编码方法、***及电子设备
CN112148673A (zh) * 2020-09-22 2020-12-29 北京中房智宝科技有限公司 一种多二进制合并成一个二进制文件读写错误的解决方法
CN112818639A (zh) * 2020-12-30 2021-05-18 平安普惠企业管理有限公司 数据编码方法、装置、计算机设备和存储介质
CN112910568A (zh) * 2021-01-18 2021-06-04 猫岐智能科技(上海)有限公司 一种数据通信方法、数据发送方法及数据接收方法
KR102627365B1 (ko) * 2021-04-28 2024-01-18 한전케이디엔주식회사 배전설비 pd 진단시스템의 prpd 데이터 포맷변환 및 압축 방법
CN113542762A (zh) * 2021-07-20 2021-10-22 中交信捷科技有限公司 一种车辆红外图像的压缩与增强方法和***

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1994021051A1 (en) * 1993-03-10 1994-09-15 Awacs Communications (Nz) Limited Enhanced one way radio seven bit data network
JP2000307431A (ja) * 1999-04-23 2000-11-02 Victor Co Of Japan Ltd 変調装置及び復調装置
CN1466342A (zh) * 2002-07-02 2004-01-07 深圳市中兴通讯股份有限公司 一种在网关上还原电子邮件内容的方法
CN1703108A (zh) * 2005-06-01 2005-11-30 海信集团有限公司 移动终端短消息加密的方法
CN1816170A (zh) * 2005-11-08 2006-08-09 杭州华为三康技术有限公司 短信收发的编码转换方法及其应用的网络设备
CN101080038A (zh) * 2007-06-22 2007-11-28 ***通信集团广东有限公司 一种基于ussd协议的中文信息传输方法
CN105740215A (zh) * 2016-01-23 2016-07-06 北京掌阔移动传媒科技有限公司 一种数据通信编码和解码方法

Family Cites Families (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4597057A (en) 1981-12-31 1986-06-24 System Development Corporation System for compressed storage of 8-bit ASCII bytes using coded strings of 4 bit nibbles
US5007013A (en) 1986-04-01 1991-04-09 Westinghouse Electric Corp. Bidirectional communication and control network with programmable microcontroller interfacing digital ICS and controlled product
US4789852A (en) 1987-06-05 1988-12-06 Bailey Guy R Method and apparatus for converting data in a binary format
US5136291A (en) 1990-11-30 1992-08-04 Unisys Corporation Transmitting binary data files using electronic mail
US5406279A (en) 1992-09-02 1995-04-11 Cirrus Logic, Inc. General purpose, hash-based technique for single-pass lossless data compression
US5406280A (en) 1993-08-26 1995-04-11 Commerce Clearing House Data retrieval system using compression scheme especially for serial data stream
US5974464A (en) 1995-10-06 1999-10-26 Silicon Image, Inc. System for high speed serial video signal transmission using DC-balanced coding
JP2840589B2 (ja) 1996-02-09 1998-12-24 富士通株式会社 データ圧縮装置及びデータ復元装置
US5818032A (en) 1997-01-03 1998-10-06 Sun; Tsu-Hung Tom Encoded color halftone micro-dots for high density digital information storage
US7190257B2 (en) 1999-03-16 2007-03-13 Intermec Ip Corp. Data encoding in radio frequency identification transponders
US6801625B1 (en) * 1999-12-08 2004-10-05 Intel Corporation Apparatus and method for stripping parity bits from an input stream
US7451229B2 (en) 2002-06-24 2008-11-11 Microsoft Corporation System and method for embedding a streaming media format header within a session description message
CN1251522C (zh) * 2002-10-29 2006-04-12 蔡宁 一种利用pocsag编码传送图形文件的方法
US7590837B2 (en) 2003-08-23 2009-09-15 Softex Incorporated Electronic device security and tracking system and method
US7519274B2 (en) 2003-12-08 2009-04-14 Divx, Inc. File format for multiple track digital data
US7769904B2 (en) 2004-06-09 2010-08-03 L-3 Communications Integrated Systems L.P. Extensible binary mark-up language for efficient XML-based data communications and related systems and methods
CN100423582C (zh) * 2005-11-03 2008-10-01 浙江大学 一种用于将待编码数据进行二进制化编码的方法和装置
CN1937582B (zh) * 2006-08-11 2012-08-15 白杰 待压缩数据的预处理方法以及压缩数据的传输方法
US10175990B2 (en) * 2009-12-22 2019-01-08 Intel Corporation Gathering and scattering multiple data elements
CN101840394B (zh) * 2010-03-04 2012-12-19 英华达(南昌)科技有限公司 数据解码方法
CN103067022B (zh) * 2012-12-19 2015-10-21 中国石油天然气集团公司 一种整型数据无损压缩方法、解压缩方法及装置
US20140204994A1 (en) * 2013-01-24 2014-07-24 Silicon Image, Inc. Auxiliary data encoding in video data
US9626184B2 (en) * 2013-06-28 2017-04-18 Intel Corporation Processors, methods, systems, and instructions to transcode variable length code points of unicode characters
CN107251438B (zh) * 2015-02-16 2020-10-30 三菱电机株式会社 数据压缩装置及方法、数据解压缩装置及方法和记录介质

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1994021051A1 (en) * 1993-03-10 1994-09-15 Awacs Communications (Nz) Limited Enhanced one way radio seven bit data network
JP2000307431A (ja) * 1999-04-23 2000-11-02 Victor Co Of Japan Ltd 変調装置及び復調装置
CN1466342A (zh) * 2002-07-02 2004-01-07 深圳市中兴通讯股份有限公司 一种在网关上还原电子邮件内容的方法
CN1703108A (zh) * 2005-06-01 2005-11-30 海信集团有限公司 移动终端短消息加密的方法
CN1816170A (zh) * 2005-11-08 2006-08-09 杭州华为三康技术有限公司 短信收发的编码转换方法及其应用的网络设备
CN101080038A (zh) * 2007-06-22 2007-11-28 ***通信集团广东有限公司 一种基于ussd协议的中文信息传输方法
CN105740215A (zh) * 2016-01-23 2016-07-06 北京掌阔移动传媒科技有限公司 一种数据通信编码和解码方法

Also Published As

Publication number Publication date
EP3528389A1 (en) 2019-08-21
US20190245906A1 (en) 2019-08-08
BR112019007284A2 (pt) 2019-07-09
JP6931050B2 (ja) 2021-09-01
MX2019004256A (es) 2019-07-01
KR20190064621A (ko) 2019-06-10
RU2725763C1 (ru) 2020-07-06
US10785277B2 (en) 2020-09-22
AU2019101588A4 (en) 2020-01-23
CA3040003C (en) 2021-02-09
SG11201903176RA (en) 2019-05-30
AU2017342863B2 (en) 2020-10-22
PH12019500783B1 (en) 2019-12-11
ZA201902948B (en) 2020-08-26
CN107919943A (zh) 2018-04-17
EP3528389A4 (en) 2020-05-13
AU2017342863A1 (en) 2019-05-02
TW201815074A (zh) 2018-04-16
CA3040003A1 (en) 2018-04-19
JP2019537332A (ja) 2019-12-19
CN107919943B (zh) 2020-08-04
PH12019500783A1 (en) 2019-12-11
KR102249267B1 (ko) 2021-05-10
MY196192A (en) 2023-03-22

Similar Documents

Publication Publication Date Title
WO2018068634A1 (zh) 二进制数据的编码、解码方法和装置
WO2016029801A1 (zh) 编码、解码方法以及编码装置和解码装置
CN107395209B (zh) 数据压缩方法、数据解压缩方法及其设备
US9710415B2 (en) Asynchronous FIFO buffer with Johnson code write pointer
JP6381546B2 (ja) 多バイト・フレームのパイプライン化圧縮のための方法、符号化データ・ストリームへの高帯域圧縮のための装置、およびコンピュータ・プログラム製品
WO2017059798A1 (zh) 序列化与反序列化的方法、装置、***以及电子设备
US10019409B2 (en) Extending remote direct memory access operations for storage class memory access
WO2017054597A1 (zh) 表情字符串的处理方法及装置
JP2019537332A5 (zh)
US10757227B2 (en) Security-oriented compression
US20160335255A1 (en) Innovative method for text encodation in quick response code
TW201728182A (zh) 音頻-視頻資料的發送方法、接收方法和音頻-視頻資料的傳輸系統
CN111464189A (zh) 一种斐波那契进制译码装置、方法
CN110750388A (zh) 一种备份解析方法、装置、设备和介质
KR20160008386A (ko) 펄스폭 변조 데이터 복원 장치 및 이의 구동 방법
CN111178010B (zh) 显示数字签名的方法及***、数据编辑方法及终端
Zeng et al. Research on LZW Algorithm Based on AES in Data Backup Under Data Block Compression and Encryption
US20100202468A1 (en) Bridge, data compressing method thereof and computer system applying the same
CN113283215B (zh) 一种基于utf-32编码的数据混淆方法及装置
CN115001628B (zh) 数据编码的方法及装置、数据解码的方法及装置和数据结构
KR100660057B1 (ko) 패스트 인포셋을 이용한 이진 엑스엠엘 저장 방법 및 복원방법
CN110888999A (zh) 一种图片与字符相互转换的方法
CN117850661A (zh) 用于处理压缩数据的方法、设备和计算机程序产品
CN114189331A (zh) 一种密钥存储和读取方法、装置、设备及存储介质
Pujari et al. OUNano a novel method and framework to optimize the utilization of digital communication channel and storage resources for textual based transactions

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: 17860029

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 3040003

Country of ref document: CA

ENP Entry into the national phase

Ref document number: 2019519660

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

REG Reference to national code

Ref country code: BR

Ref legal event code: B01A

Ref document number: 112019007284

Country of ref document: BR

ENP Entry into the national phase

Ref document number: 2017342863

Country of ref document: AU

Date of ref document: 20170926

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 20197013004

Country of ref document: KR

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2017860029

Country of ref document: EP

Effective date: 20190513

ENP Entry into the national phase

Ref document number: 112019007284

Country of ref document: BR

Kind code of ref document: A2

Effective date: 20190410