|
Posted at 1/27/2015 10:21:54
Only Author
1#
How to use the vpu lib (base on C)on our firfly-rk3288
as you gus know .the vpu works fine on our android os. and we can use it by android api "mediacodec".
today.i will to show you how to use it directly.
the libs we need :
- LOCAL_SHARED_LIBRARIES := \
- libvpu \
- librk_on2 \
- libcutils \
- liblog \
Copy the code
the head file path
- LOCAL_C_INCLUDES := \
- $(TOP)/hardware/rk29/libon2/
Copy the code
actualy ,we need :
hardware/rk29/libon2/vpu_api.h
hardware/rk29/libon2/vpu_global.h
hardware/rk29/libon2/vpu_mem.h
first of all , open the vpu and get the context:
- struct VpuCodecContext* ctx=NULL;
- vpu_open_context(&ctx);
Copy the code
then , initialize it:
- ctx->codecType=cmd->codec_type; // CODEC_DECODER?
- ctx->videoCoding=cmd->coding;
- ctx->width=cmd->width;
- ctx->height=cmd->height;
- ctx->no_thread=1;
- ret=ctx->init(ctx, pExtra, extraSize)
Copy the code
now we can do decode :
get a packet from your file .
- VideoPacket_t* pkt =NULL;
Copy the code
after decoding :
- ret=ctx->decode(ctx, pkt, pOut)
Copy the code
we get a out packet
ok we get the output .how to use it?
the data of pOut contains :
- VPU_FRAME *frame=(VPU_FRAME *)(pOut->data);
Copy the code
both virtual and physical address of the decoded frame are contained in structure named VPU_FRAME,
if you want to use virtual address, make sure you have done VPUMemLink before.
- VPUMemLink(&frame->vpumem);
Copy the code
save the output data :
- fwrite((U8*)(frame->vpumem.vir_addr), 1, frameSize, pOutFile);
Copy the code
remember use VPUFreeLinear to free, otherwise memory leak will give you a surprise.
- VPUFreeLinear(&frame->vpumem);
Copy the code
done !
|
|