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

📄 tidtv_gammactrl2.c

📁 ti的数字电视芯片 tvp9000的源码
💻 C
字号:
/*******************************************************************************
*  @ModuleName :: TiDTV_GammaCtrl2.c
*
*	@Copyright	::	Copyright 2005- Texas Instruments, Inc.
*
*  @Description:: Functions for TI DTV Gamma Correction APIs
*
*	@History	::
*---------------------------------------
*	07-14-2005	Paul Hunt	Created
*******************************************************************************/

#include <stdio.h>
#include <math.h>
#include <string.h>

#ifndef MS_DEBUG
#include "Tvp9000.h"
#include "TvpError.h"
#include "TvpEncoder.h"
#include "TvpEncoderMem.h"

#include "TiDTV_DataType.h"
#include "ucos_ii.h"
#include "TiDTV_UART.h"
#endif

#include "TiDTV_GammaCtrl2.h"

// Buffers for Encoder LUTs
unsigned char TiDTV_EncRedLUT[256];
unsigned char TiDTV_EncGrnLUT[256];
unsigned char TiDTV_EncBluLUT[256];

/*******************************************************************************
*  @RoutineName:: tvpEncGammaTableGen
*
*  @Description:: Generate and update one or more Gamma tables using
*                 the supplied parameters
*
*  @Input      :: channelFlags specifies which channel(s) to populate
*
*  @Output     :: zero to three Look Up Tables
*
*  @Return     :: none
*******************************************************************************/
void tvpEncGammaTableGen2(unsigned char channelFlags, unsigned short gamma_fix, char inc_gain)
{
   unsigned short i;
   unsigned char gamma_entry;
   short short_entry;
   float float_entry;
   float gamma_float;
   float scale;
   char fstring[80];

   gamma_float = ((float) gamma_fix) / ENC_GAMMA_DIVISOR;
   scale = 1.0 + (inc_gain / 512.0);


   for (i = 0; i < TVP_NUM_LUT_ENTRIES; i++)
   {
      // compute gamma for index i as a function of parms
      float_entry = scale * 255.0 * pow( i/255.0, gamma_float );
      short_entry = (short) float_entry;
      if (short_entry > 255) short_entry = 255;
      gamma_entry = (unsigned char) short_entry;

#ifdef MS_DEBUG
      sprintf(fstring, "i = %d, gamma_entry = %d\n", i, gamma_entry);
	   printf("%s", fstring);
#endif

      // store in selected table(s)

      if (channelFlags & ENC_GAMMA_GEN_GRN) TiDTV_EncGrnLUT[i] = gamma_entry;
      if (channelFlags & ENC_GAMMA_GEN_BLU) TiDTV_EncBluLUT[i] = gamma_entry;
      if (channelFlags & ENC_GAMMA_GEN_RED) TiDTV_EncRedLUT[i] = gamma_entry;

   }
}

#ifndef MS_DEBUG
/*******************************************************************************
*  @RoutineName:: tvpEncLutWrite
*
*  @Description:: Update the LUT data of Encoder
*
*  @Input      :: channelFlags specifies which channel(s) to write to Encoder
*
*  @Output     :: none
*
*  @Return     :: none
*******************************************************************************/
void tvpEncLutWrite(unsigned char channelFlags)
{
   volatile unsigned long *dst_p;
   volatile unsigned char *src_p;
   unsigned long i;

   if (channelFlags & ENC_LUT_WRITE_GRN)
   {
      dst_p = TVP_ENC_LUT0_BASE;
      src_p = TiDTV_EncGrnLUT;

      // Load the new gamma LUT conversion table for Green
      for (i=0; i<TVP_NUM_LUT_ENTRIES; i++)
      {
           *dst_p++ = (unsigned long) *src_p++;
      }
   }

   if (channelFlags & ENC_LUT_WRITE_BLU)
   {
      dst_p = TVP_ENC_LUT1_BASE;
      src_p = TiDTV_EncBluLUT;

      // Load the new gamma LUT conversion table for Blue
      for (i=0; i<TVP_NUM_LUT_ENTRIES; i++)
      {
           *dst_p++ = (unsigned long) *src_p++;
      }
   }

   if (channelFlags & ENC_LUT_WRITE_RED)
   {
      dst_p = TVP_ENC_LUT2_BASE;
      src_p = TiDTV_EncRedLUT;

      // Load the new gamma LUT conversion table for Red
      for (i=0; i<TVP_NUM_LUT_ENTRIES; i++)
      {
           *dst_p++ = (unsigned long) *src_p++;
      }
   }
}
#endif

⌨️ 快捷键说明

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