Summary of the invention
Technology of the present invention is dealt with problems: overcome the deficiencies in the prior art, a kind of any exponent number index Columbus encoder and coding method thereof are provided, in order to solve in encoding video pictures, computational complexity is high, the excessive entropy coding rate that causes of amount of calculation is low, is difficult to satisfy the problem of ultra high-definition or HD video Real Time Compression because entropy is encoded.
The present invention is achieved by the following technical solutions:
A kind of any exponent number index Columbus encoder comprises at least:
The encoded radio computing module utilizes sample value and the index Columbus coding exponent number inputted, calculates the binary coded value of this sample; Described binary coded value is that input sample value and 1 results added of inputting the exponent number position that moves to left is obtained;
Encoded radio length computation module, the binary coded value of utilizing the encoded radio computing module to obtain, and the index Columbus coding exponent number of input calculate the length of binary coded value;
Cumulative control module, the binary coded value length that encoded radio length computation module is obtained adds up, and produces shift control signal and code stream output control signal;
The code stream generation module, shift control signal and code stream output control signal according to cumulative control module output, use " displacement " and OR operation to complete amalgamation and the output of code stream, and the encoded radio that needs at least to use two registers to deposit respectively and obtain and the encoded radio after amalgamation.
Further, described encoded radio length computation module uses look-up table and adder to obtain the length of encoded radio.
Further, the degree of depth of depositing the register of encoded radio after encoded radio and amalgamation will equate, and will reach at least 2 times of input Sample Maximal value code length.
Another technical scheme of the present invention is as follows:
A kind of any exponent number index Columbus encoding method comprises the steps:
A) read in sample value and exponent number K;
B) calculate binary coded value and the length thereof of sample value;
C) binary coded value that obtains is buffered in a register, when the code stream length that cushions in register reaches appointment output length, the code stream of output designated length;
D) if read in the finish command, finish coding; Otherwise repeat A-D.
Further, by inputting the move to left results added of K position of sample value and 1, obtain binary coded value; This binary coded value is searched for one by one, obtain first ' 1 ' to low level from a high position apart from the distance L of lowest order, the result of calculating 2L-1+K is exactly the length of this binary coded value;
Further, the binary coded value of input is right after a sample binary coded value thereafter, leaves the high order end of a register in; After the code stream length in this register reaches appointment output length, begin to take out the encoded radio of appointment output length from the high position of this register, export as code stream; Simultaneously remaining encoded radio in register is displaced to this register highest order place.
Beneficial effect of the present invention is: (1) modules of the present invention only related to addition or, displacement and compare operation, computation complexity is low, suitable hardware is realized fast; (2) pipeline organization has all been adopted in modules inside, takes full advantage of the concurrency of hardware; (3) be easy to hardware and realize, coding rate is fast, can satisfy the real-time coding of ultra high-definition video and even higher coding requirement; (4) required hardware resource is few.
Embodiment
Below in conjunction with accompanying drawing and instantiation, the present invention is described in detail.
The index Columbus coding is a kind of variable length prefix code, its hardware is realized simple, need not to set up in advance and the storage code table, not only can calculate by hardware and produce fast code word, and can adjust flexibly exponent number k according to the information probability distribution function, thereby can reach very high code efficiency.Its code word is comprised of two parts: monobasic code+group internal label.It is the k=0 of 0-9 that table 1 has been listed sample, 1,2,3 index Columbus coding result.
The 0-3 level index Columbus coding of table 1 sample 0-9
Because index Columbus coding can only be to encoding more than or equal to zero integer, to the integral sample that has negative, can carry out preliminary treatment before being input to the index Columbus encoder, negative is mapped in the positive number scope.Non-negative mapping can adopt formula (1) to carry out:
Fig. 1 is a kind of any exponent number index Columbus encoder external interface schematic diagram of the present invention.Input signal comprises: input data D, useful signal V, coding exponent number K, end signal E, clock signal clk and reset signal rst_n; Output signal comprises: output code flow CB, useful signal VCB and end signal CE.The sample value that input data D indicates to encode; Useful signal V represents when being high that these input data are effective, otherwise is invalid; The exponent number of the index Columbus coding that the sample value that represents coding exponent number K to input will adopt; When end signal E is high, simultaneously that the accumulation length in the index Columbus encoder is clear 0 even in index Columbus coding, existing code stream does not reach set output code flow length and code stream will be exported yet, end-of-encode; Clock clk represents the clock of this index Columbus encoder work; Reset signal rst_n is 0 o'clock, register and operating state clear 0 in inner all modules of index Columbus coding.Output code flow CB represents the code stream that obtains; When useful signal VCB was high, the code stream CB that expression obtains was effective, otherwise invalid.End signal CE represents that the index Columbus encoder encodes finishes, the accumulation length in the index Columbus encoder clear 0.
As shown in Figure 2, any exponent number index Columbus fgs encoder device of the present invention comprises: encoded radio computing module, encoded radio length computation module, cumulative control module and code stream generation module.The below will describe in detail to modules and workflow thereof.
See also Fig. 3 (a), the input signal of encoded radio computing module has input data D, useful signal V, coding exponent number K, clock clk and reset signal rst_n; Output signal is encoded radio C and useful signal V_C.Wherein, the input signal input signal of index Columbus coding namely; Output encoder value C represents to input the binary coded value of sample; Useful signal V_C is high, represents that this encoded radio C is effective, otherwise invalid.Fig. 3 (b) has showed the core texture of encoded radio computing module module: at first to the 1 K position that moves to left, then namely obtain encoded radio C with input data D addition.This module divides two clocks to complete, and the dotted line in figure represents that streamline cuts apart.
See also Fig. 4 (a), the input signal of encoded radio length computation module has encoded radio C, useful signal V_C, coding exponent number K_2t, clock clk and reset signal rst_n2t; Output signal has code word size L_C and useful signal V_L.Wherein, input signal encoded radio C, useful signal V_C are the output signal of encoded radio computing module; Because the encoded radio computing module needs 2 clocks, so the input exponent number K_2t of this module and the rst_n_2t that resets represent respectively the signal of K and 2 clocks of rst_n time-delay; Output codons length L _ C is the length of encoded radio C; Useful signal V_L is high, and L_C is effective in expression output, otherwise invalid.Fig. 4 (b) has showed the core texture of encoded radio length computation module: at first output encoder value C is carried out head 1 and detect, find that in encoded radio C, first from a high position to the low level ' 1 ' apart from the distance L of lowest order, then obtains the value of 2L-1.The present invention adopts the thinking of look-up table, has completed above-mentioned two steps in a clock.Table 2 has been listed the example of a look-up table, and the value of priority is larger, and expression priority is higher.This module also divides two clocks to complete, and the dotted line in figure represents that streamline cuts apart.
Look-up table example of table 2
See also Fig. 5 (a), the input signal of cumulative control module has code word size L_C, useful signal V_L, end signal E_4t, clock clk and reset signal rst_n_4t; Output signal has Len_A, Valid_L and G_then_CL.Code word size L_C and useful signal V_L are the output signals of encoded radio length computation module; End signal E_4t and reset signal rst_n_4t are respectively the signal after end signal E and 4 clocks of reset signal rst_n time-delay; Output signal Len_A represents the total length after L_C adds up; Valid_L is high, and the Len_A of expression output is effective; G_then_CL for low expression the total length L en_A after cumulative less than set output code flow length C L.Fig. 5 (b) has showed the core texture of cumulative control module: if the length of Len_A less than set code stream length C L, code word size L_C and Len_A are cumulative; If the length of Len_A more than or equal to set output code flow length C L, after Len_A deducts CL, then adds up with code word size C_L.Simultaneously G_than_CL is set high.This module divides three clocks to complete, and the dotted line in figure represents that streamline cuts apart.
See also Fig. 6 (a), the input signal of code stream generation module has Len_A, Valid_L, G_than_CL, encoded radio C_4t, clock clk and the rst_n_7t that resets; Output signal has code stream CB, useful signal VCB and end signal E_C.Wherein Len_A, Valid_L, G_than_CL are the output signal of cumulative control module, and encoded radio C_4t is the signal after 4 clocks of encoded radio C time-delay of encoded radio computing module output; The rst_n_7t that resets represents the signal of 7 clocks of reset signal rst_n time-delay.The output signal of any exponent number index Columbus of namely the present invention of output signal encoder.Fig. 6 (b) has showed the core texture of code stream generation module module: the initial value of register d1, d2, c1 and c2 in this module is all 0.At first with encoded radio C_4t assignment to register d1, then to the right cyclic shift Len_A assignment to register d2, then register d2 and register c1 by or operation realize the amalgamation of code stream, if input signal G_than_CL be high, the high CL position of register c2 is exported as code stream CB.Simultaneously the value of register c1 also needs register c2 to constantly update, if G_than_CL be height, and the value of the register c1 CL position that need to move to left; If G_than_CL is low, do not make shifting processing.This module divides three clocks to complete, and the dotted line in figure represents that streamline cuts apart.Here, the degree of depth of register d1, d2, c1 and c2 need to be greater than peaked 2 times of input coding value C_4t, carrying out peeks from register c2 all needs time-delay because the G_than_CL signal is from producing to, so need to reserve to these registers the space of at least 2 times.In figure, the degree of depth of register d1, d2, c1 and c2 is set as 128.In example, we are set as 64 with set code stream length C L.
In order to verify validity of the present invention, field programmable gate array (FPGA) programming that any exponent number index Columbus encoder of the present invention is XC5VFX70T in model realizes, the highest frequency that comprehensively obtains is 393.918MHz, used 502 register cells (Slice Registers) and 533 look-up table unit (Slice LUTs), institute's cost source is about 1% of this model FPGA total resources.Fig. 7 downloads to any exponent number index Columbus encoder sequence of the present invention the coding result that obtains after the FPGA operation of above-mentioned model, and in figure, reset_n represents to input reset signal; Level_K presentation code exponent number k; Data_in_24 is the input sample value; Valid_in is the useful signal of input number, and height is effective; Data_end_in represents the end of input signal; Code_out represents output code flow; Valid_out represents the useful signal of output code flow, and height is effective; Code_end_out represents the end of output signal.Fig. 7 (a) is continuously the integer of input 0-256, the result of using 0 rank index Columbus coding to obtain; Fig. 7 (b) is continuously the integer of input 0-256, the result of using the index Columbus coding on 1 rank to obtain; Fig. 7 (c) is for being interrupted the integer of input 0-256, the result that the index Columbus coding of use exponent number from 0 to 15 circulation change obtains; Fig. 7 (d) is continuously the integer of input 0-256, uses the index Columbus coding of exponent number from 0 to 15 circulation change, the coding result that obtains after the end signal of a clock of input.
In conjunction with flow chart shown in Figure 8, a kind of step of any exponent number index Columbus encoding method is as follows:
Step 1, read in sample value and exponent number K;
Binary coded value and the length thereof of step 2, calculating sample value;
Step 3, the binary coded value that obtains is buffered in a register, when the code stream length that cushions in register reaches when specifying output length, the code stream of output designated length.
If step 4 is read in the finish command, finish coding; Otherwise repeat A-D.
In step 3, by inputting the move to left results added of K position of sample value and 1, obtain binary coded value; This binary coded value is searched for one by one, obtain first ' 1 ' to low level from a high position apart from the distance L of lowest order, the result of calculating 2L-1+K is exactly the length of this binary coded value.As input that sample value is 5, exponent number is 0, can obtain binary coded value and be (101)
B+ 1=(110)
B, subscript B represents binary representation; Can get encoded radio length is 2*3-1+0=5, so the code word that obtains is (00110)
B
In step 4, the binary coded value of input is right after a sample binary coded value thereafter, leaves the high order end of a register in; After the code stream length in this register reaches appointment output length, begin to take out the encoded radio of appointment output length from the high position of this register, export as code stream; Simultaneously remaining encoded radio in register is displaced to this register highest order place.If encoder reads in sample 5,6,7,8 continuously, exponent number is all 0, and the code stream that cushions in register is 001100011100010000001001, is 16 if specify output length, the code stream of output is 0011000111000100, and in register, remaining code stream is 00001001.
Due to, the present invention is after the FPGA that model is XC5VFX70T realizes, and the highest frequency that comprehensively obtains is 393.918MHz, and namely the theoretical peak processing speed can reach per second 393.918M pixel.The real-time coding of ultra high-definition video needs per second to process the ultra high-definition image of 25-30 frame 3840 * 2160, and its maximum processing speed reaches per second 3840 * 2160 * 30=248.832M pixel.So, in actual applications, even dominant frequency of the present invention is reduced slightly, also can satisfy the requirement of ultra high-definition video real-time coding fully.Certainly, application of the present invention is not limited to this, and the present invention is embedded in very lagre scale integrated circuit (VLSIC) (VLSI), and processing speed can further promote, and is enough to satisfy rate request higher application scenario.
The non-elaborated part of the present invention belongs to those skilled in the art's known technology.
The above is only better embodiment of the present invention, and need not with the restriction the present invention.Within the spirit and principles in the present invention all, any modification of doing, the merging that is equal to replacement, functional module or expansion and improvement etc., all should be included in of the present invention comprise scope within.