生成的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