Commit 5557e881 authored by James Almer's avatar James Almer

avformat/framehash: add extradata checksum

Reviewed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 33aa8a62
......@@ -149,6 +149,27 @@ AVOutputFormat ff_md5_muxer = {
#endif
#if CONFIG_FRAMEHASH_MUXER || CONFIG_FRAMEMD5_MUXER
static void framehash_print_extradata(struct AVFormatContext *s)
{
int i;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
AVCodecParameters *par = st->codecpar;
if (par->extradata) {
struct HashContext *c = s->priv_data;
char buf[AV_HASH_MAX_SIZE*2+1];
avio_printf(s->pb, "#extradata %d, %31d, ", i, par->extradata_size);
av_hash_init(c->hash);
av_hash_update(c->hash, par->extradata, par->extradata_size);
av_hash_final_hex(c->hash, buf, sizeof(buf));
avio_write(s->pb, buf, strlen(buf));
avio_printf(s->pb, "\n");
}
}
}
static int framehash_write_header(struct AVFormatContext *s)
{
struct HashContext *c = s->priv_data;
......@@ -158,6 +179,8 @@ static int framehash_write_header(struct AVFormatContext *s)
avio_printf(s->pb, "#format: frame checksums\n");
avio_printf(s->pb, "#version: %d\n", c->format_version);
avio_printf(s->pb, "#hash: %s\n", av_hash_get_name(c->hash));
if (c->format_version > 1)
framehash_print_extradata(s);
ff_framehash_write_header(s, c->format_version);
avio_printf(s->pb, "#stream#, dts, pts, duration, size, hash\n");
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment