[FFmpeg-devel] [PATCH v2 1/2] avformat/framehash: add extradata checksum

Michael Niedermayer michael at niedermayer.cc
Wed Apr 13 12:28:23 CEST 2016


On Wed, Apr 13, 2016 at 01:54:25AM -0300, James Almer wrote:
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> I'm keeping the version code for the time being, unless people disagree.
> Removing it if needed is trivial.
> 
>  libavformat/hashenc.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/libavformat/hashenc.c b/libavformat/hashenc.c
> index 614c815..e471789 100644
> --- a/libavformat/hashenc.c
> +++ b/libavformat/hashenc.c
> @@ -149,6 +149,33 @@ AVOutputFormat ff_md5_muxer = {
>  #endif
>  
>  #if CONFIG_FRAMEHASH_MUXER || CONFIG_FRAMEMD5_MUXER
> +static void framehash_print_extradata(struct AVFormatContext *s)
> +{
> +    int i, header_printed = 0;
> +
> +    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+128];
> +            int len;
> +
> +            if (!header_printed) {
> +                avio_printf(s->pb, "#extradata#,                             size, hash\n");
> +                header_printed = 1;
> +            }
> +            av_hash_init(c->hash);
> +            av_hash_update(c->hash, par->extradata, par->extradata_size);
> +            snprintf(buf, sizeof(buf) - (AV_HASH_MAX_SIZE * 2 + 1), "%d, %42d, ", i, par->extradata_size);
> +            len = strlen(buf);
> +            av_hash_final_hex(c->hash, buf + len, sizeof(buf) - len);
> +            av_strlcatf(buf, sizeof(buf), "\n");
> +            avio_write(s->pb, buf, strlen(buf));
> +        }
> +    }
> +}

This breaks the syntax of framehash and anything using it
the syntax prior to this is that
theres one header followed by frames with fields described by that
header and comments starting with #
also comment generally had as 2nd field the stream number

after that there would be multiple headers and lists

also in practical terms this syntax is much harder to parse as lines
no longer can be interpreted on their own but their position
in  the file in relation to other lines suddenly becomes required
to be used to interpret them
especially simple parsing with basic tools like grep and sed would
suffer from this

framecrc already lists the hash and size of extradata within the
bounds of the framehash syntax, that should be reuseable

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
            conveniently.
New school: Use the highest level language in which the latest supercomputer
            can solve the problem without the user falling asleep waiting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160413/c7670d4e/attachment.sig>


More information about the ffmpeg-devel mailing list