Recognizes if input is ogg or not.
[xiph.git] / theora-fpga / testbenchs / reconrefframes / loopfilter.vhd
blobcb9e5873cbf4469a07418633f1ab5e0e242cdfed
1 -------------------------------------------------------------------------------
2 -- Description: This file implements the loopfilter. A filter that do
3 -- a deblocking on the fragments.
4 -------------------------------------------------------------------------------
5 library std;
6 library ieee;
7 library work;
9 use ieee.std_logic_1164.all;
10 use ieee.numeric_std.all;
11 use work.all;
14 entity LoopFilter is
16 port (Clk,
17 Reset_n : in std_logic;
18 Enable : in std_logic;
20 in_request : out std_logic;
21 in_valid : in std_logic;
22 in_data : in signed(31 downto 0);
24 in_sem_request : out std_logic;
25 in_sem_valid : in std_logic;
26 in_sem_addr : out unsigned(19 downto 0);
27 in_sem_data : in signed(31 downto 0);
29 out_sem_requested : in std_logic;
30 out_sem_valid : out std_logic;
31 out_sem_addr : out unsigned(19 downto 0);
32 out_sem_data : out signed(31 downto 0);
34 out_done : out std_logic
36 end LoopFilter;
38 architecture a_LoopFilter of LoopFilter is
39 component syncram
40 generic (
41 DEPTH : positive := 64; -- How many slots
42 DATA_WIDTH : positive := 16; -- How many bits per slot
43 ADDR_WIDTH : positive := 6 -- = ceil(log2(DEPTH))
45 port (
46 clk : in std_logic;
47 wr_e : in std_logic;
48 wr_addr : in unsigned(ADDR_WIDTH-1 downto 0);
49 wr_data : in signed(DATA_WIDTH-1 downto 0);
50 rd_addr : in unsigned(ADDR_WIDTH-1 downto 0);
51 rd_data : out signed(DATA_WIDTH-1 downto 0)
53 end component;
55 component ReconPixelIndex
56 port (Clk,
57 Reset_n : in std_logic;
59 in_request : out std_logic;
60 in_valid : in std_logic;
61 in_data : in signed(31 downto 0);
63 out_requested : in std_logic;
64 out_valid : out std_logic;
65 out_data : out signed(31 downto 0)
67 end component;
69 component LFLimits
70 port (
71 parameter : in unsigned(8 downto 0);
72 FLimit : in signed(8 downto 0);
73 fbv_value : out signed(9 downto 0));
74 end component;
77 -- We are using 1024 as the maximum width and height size
78 -- = ceil(log2(Maximum Size))
79 constant LG_MAX_SIZE : natural := 10;
80 constant MEM_ADDR_WIDTH : natural := 20;
81 constant ZERO_ADDR_MEM : unsigned(LG_MAX_SIZE*2 downto 0) := "000000000000000000000";
83 -- This values must not be changed.
84 constant MEM_DATA_WIDTH : natural := 32;
86 subtype ogg_int32_t is signed(31 downto 0);
87 subtype uchar_t is unsigned (7 downto 0);
89 type mem_64_8bits_t is array (0 to 63) of uchar_t;
91 -- Fragment Parameters
92 signal HFragments : unsigned(LG_MAX_SIZE-3 downto 0);
93 signal VFragments : unsigned(LG_MAX_SIZE-3 downto 0);
94 signal YStride : unsigned(LG_MAX_SIZE+1 downto 0);
95 signal UVStride : unsigned(LG_MAX_SIZE downto 0);
96 signal YPlaneFragments : unsigned(LG_MAX_SIZE*2 downto 0);
97 signal UVPlaneFragments : unsigned(LG_MAX_SIZE*2-2 downto 0);
98 signal ReconYDataOffset : unsigned(MEM_ADDR_WIDTH-1 downto 0);
99 signal ReconUDataOffset : unsigned(MEM_ADDR_WIDTH-1 downto 0);
100 signal ReconVDataOffset : unsigned(MEM_ADDR_WIDTH-1 downto 0);
101 signal UnitFragmets : unsigned(LG_MAX_SIZE*2 downto 0);
103 -- FLimits signals
104 signal FLimit : signed(8 downto 0);
105 signal fbv_position : unsigned(8 downto 0);
106 signal fbv_value : signed(9 downto 0);
108 -- ReconPixelIndex signals and constants
109 constant RPI_DATA_WIDTH : positive := 32;
110 constant RPI_POS_WIDTH : positive := 17;
111 signal rpi_position : unsigned(RPI_POS_WIDTH-1 downto 0);
112 signal rpi_value : signed(RPI_DATA_WIDTH-1 downto 0);
114 signal s_rpi_in_request : std_logic;
115 signal s_rpi_in_valid : std_logic;
116 signal s_rpi_in_data : signed(31 downto 0);
118 signal s_rpi_out_requested : std_logic;
119 signal s_rpi_out_valid : std_logic;
120 signal s_rpi_out_data : signed(31 downto 0);
123 -- Memories
124 signal LoopFilterLimits : mem_64_8bits_t;
126 -- Process Signals
127 signal ThisFrameQualityValue : signed(31 downto 0);
129 signal QIndex : unsigned(5 downto 0);
130 signal pli : unsigned(1 downto 0);
132 signal FragsAcross : unsigned(LG_MAX_SIZE-3 downto 0);
133 signal FragsDown : unsigned(LG_MAX_SIZE-3 downto 0);
134 signal LineLength : unsigned(LG_MAX_SIZE+1 downto 0);
135 signal LineFragments : unsigned(LG_MAX_SIZE-3 downto 0);
136 signal Fragment : unsigned(LG_MAX_SIZE*2 downto 0);
137 signal dpf_position : unsigned(LG_MAX_SIZE*2 downto 0);
139 signal MaxDPFCount : unsigned(LG_MAX_SIZE*2 downto 0);
141 signal pixelPtr : unsigned(MEM_ADDR_WIDTH-1 downto 0);
142 signal DeltaHorizFilter : signed(3 downto 0);
144 signal CountFilter : unsigned(2 downto 0);
145 signal CountColumns : unsigned(2 downto 0);
147 signal disp_frag_value : std_logic;
149 signal CountMiddles : unsigned(LG_MAX_SIZE*2 downto 0);
150 signal CountMidCols : unsigned(LG_MAX_SIZE*2 downto 0);
152 -- Memories Signals
153 signal mem_rd_data : signed(31 downto 0);
154 signal mem_rd_valid : std_logic;
155 signal mem_wr_ready : std_logic;
157 -- FSMs
158 type state_t is (readIn, proc);
159 signal state : state_t;
161 type read_state_t is (stt_qTT, stt_lfLim,
162 stt_dispFrag, stt_Others,
163 stt_32bitsData);
164 signal read_state : read_state_t;
167 type proc_state_t is (stt_ReadMemory, stt_WriteMemory,
168 stt_FindQIndex, stt_CalcFLimit,
169 stt_SelectColor, stt_ApplyFilter,
170 stt_CalcDispFragPos,
171 stt_CallFilterHoriz, stt_CalcFilterHoriz,
172 stt_CallFilterVert, stt_CalcFilterVert,
173 stt_Calc_RPI_Value);
174 signal proc_state : proc_state_t;
175 signal back_proc_state : proc_state_t;
176 signal next_proc_state : proc_state_t;
178 type calc_rpi_state_t is (stt_calc_rpi1, stt_calc_rpi2);
179 signal calc_rpi_state : calc_rpi_state_t;
181 type set_bound_val_state_t is (stt_SetBVal1, stt_SetBVal2, stt_SetBVal3, stt_SetBVal4);
182 signal set_bound_val_state : set_bound_val_state_t;
184 type calc_filter_state_t is (stt_CalcFilter1, stt_CalcFilter2,
185 stt_CalcFilter3);
186 signal calc_filter_state : calc_filter_state_t;
189 type apply_filter_state_t is (stt_ApplyFilter_1, stt_ApplyFilter_2,
190 stt_ApplyFilter_3, stt_ApplyFilter_4,
191 stt_ApplyFilter_5, stt_ApplyFilter_6,
192 stt_ApplyFilter_7, stt_ApplyFilter_8,
193 stt_ApplyFilter_9, stt_ApplyFilter_10,
194 stt_ApplyFilter_11, stt_ApplyFilter_12,
195 stt_ApplyFilter_13, stt_ApplyFilter_14,
196 stt_ApplyFilter_15, stt_ApplyFilter_16,
197 stt_ApplyFilter_17, stt_ApplyFilter_18,
198 stt_ApplyFilter_19, stt_ApplyFilter_20,
199 stt_ApplyFilter_21, stt_ApplyFilter_22,
200 stt_ApplyFilter_23, stt_ApplyFilter_24,
201 stt_ApplyFilter_25, stt_ApplyFilter_26,
202 stt_ApplyFilter_27, stt_ApplyFilter_28,
203 stt_ApplyFilter_29, stt_ApplyFilter_30,
204 stt_ApplyFilter_31, stt_ApplyFilter_32,
205 stt_ApplyFilter_33, stt_ApplyFilter_34);
206 signal apply_filter_state : apply_filter_state_t;
207 signal next_apply_filter_state : apply_filter_state_t;
210 type disp_frag_state_t is (stt_DispFrag1, stt_DispFrag2,
211 stt_DispFrag3, stt_DispFrag4,
212 stt_DispFrag5, stt_DispFrag6,
213 stt_DispFrag7, stt_DispFrag8,
214 stt_DispFrag9, stt_DispFrag10,
215 stt_DispFrag11, stt_DispFrag12,
216 stt_DispFrag13, stt_DispFrag14,
217 stt_DispFrag15, stt_DispFrag16,
218 stt_DispFrag17, stt_DispFrag18,
219 stt_DispFrag19, stt_DispFrag20,
220 stt_DispFrag21, stt_DispFrag22);
222 signal disp_frag_state : disp_frag_state_t;
223 signal next_disp_frag_state : disp_frag_state_t;
225 type calc_disp_frag_state_t is (stt_CalcDispFrag1,
226 stt_CalcDispFrag2,
227 stt_CalcDispFrag3);
228 signal calc_disp_frag_state : calc_disp_frag_state_t;
230 -- Handshake
231 signal count : integer range 0 to 2097151;
233 signal s_in_request : std_logic;
235 signal s_in_sem_request : std_logic;
236 signal s_out_sem_valid : std_logic;
237 signal s_out_done : std_logic;
239 signal lfr_OffSet : unsigned(MEM_ADDR_WIDTH-1 downto 0);
241 constant NULL_24bits : signed(23 downto 0) := "000000000000000000000000";
242 constant NULL_32bits : signed(31 downto 0) := x"00000000";
243 constant MAX_32bits : signed(31 downto 0) := x"11111111";
245 constant QTT_DEPTH : positive := 64;
246 constant QTT_DATA_WIDTH : positive := 32;
247 constant QTT_ADDR_WIDTH : positive := 6;
249 constant DPF_DEPTH : positive := 57;
250 constant DPF_DATA_WIDTH : positive := 32;
251 constant DPF_ADDR_WIDTH : positive := 6;
253 -- Memories
254 signal qtt_wr_e : std_logic;
255 signal qtt_wr_addr : unsigned(QTT_ADDR_WIDTH-1 downto 0);
256 signal qtt_wr_data : signed(QTT_DATA_WIDTH-1 downto 0);
257 signal qtt_rd_addr : unsigned(QTT_ADDR_WIDTH-1 downto 0);
258 signal qtt_rd_data : signed(QTT_DATA_WIDTH-1 downto 0);
260 type mem4bytes_t is array (0 to 3) of uchar_t;
261 signal Pixel : mem4bytes_t;
262 type lfr_array_2_t is array (0 to 1) of ogg_int32_t;
263 signal lfr_datas : lfr_array_2_t;
264 type lfr_pos_pixels_t is array (0 to 1) of unsigned(1 downto 0);
265 signal lfr_pos_pixels : lfr_pos_pixels_t;
267 signal dpf_wr_e : std_logic;
268 signal dpf_wr_addr : unsigned(DPF_ADDR_WIDTH-1 downto 0);
269 signal dpf_wr_data : signed(DPF_DATA_WIDTH-1 downto 0);
270 signal dpf_rd_addr : unsigned(DPF_ADDR_WIDTH-1 downto 0);
271 signal dpf_rd_data : signed(DPF_DATA_WIDTH-1 downto 0);
274 -- signal T_Pixel1 : ogg_int32_t;
275 -- signal T_Pixel2 : ogg_int32_t;
277 -- signal applyfilter_states : integer;
278 -- signal dispfragstates_states : integer;
281 begin -- a_LoopFilter
283 in_request <= s_in_request;
284 in_sem_request <= s_in_sem_request;
285 out_sem_valid <= s_out_sem_valid;
286 out_done <= s_out_done;
288 mem_64_int32: syncram
289 generic map (QTT_DEPTH, QTT_DATA_WIDTH, QTT_ADDR_WIDTH)
290 port map (clk, qtt_wr_e, qtt_wr_addr, qtt_wr_data, qtt_rd_addr, qtt_rd_data);
292 mem_512_int32_1: syncram
293 generic map (DPF_DEPTH, DPF_DATA_WIDTH, DPF_ADDR_WIDTH)
294 port map (clk, dpf_wr_e, dpf_wr_addr, dpf_wr_data, dpf_rd_addr, dpf_rd_data);
296 lflimits0: lflimits
297 port map (fbv_position, FLimit, fbv_value);
299 rpi0: reconpixelindex
300 port map (Clk => Clk,
301 Reset_n => Reset_n,
302 in_request => s_rpi_out_requested,
303 in_valid => s_rpi_out_valid,
304 in_data => s_rpi_out_data,
306 out_requested => s_rpi_in_request,
307 out_valid => s_rpi_in_valid,
308 out_data => s_rpi_in_data);
311 RPI_HandShake: process (count, in_data, in_valid,
312 state, read_state, proc_state,
313 calc_rpi_state, rpi_position,
314 s_in_request)
315 begin -- process RPI_HandShake
316 s_rpi_out_data <= x"00000000";
317 s_rpi_out_valid <= '0';
318 if (s_in_request = '1') then
319 if (state = readIn and read_state = stt_32bitsData) then
320 if (count >=0 and count <=8) then
321 s_rpi_out_data <= in_data;
322 s_rpi_out_valid <= in_valid;
323 end if;
324 end if;
325 else
326 if (state = proc and
327 proc_state = stt_Calc_RPI_Value and
328 calc_rpi_state = stt_calc_rpi1) then
329 s_rpi_out_data <= resize(signed('0'&rpi_position), 32);
330 s_rpi_out_valid <= '1';
331 end if;
332 end if;
333 end process RPI_HandShake;
336 process (clk)
337 -------------------------------------------------------------------------------
338 -- Procedures called when state is readIn
339 -------------------------------------------------------------------------------
340 procedure Read32bitsData is
341 begin
342 -- assert false report "in_data = "&integer'image(to_integer(in_data)) severity note;
343 if (count = 0) then
344 HFragments <= unsigned(in_data(LG_MAX_SIZE-3 downto 0));
345 count <= count + 1;
346 elsif (count = 1) then
347 YPlaneFragments <= unsigned(in_data(LG_MAX_SIZE*2 downto 0));
348 count <= count + 1;
349 elsif (count = 2) then
350 YStride <= unsigned(in_data(LG_MAX_SIZE+1 downto 0));
351 count <= count + 1;
352 elsif (count = 3) then
353 UVPlaneFragments <= unsigned(in_data(LG_MAX_SIZE*2-2 downto 0));
354 count <= count + 1;
355 elsif (count = 4) then
356 UVStride <= unsigned(in_data(LG_MAX_SIZE downto 0));
357 count <= count + 1;
358 elsif (count = 5) then
359 VFragments <= unsigned(in_data(LG_MAX_SIZE-3 downto 0));
360 count <= count + 1;
361 elsif (count = 6) then
362 ReconYDataOffset <= unsigned(in_data(MEM_ADDR_WIDTH-1 downto 0));
363 count <= count + 1;
364 elsif (count = 7) then
365 ReconUDataOffset <= unsigned(in_data(MEM_ADDR_WIDTH-1 downto 0));
366 count <= count + 1;
367 elsif (count = 8) then
368 ReconVDataOffset <= unsigned(in_data(MEM_ADDR_WIDTH-1 downto 0));
369 count <= count + 1;
370 else
371 assert false report "UnitFragments = "&integer'image(to_integer(in_data)) severity note;
372 UnitFragmets <= unsigned(in_data(LG_MAX_SIZE*2 downto 0));
374 MaxDPFCount <= SHIFT_RIGHT(
375 unsigned(in_data(LG_MAX_SIZE*2 downto 0)), 5) + 1;
376 if (in_data(4 downto 0) = "00000") then
377 MaxDPFCount <= SHIFT_RIGHT(
378 unsigned(in_data(LG_MAX_SIZE*2 downto 0)), 5);
379 end if;
380 read_state <= stt_qTT;
381 count <= 0;
382 end if;
383 end procedure Read32bitsData;
385 -------------------------------------------------------------------------------
386 -- Procedure that receives the QThreashTable matrice and keep the data
387 -- in a SRAM memory
388 -------------------------------------------------------------------------------
389 procedure QThreTab is
390 begin
391 qtt_wr_e <= '1';
392 qtt_wr_data <= in_data;
393 qtt_wr_addr <= qtt_wr_addr + 1;
395 if (count = 0) then
396 qtt_wr_addr <= "000000";
397 count <= count + 1;
398 elsif (count = 63) then
399 read_state <= stt_lfLim;
400 count <= 0;
401 -- on next state must set qtt_wr_e to 0
402 else
403 count <= count + 1;
404 end if;
405 end procedure QThreTab;
407 -------------------------------------------------------------------------------
408 -- Procedure that receives the loop filter limits values and keep the data
409 -- in an internal memory
410 -------------------------------------------------------------------------------
411 procedure LfLim is
412 begin
413 qtt_wr_e <= '0';
415 LoopFilterLimits(count + 3) <= unsigned(in_data(7 downto 0));
416 LoopFilterLimits(count + 2) <= unsigned(in_data(15 downto 8));
417 LoopFilterLimits(count + 1) <= unsigned(in_data(23 downto 16));
418 LoopFilterLimits(count) <= unsigned(in_data(31 downto 24));
419 if(count = 60)then
420 read_state <= stt_dispFrag;
421 count <= 0;
422 else
423 count <= count + 4;
424 end if;
425 end procedure LfLim;
427 -------------------------------------------------------------------------------
428 -- Procedure that receives the display fragments matrice and keep the data
429 -- in a SRAM memory
430 -------------------------------------------------------------------------------
431 procedure DispFrag is
432 begin
433 dpf_wr_e <= '1';
434 dpf_wr_data <= in_data;
435 dpf_wr_addr <= dpf_wr_addr + 1;
436 if (count = 0) then
437 dpf_wr_addr <= "000000";
438 count <= 1;
439 elsif (count = MaxDPFCount - 1) then
440 read_state <= stt_Others;
441 count <= 0;
442 else
443 count <= count + 1;
444 end if;
445 end procedure DispFrag;
447 -------------------------------------------------------------------------------
448 -- Procedure that receives the ThisFrameQualityValue and the Last Reconstructed
449 -- Frame offset
450 -------------------------------------------------------------------------------
451 procedure ReadOthers is
452 begin
453 if (count = 0) then
454 ThisFrameQualityValue <= in_data;
455 count <= count + 1;
456 else
457 lfr_OffSet <= SHIFT_RIGHT(unsigned(in_data(MEM_ADDR_WIDTH-1 downto 0)), 2);
458 state <= proc;
459 count <= 0;
460 read_state <= stt_dispFrag;
461 proc_state <= stt_FindQIndex;
462 s_in_request <= '0';
463 QIndex <= "111111";
464 end if;
465 end procedure ReadOthers;
467 -------------------------------------------------------------------------------
468 -- Procedure that controls the read state machine
469 -------------------------------------------------------------------------------
470 procedure ReadIn is
471 begin
472 s_out_done <= '0';
473 s_in_request <= '1';
475 s_out_sem_valid <= '0';
476 s_in_sem_request <= '0';
477 if (s_in_request = '1' and in_valid = '1') then
479 case read_state is
480 when stt_qTT => QThreTab;
481 when stt_lfLim => LfLim;
482 when stt_dispFrag => DispFrag;
483 when stt_Others => ReadOthers;
484 when others => Read32bitsData;
485 end case;
486 end if;
487 end procedure ReadIn;
489 -- *****************************************************
490 -- Procedures called when state is proc
491 -- *****************************************************
493 procedure ReadMemory is
494 begin
495 -- After use the data mem_rd_valid must
496 -- be set to '0'
497 mem_rd_valid <= in_sem_valid;
498 s_in_sem_request <= '1';
499 if (s_in_sem_request = '1' and in_sem_valid = '1') then
500 mem_rd_data <= in_sem_data;
501 s_in_sem_request <= '0';
502 proc_state <= back_proc_state;
503 end if;
504 end procedure ReadMemory;
506 procedure WriteMemory is
507 begin
508 if (out_sem_requested = '1') then
509 proc_state <= back_proc_state;
510 mem_wr_ready <= '1';
511 s_out_sem_valid <= '0';
512 end if;
513 end procedure WriteMemory;
515 procedure CalcRPIValue is
516 begin
517 case calc_rpi_state is
518 when stt_calc_rpi1 =>
519 -- Wait until ReconPixelIndex can receive the data
520 if (s_rpi_out_requested = '1') then
521 calc_rpi_state <= stt_calc_rpi2;
522 end if;
525 when others =>
526 -- Wait until ReconPixelIndex returns the value
527 s_rpi_in_request <= '1';
528 if (s_rpi_in_request = '1' and s_rpi_in_valid = '1') then
529 rpi_value <= s_rpi_in_data;
530 s_rpi_in_request <= '0';
531 proc_state <= next_proc_state;
532 end if;
533 end case;
534 end procedure CalcRPIValue;
536 -------------------------------------------------------------------------------
537 -- Initialize QIndex with 63.
538 -- For each element i of qtt in decreasing order, if i >= ThisFrameQualityValue
539 -- then stop, else subtract one of the QIndex and read the i-1 element of qtt,
540 -- until QIndex = 0
541 -------------------------------------------------------------------------------
542 procedure FindQIndex is
543 begin
544 if (count = 0) then
545 qtt_rd_addr <= QIndex;
546 count <= 1;
547 elsif (count = 1) then
548 qtt_rd_addr <= QIndex - 1;
549 count <= 2;
550 else
551 if ((QIndex = "000000") or
552 (qtt_rd_data >= ThisFrameQualityValue)) then
553 proc_state <= stt_CalcFLimit;
554 count <= 0;
555 else
556 qtt_rd_addr <= QIndex - 2;
557 QIndex <= QIndex - 1;
558 count <= 2;
559 end if;
560 end if;
561 end procedure FindQIndex;
563 -------------------------------------------------------------------------------
564 -- If LoopFilterLimits[QIndex] is not zero do the loopfiltering in the frame.
565 -- The next procedure is SelectColor
566 -------------------------------------------------------------------------------
567 procedure CalcFLimit is
568 begin
569 if (LoopFilterLimits(to_integer(QIndex)) /= "00000000000000000000000000000000") then
570 proc_state <= stt_SelectColor;
571 FLimit <= '0' & signed(LoopFilterLimits(to_integer(QIndex)));
572 else
573 pli <= "00";
574 count <= 0;
575 s_out_done <= '1';
577 state <= readIn;
578 read_state <= stt_dispFrag;
579 proc_state <= stt_FindQIndex;
580 apply_filter_state <= stt_ApplyFilter_1;
581 calc_filter_state <= stt_CalcFilter1;
582 end if;
583 end procedure CalcFLimit;
585 -------------------------------------------------------------------------------
586 -- Adjust some parameters according the plane of color
587 -------------------------------------------------------------------------------
588 procedure SelectColor is
589 begin
590 if (pli = "00") then
591 FragsAcross <= HFragments;
592 LineLength <= YStride;
593 LineFragments <= HFragments;
594 FragsDown <= VFragments;
595 Fragment <= "000000000000000000000";
596 proc_state <= stt_ApplyFilter;
597 disp_frag_state <= stt_DispFrag1;
598 pli <= pli + 1;
600 elsif (pli = "01") then
602 FragsAcross <= SHIFT_RIGHT(HFragments, 1);
603 LineLength <= '0' & UVStride;
604 LineFragments <= SHIFT_RIGHT(HFragments, 1);
605 FragsDown <= SHIFT_RIGHT(VFragments, 1);
606 Fragment <= YPlaneFragments;
607 proc_state <= stt_ApplyFilter;
608 disp_frag_state <= stt_DispFrag1;
609 pli <= pli + 1;
611 elsif (pli = "10") then
613 FragsAcross <= SHIFT_RIGHT(HFragments, 1);
614 LineLength <= '0' & UVStride;
615 LineFragments <= SHIFT_RIGHT(HFragments, 1);
616 FragsDown <= SHIFT_RIGHT(VFragments, 1);
617 Fragment <= YPlaneFragments + UVPlaneFragments;
618 proc_state <= stt_ApplyFilter;
619 disp_frag_state <= stt_DispFrag1;
620 pli <= pli + 1;
621 else
622 assert false report "SelectColor 4" severity note;
623 pli <= "00";
624 count <= 0;
625 s_out_done <= '1';
627 state <= readIn;
628 read_state <= stt_dispFrag;
629 proc_state <= stt_FindQIndex;
630 apply_filter_state <= stt_ApplyFilter_1;
631 calc_filter_state <= stt_CalcFilter1;
632 end if;
633 end procedure SelectColor;
636 procedure CallFilterHoriz is
637 variable fourPixels : signed(MEM_DATA_WIDTH-1 downto 0);
638 variable memPosPixel : unsigned(1 downto 0);
639 variable numPixel : signed(RPI_DATA_WIDTH-1 downto 0);
641 begin
642 numPixel := rpi_value +
643 DeltaHorizFilter +
644 ('0' & signed(pixelPtr) + count);
645 memPosPixel := unsigned(numPixel(1 downto 0));
647 -- When use the data mem_rd_valid must
648 -- be set to '0'
649 if (mem_rd_valid = '0') then
650 s_in_sem_request <= '1';
651 in_sem_addr <= lfr_OffSet +
652 resize(
653 SHIFT_RIGHT('0' & unsigned(numPixel), 2)
654 , MEM_ADDR_WIDTH
656 back_proc_state <= stt_CallFilterHoriz;
657 proc_state <= stt_ReadMemory;
658 else
659 mem_rd_valid <= '0';
660 fourPixels := (SHIFT_RIGHT(
661 mem_rd_data,
662 24 -
663 to_integer(memPosPixel) * 8));
664 Pixel(count) <= unsigned(fourPixels(7 downto 0));
666 if (count = 1 or count = 2) then
667 -- Saves the second or third pixel data slot and
668 -- their positions in the slot
669 lfr_datas(count - 1) <= mem_rd_data;
670 lfr_pos_pixels(count - 1) <= memPosPixel;
671 end if;
672 if (count = 3) then
673 fbv_position <= resize(unsigned(
674 256 +
675 SHIFT_RIGHT(
676 ("0000" &
677 signed(Pixel(0))) -
678 (("0000" &
679 signed(Pixel(1))) * 3) +
680 (("0000" &
681 signed(Pixel(2))) * 3) -
682 ("0000" &
683 signed(fourPixels(7 downto 0))) + 4
684 , 3)), 9);
686 count <= 0;
687 proc_state <= stt_CalcFilterHoriz;
688 else
689 count <= count + 1;
690 end if;
691 end if;
692 end procedure CallFilterHoriz;
694 procedure CalcFilterHoriz is
695 variable Pixel1 : ogg_int32_t;
696 variable Pixel2 : ogg_int32_t;
697 variable newPixel : uchar_t;
699 begin
700 if (calc_filter_state = stt_CalcFilter1) then
702 Pixel1 := NULL_24bits &
703 signed(Pixel(1)) + fbv_value;
704 -- T_Pixel1 <= Pixel1;
706 out_sem_addr <= lfr_OffSet +
707 resize(
708 SHIFT_RIGHT(
709 '0' &
710 unsigned(
711 rpi_value +
712 DeltaHorizFilter +
713 ('0' & signed(pixelPtr)) + 1)
715 ), MEM_ADDR_WIDTH
718 if (Pixel1 < "00000000000000000000000000000000") then
719 newPixel := "00000000";
720 elsif (Pixel1 > "00000000000000000000000011111111") then
721 newPixel := "11111111";
722 else
723 newPixel := unsigned(Pixel1(7 downto 0));
724 end if;
726 case lfr_pos_pixels(0) is
727 when "00" =>
728 out_sem_data <= signed(newPixel) &
729 lfr_datas(0)(23 downto 0);
730 when "01" =>
731 out_sem_data <= lfr_datas(0)(31 downto 24) &
732 signed(newPixel) &
733 lfr_datas(0)(15 downto 0);
734 when "10" =>
735 out_sem_data <= lfr_datas(0)(31 downto 16) &
736 signed(newPixel) &
737 lfr_datas(0)(7 downto 0);
738 when others =>
739 out_sem_data <= lfr_datas(0)(31 downto 8) &
740 signed(newPixel);
741 end case;
743 s_out_sem_valid <= '1';
744 calc_filter_state <= stt_CalcFilter2;
745 back_proc_state <= stt_CalcFilterHoriz;
746 proc_state <= stt_WriteMemory;
748 elsif (calc_filter_state = stt_CalcFilter2) then
749 Pixel2 := NULL_24bits &
750 signed(Pixel(2)) - fbv_value;
752 -- T_Pixel2 <= Pixel2;
754 out_sem_addr <= lfr_OffSet +
755 resize(
756 SHIFT_RIGHT(
757 '0' &
758 unsigned(
759 rpi_value +
760 DeltaHorizFilter +
761 ('0' & signed(pixelPtr)) + 2)
763 ), MEM_ADDR_WIDTH
767 if (Pixel2 < "00000000000000000000000000000000") then
768 newPixel := "00000000";
769 elsif (Pixel2 > "00000000000000000000000011111111") then
770 newPixel := "11111111";
771 else
772 newPixel := unsigned(Pixel2(7 downto 0));
773 end if;
775 case lfr_pos_pixels(1) is
776 when "00" =>
777 out_sem_data <= signed(newPixel) &
778 lfr_datas(1)(23 downto 0);
779 when "01" =>
780 out_sem_data <= lfr_datas(1)(31 downto 24) &
781 signed(newPixel) &
782 lfr_datas(1)(15 downto 0);
783 when "10" =>
784 out_sem_data <= lfr_datas(1)(31 downto 16) &
785 signed(newPixel) &
786 lfr_datas(1)(7 downto 0);
787 when others =>
788 out_sem_data <= lfr_datas(1)(31 downto 8) &
789 signed(newPixel);
790 end case;
792 s_out_sem_valid <= '1';
793 calc_filter_state <= stt_CalcFilter3;
794 back_proc_state <= stt_CalcFilterHoriz;
795 proc_state <= stt_WriteMemory;
797 else
799 if (CountFilter = "111") then
800 proc_state <= stt_ApplyFilter;
801 apply_filter_state <= next_apply_filter_state; -- Next state
802 pixelPtr <= "00000000000000000000";
803 CountFilter <= "000";
804 else
805 pixelPtr <= pixelPtr + LineLength; -- Next Row
806 proc_state <= stt_CallFilterHoriz;
807 CountFilter <= CountFilter + 1;
808 end if;
809 calc_filter_state <= stt_CalcFilter1;
810 end if;
811 end procedure CalcFilterHoriz;
814 procedure CallFilterVert is
815 variable fourPixels : signed(MEM_DATA_WIDTH-1 downto 0);
816 variable memPosPixel : unsigned(1 downto 0);
817 variable numPixel : signed(RPI_DATA_WIDTH-1 downto 0);
818 variable posLine : signed(2 downto 0);
819 begin
820 if (count = 0) then
821 posLine := "110";
822 elsif (count = 1) then
823 posLine := "111";
824 elsif (count = 2) then
825 posLine := "000";
826 else
827 posLine := "001";
828 end if;
830 numPixel := rpi_value +
831 (signed('0' & LineLength)*posLine) +
832 ('0' & signed(CountColumns));
833 memPosPixel := unsigned(numPixel(1 downto 0));
835 -- When use the data mem_rd_valid must
836 -- be set to '0'
838 if (mem_rd_valid = '0') then
839 s_in_sem_request <= '1';
840 in_sem_addr <= lfr_OffSet +
841 resize(
842 SHIFT_RIGHT('0' & unsigned(numPixel), 2)
843 , MEM_ADDR_WIDTH
846 if (to_integer(lfr_OffSet +
847 resize(
848 SHIFT_RIGHT('0' & unsigned(numPixel), 2)
849 , MEM_ADDR_WIDTH
850 )) = 1530) then
851 end if;
854 back_proc_state <= stt_CallFilterVert;
855 proc_state <= stt_ReadMemory;
857 else
858 mem_rd_valid <= '0';
860 fourPixels := (SHIFT_RIGHT(
861 mem_rd_data,
862 24 -
863 to_integer(memPosPixel) * 8));
865 Pixel(count) <= unsigned(fourPixels(7 downto 0));
867 if (count = 1 or count = 2) then
868 -- Saves the second or third pixel data slot and
869 -- their positions in the slot
870 lfr_datas(count - 1) <= mem_rd_data;
871 lfr_pos_pixels(count - 1) <= memPosPixel;
872 end if;
873 if (count = 3) then
874 fbv_position <= resize(unsigned(
875 256 +
876 SHIFT_RIGHT(
877 ("0000" &
878 signed(Pixel(0))) -
879 (("0000" &
880 signed(Pixel(1))) * 3) +
881 (("0000" &
882 signed(Pixel(2))) * 3) -
883 ("0000" &
884 signed(fourPixels(7 downto 0))) + 4
885 , 3)), 9);
886 count <= 0;
887 proc_state <= stt_CalcFilterVert;
888 else
889 count <= count + 1;
890 end if;
891 end if;
892 end procedure CallFilterVert;
894 procedure CalcFilterVert is
895 variable Pixel1 : ogg_int32_t;
896 variable Pixel2 : ogg_int32_t;
897 variable newPixel : uchar_t;
899 begin
901 if (calc_filter_state = stt_CalcFilter1) then
903 Pixel1 := (NULL_24bits &
904 signed(Pixel(1))) + fbv_value;
905 -- T_Pixel1 <= Pixel1;
906 out_sem_addr <= lfr_OffSet +
907 resize(
908 SHIFT_RIGHT(
909 '0' &
910 unsigned(
911 rpi_value -
912 ('0' & signed(LineLength)) +
913 ('0' & signed(CountColumns)))
915 ), MEM_ADDR_WIDTH
918 if (Pixel1 < "00000000000000000000000000000000") then
919 newPixel := "00000000";
920 elsif (Pixel1 > "00000000000000000000000011111111") then
921 newPixel := "11111111";
922 else
923 newPixel := unsigned(Pixel1(7 downto 0));
924 end if;
926 case lfr_pos_pixels(0) is
927 when "00" =>
928 out_sem_data <= signed(newPixel) &
929 lfr_datas(0)(23 downto 0);
930 when "01" =>
931 out_sem_data <= lfr_datas(0)(31 downto 24) &
932 signed(newPixel) &
933 lfr_datas(0)(15 downto 0);
934 when "10" =>
935 out_sem_data <= lfr_datas(0)(31 downto 16) &
936 signed(newPixel) &
937 lfr_datas(0)(7 downto 0);
938 when others =>
939 out_sem_data <= lfr_datas(0)(31 downto 8) &
940 signed(newPixel);
941 end case;
943 s_out_sem_valid <= '1';
944 calc_filter_state <= stt_CalcFilter2;
945 back_proc_state <= stt_CalcFilterVert;
946 proc_state <= stt_WriteMemory;
948 elsif (calc_filter_state = stt_CalcFilter2) then
950 Pixel2 := (NULL_24bits &
951 signed(Pixel(2))) - fbv_value;
952 -- T_Pixel2 <= Pixel2;
954 out_sem_addr <= lfr_OffSet +
955 resize(
956 SHIFT_RIGHT(
957 '0' &
958 unsigned(
959 rpi_value +
960 ('0' & signed(CountColumns)))
962 ), MEM_ADDR_WIDTH
965 if (Pixel2 < "00000000000000000000000000000000") then
966 newPixel := "00000000";
967 elsif (Pixel2 > "00000000000000000000000011111111") then
968 newPixel := "11111111";
969 else
970 newPixel := unsigned(Pixel2(7 downto 0));
971 end if;
973 case lfr_pos_pixels(1) is
974 when "00" =>
975 out_sem_data <= signed(newPixel) &
976 lfr_datas(1)(23 downto 0);
977 when "01" =>
978 out_sem_data <= lfr_datas(1)(31 downto 24) &
979 signed(newPixel) &
980 lfr_datas(1)(15 downto 0);
981 when "10" =>
982 out_sem_data <= lfr_datas(1)(31 downto 16) &
983 signed(newPixel) &
984 lfr_datas(1)(7 downto 0);
985 when others =>
986 out_sem_data <= lfr_datas(1)(31 downto 8) &
987 signed(newPixel);
988 end case;
990 s_out_sem_valid <= '1';
991 calc_filter_state <= stt_CalcFilter3;
992 back_proc_state <= stt_CalcFilterVert;
993 proc_state <= stt_WriteMemory;
995 else
997 if (CountFilter = "111") then
998 proc_state <= stt_ApplyFilter;
999 apply_filter_state <= next_apply_filter_state; -- Next state
1000 CountFilter <= "000";
1001 CountColumns <= "000";
1002 else
1003 CountColumns <= CountColumns + 1;
1004 proc_state <= stt_CallFilterVert;
1005 CountFilter <= CountFilter + 1;
1006 end if;
1007 calc_filter_state <= stt_CalcFilter1;
1008 end if;
1009 end procedure CalcFilterVert;
1012 procedure CalcDispFragPos is
1013 begin
1014 if (calc_disp_frag_state = stt_CalcDispFrag1) then
1015 -- Wait display_fragments memory
1016 calc_disp_frag_state <= stt_CalcDispFrag2;
1018 else
1019 disp_frag_value <= dpf_rd_data(31 - to_integer(dpf_position(4 downto 0)));
1020 calc_disp_frag_state <= stt_CalcDispFrag1;
1021 proc_state <= stt_ApplyFilter;
1022 apply_filter_state <= next_apply_filter_state; -- Next state
1023 disp_frag_state <= next_disp_frag_state;
1024 end if;
1025 end procedure CalcDispFragPos;
1028 procedure ApplyFilter is
1029 variable NextFragment : unsigned(LG_MAX_SIZE*2 downto 0);
1030 begin
1032 if (apply_filter_state = stt_ApplyFilter_1) then
1033 -- applyfilter_states <= 1;
1034 -- ******************************************************
1035 -- First Row
1036 -- ******************************************************
1037 -- First column coditions
1038 -- only do 2 prediction if fragment coded and on non intra
1039 -- or if all fragments are intra
1040 if (disp_frag_state = stt_DispFrag1) then
1041 -- dispfragstates_states <= 1;
1042 -- dpf_rd_addr <= resize(SHIFT_RIGHT(Fragment,5), DPF_ADDR_WIDTH);
1043 dpf_rd_addr <= Fragment((4+DPF_ADDR_WIDTH) downto 5);
1044 dpf_position <= Fragment;
1045 proc_state <= stt_CalcDispFragPos;
1046 next_apply_filter_state <= stt_ApplyFilter_1;
1047 next_disp_frag_state <= stt_DispFrag2;
1048 else
1049 if (disp_frag_value = '1') then
1050 apply_filter_state <= stt_ApplyFilter_34;
1051 else
1052 apply_filter_state <= stt_ApplyFilter_3;
1053 end if;
1054 end if;
1056 elsif (apply_filter_state = stt_ApplyFilter_34) then
1057 -- applyfilter_states <= 34;
1058 -- Filter right hand border only if the block to the right
1059 -- is not coded
1060 if (disp_frag_state = stt_DispFrag2) then
1061 -- dispfragstates_states <= 2;
1062 NextFragment := Fragment + 1;
1063 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1064 dpf_position <= Fragment + 1;
1065 proc_state <= stt_CalcDispFragPos;
1066 next_apply_filter_state <= stt_ApplyFilter_34;
1067 next_disp_frag_state <= stt_DispFrag3;
1068 else
1069 if (disp_frag_value = '0') then
1070 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1071 -- Horizontal Filter Parameter
1072 DeltaHorizFilter <= x"6";
1074 -- Calculate RPI_Value before continue
1075 proc_state <= stt_Calc_RPI_Value;
1076 calc_rpi_state <= stt_calc_rpi1;
1077 -- Next state after RPI_Value calculation
1078 next_proc_state <= stt_CallFilterHoriz;
1079 next_apply_filter_state <= stt_ApplyFilter_2;
1080 else
1081 apply_filter_state <= stt_ApplyFilter_2;
1082 end if;
1083 end if;
1085 elsif (apply_filter_state = stt_ApplyFilter_2) then
1086 -- applyfilter_states <= 2;
1087 -- Bottom done if next row set
1088 if (disp_frag_state = stt_DispFrag3) then
1089 NextFragment := Fragment + LineFragments;
1090 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1091 dpf_position <= Fragment + LineFragments;
1092 proc_state <= stt_CalcDispFragPos;
1093 next_apply_filter_state <= stt_ApplyFilter_2;
1094 next_disp_frag_state <= stt_DispFrag4;
1095 else
1096 if (disp_frag_value = '0') then
1097 rpi_position <= resize(Fragment + LineFragments, RPI_POS_WIDTH);
1099 -- Calculate RPI_Value before continue
1100 proc_state <= stt_Calc_RPI_Value;
1101 calc_rpi_state <= stt_calc_rpi1;
1102 -- Next state after RPI_Value calculation
1103 next_proc_state <= stt_CallFilterVert;
1104 next_apply_filter_state <= stt_ApplyFilter_3;
1105 else
1106 apply_filter_state <= stt_ApplyFilter_3;
1107 end if;
1108 end if;
1110 elsif (apply_filter_state = stt_ApplyFilter_3) then
1111 -- applyfilter_states <= 3;
1112 Fragment <= Fragment + 1;
1113 CountMiddles <= '0' & x"00001";
1114 apply_filter_state <= stt_ApplyFilter_4;
1115 disp_frag_state <= stt_DispFrag4;
1117 elsif (apply_filter_state = stt_ApplyFilter_4) then
1119 if (CountMiddles < FragsAcross - 1) then
1121 -- Middle Columns
1123 if (disp_frag_state = stt_DispFrag4) then
1124 dpf_rd_addr <= Fragment((4+DPF_ADDR_WIDTH) downto 5);
1125 dpf_position <= Fragment;
1126 proc_state <= stt_CalcDispFragPos;
1127 next_apply_filter_state <= stt_ApplyFilter_4;
1128 next_disp_frag_state <= stt_DispFrag5;
1130 else
1132 if (disp_frag_value = '1') then
1133 -- Filter Left edge always
1134 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1135 -- Horizontal Filter Parameter
1136 DeltaHorizFilter <= x"E";
1138 -- Calculate RPI_Value before continue
1139 proc_state <= stt_Calc_RPI_Value;
1140 calc_rpi_state <= stt_calc_rpi1;
1141 -- Next state after RPI_Value calculation
1142 next_proc_state <= stt_CallFilterHoriz;
1144 next_apply_filter_state <= stt_ApplyFilter_5;
1145 else
1146 apply_filter_state <= stt_ApplyFilter_7; -- Increment CountMiddles
1147 end if;
1148 end if;
1149 else
1150 apply_filter_state <= stt_ApplyFilter_8;
1151 disp_frag_state <= stt_DispFrag7;
1152 end if;
1156 elsif (apply_filter_state = stt_ApplyFilter_5) then
1158 -- Enter here only if (CountMiddles < FragsAcross - 1) is true
1159 -- and display_fragments(Fragment) is not zero
1160 if (disp_frag_state = stt_DispFrag5) then
1161 NextFragment := Fragment + 1;
1162 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1164 dpf_position <= Fragment + 1;
1165 proc_state <= stt_CalcDispFragPos;
1166 next_apply_filter_state <= stt_ApplyFilter_5;
1167 next_disp_frag_state <= stt_DispFrag6;
1169 else
1171 if (disp_frag_value = '0') then
1173 -- Filter right hand border only if the block to the right is
1174 -- not coded
1175 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1176 -- Horizontal Filter Parameter
1177 DeltaHorizFilter <= x"6";
1179 -- Calculate RPI_Value before continue
1180 proc_state <= stt_Calc_RPI_Value;
1181 calc_rpi_state <= stt_calc_rpi1;
1182 -- Next state after RPI_Value calculation
1183 next_proc_state <= stt_CallFilterHoriz;
1184 next_apply_filter_state <= stt_ApplyFilter_6;
1186 else
1187 apply_filter_state <= stt_ApplyFilter_6;
1188 end if;
1189 end if;
1191 elsif (apply_filter_state = stt_ApplyFilter_6) then
1193 -- Enter here only if (CountMiddles < FragsAcross - 1) is true
1194 -- and display_fragments(Fragment) is not zero
1195 if (disp_frag_state = stt_DispFrag6) then
1196 NextFragment := Fragment + LineFragments;
1197 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1199 dpf_position <= Fragment + LineFragments;
1200 proc_state <= stt_CalcDispFragPos;
1201 next_apply_filter_state <= stt_ApplyFilter_6;
1202 next_disp_frag_state <= stt_DispFrag7;
1204 else
1206 if (disp_frag_value = '0') then
1208 -- Bottom done if next row set
1209 rpi_position <= resize(Fragment + LineFragments, RPI_POS_WIDTH);
1211 -- Calculate RPI_Value before continue
1212 proc_state <= stt_Calc_RPI_Value;
1213 calc_rpi_state <= stt_calc_rpi1;
1214 -- Next state after RPI_Value calculation
1215 next_proc_state <= stt_CallFilterVert;
1216 next_apply_filter_state <= stt_ApplyFilter_7;
1217 else
1218 apply_filter_state <= stt_ApplyFilter_7;
1219 end if;
1220 end if;
1222 elsif (apply_filter_state = stt_ApplyFilter_7) then
1224 CountMiddles <= CountMiddles + 1;
1225 Fragment <= Fragment + 1;
1226 apply_filter_state <= stt_ApplyFilter_4;
1227 disp_frag_state <= stt_DispFrag4;
1230 elsif (apply_filter_state = stt_ApplyFilter_8) then
1232 -- ******************************************************
1233 -- Last Column
1234 -- ******************************************************
1235 if (disp_frag_state = stt_DispFrag7) then
1236 dpf_rd_addr <= Fragment((4+DPF_ADDR_WIDTH) downto 5);
1238 dpf_position <= Fragment;
1239 proc_state <= stt_CalcDispFragPos;
1240 next_apply_filter_state <= stt_ApplyFilter_8;
1241 next_disp_frag_state <= stt_DispFrag8;
1243 else
1245 if (disp_frag_value = '1') then
1246 -- Filter Left edge always
1247 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1248 -- Horizontal Filter Parameter
1249 DeltaHorizFilter <= x"E";
1251 -- Calculate RPI_Value before continue
1252 proc_state <= stt_Calc_RPI_Value;
1253 calc_rpi_state <= stt_calc_rpi1;
1254 -- Next state after RPI_Value calculation
1255 next_proc_state <= stt_CallFilterHoriz;
1256 next_apply_filter_state <= stt_ApplyFilter_9;
1257 else
1258 apply_filter_state <= stt_ApplyFilter_10;
1259 end if;
1260 end if;
1262 elsif (apply_filter_state = stt_ApplyFilter_9) then
1264 if (disp_frag_state = stt_DispFrag8) then
1265 NextFragment := Fragment + LineFragments;
1266 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1268 dpf_position <= Fragment + LineFragments;
1269 proc_state <= stt_CalcDispFragPos;
1270 next_apply_filter_state <= stt_ApplyFilter_9;
1271 next_disp_frag_state <= stt_DispFrag9;
1273 else
1274 if (disp_frag_value = '0') then
1275 -- Bottom done if next row set
1276 rpi_position <= resize(Fragment + LineFragments, RPI_POS_WIDTH);
1278 -- Calculate RPI_Value before continue
1279 proc_state <= stt_Calc_RPI_Value;
1280 calc_rpi_state <= stt_calc_rpi1;
1281 -- Next state after RPI_Value calculation
1282 next_proc_state <= stt_CallFilterVert;
1283 next_apply_filter_state <= stt_ApplyFilter_10;
1284 else
1285 apply_filter_state <= stt_ApplyFilter_10;
1286 end if;
1287 end if;
1289 elsif (apply_filter_state = stt_ApplyFilter_10) then
1291 Fragment <= Fragment + 1;
1292 CountMiddles <= '0' & x"00001";
1293 apply_filter_state <= stt_ApplyFilter_11;
1294 disp_frag_state <= stt_DispFrag9;
1296 elsif (apply_filter_state = stt_ApplyFilter_11) then
1299 -- ******************************************************
1300 -- Middle Rows
1301 -- ******************************************************
1302 if (CountMiddles < FragsDown - 1) then
1303 -- first column conditions
1304 -- only do 2 prediction if fragment coded and on non intra or if
1305 -- all fragments are intra */
1306 if (disp_frag_state = stt_DispFrag9) then
1307 dpf_rd_addr <= Fragment((4+DPF_ADDR_WIDTH) downto 5);
1309 dpf_position <= Fragment;
1310 proc_state <= stt_CalcDispFragPos;
1311 next_apply_filter_state <= stt_ApplyFilter_11;
1312 next_disp_frag_state <= stt_DispFrag10;
1313 else
1314 if (disp_frag_value = '1') then
1315 -- TopRow is always done
1316 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1318 -- Calculate RPI_Value before continue
1319 proc_state <= stt_Calc_RPI_Value;
1320 calc_rpi_state <= stt_calc_rpi1;
1321 -- Next state after RPI_Value calculation
1322 next_proc_state <= stt_CallFilterVert;
1323 next_apply_filter_state <= stt_ApplyFilter_12;
1324 else
1325 apply_filter_state <= stt_ApplyFilter_14; -- Do middle columns
1326 end if;
1327 end if;
1328 else
1329 apply_filter_state <= stt_ApplyFilter_24; -- End "Loop"
1330 disp_frag_state <= stt_DispFrag17;
1331 end if;
1334 elsif (apply_filter_state = stt_ApplyFilter_12) then
1336 -- Enter here only if (CountMiddles < FragsDown - 1) is true
1337 -- and display_fragments(Fragment) is not zero
1338 if (disp_frag_state = stt_DispFrag10) then
1339 NextFragment := Fragment + 1;
1340 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1342 dpf_position <= Fragment + 1;
1343 proc_state <= stt_CalcDispFragPos;
1344 next_apply_filter_state <= stt_ApplyFilter_12;
1345 next_disp_frag_state <= stt_DispFrag11;
1346 else
1348 if (disp_frag_value = '0') then
1349 -- Filter right hand border only if the block to the right is
1350 -- not coded
1351 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1352 -- Horizontal Filter Parameter
1353 DeltaHorizFilter <= x"6";
1355 -- Calculate RPI_Value before continue
1356 proc_state <= stt_Calc_RPI_Value;
1357 calc_rpi_state <= stt_calc_rpi1;
1358 -- Next state after RPI_Value calculation
1359 next_proc_state <= stt_CallFilterHoriz;
1360 next_apply_filter_state <= stt_ApplyFilter_13;
1361 else
1362 apply_filter_state <= stt_ApplyFilter_13;
1363 end if;
1364 end if;
1366 elsif (apply_filter_state = stt_ApplyFilter_13) then
1368 -- Enter here only if (CountMiddles < FragsDown - 1) is true
1369 -- and display_fragments(Fragment) is not zero
1370 if (disp_frag_state = stt_DispFrag11) then
1371 NextFragment := Fragment + LineFragments;
1372 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1374 dpf_position <= Fragment + LineFragments;
1375 proc_state <= stt_CalcDispFragPos;
1376 next_apply_filter_state <= stt_ApplyFilter_13;
1377 next_disp_frag_state <= stt_DispFrag12;
1378 else
1380 if (disp_frag_value = '0') then
1381 -- Bottom done if next row set
1382 rpi_position <= resize(Fragment + LineFragments, RPI_POS_WIDTH);
1384 -- Calculate RPI_Value before continue
1385 proc_state <= stt_Calc_RPI_Value;
1386 calc_rpi_state <= stt_calc_rpi1;
1387 -- Next state after RPI_Value calculation
1388 next_proc_state <= stt_CallFilterVert;
1389 next_apply_filter_state <= stt_ApplyFilter_14;
1390 else
1391 apply_filter_state <= stt_ApplyFilter_14;
1392 end if;
1393 end if;
1396 elsif (apply_filter_state = stt_ApplyFilter_14) then
1398 Fragment <= Fragment + 1; -- Increment position
1399 CountMidCols <= '0' & x"00001"; -- Initialize Counter
1400 apply_filter_state <= stt_ApplyFilter_15;
1401 disp_frag_state <= stt_DispFrag12;
1403 elsif (apply_filter_state = stt_ApplyFilter_15) then
1405 -- ******************************************************
1406 -- Middle Columns inside Middle Rows
1407 -- ******************************************************
1408 if (CountMidCols < FragsAcross - 1) then
1410 if (disp_frag_state = stt_DispFrag12) then
1411 dpf_rd_addr <= Fragment((4+DPF_ADDR_WIDTH) downto 5);
1413 dpf_position <= Fragment;
1414 proc_state <= stt_CalcDispFragPos;
1415 next_apply_filter_state <= stt_ApplyFilter_15;
1416 next_disp_frag_state <= stt_DispFrag13;
1417 else
1418 if (disp_frag_value = '1') then
1419 -- Filter Left edge always
1420 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1421 -- Horizontal Filter Parameter
1422 DeltaHorizFilter <= x"E";
1424 -- Calculate RPI_Value before continue
1425 proc_state <= stt_Calc_RPI_Value;
1426 calc_rpi_state <= stt_calc_rpi1;
1427 -- Next state after RPI_Value calculation
1428 next_proc_state <= stt_CallFilterHoriz;
1429 next_apply_filter_state <= stt_ApplyFilter_16;
1430 else
1431 apply_filter_state <= stt_ApplyFilter_19; -- Increment CountMidCols
1432 end if;
1433 end if;
1434 else
1436 apply_filter_state <= stt_ApplyFilter_20; -- End "Loop" and
1437 -- do Last Column
1438 disp_frag_state <= stt_DispFrag15;
1439 end if;
1442 elsif (apply_filter_state = stt_ApplyFilter_16) then
1444 -- Enter here only if (CountMidCols < FragsAcross - 1) is true
1445 -- and display_fragments(Fragment) is not zero
1447 -- TopRow is always done
1448 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1450 -- Calculate RPI_Value before continue
1451 proc_state <= stt_Calc_RPI_Value;
1452 calc_rpi_state <= stt_calc_rpi1;
1453 -- Next state after RPI_Value calculation
1454 next_proc_state <= stt_CallFilterVert;
1455 next_apply_filter_state <= stt_ApplyFilter_17;
1458 elsif (apply_filter_state = stt_ApplyFilter_17) then
1460 -- Enter here only if (CountMidCols < FragsAcross - 1) is true
1461 -- and display_fragments(Fragment) is not zero
1463 -- Filter right hand border only if the block to the right
1464 -- is not coded
1465 if (disp_frag_state = stt_DispFrag13) then
1466 NextFragment := Fragment + 1;
1467 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1469 dpf_position <= Fragment + 1;
1470 proc_state <= stt_CalcDispFragPos;
1471 next_apply_filter_state <= stt_ApplyFilter_17;
1472 next_disp_frag_state <= stt_DispFrag14;
1473 else
1474 if (disp_frag_value = '0') then
1475 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1476 -- Horizontal Filter Parameter
1477 DeltaHorizFilter <= x"6";
1479 -- Calculate RPI_Value before continue
1480 proc_state <= stt_Calc_RPI_Value;
1481 calc_rpi_state <= stt_calc_rpi1;
1482 -- Next state after RPI_Value calculation
1483 next_proc_state <= stt_CallFilterHoriz;
1484 next_apply_filter_state <= stt_ApplyFilter_18;
1485 else
1486 apply_filter_state <= stt_ApplyFilter_18;
1487 end if;
1488 end if;
1490 elsif (apply_filter_state = stt_ApplyFilter_18) then
1492 -- Enter here only if (CountMidCols < FragsAcross - 1) is true
1493 -- and display_fragments(Fragment) is not zero
1495 -- Bottom done if next row set
1496 if (disp_frag_state = stt_DispFrag14) then
1497 NextFragment := Fragment + LineFragments;
1498 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1500 dpf_position <= Fragment + LineFragments;
1501 proc_state <= stt_CalcDispFragPos;
1502 next_apply_filter_state <= stt_ApplyFilter_18;
1503 next_disp_frag_state <= stt_DispFrag15;
1504 else
1505 if (disp_frag_value = '0') then
1506 rpi_position <= resize(Fragment + LineFragments, RPI_POS_WIDTH);
1508 -- Calculate RPI_Value before continue
1509 proc_state <= stt_Calc_RPI_Value;
1510 calc_rpi_state <= stt_calc_rpi1;
1511 -- Next state after RPI_Value calculation
1512 next_proc_state <= stt_CallFilterVert;
1513 next_apply_filter_state <= stt_ApplyFilter_19;
1514 else
1515 apply_filter_state <= stt_ApplyFilter_19;
1516 end if;
1517 end if;
1519 elsif (apply_filter_state = stt_ApplyFilter_19) then
1521 CountMidCols <= CountMidCols + 1;
1522 Fragment <= Fragment + 1;
1523 apply_filter_state <= stt_ApplyFilter_15;
1524 disp_frag_state <= stt_DispFrag12;
1526 elsif (apply_filter_state = stt_ApplyFilter_20) then
1528 -- Last Column
1530 if (disp_frag_state = stt_DispFrag15) then
1531 dpf_rd_addr <= Fragment((4+DPF_ADDR_WIDTH) downto 5);
1533 dpf_position <= Fragment;
1534 proc_state <= stt_CalcDispFragPos;
1535 next_apply_filter_state <= stt_ApplyFilter_20;
1536 next_disp_frag_state <= stt_DispFrag16;
1537 else
1538 if (disp_frag_value = '1') then
1539 -- Filter Left edge always
1540 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1541 -- Horizontal Filter Parameter
1542 DeltaHorizFilter <= x"E";
1544 -- Calculate RPI_Value before continue
1545 proc_state <= stt_Calc_RPI_Value;
1546 calc_rpi_state <= stt_calc_rpi1;
1547 -- Next state after RPI_Value calculation
1548 next_proc_state <= stt_CallFilterHoriz;
1549 next_apply_filter_state <= stt_ApplyFilter_21;
1550 else
1551 apply_filter_state <= stt_ApplyFilter_23;
1552 end if;
1553 end if;
1555 elsif (apply_filter_state = stt_ApplyFilter_21) then
1557 -- Enter here only if display_fragments(Fragment) not zero
1559 -- TopRow is always done
1560 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1562 -- Calculate RPI_Value before continue
1563 proc_state <= stt_Calc_RPI_Value;
1564 calc_rpi_state <= stt_calc_rpi1;
1565 -- Next state after RPI_Value calculation
1566 next_proc_state <= stt_CallFilterVert;
1567 next_apply_filter_state <= stt_ApplyFilter_22;
1570 elsif (apply_filter_state = stt_ApplyFilter_22) then
1571 -- Enter here only if display_fragments(Fragment) not zero
1574 -- Bottom done if next row set
1575 if (disp_frag_state = stt_DispFrag16) then
1576 NextFragment := Fragment + LineFragments;
1577 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1579 dpf_position <= Fragment + LineFragments;
1580 proc_state <= stt_CalcDispFragPos;
1581 next_apply_filter_state <= stt_ApplyFilter_22;
1582 next_disp_frag_state <= stt_DispFrag17;
1583 else
1585 if (disp_frag_value = '0') then
1586 rpi_position <= resize(Fragment + LineFragments, RPI_POS_WIDTH);
1588 -- Calculate RPI_Value before continue
1589 proc_state <= stt_Calc_RPI_Value;
1590 calc_rpi_state <= stt_calc_rpi1;
1591 -- Next state after RPI_Value calculation
1592 next_proc_state <= stt_CallFilterVert;
1593 next_apply_filter_state <= stt_ApplyFilter_23;
1594 else
1595 apply_filter_state <= stt_ApplyFilter_23;
1596 end if;
1597 end if;
1599 elsif (apply_filter_state = stt_ApplyFilter_23) then
1601 Fragment <= Fragment + 1;
1602 CountMiddles <= CountMiddles + 1;
1603 apply_filter_state <= stt_ApplyFilter_11;
1604 disp_frag_state <= stt_DispFrag9;
1606 elsif (apply_filter_state = stt_ApplyFilter_24) then
1608 -- ******************************************************
1609 -- Last Row
1610 -- ******************************************************
1612 -- First column conditions
1613 -- Only do 2 prediction if fragment coded and on non intra or if
1614 -- all fragments are intra */
1615 if (disp_frag_state = stt_DispFrag17) then
1616 dpf_rd_addr <= Fragment((4+DPF_ADDR_WIDTH) downto 5);
1617 dpf_position <= Fragment;
1618 proc_state <= stt_CalcDispFragPos;
1619 next_apply_filter_state <= stt_ApplyFilter_24;
1620 next_disp_frag_state <= stt_DispFrag18;
1621 else
1623 if (disp_frag_value = '1') then
1624 -- TopRow is always done
1625 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1627 -- Calculate RPI_Value before continue
1628 proc_state <= stt_Calc_RPI_Value;
1629 calc_rpi_state <= stt_calc_rpi1;
1630 -- Next state after RPI_Value calculation
1631 next_proc_state <= stt_CallFilterVert;
1632 next_apply_filter_state <= stt_ApplyFilter_25;
1633 else
1634 apply_filter_state <= stt_ApplyFilter_26;
1635 end if;
1636 end if;
1637 elsif (apply_filter_state = stt_ApplyFilter_25) then
1639 -- Enter here only if display_fragments(Fragment) is not zero
1641 -- Filter right hand border only if the block to the right
1642 -- is not coded
1643 if (disp_frag_state = stt_DispFrag18) then
1644 NextFragment := Fragment + 1;
1645 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1647 dpf_position <= Fragment + 1;
1648 proc_state <= stt_CalcDispFragPos;
1649 next_apply_filter_state <= stt_ApplyFilter_25;
1650 next_disp_frag_state <= stt_DispFrag19;
1651 else
1653 if (disp_frag_value = '0') then
1654 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1655 -- Horizontal Filter Parameter
1656 DeltaHorizFilter <= x"6";
1658 -- Calculate RPI_Value before continue
1659 proc_state <= stt_Calc_RPI_Value;
1660 calc_rpi_state <= stt_calc_rpi1;
1661 -- Next state after RPI_Value calculation
1662 next_proc_state <= stt_CallFilterHoriz;
1663 next_apply_filter_state <= stt_ApplyFilter_26;
1664 else
1665 apply_filter_state <= stt_ApplyFilter_26;
1666 end if;
1667 end if;
1669 elsif (apply_filter_state = stt_ApplyFilter_26) then
1671 Fragment <= Fragment + 1;
1672 CountMiddles <= '0' & x"00001";
1673 apply_filter_state <= stt_ApplyFilter_27;
1674 disp_frag_state <= stt_DispFrag19;
1676 elsif (apply_filter_state = stt_ApplyFilter_27) then
1678 if (CountMiddles < FragsAcross - 1) then
1679 -- Middle Columns
1680 if (disp_frag_state = stt_DispFrag19) then
1681 dpf_rd_addr <= Fragment((4+DPF_ADDR_WIDTH) downto 5);
1683 dpf_position <= Fragment;
1684 proc_state <= stt_CalcDispFragPos;
1685 next_apply_filter_state <= stt_ApplyFilter_27;
1686 next_disp_frag_state <= stt_DispFrag20;
1687 else
1688 if (disp_frag_value = '1') then
1689 -- Filter Left edge always
1690 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1691 -- Horizontal Filter Parameter
1692 DeltaHorizFilter <= x"E";
1694 -- Calculate RPI_Value before continue
1695 proc_state <= stt_Calc_RPI_Value;
1696 calc_rpi_state <= stt_calc_rpi1;
1697 -- Next state after RPI_Value calculation
1698 next_proc_state <= stt_CallFilterHoriz;
1699 next_apply_filter_state <= stt_ApplyFilter_28;
1700 else
1701 apply_filter_state <= stt_ApplyFilter_30; -- Increment CountMiddles
1702 end if;
1703 end if;
1704 else
1705 apply_filter_state <= stt_ApplyFilter_31; -- End "Loop"
1706 disp_frag_state <= stt_DispFrag21;
1707 end if;
1709 elsif (apply_filter_state = stt_ApplyFilter_28) then
1711 -- Enter here only if display_fragments(Fragment) is not zero
1713 -- TopRow is always done
1714 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1716 -- Calculate RPI_Value before continue
1717 proc_state <= stt_Calc_RPI_Value;
1718 calc_rpi_state <= stt_calc_rpi1;
1719 -- Next state after RPI_Value calculation
1720 next_proc_state <= stt_CallFilterVert;
1721 next_apply_filter_state <= stt_ApplyFilter_29;
1723 elsif (apply_filter_state = stt_ApplyFilter_29) then
1725 -- Enter here only if (CountMidCols < FragsAcross - 1) is true
1726 -- and display_fragments(Fragment) is not zero
1728 -- Filter right hand border only if the block to the right
1729 -- is not coded
1730 if (disp_frag_state = stt_DispFrag20) then
1731 NextFragment := Fragment + 1;
1732 dpf_rd_addr <= NextFragment((4+DPF_ADDR_WIDTH) downto 5);
1734 dpf_position <= Fragment + 1;
1735 proc_state <= stt_CalcDispFragPos;
1736 next_apply_filter_state <= stt_ApplyFilter_29;
1737 next_disp_frag_state <= stt_DispFrag21;
1738 else
1739 if (disp_frag_value = '0') then
1740 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1741 --Horizontal Filter Parameter
1742 DeltaHorizFilter <= x"6";
1744 -- Calculate RPI_Value before continue
1745 proc_state <= stt_Calc_RPI_Value;
1746 calc_rpi_state <= stt_calc_rpi1;
1747 -- Next state after RPI_Value calculation
1748 next_proc_state <= stt_CallFilterHoriz;
1749 next_apply_filter_state <= stt_ApplyFilter_30;
1750 else
1751 apply_filter_state <= stt_ApplyFilter_30;
1752 end if;
1753 end if;
1756 elsif (apply_filter_state = stt_ApplyFilter_30) then
1758 CountMiddles <= CountMiddles +1;
1759 Fragment <= Fragment + 1;
1760 apply_filter_state <= stt_ApplyFilter_27;
1761 disp_frag_state <= stt_DispFrag19;
1763 elsif (apply_filter_state = stt_ApplyFilter_31) then
1765 -- ******************************************************
1766 -- Last Column
1767 -- ******************************************************
1768 if (disp_frag_state = stt_DispFrag21) then
1769 dpf_rd_addr <= Fragment((4+DPF_ADDR_WIDTH) downto 5);
1771 dpf_position <= Fragment;
1772 proc_state <= stt_CalcDispFragPos;
1773 next_apply_filter_state <= stt_ApplyFilter_31;
1774 next_disp_frag_state <= stt_DispFrag22;
1775 else
1777 if (disp_frag_value = '1') then
1778 -- Filter Left edge always
1779 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1780 -- Horizontal Filter Parameter
1781 DeltaHorizFilter <= x"E";
1783 -- Calculate RPI_Value before continue
1784 proc_state <= stt_Calc_RPI_Value;
1785 calc_rpi_state <= stt_calc_rpi1;
1786 -- Next state after RPI_Value calculation
1787 next_proc_state <= stt_CallFilterHoriz;
1788 next_apply_filter_state <= stt_ApplyFilter_32;
1789 else
1790 apply_filter_state <= stt_ApplyFilter_33;
1791 end if;
1792 end if;
1794 elsif (apply_filter_state = stt_ApplyFilter_32) then
1796 -- Enter here only if display_fragments(Fragment) is not zero
1798 -- TopRow is always done
1799 rpi_position <= resize(Fragment, RPI_POS_WIDTH);
1801 -- Calculate RPI_Value before continue
1802 proc_state <= stt_Calc_RPI_Value;
1803 calc_rpi_state <= stt_calc_rpi1;
1804 -- Next state after RPI_Value calculation
1805 next_proc_state <= stt_CallFilterVert;
1806 next_apply_filter_state <= stt_ApplyFilter_33;
1809 --elsif (apply_filter_state = stt_ApplyFilter_33) then
1810 else
1812 proc_state <= stt_SelectColor;
1813 apply_filter_state <= stt_ApplyFilter_1;
1814 next_disp_frag_state <= stt_DispFrag1;
1815 end if;
1816 end procedure ApplyFilter;
1819 procedure Proc is
1820 begin
1821 case proc_state is
1822 when stt_ReadMemory => ReadMemory;
1823 when stt_WriteMemory => WriteMemory;
1824 when stt_Calc_RPI_Value => CalcRPIValue;
1825 when stt_FindQIndex => FindQIndex;
1826 when stt_CalcFLimit => CalcFLimit;
1827 when stt_SelectColor => SelectColor;
1828 when stt_ApplyFilter => ApplyFilter;
1829 when stt_CalcDispFragPos => CalcDispFragPos;
1830 when stt_CallFilterHoriz => CallFilterHoriz;
1831 when stt_CalcFilterHoriz => CalcFilterHoriz;
1832 when stt_CallFilterVert => CallFilterVert;
1833 -- when stt_CalcFilterVert = other
1834 when others => CalcFilterVert;
1835 end case;
1836 end procedure Proc;
1838 begin -- process
1841 if (clk'event and clk = '1') then
1842 if (Reset_n = '0') then
1843 state <= readIn;
1844 read_state <= stt_32bitsData;
1845 proc_state <= stt_FindQIndex;
1846 apply_filter_state <= stt_ApplyFilter_1;
1847 calc_filter_state <= stt_CalcFilter1;
1848 calc_rpi_state <= stt_calc_rpi1;
1850 s_in_request <= '0';
1851 s_in_sem_request <= '0';
1852 count <= 0;
1853 pli <= "00";
1854 s_out_sem_valid <= '0';
1855 s_out_done <= '0';
1857 mem_rd_valid <= '0';
1859 CountFilter <= "000";
1860 CountColumns <= "000";
1861 pixelPtr <= "00000000000000000000";
1863 rpi_position <= '0' & x"0000";
1864 HFragments <= x"11";
1865 VFragments <= x"00";
1866 YStride <= x"000";
1867 UVStride <= "000" & x"00";
1868 YPlaneFragments <= '0' & x"00000";
1869 UVPlaneFragments <= "000" & x"0000";
1870 ReconYDataOffset <= x"00000";
1871 ReconUDataOffset <= x"00000";
1872 ReconVDataOffset <= x"00000";
1874 -- FLimits signals initialiation
1875 fbv_position <= "000000000";
1876 FLimit <= "000000000";
1879 -- QThreshTable signal memories
1880 qtt_wr_e <= '0';
1881 qtt_wr_addr <= "000000";
1882 qtt_wr_data <= "00000000000000000000000000000000";
1883 qtt_rd_addr <= "000000";
1886 --display_fragments signal memories
1887 dpf_wr_e <= '0';
1888 dpf_wr_addr <= to_unsigned(0, DPF_ADDR_WIDTH);
1889 dpf_wr_data <= "00000000000000000000000000000000";
1890 dpf_rd_addr <= to_unsigned(0, DPF_ADDR_WIDTH);
1891 else
1892 if (Enable = '1') then
1893 case state is
1894 when readIn => ReadIn;
1895 when proc => Proc;
1896 when others => ReadIn; state <= readIn;
1897 end case;
1898 end if;
1899 end if;
1900 end if;
1901 end process;
1904 end a_LoopFilter;