?? invtransform.c
字號:
/*COPYRIGHT, LICENSE AND WARRANTY INFORMATIONThis software module has been originally developed by Nokia Corporation. Provided that a person, entity or a company willing to use the Software (hereinafter Licensee) comply with all the terms and conditions of this Statement and subject to the limitations set forth in this Statement Nokia grants to such Licensee a non-exclusive, sub-licensable, worldwide, limited license under copyrights owned by Nokia to use the Software for the sole purpose of creating, manufacturing, selling, marketing, or distributing (including the right to make modifications to the Software) a fully compliant decoder implementation (hereinafter "Decoder") of ITU-T Recommendation H.264 / ISO/IEC International Standard 14496-10 and an encoder implementation producing output that is decodable with the Decoder.Nokia retains the ownership of copyrights to the Software. There is no patent nor other intellectual property right of Nokia licensed under this Statement (except the copyright license above). Licensee hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if patent licenses are required, it is their responsibility to acquire the license before utilizing the Software.The license by Nokia is subject to that the Licensee grants to Nokia the non-exclusive, worldwide, royalty-free, perpetual and irrevocable covenant that the Licensee(s) shall not bring a suit before any court or administrative agency or otherwise assert a claim for infringement under the Licensee intellectual property rights that, but for a license, would be infringed by the Software against (a) Nokia or Nokia's Affiliate; or (b) other recipient of a license and covenant not to sue with respect to the Software from Nokia; or (c) contractor, customer or distributor of a party listed above in a or b, which suit or claim is related to the Software or use thereof.The Licensee(s) further agrees to grant a reciprocal license to Nokia (as granted by Nokia to the Licensee(s) on the modifications made by Licensee(s) to the Software. THE SOFTWARE IS PROVIDED "AS IS" AND THE ORIGINAL DEVELOPER DISCLAIMS ANY AND ALL WARRANTIES WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. THOSE INTENDING TO USE THE SOFTWARE ARE EXPRESSLY ADVISED THAT ITS USE MAY INFRINGE EXISTING PATENTS AND BE SUBJECT TO ROYALTY PAYMENTS TO PATENT OWNERS. ANYONE USING THE SOFTWARE ON THE BASIS OF THIS LICENSE AGREES TO OBTAIN THE NECESSARY PERMISSIONS FROM ANY AND ALL APPLICABLE PATENT OWNERS FOR SUCH USE.IN NO EVENT SHALL THE ORIGINAL DEVELOPER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.This copyright, license and warranty information notice must be retained in all copies and derivative works of the Software or substantial portions thereof.*/#include "globals.h"#include "invtransform.h"static const int8 dequantCoef[6][16] = { {10, 13, 10, 13, 13, 16, 13, 16, 10, 13, 10, 13, 13, 16, 13, 16}, {11, 14, 11, 14, 14, 18, 14, 18, 11, 14, 11, 14, 14, 18, 14, 18}, {13, 16, 13, 16, 16, 20, 16, 20, 13, 16, 13, 16, 16, 20, 16, 20}, {14, 18, 14, 18, 18, 23, 18, 23, 14, 18, 14, 18, 18, 23, 18, 23}, {16, 20, 16, 20, 20, 25, 20, 25, 16, 20, 16, 20, 20, 25, 20, 25}, {18, 23, 18, 23, 23, 29, 23, 29, 18, 23, 18, 23, 23, 29, 23, 29}};const int8 qpPerTab[52] = { 0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4, 5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8};const int8 qpRemTab[52] = { 0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5, 0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3};/* * * itrIDCT4x4: * * Parameters: * src Source values * dest Inverse transformed values * * Function: * Compute approximate 4x4 inverse DCT. * * Returns: * - */void itrIDCT4x4(int src[4][4]){ int tmp[4][4]; int E; int F; int i; /* * a = A + B + C + (D>>1) * b = A + (B>>1) - C - D * c = A - (B>>1) - C + D * d = A - B + C - (D>>1) * => * E = A + C * F = B + (D>>1) * a = E + F * d = E - F * E = A - C * F = (B>>1) - D * b = E + F * c = E - F */ for (i = 0; i < 4; i++) { E = src[i][0] + src[i][2]; F = src[i][1] + (src[i][3]>>1); tmp[i][0] = E + F; tmp[i][3] = E - F; E = src[i][0] - src[i][2]; F = (src[i][1]>>1) - src[i][3]; tmp[i][1] = E + F; tmp[i][2] = E - F; } for (i = 0; i < 4; i++) { E = tmp[0][i] + tmp[2][i]; F = tmp[1][i] + (tmp[3][i]>>1); src[0][i] = E + F; src[3][i] = E - F; E = tmp[0][i] - tmp[2][i]; F = (tmp[1][i]>>1) - tmp[3][i]; src[1][i] = E + F; src[2][i] = E - F; }}/* * * itrIHada4x4: * * Parameters: * src Source values * dest Inverse transformed values * * Function: * Compute 4x4 inverse Hadamard transform. * * Returns: * - * */void itrIHada4x4(int src[4][4], int dest[4][4]){ int tmp[4][4]; int E; int F; int i; for (i = 0; i < 4; i++) { E = src[i][0] + src[i][2]; F = src[i][1] + src[i][3]; tmp[i][0] = E + F; tmp[i][3] = E - F; E = src[i][0] - src[i][2]; F = src[i][1] - src[i][3]; tmp[i][1] = E + F; tmp[i][2] = E - F; } for (i = 0; i < 4; i++) { E = tmp[0][i] + tmp[2][i]; F = tmp[1][i] + tmp[3][i]; dest[0][i] = E + F; dest[3][i] = E - F; E = tmp[0][i] - tmp[2][i]; F = tmp[1][i] - tmp[3][i]; dest[1][i] = E + F; dest[2][i] = E - F; }}/* * * itrIDCT2x2: * * Parameters: * src Source values * dest Inverse transformed values * * Function: * Compute 2x2 inverse DCT. * * Returns: * - * */void itrIDCT2x2(int src[2][2], int dest[2][2]){ int DDC00 = src[0][0]; int DDC10 = src[0][1]; int DDC01 = src[1][0]; int DDC11 = src[1][1]; int A, B; /* * DDC(0,0) DDC(1,0) => DC0 DC1 * DDC(0,1) DDC(1,1) DC2 DC3 * * DC0 = (DDC00+DDC10+DDC01+DDC11) * DC1 = (DDC00-DDC10+DDC01-DDC11) * DC2 = (DDC00+DDC10-DDC01-DDC11) * DC3 = (DDC00-DDC10-DDC01+DDC11) */ A = DDC00 + DDC01; B = DDC10 + DDC11; dest[0][0] = (A + B); dest[0][1] = (A - B); A = DDC00 - DDC01; B = DDC10 - DDC11; dest[1][0] = (A + B); dest[1][1] = (A - B);}/* * * itrInvQuant4x4: * * Parameters: * src Source values * dest Dequantized values * qp Quantization parameter * n Number of values * * Function: * Dequantize input values. * * Returns: * - * */void itrInvQuant4x4(int *src, int *dest, int qp){ int i; int qp_per = qpPerTab[qp-MIN_QP]; int qp_rem = qpRemTab[qp-MIN_QP]; for (i = 0; i < BLK_SIZE*BLK_SIZE; i ++) dest[i] = src[i]*dequantCoef[qp_rem][i]<<qp_per;}/* * * itrInvQuantDC4x4: * * Parameters: * src Source values * dest Dequantized values * qp Quantization parameter * * Function: * Dequantize 4x4 DC values. * * Returns: * - * */void itrInvQuantDC4x4(int *src, int *dest, int qp){ int i; int qp_per = qpPerTab[qp-MIN_QP]; int qp_rem = qpRemTab[qp-MIN_QP]; int deqc = dequantCoef[qp_rem][0]<<qp_per; for (i = 0; i < 16; i++) dest[i] = (src[i]*deqc+2)>>2;}/* * * itrInvQuantDC2x2: * * Parameters: * src Source values * dest Dequantized values * qp Quantization parameter * * Function: * Dequantize 2x2 DC values. * * Returns: * - * */void itrInvQuantDC2x2(int *src, int *dest, int qp){ int i; int qp_per = qpPerTab[qp-MIN_QP]; int qp_rem = qpRemTab[qp-MIN_QP]; int deqc = dequantCoef[qp_rem][0]<<qp_per; for (i = 0; i < 4; i++) dest[i] = (src[i]*deqc)>>1;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -