CN102903378B - For the two-dimentional run length constraint coding/decoding device and method of elongated code check - Google Patents

For the two-dimentional run length constraint coding/decoding device and method of elongated code check Download PDF

Info

Publication number
CN102903378B
CN102903378B CN201210373044.XA CN201210373044A CN102903378B CN 102903378 B CN102903378 B CN 102903378B CN 201210373044 A CN201210373044 A CN 201210373044A CN 102903378 B CN102903378 B CN 102903378B
Authority
CN
China
Prior art keywords
dimensional
word
module
word unit
array
Prior art date
Legal status (The legal status 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 status listed.)
Expired - Fee Related
Application number
CN201210373044.XA
Other languages
Chinese (zh)
Other versions
CN102903378A (en
Inventor
刘继斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Textile University
Original Assignee
Wuhan Textile University
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 Wuhan Textile University filed Critical Wuhan Textile University
Priority to CN201210373044.XA priority Critical patent/CN102903378B/en
Publication of CN102903378A publication Critical patent/CN102903378A/en
Application granted granted Critical
Publication of CN102903378B publication Critical patent/CN102903378B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

本发明提供了用于变长码率的二维游程长度受限约束编解码装置及方法,该装置包括编码器和解码器,所述编码器包括一维数据流缓冲及分组模块、2×2码字生成模块、二维字单元阵列构造模块、2×2码字写入二维字单元阵列模块,最后通过其中的2×2码字写入二维字单元阵列模块将二维数据阵列输出给二维数据记录装置;所述解码器包括二维阵列缓冲模块、二维字单元页构造模块、二维字单元读取模块、2×2码字到一维数据映射模块、一维数据流组装模块,最后通过其中的一维数据流组装模块输出。本发明能解决二维数据阵列在水平和垂直两个方向上,相邻数据1之间,数据0的游程长度最小等于1最大等于3的二维数据阵列构造的技术问题。

The present invention provides a two-dimensional run-length constrained coding and decoding device and method for variable-length code rates, the device includes an encoder and a decoder, and the encoder includes a one-dimensional data stream buffering and grouping module, a 2×2 Codeword generation module, two-dimensional word cell array construction module, 2×2 codeword writing two-dimensional word cell array module, and finally two-dimensional data array output through the 2×2 codeword writing two-dimensional word cell array module For a two-dimensional data recording device; the decoder includes a two-dimensional array buffer module, a two-dimensional word unit page construction module, a two-dimensional word unit reading module, a 2×2 codeword to one-dimensional data mapping module, and a one-dimensional data stream Assemble the module, and finally assemble the module output through the one-dimensional data flow therein. The invention can solve the technical problem of the two-dimensional data array structure in which the run length of the data 0 is at least equal to 1 and at most equal to 3 between adjacent data 1 in the horizontal and vertical directions of the two-dimensional data array.

Description

用于变长码率的二维游程长度受限约束编解码装置及方法Apparatus and method for two-dimensional run-length constrained encoding and decoding for variable-length code rate

技术领域 technical field

本发明属于数据存储领域和通信领域。具体涉及当将二进制数据存储在矩形格子组成的平面上,无论是在水平方向还是在垂直两个方向上,在相邻数据”1”之间,数据“0”的游程长度最少等于1,最多不超过3的编解码方法及其使用装置。本发明是一种变长码率的编译码技术,即输出的二维码字长度和输入的一维数据长度之比是随着输入条件变化而变化,码率是变化的。 The invention belongs to the fields of data storage and communication. Specifically, when storing binary data on a plane composed of rectangular grids, whether in the horizontal direction or in the vertical direction, between adjacent data "1", the run length of data "0" is at least equal to 1, and at most No more than 3 codec methods and devices for their use. The present invention is a coding and decoding technology with a variable length code rate, that is, the ratio of the length of the output two-dimensional code word to the length of the input one-dimensional data changes with the change of the input condition, and the code rate changes.

背景技术 Background technique

在当前主流的磁带和光盘存储技术中,数据是沿着轨道(Track)记录在存储介质上。在这些存储器中,为提高存储系统的可靠性,通常对二进制数据序列做必要的约束限制。其中最为常见的限制是RLL(d,k)游程长度受限约束(Runlength Limited Constraint),d表示在连续数据“1”之间,“0”的游程长度最小值,k表示其最大值。通过选取适当的参数d可控制最高传输频率,以达到减少码间串扰的目的;在读取数据时,参数k则可确保有足够的跳变频率来满足对时钟同步控制的需求。著名的Miller码,即改进型调频码MFM(美国专利号3,108,261,公布日1963年10月22日),就是其中的一个代表。在MFM码中,相邻数据“1”之间,“0”的游程长度至少等于1,最多不超过3。 In current mainstream magnetic tape and optical disc storage technologies, data is recorded on a storage medium along a track (Track). In these memories, in order to improve the reliability of the storage system, necessary constraints are usually imposed on the binary data sequence. The most common restriction is the RLL (d, k) run length limited constraint (Runlength Limited Constraint), where d represents the minimum value of the run length of "0" between continuous data "1", and k represents its maximum value. By selecting the appropriate parameter d, the highest transmission frequency can be controlled to achieve the purpose of reducing intersymbol crosstalk; when reading data, the parameter k can ensure sufficient hopping frequency to meet the demand for clock synchronization control. The famous Miller code, that is, the improved frequency modulation code MFM (US Patent No. 3,108,261, published on October 22, 1963), is one of the representatives. In the MFM code, between adjacent data "1", the run length of "0" is at least equal to 1, and at most no more than 3.

近些年出现了以二维页面方式记录数据的新型存储器,比如全息存储器、二维光盘和二维图案记录等。这类存储器有一个共同特点:数据每次按照二维页面的方式存储在记录介质上,在读取数据时,也是按照整页整页的方式进行。图1描述了8×8的二进制比特数据在这种新型二维存储器中的布局示意。在这个例子中,一个方形格子代表了1位数据信息,即黑色代表“1”,白色代表“0”,每位二进制数据比特“0”或“1”都有4个比特信息和它本身直接相邻(即通常所说的上、下、左和右)。类似于在一维存储技术中对二进制序列做出的约束限制,在这种二维页面记录的存储器中,也需要对二维数据阵列在行(水平)方向和列(垂直)方向上做约束限制。不难看出,前面提到的改进型调频码(MFM),在这种二维情形下就不再有效,即由数据“0”和“1”构成的二维二进制数据阵列在行方向和列方向上不能同时满足当d=1及k=3的时候,对数据“0”的游程长度最小等于1,最多不超过3的限制要求。专利申请201110148840.9提出了一种带保护字的沿二维格子对角线编码方法,基于该专利的方法可构造出由数据“1”和数据“0”组成的二进制矩形数据阵列在行(水平)方向和列(垂直)方向两个方向能同时满足数据“0”的游程长度的最小值等于1,最多不超过3的二维数据阵列。但该专利给出的技术是固定码率的,码字长度和输入数据之比是固定值,即码率等于0.25。 In recent years, new types of memory that record data in two-dimensional pages have emerged, such as holographic memory, two-dimensional optical discs, and two-dimensional pattern records. This type of memory has a common feature: data is stored on the recording medium in the form of two-dimensional pages each time, and when reading data, it is also performed in the form of a full page. Figure 1 depicts the schematic layout of 8×8 binary bit data in this new type of two-dimensional memory. In this example, a square grid represents 1 bit of data information, that is, black represents "1" and white represents "0". Each binary data bit "0" or "1" has 4 bits of information and itself directly Adjacent (that is, commonly referred to as top, bottom, left, and right). Similar to the constraints on binary sequences in one-dimensional storage technology, in this two-dimensional page record memory, it is also necessary to constrain the two-dimensional data array in the row (horizontal) direction and column (vertical) direction limit. It is not difficult to see that the aforementioned modified frequency modulation code (MFM) is no longer effective in this two-dimensional situation, that is, the two-dimensional binary data array composed of data "0" and "1" is in the row direction and column direction. When d=1 and k=3 in the direction, the run length of the data "0" must be at least equal to 1 and not exceed 3 at the same time. Patent application 201110148840.9 proposes a method of coding along the diagonal of a two-dimensional grid with protected words. Based on the method of this patent, a binary rectangular data array composed of data "1" and data "0" can be constructed in rows (horizontally) A two-dimensional data array in which the minimum value of the run length of the data "0" in the two directions of direction and column (vertical) direction is equal to 1 and the maximum is no more than 3 at the same time. However, the technology provided by this patent is a fixed code rate, and the ratio of the code word length to the input data is a fixed value, that is, the code rate is equal to 0.25.

发明内容 Contents of the invention

本发明所要解决的技术问题是:提供用于变长码率的二维游程长度受限约束的编解码装置及使用方法,本发明的编解码方法和装置能解决由“0”和“1”构成的二维数据阵列在水平(行方向)和垂直(列方向)两个方向上,在相邻数据“1”之间,数据“0”的游程长度最小等于1,最大等于3的二维数据阵列构造的技术问题,相对于专利201110148840.9给出的码率等于0.25,本发明的平均编码码率大约提高了大约12.3%,达到了0.2808左右。 The technical problem to be solved by the present invention is to provide a codec device and method of use for two-dimensional run-length constraints of variable-length code rates. The formed two-dimensional data array is in the two directions of horizontal (row direction) and vertical (column direction), between adjacent data "1", the run length of data "0" is at least equal to 1, and the maximum is equal to 3 two-dimensional For the technical problem of data array construction, compared with the code rate given in patent 201110148840.9 which is equal to 0.25, the average code rate of the present invention has increased by about 12.3%, reaching about 0.2808.

为了达到上述发明目的,本发明采取的技术方案是:用于变长码率二维游程长度受限约束的编解码装置,包括编码器和解码器,所述编码器包括: In order to achieve the above-mentioned purpose of the invention, the technical solution adopted by the present invention is: a coding and decoding device for a variable-length code rate two-dimensional run length constraint, including an encoder and a decoder, and the encoder includes:

一维数据流缓冲及分组模块,该模块在缓冲接收一维数据流的同时,按照2比特为一组将其划分成若干个一维数据字; A one-dimensional data stream buffering and grouping module, which divides it into several one-dimensional data words according to 2 bits as a group while buffering and receiving the one-dimensional data stream;

2×2码字生成模块,该模块根据编译码规则表,将一维数据流缓冲及分组模块划分的若干个一维数据字生成相应的2×2二维约束码字,按照先后产生次序输入到2×2码字写入二维字单元阵列模块的2×2字单元缓冲区; 2×2 codeword generation module, which generates corresponding 2×2 two-dimensional constraint codewords from several one-dimensional data words divided by the one-dimensional data stream buffer and grouping module according to the encoding and decoding rule table, and input them in the order of generation 2*2 code words are written into the 2*2 word unit buffer of the two-dimensional word unit array module;

二维字单元阵列构造模块,该模块将二维阵列划分成若干个由大小为2×2的二维字单元组成的二维字单元阵列,并置二维字单元阵列的每个二维字单元写入标志位等于可写标志; Two-dimensional word cell array construction module, which divides the two-dimensional array into several two-dimensional word cell arrays composed of two-dimensional word cells with a size of 2×2, and juxtaposes each two-dimensional word cell array of the two-dimensional word cell array The unit write flag is equal to the writable flag;

2×2码字写入二维字单元阵列模块,该模块将2×2码字生成模块中的2×2二维约束码字序列从本模块的缓冲区按照先后顺序读出,并沿着二维字单元阵列对角行,逐行将2×2二维约束码字写入到二维字单元阵列中; 2×2 codewords are written into the two-dimensional word unit array module, which reads out the 2×2 two-dimensional constrained codeword sequences in the 2×2 codeword generation module from the buffer of this module in sequence, and along the Diagonal rows of the two-dimensional word cell array, writing 2×2 two-dimensional constrained code words into the two-dimensional word cell array row by row;

上述编码器的四个模块依次连接,最后通过其中的2×2码字写入二维字单元阵列模块将二维数据阵列输出给二维数据记录装置; The four modules of the above-mentioned encoder are connected in sequence, and finally the two-dimensional data array is output to the two-dimensional data recording device through the 2×2 code word therein written into the two-dimensional word cell array module;

所述解码器包括: The decoder includes:

二维阵列缓冲模块,该模块主要用于暂时存放从二维数据记录装置读取的大小为2N×2M的二维数据阵列; A two-dimensional array buffer module, which is mainly used to temporarily store a two-dimensional data array with a size of 2N×2M read from a two-dimensional data recording device;

二维字单元页构造模块,该模块主要用于将二维阵列缓冲模块中的2N×2M二维数据阵列划分成由2×2为最小读取单元的N×M的二维字单元阵列,并置二维字单元阵列的每个字单元读取标志位为可读标志; Two-dimensional word unit page construction module, which is mainly used to divide the 2N×2M two-dimensional data array in the two-dimensional array buffer module into N×M two-dimensional word unit arrays with 2×2 as the minimum read unit, juxtaposing each word unit read flag of the two-dimensional word unit array as a readable flag;

二维字单元读取模块,该模块主要用于从二维字单元阵列读取适宜的2×2二维约束码字,并暂时存放所产生的2×2二维约束码字序列; A two-dimensional word unit reading module, which is mainly used to read a suitable 2×2 two-dimensional constrained codeword from the two-dimensional word unit array, and temporarily store the generated 2×2 two-dimensional constrained codeword sequence;

2×2码字到一维数据映射模块,该模块主要用于从二维字单元读取模块中读取2×2二维约束码字序列,根据编译码规则表,将2×2二维约束码字按照先后次序译码成大小等于2比特的一维数据字; 2×2 codeword to one-dimensional data mapping module, this module is mainly used to read 2×2 two-dimensional constrained codeword sequence from two-dimensional word unit reading module, according to the encoding and decoding rule table, convert 2×2 two-dimensional The constrained codeword is decoded into a one-dimensional data word whose size is equal to 2 bits according to the sequence;

一维数据流组装模块,该模块主要用于将2×2码字到一维数据映射模块产生的2比特一维数据字按照产生的先后顺序组装成一维数据流; A one-dimensional data stream assembly module, which is mainly used to assemble the 2-bit one-dimensional data words generated by the 2×2 codeword to one-dimensional data mapping module into a one-dimensional data stream according to the sequence of generation;

上述解码器的五个模块依次连接,最后通过其中的一维数据流组装模块输出。 The five modules of the above decoder are connected in sequence, and finally output through the one-dimensional data stream assembly module.

所述用于变长码率的二维游程长度受限约束的编解码装置的编解码方法,通过编码器实现编码过程,依次包括以下步骤: The encoding and decoding method of the two-dimensional run-length-limited encoding and decoding device used for variable-length code rate, realizes the encoding process through the encoder, and includes the following steps in turn:

S101)一维数据流缓冲及分组模块将输入的二进制一维数据流按每2比特为一组均匀地划分成若干一维2比特数据字,并将该2比特数据字输入到2×2码字生成模块的数据缓冲区暂存; S101) The one-dimensional data stream buffering and grouping module evenly divides the input binary one-dimensional data stream into a number of one-dimensional 2-bit data words in groups of 2 bits, and inputs the 2-bit data words into a 2×2 code The data buffer of the word generation module is temporarily stored;

