使用xvid进行解码

这个博客介绍了一个使用Xvid库解码MPEG4流的C语言实现。程序从输入文件读取数据,解码后将输出保存为PNM或TGA图像格式,同时提供了解码初始化、主要解码过程和停止解码的函数。通过命令行参数可以设置颜色空间、输出格式等选项。
摘要由CSDN通过智能技术生成

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#ifndef WIN32
#include <sys/time.h>
#else
#include <time.h>
#endif

#include "xvid.h"

/*****************************************************************************
 *               Global vars in module and constants
 ****************************************************************************/

#define USE_PNM 0
#define USE_TGA 1

static int XDIM = 352;
static int YDIM = 288;
//static int XDIM = 176;
//static int YDIM = 144;
static int ARG_SAVEDECOUTPUT = 0;
static int ARG_SAVEMPEGSTREAM = 0;
static char *ARG_INPUTFILE = "tmp.m4d";
static int CSP = XVID_CSP_I420;
//static int CSP = XVID_CSP_YV12;
static int BPP = 1;
static int FORMAT = USE_PNM;

static char filepath[256] = "./";
static void *dec_handle = NULL;

#define BUFFER_SIZE (2*1024*1024)

static const int display_buffer_bytes = 0;

#define MIN_USEFUL_BYTES 1

/*****************************************************************************
 *               Local prototypes
 ****************************************************************************/

static double msecond();
static int dec_init(int use_assembler, int debug_level);
static int dec_main(unsigned char *istream,
     unsigned char *ostream,
     int istream_size,
     xvid_dec_stats_t *xvid_dec_stats);
static int dec_stop();
static void usage();
static int write_pnm(char *filename, unsigned char *image);
static int write_tga(char *filename, unsigned char *image);

const char * type2str(int type)
{
    if (type==XVID_TYPE_IVOP)
        return "I";
    if (type==XVID_TYPE_PVOP)
        return "P";
    if (type==XVID_TYPE_BVOP)
        return "B";
    return "S";
}


/*****************************************************************************
 *               Usage function
 ****************************************************************************/

static void usage()
{

 fprintf(stderr, "Usage : xvid_decraw [OPTIONS]/n");
 fprintf(stderr, "Options :/n");
 fprintf(stderr, " -asm           : use assembly optimizations (default=disabled)/n");
 fprintf(stderr, " -debug         : debug level (debug=0)/n");
 fprintf(stderr, " -i string      : input filename (default=stdin)/n");
 fprintf(stderr, " -d             : s

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值