Go to the documentation of this file.
22 #include "config_components.h"
41 #define OFFSET(x) offsetof(struct HashContext, x)
42 #define ENC AV_OPT_FLAG_ENCODING_PARAM
43 #define HASH_OPT(defaulttype) \
44 { "hash", "set hash to use", OFFSET(hash_name), AV_OPT_TYPE_STRING, {.str = defaulttype}, 0, 0, ENC }
45 #define FORMAT_VERSION_OPT \
46 { "format_version", "file format version", OFFSET(format_version), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC }
48 #if CONFIG_HASH_MUXER || CONFIG_STREAMHASH_MUXER
49 static const AVOption hash_streamhash_options[] = {
54 static const AVClass hash_streamhashenc_class = {
57 .option = hash_streamhash_options,
62 #if CONFIG_FRAMEHASH_MUXER
63 static const AVOption framehash_options[] = {
71 static const AVOption md5_options[] = {
77 #if CONFIG_FRAMEMD5_MUXER
78 static const AVOption framemd5_options[] = {
85 #if CONFIG_HASH_MUXER || CONFIG_MD5_MUXER
102 #if CONFIG_STREAMHASH_MUXER
108 c->hashes =
av_calloc(
s->nb_streams,
sizeof(*
c->hashes));
111 for (
i = 0;
i <
s->nb_streams;
i++) {
122 #if CONFIG_HASH_MUXER || CONFIG_MD5_MUXER || CONFIG_STREAMHASH_MUXER
145 int num_hashes =
c->per_stream ?
s->nb_streams : 1;
146 for (
int i = 0;
i < num_hashes;
i++) {
168 int num_hashes =
c->per_stream ?
s->nb_streams : 1;
169 for (
int i = 0;
i < num_hashes;
i++) {
176 #if CONFIG_HASH_MUXER
184 .write_packet = hash_write_packet,
185 .write_trailer = hash_write_trailer,
189 .p.priv_class = &hash_streamhashenc_class,
194 static const AVClass md5enc_class = {
197 .option = md5_options,
208 .write_packet = hash_write_packet,
209 .write_trailer = hash_write_trailer,
213 .p.priv_class = &md5enc_class,
217 #if CONFIG_STREAMHASH_MUXER
219 .
p.
name =
"streamhash",
224 .init = streamhash_init,
225 .write_packet = hash_write_packet,
226 .write_trailer = hash_write_trailer,
230 .p.priv_class = &hash_streamhashenc_class,
234 #if CONFIG_FRAMEHASH_MUXER || CONFIG_FRAMEMD5_MUXER
239 for (
i = 0;
i <
s->nb_streams;
i++) {
276 framehash_print_extradata(
s);
278 avio_printf(
s->pb,
"#stream#, dts, pts, duration, size, hash\n");
321 #if CONFIG_FRAMEHASH_MUXER
322 static const AVClass framehash_class = {
325 .option = framehash_options,
330 .
p.
name =
"framehash",
335 .init = framehash_init,
336 .write_header = framehash_write_header,
337 .write_packet = framehash_write_packet,
341 .p.priv_class = &framehash_class,
345 #if CONFIG_FRAMEMD5_MUXER
346 static const AVClass framemd5_class = {
349 .option = framemd5_options,
354 .
p.
name =
"framemd5",
359 .init = framehash_init,
360 .write_header = framehash_write_header,
361 .write_packet = framehash_write_packet,
365 .p.priv_class = &framemd5_class,
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
#define AV_HASH_MAX_SIZE
Maximum value that av_hash_get_size() will currently return.
This struct describes the properties of an encoded stream.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static char get_media_type_char(enum AVMediaType type)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
const char * av_hash_get_name(const AVHashContext *ctx)
#define FORMAT_VERSION_OPT
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static void hash_free(struct AVFormatContext *s)
int av_hash_alloc(AVHashContext **ctx, const char *name)
Allocate a hash context for the algorithm specified by name.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
void av_hash_init(AVHashContext *ctx)
Initialize or reset a hash context.
enum AVPacketSideDataType type
const char * av_default_item_name(void *ptr)
Return the context name.
void av_hash_update(AVHashContext *ctx, const uint8_t *src, size_t len)
Update a hash context with additional data.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
void av_hash_freep(AVHashContext **ctx)
Free hash context and set hash context pointer to NULL.
int extradata_size
Size of the extradata content in bytes.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
struct AVHashContext ** hashes
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void * av_calloc(size_t nmemb, size_t size)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
Writes a formatted string to the context.
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...
#define HASH_OPT(defaulttype)
This structure stores compressed data.
int ff_framehash_write_header(AVFormatContext *s)
Set the timebase for each stream from the corresponding codec timebase and print it.