Integer transform based on AVS quantizes and the integral inverse transform quantification method
Technical field
The present invention relates to a kind of integer transform based on AVS quantizes and the integral inverse transform quantification method.
Background technology
AVS (Audio Video coding Standard) sets up the autonomous digital audio/video encoding and decoding technique standard of formulating of China that " digital audio/video encoding and decoding technique standard operation group " proposes by China's Ministry of Information Industry, is the general character basic standard of digital audio/video industrial colonies such as Digital Television, broadband network Streaming Media, mobile multimedia communication, videodisc.This standard is very advanced, and its code efficiency is than Moving Picture Experts Group-2 high 2~3 times (high definition TV can reach 3 times or more), and is suitable with MPEG-4 AVC/H.264 standard code efficient, but technical scheme is more succinct.At 2006 beginning of the years, the national standard that the AVS standard becomes the audio frequency and video field has been passed through in Ministry of Information Industry's official approval, and formally in implementation of China, can save the multi-million dollar patent fee every year, have good market prospects and researching value.
Compare with other video encoding and decoding standard, the main difference point of AVS has adopted 8 * 8 integer transforms with regard to the conversion fraction that is it.Can eliminate the intrinsic problem that adopts discrete cosine transform (DCT) conversion to have mismatch.8 * 8 integer direct transforms as the formula (1).
In the formula, X represents 8 * 8 image residual matrix, and Y represents 8 * 8 transform coefficient matrix, and H represents 8 * 8 integer direct transform matrix, H
TThe integer direct transform transpose of a matrix matrix of expression 8 * 8.
AVS8 * 8 integral inverse transforms are the process that 8 * 8 transform coefficient matrix Y are converted to 8 * 8 residual error sample value matrix X, and step is as follows:
At first, transform coefficient matrix is carried out following horizontal inverse transformation: H=Y * T
8 T
Wherein, T
8Be 8 * 8 inverse transformation matrixes, T
8 TBe T
8Transposed matrix, H represents the intermediate object program after the horizontal inverse transformation.
Second step, the element h of matrix H
IjBe calculated as follows:
h
ij=(Clip3(-2
15,2
15-1,(h
ij+4)))>>3 i,j=0~7
In the 3rd step, matrix H is carried out following vertical inverse transformation: H=T
8* H.Wherein, H represents 8 * 8 matrixes after the inverse transformation.
The 4th step, the element r of residual error sample value matrix X
IjBe calculated as follows:
r
ij=(Clip3(-2
15,2
15-1,(h
ij+2
6)))>>7 i,j=0~7
H wherein
IjIt is H entry of a matrix element.
Aspect the quantification inverse quantization, AVS quantizes choosing of progression and also is different from H.264/AVC, and it is worth as index with a quantization parameter QP (Quantization Parameter) 52 kinds of step-lengths, and adopts 64 grades of quantifications, whenever QP value increase by 8, then quantization step Q
StepDouble.This has just strengthened different application and the professional ability that code check and quality is had different requirements of adapting to.Round the error of bringing in the transform and quantization process in order to reduce, the operation that among the AVS convergent-divergent and quantification combined, as the formula (2).
F
q(u,v)=sign[F(u,v)][((|F(u,v)|M(u&3,v&3)+2
18)>>19)×QC+f×2
L]>>L (2)
Wherein, F is a transform coefficient matrix; U, v are the row and column index; L=15+QP/8; M is a scaled matrix, and QC is to be the quantization parameter table of index with QP, is made up of some positive integers, and its value can be with reference to pertinent literature.F is used for rounding off and rounds, and in actual applications, also can not consider sometimes.The inverse quantization process as the formula (3).
w
ij=(F
q[i,j]×DequantTable(QP)+2
ShiftTable(QP)-1)>>ShiftTable(QP)i,j=0~7 (3)
W wherein
IjBe the element of two-dimensional transform coefficient matrix, i, j are the call number of row, column in the matrix; F
qBe two-dimentional quantization parameter matrix; DequantTable is the dequantized coefficients table; ShiftTable is a dequantized coefficients translation table.
In realizing AVS hardware encoding process, the hardware designs and the realization of research integer transform, quantification and integral inverse transform, inverse quantization have a very important role.Along with the hardware handles frequency requirement is improved day by day, this class design and the method that realizes also more and more are held in esteem and look.
Summary of the invention
The integer transform that technical problem to be solved by this invention provides based on AVS quantizes and the integral inverse transform quantification method, can reduce hard-wired complexity greatly on the one hand, the economize on hardware resource, can significantly improve data processing speed on the other hand, make it satisfy the real-time processing requirements of high definition coding.
In order to solve the problems of the technologies described above, the present invention is achieved in that a kind of integer transform based on AVS quantizes and the integral inverse transform quantification method, wherein the conversion of first line translation rank rear is adopted in the integer direct transform, integral inverse transform adopts the mode deal with data of line translation behind the first rank transformation, and it comprises following steps:
Step 1, the PredDiffEn_IH signal is set is enable signal, when if PredDiffEn_IH is high level, expression input data PredDiff_I is valid data, the input data are 9 bit strip symbolic numbers, through output transform coefficient T rans_M and output enable TransEn_MH behind the integer transform, wherein:
8 * 8 integer direct transform expression formulas are:
X represents 8 * 8 image residual matrix, and Y represents 8 * 8 transform coefficient matrix, and H represents 8 * 8 integer direct transform matrix, H
TThe integer direct transform transpose of a matrix matrix of expression 8 * 8,
If the input data in the X image residual matrix are X (0), X (1) ... X (6), X (7), through the dateout behind the single step integer transform is Z (0), Z (1), Z (2), Z (3), Z (4), Z (5), Z (6), Z (7), by the above-mentioned integer transform expression formula even number behavior even symmetry of transformation matrix H as can be known, and odd number behavior odd symmetry, thereby utilize the symmetry of transformation matrix H, release following matrix:
Because (N * N) * (N * 1) matrix-vector multiplication changes twice ((N/2) * (N/2)) * ((N/2) * 1) matrix-vector multiplication into, thus the number of times of computing can reduce by half, but and parallel computation;
Step 2, if enable signal TransEn_MH is a high level, show that conversion coefficient Trans_M is valid data, through after quantizing, conversion coefficient Quant_O and output enable QuantEn_OH after output quantizes;
Step 3, if enable signal QuantEn_OH is a high level, show that the conversion coefficient after the quantification is valid data, through behind the inverse quantization, output variation coefficient InvTrans_M and output enable InvTrans_MH; And
Step 4, if enable signal InvTrans_MH is a high level, show that the conversion coefficient behind the inverse quantization is valid data, through after the inverse transformation, prediction of output residual error InvPredDiff_I and prediction residual output enable InvPredDiffEn_IH, wherein:
The input data are the conversion coefficient behind the inverse quantization, and establishing the input data is Y (0), Y (1) ... Y (6), Y (7), integral inverse transform matrix
T
8Even number classify even symmetry as, and odd number is classified odd symmetry as, if be Z (0) through the dateout after the computing of single step inverse discrete cosine, Z (1), Z (2), Z (3), Z (4), Z (5), Z (6), Z (7) utilizes the symmetry of transformation matrix T8, can release following matrix:
Because (matrix multiplication operation of N * N) * (N * 1) is replaced by the matrix product of two ((N/2) * (N/2)) * ((N/2) * 1), operation times has also reduced half, and because the latter half on equation the right only has the poor of sign symbol, so two matrix equalities can calculate simultaneously.
The above-mentioned integer transform based on AVS quantizes and the integral inverse transform quantification method, it further comprises: in the step 1, integer transform adopts the mode of multiplexing single step discrete cosine transform computing, finishing whole integer transform need be with multiplexing 2 times of single step discrete cosine transform computing, and wherein single step discrete cosine transform calculation step is:
Step 1a, with X (0)+X (7), X (1)+X (6), X (2)+X (5), X (3)+X (4), X (0)-X (7) X (1)-X (6), X (2)-X (5), X (3)-X (4) is expressed as R0, R1, R2, R3, R4, R5, R6, R7 respectively.Can get Y (0)=8R0+8R1+8R2+8R3, Y (1)=10R4+9R5+6R6+2R7, Y (2)=10R0+4R1-4R2-10R3, Y (3)=9R4-2R5-10R6-6R7, Y (4)=8R0-8R1-8R2+8R3, Y (5)=6R4-10R5+2R6+9R7, Y (6)=4R0-10R1+10R2-4R3, Y (7)=2R4-6R5+9R6-10R7;
Step 1b, make Q0=8R0+8R3, Q1=8R1+8R2, Q2=10R4+6R6, Q3=9R5+2R7, Q4=10R0-4R2, Q5=4R1-10R3, Q6=9R4-10R6, Q7=2R5+6R7, Q8=6R4+2R6, Q9=10R5-9R7, Q10=4R0+10R2, Q11=10R1+4R3, Q12=2R4+9R6, Q13=6R5+10R7 establishes through the value after the single step DCT computing and is respectively Z0, Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z0=Q0+Q1 then, Z1=Q2+Q3, Z2=Q4+Q5, Z3=Q6-Q7, Z4=Q0-Q1, Z5=Q8-Q9, Z6=Q10-Q11, Z7=Q12-Q13;
Step 1c, in the process that realizes, above-mentioned constant coefficient multiplication is realized with the mode that is shifted, as Q0=R0<<3+R3<<3.
Above-mentioned integer transform based on AVS quantizes and the integral inverse transform quantification method, and it further comprises: in the step 1, realize the shifting function of different directions by exercising energy signal Row_En and row enable signal Col_En, thus the transposition of realization matrix.
The above-mentioned integer transform based on AVS quantizes and the integral inverse transform quantification method, and it further comprises: in the step 2, quantize to comprise convergent-divergent and quantize two steps that realize quantizing to calculate by 3 grades of flowing water, first order flowing water is realized M (u﹠amp; 3, v﹠amp; 3), the calculating of QC and f, finish by tabling look-up, second level flowing water is mainly realized calculating | F (u, v) | M (u﹠amp; 3, v﹠amp; 3)+2
18)>>19, third level flowing water mainly realize [((| F (u, v) | M (u﹠amp; 3, v﹠amp; 3)+2
18)>>19) * QC+f * 2
LThe L of]>>, wherein, (u v) is a transform coefficient matrix to F, and u, v are the row and column index; M (u﹠amp; 3, v﹠amp; 3) be scaled matrix; QC is to be the quantization parameter table of index with quantization parameter QP; F is used for rounding off and rounds; L=15+QP/8.
The above-mentioned integer transform based on AVS quantizes and the integral inverse transform quantification method, it further comprises: in the step 3, inverse quantization is realized by 2 grades of flowing water, first order flowing water is realized IQ_TAB[qp], (shift-2) and calculating (shift-1), finish by tabling look-up, second level flowing water realize (coeff*IQ_TAB[qp]+(1<<(shift-2)))>>(shift-1) calculating.
The above-mentioned integer transform based on AVS quantizes and the integral inverse transform quantification method, it further comprises: in the step 4, integral inverse transform adopts multiplexing single step inverse discrete cosine compute mode, finishing whole integral inverse transform need be with multiplexing 2 times of single step inverse discrete cosine computing, and wherein single step inverse discrete cosine calculation step is:
Step 4a, make U0=8Y0+8Y4, U1=8Y0-8Y4, U2=10Y1+6Y5, U3=9Y1-10Y5, U4=6Y1+2Y5, U5=2Y1+9Y5, U6=10Y2+4Y6, U7=4Y2-10Y6, U8=9Y3+2Y7, U9=2Y3+6Y7, U10=10Y3-9Y7, U11=6Y3+10Y7, W0=U0+U6 then, W1=U1+U7, W2=U1-U7, W3=U0-U6, W4=U2+U8, W5=U3-U9, W6=U4-U10, W7=U5-U11;
Step 4b, establish through the value after the computing of a single step inverse discrete cosine and be respectively Z0, Z1, Z2, Z3, Z4, Z5, Z6, Z7 is got by formula (6) formula (7), Z (0)=W0+W4, Z (1)=W1+W5, Z (2)=W2+W6, Z (3)=W3+W7, Z (4)=W0-W4, Z (5)=W1-W5, Z (6)=W2-W6, Z (7)=W3-W7;
Step 4c, in the process that realizes, above-mentioned constant coefficient multiplication is realized with the mode that is shifted, as U0=Y (0)<<3+Y (4)<<3.
The above-mentioned integer transform based on AVS quantizes and the integral inverse transform quantification method, and it further comprises: in the step 4, and integral inverse transform and the shared same transpose memory of integer direct transform unit.
The present invention makes it compared with prior art owing to adopted above-mentioned technical scheme, has following advantage and good effect:
1, because in the step 1, integer transform adopts the mode of multiplexing single step discrete cosine transform computing; In the step 4, integral inverse transform adopts the mode of multiplexing single step inverse discrete cosine computing; In whole change quantization and inverse transformation inverse quantization process, all avoid using multiplication and division, and adopt modes such as displacement, ROM or other to realize and integer transform and the multiplexing same transposition register of inverse transformation or the like.The present invention reduces hard-wired complexity greatly as can be seen, has saved hardware resource;
2, because in the step 1 and 4, the parallel pipelining process of integer transform and inverse transformation is handled; In the step 2,3, avoid using multiplication and division in the stream treatment of quantification and inverse quantization and the whole computational process, thereby significantly improve data processing speed, increased the data throughout of entire process structure, make it satisfy the real-time processing requirements of high definition coding.
Description of drawings
Integer transform based on AVS of the present invention quantizes and the integral inverse transform quantification method is provided by following embodiment and accompanying drawing.
Fig. 1 is integer transform, quantification and integral inverse transform, the inverse quantization hardware implementation structure figure that the invention provides AVS.
Fig. 2 the invention provides discrete cosine transform multiplexing structure figure.
Embodiment
Below will be described in further detail integer transform quantification and the integral inverse transform quantification method based on AVS of the present invention.
As shown in Figure 1, be that the integer transform based on AVS provided by the invention quantizes and the integral inverse transform quantification method, it comprises following steps:
Step 1, the PredDiffEn_IH signal is set is enable signal, if when PredDiffEn_IH is high level, expression input data PredDiff_I is valid data, and the input data are 9 bit strip symbolic numbers.Through output transform coefficient T rans_M and output enable TransEn_MH behind the integer transform;
Step 2, if enable signal TransEn_MH is a high level, show that conversion coefficient Trans_M is valid data, through after quantizing, conversion coefficient Quant_O and output enable QuantEn_OH after output quantizes;
Step 3, if enable signal QuantEn_OH is a high level, show that the conversion coefficient after the quantification is valid data, through behind the inverse quantization, output variation coefficient InvTrans_M and output enable InvTrans_MH;
Step 4, if enable signal InvTrans_MH is a high level, show that the conversion coefficient behind the inverse quantization is valid data, through after the inverse transformation, prediction of output residual error InvPredDiff_I and prediction residual output enable InvPredDiffEn_IH.
In the step 1, integer transform adopts the mode of multiplexing single step discrete cosine transform (DCT) computing to realize, saves the resource that is consumed significantly.Finishing whole integer transform need be with multiplexing 2 times of single step DCT computing.The DCT of this multiplexing single step algorithm realizes block diagram (as shown in Figure 2).The counter State that is controlled by system controller reflects the state that current DCT computing is carried out.The input data enter single step DCT arithmetic element after importing mask register, by exporting by the output mask register after a series of computing, if State==1 then output result that will this moment feeds back to the input mask register carries out single step DCT computing again, if State==2 then operation result output that will this moment.After single step DCT computing is finished each time, add a post-processing unit, realize rounding single step DCT operation result.
In the step 1, establishing the input data is X0, X1......X6, and X7 by integer transform expression formula (1) the even number behavior even symmetry of transformation matrix H as can be known, and odd number behavior odd symmetry, thereby utilizes the symmetry of transformation matrix H, can release following matrix:
Single step DCT computing comprises following steps:
Step 1.1, with X (0)+X (7), X (1)+X (6), X (2)+X (5), X (3)+X (4), X (0)-X (7) X (1)-X (6), X (2)-X (5), X (3)-X (4) is expressed as R0, R1, R2, R3, R4, R5, R6, R7 respectively.Can get Y (0)=8R0+8R1+8R2+8R3, Y (1)=10R4+9R5+6R6+2R7, Y (2)=10R0+4R1-4R2-10R3, Y (3)=9R4-2R5-10R6-6R7, Y (4)=8R0-8R1-8R2+8R3, Y (5)=6R4-10R5+2R6+9R7, Y (6)=4R0-10R1+10R2-4R3, Y (7)=2R4-6R5+9R6-10R7;
Step 1.2, make Q0=8R0+8R3, Q1=8R1+8R2, Q2=10R4+6R6, Q3=9R5+2R7, Q4=10R0-4R2, Q5=4R1-10R3, Q6=9R4-10R6, Q7=2R5+6R7, Q8=6R4+2R6, Q9=10R5-9R7, Q10=4R0+10R2, Q11=10R1+4R3, Q12=2R4+9R6, Q13=6R5+10R7 establishes through the value after the single step DCT computing and is respectively Z0, Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z0=Q0+Q1 then, Z1=Q2+Q3, Z2=Q4+Q5, Z3=Q6-Q7, Z4=Q0-Q1, Z5=Q8-Q9, Z6=Q10-Q11, Z7=Q12-Q13;
Step 1.3, in the process that realizes, above-mentioned constant coefficient multiplication is realized with the mode that is shifted, as Q0=R0<<3+R3<<3;
In the step 1, the shift register that transpose memory is made up of 8 * 8 register arrays realizes, by exercise can signal Row_En and row enable signal Col_En realize the shifting function of different directions, thereby the transposition of realization matrix.
In the step 2, quantize to comprise convergent-divergent and quantize two steps, mainly realize quantizing to calculate as can be seen by 3 grades of flowing water from quantizing expression formula.First order flowing water is realized M (u﹠amp; 3, v﹠amp; 3), the calculating of QC and f, finish by tabling look-up.Second level flowing water is mainly realized calculating | and F (u, v) | M (u﹠amp; 3, v﹠amp; 3)+2
18)>>19.Third level flowing water mainly realize [((| F (u, v) | M (u﹠amp; 3, v﹠amp; 3)+2
18)>>19) * QC+f * 2
LThe L of]>>.
In the step 3, the inverse quantization expression formula is:
Curr_blk[yy][xx]=(coeff*IQ_TAB[qp]+(1<<(shift-2)))>>(shift-1)。From the inverse quantization expression formula as can be seen, inverse quantization can be realized by 2 grades of flowing water.First order flowing water is realized IQ_TAB[qp], (shift-2) and calculating (shift-1), finish by tabling look-up.Second level flowing water realize (coeff*IQ_TAB[qp]+(1<<(shift-2)))>>(shift-1) calculating.
In the step 3, operation for (shift-1) position that moves to right at last, can not directly carry out shifting function because the figure place of being moved is uncertain, the structure that adopts a look-up table to add a MUX in the present invention realizes this shifting function, not only can avoid using complicated multiplication and division method computing but also can realizing function;
In the step 4, integral inverse transform adopts the mode of multiplexing single step inverse discrete cosine (IDCT) computing, saves the resource that is consumed significantly.Finishing whole integral inverse transform need be with multiplexing 2 times of single step IDCT computing.It is similar when the IDCT of this multiplexing single step algorithm realizes block diagram to integer transform.The counter INVState that is controlled by system controller reflects the state that current I DCT computing is carried out.The input data enter single step IDCT arithmetic element after importing mask register, by exporting by the output mask register after a series of computing, if INVState==1 then output result that will this moment feeds back to the input mask register carries out single step IDCT computing again, if INVState==2 then operation result output that will this moment.After single step IDCT computing is finished each time, add a post-processing unit, realize rounding single step IDCT operation result.
In the step 4, establishing the input data is Y0, Y1......Y6, and Y7 is by the integral inverse transform matrix T
8Even number classify even symmetry as, and odd number is classified odd symmetry as, thereby utilizes transformation matrix T
8Symmetry, can release following matrix:
Single step IDCT computing comprises following steps:
Step 4.1, make U0=8Y0+8Y4, U1=8Y0-8Y4, U2=10Y1+6Y5, U3=9Y1-10Y5, U4=6Y1+2Y5, U5=2Y1+9Y5, U6=10Y2+4Y6, U7=4Y2-10Y6, U8=9Y3+2Y7, U9=2Y3+6Y7, U10=10Y3-9Y7, U11=6Y3+10Y7, W0=U0+U6 then, W1=U1+U7, W2=U 1-U7, W3=U0-U6, W4=U2+U8, W5=U3-U9, W6=U4-U10, W7=U5-U11;
Step 4.2, establish through the value after the single step IDCT computing and be respectively Z0, Z1, Z2, Z3, Z4, Z5, Z6, Z7 is got by formula (6) formula (7), Z (0)=W0+W4, Z (1)=W1+W5, Z (2)=W2+W6, Z (3)=W3+W7, Z (4)=W0-W4, Z (5)=W 1-W5, Z (6)=W2-W6, Z (7)=W3-W7;
Step 4.3, in the process that realizes, above-mentioned constant coefficient multiplication is realized with the mode that is shifted, as U0=Y (0)<<3+Y (4)<<3;
In the step 4,, thereby consider module reuse, integral inverse transform and the shared same transpose memory of integer direct transform unit because the logical resource that 8 * 8 register arrays take is more.
Among the present invention, integer transform adopts the conversion of first line translation rank rear and the mode deal with data that row changes behind the first rank transformation is adopted in the integer inverse transformation, can make the transfer process between the few row, column of data minus, has improved the speed of data processing.
The emulation of the present invention on ModelsimSE 6.1b, the language of use is Verilog; Whole integer transform, quantification, inverse quantization, inverse transformation are all finished and have been used 42 clock cycle; Clock frequency can reach more than the 100MHz, satisfies the requirement that video image is handled in real time.