On Tue, May 28, 2013 at 11:05:49AM +0200, Anton Khirnov wrote:
> ---
>  libavformat/Makefile      |    2 +-
>  libavformat/matroskaenc.c |   82 
> ++++++++++++++++++++++++++++++++++++++++++++-
>  tests/Makefile            |    2 ++
>  tests/fate/wavpack.mak    |   10 ++++++
>  4 files changed, 94 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 2883612..06c6ad8 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -160,7 +160,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)          += matroskadec.o 
> matroska.o  \
>                                              isom.o rmsipr.o
>  OBJS-$(CONFIG_MATROSKA_MUXER)            += matroskaenc.o matroska.o \
>                                              isom.o avc.o \
> -                                            flacenc_header.o avlanguage.o
> +                                            flacenc_header.o avlanguage.o 
> wv.o
>  OBJS-$(CONFIG_MD5_MUXER)                 += md5enc.o
>  OBJS-$(CONFIG_MJPEG_DEMUXER)             += rawdec.o
>  OBJS-$(CONFIG_MJPEG_MUXER)               += rawenc.o
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index c521ed3..3bf1015 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -27,6 +27,7 @@
>  #include "isom.h"
>  #include "matroska.h"
>  #include "riff.h"
> +#include "wv.h"
>  
>  #include "libavutil/avstring.h"
>  #include "libavutil/dict.h"
> @@ -450,6 +451,15 @@ static int put_xiph_codecpriv(AVFormatContext *s, 
> AVIOContext *pb, AVCodecContex
>      return 0;
>  }
>  
> +static int put_wv_codecpriv(AVIOContext *pb, AVCodecContext *codec)
> +{
> +    if (codec->extradata && codec->extradata_size == 2)
> +        avio_write(pb, codec->extradata, 2);
> +    else
> +        avio_wl16(pb, 0x403); // fallback to the version mentioned in 
> matroska specs
> +    return 0;
> +}
> +
>  static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, 
> int *sample_rate, int *output_sample_rate)
>  {
>      MPEG4AudioConfig mp4ac;
> @@ -479,6 +489,8 @@ static int mkv_write_codecprivate(AVFormatContext *s, 
> AVIOContext *pb, AVCodecCo
>              ret = put_xiph_codecpriv(s, dyn_cp, codec);
>          else if (codec->codec_id == AV_CODEC_ID_FLAC)
>              ret = ff_flac_write_header(dyn_cp, codec, 1);
> +        else if (codec->codec_id == AV_CODEC_ID_WAVPACK)
> +            ret = put_wv_codecpriv(dyn_cp, codec);
>          else if (codec->codec_id == AV_CODEC_ID_H264)
>              ret = ff_isom_write_avcc(dyn_cp, codec->extradata, 
> codec->extradata_size);
>          else if (codec->codec_id == AV_CODEC_ID_ALAC) {
> @@ -1054,6 +1066,68 @@ static int mkv_write_ass_blocks(AVFormatContext *s, 
> AVIOContext *pb, AVPacket *p
>      return max_duration;
>  }
>  
> +static int mkv_strip_wavpack(const uint8_t *src, uint8_t **pdst, int *size)
> +{
> +    uint8_t *dst = NULL;
> +    int dstlen   = 0;
> +    int srclen   = *size;
> +    int offset   = 0;
> +    int ret;

I'd suggest simply allocate dst with the size of srclen once and do not bother
with reallocations later.

In general LGTM.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to