| @@ -2037,21 +2037,15 @@ int av_get_bits_per_sample(enum AVCodecID codec_id) · 2036 unmodified lines |
| 2037 | 2037 | } |
| 2038 | 2038 | } |
| 2039 | 2039 | |
| 2040 | | −int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) |
| 2040 | +static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, |
| 2041 | + uint32_t tag, int bits_per_coded_sample, int frame_bytes) |
| 2041 | 2042 | { |
| 2042 | | − int id, sr, ch, ba, tag, bps; |
| 2043 | | − |
| 2044 | | − id = avctx->codec_id; |
| 2045 | | − sr = avctx->sample_rate; |
| 2046 | | − ch = avctx->channels; |
| 2047 | | − ba = avctx->block_align; |
| 2048 | | − tag = avctx->codec_tag; |
| 2049 | | − bps = av_get_exact_bits_per_sample(avctx->codec_id); |
| 2043 | + int bps = av_get_exact_bits_per_sample(id); |
| 2050 | 2044 | |
| 2051 | 2045 | /* codecs with an exact constant bits per sample */ |
| 2052 | 2046 | if (bps > 0 && ch > 0 && frame_bytes > 0) |
| 2053 | 2047 | return (frame_bytes * 8) / (bps * ch); |
| 2054 | | − bps = avctx->bits_per_coded_sample; |
| 2048 | + bps = bits_per_coded_sample; |
| 2055 | 2049 | |
| 2056 | 2050 | /* codecs with a fixed packet duration */ |
| 2057 | 2051 | switch (id) { |
| @@ -2155,7 +2149,7 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) · 97 unmodified lines |
| 2155 | 2149 | if (ba > 0) { |
| 2156 | 2150 | /* calc from frame_bytes, channels, and block_align */ |
| 2157 | 2151 | int blocks = frame_bytes / ba; |
| 2158 | | − switch (avctx->codec_id) { |
| 2152 | + switch (id) { |
| 2159 | 2153 | case AV_CODEC_ID_ADPCM_IMA_WAV: |
| 2160 | 2154 | return blocks * (1 + (ba - 4 * ch) / (4 * ch) * 8); |
| 2161 | 2155 | case AV_CODEC_ID_ADPCM_IMA_DK3: |
| @@ -2169,7 +2163,7 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) · 7 unmodified lines |
| 2169 | 2163 | |
| 2170 | 2164 | if (bps > 0) { |
| 2171 | 2165 | /* calc from frame_bytes, channels, and bits_per_coded_sample */ |
| 2172 | | − switch (avctx->codec_id) { |
| 2166 | + switch (id) { |
| 2173 | 2167 | case AV_CODEC_ID_PCM_DVD: |
| 2174 | 2168 | return 2 * (frame_bytes / ((bps * 2 / 8) * ch)); |
| 2175 | 2169 | case AV_CODEC_ID_PCM_BLURAY: |
| @@ -2184,6 +2178,22 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) · 8 unmodified lines |
| 2184 | 2178 | return 0; |
| 2185 | 2179 | } |
| 2186 | 2180 | |
| 2181 | +int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) |
| 2182 | +{ |
| 2183 | + return get_audio_frame_duration(avctx->codec_id, avctx->sample_rate, |
| 2184 | + avctx->channels, avctx->block_align, |
| 2185 | + avctx->codec_tag, avctx->bits_per_coded_sample, |
| 2186 | + frame_bytes); |
| 2187 | +} |
| 2188 | + |
| 2189 | +int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes) |
| 2190 | +{ |
| 2191 | + return get_audio_frame_duration(par->codec_id, par->sample_rate, |
| 2192 | + par->channels, par->block_align, |
| 2193 | + par->codec_tag, par->bits_per_coded_sample, |
| 2194 | + frame_bytes); |
| 2195 | +} |
| 2196 | + |
| 2187 | 2197 | #if !HAVE_THREADS |
| 2188 | 2198 | int ff_thread_init(AVCodecContext *s) |
| 2189 | 2199 | { |