function MPEG_playback_w_compare(orig_movie, decoded_movie)
% plays back the orig and the encoded-decoded movie side by side

function MPEG_decode(stream_to_decode)
% decodes an MPEG stream previously encoded with MPEG_encode
% it creates a file named [stream_to_decode '_dec'] 

function [ frame_encoded ] = encode_I_frame( frame_in, B_size, MB_size, Q)
function [ frame_encoded, u, v ] = encode_P_frame( frame_in, ref_past, B_size, MB_size, Q, search_width )
function [ frame_encoded, u_p, v_p, u_f, v_f ] = encode_B_frame( frame_in, ref_past, ref_future, B_size, MB_size, Q, search_width )
% encode a frame as I, P, B frame
%
% frame_in: the frame to be encoded
% ref OR ref_past, ref_future: the reference frames on which to look for MBs to be moved
% B_size: block size (in pixels)
% MB_size: macro block (MB) size (in pixels)
% Q: quantization matrix

function [ frame_out ] = decode_I_frame( frame_encoded, B_size, MB_size, Q  )
function [ frame_out] = decode_P_frame( frame_encoded, ref_past, B_size, MB_size, Q, u, v )
function [ frame_out ] = decode_B_frame( frame_encoded, ref_past, ref_future, B_size, MB_size, Q, u_p, v_p, u_f, v_f )
% decode an I, P, B frame
%
% frame_encoded: the frame to be decoded
% ref_past OR ref_past, ref_future: the reference frames on which to MBs are to be moved
% MB_size: macro block (MB) size in pixels (can be different for luma and chroma!)
% B_size: block size (in pixels)
% Q: quantization matrix to apply
% u, v OR u_f, v_f, u_b, v_b: matrices containing the motion vectors for each MB

function [ u, v ] = get_motion_vector( MB_in, m, n, ref, MB_size, search_width )
% returns the indices of best maching MB on ref to MB_in
%
% MB_in: MB to estimate
% m,n: position of MB_in (in MB coordinates, not pixel (!))
% ref: the reference picture's luma component (! - not MB)
% MB_size: macro block (MB) size in pixels (can be different for luma and chroma!)
% search_width: number of pixels to look for MB movement 

function [ pred_MB ] = motion_prediction( MB_size, ref, u, v, m, n )
% returns a predicted MB
%
% MB_size: macro block (MB) size in pixels (can be different for luma and chroma!)
% ref: the reference picture's luma or chroma component (! - not MB)
% u,v: the coordinates of the MB in ref frame which matches the best to MB to predict (in MB coordinates, not pixels (!))
% m,n: position of MB_in (in MB coordinates, not pixel (!))

function [ MB_quantized ] = quantize( MB_in, B_size, Q  )
% quantizes all blocks of a MB according to Q
%
% MB_in: MB to quantize
% B_size: dimensions of a DCT block (in pixels)
% Q: quantization matrix
