TriMedia Lab

Problem

The NTSC (National Television Standards Committee) is a standard protocol for TV signals in the US. An NTSC TV image has 525 horizontal lines per frame, which are scanned from left to right, and from top to bottom. To reduce the amount of data that must be sent, each frame is sent and displayed in two halves, the odd lines, followed by the even lines. Each halve-frame scans in approximately 1/60 of a second, so a complete frame is scanned every 1/30 second. Such interlacing occurs so quickly that humans can't see it happening.

However, PC monitors do not perform such interlacing, instead displaying progressive pictures where each frame contains all the lines, so one must perform scan rate conversion if one wants to display a standard video signal onto a PC monitor. In order to display an NTSC picture on the PC monitor, first the picture must be de-interlaced.

The algorithm that you will be using to de-interlace the picture so it can be displayed on the monitor is the median filter algorithm. In this algorithm, pixels in the missing lines are filled in by taking the median of two pixels from the neighboring lines in the current field and one pixel from the same vertical position from the previous frame.

A simple median filter algorithm is given to you to begin with in the file median.c below. The simple algorithm generates the correct output, but is too slow, and so doesn't display the picture properly. This is an example of a real-time algorithm. You need to be optimize the algorithm to display fast enough. Your job will be to optimize this function for the TriMedia (www.trimedia.com) processor so that an interlaced picture from a DVD player can be displayed on the PC monitor correctly. You'll be using the TriMedia development tools, and testing your algorithms on a real TriMedia processor. Details of the TriMedia environment will be given in lab.

The algorithm is an example of media processing, a class of applications becoming extremely common with the growth of audio and video business and consumer electronics applications. Special microprocessors, known as media processors , have evolved to meet the unique needs of media processing, which different from general-purpose PC processing needs. Among other things, media processors contain special hardware to perform common media processing operations much more quickly. These sped-up operations can be accessed by C-level library calls. Trimedia, a spinoff of Philips, licenses one of the most popular such media processors.

Assignment

In this lab you will need to modify the median.c file to run faster. The function that you will need to modify in median.c is as follows:

      void median_filter(pixel_t* input, pixel* prev_input, 
                         pixel_t* output, const int pixelsPerLine,
			 const int linesPerField, const int field)  
   

The arguments are as follows:

Some of the things you should consider while optimizing the medain_filter algorithims is as follows:

Setup

In order to use the TriMedia tools

Simulation

All of the necessary files are stored in ooti.tar.gz Unzip and untar this file. In order to simulate, you must run the file make.2.bat located within the Src directory. This will generate a file named sim.out. Run this through the simulator by using the command tmsim -statfile sim.stat -cf 75000000 sim.out This will generate a statfile named sim.stat. Run this through tmprof in order to generate a report of where all the time is being spent in your program.

The Program

The whole program will time the median filter function and will, depending on the delay, slowly add lines displayed in real-time until it The program takes the attitude that it is better to display a portion of the screen in real time rather than to display the whole picture in a choppy format. The maximum number of lines that can be displayed is 288. The median.c file we initialy provide displays 23 lines, this is the only file you should have to modify.

Be sure to include custom_ops.h and ops/custom_defs.h in the median.cc file.

File(s)


CS122B, Winter 2002