S102)2×2码字生成模块从数据缓冲区逐一读取一维2比特数据字,选取编解码规则表的输出方案将一维2比特数据字转化成2×2二维约束码字; S102) The 2×2 codeword generation module reads the one-dimensional 2-bit data words from the data buffer one by one, and selects the output scheme of the codec rule table to convert the one-dimensional 2-bit data words into 2×2 two-dimensional constrained codewords;

S103)二维字单元阵列构造模块根据二维数据记录装置的存储大小,将大小为2N×2M的一个二维数据阵列以2×2的字单元为一组,划分成包含N×M个大小相同的2×2二维字单元的二维字单元阵列,并置每个2×2二维字单元写入标志为真,其中N和M为正整数; S103) The two-dimensional word unit array construction module divides a two-dimensional data array with a size of 2N×2M into groups of N×M word units according to the storage size of the two-dimensional data recording device. The two-dimensional word unit array of the same 2×2 two-dimensional word unit, juxtaposing each 2×2 two-dimensional word unit write flag as true, wherein N and M are positive integers;

S104)2×2码字写入二维字单元阵列模块将步骤S102得到的2×2二维约束码字,以步骤S103得到的2×2的二维字单元为基准,沿二维字单元阵列对角方向从右上角到左下角依次将二维约束码字写入大小等于2×2的二维字单元中,同时根据编解码规则表对当前写入的二维字单元的右方和下方的直接相邻二维字单元进行选择性填充;若该对角行的二维字单元全部被写入则进入下一步,若所有的二维约束码字已填充完毕则直接结束编码过程; S104) 2×2 codewords are written into the two-dimensional word unit array module. The 2×2 two-dimensional constrained codeword obtained in step S102 is based on the 2×2 two-dimensional word unit obtained in step S103, along the two-dimensional word unit The two-dimensional constrained codewords are sequentially written into the two-dimensional word units with a size equal to 2×2 from the upper right corner to the lower left corner in the diagonal direction of the array, and at the same time, the right and The directly adjacent two-dimensional word units below are selectively filled; if all the two-dimensional word units of the diagonal row are written, then enter the next step, and if all the two-dimensional constraint codewords have been filled, the encoding process is directly ended;

S105)判断是否有下一个对角行尚未写入,若有则转至步骤S104;若该二维字单元页的所有2×2二维字单元已写满二维约束码字,则进入下一步; S105) Judging whether the next diagonal row has not been written, if so, go to step S104; if all 2×2 two-dimensional word units of the two-dimensional word unit page have been filled with two-dimensional constraint code words, then enter the next step;

S106)判断是否还有未编码的一维数据字,若有则转至步骤S102;否则结束编码过程。 S106) Judging whether there are unencoded one-dimensional data words, if so, go to step S102; otherwise, end the encoding process.

所述的用于变长码率二维游程长度受限约束的编解码装置的编解码方法,通过解码器实现解码过程,依次包括以下步骤: The encoding and decoding method for a codec device with a variable-length code rate two-dimensional run length constraint is implemented by a decoder to realize the decoding process, which includes the following steps in turn:

S201)将从二维数据记录装置读取的二维数据阵列暂时存放在二维数据缓冲模块中; S201) Temporarily store the two-dimensional data array read from the two-dimensional data recording device in the two-dimensional data buffer module;

S202)二维字单元页构造模块读取大小为2N×2M的二维数据阵列,将该二维数据阵列以2×2为最小读取单元进行均匀划分,形成包含于N×M个大小相同的2×2二维字单元的二维字单元阵列,并置二维字单元阵列的每个二维字单元读取标志位为可读标志真,其中N和M为正整数; S202) The two-dimensional word unit page construction module reads a two-dimensional data array with a size of 2N×2M, divides the two-dimensional data array evenly with 2×2 as the minimum reading unit, and forms N×M identically sized A two-dimensional word unit array of 2×2 two-dimensional word units, juxtaposing each two-dimensional word unit of the two-dimensional word unit array to read the flag as a readable flag true, wherein N and M are positive integers;

S203)二维字单元读取模块以该二维字单元阵列的2×2二维字单元为基准,依据编码器编码顺序,沿二维字单元阵列的对角行,从右上角到左下角依次根据每个二维字单元的读取标志选择性读取二维字单元阵列中的二维约束码字,若该行的二维约束码字全部被读取则进入下一步,若当前二维字单元阵列的二维约束码字已读取完毕,则转步骤S205; S203) The two-dimensional word unit reading module takes the 2×2 two-dimensional word unit of the two-dimensional word unit array as a reference, and according to the encoding order of the encoder, along the diagonal row of the two-dimensional word unit array, from the upper right corner to the lower left corner Selectively read the two-dimensional constrained codewords in the two-dimensional word cell array according to the reading sign of each two-dimensional word unit in turn, if all the two-dimensional constrained codewords of this row are read, then enter the next step, if the current two-dimensional constrained codewords are all read The two-dimensional constrained codeword of the dimension word unit array has been read, then go to step S205;

S204)判断是否有下一个对角行尚未译码,若有转至步骤S203;若该二维字单元页的所有对角行的二维约束码字已全部被读取,进入下一步; S204) Judging whether there is a next diagonal row that has not been decoded, if so, go to step S203; if all the two-dimensional constraint codewords of all diagonal rows of the two-dimensional word unit page have been read, go to the next step;

S205)2×2码字到一维数据映射模块根据所选取的编解码表对应的译码表,将从二维字单元读取模块读取的2×2二维约束码字按照产生次序译码成相应的一维2比特数据字,完成后进入下一步; S205) The 2×2 codeword-to-one-dimensional data mapping module decodes the 2×2 two-dimensional constraint codewords read from the two-dimensional word unit reading module according to the generation order according to the decoding table corresponding to the selected codec table Code into a corresponding one-dimensional 2-bit data word, and enter the next step after completion;

S206)一维数据流组装模块将得到的一维2比特数据字按照相应的译码先后次序进行组装,获取对应的一维二进制数据流,解码完成。 S206) The one-dimensional data stream assembly module assembles the obtained one-dimensional 2-bit data words according to the corresponding decoding sequence, obtains the corresponding one-dimensional binary data stream, and completes the decoding.

所述的方法,步骤S104对当前写入2×2二维字单元的右方和下方相邻二维字单元进行选择性填充的方法为: In the method described, the method of selectively filling the adjacent two-dimensional word units on the right and below of the currently written 2×2 two-dimensional word unit in step S104 is as follows:

a)如果写入到当前2×2二维字单元的二维约束码字不属于对角矩阵或次对角矩阵,则判断和当前2×2二维字单元的直接相邻的右方、下方二维字单元的写入标志真假;若为真,在和该标志位对应的二维字单元位置填充值为对角矩阵或次对角矩阵的二维约束码字;若为假或未定义,则不填充二维约束码字; a) If the two-dimensional constrained codeword written into the current 2×2 two-dimensional word unit does not belong to the diagonal matrix or sub-diagonal matrix, then judge the right side, The writing flag of the two-dimensional word unit below is true or false; if it is true, the two-dimensional constrained codeword that is filled in the two-dimensional word unit position corresponding to the flag bit is a diagonal matrix or a sub-diagonal matrix; if it is false or If not defined, the two-dimensional constraint codeword will not be filled;

完成上述写入过程后,置当前2×2二维字单元和填充二维约束码字的二维字单元写入标志为假,表示这些位置以后不能被再次允许写入二维约束码字; After completing the above-mentioned writing process, set the current 2×2 two-dimensional word unit and the two-dimensional word unit writing flag filled with the two-dimensional constraint codeword as false, indicating that these positions cannot be allowed to write the two-dimensional constraint codeword again in the future;

b)如果写入到当前2×2二维字单元的二维约束码字属于对角矩阵或次对角矩阵,在当前二维字单元位置写入此二维约束码字后,将其写入标志设置为假。 b) If the two-dimensional constraint code word written into the current 2×2 two-dimensional word unit belongs to a diagonal matrix or a sub-diagonal matrix, after writing the two-dimensional constraint code word at the position of the current two-dimensional word unit, write it In flag is set to false.

5.根据权利要求3所述的方法,其特征在于,步骤S203选择性读取二维字单元页中的二维约束码字的方法为: 5. The method according to claim 3, wherein the method for selectively reading the two-dimensional constraint codeword in the two-dimensional word unit page in step S203 is:

a)若当前读取的二维字单元读取标志位为真,则读取该二维字单元中的二维约束码字,并置该二维字单元的读取标志为假,即以后不被允许读取;如果当前读取的二维约束码字不属于对角矩阵或次对角矩阵,一并设置当前读取字单元位置的相邻右方、下方的二维字单元读取标志为假,即不允许读取; a) If the reading flag of the currently read two-dimensional word unit is true, read the two-dimensional constraint code word in the two-dimensional word unit, and set the reading flag of the two-dimensional word unit to false, that is, in the future Not allowed to read; if the currently read two-dimensional constraint code word does not belong to the diagonal matrix or sub-diagonal matrix, set the two-dimensional word unit adjacent to the right and below the current read word unit position to read The flag is false, that is, reading is not allowed;

