dct_sc.cpp

来自「H.264完整的C语言代码和DCT的代码」· C++ 代码 · 共 67 行

CPP
67
字号
#include "idb_streamc.hpp"
#include "dct_kc.hpp"
// this defines the function "testProgram"
// as a stream program
STREAMPROG(testProgram);
// this stream program is a simple example
// that calls the addAndSum kernel twice
// all stream programs must have only these arguments
streamprog testProgram( String args)
{
/*
// print the arguments (otherwise unused)
cout << args << endl;
im_stream<im_int> s1(32);
im_stream<im_int> s2(32);
// initialize the input stream from an array
int data[32];
for (int i = 0; i < 32; i++) {
data[i] = i;
}
//streamLoadBin(data, s1);
streamLoadBin(data, 32, s1);
// declare a microcontroller variable
im_uc<im_int> uc_sum = 0;
// declare a stream of 32 integers
im_stream<im_int> temp(32);
// call the addAndSum kernel twice
//addAndSum(s1, s1, temp, uc_sum);
//addAndSum(s1, temp, s2, uc_sum);
// save the output and display it
streamSaveBin(data, s2);
for (int i = 0; i < 32; i++) {
cout << data[i] << " ";
}
cout << endl;
cout << "sum = " << ucRead(uc_sum) << endl;
*/

    if (args == "") cout << "Sorry, have to pass a string to do example";
    else if (args == "doExample") {  
        
        /*kernel dct(istream<half2> datain,
           istream<uhalf2> consts,           // in 1.15
           ostream<half2> out,
           uc<uhalf2>& uc_quantizer_scale)   // 1/uc_quantizer_scale in 0.16*/
		
		cout << "Beginning load." << endl;
        im_stream<im_half2> datain(64);
		streamLoadFile("dct/dct_in.txt", "txt", "", datain);

		im_stream<im_uhalf2> consts(64);
		streamLoadFile("dct/dct_non_intra_consts.txt", "txt", "", consts);
		cout << "Finished load." << endl;
	
		im_stream<im_half2> out(64);

		im_uc<im_uhalf2> quantizer_scale;


        cout << "Beginning computation." << endl;
        dct(datain,consts, out, quantizer_scale);
        cout << "Finished computation." << endl;
        
        streamSaveFile("dct/output.txt", "txt", "X", out);
       
    }
}

⌨️ 快捷键说明

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