cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tgharbi2020
Contributor
Contributor
706 Views
Registered: ‎09-28-2019

Comb Filter implementation

Jump to solution

Hello,

I'm not a specialist in DSP and filter implementation.

I need to use a comb filter to separate luminance/chrominance in PAL/NTSC video signals.

Is it possible to implement a comb filter (only comb) with CIC compiler IP?

Thanks.

 

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
reaiken
Explorer
Explorer
621 Views
Registered: ‎07-18-2011

@tgharbi2020 

You don't need a FIR compiler to make a video comb filter. 

All you need to do is use BRAM FIFOs to make your 1H delay lines and shift the bits at the inputs of the adders and subtractors to do the required 1/4, 1/2, 1/4 division, this will save resources.

A shift of one bit to the right divides by 2, and a shift of two bits to the right divides by 4.  However, doing the adder that way would result in a loss of resolution, so it would be better to instead leave the two 1/4 input taps alone and shift the midpoint tap 1 bit to the left, do the sum of all three taps, and then right-shift the result by 2 bits to divide by 4 to get the output scaling correct.

Having said that, I would highly recommend you start with a simple two-line comb filter first, get that working, and then start improving it.  

A simple two-line comb implementation only requires one 1H delay line, one adder, and one subtractor.  You simply add the input and output of the 1H delay line to get luma, and subtract the output of the 1H delay from the input to get chroma.

To make a 1H delay line, you just need to make a FIFO delay line that is exactly 1 video line long at your sample rate.  For example, if you are sampling NTSC video at 4x subcarrier, or 14.318MHz, you would need a 910 clock delay, because one line of NTSC is 63.556uS long, and 63.556uS*14.318MHz = 910 samples.   You can use a line counter to control the FIFO write and read enables to get the required one-line delay, just reset the counter at the top of the field and start reading out one line after you start writing in to the FIFO.  

That's the way we used to do it in the old days of digital composite video before the advent of BT.656 13.5MHz sampling and AXI-stream video.  Nowadays, we just stick in something like an Analog Devices ADV7280 or ADV7842 and let it do all the work.

 

 

View solution in original post

0 Kudos
4 Replies
reaiken
Explorer
Explorer
642 Views
Registered: ‎07-18-2011

@tgharbi2020 

A CIC is used for efficient multirate processing of data to save resources over standard FIR filters..

By contrast, a video comb filter is made with 1H (1 horizontal line length) buffers and an adder and subtractor.    

Since the chroma in NTSC is 180 degrees out of phase from one line to the next, if you add two adjacent video lines the chroma will cancel out, leaving you with luma, and if you subtract two adjacent lines, the luma will cancel out, leaving you with chroma.

Of course, the combing all falls apart if there is a change in the luma or chroma pixel data between the adjacent lines being added and subtracted, and you end up with some chroma information in your luma or some luma information in your chroma, which is called "cross-chrominace" and "cross-luminance".     This results in "hanging dots" or a moving "rainbow" color pattern in high-frequency luma.

How this combing at the transitions is handled is what separates a broadcast-quality comb filter from a cheap TV set comb filter.  

One way to improve the comb performance is to switch to a lowpass or notch filter for the luma and a bandpass  filter for the chroma whenever a vertical transition is detected.   This will allow still images and portions of images that aren't changing to look good and maintain high resolution, while suppressing the annoying combing artifacts at transitions.

You can also use a three-line comb, where you weight the taps at 1/4, 1/2, 1/4 to get a better averaging. Really fancy comb filters use motion-adaptive circuits to further improve the combing.

 

 

 

0 Kudos
tgharbi2020
Contributor
Contributor
634 Views
Registered: ‎09-28-2019

Thanks @reaiken 

It's a detailed explanation.

What do you mean by: You can also use a three-line comb, where you weight the taps at 1/4, 1/2, 1/4 to get a better averaging.

How to implement it with FIR compiler?

0 Kudos
reaiken
Explorer
Explorer
622 Views
Registered: ‎07-18-2011

@tgharbi2020 

You don't need a FIR compiler to make a video comb filter. 

All you need to do is use BRAM FIFOs to make your 1H delay lines and shift the bits at the inputs of the adders and subtractors to do the required 1/4, 1/2, 1/4 division, this will save resources.

A shift of one bit to the right divides by 2, and a shift of two bits to the right divides by 4.  However, doing the adder that way would result in a loss of resolution, so it would be better to instead leave the two 1/4 input taps alone and shift the midpoint tap 1 bit to the left, do the sum of all three taps, and then right-shift the result by 2 bits to divide by 4 to get the output scaling correct.

Having said that, I would highly recommend you start with a simple two-line comb filter first, get that working, and then start improving it.  

A simple two-line comb implementation only requires one 1H delay line, one adder, and one subtractor.  You simply add the input and output of the 1H delay line to get luma, and subtract the output of the 1H delay from the input to get chroma.

To make a 1H delay line, you just need to make a FIFO delay line that is exactly 1 video line long at your sample rate.  For example, if you are sampling NTSC video at 4x subcarrier, or 14.318MHz, you would need a 910 clock delay, because one line of NTSC is 63.556uS long, and 63.556uS*14.318MHz = 910 samples.   You can use a line counter to control the FIFO write and read enables to get the required one-line delay, just reset the counter at the top of the field and start reading out one line after you start writing in to the FIFO.  

That's the way we used to do it in the old days of digital composite video before the advent of BT.656 13.5MHz sampling and AXI-stream video.  Nowadays, we just stick in something like an Analog Devices ADV7280 or ADV7842 and let it do all the work.

 

 

View solution in original post

0 Kudos
tgharbi2020
Contributor
Contributor
559 Views
Registered: ‎09-28-2019

Thanks @reaiken 

It helps.

0 Kudos