资源简介
计算两个视频YUV序列的PSNR,可用于压缩后得到的视频与原始视频进行质量对比。
代码片段和文件信息
/**
* 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“); //创建存取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++
评论
共有 条评论