编解码标准H264 与 AVS 变换矩阵比较 使用的代码

mac2022-06-30  74

/ test_11.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <vector> #include <iostream> #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <Windows.h> using  namespace std; #define PI   3.1415926 // 一维离散余弦变换 // 参数data为一维输入信号,N一维信号的长度 BOOL D1_DCT(double *data,int N) {     if(N <= 0)         return false;     double *newData = new double[N];     for(int j = 0; j < N; j++)         newData[j] = data[j];     double a1 = sqrt(2 / double(N));     double a = 0;     double total = 0;     for(int n = 0; n < N; n++)     {           if(0 == n)             a = sqrt(1 / double(N));         else             a = a1;           total = 0;         for(int i = 0; i < N; i++)         {             total += newData[i] * cos((2 * i + 1) * n * PI / (2 * N));             printf(" lf   ",cos((2 * i + 1) * n * PI / (2 * N)));         }         printf("\n");         data[n] = a * total;     }     delete[] newData;     newData = NULL;     return true; } // 一维逆离散余弦变换 // 参数data为一维输入信号,N一维信号的长度 BOOL D1_IDCT(double *data, int N) {     if(N <= 0)         return false;     double *newData = new double[N];     for(int j = 0; j < N; j++)         newData[j] = data[j];     double a1 = sqrt(2 / double(N));     double a = 0;     double total = 0;     for(int n = 0; n < N; n++)     {         total = 0;         for(int i = 0; i < N; i++)         {             if(0 == i)                 a = sqrt(1 / double(N));             else                 a = a1;             total += a * newData[i] * cos((2 * n + 1) * i * PI / (2 * N));         }         data[n] = total;     }     delete[] newData;     newData = NULL;     return true; } int _tmain(int argc, _TCHAR* argv[]) {     double a[8] ={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0};     D1_DCT(a,8);     return 0; }

转载于:https://www.cnblogs.com/J2EEPLUS/archive/2012/04/26/2488025.html

相关资源:MPEG2、 H.264、 AVS 标准 pdf文档
最新回复(0)