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