b)若当前读取的二维字单元读取标志位为假,则转入读取本二维字单元所在对角行的下一个二维字单元中的数据。 b) If the reading flag of the currently read two-dimensional word unit is false, transfer to read the data in the next two-dimensional word unit in the diagonal row where the current two-dimensional word unit is located.

本发明的技术效果如下所述: Technical effect of the present invention is as follows:

1)编码器是变长的码率。编码器的码率是输出码字的比特数和输入码字比特数之比,码率越高,表示编码效果越好,在本发明中,数据在编码阶段,根据编码器的上下文情形,将一维2比特数据字输出成长度不同的二维约束码字,这种变长码字的编码方法,能充分利相邻数据之间的关联性,因此码率较已有的编码方法平均码率要高出12.3%。 1) The encoder is a variable-length code rate. The code rate of the encoder is the ratio of the number of bits of the output codeword to the number of bits of the input codeword. The higher the code rate, the better the encoding effect. In the present invention, the data is encoded according to the context of the encoder. One-dimensional 2-bit data words output two-dimensional constrained codewords with different lengths. This variable-length codeword encoding method can fully utilize the correlation between adjacent data, so the code rate is higher than that of existing encoding methods . The code rate is 12.3% higher.

2)编译码规则表简单。在本发明中,一维2比特数据字根据数据前后关联,可选取不同的输出方法来满足约束限制条件。通过简单的译码方程,即可实现一维2比特数据字的译码。 2) The compilation and decoding rule table is simple. In the present invention, the one-dimensional 2-bit data word can select different output methods according to the context and context of the data to meet the constraints. Through simple decoding equations, the decoding of one-dimensional 2-bit data words can be realized.

附图说明 Description of drawings

图1是在两个方向上都满足(1,3)游程长度受限约束的8×8二维数据阵列。 Figure 1 is an 8×8 two-dimensional data array that satisfies (1,3) run-length constraints in both directions.

图2是2×2个方形格子组成的二维字单元。 Figure 2 is a two-dimensional character unit composed of 2×2 square grids.

图3是二维字单元阵列坐标及对角行编号示意图。 Fig. 3 is a schematic diagram of the coordinates of the two-dimensional word cell array and the numbering of diagonal rows.

图4是数据在二维字单元阵列中的读/写顺序示意图。 FIG. 4 is a schematic diagram of the read/write sequence of data in the two-dimensional word cell array.

图5是计算码率的坐标示意图。 FIG. 5 is a schematic diagram of coordinates for calculating code rates.

图6是变码率的编码器原理框图。 Fig. 6 is a functional block diagram of an encoder with a variable code rate.

图7是变码率的译码器原理框图。 Fig. 7 is a functional block diagram of a decoder with a variable code rate.

图8是基于表1、2第一种编译码规则的二维数据阵列构造实施例。 FIG. 8 is an embodiment of the two-dimensional data array structure based on the first encoding and decoding rules in Tables 1 and 2.

图9是基于表1、2第一种编译码规则的二维字单元阵列在编码过程变化示意图。 FIG. 9 is a schematic diagram of the changes of the two-dimensional word unit array during the encoding process based on the first encoding and decoding rules in Tables 1 and 2.

图10是基于表1、2第一种编译码规则的二维字单元阵列译码实施例。 Fig. 10 is a decoding embodiment of a two-dimensional word cell array based on the first encoding and decoding rules in Tables 1 and 2.

图11是基于表1、2第一种编译码规则的二维字单元阵列在译码过程中的变化示意图。 FIG. 11 is a schematic diagram of changes in the decoding process of the two-dimensional word cell array based on the first encoding and decoding rules in Tables 1 and 2.

图12是基于表3、4第二种编译码规则的二维数据阵列构造实施例。 FIG. 12 is an embodiment of the two-dimensional data array structure based on the second encoding and decoding rules in Tables 3 and 4.

图13是基于表3、4第二种编译码规则的二维字单元阵列译码实施例。 FIG. 13 is a decoding embodiment of a two-dimensional word cell array based on the second encoding and decoding rules in Tables 3 and 4.

图14是二维约束码字沿着对角线的第一种相邻类型。 Figure 14 is the first adjacent type of two-dimensional constrained codewords along the diagonal.

图15是二维约束码字沿着对角线的第二种相邻类型。 Figure 15 is the second adjacent type of two-dimensional constrained codewords along the diagonal.

图16是二维约束码字沿着对角线的第三种相邻类型。 Figure 16 is the third adjacent type of two-dimensional constrained codewords along the diagonal.

图17是二维约束码字沿着对角线的第四种相邻类型。 Figure 17 is the fourth adjacent type of two-dimensional constrained codewords along the diagonal.

具体实施方式 Detailed ways

针对背景技术提出的问题,本发明提供了两种变长码率的二维游程长度受限约束的编解码方法,能在二维数据存储和通信的环境下,使得二进制比特信息满足预先指定的约束限制条件。即当二进制数据“0”和“1”写入在矩形格子组成的阵列中,也能构造出在相邻数据“1”之间,无论是在行(水平)方向还是列(垂直)方向上,数据“0”的游程长度最小等于1,最多不超过3的二进制数据阵列。和专利201110148840.9不同之处在于:本发明是一种变长码率的编译码技术,即输出的二维码字长度和输入的一维数据长度之比是随着输入条件变化而变化,码率是变长的。采取本发明给出的技术方案,充分利用二维矩形格子和二维约束码字之间的关系,并极大化利用了这种关系;编码的平均码率则从专利201110148840.9的0.25提高到0.2808,码率提高了大约12.3%。换句话说,在同等条件下,采取本发明可提高大约12.3%的系统存储容量。 Aiming at the problems raised by the background technology, the present invention provides two encoding and decoding methods with two-dimensional run-length constraints with variable-length code rates, which can make the binary bit information meet the pre-specified requirements in the environment of two-dimensional data storage and communication. Constraints. That is, when the binary data "0" and "1" are written in an array composed of rectangular grids, it is also possible to construct between adjacent data "1", whether in the row (horizontal) direction or the column (vertical) direction , a binary data array whose run length of the data "0" is at least equal to 1 and at most no more than 3. The difference from patent 201110148840.9 is that the present invention is a coding and decoding technology with a variable length code rate, that is, the ratio of the length of the output two-dimensional code word to the length of the input one-dimensional data changes with the input conditions, and the code rate is variable length. By adopting the technical solution given by the present invention, the relationship between the two-dimensional rectangular grid and the two-dimensional constraint codeword is fully utilized, and the relationship is maximized; the average coding rate is increased from 0.25 in patent 201110148840.9 to 0.2808 , the code rate has increased by about 12.3%. In other words, under the same conditions, the system storage capacity can be increased by about 12.3% by adopting the present invention.

本发明适用于将二进制数据按照二维方形格子记录的数据存储系统。存储系统的典型代表有全息全息存储器、二维光盘等二维新型存储器。本发明的一个发明目的是提供二种变长码率的二维游程长度受限约束的编码方法。本发明的另一个目的是提供和二种变长码率的编码方法相应的二维游程长度受限约束的二种解码方法。本发明的另一个目的是提供相应的编码和解码装置。 The invention is suitable for a data storage system that records binary data according to two-dimensional square grids. Typical representatives of storage systems include holographic holographic memory, two-dimensional optical disk and other two-dimensional new memory. An object of the present invention is to provide two variable-length code rate two-dimensional run-length-constrained coding methods. Another object of the present invention is to provide two decoding methods with two-dimensional run length constraints corresponding to the two variable-length code rate encoding methods. Another object of the invention is to provide corresponding encoding and decoding means.

变长码率的二维游程长度受限(1,3)约束编译码方法,以表1、2所示的第一种编译码规则为例,包括下述步骤: The two-dimensional run-length-limited (1,3) constrained encoding and decoding method of the variable-length code rate, taking the first encoding and decoding rule shown in Tables 1 and 2 as an example, includes the following steps:

表1 第一种编译码规则的编码表 Table 1 The coding table of the first coding rule

表2 第一种编译码规则的译码表 Table 2 Decoding table of the first encoding and decoding rules

第一步:将输入的一维二进制数据流按照两比特为一组,划分成大小若干个一维2比特数据字,每个一维2比特数据字的取值有以下4种可能:00,01,10,11。并将一维2比特数据字输入到一维数据缓冲区暂存,转步骤二; Step 1: Divide the input one-dimensional binary data stream into several one-dimensional 2-bit data words according to a group of two bits. The value of each one-dimensional 2-bit data word has the following four possibilities: 00, 01, 10, 11. And input the one-dimensional 2-bit data word into the one-dimensional data buffer for temporary storage, and turn to step 2;

第二步:将大小等于2N×2M的二维数据页以2×2为一组,划分成N×M个大小相同的二维字单元页,并置二维字单元阵列的每个字单元写入标志为真,然后转步骤三; Step 2: Divide the two-dimensional data pages with a size equal to 2N×2M into a group of 2×2 into N×M two-dimensional word unit pages of the same size, and arrange each word unit of the two-dimensional word unit array Write flag is true, then go to step 3;

第三步:从步骤一的一维缓冲区读取一维2比特数据字序列,并按照表1、2或表3、4所述编译码规则表的输出方案三,将缓冲区的一维2比特数据字序列逐一编码映射成2×2的二维约束码字序列,然后将该2×2的二维约束码字序列以步骤二产生的二维字单元阵列对角行为基准,沿着二维字单元阵列的45°对角行,逐行从右上角到左下角依次将该2×2的二维约束码字写入二维字单元阵列的相应字单元中,转步骤四; The third step: read the one-dimensional 2-bit data word sequence from the one-dimensional buffer of step one, and according to the output scheme three of the encoding and decoding rule table described in Table 1, 2 or Table 3, 4, the one-dimensional buffer of the buffer The 2-bit data word sequence is coded and mapped one by one into a 2×2 two-dimensional constrained codeword sequence, and then the 2×2 two-dimensional constrained codeword sequence is based on the diagonal behavior of the two-dimensional word unit array generated in step 2, along the For the 45° diagonal row of the two-dimensional word cell array, write the two-dimensional constraint code words of this 2×2 into the corresponding word units of the two-dimensional word cell array from the upper right corner to the lower left corner row by row, and turn to step 4;

表3 第二种编译码规则的编码表 Table 3 Encoding table of the second coding rule

表4 第二种编译码规则的译码表 Table 4 Decoding table of the second encoding and decoding rules

第四步:在步骤(3)的基础上,如果当前写入的二维字单元阵列坐标是,且写入标志为真,同时待写入的2×2二维约束码字是(如果步骤(3)采取表3、4所述的第二种编译码规则,则代替),则在位置写入时候,并判断两二维字单元位置的写入标志位真假,若为假,略过,否则在两位置视情况写入二维约束码字(当步骤(3)采取表3、4所述的第二种编译码规则,则代替),最后重置本步骤各二维字单元相应坐标位置的写入标志为假,转步骤五; Step 4: On the basis of step (3), if the coordinates of the currently written two-dimensional word cell array are , and the write flag is true, and the 2×2 two-dimensional constraint codeword to be written at the same time is (If step (3) adopts the second encoding and decoding rules described in tables 3 and 4, then use instead), then in position to write time, and judge and The writing flag bit of the two-dimensional word unit position is true or false, if it is false, it is skipped, otherwise it is and Write two-dimensional constraint code words according to the situation (When step (3) adopts the second encoding and decoding rules described in Table 3 and 4, then use replace), and finally reset the writing flag of the corresponding coordinate position of each two-dimensional word unit in this step to false, and go to step five;

;;         (A) ; ; (A)

;;        (B) ; ; (B)

