[Ffmpeg-devel] [PATCH] flacenc - md5

Justin Ruggles jruggle
Sun Jul 2 18:56:24 CEST 2006


This patch enables writing the MD5 checksum in the FLAC header.  It also
writes the total number of samples.  The solution is based on the way
that the WAV muxer seeks back & writes over portions of the header after
encoding is finished.

I am not 100% happy with how I had to do the md5 calculation, but I
can't think of any other way...  The problem I ran into is that there is
no way for the encoder to know when it is encoding the last frame.
Looking for a smaller frame would do it most of the time, but not if the
sample count is an even multiple of the block size.  So the solution I
came up with was to write the MD5 value to the extradata when encoding
every frame, as if every frame was the last one.  To do this, I had to
copy the working MD5 struct to a temporary struct before running
av_md5_final().  Since 'struct AVMD5' is an incomplete type, the
solution looks a bit ugly, but it works.

Also, I have attached a small patch to output_example.c.  ffmpeg writes
the trailer before closing the codec, but output_example currently does
the reverse.  I don't know if this was intended or just an oversight.

While I was writing this, Ivo's md5 cleanup patch popped up in my inbox.
 Note that there is 1 line that overlaps between that patch and this one
in libavutil/Makefile.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: flac-md5.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060702/9f5d1ae8/attachment.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: output_example-trailer.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060702/9f5d1ae8/attachment.txt>

More information about the ffmpeg-devel mailing list