[FFmpeg-devel] [RFC] properly document av_crc
Reimar Döffinger
Reimar.Doeffinger
Sun Aug 19 13:20:45 CEST 2007
Hello,
currently the crc functions in libavutil IMO have a very peculiar API
that in addition is also undocumented.
Attached patch documents it as good as I could come up with.
Though since it is not yet part of the public API I think it might be
worth changing it, e.g. make av_crc do the necessary bswaps...
Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavutil/crc.c
===================================================================
--- libavutil/crc.c (revision 10141)
+++ libavutil/crc.c (working copy)
@@ -37,6 +37,14 @@
* Inits a crc table.
* @param ctx must be an array of sizeof(AVCRC)*257 or sizeof(AVCRC)*1024
* @param cts_size size of ctx in bytes
+ * @param le if 1, lowest bit represents coefficient for highest exponent
+ * of corresponding polynomial (both for poly and actual CRC).
+ * If 0, you must swap the crc parameter and the result of av_crc
+ * (can be simplified in most cases to e.g. bswap16):
+ * bswap_32(crc << (32-bits))
+ * @param bits number of bits for the CRC
+ * @param poly generator polynomial without the x**bits coefficient, in the
+ * representation as specified by le
* @return <0 on failure
*/
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){
@@ -70,6 +78,13 @@
return 0;
}
+/**
+ * Calculate the CRC of a block
+ * @param crc CRC of previous blocks if any or initial value for CRC.
+ * @return CRC updated with the data from the given block
+ *
+ * Please read the explanation of the le parameter to av_crc_init
+ */
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length){
const uint8_t *end= buffer+length;
More information about the ffmpeg-devel
mailing list