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

📄 image_lbt.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  * QccPack: Quantization, compression, and coding libraries * Copyright (C) 1997-2009  James E. Fowler *  * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. *  * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, * MA 02139, USA. *  *//* Written by VIJAY SHAH, at Mississippi State University, 2005 */#include "libQccPack.h"#define QCCIMGLBT_PREFILTER 0#define QCCIMGLBT_POSTFILTER 1static int QccIMGImageComponentLBTCreateDCTII(QccMatrix dct2_matrix, int M){  double temp1;  double temp2;  int i, j;    for (i = 0; i < M; i++)    {      temp1 = 2 * i + 1;      for (j = 0; j < M; j++)        {          temp2 = j;          dct2_matrix[i][j] =            sqrt(2.0 / (double)M) *            cos((temp1 * temp2 * M_PI) / (double)(2 * M));          if (j == 0)            dct2_matrix[i][j] = dct2_matrix[i][j] / sqrt(2.0);        }    }    return(0);}static int QccIMGImageComponentLBTCreateDCTIV(QccMatrix dct4_matrix,                                              int M){  double temp1;  double temp2;  int i, j;    for (i = 0; i < M; i++)    {      temp1 = 2 * i + 1;      for (j = 0; j < M; j++)        {          temp2 = 2 * j + 1;          dct4_matrix[i][j] =            sqrt(2.0 / (double)M) *            cos((temp1 * temp2 * M_PI) / (double)(4 * M));        }    }  return(0);}static int QccIMGImageComponentLBTCreateV(QccMatrix v_filter,                                          int N,                                          int M,                                          double s1){  int return_value;  QccMatrix dct2_matrix = NULL;  QccMatrix dct4_matrix = NULL;  QccMatrix I = NULL;  QccMatrix J = NULL;  QccMatrix S = NULL;  QccMatrix temp_V = NULL;  QccMatrix temp1_V = NULL;  QccMatrix temp2_V = NULL;  int mn;  int i, j;    mn = (int)((M - (2 * N)) / 2);    if ((dct4_matrix = QccMatrixAlloc(N, N)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixAlloc()");      goto Error;    }    if ((dct2_matrix = QccMatrixAlloc(N, N)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixAlloc()");      goto Error;    }    if ((I = QccMatrixAlloc(N, N)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixAlloc()");      goto Error;    }    if ((J = QccMatrixAlloc(N, N)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixAlloc()");      goto Error;    }    if ((S = QccMatrixAlloc(N, N)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixAlloc()");      goto Error;    }    if ((temp_V = QccMatrixAlloc(N, N)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixAlloc()");      goto Error;    }  if ((temp1_V = QccMatrixAlloc(N, N)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixAlloc()");      goto Error;    }  if ((temp2_V = QccMatrixAlloc(N, N)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixAlloc()");      goto Error;    }     for (i = 0; i < N; i++)    for (j = 0;j < N; j++)      if (i == j)        {          J[i][N - j - 1] = 1;          S[i][j] = 1;        }      else        {          J[i][N - j - 1] = 0;          S[i][j] = 0;        }  S[0][0] = s1;  if (QccIMGImageComponentLBTCreateDCTIV(dct4_matrix, N))    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccIMGImageComponentLBTCreateDCTIV()");      goto Error;    }   if (QccIMGImageComponentLBTCreateDCTII(dct2_matrix, N))    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccIMGImageComponentLBTCreateDCTII()");      goto Error;    }     if (QccMatrixMultiply(J, N, N,                        dct2_matrix, N, N,                        temp_V))    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixMultiply()");      goto Error;    }     if (QccMatrixMultiply(temp_V, N, N,                        S, N, N,                        temp1_V))    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixMultiply()");      goto Error;    }     if (QccMatrixMultiply(dct4_matrix, N, N,                        J, N, N,                        temp_V))    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixMultiply()");      goto Error;    }     if (QccMatrixMultiply(temp1_V, N, N,                        temp_V, N, N,                        temp2_V))    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreateV): Error calling QccMatrixMultiply()");      goto Error;    }     for (i = 0; i < N + mn; i++)    for (j = 0; j < N + mn; j++)      if ((i < N) && (j < N))        v_filter[i][j] = temp2_V[i][j];      else        if ((i >= N) && (i == j))          v_filter[i][j] = 1;        else          v_filter[i][j] = 0;    return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccMatrixFree(dct2_matrix, N);   QccMatrixFree(dct4_matrix, N);   QccMatrixFree(I, N);   QccMatrixFree(J, N);   QccMatrixFree(S, N);   QccMatrixFree(temp_V, N);   QccMatrixFree(temp1_V, N);   QccMatrixFree(temp2_V, N);   return(return_value);} static int QccIMGImageComponentLBTCreateFilter(QccMatrix p_filter,                                               int N,                                               int f_size,                                               double s1,                                               int transform_direction){  int return_value;  int M;  int i, j;  QccMatrix v_filter = NULL;  QccMatrix bf1 = NULL;  QccMatrix bf2 = NULL;  QccMatrix temp_P = NULL;    M = f_size / 2;    if ((v_filter = QccMatrixAlloc(M, M)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreate): Error calling QccMatrixAlloc()");      goto Error;    }    if ((bf1 = QccMatrixAlloc(f_size, f_size)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreate): Error calling QccMatrixAlloc()");      goto Error;    }    if ((bf2 = QccMatrixAlloc(f_size, f_size)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreate): Error calling QccMatrixAlloc()");      goto Error;    }    if ((temp_P = QccMatrixAlloc(f_size, f_size)) == NULL)    {      QccErrorAddMessage("(QccIMGImageComponentLBTCreate): Error calling QccMatrixAlloc()");      goto Error;    }    QccMatrixZero(bf1, f_size, f_size);  QccMatrixZero(bf2, f_size, f_size);    for (i = 0; i < f_size; i++)    for (j = 0; j < f_size; j++)      if (i == j)        {          if(i >= M)            bf1[i][j] = -1;          else            bf1[i][j] = 1;                    bf1[i][f_size - j - 1] = 1;        }    if (QccIMGImageComponentLBTCreateV(v_filter, N, f_size, s1))    {

⌨️ 快捷键说明

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