.ft title Sample Session\n
\n
This example demonstrates how 
.ft sdout mpeg_bits
 might be used to monitor and modify the encoding of an mpeg stream.
\n
\n
Get the mpeg stream entitled \"waterski.mpg\" from the following ftp 
site:
\n
.ft sdout  mm-ftp.cs.berkeley.edu:/pub/multimedia/mpeg/movies.  
\n
Suppose we have just produced this stream from a set of yuv files using 
.ft sdout mpeg_encode
 with parameter file \"waterski.param\", and we wish to observe and perhaps
 modify the results of the encoding using 
.ft sdout mpeg_bits.
\n
\n
Using \"Open Video\" from the 
.ht .filHelp File
 menu, open the stream \"waterski.mpeg\".  The
 first frame appears on the screen, along with associated information.  Hit the
 \"step forward\" button on the 
.ht .ovrHelp control window
 several times; the video steps 
 forward several frames.  Hit the \"play\" button on the 
.ht .ovrHelp control window;
 the video will play until you hit the stop button.  Notice that the 
.ht .ovrHelp information window
 changes with each frame to reflect the current frame's size and type.  Click and
 hold the middle mouse over a block in the 
.ht .ovrHelp bit field.
  Note that the block's
 size appears in the upper right of the 
.ht .ovrHelp information window.
  Click and hold the
 middle mouse over any of the frames represented in the 
.ht .ovrHelp relative frame sizes field.
  Note that the frame's size appears in the upper right of the 
.ht .ovrHelp information window.
\n
\n
Use the \"step-back\" button in the 
.ht .ovrHelp control window
 to step back to the first frame.
\n
\n
Suppose, having viewed the stream, we decide that it needs some sprucing up.  In
particular, we would like for the woman running into the water and the cooler
beneath her at the center of the display to be encoded more clearly.  
Using the left mouse button,
drop and drag over the region in the 
.ht .ovrHelp bit field
 corresponding the region where
 the woman is in the 
.ht .ovrHelp display window.
  Or, drop and drag with the left mouse button over the image itself in the
.ht .ovrHelp display window.
  The selected region will darken.  You may
 select more regions at this point with dropping and dragging, or deselect and
 start over by clicking the right mouse button.
\n
\n
Now select \"Mark First Frame\" from the 
.ht .ediHelp Edit
 menu.  The Frame Selection dialog
 will appear.  Use the buttons in the control window to advance to the last
 frame to be included in the edit, say frame 6.  Stop at frame 6, and click
 the \"Mark Last Frame\" button.  
\n
\n
The Re-encode Frames dialog will appear.  Since we want the woman and cooler 
to be clearer, we want to decrease the Q-scale for the blocks that display 
their images.  Set the Q-scale adjustment to -3, and click \"Confirm Edit\".  The
dialog will disappear, the shaded regions will clear up, and the edit is 
confirmed.
\n
\n
To view a list of confirmed edits, select \"View Edit List\" from the 
.ht .ediHelp Edit menu.
  The Edit List window appears, listing edits with the frames affected and the
 adjustment to be made.  In this case we see that we have one edit affecting 
 frame 0 to frame 6, adjusting the Q-scale by -3.  To see the macroblocks 
 affected by the change, select the edit with the left mouse button, then click 
 \"View Macroblocks\".  A mini version of the bit field will appear, indicating by
 shading which blocks are included in the edit.
\n
\n
We can now generate a parameter file to support the actual encoding of all
confirmed edits.  Select \"Save\" from the 
.ht .filHelp File
 menu.  A dialog appears prompting
 for a file name.  Enter \"waterski.param.spec\" and hit Return.  
\n
\n
Once the file is generated, you may exit from 
.ft sdout mpeg_bits
 by selecting Quit from the 
.ht .filHelp File
 menu.
\n
\n
To include these edits in subsequent encodings of waterski.mpg, create a line
in waterski.param reading:
\n
.ft sdout SPECIFICS_FILE waterski.param.spec
\n
\n
Now, suppose we re-encode, view the results using 
.ft sdout mpeg_play
, and decide
 that we'd like to de-emphasize the people in the water around the woman, while
 making the woman and the cooler even more clear over a wider range of frames.
\n
\n
Again, we load waterski.mpg from the 
.ht .filHelp File
 menu (we might want to use the
 version we just generated from the re-encoding to see how the re-encoding
 affected bit distribution).  To de-emphasize the people in the water, we proceed
 as described above: position the stream to the first frame in the edit (say 2),
 select the macroblocks to change, select \"Mark First Frame\", move the end of
 the range of frames we want included in the edit (say 8), select \"Mark
 Last Frame\", enter a Q scale adjustment (say 2), and click \"Confirm Edit\".
\n
\n
To re-encode the woman and the cooler, we can re-use the product of the
 previous session.  Select \"Open Edit List\" from the 
.ht .filHelp File
 menu, and enter
 \"waterski.param.spec\" in the file dialog provided.  The edits used to generate
 that file will be loaded into mpeg_bits.  Select \"View Edit List\" from the 
.ht .ediHelp Edit
 menu, and note that both the edit you just made and the edit from
 the previous session are confirmed.  

To change the re-encoding of the woman, select the edit in the Edit List and
 click \"Adjust\".  The Adjust Edit dialog appears.  Change the final frame to
 12 and the Q-scale adjustment to -5.  Click \"Confirm Adjustment\".  The
 adjusted edit now appears in the Edit List.

Note that unless we were extremely careful in selecting the macroblocks in
 each edit, there are some frames in which we have set a particluar macroblock
 to have both a higher Q-scale, because it is near the swimmers we want to
 de-emphasize, and also to have a lower Q-scale, because it is near the woman.
 In such cases, 
.ft sdout mpeg_bits
 will treat the macroblock as part of the topmost edit
 in the edit list.  Here, suppose we decide that we want the re-encoding of the
 woman to take priority.  To raise the priority of that edit over the other
 one, select the bottom edit and click \"Raise Priority\".  The edit will
 switch places with the one above it.
\n
\n
At this point, we can save again to \"waterski.param.spec\", which will overwrite
 the previous version of this file.