第五步:如果当前写入的二维单元阵列坐标是,且待写入的2×2二维约束码字是,直接在位置写入(如果步骤(3)采取表3、4编译码规则,则步骤(5)的两处均用代替),并置该坐标的写入标志为假,表示此坐标已写过数据,转步骤六; Step 5: If the coordinates of the currently written two-dimensional cell array are , and the 2×2 two-dimensional constrained codeword to be written is, directly at the position Write (if step (3) adopts table 3, 4 encoding and decoding rules, then the two places of step (5) Use evenly replace), and set the writing flag of this coordinate as false, indicating that data has been written at this coordinate, and go to step 6;

第六步:重复步骤四,直到步骤(2)产生的所有2×2二维约束字写入到N×M的二维字单元阵列。 Step 6: Repeat step 4 until all 2×2 two-dimensional constraint words generated in step (2) are written into the N×M two-dimensional word cell array.

(以表1、2所述的第一种编译码规则为例)译码步骤如下: (Taking the first encoding and decoding rules described in Tables 1 and 2 as an example) the decoding steps are as follows:

第一步:读取大小等于2N×2M的二进制数据阵列,将二维数据阵列以2×2为一个二维字单元,划分成N×M的二维字单元阵列,并置该二维字单元阵列的各个字单元读取标志为真; Step 1: Read a binary data array whose size is equal to 2N×2M, divide the two-dimensional data array into N×M two-dimensional word unit arrays with 2×2 as a two-dimensional word unit, and place the two-dimensional word unit Each word unit read flag of the cell array is true;

第二步:沿着二维字单元阵列的45°对角线逐行从右上角到左下角依次读取二维约束码字; Step 2: Read the two-dimensional constrained codeword row by row along the 45° diagonal of the two-dimensional word cell array from the upper right corner to the lower left corner;

第三步:在步骤二的基础上,如果当前坐标读取标志为真,则读取相应的2×2二维约束码字,同时判断是否等于,如果是,则置坐标的读取标志为假; Step 3: On the basis of Step 2, if the current coordinates If the read flag is true, read the corresponding 2×2 two-dimensional constraint codeword, and judge whether it is equal to , if yes, set the coordinates and The read flag of is false;

第四步:根据二维字单元阵列各个字单元读取标志位的真假,判断二维字单元阵列所有二维字单元是否被全部读取,若是转步骤五,否则转步骤二; The fourth step: according to whether each word unit of the two-dimensional word unit array reads the true or false of the flag bit, judge whether all the two-dimensional word units of the two-dimensional word unit array are all read, if turn to step five, otherwise turn to step two;

第五步:将步骤三得到的2×2二维约束码字根据表1、2或表3、4的译码表译码成一维2比特数据字; Step 5: Decode the 2 × 2 two-dimensional constrained codewords obtained in step 3 into one-dimensional 2-bit data words according to the decoding tables in Tables 1 and 2 or Tables 3 and 4;

第六步:将步骤五得到的一维2比特数据字按照生成的先后次序组装成一维数据流并输出,译码完成。 Step 6: Assemble the one-dimensional 2-bit data words obtained in step five into a one-dimensional data stream according to the order of generation and output it, and the decoding is completed.

为了实现上述目的,本发明还提供了实现上述数据编码方法的编码器,包括: In order to achieve the above object, the present invention also provides an encoder for implementing the above data encoding method, including:

一维数据流缓冲及分组模块,该模块在缓冲一维数据流的同时,根据二维阵列的大小,将数据划分成若干个一维2比特数据字; A one-dimensional data stream buffering and grouping module, which divides the data into several one-dimensional 2-bit data words according to the size of the two-dimensional array while buffering the one-dimensional data stream;

2×2码字生成模块,该模块根据表1、2或表3、4所述编译码规则表的输出方案三,将一维数据流缓冲及分组模块的若干个一维2比特数据字生成相应的2×2二维约束码字,按照先后产生次序输入到2×2码字写入二维字单元阵列模块的2×2字单元缓冲区; 2 × 2 code word generation module, this module generates several one-dimensional 2-bit data words of the one-dimensional data stream buffering and grouping module according to the output scheme three of the encoding and decoding rule table described in tables 1 and 2 or tables 3 and 4 The corresponding 2×2 two-dimensional constraint codewords are input to the 2×2 word unit buffer of the two-dimensional word unit array module according to the order of generation;

二维字单元阵列构造模块,该模块将二维阵列划分成若干个由2×2阵列组成的字单元阵列,并置二维字单元阵列的每个二维字单元写入标志位等于可写标志“0”; The two-dimensional word cell array construction module, which divides the two-dimensional array into several word cell arrays composed of 2×2 arrays, and juxtaposes the writing flag bit of each two-dimensional word cell of the two-dimensional word cell array to be equal to the writable flag "0";

2×2码字写入二维字单元阵列模块,该模块将2×2码字生成模块中的2×2二维约束码字序列从本模块的缓冲区按照先后顺序读出,并沿着二维字单元阵列45°的对角行,逐行将2×2二维约束码字写入到二维阵列中; 2×2 codewords are written into the two-dimensional word unit array module, which reads out the 2×2 two-dimensional constrained codeword sequences in the 2×2 codeword generation module from the buffer of this module in sequence, and along the 45° diagonal rows of the two-dimensional word cell array, and write 2×2 two-dimensional constrained codewords into the two-dimensional array row by row;

为了实现上述目的,本发明还提供了实现上述数据解码方法的编码器,包括: In order to achieve the above object, the present invention also provides an encoder for implementing the above data decoding method, including:

二维阵列缓冲模块,该模块主要用于暂时存放从二维数据记录装置读取的2N×2M二维数据阵列; Two-dimensional array buffer module, which is mainly used to temporarily store the 2N×2M two-dimensional data array read from the two-dimensional data recording device;

二维字单元页构造模块,该模块主要用于将二维阵列缓冲模块中的2N×2M二维数据阵列划分成由2×2为最小读取单元的N×M的二维字单元阵列,并置二维字单元阵列的每个字单元读取标志位为可读标志“0”; Two-dimensional word unit page construction module, which is mainly used to divide the 2N×2M two-dimensional data array in the two-dimensional array buffer module into N×M two-dimensional word unit arrays with 2×2 as the minimum read unit, The read flag bit of each word unit of the two-dimensional word cell array is arranged as a readable flag "0";

二维字单元读取模块,该模块主要用于从当前二维字单元阵列读取适宜的2×2二维约束码字,并暂时存放此二维字单元阵列所产生的全部2×2二维约束码字; Two-dimensional word unit reading module, this module is mainly used to read suitable 2×2 two-dimensional constraint codewords from the current two-dimensional word unit array, and temporarily store all 2×2 two-dimensional code words generated by this two-dimensional word unit array. Dimensional constraint code word;

2×2码字到一维数据映射模块,该模块主要用于从二维字单元读取模块中按照先后产生次序读取2×2二维约束码字,根据表1、2或表3、4所述编译码规则的译码表,将2×2二维约束码字按照先后次序译码成大小等于2比特的一维数据字; 2×2 codewords to one-dimensional data mapping module, this module is mainly used to read 2×2 two-dimensional constrained codewords from the two-dimensional word unit reading module according to the sequence of generation, according to Table 1, 2 or Table 3, 4. The decoding table of the encoding and decoding rules, which decodes the 2×2 two-dimensional constraint codewords into one-dimensional data words whose size is equal to 2 bits according to the sequence;

一维数据流组装模块,该模块主要用于将2×2码字到一维数据映射模块产生的2比特一维数据字按照产生的先后顺序组装成一维数据流。 A one-dimensional data stream assembly module, which is mainly used to assemble the 2-bit one-dimensional data words generated by the 2×2 codeword to one-dimensional data mapping module into a one-dimensional data stream according to the sequence of generation.

下面结合附图和实施例对本发明作进一步的详细说明: Below in conjunction with accompanying drawing and embodiment the present invention is described in further detail:

如图1所示,描述了根据本发明产生的二维数据阵列,该二维数据阵列无论是在水平方向还是在垂直方向上,在相邻数据“1”之间,数据“0”的游程长度都满足最小等于1,最多不超过3的约束条件。图1的左图是二维数据在全息存储器的记录模式,右边是二进制数据阵列的数字模式。 As shown in Figure 1, a two-dimensional data array produced according to the present invention is described, whether in the horizontal direction or in the vertical direction, the run length of data "0" between adjacent data "1" The length satisfies the constraints that the minimum is equal to 1 and the maximum is no more than 3. The left figure of Figure 1 is the recording mode of two-dimensional data in the holographic memory, and the right is the digital mode of the binary data array.

如图2所示,2×2个方形格子构造的二维字单元是编译码二维数据阵列的最小单位。 As shown in FIG. 2 , a two-dimensional word unit constructed of 2×2 square grids is the smallest unit of a codec two-dimensional data array.

如图3所示,描述了二维字单元阵列坐标及对角行编号示意图。图中阵列的每个基本单位是二维字单元,该二维字单元由图2所示的2×2方形格子组成。 As shown in FIG. 3 , a schematic diagram of coordinates of a two-dimensional word cell array and numbers of diagonal rows is described. Each basic unit of the array in the figure is a two-dimensional word unit, and the two-dimensional word unit is composed of a 2×2 square grid as shown in FIG. 2 .

如图4所示,描述的是数据在二维字单元阵列的读/写顺序。即在二维字单元中,数据的读取/写入均是沿着45°的对角线逐行逐行进行,在45°对角线的每一行,都是从右上角往左下角按照顺序对数据进行读取/写入。 As shown in FIG. 4, it describes the read/write sequence of data in the two-dimensional word cell array. That is, in the two-dimensional word unit, the reading/writing of data is carried out line by line along the 45° diagonal, and each line of the 45° diagonal is from the upper right corner to the lower left corner according to the Data is read/written sequentially.

如表1、2所示,表1给出的是第一种编译码规则的编码表,在该编码表中,一维数据字00、01、10根据上下文有3种方案二维约束码字可供编码输出;一维数据字11只有一种二维约束码字供编码输出。表2给出的是基于表1所述编码规则所对应的译码规则表。在该译码规则表中,如果2比特一维数据字用表示,2×2的二维约束码字用表示。基于这个编译码规则,2×2的二维约束码字基本编码方程如下所示: As shown in Tables 1 and 2, Table 1 shows the coding table of the first encoding and decoding rule. In this coding table, the one-dimensional data words 00, 01, and 10 have three schemes for two-dimensional constraint code words according to the context. available for coding output; the one-dimensional data word 11 has only one kind of two-dimensional constraint code word for coding output. Table 2 shows the decoding rule table corresponding to the encoding rule based on Table 1. In the decoding rule table, if the 2-bit one-dimensional data word is used Indicates that the 2×2 two-dimensional constrained codeword uses express. Based on this encoding and decoding rule, the basic encoding equation of the 2×2 two-dimensional constrained codeword is as follows:

其中×1~×2为一维数据字的单个比特位。Y11~Y22为二维码字的比特位。同样根据该基本编码方程,在译码的过程中,一维2比特数据字的译码方程如下所示: Among them, × 1 to × 2 are single bits of a one-dimensional data word. Y 11 to Y 22 are bits of the two-dimensional code word. Also according to the basic encoding equation, in the process of decoding, the decoding equation of the one-dimensional 2-bit data word is as follows:

;

如式A所示,式A给出的是在表1、2所述第一种编译码规则表的基础上,对4个2×2的二维约束码字进行的分类。这3个二维约束字是一类,分别用表示;单独划成第二类,用表示,为方便描述,简称对角矩阵。 As shown in Formula A, Formula A provides the classification of four 2×2 two-dimensional constrained codewords based on the first encoding and decoding rule table described in Tables 1 and 2. , , These three two-dimensional constraint words belong to one category, and are respectively used , and express; Separately classified into the second category, with Represents, for the convenience of description, referred to as a diagonal matrix.

