AN-524
VIDEO FREQUENCY – MHz
0
0.1
3.37
LOW PASS SUB-BAND
LOWEST HIGH PASS BAND
SECOND HIGH PASS SUB-BAND
THIRD HIGH PASS SUB-BAND
FOURTH HIGH PASS SUB-BAND
FIFTH HIGH PASS SUB-BAND
0.21
0.42
0.84
1.68
a
ONE TECHNOLOGY WAY • P.O. BOX 9106
ADV601 Bin Width Calculation in ADSP-21xx DSP
INTRODUCTION
This application note is for hardware and software designers integrating an Analog Devices ADSP-21xx family Digital Signal Processor (DSP) into an ADV601
design. It describes software to control video compression in the ADV601 Video Codec chip via the auxiliary
serial port. Using this note and the information in the
ADV601 Video Codec data sheet you can do the following:
Design the DSP to ADV601 interface
Program the DSP
•
NORWOOD, MASSACHUSETTS 02062-9106
by David Starr
APPLICATION NOTE
781/329-4700
•
LOW PASS SUB-BAND
LOWEST HIGH PASS BAND
SECOND HIGH PASS SUB-BAND
THIRD HIGH PASS SUB-BAND
FOURTH HIGH PASS SUB-BAND
FIFTH HIGH PASS SUB-BAND
The design examples in this application note refer to the
ADV601-based Videolab demonstration board, but you
can apply the techniques used in these examples to any
ADV601-based design. The software source code and
hardware schematics mentioned in this note are available on the Analog Devices computer products FTP site,
whose Uniform Resource Locator (URL) is:
ftp://ftp.analog.com/pub/dsp/adv601/
WHAT IS A BIN WIDTH CALCULATOR?
The ADV601 Video Codec chip has two main parts, a
Wavelet Filter Bank and a run length/Huffman encoder.
On compression (encoding) the video is transformed
into the Wavelet domain and then run length/Huffman
encoded. The Wavelet transform is analogous to the
Fourier transform. The Fourier transform is reversible
and can be, but seldom is, realized as a bank of bandpass filters. The output of each Fourier filter is often
called a “bin.” After Fourier transformation the signal is
said to be in the frequency domain. Like the Fourier
transform, the Wavelet transform is reversible. Unlike
Fourier, it is realized as a bank of band pass filters that
divides the input signal into “sub-bands.” The sub-band
width is logarithmic in frequency. The highest sub-band
contains the top half of the input signal frequency. The
next sub-band contains the middle quarter, and so on.
0
0.21
0.84
0.42
1.68
VIDEO FREQUENCY – MHz
3.37
6.75
Figure 1. ADV601 Luma Sub-Band Frequency Limits
Since Chroma is sampled at one-half the rate of Luma,
the frequency range of the chroma sub-bands is half that
of the corresponding Luma sub-bands.
Figure 2. Chroma Sub-Band Frequency Limits
AN-524
42 RECIPROCAL BIN
WIDTH REGISTERS
RAW VIDEO IN
WAVELET TRANSFORM
ADAPTIVE QUANTIZER
Figure 3. Block Diagram Encoding
RAW VIDEO
OUT
WAVELET TRANSFORM
ADAPTIVE QUANTIZER
Figure 4. Block Diagram Decoding
To reverse the Wavelet transform and recover the original signal, simply add all the sub-bands back together. If
all the bits in all the sub-bands are preserved, there is a
loss less transformation and the original signal is recovered intact. This gives about 3:1 loss less compression,
which is not really enough for many applications. The
signal in the highest frequency sub-band will contain
small amplitude wiggles that are mostly high frequency
noise and a few high amplitude spikes that represent
sharp edges in the picture.
To obtain more compression we discard low order bits
in the high frequency sub-bands. This gives longer runs
of zeros that the run length encoder converts into a very
short code. Multiplying every data point in each subband by a fraction, called the reciprocal bin width, discards the low order bits. This is the adaptive quantizer
located in between the Wavelet filter bank and the run
length/Huffman encoder. There are 42 different subbands and each one has a reciprocal bin width register,
permitting independent quantization of each sub-band.
On decode, we restore the quantized signal to its proper
amplitude by multiplying each data point by a factor
called the bin width. Again there are 42 bin width registers. The duty of the “Bin Width Calculator” program is
to set all 42 bin width and 42 reciprocal bin width register with the proper fraction to achieve the desired compression ratio.
DESIRABLE FEATURES IN A BIN WIDTH CALCULATOR
Bit Rate Depends On Video Signal
Simple video (e.g., a shot of a cloudless blue sky) has
very little high frequency detail. Every pixel is the same
(blue). The high pass sub-bands will all be zero. The run
42 BIN WIDTH
REGISTERS
COMPRESSED
RUN LENGTH &
HUFFMAN ENCODER
RUN LENGTH &
HUFFMAN ENCODER
VIDEO OUT
COMPRESSED
VIDEO IN
length encoder will efficiently convert the long runs of
zeros into a single short code group, and the image will
compress tremendously. Other video (e.g., an actor
wearing a plaid shirt) has significant high frequency detail. When the TV broadcaster cuts from simple video to
complex video, or even from one scene to another, or to
a commercial, the bit rate will change substantially unless something is done. That "something" is handled by
the Bin Width Calculator, which must respond to the
video change by altering the bin-width register settings
to achieve the desired bit rate.
Constant Bit Rate
A constant bit rate Bin Width Calculator is needed when
video must go through a fixed bit rate communications
link. If the video bit rate from the ADV601 exceeds the
communication link bit rate, video will be lost. If the bit
rate from the ADV601 is less than the communications
link can handle, the viewer at the far end of the link is not
receiving the best possible picture. A better picture
would be obtained if more bits were sent. The constant
bit rate Bin Width Calculator adjusts the bin width registers on every frame to achieve the programmed target
bit rate as closely as possible.
Constant Quality
It is also possible to create a constant quality Bin Width
Calculator. If the objective is to maximize the amount of
video stored on a hard disk, the problem is a bit less demanding. Plain and simple video that compresses well
can be allowed to do so and only the busy and complex
video needs be trimmed down to size. The savings in
disk space are worthwhile, and might permit a longer
video capture before the hard drive is filled.
–2–
AN-524
0.9
0.8
0.7
0.6
SERIES 1
SERIES 2
41
35 29 23 17 11 5 –1
SUB-BAND NUMBER
0.5
0.4
0.3
RECIPROCAL BIN WIDTH
0.2
0.1
0
Figure 5. Sub-Band Quantization vs. Frequency
The Quantizing Curve
For reasonable compression, all the wavelet sub-bands
must be quantized to some degree. Given a fixed budget
of bits to encode a field, the Bin Width Calculator must
allocate the bits to produce a pleasing picture upon reconstruction. This Bin Width Calculator favors the low
frequency sub-bands. It always increases the quantization (discards more low order bits) as the frequency increases. The eye is most critical of the low frequency
information and does not really miss the higher frequencies. Stored in the Bin Width Calculator is a set of bin
widths that preserves a maximum number of bits and
creates a high quality minimum compression image.
Also stored is a second set of bin widths that discards
most of the bits to achieve maximum compression. The
program varies the actual bit rate by interpolating an intermediate curve that lies somewhere between the two
extremes. The max and min curves used by the program
could be modified to make various trade-offs of picture
quality versus bit rate. For instance, the highest frequency Luma sub-bands contain information in the
3.37 to 6.75 Megahertz band. If the video source is
known to roll off at say 3.58 Megahertz, then signal energy in the highest frequency bin is likely to be noise. In
such a case, better performance might be obtained by
multiplying the highest frequency sub-bands by zero to
discard ALL the bits in the bin. In this way, the limited bit
budget is directed toward encoding real picture rather
than video noise (snow or on color TV, confetti) Some
experimentation with the quantizing curves may yield
worthwhile performance improvements.
DSP-Based vs. Host-Based Bin Width Calculators
The bin width calculation problem remains the same
whether the calculator is interfaced to the ADV601
through the DSP serial port or through the Host parallel
port. From the host port, a processor can access all the
registers in the ADV601. From the DSP port a processor
can only read the statistics registers and write the bin
width registers. This is a subset of all the registers in the
ADV601. This program was tested on a system with a
Pentium
®
-based PC interfaced to the host port and a
ADSP-21xx DSP interfaced to the DSP port. The DSP performed only the bin width calculation and the host did
everything else. In a stand-alone design or embedded
system, the DSP could be interfaced through the host
port and thus have access to all the other registers in the
ADV601. In a stand-alone design, the DSP must be able
to read and write to the ADV601 mode control register,
among others.
Advantages of DSP Bin Width Computation
Speed
This DSP program takes a time critical computation out
of the host. The DSP can compute new bin widths within
the 1.2 milliseconds vertical retrace time, so the bin
width settings are right up to date. This can be difficult
to achieve in the host because Windows
®
is not a realtime operating system. It makes no guarantees of response time to anything. Tasks can hog the CPU and
prevent a host-based Bin Width Calculator from running
in a timely fashion. Windows 95 interrupt handlers are
not permitted to use the hardware floating point unit.
A Windows 95 interrupt handler that relies upon Windows calls to schedule a Bin Width Calculator run as
soon as possible may find that Windows occasionally
schedules something other than the Bin Width Calculator to run next. In this case, the Bin Width Calculator
cannot compute the new bin widths before the next
frame begins.
Easier Program Development
The important Bin Width Calculator is one small program running in a dedicated CPU. If bit rate problems
are encountered, you know just where to look and the
code is small and self contained. Windows 95 device
driver and systems programming expertise is not required. Timing issues are easier to deal with because the
DSP does nothing but bin width calculation. Under Windows, if some other program has control of the machine, the Bin Width Calculator may be locked out and
unable to run in time.
Advantages of Host-Based Computations
Cost (No DSP to Buy)
Easier Program Development
Programmers may be more familiar with the host architecture and programming tools. Operating system expertise may be abundant and DSP experience may be
slim.
All trademarks are the property of their respective holders.
–3–