Please look at proj23/sanjay-part3 for code. mpeg_bytes_transmit.ipynb is where the encoding actually happpens. In this code, we take the gif, apply the necessary functions from jpeg.py, mpeg.py, huffman_gen.py, and huffman.py, generate the final encoding bytearray, and then store this bytearray in recon/bytes.jpeg123. Note that our encoding is too computationally intensive to run on the pi, so we need to encode (generate recon/bytes.jpeg123) locally, push this file to the repo, pull from the pi, and then transmit from the pi. The transmission code is in the In [37] cell in fp-part3-APRS-TNC.ipynb. Here we just convert the bytearray in recon/bytes.jpeg123 to b64 format and then transmit it.
Also, our transmission format is -
[I-frame jpeg bytes, P-frame 1 motion vector bytes, ... , P-frame n motion vector bytes, marker (0xFFFFFFFF00000000), metadata]
The format of metadata is -
[Number of frames, frame 1 encoding size in bytes, ..., frame n encoding size in bytes, block size, scan area, frame duration]
This is a brief description of jpeg.py, mpeg.py, huffman_gen.py, and huffman.py. jpeg.py and huffman.py are from part 1 and this is for compressing the first I-frame in our compression scheme. mpeg.py contains all the mpeg encoding functions to generate motion vectors given an I-frame and P-frame and to also reconstruct a P-frame given an I-frame and motion vectors. huffman_gen.py contains a single function that takes in our block size and scan area compression parameters and creates and returns a huffman table for decoding in reconstruction.py.