2 * CRC decoder (for codec/format testing)
3 * Copyright (c) 2002 Fabrice Bellard.
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.
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.
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
22 #ifdef CONFIG_CRC_MUXER
23 typedef struct CRCState {
27 static int crc_write_header(struct AVFormatContext *s)
29 CRCState *crc = s->priv_data;
37 static int crc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
39 CRCState *crc = s->priv_data;
40 crc->crcval = av_adler32_update(crc->crcval, pkt->data, pkt->size);
44 static int crc_write_trailer(struct AVFormatContext *s)
46 CRCState *crc = s->priv_data;
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);
56 #ifdef CONFIG_FRAMECRC_MUXER
57 static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
59 uint32_t crc = av_adler32_update(0, pkt->data, pkt->size);
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);
69 #ifdef CONFIG_CRC_MUXER
70 AVOutputFormat crc_muxer = {
83 #ifdef CONFIG_FRAMECRC_MUXER
84 AVOutputFormat framecrc_muxer = {
86 "framecrc testing format",
93 framecrc_write_packet,