表3、4给出的是第二种编译码规则。表3给出的是基于第二种编译码规则的基本编码表,在这个编码规则中,一维数据字00、01、10根据上下文采用另外的3种二维约束码字方案供编码输出;一维数据字11同第一种方案一样也只有一种编码输出方案供选择。表4给出的是基于表3所述编码规则的译码表。如果一维2比特数据字仍用表示,2×2的二维约束码字仍用表示。基于该第二种编译码规则,2×2的二维约束码字基本编码方程如下所示: Tables 3 and 4 show the second encoding and decoding rules. Table 3 shows the basic encoding table based on the second encoding and decoding rule. In this encoding rule, the one-dimensional data words 00, 01, and 10 adopt three other two-dimensional constrained codeword schemes for encoding output according to the context; The one-dimensional data word 11 is the same as the first scheme, and there is only one encoding output scheme to choose from. Table 4 shows the decoding table based on the coding rules described in Table 3. If a one-dimensional 2-bit data word is still used Indicates that the 2×2 two-dimensional constrained codewords still use express. Based on the second encoding and decoding rule, the basic encoding equation of the 2×2 two-dimensional constrained codeword is as follows:

根据该第二种基本编译码规则,一维2比特数据字的第二种译码方程如下所示: According to the second basic encoding and decoding rules, the second decoding equation of the one-dimensional 2-bit data word is as follows:

;

如式B所示,式B给出的是是在表3、4所述第二种编译码规则表的基础上,对4个2×2的二维约束码字进行的分类,这3个二维约束字是一类,分别用表示;单独划成第二类,用表示,为方便描述,简称次对角矩阵。 As shown in formula B, what formula B provides is the classification of four 2×2 two-dimensional constrained codewords based on the second encoding and decoding rule table described in Tables 3 and 4. , , These three two-dimensional constraint words belong to one category, and are respectively used , and express; Separately classified into the second category, with Represents, for the convenience of description, referred to as subdiagonal matrix.

如图5所示,该图描述了在基于表1、2和表3、4的两种编译码规则上,如何计算这两种变长编码方法的平均码率。即计算在单元阵列中坐标的出现写入二维约束码字的概率。以表1、2所述第一种编译码方法为例,具体计算编码方法的平均码率如下 As shown in Figure 5, the figure describes how to calculate the average code rate of the two variable-length coding methods based on the two encoding and decoding rules based on Tables 1 and 2 and Tables 3 and 4. i.e. compute the coordinates in the cell array The probability of writing the two-dimensional constrained codeword for the occurrence of . Taking the first encoding and decoding method described in Tables 1 and 2 as an example, the average code rate of the specific calculation encoding method is as follows :

首先将一维二进制数据序列按照两两一组,进行划分,然后根据一维到二维映射关系,依次将一维2比特数据字映射成2×2的二维字单元,即将一维二进制数据序列转化成二维2×2字单元数据序列。为了方便描述问题,以第一种变码率方法为例,即将2×2的二维字单元数据划分成两类,也就是二维2×2字单元数据序列由由组成。这里,且First, the one-dimensional binary data sequence is divided into groups of two by two, and then according to the one-dimensional to two-dimensional mapping relationship, the one-dimensional 2-bit data words are sequentially mapped into 2×2 two-dimensional word units, that is, the one-dimensional binary data The sequence is converted into a two-dimensional 2×2 word unit data sequence. In order to facilitate the description of the problem, take the first variable code rate method as an example, that is, divide the 2×2 two-dimensional word unit data into two types , that is, the two-dimensional 2×2 word unit data sequence consists of Consists of. here ,and ; .

一般情况下,的概率等于,而的概率等于。经过上述映射变换后,一维二进制数据序列转化成二维字单元数据序列。显然经过上述变换后,4个2×2二维约束码字组成的阵列序列熵等于,即。在二维单元阵列中,用表示当然单元的写入值,其中。在二维单元阵列坐标等于的写入值用表示。同时由于2×2二维约束码字写入到二维字单元阵列是按照45°对角行逐行写入,因此在对角第N行,2×2二维约束码字沿着对角线存在如图14~图17所示四种相邻类型。在图14第一种类型里;图15第二种类型里,;图16第三种类型里;图17第四种类型里,其中i=1,2,3。显然编码器的平均码率 In general, The probability is equal to ,and The probability is equal to . After the above mapping transformation, the one-dimensional binary data sequence is transformed into a two-dimensional word unit data sequence. Obviously, after the above transformation, the entropy of the array sequence composed of four 2×2 two-dimensional constrained codewords is equal to ,Right now . In a two-dimensional cell array, use represents the write value of the course cell, where . In a 2D cell array coordinates equal to The write value of express. At the same time, because the 2×2 two-dimensional constrained codewords are written into the two-dimensional word cell array line by row according to the 45° diagonal row, so in the Nth diagonal row, the 2×2 two-dimensional constrained codewords are written along the diagonal There are four adjacent types of lines as shown in Figure 14 to Figure 17. In the first type in Figure 14 , ; In the second type in Figure 15, ; Figure 16 in the third type , ; Figure 17 in the fourth type , where i=1,2,3. Obviously the average code rate of the encoder

其中表示在任意位置写入二维约束码字的概率。根据写入二维单元数据的先后次序,要在位置任意写入二维约束码字,根据约束条件,即在位置及位置上的单元数据值应该同时等于。结合说明书附图5有: in in any position The probability of writing a 2D constrained codeword. According to the order of writing two-dimensional unit data, the position Arbitrarily write two-dimensional constraint codewords , according to the constraints, that is, at position and location The cell data values on the should both be equal to . In conjunction with accompanying drawing 5 of the description, there are:

         

         

         

综合方程(2)、(3)、(4)、(5)、(6)、(7)、(8),即有如下方程: Combining equations (2), (3), (4), (5), (6), (7), and (8), we have the following equations:

           

其中。解方程,有 in . Solving equations ,have

代入方程(1),即 Substitute into equation (1), that is

通常二进制数据流是独立同分布的,即“0”和“1”的概率都等于1/2,则二进制数据流用表1、2所述第一种编译码规则采取输出方案三直接转化为二维约束码字序列时,二维约束码字出现的概率等于,根据上面的计算公式(11),因此变码率的平均码率。显然采取第二种表3、4的编译码规则方法得到的平均码率和第一种方法一样。 Usually the binary data stream is independent and identically distributed, that is, the probability of "0" and "1" is equal to 1/2, then the binary data stream is directly converted into two dimensional constraint codeword sequence, the two-dimensional constraint codeword The probability of occurrence is equal to , according to the above calculation formula (11), so the average code rate of variable code rate . Apparently, the average code rate obtained by adopting the encoding and decoding rule method of the second table 3 and 4 is the same as that of the first method.

如图6所示,编码器编码过程如下:首先将一维数据流输入到一维数据流缓冲及分组模块。该模块在缓冲一维数据流的同时,将数据划分成若干个长度相等的分组,分组大小等于2比特数据字。一维数据流经过分组模块后,首先将大小等于2比特的数据分组输入到2×2码字生成模块,然后再根据表1、2或表3、4所述编译码规则表的基本编码表,首先生成2×2的二维约束码字,并将形成的2×2二维约束码字序列输入到2×2码字写入二维字单元阵列模块的二维字单元缓存起来。另一方面,二维字单元阵列构造模块按照2×2个格子构成一个二维字单元,将大小等于2N×2M的二维阵列划分成N×M的二维字单元阵列。二维数据阵列的生成是由二维码字写入阵列模块来完成。当完成上述操作后,2×2码字写入二维字单元阵列模块从本模块的缓存中读取2×2约束码字,并根据表1、2或表3、4的基本编码规则,沿着图3二维字单元阵列45°的对角行逐行逐行将2×2约束码字写入。在每个对角行的写入过程中,写入的顺序按照图4所述,即从当前对角行的左上角往右下角逐个写入。根据式A或式B对2×2二维约束码字的分类,选取相应二维约束码字写入对应位置的二维字单元中,从而实现将一维数据流编码成二维数据阵列。以表1、2所述第一种编译码规则为例,其编码步骤包括: As shown in Figure 6, the encoding process of the encoder is as follows: first, the one-dimensional data stream is input to the one-dimensional data stream buffering and grouping module. While buffering the one-dimensional data stream, the module divides the data into several equal-length packets, and the packet size is equal to 2-bit data words. After the one-dimensional data stream passes through the grouping module, firstly, the data group whose size is equal to 2 bits is input to the 2×2 code word generation module, and then according to the basic coding table of the encoding and decoding rule table described in Table 1, 2 or Table 3, 4 , first generate 2×2 two-dimensional constrained codewords, and input the formed 2×2 two-dimensional constrained codeword sequence to the two-dimensional word unit cache of the 2×2 codeword write two-dimensional word unit array module. On the other hand, the two-dimensional word unit array construction module constructs a two-dimensional word unit according to 2×2 grids, and divides the two-dimensional array with a size equal to 2N×2M into N×M two-dimensional word unit arrays. The generation of the two-dimensional data array is completed by writing the two-dimensional code word into the array module. After the above operations are completed, the 2×2 codeword is written into the two-dimensional word cell array module to read the 2×2 constraint codeword from the cache of this module, and according to the basic coding rules in Tables 1 and 2 or Tables 3 and 4, The 2×2 constraint codewords are written row by row along the 45° diagonal rows of the two-dimensional word cell array in FIG. 3 . During the writing process of each diagonal row, the writing sequence is as described in FIG. 4 , that is, writing one by one from the upper left corner to the lower right corner of the current diagonal row. According to the classification of 2×2 two-dimensional constrained codewords by formula A or formula B, the corresponding two-dimensional constrained codewords are selected and written into the two-dimensional word units at the corresponding positions, so as to realize the encoding of one-dimensional data streams into two-dimensional data arrays. Taking the first encoding and decoding rules described in Tables 1 and 2 as an example, the encoding steps include:

(1)将输入的一维数据流按照2个比特为一组,划分成若干个一维数据字; (1) Divide the input one-dimensional data stream into several one-dimensional data words according to a group of 2 bits;

(2)将步骤(1)产生的一维2比特数据字根据表1、2所述编译码规则表的输出方案三,将2比特的一维数据字编码成2×2的二维约束码字; (2) Encode the one-dimensional 2-bit data word generated in step (1) into a 2×2 two-dimensional constraint code according to the output scheme 3 of the encoding and decoding rule table described in Table 1 and 2 Character;

(3)以2×2格子构成一个二维字单元,将二维2N×2M阵列划分以二维字单元为单位的N×M二维字单元阵列,并置二维字单元阵列的每个字单元可写标志为真“0”; (3) A two-dimensional word unit is formed with a 2×2 grid, and the two-dimensional 2N×2M array is divided into N×M two-dimensional word unit arrays with two-dimensional word units as units, and each of the two-dimensional word unit arrays is juxtaposed The word unit writable flag is true "0";

(4)在步骤(3)构成的二维字单元阵列基础上,将步骤(2)得到的2×2二维约束码字序列,按照式A对2×2二维约束码字的分类,沿着二维字单元阵列45°对角行,逐行从右上角往左下角方向依次写入数据; (4) On the basis of the two-dimensional word unit array formed in step (3), the 2×2 two-dimensional constrained codeword sequence obtained in step (2) is classified according to formula A to the 2×2 two-dimensional constrained codewords, Along the 45° diagonal row of the two-dimensional word cell array, data is written row by row from the upper right corner to the lower left corner;

(5)在步骤(4)的基础上,如果当前写入的二维字单元阵列坐标是,且待写入的2×2二维约束码字是,在位置写入时候,判断两位置的写入标志位真假,若为假,略过,否则在两位置视情况写入二维约束码字,并重置相应坐标位置的写入标志为假“1”,表示这些位置的写入操作已完成,转步骤(6); (5) On the basis of step (4), if the coordinates of the currently written two-dimensional word cell array are , and the 2×2 two-dimensional constraint codeword to be written is , at position to write time, judgment and The writing flag of the two positions is true or false, if it is false, skip it, otherwise in and Write two-dimensional constraint codewords in the two positions according to the situation, and reset the writing flag of the corresponding coordinate position to false "1", indicating that the writing operation of these positions has been completed, and go to step (6);

