[FFmpeg-devel] [PATCH] iff: support IFF MAUD

Peter Ross pross at xvid.org
Thu Nov 29 08:46:55 CET 2012


On Thu, Nov 29, 2012 at 06:06:59AM +0100, Piotr Bandurski wrote:
> info:
> 
> http://lclevy.free.fr/amiga/MAUDINFO.TXT
> 
> samples:
> 
> http://www.datafilehost.com/download-e7d22dd6.html

> diff --git a/libavformat/iff.c b/libavformat/iff.c
> index c8936d3..18d8f31 100644
> --- a/libavformat/iff.c
> +++ b/libavformat/iff.c
> @@ -38,6 +38,9 @@
>  
>  #define ID_8SVX       MKTAG('8','S','V','X')
>  #define ID_16SV       MKTAG('1','6','S','V')
> +#define ID_MAUD       MKTAG('M','A','U','D')
> +#define ID_MHDR       MKTAG('M','H','D','R')
> +#define ID_MDAT       MKTAG('M','D','A','T')
>  #define ID_VHDR       MKTAG('V','H','D','R')
>  #define ID_ATAK       MKTAG('A','T','A','K')
>  #define ID_RLSE       MKTAG('R','L','S','E')
> @@ -91,6 +94,8 @@ typedef struct {
>      uint32_t  body_size;
>      uint32_t  sent_bytes;
>      svx8_compression_type   svx8_compression;
> +    unsigned  maud_bits;
> +    unsigned  maud_compression;
>      unsigned  bitmap_compression;  ///< delta compression method used
>      unsigned  bpp;          ///< bits per plane to decode (differs from bits_per_coded_sample if HAM)
>      unsigned  ham;          ///< 0 if non-HAM or number of hold bits (6 for bpp > 6, 4 otherwise)
> @@ -125,6 +130,7 @@ static int iff_probe(AVProbeData *p)
>      if (  AV_RL32(d)   == ID_FORM &&
>           (AV_RL32(d+8) == ID_8SVX ||
>            AV_RL32(d+8) == ID_16SV ||
> +          AV_RL32(d+8) == ID_MAUD ||
>            AV_RL32(d+8) == ID_PBM  ||
>            AV_RL32(d+8) == ID_ACBM ||
>            AV_RL32(d+8) == ID_DEEP ||
> @@ -184,9 +190,42 @@ static int iff_read_header(AVFormatContext *s)
>              }
>              break;
>  
> +        case ID_MHDR:
> +            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
> +
> +            iff->maud_bits = -1;
> +            iff->maud_compression = -1;
> +            if (data_size < 32)
> +                return AVERROR_INVALIDDATA;
> +            avio_skip(pb, 4);
> +            iff->maud_bits = avio_rb16(pb);
> +            avio_skip(pb, 2);
> +            st->codec->sample_rate = avio_rb32(pb);
> +            avio_skip(pb, 4);
> +            st->codec->channels = avio_rb16(pb);
> +            iff->maud_compression = avio_rb16(pb);
> +            if (iff->maud_bits != 8 && iff->maud_bits != 16) {
> +                av_log_ask_for_sample(s, "unsupported bit depth (%d)", iff->maud_bits);
> +                return AVERROR_PATCHWELCOME;
> +            }
> +            if (st->codec->channels == 1)
> +                st->codec->channel_layout = AV_CH_LAYOUT_MONO;
> +            else if (st->codec->channels == 2)
> +                st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
> +            else {
> +                av_log_ask_for_sample(s, "unsupported number of channels (%d)", st->codec->channels);
> +                return AVERROR_PATCHWELCOME;
> +            }
> +            if (iff->maud_compression != 0) {
> +                av_log_ask_for_sample(s, "unsupported compression (%d)", st->codec->channels);
> +                return AVERROR_PATCHWELCOME;
> +            }
> +            break;
> +
>          case ID_ABIT:
>          case ID_BODY:
>          case ID_DBOD:
> +        case ID_MDAT:
>              iff->body_pos = avio_tell(pb);
>              iff->body_size = data_size;
>              break;
> @@ -305,7 +344,12 @@ static int iff_read_header(AVFormatContext *s)
>  
>          if (st->codec->codec_tag == ID_16SV)
>              st->codec->codec_id = AV_CODEC_ID_PCM_S16BE_PLANAR;
> -        else {
> +        else if (st->codec->codec_tag == ID_MAUD) {
> +            if (iff->maud_bits == 8)
> +                st->codec->codec_id = AV_CODEC_ID_PCM_U8;
> +            else
> +                st->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
> +        } else {
>          switch (iff->svx8_compression) {
>          case COMP_NONE:
>              st->codec->codec_id = AV_CODEC_ID_PCM_S8_PLANAR;

Looks good.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121129/369f1977/attachment.asc>


More information about the ffmpeg-devel mailing list