From cd782ef4c32a549e5fa211947f3a31410fea23c3 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 10 Jun 2012 15:14:23 +0200 Subject: [PATCH] Basic XvMC support --- videovpeogl.cc | 43 ++++++++++++++++++++++++++++++++++++++----- videovpeogl.h | 4 ++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/videovpeogl.cc b/videovpeogl.cc index 77d5bcb..f528687 100755 --- a/videovpeogl.cc +++ b/videovpeogl.cc @@ -47,8 +47,9 @@ VideoVPEOGL::VideoVPEOGL() dec_frame_libav_uploading=NULL; dec_frame_libav_decoding=NULL; ogl_frame_outside=false; - decoding_mode=VPE_NO_XVMC; - //decoding_mode=VPE_XVMC_MOCOMP; + //decoding_mode=VPE_NO_XVMC; + decoding_mode=VPE_XVMC_MOCOMP; + framebuf_framenum=0; #endif #ifdef BENCHMARK_FPS @@ -1369,6 +1370,9 @@ int VideoVPEOGL::get_buffer_libav(struct AVCodecContext *c, AVFrame *pic) unsigned int want_sizes[4]={0,0,0,0}; AVPicture pict; bool normal_pixs=false; + int num_blocks=0; + int num_dct_blocks=0; + int s_a[4]; //reget logic from mplayer if (pic->opaque && pic->data[0] && (!pic->buffer_hints ||pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE )){ @@ -1417,18 +1421,27 @@ int VideoVPEOGL::get_buffer_libav(struct AVCodecContext *c, AVFrame *pic) } } else { - //TODE set linesizes! - Log::getInstance()->log("Video", Log::ERR, "Not implemented"); - return -1; + //TODO set linesizes! + + num_blocks=((c->width+15)/16)*((c->height+15)/16); + num_dct_blocks=num_blocks*6; //6 blocks per macroblock + + want_sizes[2]=sizeof(xvmc_pix_fmt); + want_sizes[1]=sizeof(short)*num_dct_blocks*8*8; + want_sizes[0]=sizeof(XvMCMacroBlock)*num_blocks; + pict.linesize[0]=pict.linesize[1]=pict.linesize[2]=pict.linesize[3]=0; } VPE_FrameBuf *frame_buf=((VideoVPEOGL*)Video::getInstance())->getFrameBuf(want_sizes); + //Log::getInstance()->log("Video", Log::NOTICE, "get buffer %x",frame_buf); if (!frame_buf) { Log::getInstance()->log("Video", Log::ERR, "Getting buffer libav failed"); return -1; } + + //populate pict pic->type=FF_BUFFER_TYPE_USER; // we are controlling the buffers int hchr_shift,vchr_shift; @@ -1459,6 +1472,24 @@ int VideoVPEOGL::get_buffer_libav(struct AVCodecContext *c, AVFrame *pic) pic->sample_aspect_ratio=c->sample_aspect_ratio; pic->reordered_opaque= c->reordered_opaque; pic->age=INT_MAX; + if (!normal_pixs) { + xvmc_pix_fmt *pix_xvmc=(xvmc_pix_fmt *)pic->data[2]; + pix_xvmc->xvmc_id=AV_XVMC_ID; + pix_xvmc->data_blocks=(short*)pic->data[1]; + pix_xvmc->mv_blocks=(XvMCMacroBlock*)pic->data[0]; + pix_xvmc->allocated_mv_blocks=num_blocks; + pix_xvmc->allocated_data_blocks=num_dct_blocks; + if (c->pix_fmt==PIX_FMT_XVMC_MPEG2_IDCT) pix_xvmc->idct=1; + else pix_xvmc->idct=0; + pix_xvmc->unsigned_intra=0; // let see what happens + pix_xvmc->p_surface=(XvMCSurface*)frame_buf->pict_num; + pix_xvmc->start_mv_blocks_num=0; + pix_xvmc->filled_mv_blocks_num=0; + pix_xvmc->next_free_data_block_num=0; + //that is all folks + + + } return 0; @@ -1651,6 +1682,8 @@ VPE_FrameBuf *VideoVPEOGL::getFrameBuf(unsigned int *size) current->size[x]=size[x]; } } + framebuf_framenum++; + current->pict_num=framebuf_framenum; //This is used for tracking reference frames through the conversion pipeline return current; } diff --git a/videovpeogl.h b/videovpeogl.h index ef73724..4af2bab 100755 --- a/videovpeogl.h +++ b/videovpeogl.h @@ -71,6 +71,7 @@ struct VPE_OMX_EVENT { extern "C" { #include +#include #include #include } @@ -79,6 +80,7 @@ struct VPE_FrameBuf { //This is a frame bulibaver, nothing fancy just plain memory void *data[4]; unsigned int size[4]; + unsigned int pict_num; }; #endif @@ -271,6 +273,8 @@ class VideoVPEOGL : public Video, public Thread_TYPE void lockFrameBufUpload(VPE_FrameBuf* data); void releaseFrameBufUpload(VPE_FrameBuf* data); + unsigned int framebuf_framenum; + Mutex vpe_framebuf_mutex; -- 2.39.5