(6)如果当前写入的二维字单元阵列坐标是,且待写入的2×2二维约束码字是,直接在位置写入,并置该坐标的写入标志为假“1”,表示该位置写入操作完成; (6) If the coordinates of the currently written two-dimensional word cell array are , and the 2×2 two-dimensional constrained codeword to be written is, directly at the position Write, and set the write flag of this coordinate to false "1", indicating that the write operation at this position is completed;

(7)重复步骤(4),直到步骤(2)产生的所有2×2二维约束字写入到N×M的二维字单元阵列; (7) Repeat step (4) until all 2×2 two-dimensional constraint words generated in step (2) are written into the N×M two-dimensional word cell array;

如图7所示,编码器译码过程如下:首先从二维记录装置读取二维数据阵列,然后从二维阵列缓冲模块逐页读取数据,输入到二维字单元页构造模块,按照2×2为一个二维字单元,将二维数据阵列划分成二维字单元页,然后将划分后的二维字单元页输入到二维字单元读取模块读取2×2的二维约束码字,将二维约束码字输入到2×2码字到一维数据映射模块,得到相应的一维2比特数据字,将一维2比特数据字输入到一维数据流组装模块,按照2比特数据字的先后次序组装成一维原始数据流,从而完成二维约束阵列到一维数据流的转化,实现解码过程。仍以表1、2所述第一种编译码规则为例,其译码步骤包括: As shown in Figure 7, the decoding process of the encoder is as follows: first read the two-dimensional data array from the two-dimensional recording device, then read the data page by page from the two-dimensional array buffer module, and input it to the two-dimensional word unit page construction module, according to 2×2 is a two-dimensional word unit, divide the two-dimensional data array into two-dimensional word unit pages, and then input the divided two-dimensional word unit pages to the two-dimensional word unit reading module to read the 2×2 two-dimensional Constraint codewords, input two-dimensional constraint codewords to 2×2 codewords to one-dimensional data mapping module, obtain corresponding one-dimensional 2-bit data words, input one-dimensional 2-bit data words to one-dimensional data stream assembly module, The one-dimensional original data stream is assembled into a one-dimensional original data stream according to the order of the 2-bit data words, thereby completing the transformation from the two-dimensional constrained array to the one-dimensional data stream, and realizing the decoding process. Still taking the first encoding and decoding rules described in Tables 1 and 2 as an example, its decoding steps include:

(1)从二维记录装置读取二维数据阵列,并将二维阵列输入到二维阵列缓冲模块保存; (1) Read the two-dimensional data array from the two-dimensional recording device, and input the two-dimensional array to the two-dimensional array buffer module for storage;

(2)将二维数据阵列按照2×2为一个基本单元,划分成相应的二维字单元阵列,并置相应的二维字单元阵列的读取标志为真; (2) Divide the two-dimensional data array into corresponding two-dimensional word cell arrays according to 2×2 as a basic unit, and set the reading flag of the corresponding two-dimensional word cell array as true;

(3)沿着二维字单元阵列的45°对角线逐行递增方式从右上角到左下角读取二维约束码字; (3) Read the two-dimensional constrained codeword from the upper right corner to the lower left corner along the 45° diagonal line of the two-dimensional word unit array in an incremental manner;

(4)在步骤(3)的基础上,如果当前坐标读取标志为真,则读取相应的2×2二维约束码字,同时判断是否等于,如果是,则置坐标的读取标志为假,否则继续步骤(3)读取下一个坐标的二维约束码字,直至读取完整个二维字单元阵列,然后转步骤(5); (4) On the basis of step (3), if the current coordinate If the read flag is true, read the corresponding 2×2 two-dimensional constraint codeword, and judge whether it is equal to , if yes, set the coordinates and The reading flag of is false, otherwise continue to step (3) to read the two-dimensional constraint codeword of the next coordinate until the entire two-dimensional word cell array is read, and then go to step (5);

(5)将步骤(4)得到的2×2二维约束码字序列,逐一根据表1、2的译码表译码成一维2比特数据字; (5) Decode the 2×2 two-dimensional constrained codeword sequence obtained in step (4) into one-dimensional 2-bit data words one by one according to the decoding tables in Tables 1 and 2;

(6)将步骤(5)得到的一维2比特数据字按照先后次序组装成一维数据流并输出,译码完成。 (6) Assemble the one-dimensional 2-bit data words obtained in step (5) into a one-dimensional data stream in sequence and output it, and the decoding is completed.

为了说明编码规则的应用方法,图8和图9列举了本发明基于表1、2所述的第一种编译码规则的编码实施例1。图10和图11列举了本发明基于表1、2所述的第一种编译码规则的译码实施例2。实施例1和实施例2均依据表1、2所描述的编译码规则表和式A所述的二维约束码字分类,二维阵列的大小等于8×8,相应的二维字单元阵列大小等于4×4。若依据表3、4和式B所述的第二种编译码规则表和二维约束码字分析,其编码和译码实施例见图12和图13。 In order to illustrate the application method of the coding rules, Fig. 8 and Fig. 9 list the coding embodiment 1 based on the first coding and coding rules described in Tables 1 and 2 of the present invention. FIG. 10 and FIG. 11 illustrate the decoding embodiment 2 of the present invention based on the first encoding and decoding rules described in Tables 1 and 2. Both embodiment 1 and embodiment 2 are classified according to the encoding and decoding rule tables described in tables 1 and 2 and the two-dimensional constraint code words described in formula A. The size of the two-dimensional array is equal to 8×8, and the corresponding two-dimensional word cell array The size is equal to 4×4. According to Table 3, 4 and the second encoding and decoding rule table described in Formula B and the two-dimensional constraint code word analysis, its encoding and decoding embodiments are shown in Fig. 12 and Fig. 13 .

编码实施例1: Coding Example 1:

图8给出了具体的编码过程。一维数据流00110111111011001011按照先后顺序从右到左2比特为一组进行组合划分成10个2比特数据字,这10个一维2比特数据字如下所示:11,01,00,11,01,11,11,10,11,00。根据表1、2所述基本编码表的输出方案三进行编码产生10个2×2的二维约束码字序列,产生的2×2二维约束码字按照对应关系排列如下: Figure 8 shows the specific encoding process. The one-dimensional data stream 00110111111011001011 is combined and divided into 10 2-bit data words from right to left according to the order of 2 bits. The 10 one-dimensional 2-bit data words are as follows: 11, 01, 00, 11, 01 , 11, 11, 10, 11, 00. According to the output scheme three of the basic coding table described in Tables 1 and 2, encoding is performed to generate 10 2×2 two-dimensional constraint codeword sequences, and the generated 2×2 two-dimensional constraint codewords are arranged as follows according to the corresponding relationship:

, , , , , , , , ,

接着将上述10个2×2二维约束码字写入之前构造的4×4二维字单元阵列。在实施之前,将4×4二维字单元阵列的每个单元写入标志位置0,即单元标志位等于0,表示当前位置的单元可以写入数据,等于1表示不可写入。然后先将第一个2×2的二维约束码字沿着二维字单元阵列对角线第0行写入坐标(0,0)的二维字单元中,写入后的二维字单元阵列如图9(1)所示。然后将第2个2×2的二维约束码字写入到对角线第1行坐标等于(0,1)的二维字单元位置,同时根据式A,属于,因为坐标(1,1)和(0,2)处的写入标志等于0,因此在坐标(1,1)和(0,2)的字单元位置写入,同时将(1,1)和(0,2)这两处的写入标志位置1,即一维数据字01在此时根据表1、2的编码规则且按照输出方案一,编码成。在写入第2个一维2比特数据字01后,二维字单元阵列如图9(2)所示。将第3个2×2二维约束码字继续沿着45°对角线第1行写入到相应字单元阵列中,即坐标(1,0)处。由于也属于,且坐标(1,1)的写入标志等于1,而坐标(2,0)的写入标志等于0,因此根据编码规则,将写入到字单元阵列坐标(1,0)处,在坐标(2,0)处则写入,另一方面,由于坐标(1,1)的写入标志等于1,因此在当前情形下,在坐标(1,1)处略过。完成上述过程后,将这两处坐标的写入标志置1。即当将一维2比特数据字00写入阵列时,根据表1、2所述第一种编译码规则基本编码表,根据输出方案二,00被编码成,即在写入第3个一维2比特数据字00后,二维字单元阵列如图9(3)所示。由于阵列对角线第2行已经没有空余的位置,因此第4个2×2二维约束码字在二维字单元阵列的写入位置坐标是阵列对角第3行的(0,3)。由于属于,因此一维2比特数据字11根据表1、2所述第一种编译码规则基本编码表,编码成,即当第4个一维2比特数据字00被编码写入二维字单元阵列后,二维字单元阵列则变得如图9(4)所示。重复上述过程直至第10个2比特数据字00被写入到二维字阵列单元对角第6行的(3,3)处,由于此时二维字单元阵列已经被写满,因此00根据表1、2的编码规则基本编码表的输出方案三,编码成,将2×2的二维约束码字写入阵列(3,3)处,即完成对一维数据流到一个页面的二维约束阵列编码过程。 Then write the above-mentioned 10 2×2 two-dimensional constrained code words into the previously constructed 4×4 two-dimensional word cell array. Before implementation, each unit of the 4×4 two-dimensional word cell array is written into the flag position 0, that is, the unit flag bit is equal to 0, indicating that the unit at the current position can write data, and equal to 1, indicating that it cannot be written. Then the first 2×2 two-dimensional constraint codeword Write into the two-dimensional word unit at coordinates (0,0) along the 0th row of the diagonal line of the two-dimensional word unit array, and the written two-dimensional word unit array is shown in FIG. 9 (1). Then the second 2×2 two-dimensional constraint codeword Write to the position of the two-dimensional word unit whose coordinates are equal to (0,1) in the first row of the diagonal line, and according to formula A, belong , because the write flag at coordinates (1,1) and (0,2) is equal to 0, so write at the word unit position at coordinates (1,1) and (0,2) , and at the same time write the flag positions (1,1) and (0,2) to 1, that is, the one-dimensional data word 01 is encoded as . After writing the second one-dimensional 2-bit data word 01, the two-dimensional word cell array is shown in Figure 9 (2). The third 2×2 two-dimensional constraint codeword Continue to write to the corresponding word cell array along the first row along the 45° diagonal, that is, coordinates (1,0). because also belongs to , and the writing flag of the coordinate (1,1) is equal to 1, and the writing flag of the coordinate (2,0) is equal to 0, so according to the coding rules, the Write to the word cell array at coordinate (1,0), and write at coordinate (2,0) , on the other hand, since the write flag at coordinate (1,1) is equal to 1, skip at coordinate (1,1) in the current case. After the above process is completed, set the write flags of these two coordinates to 1. That is, when the one-dimensional 2-bit data word 00 is written into the array, according to the basic encoding table of the first coding rule described in Tables 1 and 2, according to the output scheme 2, 00 is encoded into , that is, after writing the third one-dimensional 2-bit data word 00, the two-dimensional word cell array is shown in Figure 9 (3). Since there is no free space in the second row of the diagonal of the array, the fourth 2×2 two-dimensional constraint codeword The coordinates of the writing position in the two-dimensional word cell array are (0,3) in the third row of the diagonal array. because belong , so the one-dimensional 2-bit data word 11 is encoded into , that is, when the fourth one-dimensional 2-bit data word 00 is encoded and written into the two-dimensional word cell array, the two-dimensional word cell array becomes as shown in Figure 9 (4). Repeat the above process until the 10th 2-bit data word 00 is written into (3, 3) of the 6th diagonal row of the two-dimensional word array unit. The output scheme three of the coding rule basic coding table of table 1, 2, is coded into , the 2×2 two-dimensional constraint codeword Write to the array (3,3), that is to complete the two-dimensional constrained array encoding process for one-dimensional data stream to one page.

实施例2: Example 2:

