[FFmpeg-devel] [PATCH] lxfdec: support version 1 files, too.

Tomas Härdin tomas.hardin at codemill.se
Thu Mar 29 13:37:50 CEST 2012


On Sat, 2012-03-24 at 16:48 +0100, Reimar Döffinger wrote:
> Fixes trac issue #656.
> 
> Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> ---
>  libavformat/lxfdec.c |   92 ++++++++++++++++++++++++++++++++------------------
>  1 files changed, 59 insertions(+), 33 deletions(-)
> 
> diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
> index f82d4f4..b6b6810 100644
> --- a/libavformat/lxfdec.c
> +++ b/libavformat/lxfdec.c
> @@ -20,11 +20,12 @@
>   */
>  
>  #include "libavutil/intreadwrite.h"
> +#include "libavcodec/bytestream.h"
>  #include "avformat.h"
>  #include "internal.h"
>  #include "riff.h"
>  
> -#define LXF_PACKET_HEADER_SIZE  60
> +#define LXF_MAX_PACKET_HEADER_SIZE 256
>  #define LXF_HEADER_DATA_SIZE    120
>  #define LXF_IDENT               "LEITCH\0"
>  #define LXF_IDENT_LENGTH        8
> @@ -49,6 +50,7 @@ typedef struct {
>      int channels;                       ///< number of audio channels. zero means no audio
>      uint8_t temp[LXF_MAX_AUDIO_PACKET]; ///< temp buffer for de-planarizing the audio data
>      int frame_number;                   ///< current video frame
> +    uint32_t video_format, packet_type, extended_size;
>  } LXFDemuxContext;
>  
>  static int lxf_probe(AVProbeData *p)
> @@ -65,12 +67,12 @@ static int lxf_probe(AVProbeData *p)
>   * @param[in] header the packet header to check
>   * @return zero if the checksum is OK, non-zero otherwise
>   */
> -static int check_checksum(const uint8_t *header)
> +static int check_checksum(const uint8_t *header, int size)
>  {
>      int x;
>      uint32_t sum = 0;
>  
> -    for (x = 0; x < LXF_PACKET_HEADER_SIZE; x += 4)
> +    for (x = 0; x < size; x += 4)
>          sum += AV_RL32(&header[x]);

Unsafe if size & 3 != 0. I see it's checked further down though..

> +    if (header_size < (version ? 72 : 60) ||
> +        header_size > LXF_MAX_PACKET_HEADER_SIZE ||
> +        (header_size & 3)) {
> +        av_log(s, AV_LOG_ERROR, "Invalid header size 0x%x\n", header_size);
> +        return AVERROR_INVALIDDATA;
> +    }

.. here. So OK.

> @@ -148,12 +170,16 @@ static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *form
>              break;
>          }
>  
> +        if (version == 0) p += 8;
> +        audio_format                     = bytestream_get_le32(&p);
> +        channels   = bytestream_get_le32(&p);
> +        track_size = bytestream_get_le32(&p);

Odd indentation?

Anyway, OK if all samples at
http://titan.codemill.se/~tomhar/samples/lxf/ work (BARS01.lxf is v1,
maybe a few more).

/Tomas



More information about the ffmpeg-devel mailing list