Firefly Open Source Community

   Login   |   Register   |
New_Topic
Print Previous Topic Next 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      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 :
  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

1821

Credits

10

Prestige

17

Contribution

super moderator

Rank: 8Rank: 8

Credits
1821
Posted at 10/9/2015 15:48:46      2#
In theory,It can work.
you could try。
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      3#
h265?
the libhevcdec.so is needed.
Reply

Use props Report

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

This forum Credits Rules

Quick Reply Back to top Back to list