資源簡介
計算兩個視頻YUV序列的PSNR,可用于壓縮后得到的視頻與原始視頻進行質(zhì)量對比。
代碼片段和文件信息
/**?
*?Calculate?PSNR?between?2?YUV420P?file?
*?@param?url1?????Location?of?first?Input?YUV?file.?
*?@param?url2?????Location?of?another?Input?YUV?file.?
*?@param?w????????Width?of?Input?YUV?file.?
*?@param?h????????Height?of?Input?YUV?file.?
*?@param?num??????Number?of?frames?to?process.?
*/??
#include
using?namespace?std;
int?simplest_yuv420_psnr(char?*url1char?*url2int?wint?hint?num){??
????FILE?*fp1=fopen(url1“rb+“);??
????FILE?*fp2=fopen(url2“rb+“);??
FILE?*fp=fopen(“Video_PSNR.txt““w“);?????????//創(chuàng)建存取PSNR值信息的txt文件
????unsigned?char?*pic1=(unsigned?char?*)malloc(w*h);??
????unsigned?char?*pic2=(unsigned?char?*)malloc(w*h);??
????
float?Sum_PSNR=0;????//定義所有幀的PSNR和
float?average_PSNR;??//定義平均PSNR
????for(int?i=0;i ????????fread(pic11w*hfp1);??
????????fread(pic21w*hfp2);??
????????double?mse_sum=0mse=0psnr=0;??
????????for(int?j
- 上一篇:軟通動力C筆試題
- 下一篇:K-means算法串行程序C++
評論
共有 條評論