aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/hashenc.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2016-04-13 10:49:16 -0300
committerJames Almer <jamrial@gmail.com>2016-04-13 11:41:20 -0300
commit5557e881c9e5138f916447d8137b0ce404cd256c (patch)
tree9205afec5c9b276bbb39dd156c60097a6c0e6535 /libavformat/hashenc.c
parent33aa8a62219d07f77f11f38dd71c5999e0f8e242 (diff)
downloadffmpeg-5557e881c9e5138f916447d8137b0ce404cd256c.tar.gz
avformat/framehash: add extradata checksum
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/hashenc.c')
-rw-r--r--libavformat/hashenc.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libavformat/hashenc.c b/libavformat/hashenc.c
index 614c8157a5..4aa4fcf3ab 100644
--- a/libavformat/hashenc.c
+++ b/libavformat/hashenc.c
@@ -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;