图10给出了具体的译码过程。首先从二维记录装置读取数据到二维阵列缓冲模块。在本实施例中,这个8×8的二维数据阵列如下: Figure 10 shows the specific decoding process. First read data from the two-dimensional recording device to the two-dimensional array buffer module. In this embodiment, the 8×8 two-dimensional data array is as follows:

然后将该二维数据阵列以2×2为一个基本单元,划分成大小等于4×4的二维字单元阵列如下: Then the two-dimensional data array is divided into two-dimensional word cell arrays whose size is equal to 4×4 with 2×2 as a basic unit as follows:

然后沿着二维字单元阵列的对角行逐行读取2×2的二维约束码字。在读取数据之前,设置4×4二维字单元阵列的每个字单元读取标志位,标志位“0”表示二维字单元坐标处的2×2二维约束码字可被读取,标志位“1”表示不可读取,这里 Then read the 2×2 two-dimensional constraint codeword row by row along the diagonal rows of the two-dimensional word cell array. Before reading data, set the read flag bit for each word unit of the 4×4 two-dimensional word unit array , the flag bit "0" indicates the coordinates of the two-dimensional word unit The 2×2 two-dimensional constraint codeword at can be read, and the flag bit “1” means it cannot be read, here .

首先从对角第0行坐标(0,0)处读取2×2的二维约束码字,读取后的二维字单元阵列如图11(1)所示,然后读取第1行(0,1)处的二维约束码字,由于属于,因此将阵列的字单元坐标分别等于(0,2)和(1,1)的读取标志位置1,即有,此时读取后的二维字单元阵列如图11(2)所示,图中空白表示二维约束码字已经被读取。由于阵列对角第1行尚有数据没有被读取,因此从右上角往左下角继续读取该对角行的字单元(1,0)的二维约束码字,因为属于,所以将单元坐标(2,0)和(1,1)的读取标志位置1,由于前面已经,因此仅置,图11(3)描述了读取二维约束码字后的情形。重复上述读取二维阵列的过程,直至二维阵列的数据被全部读取。上述读取后的二维约束码字,根据读取顺序,排列如下: First read the 2×2 two-dimensional constraint codeword from the coordinate (0,0) of the 0th row of the diagonal , the read two-dimensional word cell array is shown in Figure 11(1), and then read the two-dimensional constrained codeword at row 1 (0,1) ,because belong , so the word unit coordinates of the array are respectively equal to (0,2) and (1,1) read flag position 1, that is, , the read two-dimensional word cell array is shown in Figure 11 (2), and the blank in the figure indicates that the two-dimensional constraint codeword has been read. Since there is still data in the first row of the diagonal row that has not been read, continue to read the two-dimensional constraint codeword of the word unit (1,0) of the diagonal row from the upper right corner to the lower left corner ,because belong , so set the reading flag position of unit coordinates (2,0) and (1,1) to 1, since the previous , so only , Fig. 11(3) describes the reading of two-dimensional constrained codewords after the situation. The above process of reading the two-dimensional array is repeated until all the data in the two-dimensional array is read. The two-dimensional constrained codewords read above are arranged as follows according to the reading order:

, , , , , , , , ,

在本实施例中,读取的二维数据字按照表1、2的编译码规则的译码表译码成一维2比特数据字,即有:。最后将11,01,00,11,01,11,11,10,11,00这些一维2比特数据字组装成用户数据流00110111111011001011并输出,即可完成用户数据的二维解码。 In this embodiment, the read two-dimensional data word is decoded into a one-dimensional 2-bit data word according to the decoding table of the encoding and decoding rules of Tables 1 and 2, namely: ; ; ; . Finally, the one-dimensional 2-bit data words 11, 01, 00, 11, 01, 11, 11, 10, 11, 00 are assembled into a user data stream 00110111111011001011 and output to complete the two-dimensional decoding of user data.

基于表3、4的第二种编译码规则,也可完成类似地编译码工作,其具体实施例见图12编码例子和图13译码例子。尽管已经详细描述了本发明公开的实施例,但应理解在不脱离基于表1、2和表3、4的两种编译码规则,本发明在具体实施例还有很多变化、替代和修改。 Based on the second encoding and decoding rules in Tables 3 and 4, a similar encoding and decoding work can also be completed. See the encoding example in FIG. 12 and the decoding example in FIG. 13 for specific embodiments. Although the disclosed embodiments of the present invention have been described in detail, it should be understood that there are many changes, substitutions and modifications in the specific embodiments of the present invention without departing from the two coding rules based on Tables 1 and 2 and Tables 3 and 4.

Claims (7)

