資源簡介
詳細內容見博客:https://blog.csdn.net/li_wen01/article/details/81146461
代碼片段和文件信息
/************************************************************
*FileName:?avilib.c
*Date: ???2018-07-15
*Author:???Wen?Lee
*Version:??V1.0
*Description:?AVI?音視頻格式封裝
*Others:???
*History:
***********************************************************/
#include?“avilib.h“
static?AVI_S?g_stAVIPara;
static?WAV_S?g_stWAVPara;
static?void?Int2Str(unsigned?char?*dst?int?n)
{
????dst[0]?=?(n)&0xff;
????dst[1]?=?(n>>?8)&0xff;
????dst[2]?=?(n>>16)&0xff;
????dst[3]?=?(n>>24)&0xff;
????return;
}
#define?OUT4CC(s)?\
????if(s64Nhb<=HEADERBYTES-4)?memcpy(arrAVI_header+s64Nhbs4);?s64Nhb?+=?4
#define?OUTLONG(n)?\
????if(s64Nhb<=HEADERBYTES-4)?Int2Str(arrAVI_header+s64Nhbn);?s64Nhb?+=?4
#define?OUTSHRT(n)?\
????if(s64Nhb<=HEADERBYTES-2)?{?\
??????arrAVI_header[s64Nhb??]?=?(n???)&0xff;?\
??????arrAVI_header[s64Nhb+1]?=?(n>>8)&0xff;?\
????}?\
????s64Nhb?+=?2
typedef?struct?IDRIndex
{
short?s16IdrNo;
char??arrBCDTime[6];
int???s32OffsetAddr;
char??arrResv[4];
}__attribute__?((packed))IDR_INDEX_S;
int?HstAviHeaderWrite(void)
{
long?s64Nhb;
//int?s32Strl_start;
int?s32Hdrl_start?s32Audio_strl_start;
int??s32Njunk?s32Sampsize?s32HasIndex?s32Ms_per_frame?s32Frate?s32Idxerror?s32Flag;
unsigned?char?arrAVI_header[HEADERBYTES];
unsigned?int??l_u32AVILen?=?0;
unsigned?int?j?=?0;
????if(g_stAVIPara.u32AviLen?>?0)
????{
????l_u32AVILen?=?g_stAVIPara.u32AviLen;
????}??
????else
????{
l_u32AVILen?=?0;
}
????????
????s32Idxerror?=?0;
????s32HasIndex?=0;
????
????if(g_stAVIPara.u32MustUseIndex?==1)
????{
????????s32HasIndex?=1;
????}
????
????if(g_stAVIPara.u64fps?0.001)
????{
????????s32Frate=0;
????????s32Ms_per_frame=0;
????}
????else
????{
????????s32Frate?=?(int)?(frame_RATE_SCALE*g_stAVIPara.u64fps?+?0.5);
????????s32Ms_per_frame=(int)?(1000000/g_stAVIPara.u64fps?+?0.5);
????}
????s64Nhb?=?0;
????
????/*?The?RIFF?header?*/
????OUT4CC?(“RIFF“);
????OUTLONG(l_u32AVILen);???? /*?#?of?bytes?to?follow?*/
????OUT4CC?(“AVI?“);
????/*?Start?the?header?list?*/
????OUT4CC?(“LIST“);
????OUTLONG(0);???????? /*?Length?of?list?in?bytes?don‘t?know?yet?*/
????s32Hdrl_start?=?s64Nhb;?? /*?Store?start?position?*/
????OUT4CC?(“hdrl“);
????/*?The?main?AVI?header?*/
????/*?The?Flags?in?AVI?File?header*/
????OUT4CC?(“avih“);
????OUTLONG(56);????????????????? /*?#?of?bytes?to?follow?*/
????OUTLONG(s32Ms_per_frame);???????????/*?Microseconds?per?frame?*/
????OUTLONG(0);
/**Specifies?the?alignment?for?data?in?bytes.
Pad?the?data?to?multiples?of?this?value.**/?
????OUTLONG(g_stAVIPara.u32Gop);???????
s32Flag?=?AVIF_ISINTERLEAVED;
????if(s32HasIndex)?s32Flag?|=?AVIF_HASINDEX;
????if(s32HasIndex?&&?g_stAVIPara.u32MustUseIndex)?s32Flag?|=?AVIF_TRUSTCKTYPE;
????OUTLONG(s32Flag);????????????????????/*?Flags?*/
OUTLONG(g_stAVIPara.u32Videoframes);?/*?Vedio?Totalframes?*/
????OUTLONG(0);?????????????????? ?/*?Initialframes?*/
????OUTLONG(g_stAVIPara.u32StreamNum); ?/**Be?Careful?streams?=?1**/
OUTLONG(0);?????????????????? ?/*?SuggestedBufferSize?*/
??
評論
共有 條評論