提交 bc255c9d 编写于 作者: 辍之耕's avatar 辍之耕

ii1

上级 eb3abd01
#include <stdio.h>
#include <stdlib.h>
#define LOG_W(fmt, args...) printf("\033[33m[Module_Menusetting][%s@%d]:\033[0m" fmt, __func__, __LINE__, ##args);
/**
* Add border for YUV420P file
* @param url Location of Input YUV file.
* @param w Width of Input YUV file.
* @param h Height of Input YUV file.
* @param border Width of Border.
* @param num Number of frames to process.
*/
int simplest_yuv420_border(char *url, int w, int h,int border)
{
FILE *fp=fopen(url,"rb+");
FILE *fp1=fopen("output_border.yuv","wb+");
int j, k;
unsigned char *pic=(unsigned char *)malloc(w*h*3/2);
int ow = w -border*2;
int oh = h -border*2;
unsigned char *out=(unsigned char *)malloc(ow*oh*3/2);
int out_i = 0;
int real_w, real_h;
int count;
int i;
fread(pic,1,w*h*3/2,fp);
//Y
#if 1
for(j=0;j<h;j++){
for(k=0, count = 0;k<w;k++){
if(k<border||k>(w-border-1)||j<border||j>(h - border - 1)){
//pic[j*w+k]=0;
} else {
count ++;
out[out_i] = pic[j*w+k];
out_i++;
}
}
//LOG_W("%d, %d, %d\n",j, out_i, count);
}
#endif
#if 1
for (i = 0; i < w * (h / 2); i++) {
/*U, Cb*/
if (i % 2 == 0) {
real_h = ( (i / 2) / (w / 2)) * 2;
real_w = ( (i / 2) % (w / 2)) * 2;
/*LOG_W("(%d, %d)\n", real_h, real_w);*/
if(real_w<border||real_w>(w-border-1)||real_h<border||real_h>(h - border - 1)){
} else {
out[out_i] = pic[w * h + i];
out_i++;
printf("U");
}
/*V, Cr*/
} else {
real_h = ( (i / 2) / (w / 2)) * 2 + 1;
real_w = ( (i / 2) % (w / 2)) * 2;
/*LOG_W("(%d, %d)\n", real_h, real_w);*/
if(real_w<border||real_w>(w-border-1)||real_h<border||real_h>(h - border - 1)){
} else {
out[out_i] = pic[w * h + i];
out_i++;
printf("V");
}
}
}
#endif
fwrite(out,1,oh * ow * 3 / 2,fp1);
LOG_W("%d,%d\n", out_i, w * (h /4));
free(out);
free(pic);
fclose(fp);
fclose(fp1);
return 0;
}
int main()
{
simplest_yuv420_border("0N_1.yuv", 720, 288,10);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
/**
* Add border for YUV420P file
* @param url Location of Input YUV file.
* @param w Width of Input YUV file.
* @param h Height of Input YUV file.
* @param border Width of Border.
* @param num Number of frames to process.
*/
int simplest_yuv420_border(char *url, int w, int h,int border)
{
FILE *fp=fopen(url,"rb+");
FILE *fp1=fopen("output_border.yuv","wb+");
int j, k;
unsigned char *pic=(unsigned char *)malloc(w*h*3/2);
int ow = w -border*2;
int oh = h -border*2;
unsigned char *out=(unsigned char *)malloc(ow*oh*3/2);
int out_i = 0;
int real_w, real_h;
int count;
int i;
fread(pic,1,w*h*3/2,fp);
//Y
#if 1
for(j=0;j<h;j++){
for(k=0, count = 0;k<w;k++){
if(k<border||k>(w-border-1)||j<border||j>(h - border - 1)){
//pic[j*w+k]=0;
} else {
count ++;
out[out_i] = pic[j*w+k];
out_i++;
}
}
//printf("%d, %d, %d\n",j, out_i, count);
}
#endif
#if 1
//U
count = 0;
for(i=0; i< w * (h/4);i++){
real_h = (i / (w/2) ) * 2;
real_w = (i % (w / 2)) * 2;
//printf("(%d, %d), \n", real_h, real_w);
if(real_w<border||real_w>(w-border-1)||real_h<border||real_h>(h - border - 1)){
} else {
out[out_i] = pic[w * h + i];
out_i++;
count++;
}
}
printf("count: %d\n", count);
#endif
#if 1
for(i=0; i< w * (h/4);i++){
real_h = (i / (w/2) ) * 2 + 1;
real_w = (i % (w / 2)) * 2;
printf("(%d, %d), \n", real_h, real_w);
if(real_w<border||real_w>(w-border-1)||real_h<border||real_h>(h - border - 1)){
} else {
out[out_i] = pic[w * h + i];
out_i++;
count++;
}
}
#endif
fwrite(out,1,oh * ow * 3 / 2,fp1);
printf("%d,%d\n", out_i, w * (h /4));
free(out);
free(pic);
fclose(fp);
fclose(fp1);
return 0;
}
int main()
{
simplest_yuv420_border("0N_1.yuv", 720, 288,10);
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册