Firefly Open Source Community

Title: How to use the vpu lib (base on C)on our firfly-rk3288 [Print This Page]

Author: isle    Time: 1/27/2015 10:21
Title: 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 :
  1. LOCAL_SHARED_LIBRARIES := \
  2.         libvpu \
  3.         librk_on2 \
  4.         libcutils \
  5.         liblog \
Copy the code




the head file path
  1. LOCAL_C_INCLUDES := \
  2. $(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:


  1.     struct VpuCodecContext* ctx=NULL;
  2.     vpu_open_context(&ctx);
Copy the code




        

then ,  initialize it:
  1.     ctx->codecType=cmd->codec_type;  // CODEC_DECODER?
  2.     ctx->videoCoding=cmd->coding;   
  3.     ctx->width=cmd->width;
  4.     ctx->height=cmd->height;
  5.     ctx->no_thread=1;

  6.     ret=ctx->init(ctx, pExtra, extraSize)
Copy the code



now we can do decode £º
get a packet from your file .
  1. VideoPacket_t* pkt =NULL;
Copy the code



after decoding :
  1. ret=ctx->decode(ctx, pkt, pOut)
Copy the code



we get a out packet
  1. DecoderOut_t *pOut=NULL;
Copy the code



ok  we get the output .how to use it?

the data of pOut contains :

  1. 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.
  1. VPUMemLink(&frame->vpumem);
Copy the code



save the output data :
  1. 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.
  1. VPUFreeLinear(&frame->vpumem);
Copy the code



done !


Author: youbainiao    Time: 10/8/2015 18:34
hi,isle,

I want to use rk3288 video HW(hevc) decoder on linux,I use libhyris directly invoke the libvpu method,Can this be achieved?
Author: youbainiao    Time: 10/8/2015 18:34
hi,isle,

I want to use rk3288 video HW(hevc) decoder on linux,I use libhyris directly invoke the libvpu method,Can this be achieved?
Author: isle    Time: 10/9/2015 15:48
In theory£¬It can work.
you could try¡£
Author: youbainiao    Time: 10/13/2015 12:04
isle Posted at 10/9/2015 15:48
In theory£¬It can work.
you could try¡£

hi,isle,

Thank you for your reply,I intend to do so, can you give me some advice do?such as,about vpu service,Is available under Linux?
Author: youbainiao    Time: 10/14/2015 14:49
isle Posted at 10/9/2015 15:48
In theory£¬It can work.
you could try¡£

hi,isle,

If I want to use h265 lib directly,which libs is need?
Author: isle    Time: 10/15/2015 10:33
h265?
the libhevcdec.so is needed.
Author: youbainiao    Time: 10/15/2015 15:42
isle Posted at 10/15/2015 10:33
h265?
the libhevcdec.so is needed.

You mean I just need to libhevcdec.so,no need libvpu.so?What is the relationship between these two libraries?
Author: mac_l1    Time: 10/28/2015 15:06
hi guys!

to add some info here:
libvpu is mainly needed for VPU/GPU memory access; librkon2 is needed for encoding/decoding; librkon2 uses other rk libs like libhevcdec to do its magic.
librkffplayer is a more complete library based on ffplayer lib to (de)mux and encoding/decoding streams and is used by androids stagefright, not yet available in machybris but can be quite easily added.
machybris also exposes the very high level api for androids media service by libmedia: ubuntu made this for their ubuntu touch/phablet products

hope this helps...
Author: youbainiao    Time: 11/3/2015 16:25
mac_l1 Posted at 10/28/2015 15:06
hi guys!

to add some info here:

Thank you very much.
Author: yyangss@163.com    Time: 6/1/2017 08:53
There is no librk_on2.so in Android 5.1 , so how to directly use vpu? which libs need?




Welcome Firefly Open Source Community (https://bbs.t-firefly.com/) Powered by Discuz! X3.1