www.pudn.com > henclib263.rar > test.cxx
// testencoder.cpp : Defines the entry point for the console application. // #include#include #include //#include #include "../include/H263PEncode.h" #define QCIF #define BUFF_SIZE 100000 #ifdef QCIF #define PIC_SIZE 176*144*3/2 #else #define PIC_SIZE 352*288*3/2 #endif #define FILE_IN "foreman.qcif" #define FILE_OUT "out.263" #define FILE_BIT "bit.txt" #define QUANT_I 5 #define QUANT_P 5 #define QUANT_B 5 FILE *out_file; long writestrm(unsigned char*pData, int len, long time, unsigned long type, void* context); int main(int argc, char* argv[]) { unsigned char src_pic[PIC_SIZE]; FILE *src_file; FILE *bit_counter; CH263Encoder encoder; Enc_Option option; clock_t start; clock_t end; float total_time; int size = 0; int type = 0; int frame = 0; unsigned int nTime = 0; int stop = 300; int deltaT = 30; bit_counter = fopen(FILE_BIT, "w"); src_file = fopen(FILE_IN, "rb"); if (src_file == 0) { printf("error during open source file!\n"); exit(0); } if (bit_counter == 0) { printf("error during open bit file!\n"); exit(0); } out_file = fopen(FILE_OUT, "wb"); encoder.GetOption(option); option.m_iMVSearchMethod = MVFAST; option.m_EncoderCallBack = writestrm; option.m_iQuantI = QUANT_I; option.m_iQuantP = QUANT_P; option.m_iQuantB = QUANT_B; encoder.EncOpen(option); start = clock(); while (stop--) { if(PIC_SIZE != fread(src_pic, 1, PIC_SIZE, src_file)) break; size += encoder.EncOneFrame(src_pic, nTime); frame++; deltaT--; if (!deltaT) { fprintf(bit_counter, "%d\n", size*8); deltaT = 30; size = 0; } nTime = (unsigned int)frame; } end = clock(); total_time = (float)((end - start)/*/CLOCKS_PER_SEC*/); encoder.EncClose(); printf("total time:%fms\n", total_time); printf("average coding speed: %f frames per second.\n", (float)(1000*frame/total_time)); fclose(out_file); fclose(src_file); fclose(bit_counter); return 0; } long writestrm(unsigned char*pData, int len, long time, unsigned long type, void* context) { fwrite(pData, 1, len, out_file); return len; }