comparison aiff.c @ 1376:1d7727481acf libavformat

use av_get_bits_per_sample
author bcoudurier
date Wed, 11 Oct 2006 10:17:18 +0000
parents c42cb95fa0d4
children 51f4a1e475f8
comparison
equal deleted inserted replaced
1375:c42cb95fa0d4 1376:1d7727481acf
93 size -= res; 93 size -= res;
94 if (size); 94 if (size);
95 url_fskip(pb, size); 95 url_fskip(pb, size);
96 } 96 }
97 97
98 /* Returns the number of bits per second */
99 static int fix_bps(int codec_id)
100 {
101 switch (codec_id) {
102 case CODEC_ID_PCM_S8:
103 return 8;
104 case CODEC_ID_PCM_S16BE:
105 return 16;
106 case CODEC_ID_PCM_S24BE:
107 return 24;
108 case CODEC_ID_PCM_S32BE:
109 return 32;
110 }
111
112 return -1;
113 }
114
115 /* Returns the number of sound data frames or negative on error */ 98 /* Returns the number of sound data frames or negative on error */
116 static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec, 99 static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec,
117 int size, unsigned version) 100 int size, unsigned version)
118 { 101 {
119 AVExtFloat ext; 102 AVExtFloat ext;
139 codec->codec_tag = get_le32(pb); 122 codec->codec_tag = get_le32(pb);
140 codec->codec_id = codec_get_id (codec_aiff_tags, codec->codec_tag); 123 codec->codec_id = codec_get_id (codec_aiff_tags, codec->codec_tag);
141 124
142 if (codec->codec_id == CODEC_ID_PCM_S16BE) { 125 if (codec->codec_id == CODEC_ID_PCM_S16BE) {
143 codec->codec_id = aiff_codec_get_id (codec->bits_per_sample); 126 codec->codec_id = aiff_codec_get_id (codec->bits_per_sample);
144 codec->bits_per_sample = fix_bps(codec->codec_id); 127 codec->bits_per_sample = av_get_bits_per_sample(codec->codec_id);
145 } 128 }
146 129
147 size -= 4; 130 size -= 4;
148 } else { 131 } else {
149 /* Need the codec type */ 132 /* Need the codec type */
150 codec->codec_id = aiff_codec_get_id (codec->bits_per_sample); 133 codec->codec_id = aiff_codec_get_id (codec->bits_per_sample);
151 codec->bits_per_sample = fix_bps(codec->codec_id); 134 codec->bits_per_sample = av_get_bits_per_sample(codec->codec_id);
152 } 135 }
153 136
154 if (!codec->codec_id) 137 if (!codec->codec_id)
155 return AVERROR_INVALIDDATA; 138 return AVERROR_INVALIDDATA;
156 139