[libav-devel] [PATCH] asfdec: read values properly

Luca Barbato lu_zero at gentoo.org
Sat Aug 1 15:48:49 CEST 2015


On 01/08/15 14:16, Alexandra Hájková wrote:
> The length of BOOL values is 16 bits in the Metadata Object but
> 32 bits in the Extended Content Description Object.
> ---
>  libavformat/asfdec.c | 40 +++++++++++++++++++++++++++-------------
>  1 file changed, 27 insertions(+), 13 deletions(-)
> 
> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
> index a42120d..4ca253f 100644
> --- a/libavformat/asfdec.c
> +++ b/libavformat/asfdec.c
> @@ -304,17 +304,13 @@ failed:
>      av_freep(&value);
>      return ret;
>  }
> -
> -static int asf_read_generic_value(AVFormatContext *s, const uint8_t *name,
> -                                  uint16_t name_len, int type, AVDictionary **met)
> +static uint64_t asf_read_generic_value(AVIOContext *pb, int type)
>  {
> -    AVIOContext *pb = s->pb;
> -    uint64_t value;
> -    char buf[32];
> +    int64_t value;

why int64_t ?
>  
>      switch (type) {
>      case ASF_BOOL:
> -        value = avio_rl32(pb);
> +        value = avio_rl16(pb);
>          break;
>      case ASF_DWORD:
>          value = avio_rl32(pb);
> @@ -328,6 +324,21 @@ static int asf_read_generic_value(AVFormatContext *s, const uint8_t *name,
>      default:
>          return AVERROR_INVALIDDATA;
>      }
> +
> +    return value;
> +}
> +
> +static int asf_set_metadata(AVFormatContext *s, const uint8_t *name,
> +                            uint16_t name_len, int type, AVDictionary **met)
> +{
> +    AVIOContext *pb = s->pb;
> +    int64_t value;

Same question.

> +    char buf[32];
> +
> +    value = asf_read_generic_value(pb, type);
> +    if (value < 0)
> +        return value;

lu



More information about the libav-devel mailing list