?? main.c.user
字號:
#define MP4_GLOBALS#include "../fmpeg4_driver/fmpeg4.h"#define BIT_STREAM_SIZE (1024*1024)#define MPEG4_IP_ADDRESS 0x90900000#include "../../../libavcodec/avcodec.h"#undef ABS#include "portab.h"#include "mp4vdec.h"#include "test_mem.h"//#include "utils/mem_align.h"//#include "../faraday_mpeg4_common/dev_mem.h"#undef printftypedef struct Mpeg4DecContext { void * pvDec;} Mpeg4DecContext;int xvid_decoder_init(AVCodecContext *avctx){ Mpeg4DecContext *s = avctx->priv_data; FMP4_DEC_PARAM tDecParam; unsigned int * base; avctx->pix_fmt= PIX_FMT_RGB555; avctx->flags |= CODEC_FLAG_PICT_ALLOC_EXTERNAL; base = (unsigned int *)ioremap(MPEG4_IP_ADDRESS, 0x100000); if (base == 0) { /// maping failure printf("mpeg4 maping failure\n"); return -1; } printf("mpeg4_dec virt addr = 0x%x\n", (int)base); // Initialization // Inform the client the API version tDecParam.u32API_version = 0x00020002; tDecParam.pu32BaseAddr = base; tDecParam.pu8FrameBaseAddr_phy = NULL; tDecParam.pfnSemWait = NULL; tDecParam.pfnSemSignal= NULL; tDecParam.pvSemaphore = NULL; tDecParam.u32FrameWidth = avctx->framebuffer_rgb_stride; tDecParam.u32FrameHeight = avctx->framebuffer_rgb_height; tDecParam.u32MaxWidth = avctx->width; tDecParam.u32MaxHeight = avctx->height; tDecParam.u32BSBufSize = BIT_STREAM_SIZE; tDecParam.u32CacheAlign = 16; tDecParam.pfnDmaMalloc = TM_DmaMalloc; tDecParam.pfnDmaFree = TM_DmaFree; if (Mp4VDec_Init(&tDecParam, &(s->pvDec)) != FARADAY_ERR_OK){ printf("Mp4VDec_Init decoder failure\n"); return -1; } return 0;}int xvid_decode(AVCodecContext *avctx, void *data, int *got_picture, uint8_t *buf, int buf_size){ Mpeg4DecContext *s = avctx->priv_data; AVFrame *picture = data; FMP4_DEC_RESULT tDecResult; if (buf_size > BIT_STREAM_SIZE) { printf("xvid_decode: bitstream size over limit\n"); while (1); } if (Mp4VDec_FillBuffer(s->pvDec, buf, buf_size) == FARADAY_ERR_FAIL) { printf ("ERROR in FillBuffer, while(1)\n"); while (1); } Mp4VDec_SetOutputAddr (s->pvDec, picture->data[0], NULL, NULL); if (Mp4VDec_OneFrame(s->pvDec, &tDecResult) == FARADAY_ERR_FAIL) { printf("decode error: \n"); while (1); *got_picture = 0; } else { *got_picture = 1; } return tDecResult.u32UsedBytes;}int xvid_decoder_end(AVCodecContext *avctx){ Mpeg4DecContext *s = avctx->priv_data; Mp4VDec_Release(s->pvDec); return 0;}AVCodec fmpeg4_decoder = { "fmpeg4", CODEC_TYPE_VIDEO, CODEC_ID_MPEG4, sizeof(Mpeg4DecContext), xvid_decoder_init, NULL, /// encode xvid_decoder_end, /// close xvid_decode, /// decode 0 /// capabilities};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -