2012-03-06 18:07:10 +00:00
|
|
|
/*
|
|
|
|
* common code shared by all WMA variants
|
|
|
|
*
|
|
|
|
* This file is part of Libav.
|
|
|
|
*
|
|
|
|
* Libav is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Libav is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with Libav; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libavutil/attributes.h"
|
2014-09-02 19:28:50 +00:00
|
|
|
|
2012-03-06 18:07:10 +00:00
|
|
|
#include "wma_common.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
*@brief Get the samples per frame for this stream.
|
|
|
|
*@param sample_rate output sample_rate
|
|
|
|
*@param version wma version
|
|
|
|
*@param decode_flags codec compression features
|
|
|
|
*@return log2 of the number of output samples per frame
|
|
|
|
*/
|
2012-03-30 21:34:22 +00:00
|
|
|
av_cold int ff_wma_get_frame_len_bits(int sample_rate, int version,
|
2012-03-06 18:07:10 +00:00
|
|
|
unsigned int decode_flags)
|
|
|
|
{
|
|
|
|
int frame_len_bits;
|
|
|
|
|
2014-09-02 19:28:50 +00:00
|
|
|
if (sample_rate <= 16000)
|
2012-03-06 18:07:10 +00:00
|
|
|
frame_len_bits = 9;
|
2014-09-02 19:28:50 +00:00
|
|
|
else if (sample_rate <= 22050 || (sample_rate <= 32000 && version == 1))
|
2012-03-06 18:07:10 +00:00
|
|
|
frame_len_bits = 10;
|
2014-09-02 19:28:50 +00:00
|
|
|
else if (sample_rate <= 48000 || version < 3)
|
2012-03-06 18:07:10 +00:00
|
|
|
frame_len_bits = 11;
|
2014-09-02 19:28:50 +00:00
|
|
|
else if (sample_rate <= 96000)
|
2012-03-06 18:07:10 +00:00
|
|
|
frame_len_bits = 12;
|
2014-09-02 19:28:50 +00:00
|
|
|
else
|
2012-03-06 18:07:10 +00:00
|
|
|
frame_len_bits = 13;
|
|
|
|
|
|
|
|
if (version == 3) {
|
|
|
|
int tmp = decode_flags & 0x6;
|
2014-09-02 19:28:50 +00:00
|
|
|
if (tmp == 0x2)
|
2012-03-06 18:07:10 +00:00
|
|
|
++frame_len_bits;
|
2014-09-02 19:28:50 +00:00
|
|
|
else if (tmp == 0x4)
|
2012-03-06 18:07:10 +00:00
|
|
|
--frame_len_bits;
|
2014-09-02 19:28:50 +00:00
|
|
|
else if (tmp == 0x6)
|
2012-03-06 18:07:10 +00:00
|
|
|
frame_len_bits -= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return frame_len_bits;
|
|
|
|
}
|