00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "libavutil/adler32.h"
00023 #include "avformat.h"
00024
00025 typedef struct CRCState {
00026 uint32_t crcval;
00027 } CRCState;
00028
00029 static int crc_write_header(struct AVFormatContext *s)
00030 {
00031 CRCState *crc = s->priv_data;
00032
00033
00034 crc->crcval = 1;
00035
00036 return 0;
00037 }
00038
00039 static int crc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
00040 {
00041 CRCState *crc = s->priv_data;
00042 crc->crcval = av_adler32_update(crc->crcval, pkt->data, pkt->size);
00043 return 0;
00044 }
00045
00046 static int crc_write_trailer(struct AVFormatContext *s)
00047 {
00048 CRCState *crc = s->priv_data;
00049 char buf[64];
00050
00051 snprintf(buf, sizeof(buf), "CRC=0x%08x\n", crc->crcval);
00052 avio_write(s->pb, buf, strlen(buf));
00053 avio_flush(s->pb);
00054 return 0;
00055 }
00056
00057 AVOutputFormat ff_crc_muxer = {
00058 "crc",
00059 NULL_IF_CONFIG_SMALL("CRC testing format"),
00060 NULL,
00061 "",
00062 sizeof(CRCState),
00063 CODEC_ID_PCM_S16LE,
00064 CODEC_ID_RAWVIDEO,
00065 crc_write_header,
00066 crc_write_packet,
00067 crc_write_trailer,
00068 };