Quantize_MP3

Quantizes spectral coefficients generated by analysis filterbank.

Syntax

IppStatus ippsQuantize_MP3_32s_I(Ipp32s* pSrcDstXrIx, Ipp8s* pDstScalefactor, int* pDstScfsi, int* pDstCount1Len, int* pDstHufSize, IppMP3FrameHeader* pFrameHeader, IppMP3SideInfo* pSideInfo, IppMP3PsychoacousticModelTwoAnalysis* pPsychoInfo, IppMP3PsychoacousticModelTwoState* pFramePsyState, IppMP3BitReservoir* pResv, int meanBits, int* pIsSfbBound, Ipp32s* pWorkBuffer);

Parameters

pSrcDstXrIx

Pointer to the set of unquantized spectral coefficient vectors generated by the analysis filterbank and optionally processed by the joint stereo coding module for one frame.

pDstScaleFactor

Pointer to the output set of scalefactors generated during the quantization process.

pDstScfsi

Pointer to the output vector of scale factor selection information.

pDstCount1Len

Pointer to an output vector of count1 region length specifiers.

pDstHufSize

Pointer to an output vector of Huffman coding bit allocation specifiers.

pFrameHeader

Pointer to the IppMP3FrameHeader structure that contains the header information associated with the current frame.

pSideInfo

Pointer to the set of IppMP3SideInfo structures associated with all granules and channels.

pPsychoInfo

Pointer to the first element in a set of PsychoacousticModelTwoAnalysis structures associated with the current frame.

pFramePsyState

Pointer to the first element in a set of IppMP3PsychoacousticModelTwoState structures that contains the psychoacoustic model state information associated with both the current frame and next frame.

pResv

Pointer to the IppMP3BitReservoir structure that contains the bit reservoir state information. Upon the function entry, all structure fields must contain valid data.

meanBits

The number of bits allocated on an average basis for each frame of spectral coefficients and scalefactors given the target bit rate (kilobits per second) specified in the frame header. This number excludes the bits allocated for the frame header and side information.

pIsSfbBound

Pointer to the list of SFB lower bounds above which all L/R channel spectral coefficients have been combined into an intensity-coded representation.

pWorkBuffer

Pointer to the workspace buffer internally used by the quantizer for storage of intermediate results and other temporary data. The buffer length must be at least 2880 bytes, that is, 720 words of 32-bits each.

Description

The function is declared in the ippac.h file. This function quantizes the spectral coefficients generated by the analysis filterbank such that the resulting distortion, that is, quantization noise, is shaped to match a profile derived from the masked thresholds estimated by the psychoacoustic model.

The set of unquantized coefficients pSrcDstXrIx must be indexed as follows:

pSrcDstXrIx[gr *1152 + ch *576 + i] for stereophonic and dual-mono input sources;

pSrcDstXrIx[gr *576 + i] for monaural, that is, input sources,

where

i = 0,1,...,575 is the spectral coefficient index

gr is the granule index. 0 stands for granule 1, 1 stands for granule 2

ch is the channel index. 0 stands for channel 1, 1 stands for channel 2.

Depending on which type of joint coding has been applied, if any, the coefficients for each channel could be associated with L/R, M/S, and/or intensity representations of the input audio. All coefficients should be represented using the Q5.26 format.

The scalefactors pDstScaleFactor determine the quantizer granularity. Scale factor vector lengths depend on the block mode associated with each granule. The order of the elements is:

1. (granule 1, channel 1)

2. (granule 1, channel 2)

3. (granule 2, channel 1)

4. (granule 2, channel 2).

Given this general organization, the side information for each granule/channel in conjunction with the flags contained in the vector pDstScfsi can be used to determine the precise scale factor vector indices and lengths.

The vector pDstScfsi contains a set of binary flags that indicate whether or not scalefactors are shared across granules of a frame within predefined scale factor selection groups. For example, bands 0,1,2,3,4,5 form one group; bands 6,7,8,9,10 form a second group, as defined in ISO/IEC 11172-3 . The vector is indexed as follows: pDstScfsi[ch][scfsi_band], where

ch is the channel index. 0 stands for channel 1, 1 stands for channel 2.

scfsi_band is the scale factor selection group number:

group 0 includes SFBs 0-5, group 1 includes SFBs 6-10, group 2 includes SFBs 11‑15, group 3 includes SFBs 16-20.

For the purposes of Huffman coding spectral coefficients of a higher frequency than the bigvals region, the count1 parameter indicates the size of the region in which spectral samples can be combined into quadruples for which all elements are of magnitude less than or equal to 1. The vector contains 2*nchan, elements and is indexed as follows: pDstCount1Len[gr* nchan + ch], where

gr is the granule index. 0 stands for granule 1, 1 stands for granule 2.

nchan is the number of channels.

ch is the channel index. 0 stands for channel 1, 1 stands for channel 2.

For each granule/channel, the specifiers indicate the total number of Huffman bits required to represent the quantized spectral coefficients in the bigvals and count1 regions. Whenever necessary, each HufSize bit count is augmented to include the number of bits required to manage the bit reservoir. For frames in which the reservoir has reached the maximum capacity, the quantizer expends the surplus bits by padding with additional bits the Huffman representation of the spectral samples. The HufSize result returned by the quantizer reflects these padding requirements. That is, HufSize [i] is equal to the sum of the number of bits required for Huffman symbols and the number of padding bits. The vector contains 2*nchan, elements and is indexed as follows: pDstHufSize[gr*nchan+ch], where

gr is the granule index. 0 stands for granule 1, 1 stands for granule 2.

nchan is the number of channels.

ch is the channel index. 0 stands for channel 1, 1 stands for channel 2.

Upon the function entry, the structure IppMP3FrameHeader fields samplingFreq, id, mode, and modeExt must contain, respectively, the sample rate associated with the current input audio, the algorithm id, that is, MPEG-1 or MPEG-2, and the joint stereo coding commands generated by the psychoacoustic model. All other pFrameHeader fields are ignored. Only MPEG‑1 (id = 1) is supported.

The set of IppMP3SideInfo structures must contain 2*nchan, elements and must be indexed as follows: pSideInfo[gr* nchan + ch], where

gr is the granule index. 0 stands for granule 1, 1 stands for granule 2.

nchan is the number of channels.

ch is the channel index. 0 stands for channel 1, 1 stands for channel 2.

Upon the function entry, in all set elements the structure fields blockType, mixedBlock, and winSwitch must contain, respectively, the block type indicator (start, short, or stop), filter bank mixed block analysis mode specifier, and window switching flags (normal or blockType) associated with the current input audio. All other pSideInfo fields are ignored upon the function entry and updated upon function exit, as described below under the description of output arguments.

Each member of the set of PsychoacousticModelTwoAnalysis structures contains the MSR and PE estimates for one channel of one granule. The set should contain 2*nchan, elements and is indexed as: pPsychoaInfo[ gr* nchan +ch], where

gr is the granule index. 0 stands for granule 1, 1 stands for granule 2

nchan is the number of channels

ch is the channel index. 0 stands for channel 1, 1 stands for channel 2.

The number of elements in the set of IppMP3PsychoacousticModelTwoState structures is equal to the number of channels contained in the input audio. That is, a separate analysis is carried for each channel. The quantizer uses the frame type look ahead information nextBlockType to manage the bit reservoir. All other structure elements are ignored by the quantizer.

The quantizer uses meanBits as a target allocation for the current frame. Given perceptual bit allocation requirements greater than this target, the quantizer makes use of the surplus bits held in the bit reservoir to satisfy frame-instantaneous demands. Similarly, given perceptual bit allocation requirements below this target, the quantizer will store surplus bits in the bit reservoir for use by future frames.

The number of valid elements pointed to by pIsSfbBound depends upon the block types associated with the granules of the current frame. In particular, the list of SFB bounds pointed to by pIsSfbBound is indexed as follows: pIsSfbBound[3* gr] for long block granules, and pIsSfbBound[3* gr + w] for short block granules, where

gr is the granule index. 0 stands for granule 1, 1 stands for granule 2

w is the block index. 0 stands for block 1, 1 stands for block 2, 2 stands for block 3.

For example, given short-block analysis in granule 1 followed by long block analysis in granule 2, the list of SFB bounds would be expected in the following order: pIsSfbBound[] = {granule 1/block 1, granule 1/block 2, granule 1/block 2, granule 2/long block}.

If a granule is configured for long block analysis, then only a single SFB lower bound decision is expected, whereas three are expected for short block granules. If both MS and intensity coding have been enabled, then the SFB intensity coding lower bound simultaneously represents the upper bound SFB for MS coding. If only MS coding has been enabled, then the SFB bound represents the lowest non‑MS SFB.

Along with meeting perceptual distortion criteria, the quantizer simultaneously adjusts the overall bit allocation to achieve a fixed bit rate target. In accordance with theISO/IEC 11172-3 recommendation, a bit reservoir is maintained in order to meet instantaneous peak rate demands without violating on an average basis the fixed rate constraint. Surplus bits are deposited in the reservoir during frames with lower than average perceptual bit rate requirements. Supplementary bits are withdrawn from the reservoir to satisfy frames with higher-than-average perceptual bit allocation requirements.

The quantizer manages the reservoir and overall bit allocation such that a constant average rate constraint is satisfied. The quantizer operates on a complete frame of data, that is, two granules and either one or two channels, and it should therefore be called once per frame.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when one of the specified pointers is NULL.

ippStsMP3SideInfo

Indicates an error when pSideInfo->winSwitch and pSideInfo->mixedBlock are both defined.

ippStsMP3FrameHeaderErr

Indicates an error when pFrameHeader->samplingFreq or pFrameHeader->id is not correct.

Submit feedback on this help topic

Copyright © 2000 - 2011, Intel Corporation. All rights reserved.