1.4.4.37 libq_q15_MultiplyR2_q15_q15 Function

fractional multiplication of two 16-bit fractional values giving a 16 bit rounded result.

Description

Function libq_q15_MultiplyR2_q15_q15:

Performs fractional multiplication of two 16-bit fractional values and returns a ROUNDED 16-bit fractional result. The function performs a Q15xQ15->Q30 bit multiply with a left shift by 1 to give a Q31 result. This automatic shift left is done to get rid of the extra sign bit that occurs in the interpretation of the fractional multiply result. Saturation is applied to any 32-bit result that overflows. Rounding is applied to the 32-bit SHIFTED result by adding in a weight factor of 2^15, again any overflows are saturated. The TOP 16-bits are extracted and returned. This function is for fractional Qtype data only and it therefore will not give the correct results for true integers (because left shift by 1). This function assumes that the binary point in the 32-bit shifted multiplier output is between bit_16 and bit_15 when the rounding factor is added. For the special case where both inputs equal the MINFACT16, the function returns a value equal to MAXFACT16, i.e. 0x7fff = libq_q15_Mult2_q15_q15(0x8000,0x8000). This function internally calls the libq_q15_mult_q15_q31() routine to perform the actual multiplication and the rounding routine to perform the actual rounding.

This function relates to the ETSI mult_r function.

Parameters

q15 a value in Q1.15

q15 b value in Q1.15

Returns

q15 result - a*b rounded 16-bit signed integer (Q1.15) output value

C

q15 libq_q15_MultiplyR2_q15_q15 (q15, q15);