22#include "config_components.h"
44#define OFFSET(x) offsetof(struct HashContext, x)
45#define ENC AV_OPT_FLAG_ENCODING_PARAM
46#define HASH_OPT(defaulttype) \
47 { "hash", "set hash to use", OFFSET(hash_name), AV_OPT_TYPE_STRING, {.str = defaulttype}, 0, 0, ENC }
48#define FORMAT_VERSION_OPT \
49 { "format_version", "file format version", OFFSET(format_version), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC }
51#if CONFIG_FRAMEHASH_MUXER | CONFIG_STREAMHASH_MUXER | CONFIG_HASH_MUXER
52static const AVOption hash_options[] = {
60static const AVOption md5_options[] = {
66#if CONFIG_FRAMEMD5_MUXER
67static const AVOption framemd5_options[] = {
74#if CONFIG_HASH_MUXER || CONFIG_MD5_MUXER
98#if CONFIG_STREAMHASH_MUXER || CONFIG_FRAMEHASH_MUXER || CONFIG_FRAMEMD5_MUXER
103 for (
i = 0;
i <
s->nb_streams;
i++) {
126 for (
int i = 0;
i < side_data_elems;
i++) {
129 for (
size_t j = 0; j < sd[
i].
size; j +=
sizeof(uint32_t)) {
136 ", %8zu, ", sd[
i].
size);
137 size_t len = strlen(buf);
143#if CONFIG_HASH_MUXER || CONFIG_MD5_MUXER || CONFIG_STREAMHASH_MUXER
159 int num_hashes =
c->per_stream ?
s->nb_streams : 1;
160 for (
int i = 0;
i < num_hashes;
i++) {
163 if (
c->format_version < 2) {
168 snprintf(buf,
sizeof(buf) - 200,
"%d, %11"PRId64
", ",
i,
c->hashes[
i].stream_size);
175 if (
c->per_stream &&
c->format_version >= 2) {
192 int num_hashes =
c->per_stream ?
s->nb_streams : 1;
193 for (
int i = 0;
i < num_hashes;
i++) {
201static const AVClass hash_hashenc_class = {
202 .class_name =
"hash muxer",
204 .option = &hash_options[1],
215 .write_packet = hash_write_packet,
216 .write_trailer = hash_write_trailer,
220 .p.priv_class = &hash_hashenc_class,
225static const AVClass md5enc_class = {
226 .class_name =
"MD5 muxer",
228 .option = md5_options,
239 .write_packet = hash_write_packet,
240 .write_trailer = hash_write_trailer,
244 .p.priv_class = &md5enc_class,
248#if CONFIG_STREAMHASH_MUXER
254 c->hashes =
av_calloc(
s->nb_streams,
sizeof(*
c->hashes));
257 for (
i = 0;
i <
s->nb_streams;
i++) {
270 if (
c->format_version < 2)
275 hash_print_extradata(
s);
286 c->hashes[
pkt->stream_index].stream_size +=
pkt->size;
290static const AVClass streamhashenc_class = {
291 .class_name =
"stream hash muxer",
293 .option = hash_options,
298 .p.name =
"streamhash",
303 .init = streamhash_init,
304 .write_header = streamhash_write_header,
305 .write_packet = streamhash_write_packet,
306 .write_trailer = hash_write_trailer,
310 .p.priv_class = &streamhashenc_class,
314#if CONFIG_FRAMEHASH_MUXER || CONFIG_FRAMEMD5_MUXER
335 hash_print_extradata(
s);
337 avio_printf(
s->pb,
"#stream#, dts, pts, duration, size, hash\n");
355 if (
c->format_version > 1 &&
pkt->side_data_elems) {
364#if CONFIG_FRAMEHASH_MUXER
365static const AVClass framehash_class = {
366 .class_name =
"frame hash muxer",
368 .option = hash_options,
373 .p.name =
"framehash",
378 .init = framehash_init,
379 .write_header = framehash_write_header,
380 .write_packet = framehash_write_packet,
384 .p.priv_class = &framehash_class,
388#if CONFIG_FRAMEMD5_MUXER
389static const AVClass framemd5_class = {
390 .class_name =
"frame MD5 muxer",
392 .option = framemd5_options,
397 .p.name =
"framemd5",
402 .init = framehash_init,
403 .write_header = framehash_write_header,
404 .write_packet = framehash_write_packet,
408 .p.priv_class = &framemd5_class,
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
Writes a formatted string to the context.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
#define i(width, name, range_min, range_max)
int ff_framehash_write_header(AVFormatContext *s)
Set the timebase for each stream from the corresponding codec timebase and print it.
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
void av_hash_freep(AVHashContext **ctx)
Free hash context and set hash context pointer to NULL.
void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size)
Finalize a hash context and store the hexadecimal representation of the actual hash value as a string...
void av_hash_init(AVHashContext *ctx)
Initialize or reset a hash context.
void av_hash_update(AVHashContext *ctx, const uint8_t *src, size_t len)
Update a hash context with additional data.
int av_hash_alloc(AVHashContext **ctx, const char *name)
Allocate a hash context for the algorithm specified by name.
#define AV_HASH_MAX_SIZE
Maximum value that av_hash_get_size() will currently return.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
#define LIBAVUTIL_VERSION_INT
const char * av_hash_get_name(const AVHashContext *ctx)
#define FORMAT_VERSION_OPT
#define HASH_OPT(defaulttype)
static void hash_print_sidedata(struct AVFormatContext *s, const AVPacketSideData *sd, int side_data_elems)
static void hash_free(struct AVFormatContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
static char get_media_type_char(enum AVMediaType type)
Describe the class of an AVClass context structure.
This struct describes the properties of an encoded stream.
int extradata_size
Size of the extradata content in bytes.
int nb_coded_side_data
Amount of entries in coded_side_data.
enum AVMediaType codec_type
General type of the encoded data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
This structure stores compressed data.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
struct HashContext::@342233306123153340317170317037132003264217041033 * hashes
struct AVHashContext * hash