mirror of https://git.ffmpeg.org/ffmpeg.git
avformat/framehash: add extradata checksum
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
33aa8a6221
commit
5557e881c9
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue