2
* MD5 encoder (for codec/format testing)
3
* Copyright (c) 2009 Reimar Döffinger, based on crcenc (c) 2002 Fabrice Bellard
5
* This file is part of Libav.
7
* Libav is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
12
* Libav is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with Libav; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
#include "libavutil/md5.h"
27
static void md5_finish(struct AVFormatContext *s, char *buf)
30
int i, offset = strlen(buf);
31
av_md5_final(s->priv_data, md5);
32
for (i = 0; i < sizeof(md5); i++) {
33
snprintf(buf + offset, 3, "%02"PRIx8, md5[i]);
39
avio_write(s->pb, buf, strlen(buf));
44
static int write_header(struct AVFormatContext *s)
46
if (PRIVSIZE < av_md5_size) {
47
av_log(s, AV_LOG_ERROR, "Insuffient size for md5 context\n");
50
av_md5_init(s->priv_data);
54
static int write_packet(struct AVFormatContext *s, AVPacket *pkt)
56
av_md5_update(s->priv_data, pkt->data, pkt->size);
60
static int write_trailer(struct AVFormatContext *s)
62
char buf[64] = "MD5=";
68
AVOutputFormat ff_md5_muxer = {
70
NULL_IF_CONFIG_SMALL("MD5 testing format"),
82
#if CONFIG_FRAMEMD5_MUXER
83
static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt)
86
if (PRIVSIZE < av_md5_size) {
87
av_log(s, AV_LOG_ERROR, "Insuffient size for md5 context\n");
90
av_md5_init(s->priv_data);
91
av_md5_update(s->priv_data, pkt->data, pkt->size);
93
snprintf(buf, sizeof(buf) - 64, "%d, %"PRId64", %d, ", pkt->stream_index, pkt->dts, pkt->size);
98
AVOutputFormat ff_framemd5_muxer = {
100
NULL_IF_CONFIG_SMALL("Per-frame MD5 testing format"),
107
framemd5_write_packet,