]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/aiff.c
make it clear that the new metadata API is a work in progress
[ffmpeg] / libavformat / aiff.c
index 3dabbb81e9a98c10ad9dda1a9d031ae797a4007e..70569ed5a90c6e7a7c12d09f229f793adb52b0ef 100644 (file)
@@ -46,7 +46,7 @@ static const AVCodecTag codec_aiff_tags[] = {
 #define AIFF                    0
 #define AIFF_C_VERSION1         0xA2805140
 
-static int aiff_codec_get_id(int bps)
+static enum CodecID aiff_codec_get_id(int bps)
 {
     if (bps <= 8)
         return CODEC_ID_PCM_S8;
@@ -58,7 +58,7 @@ static int aiff_codec_get_id(int bps)
         return CODEC_ID_PCM_S32BE;
 
     /* bigger than 32 isn't allowed  */
-    return 0;
+    return CODEC_ID_NONE;
 }
 
 /* returns the size of the found tag */
@@ -112,7 +112,7 @@ static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec,
     codec->codec_type = CODEC_TYPE_AUDIO;
     codec->channels = get_be16(pb);
     num_frames = get_be32(pb);
-    codec->bits_per_sample = get_be16(pb);
+    codec->bits_per_coded_sample = get_be16(pb);
 
     get_buffer(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
     sample_rate = av_ext2dbl(ext);          /* 80 bits BE IEEE extended float */
@@ -126,8 +126,8 @@ static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec,
 
         switch (codec->codec_id) {
         case CODEC_ID_PCM_S16BE:
-            codec->codec_id = aiff_codec_get_id(codec->bits_per_sample);
-            codec->bits_per_sample = av_get_bits_per_sample(codec->codec_id);
+            codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
+            codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
             break;
         case CODEC_ID_ADPCM_IMA_QT:
             codec->block_align = 34*codec->channels;
@@ -141,20 +141,24 @@ static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec,
             codec->block_align = 1*codec->channels;
             codec->frame_size = 6;
             break;
+        case CODEC_ID_GSM:
+            codec->block_align = 33;
+            codec->frame_size = 160;
+            break;
         default:
             break;
         }
         size -= 4;
     } else {
         /* Need the codec type */
-        codec->codec_id = aiff_codec_get_id(codec->bits_per_sample);
-        codec->bits_per_sample = av_get_bits_per_sample(codec->codec_id);
+        codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
+        codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
     }
 
     /* Block align needs to be computed in all cases, as the definition
      * is specific to applications -> here we use the WAVE format definition */
     if (!codec->block_align)
-        codec->block_align = (codec->bits_per_sample * codec->channels) >> 3;
+        codec->block_align = (codec->bits_per_coded_sample * codec->channels) >> 3;
 
     codec->bit_rate = (codec->frame_size ? codec->sample_rate/codec->frame_size :
                        codec->sample_rate) * (codec->block_align << 3);
@@ -166,11 +170,11 @@ static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec,
     return num_frames;
 }
 
-#ifdef CONFIG_MUXERS
+#if CONFIG_AIFF_MUXER
 typedef struct {
-    offset_t form;
-    offset_t frames;
-    offset_t ssnd;
+    int64_t form;
+    int64_t frames;
+    int64_t ssnd;
 } AIFFOutputContext;
 
 static int aiff_write_header(AVFormatContext *s)
@@ -194,7 +198,7 @@ static int aiff_write_header(AVFormatContext *s)
     put_tag(pb, aifc ? "AIFC" : "AIFF");
 
     if (aifc) { // compressed audio
-        enc->bits_per_sample = 16;
+        enc->bits_per_coded_sample = 16;
         if (!enc->block_align) {
             av_log(s, AV_LOG_ERROR, "block align not set\n");
             return -1;
@@ -213,16 +217,16 @@ static int aiff_write_header(AVFormatContext *s)
     aiff->frames = url_ftell(pb);
     put_be32(pb, 0);              /* Number of frames */
 
-    if (!enc->bits_per_sample)
-        enc->bits_per_sample = av_get_bits_per_sample(enc->codec_id);
-    if (!enc->bits_per_sample) {
+    if (!enc->bits_per_coded_sample)
+        enc->bits_per_coded_sample = av_get_bits_per_sample(enc->codec_id);
+    if (!enc->bits_per_coded_sample) {
         av_log(s, AV_LOG_ERROR, "could not compute bits per sample\n");
         return -1;
     }
     if (!enc->block_align)
-        enc->block_align = (enc->bits_per_sample * enc->channels) >> 3;
+        enc->block_align = (enc->bits_per_coded_sample * enc->channels) >> 3;
 
-    put_be16(pb, enc->bits_per_sample); /* Sample size */
+    put_be16(pb, enc->bits_per_coded_sample); /* Sample size */
 
     sample_rate = av_dbl2ext((double)enc->sample_rate);
     put_buffer(pb, (uint8_t*)&sample_rate, sizeof(sample_rate));
@@ -261,7 +265,7 @@ static int aiff_write_trailer(AVFormatContext *s)
     AVCodecContext *enc = s->streams[0]->codec;
 
     /* Chunks sizes must be even */
-    offset_t file_size, end_size;
+    int64_t file_size, end_size;
     end_size = file_size = url_ftell(pb);
     if (file_size & 1) {
         put_byte(pb, 0);
@@ -289,7 +293,7 @@ static int aiff_write_trailer(AVFormatContext *s)
 
     return 0;
 }
-#endif //CONFIG_MUXERS
+#endif /* CONFIG_AIFF_MUXER */
 
 static int aiff_probe(AVProbeData *p)
 {
@@ -308,7 +312,7 @@ static int aiff_read_header(AVFormatContext *s,
                             AVFormatParameters *ap)
 {
     int size, filesize;
-    offset_t offset = 0;
+    int64_t offset = 0;
     uint32_t tag;
     unsigned version = AIFF_C_VERSION1;
     ByteIOContext *pb = s->pb;
@@ -435,7 +439,7 @@ static int aiff_read_packet(AVFormatContext *s,
     return 0;
 }
 
-#ifdef CONFIG_AIFF_DEMUXER
+#if CONFIG_AIFF_DEMUXER
 AVInputFormat aiff_demuxer = {
     "aiff",
     NULL_IF_CONFIG_SMALL("Audio IFF"),
@@ -445,11 +449,11 @@ AVInputFormat aiff_demuxer = {
     aiff_read_packet,
     NULL,
     pcm_read_seek,
-    .codec_tag= (const AVCodecTag*[]){codec_aiff_tags, 0},
+    .codec_tag= (const AVCodecTag* const []){codec_aiff_tags, 0},
 };
 #endif
 
-#ifdef CONFIG_AIFF_MUXER
+#if CONFIG_AIFF_MUXER
 AVOutputFormat aiff_muxer = {
     "aiff",
     NULL_IF_CONFIG_SMALL("Audio IFF"),
@@ -461,6 +465,6 @@ AVOutputFormat aiff_muxer = {
     aiff_write_header,
     aiff_write_packet,
     aiff_write_trailer,
-    .codec_tag= (const AVCodecTag*[]){codec_aiff_tags, 0},
+    .codec_tag= (const AVCodecTag* const []){codec_aiff_tags, 0},
 };
 #endif