Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 1 | /* |
| 2 | * common code shared by all WMA variants |
| 3 | * |
Thilo Borgmann | d814a83 | 2013-08-15 21:12:51 | [diff] [blame] | 4 | * This file is part of FFmpeg. |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 5 | * |
Thilo Borgmann | d814a83 | 2013-08-15 21:12:51 | [diff] [blame] | 6 | * FFmpeg is free software; you can redistribute it and/or |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
Thilo Borgmann | d814a83 | 2013-08-15 21:12:51 | [diff] [blame] | 11 | * FFmpeg is distributed in the hope that it will be useful, |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
Thilo Borgmann | d814a83 | 2013-08-15 21:12:51 | [diff] [blame] | 17 | * License along with FFmpeg; if not, write to the Free Software |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include "libavutil/attributes.h" |
Gabriel Dume | d2a4e4b | 2014-09-02 19:28:50 | [diff] [blame] | 22 | |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 23 | #include "wma_common.h" |
| 24 | |
| 25 | /** |
| 26 | *@brief Get the samples per frame for this stream. |
| 27 | *@param sample_rate output sample_rate |
| 28 | *@param version wma version |
| 29 | *@param decode_flags codec compression features |
| 30 | *@return log2 of the number of output samples per frame |
| 31 | */ |
Diego Biurrun | 3dde147 | 2012-03-30 21:34:22 | [diff] [blame] | 32 | av_cold int ff_wma_get_frame_len_bits(int sample_rate, int version, |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 33 | unsigned int decode_flags) |
| 34 | { |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 35 | int frame_len_bits; |
| 36 | |
Gabriel Dume | d2a4e4b | 2014-09-02 19:28:50 | [diff] [blame] | 37 | if (sample_rate <= 16000) |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 38 | frame_len_bits = 9; |
Gabriel Dume | d2a4e4b | 2014-09-02 19:28:50 | [diff] [blame] | 39 | else if (sample_rate <= 22050 || (sample_rate <= 32000 && version == 1)) |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 40 | frame_len_bits = 10; |
Gabriel Dume | d2a4e4b | 2014-09-02 19:28:50 | [diff] [blame] | 41 | else if (sample_rate <= 48000 || version < 3) |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 42 | frame_len_bits = 11; |
Gabriel Dume | d2a4e4b | 2014-09-02 19:28:50 | [diff] [blame] | 43 | else if (sample_rate <= 96000) |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 44 | frame_len_bits = 12; |
Gabriel Dume | d2a4e4b | 2014-09-02 19:28:50 | [diff] [blame] | 45 | else |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 46 | frame_len_bits = 13; |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 47 | |
| 48 | if (version == 3) { |
| 49 | int tmp = decode_flags & 0x6; |
Gabriel Dume | d2a4e4b | 2014-09-02 19:28:50 | [diff] [blame] | 50 | if (tmp == 0x2) |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 51 | ++frame_len_bits; |
Gabriel Dume | d2a4e4b | 2014-09-02 19:28:50 | [diff] [blame] | 52 | else if (tmp == 0x4) |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 53 | --frame_len_bits; |
Gabriel Dume | d2a4e4b | 2014-09-02 19:28:50 | [diff] [blame] | 54 | else if (tmp == 0x6) |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 55 | frame_len_bits -= 2; |
Diego Biurrun | 8ca6e52 | 2012-03-06 18:07:10 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | return frame_len_bits; |
| 59 | } |