]> git.sesse.net Git - ffmpeg/blob - libavformat/crc.c
add information about codec uls
[ffmpeg] / libavformat / crc.c
1 /*
2  * CRC decoder (for codec/format testing)
3  * Copyright (c) 2002 Fabrice Bellard.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 #include "avformat.h"
20 #include "adler32.h"
21
22 #ifdef CONFIG_CRC_MUXER
23 typedef struct CRCState {
24     uint32_t crcval;
25 } CRCState;
26
27 static int crc_write_header(struct AVFormatContext *s)
28 {
29     CRCState *crc = s->priv_data;
30
31     /* init CRC */
32     crc->crcval = 1;
33
34     return 0;
35 }
36
37 static int crc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
38 {
39     CRCState *crc = s->priv_data;
40     crc->crcval = av_adler32_update(crc->crcval, pkt->data, pkt->size);
41     return 0;
42 }
43
44 static int crc_write_trailer(struct AVFormatContext *s)
45 {
46     CRCState *crc = s->priv_data;
47     char buf[64];
48
49     snprintf(buf, sizeof(buf), "CRC=0x%08x\n", crc->crcval);
50     put_buffer(&s->pb, buf, strlen(buf));
51     put_flush_packet(&s->pb);
52     return 0;
53 }
54 #endif
55
56 #ifdef CONFIG_FRAMECRC_MUXER
57 static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
58 {
59     uint32_t crc = av_adler32_update(0, pkt->data, pkt->size);
60     char buf[256];
61
62     snprintf(buf, sizeof(buf), "%d, %"PRId64", %d, 0x%08x\n", pkt->stream_index, pkt->dts, pkt->size, crc);
63     put_buffer(&s->pb, buf, strlen(buf));
64     put_flush_packet(&s->pb);
65     return 0;
66 }
67 #endif
68
69 #ifdef CONFIG_CRC_MUXER
70 AVOutputFormat crc_muxer = {
71     "crc",
72     "crc testing format",
73     NULL,
74     "",
75     sizeof(CRCState),
76     CODEC_ID_PCM_S16LE,
77     CODEC_ID_RAWVIDEO,
78     crc_write_header,
79     crc_write_packet,
80     crc_write_trailer,
81 };
82 #endif
83 #ifdef CONFIG_FRAMECRC_MUXER
84 AVOutputFormat framecrc_muxer = {
85     "framecrc",
86     "framecrc testing format",
87     NULL,
88     "",
89     0,
90     CODEC_ID_PCM_S16LE,
91     CODEC_ID_RAWVIDEO,
92     NULL,
93     framecrc_write_packet,
94     NULL,
95 };
96 #endif