ITU-R BT.601-4 Digital Filters This note concerns digital filters to implement the frequency response specifications of ITU-R (formerly CCIR) Rec. 601. In article , sears@netcom.com (Daniel Sears) wrote: > I'm looking for a low-pass FIR filter which satisfies the CCIR 601 > RGB/luminance template. For chrominance, I have a filter from a > BBC tech report: > > sinc(i / 2.0) * sinc(i * FT_FS) / (2 * (1 - i * i * FT_FS * FT_FS)); > > The values are summed over the width and normalized for unity gain. > > I've seen filter tap values from component data sheets, but these tend > to be just numbers, a filter of a fixed width and a certain precision: > > -0.05674, 0.01883, 1.07582, 0.01883, -0.05674 > > I'm interested in floating point, integer or multiplier-less. The filter > widths could be out to 15 or so. The principle behind the chroma equation in the BBC report -- use of a sin(x)/x function -- is appropriate for luma as well. But for a filter of limited extent, it is better to use a set of tuned coefficients than to simply truncate the sin(x)/x series. Here is a luma filter and a chroma filter. Both use eight-bit coefficients. Neither quite meets Rec. 601-4, but 601 is considered to be a little too demanding for practical needs and the filters here are a good compromise between performance and complexity. Both are FIR digital filters. Form an output sample as a weighted sum of consecutive input samples weighted by the filter coefficients -- a dot product, if you will. Note that the filters are symmetrical, so you can avoid some multiplies (or table lookups) by folding the computation around the middle (largest) coefficient. Here are the coefficients for the luma filter, scaled by 128: 1, -2, 3, -5, 6, -8, 10, -11, 12, 116, 12, -11, 10, -8, 6, -5, 3, -2, 1 Here are the chroma coefficients: -1, 3, -6, 12, -24, 80, 128, 80, -24, 12, -6, 3, -1 If you're using fixed-point arithmetic, clamp the sum to the range zero and unity (or +-unity, for the chroma filter), to avoid uncontained high-frequency components from causing your arithmetic to wrap around and cause nasty artifacts in your image. You can subsample chroma to make 4:2:2 video by omitting alternate odd-numbered samples. At the risk of stating the obvious, since the filtered samples are computed independently, you can omit not only the output samples but also their calculations. Both filters are normalized to unity: no scaling is performed in the filter itself. To make Rec. 601 4:2:2 video out of computer RGB from 0 to 255, scale luma to +219 and offset +16 [to the range [16..235]. Scale chroma to +-112 and offset +128 [to the range [16..240]. Consult my Colour FAQ for details, If you really want to make video, you should impose blanking transitions having raised-cosine shape about eight samples in extent for luma and about sixteen samples for chroma. Of the 720 "active" samples of Rec. 601, for 525/59.94 video, 712 samples should lie between the 50% points of video. For 625/50 video, 702 samples lie between the 50% points. [For the purists, the sapect ratio of the picture is defined by these 50% points of picture width.] If the image information does not lie outside the blanking limits it should be unaltered, so the recommended way to impose blanking is to apply a min/max "clamp". Here are luma clamp values with respect to a 0..219 excursion. ..., 0, 2, 22, 61, 109, 157, 196, 216, 219, ... For 625/50 video, line it up so that the 50% blanking sample "109" lies at sample number 10. At the right-hand edge of the picture, reverse the sequence and place the middle sample of the blanking transition at sample 712. For 525/59.94 video, on the left-hand edge the 50% sample lies at sample number 5 (counting 0 to 719); at the left the 50% sample should lie at sample 717. For chroma, I express the clamp with respect to 0..+112; impose a symmetrical limit on the positive and negative excursions of chroma. ..., 0, 1, 5, 12, 20, 31, 43, 56, 69, 81, 92, 100, 107, 111, 112, ... The 50% sample is value 56. You'll run out of room in 525/59.94 to apply the full chroma transition; don't worry about this. Rec. 601 reserves values 0 and 255 for sync information. You can make sure these values don't appear by extending the luma clamp sequence above by the values 1 and 254 and the chroma clamp sequence by 126. If you have complete control over both the values presented to your colour decoding matrix and the bandwidth of your original samples then your data might already be protected from excursions to 0 or 255, in which case you can omit explicit clamping. C. Charles Poynton vox: +1 416 486 3271 fax: +1 416 486 3657 poynton@poynton.com [preferred, Mac Eudora, MIME, BinHqx]