On 11/21/2011 04:12 PM, Victor Vasiliev wrote:
> ---
> libavformat/wav.c | 70
> ++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 69 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/wav.c b/libavformat/wav.c
> index 298880d..3147093 100644
> --- a/libavformat/wav.c
> +++ b/libavformat/wav.c
> @@ -378,6 +378,66 @@ static const AVMetadataConv wav_metadata_conv[] = {
> {0},
> };
>
> +static const AVMetadataConv wav_info_tag_conv[] = {
> + {"IART", "artist" },
> + {"ICMT", "comment" },
> + {"ICOP", "copyright" },
> + {"ICRD", "creation_date"},
> + {"IGNR", "genre" },
> + {"INAM", "title" },
> + {"ISFT", "encoder" },
> + {0},
> +};
> +
> +static int wav_parse_info_tags(AVFormatContext *s, int64_t size,
> AVStream **stream)
> +{
> + int64_t start, end, cur;
> + AVIOContext *pb = s->pb;
> +
> + start = avio_tell(pb);
> + end = start + size;
> +
> + while ( (cur = avio_tell(pb)) < end) {
avio_tell() can return an error code, so i don't know if comparing it
here without checking that is wise.
> + unsigned int chunk_code;
> + int64_t chunk_size;
> + char *key, *value;
> +
> + chunk_size = next_tag(pb, &chunk_code);
> + if (chunk_size > end || end - chunk_size < cur) {
> + av_log(s, AV_LOG_ERROR, "too big INFO subchunk\n");
> + return AVERROR_INVALIDDATA;
> + }
> +
> + key = av_malloc(4 + 1);
> + value = av_malloc(chunk_size + 1);
> + if (!key || !value) {
> + av_log(s, AV_LOG_ERROR, "out of memory, unable to read
> INFO tag\n");
> + return AVERROR(ENOMEM);
> + }
if allocation of key succeeds but allocation of value fails then key
needs to be freed.
> +
> +#ifdef HAVE_BIG_ENDIAN
> + chunk_code = av_bswap32(chunk_code);
> +#endif
chunk_code = AV_RL32(&chunk_code);
will probably do the same thing. at least i'm pretty sure it does for
big-endian. the little-endian case should be checked to make sure it's a
noop.
Great job! Thanks for doing this.
-Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel