|
|
|
@ -51,23 +51,28 @@ static int vqf_probe(const AVProbeData *probe_packet) |
|
|
|
|
return AVPROBE_SCORE_EXTENSION; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void add_metadata(AVFormatContext *s, uint32_t tag, |
|
|
|
|
static int add_metadata(AVFormatContext *s, uint32_t tag, |
|
|
|
|
unsigned int tag_len, unsigned int remaining) |
|
|
|
|
{ |
|
|
|
|
int len = FFMIN(tag_len, remaining); |
|
|
|
|
char *buf, key[5] = {0}; |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
if (len == UINT_MAX) |
|
|
|
|
return; |
|
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
|
|
|
|
|
buf = av_malloc(len+1); |
|
|
|
|
if (!buf) |
|
|
|
|
return; |
|
|
|
|
if (len != avio_read(s->pb, buf, len)) |
|
|
|
|
return; |
|
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
|
|
|
|
|
ret = avio_read(s->pb, buf, len); |
|
|
|
|
if (ret < 0) |
|
|
|
|
return ret; |
|
|
|
|
if (len != ret) |
|
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
buf[len] = 0; |
|
|
|
|
AV_WL32(key, tag); |
|
|
|
|
av_dict_set(&s->metadata, key, buf, AV_DICT_DONT_STRDUP_VAL); |
|
|
|
|
return av_dict_set(&s->metadata, key, buf, AV_DICT_DONT_STRDUP_VAL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static const AVMetadataConv vqf_metadata_conv[] = { |
|
|
|
@ -165,7 +170,9 @@ static int vqf_read_header(AVFormatContext *s) |
|
|
|
|
avio_skip(s->pb, FFMIN(len, header_size)); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
add_metadata(s, chunk_tag, len, header_size); |
|
|
|
|
ret = add_metadata(s, chunk_tag, len, header_size); |
|
|
|
|
if (ret < 0) |
|
|
|
|
return ret; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|