1 |
84 |
jamey.hick |
//**********************************************************************
|
2 |
|
|
// Entropy Decoder implementation
|
3 |
|
|
//----------------------------------------------------------------------
|
4 |
|
|
//
|
5 |
|
|
//
|
6 |
|
|
|
7 |
|
|
package mkEntropyDec;
|
8 |
|
|
|
9 |
|
|
import H264Types::*;
|
10 |
|
|
import ExpGolomb::*;
|
11 |
|
|
import CAVLC::*;
|
12 |
|
|
import ICalc_nC::*;
|
13 |
|
|
import mkCalc_nC::*;
|
14 |
|
|
import IEntropyDec::*;
|
15 |
|
|
import FIFO::*;
|
16 |
|
|
|
17 |
|
|
import Connectable::*;
|
18 |
|
|
import GetPut::*;
|
19 |
|
|
import ClientServer::*;
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
//-----------------------------------------------------------
|
23 |
|
|
// Local Datatypes
|
24 |
|
|
//-----------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
typedef union tagged
|
27 |
|
|
{
|
28 |
|
|
void Start; //special state that initializes the process.
|
29 |
|
|
void NewUnit; //special state that checks the NAL unit type.
|
30 |
|
|
|
31 |
|
|
Bit#(5) CodedSlice; //decodes a type of NAL unit
|
32 |
|
|
void SEI; //decodes a type of NAL unit
|
33 |
|
|
Bit#(5) SPS; //decodes a type of NAL unit
|
34 |
|
|
Bit#(5) PPS; //decodes a type of NAL unit
|
35 |
|
|
void AUD; //decodes a type of NAL unit
|
36 |
|
|
void EndSequence; //decodes a type of NAL unit
|
37 |
|
|
void EndStream; //decodes a type of NAL unit
|
38 |
|
|
void Filler; //decodes a type of NAL unit
|
39 |
|
|
|
40 |
|
|
Bit#(5) SliceData; //decodes slice data (part of a CodedSlice NAL unit)
|
41 |
|
|
Bit#(5) MacroblockLayer; //decodes macroblock layer (part of a CodedSlice NAL unit)
|
42 |
|
|
Bit#(5) MbPrediction; //decodes macroblock prediction (part of a CodedSlice NAL unit)
|
43 |
|
|
Bit#(5) SubMbPrediction; //decodes sub-macroblock prediction (part of a CodedSlice NAL unit)
|
44 |
|
|
Bit#(5) Residual; //decodes residual (part of a CodedSlice NAL unit)
|
45 |
|
|
Bit#(5) ResidualBlock; //decodes residual block (part of a CodedSlice NAL unit)
|
46 |
|
|
}
|
47 |
|
|
State deriving(Eq,Bits);
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
//-----------------------------------------------------------
|
52 |
|
|
// Helper functions
|
53 |
|
|
function MbType mbtype_convert( Bit#(5) in_mb_type, Bit#(4) in_slice_type );//converts mb_type syntax element to MbType type
|
54 |
|
|
Bit#(5) tempmb = in_mb_type;
|
55 |
|
|
if(in_slice_type == 2 || in_slice_type == 7)//I slice
|
56 |
|
|
tempmb = in_mb_type+5;
|
57 |
|
|
case ( tempmb )
|
58 |
|
|
0: return P_L0_16x16;
|
59 |
|
|
1: return P_L0_L0_16x8;
|
60 |
|
|
2: return P_L0_L0_8x16;
|
61 |
|
|
3: return P_8x8;
|
62 |
|
|
4: return P_8x8ref0;
|
63 |
|
|
5: return I_NxN;
|
64 |
|
|
30: return I_PCM;
|
65 |
|
|
default:
|
66 |
|
|
begin
|
67 |
|
|
Bit#(5) tempmb16x16 = tempmb-6;
|
68 |
|
|
Bit#(2) tempv1 = tempmb16x16[1:0];
|
69 |
|
|
Bit#(2) tempv2;
|
70 |
|
|
Bit#(1) tempv3;
|
71 |
|
|
if(tempmb16x16 < 12)
|
72 |
|
|
begin
|
73 |
|
|
tempv3 = 0;
|
74 |
|
|
tempv2 = tempmb16x16[3:2];
|
75 |
|
|
end
|
76 |
|
|
else
|
77 |
|
|
begin
|
78 |
|
|
tempv3 = 1;
|
79 |
|
|
tempv2 = tempmb16x16[3:2]+1;
|
80 |
|
|
end
|
81 |
|
|
return I_16x16{intra16x16PredMode:tempv1, codedBlockPatternChroma:tempv2, codedBlockPatternLuma:tempv3};
|
82 |
|
|
end
|
83 |
|
|
endcase
|
84 |
|
|
endfunction
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
//-----------------------------------------------------------
|
89 |
|
|
// Entropy Decoder Module
|
90 |
|
|
//-----------------------------------------------------------
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
(* synthesize *)
|
94 |
|
|
module mkEntropyDec( IEntropyDec );
|
95 |
|
|
|
96 |
|
|
FIFO#(NalUnwrapOT) infifo <- mkSizedFIFO(entropyDec_infifo_size);
|
97 |
|
|
FIFO#(EntropyDecOT) outfifo <- mkFIFO;
|
98 |
|
|
FIFO#(EntropyDecOT_InverseTrans) outfifo_ITB <- mkFIFO;
|
99 |
|
|
Reg#(State) state <- mkReg(Start);
|
100 |
|
|
Reg#(Bit#(2)) nalrefidc <- mkReg(0);
|
101 |
|
|
Reg#(Bit#(5)) nalunittype <- mkReg(0);
|
102 |
|
|
Reg#(Buffer) buffer <- mkReg(0);
|
103 |
|
|
Reg#(Bufcount) bufcount <- mkReg(0);
|
104 |
|
|
|
105 |
|
|
//saved syntax elements
|
106 |
|
|
Reg#(Bit#(5)) spsseq_parameter_set_id <- mkReg(0);
|
107 |
|
|
Reg#(Bit#(5)) spslog2_max_frame_num <- mkReg(0);
|
108 |
|
|
Reg#(Bit#(5)) spslog2_max_pic_order_cnt_lsb <- mkReg(0);
|
109 |
|
|
Reg#(Bit#(2)) spspic_order_cnt_type <- mkReg(0);
|
110 |
|
|
Reg#(Bit#(1)) spsdelta_pic_order_always_zero_flag <- mkReg(0);
|
111 |
|
|
Reg#(Bit#(8)) spsnum_ref_frames_in_pic_order_cnt_cycle <- mkReg(0);
|
112 |
|
|
Reg#(Bit#(8)) ppspic_parameter_set_id <- mkReg(0);
|
113 |
|
|
Reg#(Bit#(1)) ppspic_order_present_flag <- mkReg(0);
|
114 |
|
|
Reg#(Bit#(1)) ppsdeblocking_filter_control_present_flag <- mkReg(0);
|
115 |
|
|
Reg#(Bit#(4)) shslice_type <- mkReg(0);
|
116 |
|
|
Reg#(Bit#(3)) shdmemory_management_control_operation <- mkReg(0);
|
117 |
|
|
Reg#(MbType) sdmmbtype <- mkReg(I_NxN);
|
118 |
|
|
Reg#(Bit#(4)) sdmcodedBlockPatternLuma <- mkReg(0);
|
119 |
|
|
Reg#(Bit#(2)) sdmcodedBlockPatternChroma <- mkReg(0);
|
120 |
|
|
Reg#(Bit#(5)) sdmrTotalCoeff <- mkReg(0);
|
121 |
|
|
Reg#(Bit#(2)) sdmrTrailingOnes <- mkReg(0);
|
122 |
|
|
|
123 |
|
|
//derived decoding variables for slice data
|
124 |
|
|
Reg#(Bit#(16)) tempreg <- mkReg(0);
|
125 |
|
|
Reg#(Bit#(5)) num_ref_idx_l0_active_minus1 <- mkReg(0);
|
126 |
|
|
Reg#(Bit#(PicAreaSz)) currMbAddr <- mkReg(0);
|
127 |
|
|
Reg#(Bit#(3)) temp3bit0 <- mkReg(0);
|
128 |
|
|
Reg#(Bit#(3)) temp3bit1 <- mkReg(0);
|
129 |
|
|
Reg#(Bit#(3)) temp3bit2 <- mkReg(0);
|
130 |
|
|
Reg#(Bit#(3)) temp3bit3 <- mkReg(0);
|
131 |
|
|
Reg#(Bit#(5)) temp5bit <- mkReg(0);
|
132 |
|
|
Reg#(Bit#(5)) temp5bit2 <- mkReg(0);
|
133 |
|
|
Reg#(Bit#(5)) maxNumCoeff <- mkReg(0);
|
134 |
|
|
FIFO#(Bit#(13)) cavlcFIFO <- mkSizedFIFO(16);
|
135 |
|
|
Calc_nC calcnc <- mkCalc_nC();
|
136 |
|
|
Reg#(Bit#(1)) residualChroma <- mkReg(0);
|
137 |
|
|
Reg#(Bit#(5)) totalCoeff <- mkReg(0);
|
138 |
|
|
Reg#(Bit#(4)) zerosLeft <- mkReg(0);
|
139 |
|
|
|
140 |
|
|
//exp-golomb 32-bit version states
|
141 |
|
|
Reg#(Bufcount) egnumbits <- mkReg(0);
|
142 |
|
|
|
143 |
|
|
//extra-buffering states
|
144 |
|
|
Reg#(Bit#(32)) extrabuffer <- mkReg(0);
|
145 |
|
|
Reg#(Bit#(3)) extrabufcount <- mkReg(0);
|
146 |
|
|
Reg#(Bit#(1)) extraendnalflag <- mkReg(0);
|
147 |
|
|
Reg#(Bit#(1)) endnalflag <- mkReg(0);
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
//-----------------------------------------------------------
|
151 |
|
|
// Rules
|
152 |
|
|
|
153 |
|
|
rule startup (state matches Start);
|
154 |
|
|
case (infifo.first()) matches
|
155 |
|
|
tagged NewUnit :
|
156 |
|
|
begin
|
157 |
|
|
infifo.deq();
|
158 |
|
|
state <= NewUnit;
|
159 |
|
|
buffer <= 0;
|
160 |
|
|
bufcount <= 0;
|
161 |
|
|
extrabuffer <= 0;
|
162 |
|
|
extrabufcount <= 0;
|
163 |
|
|
extraendnalflag <= 0;
|
164 |
|
|
endnalflag <= 0;
|
165 |
|
|
end
|
166 |
|
|
tagged RbspByte .rdata :
|
167 |
|
|
begin
|
168 |
|
|
infifo.deq();
|
169 |
|
|
end
|
170 |
|
|
tagged EndOfFile :
|
171 |
|
|
begin
|
172 |
|
|
infifo.deq();
|
173 |
|
|
outfifo.enq(EndOfFile);
|
174 |
|
|
$display( "INFO EntropyDec: EndOfFile reached" );
|
175 |
|
|
end
|
176 |
|
|
endcase
|
177 |
|
|
endrule
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
rule newunit (state matches NewUnit);
|
181 |
|
|
case (infifo.first()) matches
|
182 |
|
|
tagged NewUnit : state <= Start;
|
183 |
|
|
tagged RbspByte .rdata :
|
184 |
|
|
begin
|
185 |
|
|
infifo.deq();
|
186 |
|
|
nalrefidc <= rdata[6:5];
|
187 |
|
|
nalunittype <= rdata[4:0];
|
188 |
|
|
case (rdata[4:0])
|
189 |
|
|
1 : state <= CodedSlice 0;
|
190 |
|
|
5 : state <= CodedSlice 0;
|
191 |
|
|
6 : state <= SEI;
|
192 |
|
|
7 : state <= SPS 0;
|
193 |
|
|
8 : state <= PPS 0;
|
194 |
|
|
9 : state <= AUD;
|
195 |
|
|
10: state <= EndSequence;
|
196 |
|
|
11: state <= EndStream;
|
197 |
|
|
12: state <= Filler;
|
198 |
|
|
default:
|
199 |
|
|
begin
|
200 |
|
|
$display( "ERROR EntropyDec: NAL Unit Type = %d", rdata[4:0] );
|
201 |
|
|
state <= Start;
|
202 |
|
|
end
|
203 |
|
|
endcase
|
204 |
|
|
$display("ccl2newunit");
|
205 |
|
|
$display("ccl2rbspbyte %h", rdata);
|
206 |
|
|
outfifo.enq(NewUnit rdata);
|
207 |
|
|
outfifo_ITB.enq(NewUnit rdata);
|
208 |
|
|
end
|
209 |
|
|
tagged EndOfFile : state <= Start;
|
210 |
|
|
endcase
|
211 |
|
|
endrule
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
rule fillextrabuffer (state != Start
|
215 |
|
|
&& state != NewUnit
|
216 |
|
|
&& extrabufcount < 4
|
217 |
|
|
&& extraendnalflag == 0);
|
218 |
|
|
if(infifo.first() matches tagged RbspByte .dbyte)
|
219 |
|
|
begin
|
220 |
|
|
case ( extrabufcount )
|
221 |
|
|
0: extrabuffer <= {dbyte, extrabuffer[23:0]};
|
222 |
|
|
1: extrabuffer <= {extrabuffer[31:24],dbyte,extrabuffer[15:0]};
|
223 |
|
|
2: extrabuffer <= {extrabuffer[31:16],dbyte,extrabuffer[7:0]};
|
224 |
|
|
3: extrabuffer <= {extrabuffer[31:8],dbyte};
|
225 |
|
|
default: $display( "ERROR EntropyDec: fillextrabuffer default case_" );
|
226 |
|
|
endcase
|
227 |
|
|
extrabufcount <= extrabufcount + 1;
|
228 |
|
|
infifo.deq();
|
229 |
|
|
//$display( "TRACE EntropyDec: fillextrabuffer RbspByte %h %h %h", dbyte, extrabufcount, extrabuffer);
|
230 |
|
|
end
|
231 |
|
|
else
|
232 |
|
|
begin
|
233 |
|
|
if(extrabufcount != 0)
|
234 |
|
|
extraendnalflag <= 1;
|
235 |
|
|
//$display( "TRACE EntropyDec: fillextrabuffer else %h", extrabufcount);
|
236 |
|
|
end
|
237 |
|
|
endrule
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
rule fillbuffer (state != Start
|
241 |
|
|
&& state != NewUnit
|
242 |
|
|
&& bufcount<=truncate(buffersize-32)
|
243 |
|
|
&& (extrabufcount == 4 || extraendnalflag == 1)
|
244 |
|
|
&& endnalflag == 0);//predicate not sure
|
245 |
|
|
Buffer temp = zeroExtend(extrabuffer);
|
246 |
|
|
Bufcount temp2 = truncate(buffersize)-bufcount-32;
|
247 |
|
|
buffer <= (buffer | (temp << zeroExtend(temp2)));
|
248 |
|
|
case ( extrabufcount )
|
249 |
|
|
4: bufcount <= bufcount+32;
|
250 |
|
|
3: bufcount <= bufcount+24;
|
251 |
|
|
2: bufcount <= bufcount+16;
|
252 |
|
|
1: bufcount <= bufcount+8;
|
253 |
|
|
default: $display( "ERROR EntropyDec: fillbuffer default case" );
|
254 |
|
|
endcase
|
255 |
|
|
extrabuffer <= 0;
|
256 |
|
|
extrabufcount <= 0;
|
257 |
|
|
if(infifo.first()==NewUnit || infifo.first()==EndOfFile)
|
258 |
|
|
endnalflag <= 1;
|
259 |
|
|
//$display( "TRACE EntropyDec: fillbuffer RbspByte %h %h %h %h %h %h %h %h", extrabufcount, bufcount, extrabuffer, temp, temp2, (temp << zeroExtend(temp2)), buffer, (buffer | (temp << zeroExtend(temp2))));
|
260 |
|
|
endrule
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
rule parser (state != Start
|
264 |
|
|
&&& state != NewUnit
|
265 |
|
|
&&& (bufcount > truncate(buffersize-32) || endnalflag == 1));//predicate not sure
|
266 |
|
|
//$display( "TRACE EntropyDec: fillbuffer RbspByte %h %h", bufcount, buffer );
|
267 |
|
|
|
268 |
|
|
Bufcount numbitsused = 0;
|
269 |
|
|
State nextstate = Start;
|
270 |
|
|
Int#(16) tempint = 0;
|
271 |
|
|
Int#(32) tempint32 = 0;
|
272 |
|
|
|
273 |
|
|
case ( state ) matches
|
274 |
|
|
tagged CodedSlice .step :
|
275 |
|
|
begin
|
276 |
|
|
case ( step )
|
277 |
|
|
0:
|
278 |
|
|
begin
|
279 |
|
|
$display( "ccl2SHfirst_mb_in_slice %0d", expgolomb_unsigned(buffer) );
|
280 |
|
|
outfifo.enq(SHfirst_mb_in_slice truncate(expgolomb_unsigned(buffer)));
|
281 |
|
|
currMbAddr <= truncate(expgolomb_unsigned(buffer));
|
282 |
|
|
calcnc.initialize(truncate(expgolomb_unsigned(buffer)));
|
283 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
284 |
|
|
nextstate = CodedSlice 1;
|
285 |
|
|
end
|
286 |
|
|
1:
|
287 |
|
|
begin
|
288 |
|
|
$display( "ccl2SHslice_type %0d", expgolomb_unsigned(buffer) );
|
289 |
|
|
outfifo.enq(SHslice_type truncate(expgolomb_unsigned(buffer)));
|
290 |
|
|
shslice_type <= truncate(expgolomb_unsigned(buffer));
|
291 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
292 |
|
|
nextstate = CodedSlice 2;
|
293 |
|
|
end
|
294 |
|
|
2:
|
295 |
|
|
begin
|
296 |
|
|
$display( "ccl2SHpic_parameter_set_id %0d", expgolomb_unsigned(buffer) );
|
297 |
|
|
outfifo.enq(SHpic_parameter_set_id truncate(expgolomb_unsigned(buffer)));
|
298 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
299 |
|
|
nextstate = CodedSlice 3;
|
300 |
|
|
if(ppspic_parameter_set_id != truncate(expgolomb_unsigned(buffer))) $display( "ERROR EntropyDec: pic_parameter_set_id don't match" );
|
301 |
|
|
end
|
302 |
|
|
3:
|
303 |
|
|
begin
|
304 |
|
|
Bit#(16) tttt = buffer[buffersize-1:buffersize-16];
|
305 |
|
|
tttt = tttt >> 16 - zeroExtend(spslog2_max_frame_num);
|
306 |
|
|
$display( "ccl2SHframe_num %0d", tttt );
|
307 |
|
|
outfifo.enq(SHframe_num tttt);
|
308 |
|
|
numbitsused = zeroExtend(spslog2_max_frame_num);
|
309 |
|
|
nextstate = CodedSlice 4;
|
310 |
|
|
end
|
311 |
|
|
4:
|
312 |
|
|
begin
|
313 |
|
|
if(nalunittype == 5)
|
314 |
|
|
begin
|
315 |
|
|
$display( "ccl2SHidr_pic_id %0d", expgolomb_unsigned(buffer) );
|
316 |
|
|
outfifo.enq(SHidr_pic_id truncate(expgolomb_unsigned(buffer)));
|
317 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
318 |
|
|
end
|
319 |
|
|
nextstate = CodedSlice 5;
|
320 |
|
|
end
|
321 |
|
|
5:
|
322 |
|
|
begin
|
323 |
|
|
if(spspic_order_cnt_type == 0)
|
324 |
|
|
begin
|
325 |
|
|
Bit#(16) tttt = buffer[buffersize-1:buffersize-16];
|
326 |
|
|
tttt = tttt >> 16 - zeroExtend(spslog2_max_pic_order_cnt_lsb);
|
327 |
|
|
$display( "ccl2SHpic_order_cnt_lsb %0d", tttt );
|
328 |
|
|
outfifo.enq(SHpic_order_cnt_lsb tttt);
|
329 |
|
|
numbitsused = zeroExtend(spslog2_max_pic_order_cnt_lsb);
|
330 |
|
|
nextstate = CodedSlice 6;
|
331 |
|
|
end
|
332 |
|
|
else
|
333 |
|
|
nextstate = CodedSlice 7;
|
334 |
|
|
end
|
335 |
|
|
6:
|
336 |
|
|
begin
|
337 |
|
|
if(ppspic_order_present_flag == 1)
|
338 |
|
|
begin
|
339 |
|
|
if(egnumbits == 0)
|
340 |
|
|
begin
|
341 |
|
|
Bufcount tempbufcount = expgolomb_numbits32(buffer);
|
342 |
|
|
egnumbits <= tempbufcount;
|
343 |
|
|
numbitsused = tempbufcount-1;
|
344 |
|
|
nextstate = CodedSlice 6;
|
345 |
|
|
end
|
346 |
|
|
else
|
347 |
|
|
begin
|
348 |
|
|
tempint32 = unpack(expgolomb_signed32(buffer,egnumbits));
|
349 |
|
|
$display( "ccl2SHdelta_pic_order_cnt_bottom %0d", tempint32 );
|
350 |
|
|
outfifo.enq(SHdelta_pic_order_cnt_bottom truncate(expgolomb_signed32(buffer,egnumbits)));
|
351 |
|
|
egnumbits <= 0;
|
352 |
|
|
numbitsused = egnumbits;
|
353 |
|
|
nextstate = CodedSlice 7;
|
354 |
|
|
end
|
355 |
|
|
end
|
356 |
|
|
else
|
357 |
|
|
nextstate = CodedSlice 7;
|
358 |
|
|
end
|
359 |
|
|
7:
|
360 |
|
|
begin
|
361 |
|
|
if(spspic_order_cnt_type == 1 && spsdelta_pic_order_always_zero_flag == 0)
|
362 |
|
|
begin
|
363 |
|
|
if(egnumbits == 0)
|
364 |
|
|
begin
|
365 |
|
|
Bufcount tempbufcount = expgolomb_numbits32(buffer);
|
366 |
|
|
egnumbits <= tempbufcount;
|
367 |
|
|
numbitsused = tempbufcount-1;
|
368 |
|
|
nextstate = CodedSlice 7;
|
369 |
|
|
end
|
370 |
|
|
else
|
371 |
|
|
begin
|
372 |
|
|
tempint32 = unpack(expgolomb_signed32(buffer,egnumbits));
|
373 |
|
|
$display( "ccl2SHdelta_pic_order_cnt0 %0d", tempint32 );
|
374 |
|
|
outfifo.enq(SHdelta_pic_order_cnt0 truncate(expgolomb_signed32(buffer,egnumbits)));
|
375 |
|
|
egnumbits <= 0;
|
376 |
|
|
numbitsused = egnumbits;
|
377 |
|
|
nextstate = CodedSlice 8;
|
378 |
|
|
end
|
379 |
|
|
end
|
380 |
|
|
else
|
381 |
|
|
nextstate = CodedSlice 9;
|
382 |
|
|
end
|
383 |
|
|
8:
|
384 |
|
|
begin
|
385 |
|
|
if(ppspic_order_present_flag == 1)
|
386 |
|
|
begin
|
387 |
|
|
if(egnumbits == 0)
|
388 |
|
|
begin
|
389 |
|
|
Bufcount tempbufcount = expgolomb_numbits32(buffer);
|
390 |
|
|
egnumbits <= tempbufcount;
|
391 |
|
|
numbitsused = tempbufcount-1;
|
392 |
|
|
nextstate = CodedSlice 8;
|
393 |
|
|
end
|
394 |
|
|
else
|
395 |
|
|
begin
|
396 |
|
|
tempint32 = unpack(expgolomb_signed32(buffer,egnumbits));
|
397 |
|
|
$display( "ccl2SHdelta_pic_order_cnt1 %0d", tempint32 );
|
398 |
|
|
outfifo.enq(SHdelta_pic_order_cnt1 truncate(expgolomb_signed32(buffer,egnumbits)));
|
399 |
|
|
egnumbits <= 0;
|
400 |
|
|
numbitsused = egnumbits;
|
401 |
|
|
nextstate = CodedSlice 9;
|
402 |
|
|
end
|
403 |
|
|
end
|
404 |
|
|
else
|
405 |
|
|
nextstate = CodedSlice 9;
|
406 |
|
|
end
|
407 |
|
|
9:
|
408 |
|
|
begin
|
409 |
|
|
if(shslice_type == 0 || shslice_type == 5)
|
410 |
|
|
begin
|
411 |
|
|
$display( "ccl2SHnum_ref_idx_active_override_flag %0d", buffer[buffersize-1] );
|
412 |
|
|
outfifo.enq(SHnum_ref_idx_active_override_flag buffer[buffersize-1]);
|
413 |
|
|
numbitsused = 1;
|
414 |
|
|
if(buffer[buffersize-1] == 1)
|
415 |
|
|
nextstate = CodedSlice 10;
|
416 |
|
|
else
|
417 |
|
|
nextstate = CodedSlice 11;
|
418 |
|
|
end
|
419 |
|
|
else
|
420 |
|
|
nextstate = CodedSlice 11;
|
421 |
|
|
end
|
422 |
|
|
10:
|
423 |
|
|
begin
|
424 |
|
|
$display( "ccl2SHnum_ref_idx_l0_active %0d", expgolomb_unsigned(buffer)+1 );
|
425 |
|
|
outfifo.enq(SHnum_ref_idx_l0_active truncate(expgolomb_unsigned(buffer)+1));
|
426 |
|
|
num_ref_idx_l0_active_minus1 <= truncate(expgolomb_unsigned(buffer));
|
427 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
428 |
|
|
nextstate = CodedSlice 11;
|
429 |
|
|
end
|
430 |
|
|
11:
|
431 |
|
|
begin
|
432 |
|
|
if(shslice_type != 2 && shslice_type != 7)
|
433 |
|
|
begin
|
434 |
|
|
$display( "ccl2SHRref_pic_list_reordering_flag_l0 %0d", buffer[buffersize-1] );
|
435 |
|
|
outfifo.enq(SHRref_pic_list_reordering_flag_l0 buffer[buffersize-1]);
|
436 |
|
|
numbitsused = 1;
|
437 |
|
|
if(buffer[buffersize-1] == 1)
|
438 |
|
|
nextstate = CodedSlice 12;
|
439 |
|
|
else
|
440 |
|
|
nextstate = CodedSlice 15;
|
441 |
|
|
end
|
442 |
|
|
else
|
443 |
|
|
nextstate = CodedSlice 15;
|
444 |
|
|
end
|
445 |
|
|
12:
|
446 |
|
|
begin
|
447 |
|
|
$display( "ccl2SHRreordering_of_pic_nums_idc %0d", expgolomb_unsigned(buffer) );
|
448 |
|
|
outfifo.enq(SHRreordering_of_pic_nums_idc truncate(expgolomb_unsigned(buffer)));
|
449 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
450 |
|
|
if(expgolomb_unsigned(buffer)==0 || expgolomb_unsigned(buffer)==1)
|
451 |
|
|
nextstate = CodedSlice 13;
|
452 |
|
|
else if(expgolomb_unsigned(buffer)==2)
|
453 |
|
|
nextstate = CodedSlice 14;
|
454 |
|
|
else
|
455 |
|
|
nextstate = CodedSlice 15;
|
456 |
|
|
end
|
457 |
|
|
13:
|
458 |
|
|
begin
|
459 |
|
|
Bit#(17) temp17 = zeroExtend(expgolomb_unsigned(buffer)) + 1;
|
460 |
|
|
$display( "ccl2SHRabs_diff_pic_num %0d", temp17 );
|
461 |
|
|
outfifo.enq(SHRabs_diff_pic_num temp17);
|
462 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
463 |
|
|
nextstate = CodedSlice 12;
|
464 |
|
|
end
|
465 |
|
|
14:
|
466 |
|
|
begin
|
467 |
|
|
$display( "ccl2SHRlong_term_pic_num %0d", expgolomb_unsigned(buffer) );
|
468 |
|
|
outfifo.enq(SHRlong_term_pic_num truncate(expgolomb_unsigned(buffer)));
|
469 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
470 |
|
|
nextstate = CodedSlice 12;
|
471 |
|
|
end
|
472 |
|
|
15:
|
473 |
|
|
begin
|
474 |
|
|
if(nalrefidc == 0)
|
475 |
|
|
nextstate = CodedSlice 23;
|
476 |
|
|
else
|
477 |
|
|
begin
|
478 |
|
|
if(nalunittype == 5)
|
479 |
|
|
begin
|
480 |
|
|
$display( "ccl2SHDno_output_of_prior_pics_flag %0d", buffer[buffersize-1] );
|
481 |
|
|
outfifo.enq(SHDno_output_of_prior_pics_flag buffer[buffersize-1]);
|
482 |
|
|
numbitsused = 1;
|
483 |
|
|
nextstate = CodedSlice 16;
|
484 |
|
|
end
|
485 |
|
|
else
|
486 |
|
|
nextstate = CodedSlice 17;
|
487 |
|
|
end
|
488 |
|
|
end
|
489 |
|
|
16:
|
490 |
|
|
begin
|
491 |
|
|
$display( "ccl2SHDlong_term_reference_flag %0d", buffer[buffersize-1] );
|
492 |
|
|
outfifo.enq(SHDlong_term_reference_flag buffer[buffersize-1]);
|
493 |
|
|
numbitsused = 1;
|
494 |
|
|
nextstate = CodedSlice 23;
|
495 |
|
|
end
|
496 |
|
|
17:
|
497 |
|
|
begin
|
498 |
|
|
$display( "ccl2SHDadaptive_ref_pic_marking_mode_flag %0d", buffer[buffersize-1] );
|
499 |
|
|
outfifo.enq(SHDadaptive_ref_pic_marking_mode_flag buffer[buffersize-1]);
|
500 |
|
|
numbitsused = 1;
|
501 |
|
|
if(buffer[buffersize-1] == 1)
|
502 |
|
|
nextstate = CodedSlice 18;
|
503 |
|
|
else
|
504 |
|
|
nextstate = CodedSlice 23;
|
505 |
|
|
end
|
506 |
|
|
18:
|
507 |
|
|
begin
|
508 |
|
|
$display( "ccl2SHDmemory_management_control_operation %0d", expgolomb_unsigned(buffer) );
|
509 |
|
|
outfifo.enq(SHDmemory_management_control_operation truncate(expgolomb_unsigned(buffer)));
|
510 |
|
|
shdmemory_management_control_operation <= truncate(expgolomb_unsigned(buffer));
|
511 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
512 |
|
|
if(expgolomb_unsigned(buffer)!=0)
|
513 |
|
|
nextstate = CodedSlice 19;
|
514 |
|
|
else
|
515 |
|
|
nextstate = CodedSlice 23;
|
516 |
|
|
end
|
517 |
|
|
19:
|
518 |
|
|
begin
|
519 |
|
|
if(shdmemory_management_control_operation==1 || shdmemory_management_control_operation==3)
|
520 |
|
|
begin
|
521 |
|
|
Bit#(17) temp17 = zeroExtend(expgolomb_unsigned(buffer)) + 1;
|
522 |
|
|
$display( "ccl2SHDdifference_of_pic_nums %0d", temp17 );
|
523 |
|
|
outfifo.enq(SHDdifference_of_pic_nums temp17);
|
524 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
525 |
|
|
nextstate = CodedSlice 20;
|
526 |
|
|
end
|
527 |
|
|
else
|
528 |
|
|
nextstate = CodedSlice 20;
|
529 |
|
|
end
|
530 |
|
|
20:
|
531 |
|
|
begin
|
532 |
|
|
if(shdmemory_management_control_operation==2)
|
533 |
|
|
begin
|
534 |
|
|
$display( "ccl2SHDlong_term_pic_num %0d", expgolomb_unsigned(buffer) );
|
535 |
|
|
outfifo.enq(SHDlong_term_pic_num truncate(expgolomb_unsigned(buffer)));
|
536 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
537 |
|
|
nextstate = CodedSlice 21;
|
538 |
|
|
end
|
539 |
|
|
else
|
540 |
|
|
nextstate = CodedSlice 21;
|
541 |
|
|
end
|
542 |
|
|
21:
|
543 |
|
|
begin
|
544 |
|
|
if(shdmemory_management_control_operation==3 || shdmemory_management_control_operation==6)
|
545 |
|
|
begin
|
546 |
|
|
$display( "ccl2SHDlong_term_frame_idx %0d", expgolomb_unsigned(buffer) );
|
547 |
|
|
outfifo.enq(SHDlong_term_frame_idx truncate(expgolomb_unsigned(buffer)));
|
548 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
549 |
|
|
nextstate = CodedSlice 22;
|
550 |
|
|
end
|
551 |
|
|
else
|
552 |
|
|
nextstate = CodedSlice 22;
|
553 |
|
|
end
|
554 |
|
|
22:
|
555 |
|
|
begin
|
556 |
|
|
if(shdmemory_management_control_operation==4)
|
557 |
|
|
begin
|
558 |
|
|
$display( "ccl2SHDmax_long_term_frame_idx_plus1 %0d", expgolomb_unsigned(buffer) );
|
559 |
|
|
outfifo.enq(SHDmax_long_term_frame_idx_plus1 truncate(expgolomb_unsigned(buffer)));
|
560 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
561 |
|
|
nextstate = CodedSlice 18;
|
562 |
|
|
end
|
563 |
|
|
else
|
564 |
|
|
nextstate = CodedSlice 18;
|
565 |
|
|
end
|
566 |
|
|
23:
|
567 |
|
|
begin
|
568 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
569 |
|
|
$display( "ccl2SHslice_qp_delta %0d", tempint );
|
570 |
|
|
outfifo_ITB.enq(SHslice_qp_delta truncate(expgolomb_signed(buffer)));
|
571 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
572 |
|
|
nextstate = CodedSlice 24;
|
573 |
|
|
end
|
574 |
|
|
24:
|
575 |
|
|
begin
|
576 |
|
|
if(ppsdeblocking_filter_control_present_flag==1)
|
577 |
|
|
begin
|
578 |
|
|
$display( "ccl2SHdisable_deblocking_filter_idc %0d", expgolomb_unsigned(buffer) );
|
579 |
|
|
outfifo.enq(SHdisable_deblocking_filter_idc truncate(expgolomb_unsigned(buffer)));
|
580 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
581 |
|
|
if(expgolomb_unsigned(buffer)!=1)
|
582 |
|
|
nextstate = CodedSlice 25;
|
583 |
|
|
else
|
584 |
|
|
nextstate = CodedSlice 27;
|
585 |
|
|
end
|
586 |
|
|
else
|
587 |
|
|
nextstate = CodedSlice 27;
|
588 |
|
|
end
|
589 |
|
|
25:
|
590 |
|
|
begin
|
591 |
|
|
tempint = unpack(expgolomb_signed(buffer) << 1);
|
592 |
|
|
$display( "ccl2SHslice_alpha_c0_offset %0d", tempint );
|
593 |
|
|
outfifo.enq(SHslice_alpha_c0_offset truncate(expgolomb_signed(buffer) << 1));
|
594 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
595 |
|
|
nextstate = CodedSlice 26;
|
596 |
|
|
end
|
597 |
|
|
26:
|
598 |
|
|
begin
|
599 |
|
|
tempint = unpack(expgolomb_signed(buffer) << 1);
|
600 |
|
|
$display( "ccl2SHslice_beta_offset %0d", tempint );
|
601 |
|
|
outfifo.enq(SHslice_beta_offset truncate(expgolomb_signed(buffer) << 1));
|
602 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
603 |
|
|
nextstate = CodedSlice 27;
|
604 |
|
|
end
|
605 |
|
|
27:
|
606 |
|
|
begin
|
607 |
|
|
nextstate = SliceData 0;
|
608 |
|
|
end
|
609 |
|
|
default: $display( "ERROR EntropyDec: CodedSlice default step" );
|
610 |
|
|
endcase
|
611 |
|
|
end
|
612 |
|
|
tagged SEI .step :
|
613 |
|
|
begin
|
614 |
|
|
nextstate = Start;
|
615 |
|
|
$display( "INFO EntropyDec: SEI data thrown away" );
|
616 |
|
|
end
|
617 |
|
|
tagged SPS .step :
|
618 |
|
|
begin
|
619 |
|
|
case ( step )
|
620 |
|
|
0:
|
621 |
|
|
begin
|
622 |
|
|
Bit#(8) outputdata = buffer[buffersize-1:buffersize-8];
|
623 |
|
|
$display( "INFO EntropyDec: profile_idc = %d", outputdata );
|
624 |
|
|
outputdata = buffer[buffersize-9:buffersize-16];
|
625 |
|
|
$display( "INFO EntropyDec: constraint_set = %b", outputdata );
|
626 |
|
|
outputdata = buffer[buffersize-17:buffersize-24];
|
627 |
|
|
$display( "INFO EntropyDec: level_idc = %d", outputdata );
|
628 |
|
|
numbitsused = 24;
|
629 |
|
|
nextstate = SPS 1;
|
630 |
|
|
end
|
631 |
|
|
1:
|
632 |
|
|
begin
|
633 |
|
|
$display( "ccl2SPSseq_parameter_set_id %0d", expgolomb_unsigned(buffer) );
|
634 |
|
|
outfifo.enq(SPSseq_parameter_set_id truncate(expgolomb_unsigned(buffer)));
|
635 |
|
|
spsseq_parameter_set_id <= truncate(expgolomb_unsigned(buffer));
|
636 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
637 |
|
|
nextstate = SPS 2;
|
638 |
|
|
end
|
639 |
|
|
2:
|
640 |
|
|
begin
|
641 |
|
|
$display( "ccl2SPSlog2_max_frame_num %0d", expgolomb_unsigned(buffer)+4 );
|
642 |
|
|
outfifo.enq(SPSlog2_max_frame_num truncate(expgolomb_unsigned(buffer)+4));
|
643 |
|
|
spslog2_max_frame_num <= truncate(expgolomb_unsigned(buffer)+4);
|
644 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
645 |
|
|
nextstate = SPS 3;
|
646 |
|
|
end
|
647 |
|
|
3:
|
648 |
|
|
begin
|
649 |
|
|
let tttt = expgolomb_unsigned(buffer);
|
650 |
|
|
$display( "ccl2SPSpic_order_cnt_type %0d", tttt );
|
651 |
|
|
outfifo.enq(SPSpic_order_cnt_type truncate(tttt));
|
652 |
|
|
spspic_order_cnt_type <= truncate(tttt);
|
653 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
654 |
|
|
if(tttt == 0)
|
655 |
|
|
nextstate = SPS 4;
|
656 |
|
|
else if(tttt == 1)
|
657 |
|
|
nextstate = SPS 5;
|
658 |
|
|
else
|
659 |
|
|
nextstate = SPS 10;
|
660 |
|
|
end
|
661 |
|
|
4:
|
662 |
|
|
begin
|
663 |
|
|
$display( "ccl2SPSlog2_max_pic_order_cnt_lsb %0d", expgolomb_unsigned(buffer)+4 );
|
664 |
|
|
outfifo.enq(SPSlog2_max_pic_order_cnt_lsb truncate(expgolomb_unsigned(buffer)+4));
|
665 |
|
|
spslog2_max_pic_order_cnt_lsb <= truncate(expgolomb_unsigned(buffer)+4);
|
666 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
667 |
|
|
nextstate = SPS 10;
|
668 |
|
|
end
|
669 |
|
|
5:
|
670 |
|
|
begin
|
671 |
|
|
$display( "ccl2SPSdelta_pic_order_always_zero_flag %0d", buffer[buffersize-1] );
|
672 |
|
|
outfifo.enq(SPSdelta_pic_order_always_zero_flag buffer[buffersize-1]);
|
673 |
|
|
spsdelta_pic_order_always_zero_flag <= buffer[buffersize-1];
|
674 |
|
|
numbitsused = 1;
|
675 |
|
|
nextstate = SPS 6;
|
676 |
|
|
end
|
677 |
|
|
6:
|
678 |
|
|
begin
|
679 |
|
|
if(egnumbits == 0)
|
680 |
|
|
begin
|
681 |
|
|
Bufcount tempbufcount = expgolomb_numbits32(buffer);
|
682 |
|
|
egnumbits <= tempbufcount;
|
683 |
|
|
numbitsused = tempbufcount-1;
|
684 |
|
|
nextstate = SPS 6;
|
685 |
|
|
end
|
686 |
|
|
else
|
687 |
|
|
begin
|
688 |
|
|
tempint32 = unpack(expgolomb_signed32(buffer,egnumbits));
|
689 |
|
|
$display( "ccl2SPSoffset_for_non_ref_pic %0d", tempint32 );
|
690 |
|
|
outfifo.enq(SPSoffset_for_non_ref_pic truncate(expgolomb_signed32(buffer,egnumbits)));
|
691 |
|
|
egnumbits <= 0;
|
692 |
|
|
numbitsused = egnumbits;
|
693 |
|
|
nextstate = SPS 7;
|
694 |
|
|
end
|
695 |
|
|
end
|
696 |
|
|
7:
|
697 |
|
|
begin
|
698 |
|
|
if(egnumbits == 0)
|
699 |
|
|
begin
|
700 |
|
|
Bufcount tempbufcount = expgolomb_numbits32(buffer);
|
701 |
|
|
egnumbits <= tempbufcount;
|
702 |
|
|
numbitsused = tempbufcount-1;
|
703 |
|
|
nextstate = SPS 7;
|
704 |
|
|
end
|
705 |
|
|
else
|
706 |
|
|
begin
|
707 |
|
|
tempint32 = unpack(expgolomb_signed32(buffer,egnumbits));
|
708 |
|
|
$display( "ccl2SPSoffset_for_top_to_bottom_field %0d", tempint32 );
|
709 |
|
|
outfifo.enq(SPSoffset_for_top_to_bottom_field truncate(expgolomb_signed32(buffer,egnumbits)));
|
710 |
|
|
egnumbits <= 0;
|
711 |
|
|
numbitsused = egnumbits;
|
712 |
|
|
nextstate = SPS 8;
|
713 |
|
|
end
|
714 |
|
|
end
|
715 |
|
|
8:
|
716 |
|
|
begin
|
717 |
|
|
$display( "ccl2SPSnum_ref_frames_in_pic_order_cnt_cycle %0d", expgolomb_unsigned(buffer) );
|
718 |
|
|
outfifo.enq(SPSnum_ref_frames_in_pic_order_cnt_cycle truncate(expgolomb_unsigned(buffer)));
|
719 |
|
|
spsnum_ref_frames_in_pic_order_cnt_cycle <= truncate(expgolomb_unsigned(buffer));
|
720 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
721 |
|
|
nextstate = SPS 9;
|
722 |
|
|
end
|
723 |
|
|
9:
|
724 |
|
|
begin
|
725 |
|
|
if(spsnum_ref_frames_in_pic_order_cnt_cycle == 0)
|
726 |
|
|
nextstate = SPS 10;
|
727 |
|
|
else
|
728 |
|
|
begin
|
729 |
|
|
if(egnumbits == 0)
|
730 |
|
|
begin
|
731 |
|
|
Bufcount tempbufcount = expgolomb_numbits32(buffer);
|
732 |
|
|
egnumbits <= tempbufcount;
|
733 |
|
|
numbitsused = tempbufcount-1;
|
734 |
|
|
nextstate = SPS 9;
|
735 |
|
|
end
|
736 |
|
|
else
|
737 |
|
|
begin
|
738 |
|
|
tempint32 = unpack(expgolomb_signed32(buffer,egnumbits));
|
739 |
|
|
$display( "ccl2SPSoffset_for_ref_frame %0d", tempint32 );
|
740 |
|
|
outfifo.enq(SPSoffset_for_ref_frame truncate(expgolomb_signed32(buffer,egnumbits)));
|
741 |
|
|
egnumbits <= 0;
|
742 |
|
|
spsnum_ref_frames_in_pic_order_cnt_cycle <= spsnum_ref_frames_in_pic_order_cnt_cycle - 1;
|
743 |
|
|
numbitsused = egnumbits;
|
744 |
|
|
nextstate = SPS 9;
|
745 |
|
|
end
|
746 |
|
|
end
|
747 |
|
|
end
|
748 |
|
|
10:
|
749 |
|
|
begin
|
750 |
|
|
$display( "ccl2SPSnum_ref_frames %0d", expgolomb_unsigned(buffer) );
|
751 |
|
|
outfifo.enq(SPSnum_ref_frames truncate(expgolomb_unsigned(buffer)));
|
752 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
753 |
|
|
nextstate = SPS 11;
|
754 |
|
|
end
|
755 |
|
|
11:
|
756 |
|
|
begin
|
757 |
|
|
$display( "ccl2SPSgaps_in_frame_num_allowed_flag %0d", buffer[buffersize-1] );
|
758 |
|
|
outfifo.enq(SPSgaps_in_frame_num_allowed_flag buffer[buffersize-1]);
|
759 |
|
|
numbitsused = 1;
|
760 |
|
|
nextstate = SPS 12;
|
761 |
|
|
end
|
762 |
|
|
12:
|
763 |
|
|
begin
|
764 |
|
|
$display( "ccl2SPSpic_width_in_mbs %0d", expgolomb_unsigned(buffer)+1 );
|
765 |
|
|
outfifo.enq(SPSpic_width_in_mbs truncate(expgolomb_unsigned(buffer)+1));
|
766 |
|
|
calcnc.initialize_picWidth(truncate(expgolomb_unsigned(buffer)+1));
|
767 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
768 |
|
|
nextstate = SPS 13;
|
769 |
|
|
end
|
770 |
|
|
13:
|
771 |
|
|
begin
|
772 |
|
|
$display( "ccl2SPSpic_height_in_map_units %0d", expgolomb_unsigned(buffer)+1 );
|
773 |
|
|
outfifo.enq(SPSpic_height_in_map_units truncate(expgolomb_unsigned(buffer)+1));
|
774 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
775 |
|
|
nextstate = SPS 14;
|
776 |
|
|
end
|
777 |
|
|
14:
|
778 |
|
|
begin
|
779 |
|
|
//SPSframe_mbs_only_flag = 1 for baseline
|
780 |
|
|
numbitsused = 1;
|
781 |
|
|
nextstate = SPS 15;
|
782 |
|
|
end
|
783 |
|
|
15:
|
784 |
|
|
begin
|
785 |
|
|
$display( "ccl2SPSdirect_8x8_inference_flag %0d", buffer[buffersize-1] );
|
786 |
|
|
outfifo.enq(SPSdirect_8x8_inference_flag buffer[buffersize-1]);
|
787 |
|
|
numbitsused = 1;
|
788 |
|
|
nextstate = SPS 16;
|
789 |
|
|
end
|
790 |
|
|
16:
|
791 |
|
|
begin
|
792 |
|
|
$display( "ccl2SPSframe_cropping_flag %0d", buffer[buffersize-1] );
|
793 |
|
|
outfifo.enq(SPSframe_cropping_flag buffer[buffersize-1]);
|
794 |
|
|
numbitsused = 1;
|
795 |
|
|
if(buffer[buffersize-1] == 1)
|
796 |
|
|
nextstate = SPS 17;
|
797 |
|
|
else
|
798 |
|
|
nextstate = SPS 21;
|
799 |
|
|
end
|
800 |
|
|
17:
|
801 |
|
|
begin
|
802 |
|
|
$display( "ccl2SPSframe_crop_left_offset %0d", expgolomb_unsigned(buffer) );
|
803 |
|
|
outfifo.enq(SPSframe_crop_left_offset truncate(expgolomb_unsigned(buffer)));
|
804 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
805 |
|
|
nextstate = SPS 18;
|
806 |
|
|
end
|
807 |
|
|
18:
|
808 |
|
|
begin
|
809 |
|
|
$display( "ccl2SPSframe_crop_right_offset %0d", expgolomb_unsigned(buffer) );
|
810 |
|
|
outfifo.enq(SPSframe_crop_right_offset truncate(expgolomb_unsigned(buffer)));
|
811 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
812 |
|
|
nextstate = SPS 19;
|
813 |
|
|
end
|
814 |
|
|
19:
|
815 |
|
|
begin
|
816 |
|
|
$display( "ccl2SPSframe_crop_top_offset %0d", expgolomb_unsigned(buffer) );
|
817 |
|
|
outfifo.enq(SPSframe_crop_top_offset truncate(expgolomb_unsigned(buffer)));
|
818 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
819 |
|
|
nextstate = SPS 20;
|
820 |
|
|
end
|
821 |
|
|
20:
|
822 |
|
|
begin
|
823 |
|
|
$display( "ccl2SPSframe_crop_bottom_offset %0d", expgolomb_unsigned(buffer) );
|
824 |
|
|
outfifo.enq(SPSframe_crop_bottom_offset truncate(expgolomb_unsigned(buffer)));
|
825 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
826 |
|
|
nextstate = SPS 21;
|
827 |
|
|
end
|
828 |
|
|
21:
|
829 |
|
|
begin
|
830 |
|
|
nextstate = Start;
|
831 |
|
|
$display( "INFO EntropyDec:VUI data thrown away" );
|
832 |
|
|
end
|
833 |
|
|
default: $display( "ERROR EntropyDec: SPS default step" );
|
834 |
|
|
endcase
|
835 |
|
|
end
|
836 |
|
|
tagged PPS .step :
|
837 |
|
|
begin
|
838 |
|
|
case ( step )
|
839 |
|
|
0:
|
840 |
|
|
begin
|
841 |
|
|
ppspic_parameter_set_id <= truncate(expgolomb_unsigned(buffer));
|
842 |
|
|
$display( "ccl2PPSpic_parameter_set_id %0d", expgolomb_unsigned(buffer) );
|
843 |
|
|
outfifo.enq(PPSpic_parameter_set_id truncate(expgolomb_unsigned(buffer)));
|
844 |
|
|
outfifo_ITB.enq(PPSpic_parameter_set_id truncate(expgolomb_unsigned(buffer)));
|
845 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
846 |
|
|
nextstate = PPS 1;
|
847 |
|
|
end
|
848 |
|
|
1:
|
849 |
|
|
begin
|
850 |
|
|
$display( "ccl2PPSseq_parameter_set_id %0d", expgolomb_unsigned(buffer) );
|
851 |
|
|
outfifo.enq(PPSseq_parameter_set_id truncate(expgolomb_unsigned(buffer)));
|
852 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
853 |
|
|
nextstate = PPS 2;
|
854 |
|
|
if(spsseq_parameter_set_id != truncate(expgolomb_unsigned(buffer)))
|
855 |
|
|
$display( "ERROR EntropyDec: seq_parameter_set_id don't match" );
|
856 |
|
|
end
|
857 |
|
|
2:
|
858 |
|
|
begin
|
859 |
|
|
//PPSentropy_coding_mode_flag = 0 for baseline
|
860 |
|
|
numbitsused = 1;
|
861 |
|
|
nextstate = PPS 3;
|
862 |
|
|
end
|
863 |
|
|
3:
|
864 |
|
|
begin
|
865 |
|
|
ppspic_order_present_flag <= buffer[buffersize-1];
|
866 |
|
|
$display( "ccl2PPSpic_order_present_flag %0d", buffer[buffersize-1] );
|
867 |
|
|
outfifo.enq(PPSpic_order_present_flag buffer[buffersize-1]);
|
868 |
|
|
numbitsused = 1;
|
869 |
|
|
nextstate = PPS 4;
|
870 |
|
|
end
|
871 |
|
|
4:
|
872 |
|
|
begin
|
873 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
874 |
|
|
nextstate = PPS 5;
|
875 |
|
|
if(expgolomb_unsigned(buffer)+1 != 1)
|
876 |
|
|
$display( "ERROR EntropyDec: PPSnum_slice_groups not equal to 1" );//=1 for main
|
877 |
|
|
end
|
878 |
|
|
5:
|
879 |
|
|
begin
|
880 |
|
|
$display( "ccl2PPSnum_ref_idx_l0_active %0d", expgolomb_unsigned(buffer)+1 );
|
881 |
|
|
outfifo.enq(PPSnum_ref_idx_l0_active truncate(expgolomb_unsigned(buffer)+1));
|
882 |
|
|
num_ref_idx_l0_active_minus1 <= truncate(expgolomb_unsigned(buffer));
|
883 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
884 |
|
|
nextstate = PPS 6;
|
885 |
|
|
end
|
886 |
|
|
6:
|
887 |
|
|
begin
|
888 |
|
|
$display( "ccl2PPSnum_ref_idx_l1_active %0d", expgolomb_unsigned(buffer)+1 );
|
889 |
|
|
outfifo.enq(PPSnum_ref_idx_l1_active truncate(expgolomb_unsigned(buffer)+1));
|
890 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
891 |
|
|
nextstate = PPS 7;
|
892 |
|
|
end
|
893 |
|
|
7:
|
894 |
|
|
begin
|
895 |
|
|
//PPSweighted_pred_flag = 0 for baseline; PPSweighted_bipred_idc = 0 for baseline
|
896 |
|
|
numbitsused = 3;
|
897 |
|
|
nextstate = PPS 8;
|
898 |
|
|
end
|
899 |
|
|
8:
|
900 |
|
|
begin
|
901 |
|
|
$display( "ccl2PPSpic_init_qp %0d", expgolomb_signed(buffer)+26 );
|
902 |
|
|
outfifo_ITB.enq(PPSpic_init_qp truncate(expgolomb_signed(buffer)+26));
|
903 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
904 |
|
|
nextstate = PPS 9;
|
905 |
|
|
end
|
906 |
|
|
9:
|
907 |
|
|
begin
|
908 |
|
|
$display( "ccl2PPSpic_init_qs %0d", expgolomb_signed(buffer)+26 );
|
909 |
|
|
outfifo_ITB.enq(PPSpic_init_qs truncate(expgolomb_signed(buffer)+26));
|
910 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
911 |
|
|
nextstate = PPS 10;
|
912 |
|
|
end
|
913 |
|
|
10:
|
914 |
|
|
begin
|
915 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
916 |
|
|
$display( "ccl2PPSchroma_qp_index_offset %0d", tempint );
|
917 |
|
|
outfifo_ITB.enq(PPSchroma_qp_index_offset truncate(expgolomb_signed(buffer)));
|
918 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
919 |
|
|
nextstate = PPS 11;
|
920 |
|
|
end
|
921 |
|
|
11:
|
922 |
|
|
begin
|
923 |
|
|
ppsdeblocking_filter_control_present_flag <= buffer[buffersize-1];
|
924 |
|
|
$display( "ccl2PPSdeblocking_filter_control_present_flag %0d", buffer[buffersize-1] );
|
925 |
|
|
outfifo.enq(PPSdeblocking_filter_control_present_flag buffer[buffersize-1]);
|
926 |
|
|
numbitsused = 1;
|
927 |
|
|
nextstate = PPS 12;
|
928 |
|
|
end
|
929 |
|
|
12:
|
930 |
|
|
begin
|
931 |
|
|
$display( "ccl2PPSconstrained_intra_pred_flag %0d", buffer[buffersize-1] );
|
932 |
|
|
outfifo.enq(PPSconstrained_intra_pred_flag buffer[buffersize-1]);
|
933 |
|
|
numbitsused = 1;
|
934 |
|
|
nextstate = PPS 13;
|
935 |
|
|
end
|
936 |
|
|
13:
|
937 |
|
|
begin
|
938 |
|
|
//PPSredundant_pic_cnt_present_flag = 0 for main
|
939 |
|
|
numbitsused = 1;
|
940 |
|
|
nextstate = PPS 14;
|
941 |
|
|
if(buffer[buffersize-1] != 0)
|
942 |
|
|
$display( "ERROR EntropyDec: PPSredundant_pic_cnt_present_flag not equal to 0" );//=0 for main
|
943 |
|
|
end
|
944 |
|
|
14:
|
945 |
|
|
begin
|
946 |
|
|
nextstate = Start;
|
947 |
|
|
end
|
948 |
|
|
default: $display( "ERROR EntropyDec: PPS default step" );
|
949 |
|
|
endcase
|
950 |
|
|
end
|
951 |
|
|
tagged AUD .step :
|
952 |
|
|
begin
|
953 |
|
|
outfifo.enq(AUDPrimaryPicType buffer[buffersize-1:buffersize-3]);
|
954 |
|
|
numbitsused = 3;
|
955 |
|
|
nextstate = Start;
|
956 |
|
|
end
|
957 |
|
|
tagged EndSequence :
|
958 |
|
|
begin
|
959 |
|
|
outfifo.enq(EndOfSequence);
|
960 |
|
|
nextstate = Start;
|
961 |
|
|
end
|
962 |
|
|
tagged EndStream :
|
963 |
|
|
begin
|
964 |
|
|
outfifo.enq(EndOfStream);
|
965 |
|
|
nextstate = Start;
|
966 |
|
|
end
|
967 |
|
|
tagged Filler :
|
968 |
|
|
begin
|
969 |
|
|
nextstate = Start;
|
970 |
|
|
end
|
971 |
|
|
tagged SliceData .step :
|
972 |
|
|
begin
|
973 |
|
|
case ( step )
|
974 |
|
|
0:
|
975 |
|
|
begin
|
976 |
|
|
if( shslice_type!=2 && shslice_type!=7 )
|
977 |
|
|
begin
|
978 |
|
|
$display( "ccl2SDmb_skip_run %0d", expgolomb_unsigned(buffer) );
|
979 |
|
|
outfifo.enq(SDmb_skip_run truncate(expgolomb_unsigned(buffer)));
|
980 |
|
|
tempreg <= truncate(expgolomb_unsigned(buffer));
|
981 |
|
|
calcnc.nNupdate_pskip( truncate(expgolomb_unsigned(buffer)) );
|
982 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
983 |
|
|
nextstate = SliceData 1;
|
984 |
|
|
end
|
985 |
|
|
else
|
986 |
|
|
nextstate = SliceData 2;
|
987 |
|
|
end
|
988 |
|
|
1:
|
989 |
|
|
begin
|
990 |
|
|
if( tempreg>0 )
|
991 |
|
|
begin
|
992 |
|
|
currMbAddr <= currMbAddr+1;//only because input assumed to comform to both baseline and main
|
993 |
|
|
tempreg <= tempreg-1;
|
994 |
|
|
nextstate = SliceData 1;
|
995 |
|
|
end
|
996 |
|
|
else
|
997 |
|
|
begin
|
998 |
|
|
////$display( "ccl2SDcurrMbAddr %0d", currMbAddr );
|
999 |
|
|
////outfifo.enq(SDcurrMbAddr currMbAddr);
|
1000 |
|
|
nextstate = SliceData 2;
|
1001 |
|
|
end
|
1002 |
|
|
end
|
1003 |
|
|
2:
|
1004 |
|
|
begin
|
1005 |
|
|
if( bufcount>8 || buffer[buffersize-1]!=1 || (buffer<<1)!=0 )
|
1006 |
|
|
begin
|
1007 |
|
|
calcnc.loadMb(currMbAddr);
|
1008 |
|
|
nextstate = MacroblockLayer 0;
|
1009 |
|
|
end
|
1010 |
|
|
else
|
1011 |
|
|
nextstate = SliceData 3;
|
1012 |
|
|
end
|
1013 |
|
|
3:
|
1014 |
|
|
begin
|
1015 |
|
|
currMbAddr <= currMbAddr+1;//only because input assumed to comform to both baseline and main
|
1016 |
|
|
if( bufcount>8 || buffer[buffersize-1]!=1 || (buffer<<1)!=0 )
|
1017 |
|
|
nextstate = SliceData 0;
|
1018 |
|
|
else
|
1019 |
|
|
nextstate = Start;
|
1020 |
|
|
end
|
1021 |
|
|
default: $display( "ERROR EntropyDec: SliceData default step" );
|
1022 |
|
|
endcase
|
1023 |
|
|
end
|
1024 |
|
|
tagged MacroblockLayer .step : //return to SliceData 3
|
1025 |
|
|
begin
|
1026 |
|
|
case ( step )
|
1027 |
|
|
0:
|
1028 |
|
|
begin
|
1029 |
|
|
$display( "ccl2SDMmb_type %0d", expgolomb_unsigned(buffer) );
|
1030 |
|
|
outfifo.enq(SDMmbtype mbtype_convert(truncate(expgolomb_unsigned(buffer)), shslice_type) );
|
1031 |
|
|
outfifo_ITB.enq(SDMmbtype mbtype_convert(truncate(expgolomb_unsigned(buffer)), shslice_type) );
|
1032 |
|
|
sdmmbtype <= mbtype_convert(truncate(expgolomb_unsigned(buffer)), shslice_type);
|
1033 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1034 |
|
|
if(mbtype_convert(truncate(expgolomb_unsigned(buffer)), shslice_type) == I_PCM)
|
1035 |
|
|
begin
|
1036 |
|
|
calcnc.nNupdate_ipcm();
|
1037 |
|
|
nextstate = MacroblockLayer 1;
|
1038 |
|
|
end
|
1039 |
|
|
else
|
1040 |
|
|
nextstate = MacroblockLayer 4;
|
1041 |
|
|
end
|
1042 |
|
|
1:
|
1043 |
|
|
begin
|
1044 |
|
|
tempreg <= 256;
|
1045 |
|
|
numbitsused = zeroExtend(bufcount[2:0]);
|
1046 |
|
|
nextstate = MacroblockLayer 2;
|
1047 |
|
|
end
|
1048 |
|
|
2:
|
1049 |
|
|
begin
|
1050 |
|
|
if( tempreg>0 )
|
1051 |
|
|
begin
|
1052 |
|
|
Bit#(8) outputdata = buffer[buffersize-1:buffersize-8];
|
1053 |
|
|
$display( "ccl2SDMpcm_sample_luma %0d", outputdata );
|
1054 |
|
|
outfifo.enq(SDMpcm_sample_luma outputdata);
|
1055 |
|
|
tempreg <= tempreg-1;
|
1056 |
|
|
numbitsused = 8;
|
1057 |
|
|
nextstate = MacroblockLayer 2;
|
1058 |
|
|
end
|
1059 |
|
|
else
|
1060 |
|
|
begin
|
1061 |
|
|
tempreg <= 128;
|
1062 |
|
|
nextstate = MacroblockLayer 3;
|
1063 |
|
|
end
|
1064 |
|
|
end
|
1065 |
|
|
3:
|
1066 |
|
|
begin
|
1067 |
|
|
if( tempreg>0 )
|
1068 |
|
|
begin
|
1069 |
|
|
Bit#(8) outputdata = buffer[buffersize-1:buffersize-8];
|
1070 |
|
|
$display( "ccl2SDMpcm_sample_chroma %0d", outputdata );
|
1071 |
|
|
outfifo.enq(SDMpcm_sample_chroma outputdata);
|
1072 |
|
|
tempreg <= tempreg-1;
|
1073 |
|
|
numbitsused = 8;
|
1074 |
|
|
nextstate = MacroblockLayer 3;
|
1075 |
|
|
end
|
1076 |
|
|
else
|
1077 |
|
|
nextstate = SliceData 3;
|
1078 |
|
|
end
|
1079 |
|
|
4:
|
1080 |
|
|
begin
|
1081 |
|
|
if(sdmmbtype != I_NxN
|
1082 |
|
|
&&& mbPartPredMode(sdmmbtype,0) != Intra_16x16
|
1083 |
|
|
&&& numMbPart(sdmmbtype) == 4)
|
1084 |
|
|
nextstate = SubMbPrediction 0;
|
1085 |
|
|
else
|
1086 |
|
|
nextstate = MbPrediction 0;
|
1087 |
|
|
end
|
1088 |
|
|
5:
|
1089 |
|
|
begin
|
1090 |
|
|
if(mbPartPredMode(sdmmbtype,0) != Intra_16x16)
|
1091 |
|
|
begin
|
1092 |
|
|
$display( "ccl2SDMcoded_block_pattern %0d", expgolomb_coded_block_pattern(buffer,sdmmbtype) );
|
1093 |
|
|
////outfifo.enq(SDMcoded_block_pattern expgolomb_coded_block_pattern(buffer,sdmmbtype));
|
1094 |
|
|
sdmcodedBlockPatternLuma <= expgolomb_coded_block_pattern(buffer,sdmmbtype)[3:0];
|
1095 |
|
|
sdmcodedBlockPatternChroma <= expgolomb_coded_block_pattern(buffer,sdmmbtype)[5:4];
|
1096 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1097 |
|
|
end
|
1098 |
|
|
else
|
1099 |
|
|
begin
|
1100 |
|
|
if(sdmmbtype matches tagged I_16x16 {intra16x16PredMode:.tempv1, codedBlockPatternChroma:.tempv2, codedBlockPatternLuma:.tempv3})
|
1101 |
|
|
begin
|
1102 |
|
|
sdmcodedBlockPatternLuma <= {tempv3,tempv3,tempv3,tempv3};
|
1103 |
|
|
sdmcodedBlockPatternChroma <= tempv2;
|
1104 |
|
|
end
|
1105 |
|
|
else
|
1106 |
|
|
$display( "ERROR EntropyDec: MacroblockLayer 5 sdmmbtype not I_16x16" );
|
1107 |
|
|
end
|
1108 |
|
|
nextstate = MacroblockLayer 6;
|
1109 |
|
|
end
|
1110 |
|
|
6:
|
1111 |
|
|
begin
|
1112 |
|
|
if(sdmcodedBlockPatternLuma > 0
|
1113 |
|
|
|| sdmcodedBlockPatternChroma > 0
|
1114 |
|
|
|| mbPartPredMode(sdmmbtype,0) == Intra_16x16)
|
1115 |
|
|
begin
|
1116 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1117 |
|
|
$display( "ccl2SDMmb_qp_delta %0d", tempint );
|
1118 |
|
|
outfifo_ITB.enq(SDMmb_qp_delta truncate(expgolomb_signed(buffer)));
|
1119 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1120 |
|
|
nextstate = Residual 0;
|
1121 |
|
|
end
|
1122 |
|
|
else
|
1123 |
|
|
nextstate = Residual 0;
|
1124 |
|
|
end
|
1125 |
|
|
default: $display( "ERROR EntropyDec: MacroblockLayer default step" );
|
1126 |
|
|
endcase
|
1127 |
|
|
end
|
1128 |
|
|
tagged MbPrediction .step : //return to MacroblockLayer 5
|
1129 |
|
|
begin
|
1130 |
|
|
case ( step )
|
1131 |
|
|
0:
|
1132 |
|
|
begin
|
1133 |
|
|
if(mbPartPredMode(sdmmbtype,0) == Intra_16x16)
|
1134 |
|
|
begin
|
1135 |
|
|
$display( "ccl2SDMMintra_chroma_pred_mode %0d", expgolomb_unsigned(buffer) );
|
1136 |
|
|
outfifo.enq(SDMMintra_chroma_pred_mode truncate(expgolomb_unsigned(buffer)));
|
1137 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1138 |
|
|
nextstate = MacroblockLayer 5;
|
1139 |
|
|
end
|
1140 |
|
|
else if(mbPartPredMode(sdmmbtype,0) == Intra_4x4)
|
1141 |
|
|
begin
|
1142 |
|
|
temp5bit <= 16;
|
1143 |
|
|
nextstate = MbPrediction 1;
|
1144 |
|
|
end
|
1145 |
|
|
else if(num_ref_idx_l0_active_minus1 > 0)
|
1146 |
|
|
begin
|
1147 |
|
|
temp3bit0 <= numMbPart(sdmmbtype);
|
1148 |
|
|
nextstate = MbPrediction 2;
|
1149 |
|
|
end
|
1150 |
|
|
else
|
1151 |
|
|
begin
|
1152 |
|
|
temp3bit0 <= numMbPart(sdmmbtype);
|
1153 |
|
|
nextstate = MbPrediction 3;
|
1154 |
|
|
end
|
1155 |
|
|
end
|
1156 |
|
|
1:
|
1157 |
|
|
begin
|
1158 |
|
|
if(temp5bit == 0)
|
1159 |
|
|
begin
|
1160 |
|
|
$display( "ccl2SDMMintra_chroma_pred_mode %0d", expgolomb_unsigned(buffer) );
|
1161 |
|
|
outfifo.enq(SDMMintra_chroma_pred_mode truncate(expgolomb_unsigned(buffer)));
|
1162 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1163 |
|
|
nextstate = MacroblockLayer 5;
|
1164 |
|
|
end
|
1165 |
|
|
else
|
1166 |
|
|
begin
|
1167 |
|
|
////$display( "ccl2SDMMprev_intra4x4_pred_mode_flag %0d", buffer[buffersize-1] );
|
1168 |
|
|
if(buffer[buffersize-1] == 0)
|
1169 |
|
|
begin
|
1170 |
|
|
Bit#(4) tttt = buffer[buffersize-1:buffersize-4];
|
1171 |
|
|
$display( "ccl2SDMMrem_intra4x4_pred_mode %0d", tttt );
|
1172 |
|
|
outfifo.enq(SDMMrem_intra4x4_pred_mode tttt);
|
1173 |
|
|
numbitsused = 4;
|
1174 |
|
|
end
|
1175 |
|
|
else
|
1176 |
|
|
begin
|
1177 |
|
|
outfifo.enq(SDMMrem_intra4x4_pred_mode 4'b1000);
|
1178 |
|
|
numbitsused = 1;
|
1179 |
|
|
end
|
1180 |
|
|
temp5bit <= temp5bit-1;
|
1181 |
|
|
nextstate = MbPrediction 1;
|
1182 |
|
|
end
|
1183 |
|
|
end
|
1184 |
|
|
2:
|
1185 |
|
|
begin
|
1186 |
|
|
if(num_ref_idx_l0_active_minus1 == 1)
|
1187 |
|
|
begin
|
1188 |
|
|
$display( "ccl2SDMMref_idx_l0 %0d", 1-buffer[buffersize-1] );
|
1189 |
|
|
outfifo.enq(SDMMref_idx_l0 zeroExtend(1-buffer[buffersize-1]));
|
1190 |
|
|
numbitsused = 1;
|
1191 |
|
|
end
|
1192 |
|
|
else
|
1193 |
|
|
begin
|
1194 |
|
|
$display( "ccl2SDMMref_idx_l0 %0d", expgolomb_unsigned(buffer) );
|
1195 |
|
|
outfifo.enq(SDMMref_idx_l0 truncate(expgolomb_unsigned(buffer)));
|
1196 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1197 |
|
|
end
|
1198 |
|
|
if(temp3bit0 == 1)
|
1199 |
|
|
begin
|
1200 |
|
|
temp3bit0 <= numMbPart(sdmmbtype);
|
1201 |
|
|
nextstate = MbPrediction 3;
|
1202 |
|
|
end
|
1203 |
|
|
else
|
1204 |
|
|
begin
|
1205 |
|
|
temp3bit0 <= temp3bit0-1;
|
1206 |
|
|
nextstate = MbPrediction 2;
|
1207 |
|
|
end
|
1208 |
|
|
end
|
1209 |
|
|
3:
|
1210 |
|
|
begin
|
1211 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1212 |
|
|
$display( "ccl2SDMMmvd_l0 %0d", tempint );
|
1213 |
|
|
outfifo.enq(SDMMmvd_l0 truncate(expgolomb_signed(buffer)));
|
1214 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1215 |
|
|
nextstate = MbPrediction 4;
|
1216 |
|
|
end
|
1217 |
|
|
4:
|
1218 |
|
|
begin
|
1219 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1220 |
|
|
$display( "ccl2SDMMmvd_l0 %0d", tempint );
|
1221 |
|
|
outfifo.enq(SDMMmvd_l0 truncate(expgolomb_signed(buffer)));
|
1222 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1223 |
|
|
temp3bit0 <= temp3bit0-1;
|
1224 |
|
|
if(temp3bit0 == 1)
|
1225 |
|
|
nextstate = MacroblockLayer 5;
|
1226 |
|
|
else
|
1227 |
|
|
nextstate = MbPrediction 3;
|
1228 |
|
|
end
|
1229 |
|
|
default: $display( "ERROR EntropyDec: MbPrediction default step" );
|
1230 |
|
|
endcase
|
1231 |
|
|
end
|
1232 |
|
|
tagged SubMbPrediction .step : //return to MacroblockLayer 5
|
1233 |
|
|
begin
|
1234 |
|
|
case ( step )
|
1235 |
|
|
0:
|
1236 |
|
|
begin
|
1237 |
|
|
$display( "ccl2SDMSsub_mb_type %0d", expgolomb_unsigned(buffer) );
|
1238 |
|
|
outfifo.enq(SDMSsub_mb_type truncate(expgolomb_unsigned(buffer)));
|
1239 |
|
|
temp3bit0 <= numSubMbPart(truncate(expgolomb_unsigned(buffer)));
|
1240 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1241 |
|
|
nextstate = SubMbPrediction 1;
|
1242 |
|
|
end
|
1243 |
|
|
1:
|
1244 |
|
|
begin
|
1245 |
|
|
$display( "ccl2SDMSsub_mb_type %0d", expgolomb_unsigned(buffer) );
|
1246 |
|
|
outfifo.enq(SDMSsub_mb_type truncate(expgolomb_unsigned(buffer)));
|
1247 |
|
|
temp3bit1 <= numSubMbPart(truncate(expgolomb_unsigned(buffer)));
|
1248 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1249 |
|
|
nextstate = SubMbPrediction 2;
|
1250 |
|
|
end
|
1251 |
|
|
2:
|
1252 |
|
|
begin
|
1253 |
|
|
$display( "ccl2SDMSsub_mb_type %0d", expgolomb_unsigned(buffer) );
|
1254 |
|
|
outfifo.enq(SDMSsub_mb_type truncate(expgolomb_unsigned(buffer)));
|
1255 |
|
|
temp3bit2 <= numSubMbPart(truncate(expgolomb_unsigned(buffer)));
|
1256 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1257 |
|
|
nextstate = SubMbPrediction 3;
|
1258 |
|
|
end
|
1259 |
|
|
3:
|
1260 |
|
|
begin
|
1261 |
|
|
$display( "ccl2SDMSsub_mb_type %0d", expgolomb_unsigned(buffer) );
|
1262 |
|
|
outfifo.enq(SDMSsub_mb_type truncate(expgolomb_unsigned(buffer)));
|
1263 |
|
|
temp3bit3 <= numSubMbPart(truncate(expgolomb_unsigned(buffer)));
|
1264 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1265 |
|
|
if(num_ref_idx_l0_active_minus1 > 0
|
1266 |
|
|
&& sdmmbtype != P_8x8ref0)
|
1267 |
|
|
nextstate = SubMbPrediction 4;
|
1268 |
|
|
else
|
1269 |
|
|
nextstate = SubMbPrediction 8;
|
1270 |
|
|
end
|
1271 |
|
|
4:
|
1272 |
|
|
begin
|
1273 |
|
|
if(num_ref_idx_l0_active_minus1 == 1)
|
1274 |
|
|
begin
|
1275 |
|
|
$display( "ccl2SDMSref_idx_l0 %0d", 1-buffer[buffersize-1] );
|
1276 |
|
|
outfifo.enq(SDMSref_idx_l0 zeroExtend(1-buffer[buffersize-1]));
|
1277 |
|
|
numbitsused = 1;
|
1278 |
|
|
end
|
1279 |
|
|
else
|
1280 |
|
|
begin
|
1281 |
|
|
$display( "ccl2SDMSref_idx_l0 %0d", expgolomb_unsigned(buffer) );
|
1282 |
|
|
outfifo.enq(SDMSref_idx_l0 truncate(expgolomb_unsigned(buffer)));
|
1283 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1284 |
|
|
end
|
1285 |
|
|
nextstate = SubMbPrediction 5;
|
1286 |
|
|
end
|
1287 |
|
|
5:
|
1288 |
|
|
begin
|
1289 |
|
|
if(num_ref_idx_l0_active_minus1 == 1)
|
1290 |
|
|
begin
|
1291 |
|
|
$display( "ccl2SDMSref_idx_l0 %0d", 1-buffer[buffersize-1] );
|
1292 |
|
|
outfifo.enq(SDMSref_idx_l0 zeroExtend(1-buffer[buffersize-1]));
|
1293 |
|
|
numbitsused = 1;
|
1294 |
|
|
end
|
1295 |
|
|
else
|
1296 |
|
|
begin
|
1297 |
|
|
$display( "ccl2SDMSref_idx_l0 %0d", expgolomb_unsigned(buffer) );
|
1298 |
|
|
outfifo.enq(SDMSref_idx_l0 truncate(expgolomb_unsigned(buffer)));
|
1299 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1300 |
|
|
end
|
1301 |
|
|
nextstate = SubMbPrediction 6;
|
1302 |
|
|
end
|
1303 |
|
|
6:
|
1304 |
|
|
begin
|
1305 |
|
|
if(num_ref_idx_l0_active_minus1 == 1)
|
1306 |
|
|
begin
|
1307 |
|
|
$display( "ccl2SDMSref_idx_l0 %0d", 1-buffer[buffersize-1] );
|
1308 |
|
|
outfifo.enq(SDMSref_idx_l0 zeroExtend(1-buffer[buffersize-1]));
|
1309 |
|
|
numbitsused = 1;
|
1310 |
|
|
end
|
1311 |
|
|
else
|
1312 |
|
|
begin
|
1313 |
|
|
$display( "ccl2SDMSref_idx_l0 %0d", expgolomb_unsigned(buffer) );
|
1314 |
|
|
outfifo.enq(SDMSref_idx_l0 truncate(expgolomb_unsigned(buffer)));
|
1315 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1316 |
|
|
end
|
1317 |
|
|
nextstate = SubMbPrediction 7;
|
1318 |
|
|
end
|
1319 |
|
|
7:
|
1320 |
|
|
begin
|
1321 |
|
|
if(num_ref_idx_l0_active_minus1 == 1)
|
1322 |
|
|
begin
|
1323 |
|
|
$display( "ccl2SDMSref_idx_l0 %0d", 1-buffer[buffersize-1] );
|
1324 |
|
|
outfifo.enq(SDMSref_idx_l0 zeroExtend(1-buffer[buffersize-1]));
|
1325 |
|
|
numbitsused = 1;
|
1326 |
|
|
end
|
1327 |
|
|
else
|
1328 |
|
|
begin
|
1329 |
|
|
$display( "ccl2SDMSref_idx_l0 %0d", expgolomb_unsigned(buffer) );
|
1330 |
|
|
outfifo.enq(SDMSref_idx_l0 truncate(expgolomb_unsigned(buffer)));
|
1331 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1332 |
|
|
end
|
1333 |
|
|
nextstate = SubMbPrediction 8;
|
1334 |
|
|
end
|
1335 |
|
|
8:
|
1336 |
|
|
begin
|
1337 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1338 |
|
|
$display( "ccl2SDMSmvd_l0 %0d", tempint );
|
1339 |
|
|
outfifo.enq(SDMSmvd_l0 truncate(expgolomb_signed(buffer)));
|
1340 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1341 |
|
|
nextstate = SubMbPrediction 9;
|
1342 |
|
|
end
|
1343 |
|
|
9:
|
1344 |
|
|
begin
|
1345 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1346 |
|
|
$display( "ccl2SDMSmvd_l0 %0d", tempint );
|
1347 |
|
|
outfifo.enq(SDMSmvd_l0 truncate(expgolomb_signed(buffer)));
|
1348 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1349 |
|
|
temp3bit0 <= temp3bit0-1;
|
1350 |
|
|
if(temp3bit0 == 1)
|
1351 |
|
|
nextstate = SubMbPrediction 10;
|
1352 |
|
|
else
|
1353 |
|
|
nextstate = SubMbPrediction 8;
|
1354 |
|
|
end
|
1355 |
|
|
10:
|
1356 |
|
|
begin
|
1357 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1358 |
|
|
$display( "ccl2SDMSmvd_l0 %0d", tempint );
|
1359 |
|
|
outfifo.enq(SDMSmvd_l0 truncate(expgolomb_signed(buffer)));
|
1360 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1361 |
|
|
nextstate = SubMbPrediction 11;
|
1362 |
|
|
end
|
1363 |
|
|
11:
|
1364 |
|
|
begin
|
1365 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1366 |
|
|
$display( "ccl2SDMSmvd_l0 %0d", tempint );
|
1367 |
|
|
outfifo.enq(SDMSmvd_l0 truncate(expgolomb_signed(buffer)));
|
1368 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1369 |
|
|
temp3bit1 <= temp3bit1-1;
|
1370 |
|
|
if(temp3bit1 == 1)
|
1371 |
|
|
nextstate = SubMbPrediction 12;
|
1372 |
|
|
else
|
1373 |
|
|
nextstate = SubMbPrediction 10;
|
1374 |
|
|
end
|
1375 |
|
|
12:
|
1376 |
|
|
begin
|
1377 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1378 |
|
|
$display( "ccl2SDMSmvd_l0 %0d", tempint );
|
1379 |
|
|
outfifo.enq(SDMSmvd_l0 truncate(expgolomb_signed(buffer)));
|
1380 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1381 |
|
|
nextstate = SubMbPrediction 13;
|
1382 |
|
|
end
|
1383 |
|
|
13:
|
1384 |
|
|
begin
|
1385 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1386 |
|
|
$display( "ccl2SDMSmvd_l0 %0d", tempint );
|
1387 |
|
|
outfifo.enq(SDMSmvd_l0 truncate(expgolomb_signed(buffer)));
|
1388 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1389 |
|
|
temp3bit2 <= temp3bit2-1;
|
1390 |
|
|
if(temp3bit2 == 1)
|
1391 |
|
|
nextstate = SubMbPrediction 14;
|
1392 |
|
|
else
|
1393 |
|
|
nextstate = SubMbPrediction 12;
|
1394 |
|
|
end
|
1395 |
|
|
14:
|
1396 |
|
|
begin
|
1397 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1398 |
|
|
$display( "ccl2SDMSmvd_l0 %0d", tempint );
|
1399 |
|
|
outfifo.enq(SDMSmvd_l0 truncate(expgolomb_signed(buffer)));
|
1400 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1401 |
|
|
nextstate = SubMbPrediction 15;
|
1402 |
|
|
end
|
1403 |
|
|
15:
|
1404 |
|
|
begin
|
1405 |
|
|
tempint = unpack(expgolomb_signed(buffer));
|
1406 |
|
|
$display( "ccl2SDMSmvd_l0 %0d", tempint );
|
1407 |
|
|
outfifo.enq(SDMSmvd_l0 truncate(expgolomb_signed(buffer)));
|
1408 |
|
|
numbitsused = expgolomb_numbits(buffer);
|
1409 |
|
|
temp3bit3 <= temp3bit3-1;
|
1410 |
|
|
if(temp3bit3 == 1)
|
1411 |
|
|
nextstate = MacroblockLayer 5;
|
1412 |
|
|
else
|
1413 |
|
|
nextstate = SubMbPrediction 14;
|
1414 |
|
|
end
|
1415 |
|
|
default: $display( "ERROR EntropyDec: SubMbPrediction default step" );
|
1416 |
|
|
endcase
|
1417 |
|
|
end
|
1418 |
|
|
tagged Residual .step : //return to SliceData 3
|
1419 |
|
|
begin
|
1420 |
|
|
case ( step )
|
1421 |
|
|
0:
|
1422 |
|
|
begin
|
1423 |
|
|
residualChroma <= 0;
|
1424 |
|
|
temp5bit <= 0;
|
1425 |
|
|
if(mbPartPredMode(sdmmbtype,0) == Intra_16x16)
|
1426 |
|
|
begin
|
1427 |
|
|
maxNumCoeff <= 16;
|
1428 |
|
|
nextstate = ResidualBlock 0;
|
1429 |
|
|
end
|
1430 |
|
|
else
|
1431 |
|
|
nextstate = Residual 1;
|
1432 |
|
|
//$display( "TRACE EntropyDec: Residual 0" );
|
1433 |
|
|
end
|
1434 |
|
|
1:
|
1435 |
|
|
begin
|
1436 |
|
|
if(temp5bit == 16)
|
1437 |
|
|
begin
|
1438 |
|
|
residualChroma <= 1;
|
1439 |
|
|
temp5bit <= 0;
|
1440 |
|
|
nextstate = Residual 3;
|
1441 |
|
|
end
|
1442 |
|
|
else
|
1443 |
|
|
begin
|
1444 |
|
|
Bit#(5) tempMaxNumCoeff = 0;
|
1445 |
|
|
if(mbPartPredMode(sdmmbtype,0) == Intra_16x16)
|
1446 |
|
|
tempMaxNumCoeff = 15;
|
1447 |
|
|
else
|
1448 |
|
|
tempMaxNumCoeff = 16;
|
1449 |
|
|
maxNumCoeff <= tempMaxNumCoeff;
|
1450 |
|
|
if((sdmcodedBlockPatternLuma & (1 << zeroExtend(temp5bit[3:2]))) == 0)
|
1451 |
|
|
begin
|
1452 |
|
|
calcnc.nNupdate_luma(truncate(temp5bit),0);
|
1453 |
|
|
////$display( "ccl2SDMRcoeffLevelZeros %0d", tempMaxNumCoeff );
|
1454 |
|
|
outfifo_ITB.enq(SDMRcoeffLevelZeros tempMaxNumCoeff);
|
1455 |
|
|
temp5bit <= temp5bit+1;
|
1456 |
|
|
nextstate = Residual 1;
|
1457 |
|
|
end
|
1458 |
|
|
else
|
1459 |
|
|
nextstate = ResidualBlock 0;
|
1460 |
|
|
end
|
1461 |
|
|
//$display( "TRACE EntropyDec: Residual 1" );
|
1462 |
|
|
end
|
1463 |
|
|
3:
|
1464 |
|
|
begin
|
1465 |
|
|
if(temp5bit == 2)
|
1466 |
|
|
begin
|
1467 |
|
|
temp5bit <= 0;
|
1468 |
|
|
nextstate = Residual 5;
|
1469 |
|
|
end
|
1470 |
|
|
else
|
1471 |
|
|
begin
|
1472 |
|
|
maxNumCoeff <= 4;
|
1473 |
|
|
if((sdmcodedBlockPatternChroma & 3) == 0)
|
1474 |
|
|
begin
|
1475 |
|
|
////$display( "ccl2SDMRcoeffLevelZeros %0d", 4 );
|
1476 |
|
|
outfifo_ITB.enq(SDMRcoeffLevelZeros 4);
|
1477 |
|
|
temp5bit <= temp5bit+1;
|
1478 |
|
|
nextstate = Residual 3;
|
1479 |
|
|
end
|
1480 |
|
|
else
|
1481 |
|
|
nextstate = ResidualBlock 0;
|
1482 |
|
|
end
|
1483 |
|
|
//$display( "TRACE EntropyDec: Residual 3" );
|
1484 |
|
|
end
|
1485 |
|
|
5:
|
1486 |
|
|
begin
|
1487 |
|
|
if(temp5bit == 8)
|
1488 |
|
|
begin
|
1489 |
|
|
temp5bit <= 0;
|
1490 |
|
|
nextstate = SliceData 3;
|
1491 |
|
|
end
|
1492 |
|
|
else
|
1493 |
|
|
begin
|
1494 |
|
|
maxNumCoeff <= 15;
|
1495 |
|
|
if((sdmcodedBlockPatternChroma & 2) == 0)
|
1496 |
|
|
begin
|
1497 |
|
|
calcnc.nNupdate_chroma(truncate(temp5bit),0);
|
1498 |
|
|
////$display( "ccl2SDMRcoeffLevelZeros %0d", 15 );
|
1499 |
|
|
outfifo_ITB.enq(SDMRcoeffLevelZeros 15);
|
1500 |
|
|
temp5bit <= temp5bit+1;
|
1501 |
|
|
nextstate = Residual 5;
|
1502 |
|
|
end
|
1503 |
|
|
else
|
1504 |
|
|
nextstate = ResidualBlock 0;
|
1505 |
|
|
end
|
1506 |
|
|
//$display( "TRACE EntropyDec: Residual 5" );
|
1507 |
|
|
end
|
1508 |
|
|
default: $display( "ERROR EntropyDec: Residual default step" );
|
1509 |
|
|
endcase
|
1510 |
|
|
end
|
1511 |
|
|
tagged ResidualBlock .step : //if(residualChroma==0) return to Residual 1; else if(maxNumCoeff==4) return to Residual 3; else return to Residual 5
|
1512 |
|
|
begin//don't modify maxNumCoeff, residualChroma, and increment temp5bit on return
|
1513 |
|
|
case ( step )
|
1514 |
|
|
0:
|
1515 |
|
|
begin
|
1516 |
|
|
cavlcFIFO.clear();
|
1517 |
|
|
if(maxNumCoeff != 4)
|
1518 |
|
|
begin
|
1519 |
|
|
if(residualChroma == 0)
|
1520 |
|
|
tempreg <= zeroExtend(calcnc.nCcalc_luma(truncate(temp5bit)));
|
1521 |
|
|
else
|
1522 |
|
|
tempreg <= zeroExtend(calcnc.nCcalc_chroma(truncate(temp5bit)));
|
1523 |
|
|
end
|
1524 |
|
|
else
|
1525 |
|
|
tempreg <= zeroExtend(6'b111111);
|
1526 |
|
|
nextstate = ResidualBlock 1;
|
1527 |
|
|
//$display( "TRACE EntropyDec: ResidualBlock 0 temp5bit = %0d", temp5bit);
|
1528 |
|
|
end
|
1529 |
|
|
1:
|
1530 |
|
|
begin
|
1531 |
|
|
Bit#(2) trailingOnesTemp = 0;
|
1532 |
|
|
Bit#(5) totalCoeffTemp = 0;
|
1533 |
|
|
{trailingOnesTemp,totalCoeffTemp,numbitsused} = cavlc_coeff_token( buffer, truncate(tempreg) );
|
1534 |
|
|
temp3bit0 <= zeroExtend(trailingOnesTemp);//trailingOnes
|
1535 |
|
|
totalCoeff <= totalCoeffTemp;
|
1536 |
|
|
if(residualChroma == 0 && !(mbPartPredMode(sdmmbtype,0)==Intra_16x16 && maxNumCoeff==16))
|
1537 |
|
|
calcnc.nNupdate_luma(truncate(temp5bit),totalCoeffTemp);
|
1538 |
|
|
else if(residualChroma == 1 && maxNumCoeff != 4)
|
1539 |
|
|
calcnc.nNupdate_chroma(truncate(temp5bit),totalCoeffTemp);
|
1540 |
|
|
temp5bit2 <= 0;//i
|
1541 |
|
|
tempreg <= 0;//levelCode temp
|
1542 |
|
|
if(totalCoeffTemp > 10 && trailingOnesTemp < 3)
|
1543 |
|
|
temp3bit1 <= 1;//suffixLength
|
1544 |
|
|
else
|
1545 |
|
|
temp3bit1 <= 0;//suffixLength
|
1546 |
|
|
nextstate = ResidualBlock 2;
|
1547 |
|
|
//$display( "TRACE EntropyDec: ResidualBlock 1 nC = %0d", tempreg);
|
1548 |
|
|
$display( "ccl2SDMRtotal_coeff %0d", totalCoeffTemp );
|
1549 |
|
|
$display( "ccl2SDMRtrailing_ones %0d", trailingOnesTemp );
|
1550 |
|
|
end
|
1551 |
|
|
2:
|
1552 |
|
|
begin
|
1553 |
|
|
if( totalCoeff != 0 )
|
1554 |
|
|
begin
|
1555 |
|
|
if(temp5bit2 < zeroExtend(temp3bit0))
|
1556 |
|
|
begin
|
1557 |
|
|
if(buffer[buffersize-1] == 1)
|
1558 |
|
|
cavlcFIFO.enq(-1);
|
1559 |
|
|
else
|
1560 |
|
|
cavlcFIFO.enq(1);
|
1561 |
|
|
numbitsused = 1;
|
1562 |
|
|
end
|
1563 |
|
|
else
|
1564 |
|
|
begin
|
1565 |
|
|
Bit#(32) buffertempshow = buffer[buffersize-1:buffersize-32];
|
1566 |
|
|
Bit#(3) suffixLength = temp3bit1;
|
1567 |
|
|
Bit#(4) levelSuffixSize = zeroExtend(suffixLength);
|
1568 |
|
|
Bit#(4) level_prefix = cavlc_level_prefix( buffer );
|
1569 |
|
|
Bit#(5) temp_level_prefix = zeroExtend(level_prefix);
|
1570 |
|
|
Bit#(28) tempbuffer = buffer[buffersize-1:buffersize-28] << zeroExtend(temp_level_prefix+1);
|
1571 |
|
|
Bit#(14) levelCode = zeroExtend(level_prefix) << zeroExtend(suffixLength);
|
1572 |
|
|
if(level_prefix == 14 && suffixLength == 0)
|
1573 |
|
|
levelSuffixSize = 4;
|
1574 |
|
|
else if(level_prefix == 15)
|
1575 |
|
|
levelSuffixSize = 12;
|
1576 |
|
|
levelCode = levelCode + zeroExtend(tempbuffer[27:16] >> (12-zeroExtend(levelSuffixSize)));//level_suffix
|
1577 |
|
|
if(level_prefix == 15 && suffixLength == 0)
|
1578 |
|
|
levelCode = levelCode + 15;
|
1579 |
|
|
if(temp5bit2 == zeroExtend(temp3bit0) && temp3bit0 < 3)
|
1580 |
|
|
levelCode = levelCode + 2;
|
1581 |
|
|
if(suffixLength == 0)
|
1582 |
|
|
suffixLength = 1;
|
1583 |
|
|
if( suffixLength < 6 && ((levelCode+2) >> 1) > (3 << zeroExtend(suffixLength-1)) )
|
1584 |
|
|
suffixLength = suffixLength+1;
|
1585 |
|
|
if(levelCode[0] == 0)
|
1586 |
|
|
cavlcFIFO.enq(truncate((levelCode+2) >> 1));
|
1587 |
|
|
else
|
1588 |
|
|
cavlcFIFO.enq(truncate((~levelCode) >> 1));
|
1589 |
|
|
if(levelCode[0] == 0)//////////////////////////////////////////////////
|
1590 |
|
|
begin
|
1591 |
|
|
tempint = signExtend(unpack((levelCode+2) >> 1));
|
1592 |
|
|
//$display( "TRACE EntropyDec: temp level %0d", tempint );
|
1593 |
|
|
end
|
1594 |
|
|
else
|
1595 |
|
|
begin
|
1596 |
|
|
Bit#(13) tempinttemp = truncate((~levelCode) >> 1);
|
1597 |
|
|
tempint = signExtend(unpack(tempinttemp));
|
1598 |
|
|
//$display( "TRACE EntropyDec: temp level %0d", tempint );
|
1599 |
|
|
end///////////////////////////////////////////////////////////////////////
|
1600 |
|
|
temp3bit1 <= suffixLength;
|
1601 |
|
|
numbitsused = zeroExtend(level_prefix)+1+zeroExtend(levelSuffixSize);
|
1602 |
|
|
end
|
1603 |
|
|
end
|
1604 |
|
|
if( totalCoeff==0 || temp5bit2+1==totalCoeff )
|
1605 |
|
|
begin
|
1606 |
|
|
temp5bit2 <= 0;
|
1607 |
|
|
zerosLeft <= 0;
|
1608 |
|
|
if(totalCoeff < maxNumCoeff)
|
1609 |
|
|
nextstate = ResidualBlock 3;
|
1610 |
|
|
else
|
1611 |
|
|
nextstate = ResidualBlock 5;
|
1612 |
|
|
end
|
1613 |
|
|
else
|
1614 |
|
|
begin
|
1615 |
|
|
temp5bit2 <= temp5bit2 + 1;
|
1616 |
|
|
nextstate = ResidualBlock 2;
|
1617 |
|
|
end
|
1618 |
|
|
end
|
1619 |
|
|
3:
|
1620 |
|
|
begin
|
1621 |
|
|
Bit#(4) tempZerosLeft;
|
1622 |
|
|
if(totalCoeff > 0)
|
1623 |
|
|
begin
|
1624 |
|
|
{tempZerosLeft,numbitsused} = cavlc_total_zeros( buffer, truncate(totalCoeff), maxNumCoeff);
|
1625 |
|
|
$display( "ccl2SDMRtotal_zeros %0d", tempZerosLeft );//////////////////////////////////////
|
1626 |
|
|
end
|
1627 |
|
|
else
|
1628 |
|
|
tempZerosLeft = 0;
|
1629 |
|
|
zerosLeft <= tempZerosLeft;
|
1630 |
|
|
if(maxNumCoeff - totalCoeff - zeroExtend(tempZerosLeft) > 0)
|
1631 |
|
|
begin
|
1632 |
|
|
$display( "ccl2SDMRcoeffLevelZeros %0d", maxNumCoeff - totalCoeff - zeroExtend(tempZerosLeft) );
|
1633 |
|
|
outfifo_ITB.enq(SDMRcoeffLevelZeros (maxNumCoeff - totalCoeff - zeroExtend(tempZerosLeft)));
|
1634 |
|
|
end
|
1635 |
|
|
nextstate = ResidualBlock 5;
|
1636 |
|
|
end
|
1637 |
|
|
5:
|
1638 |
|
|
begin
|
1639 |
|
|
if( totalCoeff > 0 )
|
1640 |
|
|
begin
|
1641 |
|
|
tempint = signExtend(unpack(cavlcFIFO.first()));
|
1642 |
|
|
$display( "ccl2SDMRcoeffLevel %0d", tempint );
|
1643 |
|
|
if( zerosLeft > 0 )
|
1644 |
|
|
begin
|
1645 |
|
|
Bit#(4) run_before = 0;
|
1646 |
|
|
if( totalCoeff > 1 )
|
1647 |
|
|
{run_before,numbitsused} = cavlc_run_before( buffer, zerosLeft);
|
1648 |
|
|
else
|
1649 |
|
|
run_before = zerosLeft;
|
1650 |
|
|
zerosLeft <= zerosLeft - run_before;
|
1651 |
|
|
outfifo_ITB.enq(SDMRcoeffLevelPlusZeros {level:cavlcFIFO.first(),zeros:zeroExtend(run_before)});
|
1652 |
|
|
if( run_before > 0 )
|
1653 |
|
|
$display( "ccl2SDMRcoeffLevelZeros %0d", run_before );
|
1654 |
|
|
end
|
1655 |
|
|
else
|
1656 |
|
|
outfifo_ITB.enq(SDMRcoeffLevelPlusZeros {level:cavlcFIFO.first(),zeros:0});
|
1657 |
|
|
cavlcFIFO.deq();
|
1658 |
|
|
totalCoeff <= totalCoeff-1;
|
1659 |
|
|
end
|
1660 |
|
|
if( totalCoeff <= 1 )
|
1661 |
|
|
begin
|
1662 |
|
|
if(!(mbPartPredMode(sdmmbtype,0)==Intra_16x16 && maxNumCoeff==16))
|
1663 |
|
|
temp5bit <= temp5bit+1;
|
1664 |
|
|
if(residualChroma==0)
|
1665 |
|
|
nextstate = Residual 1;
|
1666 |
|
|
else if(maxNumCoeff==4)
|
1667 |
|
|
nextstate = Residual 3;
|
1668 |
|
|
else
|
1669 |
|
|
nextstate = Residual 5;
|
1670 |
|
|
end
|
1671 |
|
|
else
|
1672 |
|
|
nextstate = ResidualBlock 5;
|
1673 |
|
|
end
|
1674 |
|
|
default: $display( "ERROR EntropyDec: ResidualBlock default step" );
|
1675 |
|
|
endcase
|
1676 |
|
|
end
|
1677 |
|
|
endcase
|
1678 |
|
|
|
1679 |
|
|
if(numbitsused+1 > bufcount)
|
1680 |
|
|
begin
|
1681 |
|
|
$display( "ERROR EntropyDec: not enough bits in buffer" );
|
1682 |
|
|
nextstate = Start;
|
1683 |
|
|
end
|
1684 |
|
|
buffer <= buffer << zeroExtend(numbitsused);
|
1685 |
|
|
bufcount <= bufcount-numbitsused;
|
1686 |
|
|
state <= nextstate;
|
1687 |
|
|
|
1688 |
|
|
endrule
|
1689 |
|
|
|
1690 |
|
|
|
1691 |
|
|
interface Put ioin = fifoToPut(infifo);
|
1692 |
|
|
interface Get ioout = fifoToGet(outfifo);
|
1693 |
|
|
interface Get ioout_InverseTrans = fifoToGet(outfifo_ITB);
|
1694 |
|
|
|
1695 |
|
|
interface mem_client = calcnc.mem_client;
|
1696 |
|
|
|
1697 |
|
|
endmodule
|
1698 |
|
|
|
1699 |
|
|
endpackage
|