?? xmin.c
字號:
#include <stdio.h>
#include "libr263.h"
#include "rlib.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
FILE *outputstream; /* Must be declared global for OwnWriteFunction */
// 寫bit到輸出文件
void OwnWriteFunction(int byte)
{
putc(byte, outputstream);
return;
}
int EncodeBlocks[9][11];
void main ()
{
CParam cparams; // 參數
Bits bits; //輸出bit
FILE *inputstream;
FILE *reconfile;
struct qcif qcif_frame;
struct cif cif_frame;
int framecount;
/* Open input and output files */
reconfile = fopen("recon.qcif","wb"); //b
outputstream = fopen("output.263","wb");
inputstream = fopen("input.qcif","rb"); // b
if(!inputstream || !outputstream || !reconfile) {
if(outputstream)
fclose(outputstream);
if(inputstream)
fclose(inputstream);
if(reconfile)
fclose(reconfile);
fprintf(stderr,"Cannot open in or output\n");
exit(1);
}
cparams.format = CPARAM_QCIF;
framecount = 0;
//初始化cparams參數,pic參數
InitCompress(&cparams);
//寫入bit的函數
WriteByteFunction = OwnWriteFunction;
if(!ReadQCIF(inputstream,&qcif_frame)) {
fprintf(stderr,"Cannot read from inputstream");
exit(1);
}
cparams.inter = CPARAM_INTRA;
cparams.Q_intra = 8;
cparams.data = &qcif_frame;
fprintf(stderr,"qcif data is on: %p\n",&qcif_frame);
// fprintf(stderr,"cif data is on: %p\n",&cif_frame);
// 壓縮第一幀I幀
CompressToH263(&cparams, &bits);
//重建qcif數據
WriteQCIF(reconfile,cparams.recon);
// WriteCIF(reconfile,cparams.recon);
//幀間
cparams.inter = CPARAM_INTER;
cparams.half_pixel_searchwindow = 4;
cparams.search_method = CPARAM_LOGARITHMIC;
cparams.Q_inter = 8;
cparams.advanced_method = CPARAM_ADVANCED; //1
cparams.EncodeThisBlock = &EncodeBlocks;
while(ReadQCIF(inputstream, &qcif_frame))
{
++framecount;
// if(framecount % 4 == 1) {
if(cparams.advanced_method) //1
FindMotion(&cparams,2,2); //門限設定2,2,
//每個宏塊是否move,放入 *(params->EncodeThisBlock + j*mbc + i)
CompressToH263(&cparams, &bits);
// }
// In case of skipped frames, the previous frame is displayed again,
// therefore, the previous frame should be included in the recon-
// structed QCIF video stream.
WriteQCIF(reconfile,cparams.recon);
// WriteCIF(reconfile,cparams.recon);
// Not really nice, but it's just an example
if(framecount > 88)
break;
}
fclose(inputstream);
fclose(outputstream);
fclose(reconfile);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -