annotate ffmpeg/libavformat/crcenc.c @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * CRC encoder (for codec/format testing)
yading@11 3 * Copyright (c) 2002 Fabrice Bellard
yading@11 4 *
yading@11 5 * This file is part of FFmpeg.
yading@11 6 *
yading@11 7 * FFmpeg is free software; you can redistribute it and/or
yading@11 8 * modify it under the terms of the GNU Lesser General Public
yading@11 9 * License as published by the Free Software Foundation; either
yading@11 10 * version 2.1 of the License, or (at your option) any later version.
yading@11 11 *
yading@11 12 * FFmpeg is distributed in the hope that it will be useful,
yading@11 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 15 * Lesser General Public License for more details.
yading@11 16 *
yading@11 17 * You should have received a copy of the GNU Lesser General Public
yading@11 18 * License along with FFmpeg; if not, write to the Free Software
yading@11 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 20 */
yading@11 21
yading@11 22 #include "libavutil/adler32.h"
yading@11 23 #include "avformat.h"
yading@11 24
yading@11 25 typedef struct CRCState {
yading@11 26 uint32_t crcval;
yading@11 27 } CRCState;
yading@11 28
yading@11 29 static int crc_write_header(struct AVFormatContext *s)
yading@11 30 {
yading@11 31 CRCState *crc = s->priv_data;
yading@11 32
yading@11 33 /* init CRC */
yading@11 34 crc->crcval = 1;
yading@11 35
yading@11 36 return 0;
yading@11 37 }
yading@11 38
yading@11 39 static int crc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
yading@11 40 {
yading@11 41 CRCState *crc = s->priv_data;
yading@11 42 crc->crcval = av_adler32_update(crc->crcval, pkt->data, pkt->size);
yading@11 43 return 0;
yading@11 44 }
yading@11 45
yading@11 46 static int crc_write_trailer(struct AVFormatContext *s)
yading@11 47 {
yading@11 48 CRCState *crc = s->priv_data;
yading@11 49 char buf[64];
yading@11 50
yading@11 51 snprintf(buf, sizeof(buf), "CRC=0x%08x\n", crc->crcval);
yading@11 52 avio_write(s->pb, buf, strlen(buf));
yading@11 53
yading@11 54 return 0;
yading@11 55 }
yading@11 56
yading@11 57 AVOutputFormat ff_crc_muxer = {
yading@11 58 .name = "crc",
yading@11 59 .long_name = NULL_IF_CONFIG_SMALL("CRC testing"),
yading@11 60 .priv_data_size = sizeof(CRCState),
yading@11 61 .audio_codec = AV_CODEC_ID_PCM_S16LE,
yading@11 62 .video_codec = AV_CODEC_ID_RAWVIDEO,
yading@11 63 .write_header = crc_write_header,
yading@11 64 .write_packet = crc_write_packet,
yading@11 65 .write_trailer = crc_write_trailer,
yading@11 66 .flags = AVFMT_NOTIMESTAMPS,
yading@11 67 };