1.一种用于变长码率的二维游程长度受限约束编解码装置,其特征在于包括编码器和解码器,所述编码器包括:1. A two-dimensional run-length-limited codec device for variable-length code rates, characterized in that it includes an encoder and a decoder, and the encoder includes: 一维数据流缓冲及分组模块,该模块在缓冲接收一维数据流的同时,按照2比特为一组将其划分成若干个一维数据字;A one-dimensional data stream buffering and grouping module, which divides it into several one-dimensional data words according to 2 bits as a group while buffering and receiving the one-dimensional data stream; 2×2码字生成模块,该模块根据编译码规则表,将一维数据流缓冲及分组模块划分的若干个一维数据字生成相应的2×2二维约束码字,按照先后产生次序输入到2×2码字写入二维字单元阵列模块的2×2字单元缓冲区;2×2 codeword generation module, which generates corresponding 2×2 two-dimensional constraint codewords from several one-dimensional data words divided by the one-dimensional data stream buffer and grouping module according to the encoding and decoding rule table, and input them in the order of generation 2*2 code words are written into the 2*2 word unit buffer of the two-dimensional word unit array module; 二维字单元阵列构造模块,该模块将二维阵列划分成若干个由大小为2×2的二维字单元组成的二维字单元阵列,并置二维字单元阵列的每个二维字单元写入标志位为可写;Two-dimensional word cell array construction module, which divides the two-dimensional array into several two-dimensional word cell arrays composed of two-dimensional word cells with a size of 2×2, and juxtaposes each two-dimensional word cell array of the two-dimensional word cell array The unit write flag is writable; 2×2码字写入二维字单元阵列模块,该模块将2×2码字生成模块中的2×2二维约束码字序列从本模块的缓冲区按照先后顺序读出,并沿着二维字单元阵列对角行,逐行将2×2二维约束码字写入到二维字单元阵列中;2×2 codewords are written into the two-dimensional word unit array module, which reads out the 2×2 two-dimensional constrained codeword sequences in the 2×2 codeword generation module from the buffer of this module in sequence, and along the Diagonal rows of the two-dimensional word cell array, writing 2×2 two-dimensional constrained code words into the two-dimensional word cell array row by row; 上述编码器的四个模块依次连接,最后通过其中的2×2码字写入二维字单元阵列模块将二维数据阵列输出给二维数据记录装置;The four modules of the above-mentioned encoder are connected in sequence, and finally the two-dimensional data array is output to the two-dimensional data recording device through the 2×2 code word therein written into the two-dimensional word cell array module; 所述解码器包括:The decoder includes: 二维阵列缓冲模块,该模块主要用于暂时存放从二维数据记录装置读取的大小为2N×2M的二维数据阵列;A two-dimensional array buffer module, which is mainly used to temporarily store a two-dimensional data array with a size of 2N×2M read from a two-dimensional data recording device; 二维字单元页构造模块,该模块主要用于将二维阵列缓冲模块中的2N×2M二维数据阵列划分成由2×2为最小读取单元的N×M的二维字单元阵列,并置二维字单元阵列的每个字单元读取标志位为可读标志;Two-dimensional word unit page construction module, which is mainly used to divide the 2N×2M two-dimensional data array in the two-dimensional array buffer module into N×M two-dimensional word unit arrays with 2×2 as the minimum read unit, juxtaposing each word unit read flag of the two-dimensional word unit array as a readable flag; 二维字单元读取模块,该模块主要用于从二维字单元阵列读取适宜的2×2二维约束码字,并暂时存放所产生的2×2二维约束码字序列;A two-dimensional word unit reading module, which is mainly used to read a suitable 2×2 two-dimensional constrained codeword from the two-dimensional word unit array, and temporarily store the generated 2×2 two-dimensional constrained codeword sequence; 2×2码字到一维数据映射模块,该模块主要用于从二维字单元读取模块中读取2×2二维约束码字序列,根据编译码规则表,将2×2二维约束码字按照先后次序译码成大小等于2比特的一维数据字;2×2 codeword to one-dimensional data mapping module, this module is mainly used to read 2×2 two-dimensional constrained codeword sequence from two-dimensional word unit reading module, according to the encoding and decoding rule table, convert 2×2 two-dimensional The constrained codeword is decoded into a one-dimensional data word whose size is equal to 2 bits according to the sequence; 一维数据流组装模块,该模块主要用于将2×2码字到一维数据映射模块产生的2比特一维数据字按照产生的先后顺序组装成一维数据流;A one-dimensional data stream assembly module, which is mainly used to assemble the 2-bit one-dimensional data words generated by the 2×2 codeword to one-dimensional data mapping module into a one-dimensional data stream according to the sequence of generation; 上述解码器的五个模块依次连接,最后通过其中的一维数据流组装模块输出。The five modules of the above decoder are connected in sequence, and finally output through the one-dimensional data stream assembly module. 2.一种用于变长码率的二维游程长度受限约束编解码方法,其特征在于通过编码器实现编码过程,依次包括以下步骤:2. A two-dimensional run-length limited constraint encoding and decoding method for variable length code rate, characterized in that the encoding process is realized by an encoder, comprising the following steps successively: S101)一维数据流缓冲及分组模块将输入的二进制一维数据流按每2比特为一组均匀地划分成若干一维2比特数据字,并将该2比特数据字输入到2×2码字生成模块的数据缓冲区暂存;S101) The one-dimensional data stream buffering and grouping module divides the input binary one-dimensional data stream evenly into a plurality of one-dimensional 2-bit data words according to each 2-bit group, and inputs the 2-bit data words into a 2×2 code The data buffer of the word generation module is temporarily stored; S102)2×2码字生成模块从数据缓冲区逐一读取一维2比特数据字,选取编解码规则表的输出方案将一维2比特数据字转化成2×2二维约束码字;S102) The 2×2 codeword generation module reads the one-dimensional 2-bit data word one by one from the data buffer, and selects the output scheme of the codec rule table to convert the one-dimensional 2-bit data word into a 2×2 two-dimensional constraint codeword; S103)二维字单元阵列构造模块根据二维数据记录装置的存储大小,将大小为2N×2M的一个二维数据阵列以2×2的字单元为一组,划分成包含N×M个大小相同的2×2二维字单元的二维字单元阵列,并置每个2×2二维字单元写入标志为真,其中N和M为正整数;S103) The two-dimensional word unit array construction module divides a two-dimensional data array with a size of 2N×2M into 2×2 word units according to the storage size of the two-dimensional data recording device, and divides it into N×M size The two-dimensional word unit array of the same 2×2 two-dimensional word unit, juxtaposing each 2×2 two-dimensional word unit write flag as true, wherein N and M are positive integers; S104)2×2码字写入二维字单元阵列模块:将步骤S102得到的2×2二维约束码字,以步骤S103得到的2×2的二维字单元为基准,沿二维字单元阵列对角方向从右上角到左下角依次将二维约束码字写入大小等于2×2的二维字单元中,同时根据编解码规则表对当前写入的二维字单元的右方和下方的直接相邻二维字单元进行选择性填充;若该对角行的二维字单元全部被写入则进入下一步,若所有的二维约束码字已填充完毕则直接结束编码过程;S104) 2 × 2 code words are written into the two-dimensional word unit array module: the 2 × 2 two-dimensional constrained code word obtained in step S102 is based on the 2 × 2 two-dimensional word unit obtained in step S103, along the two-dimensional word In the diagonal direction of the cell array, two-dimensional constrained codewords are sequentially written into two-dimensional word units with a size equal to 2×2, and at the same time, the right side of the currently written two-dimensional word unit is written according to the codec rule table. Selectively fill with the directly adjacent two-dimensional word units below; if all the two-dimensional word units in the diagonal row are written, enter the next step, and if all the two-dimensional constraint codewords have been filled, the encoding process will end directly ; S105)判断是否有下一个对角行尚未写入,若有则转至步骤S104;若该二维字单元页的所有2×2二维字单元已写满二维约束码字,则进入下一步;S105) Judging whether there is a next diagonal line that has not been written, if so, then go to step S104; if all 2*2 two-dimensional word units of the two-dimensional word unit page have been filled with two-dimensional constraint codewords, then enter the next step step; S106)判断是否还有未编码的一维数据字,若有则转至步骤S102;否则结束编码过程。S106) Judging whether there are unencoded one-dimensional data words, if so, go to step S102; otherwise, end the encoding process. 3.根据权利要求2所述的编解码方法,其特征在于通过解码器实现解码过程,依次包括以下步骤:3. The encoding and decoding method according to claim 2, characterized in that the decoding process is realized by a decoder, comprising the following steps successively: S201)将从二维数据记录装置读取的二维数据阵列暂时存放在二维数据缓冲模块中;S201) Temporarily store the two-dimensional data array read from the two-dimensional data recording device in the two-dimensional data buffer module; S202)二维字单元页构造模块读取大小为2N×2M的二维数据阵列,将该二维数据阵列以2×2为最小读取单元进行均匀划分,形成包含于N×M个大小相同的2×2二维字单元的二维字单元阵列,并置二维字单元阵列的每个二维字单元读取标志位为可读标志真,其中N和M为正整数;S202) The two-dimensional word unit page construction module reads a two-dimensional data array with a size of 2N×2M, divides the two-dimensional data array evenly with 2×2 as the minimum reading unit, and forms N×M identically sized A two-dimensional word unit array of 2×2 two-dimensional word units, juxtaposing each two-dimensional word unit of the two-dimensional word unit array to read the flag as a readable flag true, wherein N and M are positive integers; S203)二维字单元读取模块以该二维字单元阵列的2×2二维字单元为基准,依据编码器编码顺序,沿二维字单元阵列的对角行,从右上角到左下角依次根据每个二维字单元的读取标志选择性读取二维字单元阵列中的二维约束码字,若该行的二维约束码字全部被读取则进入下一步,若当前二维字单元阵列的二维约束码字已读取完毕,则转步骤S205;S203) The two-dimensional word unit reading module takes the 2×2 two-dimensional word unit of the two-dimensional word unit array as a reference, according to the encoding sequence of the encoder, along the diagonal row of the two-dimensional word unit array, from the upper right corner to the lower left corner Selectively read the two-dimensional constrained codewords in the two-dimensional word cell array according to the reading sign of each two-dimensional word unit in turn, if all the two-dimensional constrained codewords of this row are read, then enter the next step, if the current two-dimensional constrained codewords are all read The two-dimensional constrained codeword of the dimension word unit array has been read, then go to step S205; S204)判断是否有下一个对角行尚未译码,若有转至步骤S203;若该二维字单元页的所有对角行的二维约束码字已全部被读取,进入下一步;S204) judging whether there is a next diagonal row that has not yet been decoded, if so, go to step S203; if the two-dimensional constraint codewords of all diagonal rows of the two-dimensional word unit page have all been read, enter the next step; S205)2×2码字到一维数据映射模块根据所选取的编解码表对应的译码表,将从二维字单元读取模块读取的2×2二维约束码字按照产生次序译码成相应的一维2比特数据字,完成后进入下一步;S205) The 2×2 codeword-to-one-dimensional data mapping module decodes the 2×2 two-dimensional constrained codewords read from the two-dimensional word unit reading module according to the generation order according to the decoding table corresponding to the selected codec table Code into a corresponding one-dimensional 2-bit data word, and enter the next step after completion; S206)一维数据流组装模块将得到的一维2比特数据字按照相应的译码先后次序进行组装,获取对应的一维二进制数据流,解码完成。S206) The one-dimensional data stream assembling module assembles the obtained one-dimensional 2-bit data words according to the corresponding decoding sequence, obtains the corresponding one-dimensional binary data stream, and completes the decoding. 4.根据权利要求2所述的编解码方法,其特征在于,步骤S104对当前写入2×2二维字单元的右方和下方相邻二维字单元进行选择性填充的方法为:4. The encoding and decoding method according to claim 2, characterized in that the method for selectively filling the right and lower adjacent two-dimensional word units currently written in the 2×2 two-dimensional word unit in step S104 is as follows: a)如果写入到当前2×2二维字单元的二维约束码字不属于对角矩阵或次对角矩阵,则判断和当前2×2二维字单元的直接相邻的右方、下方二维字单元的写入标志真假;若为真,在和该标志位对应的二维字单元位置填充值为对角矩阵或次对角矩阵的二维约束码字;若为假或未定义,则不填充二维约束码字;a) If the two-dimensional constrained codeword written into the current 2×2 two-dimensional word unit does not belong to a diagonal matrix or a sub-diagonal matrix, then judge the right side, directly adjacent to the current 2×2 two-dimensional word unit, The writing flag of the two-dimensional word unit below is true or false; if it is true, the two-dimensional constrained codeword that is filled in the two-dimensional word unit position corresponding to the flag bit is a diagonal matrix or a sub-diagonal matrix; if it is false or If not defined, the two-dimensional constraint codeword will not be filled; 完成上述写入过程后,置当前2×2二维字单元和填充二维约束码字的二维字单元写入标志为假,表示这些位置以后不能被再次允许写入二维约束码字;After completing the above-mentioned writing process, set the current 2×2 two-dimensional word unit and the two-dimensional word unit writing flag filled with the two-dimensional constraint codeword as false, indicating that these positions cannot be allowed to write the two-dimensional constraint codeword again in the future; b)如果写入到当前2×2二维字单元的二维约束码字属于对角矩阵或次对角矩阵,在当前二维字单元位置写入此二维约束码字后,将其写入标志设置为假。b) If the two-dimensional constraint code word written into the current 2×2 two-dimensional word unit belongs to a diagonal matrix or a sub-diagonal matrix, after writing the two-dimensional constraint code word at the position of the current two-dimensional word unit, write it In flag is set to false. 5.根据权利要求3所述的编解码方法,其特征在于,步骤S203选择性读取二维字单元页中的二维约束码字的方法为:5. The encoding and decoding method according to claim 3, wherein the method for selectively reading the two-dimensional constraint codeword in the two-dimensional word unit page in step S203 is: a)若当前读取的二维字单元读取标志位为真,则读取该二维字单元中的二维约束码字,并置该二维字单元的读取标志为假,即以后不被允许读取;如果当前读取的二维约束码字不属于对角矩阵或次对角矩阵,一并设置当前读取字单元位置的相邻右方、下方的二维字单元读取标志为假,即不允许读取;a) If the reading flag of the currently read two-dimensional word unit is true, then read the two-dimensional constraint code word in the two-dimensional word unit, and set the read flag of the two-dimensional word unit as false, that is, in the future Not allowed to read; if the currently read two-dimensional constraint code word does not belong to the diagonal matrix or sub-diagonal matrix, set the two-dimensional word unit adjacent to the right and below the current read word unit position to read The flag is false, that is, reading is not allowed; b)若当前读取的二维字单元读取标志位为假,则转入读取本二维字单元所在对角行的下一个二维字单元中的数据。b) If the reading flag of the currently read two-dimensional word unit is false, transfer to read the data in the next two-dimensional word unit in the diagonal row where the current two-dimensional word unit is located. 6.根据权利要求2~5中任一项所述的编解码方法,其特征在于,所述编解码规则表见下表1和2:6. The encoding and decoding method according to any one of claims 2 to 5, characterized in that, the encoding and decoding rule tables are shown in Tables 1 and 2 below: 表1第一种编译码规则的编码表Table 1 Encoding table of the first coding rule 表2第一种编译码规则的译码表Table 2 Decoding table of the first encoding and decoding rules 7.根据权利要求2~5中任一项所述的编解码方法,其特征在于,所述编解码规则表见下表3和4:7. The encoding and decoding method according to any one of claims 2 to 5, characterized in that, the encoding and decoding rule tables are shown in Tables 3 and 4 below: 表3第二种编译码规则的编码表Table 3 Encoding table of the second coding rule 表4第二种编译码规则的译码表Table 4 Decoding table of the second encoding and decoding rules
CN201210373044.XA 2012-09-29 2012-09-29 For the two-dimentional run length constraint coding/decoding device and method of elongated code check Expired - Fee Related CN102903378B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210373044.XA CN102903378B (en) 2012-09-29 2012-09-29 For the two-dimentional run length constraint coding/decoding device and method of elongated code check

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210373044.XA CN102903378B (en) 2012-09-29 2012-09-29 For the two-dimentional run length constraint coding/decoding device and method of elongated code check

Publications (2)

Publication Number Publication Date
CN102903378A CN102903378A (en) 2013-01-30
CN102903378B true CN102903378B (en) 2015-08-05

Family

ID=47575580

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210373044.XA Expired - Fee Related CN102903378B (en) 2012-09-29 2012-09-29 For the two-dimentional run length constraint coding/decoding device and method of elongated code check

Country Status (1)

Country Link
CN (1) CN102903378B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105630425B (en) * 2015-12-31 2020-06-26 深圳市紫光同创电子有限公司 Data management method, device and terminal
EP4030427A4 (en) * 2019-09-11 2023-06-21 Wuhan Fiberhome Technical Services Co., Ltd Two-dimensional bosk constraint-based encoding and decoding method and device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102298953A (en) * 2011-06-03 2011-12-28 武汉纺织大学 Codec with protection word and limited and restrained two dimension run length, and application method thereof

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102298953A (en) * 2011-06-03 2011-12-28 武汉纺织大学 Codec with protection word and limited and restrained two dimension run length, and application method thereof

Also Published As

Publication number Publication date
CN102903378A (en) 2013-01-30

Similar Documents

Publication Publication Date Title
CN102298953B (en) Codec with protection word and limited and restrained two dimension run length, and application method thereof
JP5723967B2 (en) Method, encoder apparatus, and solid-state storage device for recording input data to s-level storage of a solid-state storage device
CN104350544B (en) The data-storage system of modulation code is reversely cascaded using the part for record
JP2013524609A5 (en)
US20060242486A1 (en) Error correction coding method for a high-density storage media
CN102857324B (en) Low density parity check (LDPC) serial coder in deep space communication and based on lookup table and coding method
CN101854543A (en) The system and method that is used for signal processing
EP4057515B1 (en) Devices for encoding
CN102903378B (en) For the two-dimentional run length constraint coding/decoding device and method of elongated code check
JP2010272205A5 (en)
CN101540610B (en) Two-dimensional non-isolated bit constraint coding/decoding method and codec thereof
CN100437805C (en) Error correction code and data format for high density optical disk
CN102725964A (en) Encoding method, decoding method, encoding device, and decoding device
CN102098126A (en) Interleaving device, rating matching device and device used for block coding
CN102315899A (en) Quasi-cyclic decoding method for low-density parity check code
CN113811947B (en) Coding and decoding method and device for two-dimensional square constraint
CN103475379A (en) LDPC coding method
Forchhammer et al. Entropy of bit-stuffing-induced measures for two-dimensional checkerboard constraints
CN116633366A (en) DNA data storage high-efficiency coding circuit
CN116633366B (en) A DNA data storage high-efficiency coding circuit
CN116258781A (en) Image data DNA storage method, system, electronic device and storage medium
Hsu et al. Improved usable capacity for optical page-oriented memories with smart pixel interfaces
KR20220127113A (en) Encoding and decoding apparatus and method for implementing maximum transition-avoidance coding with minimum overhead
CN102034515A (en) Method for improving error correcting capability of optical storage medium
CN117672274A (en) Two-dimensional folding error correction method, controller and system suitable for optical storage

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20150805

Termination date: 20160929

CF01 Termination of patent right due to non-payment of annual fee