mirror of https://github.com/FFmpeg/FFmpeg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
68 lines
1.7 KiB
19 years ago
|
/*
|
||
17 years ago
|
* CRC encoder (for codec/format testing)
|
||
23 years ago
|
* Copyright (c) 2002 Fabrice Bellard.
|
||
23 years ago
|
*
|
||
18 years ago
|
* This file is part of FFmpeg.
|
||
|
*
|
||
|
* FFmpeg is free software; you can redistribute it and/or
|
||
23 years ago
|
* modify it under the terms of the GNU Lesser General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
18 years ago
|
* version 2.1 of the License, or (at your option) any later version.
|
||
23 years ago
|
*
|
||
18 years ago
|
* FFmpeg is distributed in the hope that it will be useful,
|
||
23 years ago
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
23 years ago
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Lesser General Public License for more details.
|
||
23 years ago
|
*
|
||
23 years ago
|
* You should have received a copy of the GNU Lesser General Public
|
||
18 years ago
|
* License along with FFmpeg; if not, write to the Free Software
|
||
19 years ago
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
23 years ago
|
*/
|
||
|
#include "avformat.h"
|
||
19 years ago
|
#include "adler32.h"
|
||
23 years ago
|
|
||
|
typedef struct CRCState {
|
||
22 years ago
|
uint32_t crcval;
|
||
23 years ago
|
} CRCState;
|
||
|
|
||
|
static int crc_write_header(struct AVFormatContext *s)
|
||
|
{
|
||
23 years ago
|
CRCState *crc = s->priv_data;
|
||
|
|
||
23 years ago
|
/* init CRC */
|
||
19 years ago
|
crc->crcval = 1;
|
||
23 years ago
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
21 years ago
|
static int crc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
|
||
23 years ago
|
{
|
||
|
CRCState *crc = s->priv_data;
|
||
19 years ago
|
crc->crcval = av_adler32_update(crc->crcval, pkt->data, pkt->size);
|
||
23 years ago
|
return 0;
|
||
|
}
|
||
|
|
||
|
static int crc_write_trailer(struct AVFormatContext *s)
|
||
|
{
|
||
|
CRCState *crc = s->priv_data;
|
||
|
char buf[64];
|
||
|
|
||
19 years ago
|
snprintf(buf, sizeof(buf), "CRC=0x%08x\n", crc->crcval);
|
||
|
put_buffer(&s->pb, buf, strlen(buf));
|
||
|
put_flush_packet(&s->pb);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
19 years ago
|
AVOutputFormat crc_muxer = {
|
||
23 years ago
|
"crc",
|
||
|
"crc testing format",
|
||
|
NULL,
|
||
|
"",
|
||
23 years ago
|
sizeof(CRCState),
|
||
23 years ago
|
CODEC_ID_PCM_S16LE,
|
||
|
CODEC_ID_RAWVIDEO,
|
||
|
crc_write_header,
|
||
|
crc_write_packet,
|
||
|
crc_write_trailer,
|
||
|
};
|