Frame-Based DSP
6.1.2 What Is a Frame?
A frame is the name we will use to describe a group of consecutive samples. Some other texts may use the term “block” or “packet” instead of “frame,” but they mean essentially the same thing. In order to implement frame-based DSP, we must collect N samples, and at that point initiate the processing of the frame. See Figure 6.1 for a pictorial comparison of sample-based versus frame-based processing.
How many samples constitute a frame? While frame sizes are common where the number
Analog
Figure 6.1: A comparison of a generic sample-based (top) versus frame-based (bottom) processing system. Note that some systems may not require the input or output conversions from/to analog as shown here.
6.2. WINDSK DEMONSTRATION 123 of samples is some power of two (i.e., N = 2n), there is no particular number that must be used. The frame size is selected based on several factors such as the DSP algorithm to be used, the speed and efficiency of the ADC, the overhead required for memory transfers, other hardware limitations, and the performance of the DSP system. This last consideration is driven by the fact that whatever result is obtained by the DSP, a new “updated” result cannot be obtained any faster than it takes to sample an entire frame of data.
For example, suppose we are graphically displaying the spectrum of a signal based on the FFT of that signal. The FFT requires a frame of data to be available at one time. If we assume a sample frequency of Fs= 48 kHz (thus, Ts= 1/(48× 103) = 20.83 μs) and a frame size of 2048 samples, then the spectrum display cannot be updated any faster than 2048× 20.83 μs = 42.66 ms, which equates to 23.44 display updates per second. Around the world, standard definition television video (both older analog formats and newer digital formats) is updated either 25 or 30 frames per second, and movies in theaters are typically updated 24 frames per second, so this might be satisfactory.3 Note the implication in this example is that we now have 42.66 ms or over 12.8 million clock cycles of the OMAP-L138 Experimenter Kit to process the data! If we double the frame size, we get twice as much time to process the data, but we can only update the spectrum display half as fast, which may not be acceptable to the user. Thus, as the frame size increases we get more time to process the data, but the response time of the system output gets slower. Frame size is one of many engineering design tradeoffs that need to be made. If the system output frames are sent to the DAC, they will be converted to an analog signal on a sample-by-sample basis, at the given sample frequency Fs. For proper operation, the next frame for output must be available by the time the last sample of the current frame is converted. If, for example, we were performing audio processing, this ensures that from the listener’s perspective there would be no “gap” in the music and the output would sound no different than if sample-based processing were being used. Of course there is a time lag, or latency, equal to the frame period, but it is imperceptible to the listener.
Most real-time DSP, such as CD and DVD players, the telephone system (both land-line and wireless cellular), internet communications, and digital television (such as HDTV) implement a form of frame-based processing. For example, CD players use a data frame that is made up of six sample periods (six left channel samples, six right channel samples, alternating) [67]. Each sample is two bytes (16-bits), so the initial frame size is 24 bytes in length.4
6.2 winDSK Demonstration
Most of the functions available in winDSK are implemented as sample-based programs to keep the code simple. However, one exception is the Oscilloscope function, which must transfer information to be displayed in real-time on the video screen of the PC via the I/O port interface. Since there is significant timing overhead in both I/O port transfers and video screen rendering, frame-based processing is used. In fact, the overhead incurred just in writing to the video screen would make sample-by-sample video transfers impractical.
The actual frame size used in this part of winDSK is 512 samples per channel.
If you haven’t yet tried the Oscilloscope function of winDSK, try it now. Note that
3Various “tricks” are often used to increase the apparent screen update rate so the human visual system will not perceive a flickering image. Most television standards allow two interlaced fields per frame (although this has other drawbacks compared to progressive scan), some high-end television display units internally reformat the frame rate to a higher frequency, and movie projectors often use a light source chopper to provide the illusion of a higher frame rate.
4Additional DSP steps, including error correction and modulation, expand this to 73.5 bytes (588 bits) per frame that is actually stored on the CD.
124 CHAPTER 6. FRAME-BASED DSP
Figure 6.2: The primary user interface window for the Oscilloscope function of winDSK.
in winDSK8, the word “Oscilloscope” is abbreviated to “Oscope” to fit on the button.
The primary user interface window for this function is shown in Figure 6.2. Note that this function can provide both time domain (i.e., Oscilloscope) or frequency domain (i.e., Spectrum Analyzer) displays. In some DSP texts “time domain” is called “sample domain.”
A time domain example is shown in Figure 6.3. When the spectrum display is selected, frequency domain values are calculated by performing the FFT on each 512 sample block of data. Using the Log10 units option often provides better results for the spectrum display.
Try the “waterfall” option as well, which adds a moving time-axis to the display. A waterfall spectral display is often called a spectrogram, which may seem familiar to you if you have tried the non-real-time spectrogram function (or the related specgramdemo) in MATLAB. In winDSK, the most recent data is shown at the top of the waterfall display.5
6.3 MATLAB Implementation
Frame-based processing in MATLAB was demonstrated previously in Section 2.4.2, where frames of 500 samples each were transferred from the DSK to the PC and manipulated using MATLAB. Another MATLAB-related application where frame-based processing is typically used is Simulink, which was demonstrated in Section 2.4.1 where frames of 1024 samples each were used. In fact, for those MATLAB Toolboxes that generate code for a C6x target DSP from Simulink models, we have found that the actual code generated uses a double buffering scheme for both input and output streams, or four buffers total.
The triple-buffered frame-based approach we explain in the next section is actually a more
5In case you’re interested, this is similar to the type of readout provided by a typical sonar system on U.S. nuclear submarines.