如何讀一個H264檔案,將資料轉換到DM8127或DM8168的Bitstream_BufList
問題如下:
Receiving encoded stream from network via RTSPClient and decode those stream. I just know copy the encoded stream from the network intoBitstream_Buf->addr and I don't know how to initialize (fill up) all fields of Bitstream_Buf before put them to the decoder by calling the function IpcBitsOutLink_putFullVideoBitStreamBufs.
Bitstream_BufList定義如下:
/*******************************************************************************
* *
* Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com/ *
* ALL RIGHTS RESERVED *
* *
******************************************************************************/
/**
\ingroup LINK_API
\defgroup VIDBITSTREAM Video Bitstream data structure definition
This file defines the data structure representing an encoded video frame's
bitstream object
@{
*/
/**
\file vidbitstream.h
\brief Definition of encoded video bitstream data structures
*/
#ifndef _VIDBITSTREAM_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define _VIDBITSTREAM_H_
/**
* @brief Buffer alignment needed for IVA-HD codecs
*/
#ifdef TI_8107_BUILD
#define IVACODEC_VDMA_BUFFER_ALIGNMENT (128)
#else
#define IVACODEC_VDMA_BUFFER_ALIGNMENT (32)
#endif
/**
* @def VIDBITSTREAM_MAX_BITSTREAM_BUFS
* @brief Maximum number of bitstream buf in a Bitstream_BufList @sa Bitstream_BufList
*/
#define VIDBITSTREAM_MAX_BITSTREAM_BUFS (64)
/**
\brief Bit stream buffer
*/
typedef struct Bitstream_Buf {
UInt32 reserved[2];
/**< First two 32 bit entries are reserved to allow use as Que element */
void *addr;
/**< Buffer Pointer */
UInt32 bufSize;
/**< Size of the buffer */
UInt32 fillLength;
/**< Filled lengh from start offset */
UInt32 startOffset;
/**< Start offset */
UInt32 mvDataOffset;
/**< Actual offset to mv data bistream in buffer, in bytes */
UInt32 mvDataFilledSize;
/**< Actual size of mv data bistream in buffer, in bytes */
UInt32 channelNum;
/**< Channel number */
UInt32 codingType;
/**< Coding type */
void *appData;
/**< Additional application parameter per buffer */
UInt32 timeStamp;
/**< Original Capture time stamp */
UInt32 temporalId;
/**< SVC TemporalId */
UInt32 upperTimeStamp;
/**< Original Capture time stamp:Upper 32 bit value*/
UInt32 lowerTimeStamp;
/**< Original Capture time stamp: Lower 32 bit value*/
UInt32 encodeTimeStamp;
/**< Encode complete time stamp */
UInt32 isKeyFrame;
/**< Flag indicating whether is currentFrame is key frame */
UInt32 allocPoolID;
/**< Pool frame from which buf was originally alloced */
UInt32 phyAddr;
/**< Physical address of the buffer */
UInt32 frameWidth;
/**< Width of the encoded frame */
UInt32 frameHeight;
/**< Height of the encoded frame */
UInt32 doNotDisplay;
/**< Flag indicating frame should not be displayed
* This is useful when display should start from a
* particular frame.
* This is temporary until Avsync suuports seek functionality*/
UInt32 bottomFieldBitBufSize;
/**< Size of the bottom field Bitstream. Filled by field Merged
interlaced encoders */
} Bitstream_Buf;
/**
* \brief Bit stream Buffer List used to exchange multiple Bitstream Buffers
* between links
*/
typedef struct
{
Bitstream_Buf *bufs[VIDBITSTREAM_MAX_BITSTREAM_BUFS];
/**< Array of Bitstream_Buf pointers that are to given or received from the
codec. */
UInt32 numBufs;
/**< Number of frames that are given or received from the codec
i.e number of valid pointers in the array containing Bitstream_Buf
pointers. */
void *appData;
/**< Additional application parameter per buffer list */
} Bitstream_BufList;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _VIDBITSTREAM_H_*/
/** @}*/
dm8127下有個例子:
Void *MultiCh_ipcBitsMain(Void *prm)
{
UInt32 i;
OSA_DmaCopy1D copy1D;
Bitstream_BufList fullBitsBufList;
Bitstream_BufList emptyBitsBufList;
IpcBitsOutLinkHLOS_BitstreamBufReqInfo ipcReqInfo;
OSA_printf("Entered IPC Bits Handler function\n");
gIpcBitsThObj.exitTh = FALSE;
gIpcBitsThObj.exitDone = FALSE;
while(gIpcBitsThObj.exitTh == FALSE)
{
OSA_semWait(&gIpcBitsNotifySem,OSA_TIMEOUT_FOREVER);
IpcBitsInLink_getFullVideoBitStreamBufs(gIpcBitsInHLOSId,&fullBitsBufList);
ipcReqInfo.numBufs = fullBitsBufList.numBufs;
for(i = 0;i < ipcReqInfo.numBufs;i++)
{
ipcReqInfo.minBufSize[i] = DEC_MIN_BUF_SIZE;
}
if(IpcBitsOutLink_getEmptyVideoBitStreamBufs(gIpcBitsOutHLOSId,&emptyBitsBufList,&ipcReqInfo) == IPC_BITSOUT_LINK_S_SUCCESS)
{
emptyBitsBufList.numBufs = fullBitsBufList.numBufs;
for(i = 0;i < fullBitsBufList.numBufs;i++)
{
if((Int32)emptyBitsBufList.bufs[i]->addr & 0x80000000)
{
goto skip;
}
emptyBitsBufList.bufs[i]->channelNum = fullBitsBufList.bufs[i]->channelNum;
emptyBitsBufList.bufs[i]->fillLength = fullBitsBufList.bufs[i]->fillLength;
emptyBitsBufList.bufs[i]->timeStamp = fullBitsBufList.bufs[i]->timeStamp;
if(gDmaHndl.chId == 0xFF)
{
memcpy(emptyBitsBufList.bufs[i]->addr,
(fullBitsBufList.bufs[i]->addr + fullBitsBufList.bufs[i]->startOffset),
fullBitsBufList.bufs[i]->fillLength);
}
else
{
copy1D.srcPhysAddr = (unsigned long)CMEM_getPhys(fullBitsBufList.bufs[i]->addr + fullBitsBufList.bufs[i]->startOffset);
copy1D.dstPhysAddr = (unsigned long)CMEM_getPhys(emptyBitsBufList.bufs[i]->addr);
copy1D.size = fullBitsBufList.bufs[i]->fillLength;
OSA_dmaCopy1D(&gDmaHndl,©1D,1);
}
}
IpcBitsOutLink_putFullVideoBitStreamBufs(gIpcBitsOutHLOSId,&emptyBitsBufList);
}
skip:
IpcBitsInLink_putEmptyVideoBitStreamBufs(gIpcBitsInHLOSId,&fullBitsBufList);
}
gIpcBitsThObj.exitDone = TRUE;
OSA_printf("Exiting IPC Bits Handler function\n");
return NULL;
}
參考這個例子:將h264資料送到videoM3解碼時,出現錯誤;
1)在videoM3解碼有問題,錯誤碼為0x2000a00, 通過查詢TI的文件,該錯誤碼是一個32位,表示32個錯誤,此錯誤碼錶示第9,11,25位對應為1;
錯誤如下:
XDM_APPLIEDCONCEALMENT :Applied concealment;
XDM_CORRUPTEDDATA : Data problem/corruption;
IH264VDEC_ERR_MISSINGSLICE: one or more slices are completely missing in this picture;
因為使用的視訊是用海康相機錄的,使用海康工具將視訊檔案轉換為標準h264檔案,然後ultraEdit裁剪到0x00 00 00 01 67 前的資料,解決;
2)dm8148,我將h264資料送入videoM3 解碼時,出錯; if(IpcBitsOutLink_getEmptyVideoBitStreamBufs(IPCBITOUTHOSTTOVIDM3ID,&emptyBitsBufList,&ipcReqInfo) == IPC_BITSOUT_LINK_S_SUCCESS) dm8127 這個地方獲取的地址emptyBitsBufList有時有問題,獲取的是實體地址了,本來是虛擬地址的; 有人知道原因嗎?
[host] ###Bit buff of size from the SR # 1 : 2073600
[host] IPC_BITSOUT:BitBuffer Alloc.PoolID:0,Size:0x1FA400
[host] IPCBITSOUTLINK:Translated Addr Virt:0x4189d080 To Phy:0x90000080
從這裡看0x4189d080是虛擬地址,而 0x90000080是實體地址;
平時正常跑的時候,獲取的地址是0x4189d080,而有時,獲取的地址是0x90000080,然後拷貝了資料就出錯了。
產生原因:
1)可能是由於讀264檔案時,IPCBitoutlink還未初始化;
解決辦法:使用0x80000000過濾掉,另外當下麵條件成立時,emptyBitsBufList的buff數可能為0,所以if語句中應該加一個條件過濾(emptyBitsBufList.numBufs>0)
if(IpcBitsOutLink_getEmptyVideoBitStreamBufs(IPCBITOUTHOSTTOVIDM3ID,&emptyBitsBufList,&ipcReqInfo) == IPC_BITSOUT_LINK_S_SUCCESS)
3)出現decLink_h264.c[333]::INTERNAL ERROR: -1 ALGPROCESS FAILED :STATUS
[m3video] 1356708:DECLINK::links_m3video/iva_dec/decLink_h264.c:[333]::INTERNAL ERROR:-1
[m3video] ALGPROCESS FAILED:STATUS
[m3video] outArgs->viddec3OutArgs.extendedError for channel 0 Error: 0x1021
[m3video] Sequence called number 11680
[m3video] 1356804:DECLINK::links_m3video/iva_dec/decLink_h264.c:[333]::INTERNAL ERROR:-1
[m3video] ALGPROCESS FAILED:STATUS
[m3video] outArgs->viddec3OutArgs.extendedError for channel 0 Error: 0x1021
[m3video] Sequence called number 11681
[m3video] 1377791:DECLINK::links_m3video/iva_dec/decLink_h264.c:[333]::INTERNAL ERROR:-1
[m3video] ALGPROCESS FAILED:STATUS
[m3video] outArgs->viddec3OutArgs.extendedError for channel 0 Error: 0x401
在dm8168 的demo_decode.c檔案中有;
/*----------------------------------------------------------------------------*/
/* Error strings which are mapped to codec errors */
/* Please refer User guide for more details on error strings */
/*----------------------------------------------------------------------------*/
static sEnumToStringMapping gDecoderErrorStrings[32] =
{
{(char *)"IH264VDEC_ERR_NOSLICE : 0, \0"},
{(char *)"IH264VDEC_ERR_SPS : 1,"},
{(char *)"IH264VDEC_ERR_PPS : 2,\0"},
{(char *)"IH264VDEC_ERR_SLICEHDR : 3,\0"},
{(char *)"IH264VDEC_ERR_MBDATA : 4,\0"},
{(char *)"IH264VDEC_ERR_UNAVAILABLESPS : 5,\0"},
{(char *)"IH264VDEC_ERR_UNAVAILABLEPPS : 6,\0"},
{(char *)"IH264VDEC_ERR_INVALIDPARAM_IGNORE : 7\0"},
{(char *)"XDM_PARAMSCHANGE : 8,\0"},
{(char *)"XDM_APPLIEDCONCEALMENT : 9,\0"},
{(char *)"XDM_INSUFFICIENTDATA : 10,\0"},
{(char *)"XDM_CORRUPTEDDATA : 11,\0"},
{(char *)"XDM_CORRUPTEDHEADER : 12,\0"},
{(char *)"XDM_UNSUPPORTEDINPUT : 13,\0"},
{(char *)"XDM_UNSUPPORTEDPARAM : 14,\0"},
{(char *)"XDM_FATALERROR : 15\0"},
{(char *)"IH264VDEC_ERR_UNSUPPFEATURE : 16,\0"},
{(char *)"IH264VDEC_ERR_METADATA_BUFOVERFLOW : 17,\0"},
{(char *)"IH264VDEC_ERR_STREAM_END : 18,\0"},
{(char *)"IH264VDEC_ERR_NO_FREEBUF : 19,\0"},
{(char *)"IH264VDEC_ERR_PICSIZECHANGE : 20,\0"},
{(char *)"IH264VDEC_ERR_UNSUPPRESOLUTION : 21,\0"},
{(char *)"IH264VDEC_ERR_NUMREF_FRAMES : 22,\0"},
{(char *)"IH264VDEC_ERR_INVALID_MBOX_MESSAGE : 23,\0"},
{(char *)"IH264VDEC_ERR_DATA_SYNC : 24,\0"},
{(char *)"IH264VDEC_ERR_MISSINGSLICE : 25,\0"},
{(char *)"IH264VDEC_ERR_INPUT_DATASYNC_PARAMS : 26,\0"},
{(char *)"IH264VDEC_ERR_HDVICP2_IMPROPER_STATE : 27,\0"},
{(char *)"IH264VDEC_ERR_TEMPORAL_DIRECT_MODE : 28,\0"},
{(char *)"IH264VDEC_ERR_DISPLAYWIDTH : 29,\0"},
{(char *)"IH264VDEC_ERR_NOHEADER : 30,\0"},
{(char *)"IH264VDEC_ERR_GAPSINFRAMENUM : 31, \0"}
};
相關文章
- 將DBF檔案(dBase, FoxPro等)中的資料轉換到SQLiteSQLite
- Mac如何將多個檔案快速歸類到一個資料夾裡Mac
- Hibernate 讀取檔案到資料庫的一個bug資料庫
- 如何將.ipynb檔案轉換為.py檔案
- 將檔案轉移到一個資料夾內batBAT
- 用VB將WORD文件(或其他的二進位制資料)生成xml檔案並互相轉換 (轉)XML
- C# 將資料夾中檔案複製到另一個資料夾C#
- 如何將本地資料同步到 shopify 或 shopify 資料同步到本地
- 如何將檔案PDF格式轉換成Word格式
- 將Schema檔案轉換為Java檔案Java
- c# 讀取多個路徑檔案到一個檔案
- 如何把多張jpg轉換成一個pdf檔案?
- 如何將Rust的“struct”轉換為資料流?RustStruct
- 轉換RDBA的檔案和資料塊地址(轉)
- 如何將HEIC轉換為JPG / JPEG或PNG?
- 如何將 PowerPoint 簡報轉換為 PDF 檔案?
- Oracle工具之sqlldr的使用--如何將文字檔案或Excel中的資料匯入資料庫OracleSQLExcel資料庫
- 如何移動asm磁碟組內的資料檔案到另外一個磁碟組ASM
- 把影像檔案上傳到資料庫,並從資料庫讀出 (轉)資料庫
- # 探索-如何將單個vue檔案轉換為小程式所需的四個檔案(wxml, wxss, json, js)VueXMLJSON
- 【原創】ASM下的資料檔案轉換為普通檔案ASM
- PDF檔案如何轉換EXCEL,一個方法教你輕鬆轉換各種檔案,讓老闆驚喜不斷Excel
- 教你如何將二進位制檔案匯入到資料庫資料庫
- 教程:如何通過DLA實現資料檔案格式轉換
- 蘋果手機如何將PDF檔案轉換為Word文件蘋果
- 如何將資料熱匯出到檔案
- DM8127如何利用EDMA搬移資料
- aspose word轉換pdf檔案後將pdf檔案轉換為圖片png
- WebSphere 6.1 程式 更新檔案 替換或新增單個檔案Web
- 如何將資料庫中的資料導成 excel 檔案資料庫Excel
- heic檔案如何轉換jpg?
- 如何遷移ASM資料檔案到檔案系統ASM
- 將資料庫轉換為歸檔日誌模式資料庫模式
- 瞧瞧這個將CBitmap寫到Bmp檔案裡的函式 (轉)函式
- 刪除某一資料夾或檔案時,提示“操作無法完成,因為其中的資料夾或檔案已在另一個程式中開啟”
- 如何遷移裸裝置raw device資料檔案到另一個raw devicedev
- 如何實現將markdown檔案實時轉換為html文件HTML
- 使用shell指令碼及asm cp或RMAN copy批量將資料檔案從ASM拷貝到檔案系統指令碼ASM