⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rotate_ti_apply.c

📁 TI公司的算法标准 Framework5的源代码
💻 C
字号:
/*
 *  Copyright 2002 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) RF5_IEK 2.00.02 12-11-02 (swat-c19)" */
/*
 *  ======== rotate_ti_apply.c ========
 *  Implementation of the color rotate operation. 
 */

#pragma CODE_SECTION(ROTATE_TI_apply, ".text:apply")

#include <std.h>

#include "irotate.h"
#include "rotate_ti.h"
#include "rotate_ti_priv.h"

    
/*
 *  ======== ROTATE_TI_apply ========
 * Function that rotates cr, cb color plane. 
 */    
Void ROTATE_TI_apply(IROTATE_Handle handle, unsigned char y[], 
                     unsigned char cr[], unsigned char cb[], 
                     Int lumaSize, Int chromaSize, Short cosine, Short sine)
{    
    ROTATE_TI_Obj *rotate = (ROTATE_TI_Obj *)handle;
    Int i;

    Short crTemp;
    Short cbTemp;         
    
    Int crInt;
    Int cbInt;
    
    Short crFin;
    Short cbFin;


    /* Reverse the image's luma if requested. */
    if (rotate->reverseImage == TRUE) {
        for(i = 0; i < lumaSize; i++) {
            y[i] = 255 - y[i];
        }
    }    
    
    for(i = 0; i < chromaSize; i++)
    {
       /* Center pixels around 0, by deducting 128 from both cr and cb. */
       crTemp = cr[i] - 128;
       cbTemp = cb[i] - 128;
       
       /* Rotate cr and cb by multiplying using cosine and sine      */
       crInt = (crTemp * cosine) - (cbTemp * sine);
       cbInt = (crTemp * sine)   + (cbTemp * cosine);

       /* 
        *  Convert Q15 number and add 128 back to center chroma
        *  values around 128.
        */

       crFin = (crInt >> 15) + 128;
       cbFin = (cbInt >> 15) + 128; 

       /* Limit values to the range of 0-255                         */
       cr[i] = crFin & 0xFF;
       cb[i] = cbFin & 0xFF;
    }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -