Project Stage 2: Reassembling and Decoding MPEG-1 Video Packets

Due: 11:59pm, 2 October 2005

The objective in Stage 2 of the project is to implement robust reassembly methods for MPEG-1 video RTP packets.

You are given the code that (i) buffers the RTP packets, (ii) reassembles their payload into MPEG frames, and (iii) uncompresses the MPEG frames. Unfortunately, the code given assumes that there is no packet loss! Thus, the video is decoded properly when no packet is loss, but if some of the RTP packets are missing, the decoder can produce corrupted and out-of-order frames (due to, for instance, attempt to decode incomplete slices, attempt to decode I-frame as P-frame because of missing picture header, etc.).

Your task, is to change the reassembler and part of the decoder such that it deals with loss packets properly. You should think carefully how to deal with different cases before start modifying the existing code. Cases to consider includes, but is not limited to,

  • Missing packet in the middle of a slice
  • Missing packet containing the beginning of a slice
  • Missing packet containing the end of a slice
  • Missing packet containing the beginning of a picture
  • Missing packet containing the end of a picture
  • Missing packet containing GOP header
  • Missing packet containing picture header
  • Missing packets containing at least one whole picture
You can assume that the first packet, which contains the sequence header is never lost.

The main script for this project is rtptoppm.tcl, which reads in the binary RTP file you created from stage 1, and produces decoded frames in PPM image format and a log file containing PSNR values of each frame.

Symptoms that the decoding is not robust enough.

  • Illegal macroblock address warnings
  • Wrongly numbered output image files
  • Extremely corrupted frames (PSNR in the range of 10-20s even for low lost rate)

The classes you may need to modify:

  • MntMPEGRTPReassembler: responsible for buffering packets from a single MPEG frame.
  • MntMPEGFrameDecoder: responsible for putting the payloads of packets together into a bitstream, and uncompress the bistream. NOTE: You are not expected to modify the code that uncompresses macroblocks. You need to, however, change how this class copies payloads into bitstream, and how it updates its members when GOP/picture headers are encountered in the bitstream.
  • MntMPEGRTPReassemblerBuffer: a dynamic array of pointers to RTP packets, ordered by sequence number.

New Classes

Here are the new classes released in this stage of the project.

Compilation Instructions

Tcl 8.3, OTcl and TclCL are not included in this release. You may either copy or link the subdirectory tcl8.3, otcl and tclcl under proj1/src to proj2/src. You will also need to copy the files that you have changed in Stage 1 to proj2/src.

Since Stage 2 of the project relies on the implementation of MntRTPMPEGPacket, the given set of code will not compile out of the box. You need to implement the following public methods in MntRTPMPEGPacket for some of the given files to compile:

  • int get_es_bit()
  • int get_bs_bit()
  • int get_pic_type()
  • int get_marker_bit()
  • int get_timestamp()
  • int get_seq_no()
The methods return the corresponding fields of the RTP header and RTP payload header.

Submission

To submit your project, create a tarball of all yours sources, (please exclude sample videos, object files etc.), and put it into IVLE workbin. Your source code should be properly commented with explanations to help me understand your code. Please include a README.txt file that explains clearly how you deal with different packet loss cases.