c 生成16×16个像素点的rgb图片并转为yuv420P 格式

生成的yuv420p 文件,用ffplay -i 16*16.yuv -pix_fmt yuv420p -s 16*16 打开正确显示

特别注意:yuv420p 格式是先存所有的256个Y分量,再存64个U分量,最后存64个V分量。UV可以任选4个Y中的一个读取,本程序选的是每组的第一个。

所以霍夫曼解码遇到yuv420格式时,是先解码所有的Y分量,再解所有的U,最后再解所有的V。怪不得前面对自编程序的解码总有问题。



#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>  
#include <string.h>
#include <sys/mman.h>
#include <linux/fb.h>

#define  pic_width  16          //水平16个像素
#define  pic_heigth  16         //垂直16个像素
#define  file  "/home/wzpc/Pictures/16*16.rgb"
#define  file1 "/home/wzpc/Pictures/16*16.yuv"
int sp[pic_width*pic_heigth];
int sp1[pic_width*pic_heigth];

static struct fb_var_screeninfo var;

int main(void)
{
   
	int t=0;
	for(int a=0;a<pic_heigth/4;a++){
		for(int 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值