Firefly Open Source Community

   Login   |   Register   |
New_Topic
12
New Topic

How to use the vpu lib (base on C)on our firfly-rk3288

1821

Credits

10

Prestige

17

Contribution

super moderator

Rank: 8Rank: 8

Credits
1821
Posted at 1/27/2015 10:21:54     

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 !

Reply

Use props Report

71

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
71
Posted at 10/8/2015 18:34:13     
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?
Reply

Use props Report

71

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
71
Posted at 10/8/2015 18:34:29     
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?
Reply

Use props Report

1821

Credits

10

Prestige

17

Contribution

super moderator

Rank: 8Rank: 8

Credits
1821
Posted at 10/9/2015 15:48:46     
In theory,It can work.
you could try。
Reply

Use props Report

71

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
71
Posted at 10/13/2015 12:04:35     
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?
Reply

Use props Report

71

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
71
Posted at 10/14/2015 14:49:34     
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?
Reply

Use props Report

1821

Credits

10

Prestige

17

Contribution

super moderator

Rank: 8Rank: 8

Credits
1821
Posted at 10/15/2015 10:33:58     
h265?
the libhevcdec.so is needed.
Reply

Use props Report

71

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
71
Posted at 10/15/2015 15:42:49     
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?
Reply

Use props Report

844

Credits

42

Prestige

48

Contribution

advanced

Rank: 4

Credits
844
Posted at 10/28/2015 15:06:14     
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...
Reply

Use props Report

71

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
71
Posted at 11/3/2015 16:25:06     
mac_l1 Posted at 10/28/2015 15:06
hi guys!

to add some info here:

Thank you very much.
Reply

Use props Report

Return to List
12
You need to log in before you can reply Login | Register

This forum Credits Rules

Quick Reply Back to top Back to list