38 #define OFFSET(x) offsetof(struct HashContext, x)
39 #define ENC AV_OPT_FLAG_ENCODING_PARAM
40 #define HASH_OPT(defaulttype) \
41 { "hash", "set hash to use", OFFSET(hash_name), AV_OPT_TYPE_STRING, {.str = defaulttype}, 0, 0, ENC }
42 #define FORMAT_VERSION_OPT \
43 { "format_version", "file format version", OFFSET(format_version), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC }
45 #if CONFIG_HASH_MUXER || CONFIG_STREAMHASH_MUXER
46 static const AVOption hash_streamhash_options[] = {
52 #if CONFIG_FRAMEHASH_MUXER
53 static const AVOption framehash_options[] = {
61 static const AVOption md5_options[] = {
67 #if CONFIG_FRAMEMD5_MUXER
68 static const AVOption framemd5_options[] = {
75 #if CONFIG_HASH_MUXER || CONFIG_MD5_MUXER
92 #if CONFIG_STREAMHASH_MUXER
101 for (
i = 0;
i <
s->nb_streams;
i++) {
112 #if CONFIG_HASH_MUXER || CONFIG_MD5_MUXER || CONFIG_STREAMHASH_MUXER
135 int num_hashes =
c->per_stream ?
s->nb_streams : 1;
136 for (
int i = 0;
i < num_hashes;
i++) {
158 int num_hashes =
c->per_stream ?
s->nb_streams : 1;
159 for (
int i = 0;
i < num_hashes;
i++) {
166 #if CONFIG_HASH_MUXER
167 static const AVClass hashenc_class = {
170 .option = hash_streamhash_options,
181 .write_packet = hash_write_packet,
182 .write_trailer = hash_write_trailer,
186 .priv_class = &hashenc_class,
191 static const AVClass md5enc_class = {
194 .option = md5_options,
205 .write_packet = hash_write_packet,
206 .write_trailer = hash_write_trailer,
210 .priv_class = &md5enc_class,
214 #if CONFIG_STREAMHASH_MUXER
215 static const AVClass streamhashenc_class = {
218 .option = hash_streamhash_options,
223 .
name =
"streamhash",
228 .init = streamhash_init,
229 .write_packet = hash_write_packet,
230 .write_trailer = hash_write_trailer,
234 .priv_class = &streamhashenc_class,
238 #if CONFIG_FRAMEHASH_MUXER || CONFIG_FRAMEMD5_MUXER
243 for (
i = 0;
i <
s->nb_streams;
i++) {
280 framehash_print_extradata(
s);
282 avio_printf(
s->pb,
"#stream#, dts, pts, duration, size, hash\n");
324 #if CONFIG_FRAMEHASH_MUXER
325 static const AVClass framehash_class = {
328 .option = framehash_options,
338 .init = framehash_init,
339 .write_header = framehash_write_header,
340 .write_packet = framehash_write_packet,
344 .priv_class = &framehash_class,
348 #if CONFIG_FRAMEMD5_MUXER
349 static const AVClass framemd5_class = {
352 .option = framemd5_options,
362 .init = framehash_init,
363 .write_header = framehash_write_header,
364 .write_packet = framehash_write_packet,
368 .priv_class = &framemd5_class,
simple assert() macros that are a bit more flexible than ISO C assert().
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)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static char get_media_type_char(enum AVMediaType type)
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, int 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.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
@ 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_free(struct AVFormatContext *s)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
This struct describes the properties of an encoded stream.
int extradata_size
Size of the extradata content in bytes.
enum AVMediaType codec_type
General type of the encoded data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVPacketSideDataType type
This structure stores compressed data.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
struct AVHashContext ** hashes