Revision 944a1b6b

View differences:

libavformat/Makefile
106 106
OBJS-$(CONFIG_MATROSKA_MUXER)            += matroskaenc.o matroska.o \
107 107
                                            riff.o isom.o avc.o \
108 108
                                            flacenc_header.o
109
OBJS-$(CONFIG_MD5_MUXER)                 += md5enc.o
109 110
OBJS-$(CONFIG_MJPEG_DEMUXER)             += raw.o
110 111
OBJS-$(CONFIG_MJPEG_MUXER)               += raw.o
111 112
OBJS-$(CONFIG_MLP_DEMUXER)               += raw.o id3v2.o
libavformat/allformats.c
106 106
    REGISTER_DEMUXER  (IV8, iv8);
107 107
    REGISTER_DEMUXER  (LMLM4, lmlm4);
108 108
    REGISTER_MUXDEMUX (M4V, m4v);
109
    REGISTER_MUXER    (MD5, md5);
109 110
    REGISTER_MUXDEMUX (MATROSKA, matroska);
110 111
    REGISTER_MUXER    (MATROSKA_AUDIO, matroska_audio);
111 112
    REGISTER_MUXDEMUX (MJPEG, mjpeg);
libavformat/md5enc.c
1
/*
2
 * MD5 encoder (for codec/format testing)
3
 * Copyright (c) 2009 Reimar Döffinger, based on crcenc (c) 2002 Fabrice Bellard
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg 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.
11
 *
12
 * FFmpeg 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.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21

  
22
#include "libavutil/md5.h"
23
#include "avformat.h"
24

  
25
#define PRIVSIZE 512
26

  
27
static int write_header(struct AVFormatContext *s)
28
{
29
    if (PRIVSIZE < av_md5_size) {
30
        av_log(s, AV_LOG_ERROR, "Insuffient size for md5 context\n");
31
        return -1;
32
    }
33
    av_md5_init(s->priv_data);
34
    return 0;
35
}
36

  
37
static int write_packet(struct AVFormatContext *s, AVPacket *pkt)
38
{
39
    av_md5_update(s->priv_data, pkt->data, pkt->size);
40
    return 0;
41
}
42

  
43
static int write_trailer(struct AVFormatContext *s)
44
{
45
    uint8_t md5[16];
46
    char buf[64] = "MD5=";
47
    int i, offset = strlen(buf);
48

  
49
    av_md5_final(s->priv_data, md5);
50
    for (i = 0; i < sizeof(md5); i++) {
51
        snprintf(buf + offset, 3, "%02"PRIx8, md5[i]);
52
        offset += 2;
53
    }
54
    buf[offset] = '\n';
55
    buf[offset+1] = 0;
56

  
57
    put_buffer(s->pb, buf, strlen(buf));
58
    put_flush_packet(s->pb);
59
    return 0;
60
}
61

  
62
AVOutputFormat md5_muxer = {
63
    "md5",
64
    NULL_IF_CONFIG_SMALL("MD5 testing format"),
65
    NULL,
66
    "",
67
    PRIVSIZE,
68
    CODEC_ID_PCM_S16LE,
69
    CODEC_ID_RAWVIDEO,
70
    write_header,
71
    write_packet,
72
    write_trailer,
73
};

Also available in: Unified diff