Ticket #8593: vaapi_v3.diff
File vaapi_v3.diff, 54.1 KB (added by , 15 years ago) |
---|
-
configure
128 128 --enable-xvmc-vld enable XvMC VLD accel. for the Unichrome (Pro) chipset 129 129 --xvmc-lib=LIB XvMC library override (for crosscompiling) 130 130 --enable-vdpau enable NVidia VDPAU hardware acceleration. 131 --enable-vaapi enable VAAPI hardware acceleration 131 132 --disable-opengl-video disable OpenGL based video display 132 133 --enable-mac-accel enable Mac OS X MPEG acceleration 133 134 --disable-opengl-vsync disable OpenGL vsync method … … 1336 1337 dvdv 1337 1338 opengl 1338 1339 vdpau 1340 vaapi 1339 1341 ' 1340 1342 1341 1343 CMDLINE_SELECT=" … … 1678 1680 xvmc_deps="xv X11_extensions_XvMClib_h" 1679 1681 xvmc_vld_deps="xvmc X11_extensions_vldXvMC_h" 1680 1682 xvmcw_deps="xvmc" 1683 vaapi_deps="opengl_video" 1681 1684 1682 1685 # default parameters 1683 1686 pre_logfile="config.ep" … … 3394 3397 check_header termios.h 3395 3398 check_header vdpau/vdpau.h 3396 3399 check_header vdpau/vdpau_x11.h 3400 check_header va/va.h 3401 check_header va/va_x11.h 3397 3402 check_header X11/extensions/XvMClib.h 3398 3403 3399 3404 check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex … … 3662 3667 disable vdpau; } 3663 3668 fi 3664 3669 3670 if ! disabled vaapi && enabled va_va_h; then 3671 enable vaapi 3672 fi 3673 3665 3674 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel" 3666 3675 enabled debug && add_cxxflags -g"$debuglevel" 3667 3676 … … 4219 4228 echo "XvMC libs $VENDOR_XVMC_LIBS" 4220 4229 fi 4221 4230 echo "VDPAU support ${vdpau-no}" 4231 echo "VAAPI support ${vaapi-no}" 4222 4232 fi 4223 4233 echo "OpenGL video ${opengl_video-no}" 4224 4234 if test x"$target_os" = x"darwin" ; then -
libs/libmythtv/videoout_openglvaapi.h
1 #ifndef VIDEOOUTPUTOPENGLVAAPI_H 2 #define VIDEOOUTPUTOPENGLVAAPI_H 3 4 #include "videoout_opengl.h" 5 #include "vaapicontext.h" 6 7 class VideoOutputOpenGLVAAPI : public VideoOutputOpenGL 8 { 9 public: 10 static void GetRenderOptions(render_opts &opts); 11 12 VideoOutputOpenGLVAAPI(MythCodecID codec_id); 13 ~VideoOutputOpenGLVAAPI(); 14 15 bool Init(int width, int height, float aspect, WId winid, 16 int winx, int winy, int winw, int winh, WId embedid = 0); 17 bool InitVAAPIContext(QSize size); 18 bool CreateBuffers(void); 19 void* GetVAAPIContext(void); 20 void SetProfile(void); 21 virtual void TearDown(void); 22 virtual bool InputChanged(const QSize &input_size, float aspect, 23 MythCodecID av_codec_id, void *codec_private, 24 bool &aspect_only); 25 uint8_t* GetSurfaceIDPointer(void* buf); 26 void ProcessFrame(VideoFrame *frame, OSD *osd, 27 FilterChain *filterList, 28 const PIPMap &pipPlayers, 29 FrameScanType scan); 30 virtual bool ApproveDeintFilter(const QString& filtername) const; 31 static QStringList GetAllowedRenderers(MythCodecID myth_codec_id, 32 const QSize &video_dim); 33 static MythCodecID GetBestSupportedCodec(uint width, uint height, 34 uint stream_type, 35 bool no_acceleration, 36 PixelFormat &pix_fmt); 37 38 private: 39 VAAPIContext *m_ctx; 40 }; 41 42 #endif // VIDEOOUTPUTOPENGLVAAPI_H 43 -
libs/libmythtv/videoout_opengl.cpp
8 8 #include "NuppelVideoPlayer.h" 9 9 #include "mythuihelper.h" 10 10 11 #define LOC QString("VidOut OGL: ")12 #define LOC_ERR QString("VidOut OGL: ")11 #define LOC QString("VidOutGL: ") 12 #define LOC_ERR QString("VidOutGL Error: ") 13 13 14 14 void VideoOutputOpenGL::GetRenderOptions(render_opts &opts, 15 15 QStringList &cpudeints) … … 37 37 opts.priorities->insert("opengl", 65); 38 38 } 39 39 40 VideoOutputOpenGL::VideoOutputOpenGL( void)40 VideoOutputOpenGL::VideoOutputOpenGL(MythCodecID codec_id) 41 41 : VideoOutput(), 42 gl_co ntext_lock(QMutex::Recursive),42 gl_codec_id(codec_id), gl_context_lock(QMutex::Recursive), 43 43 gl_context(NULL), gl_videochain(NULL), gl_pipchain_active(NULL), 44 44 gl_parent_win(0), gl_embed_win(0), gl_painter(NULL) 45 45 { … … 123 123 winid, winx, winy, winw, winh, 124 124 embedid); 125 125 126 if (db_vdisp_profile) 127 db_vdisp_profile->SetVideoRenderer("opengl"); 126 SetProfile(); 128 127 129 128 success &= SetupContext(); 130 129 InitDisplayMeasurements(width, height, false); 131 130 success &= CreateBuffers(); 131 success &= CreatePauseFrame(); 132 132 success &= SetupOpenGL(); 133 133 134 134 InitOSD(); … … 144 144 return success; 145 145 } 146 146 147 void VideoOutputOpenGL::SetProfile(void) 148 { 149 if (db_vdisp_profile) 150 db_vdisp_profile->SetVideoRenderer("opengl"); 151 } 152 147 153 bool VideoOutputOpenGL::InputChanged(const QSize &input_size, 148 154 float aspect, 149 155 MythCodecID av_codec_id, 150 156 void *codec_private, 151 157 bool &aspect_only) 152 158 { 153 VERBOSE(VB_PLAYBACK, LOC + QString("InputChanged(%1,%2,%3) %4 ")159 VERBOSE(VB_PLAYBACK, LOC + QString("InputChanged(%1,%2,%3) %4->%5") 154 160 .arg(input_size.width()).arg(input_size.height()).arg(aspect) 155 .arg(toString( av_codec_id)));161 .arg(toString(gl_codec_id)).arg(toString(av_codec_id))); 156 162 157 163 QMutexLocker locker(&gl_context_lock); 158 159 if (!codec_is_std( av_codec_id))164 gl_codec_id = av_codec_id; 165 if (!codec_is_std(gl_codec_id)) 160 166 { 161 167 VERBOSE(VB_IMPORTANT, LOC_ERR + 162 168 QString("New video codec is not supported.")); … … 242 248 windows[0].GetVideoDim(), dvr, 243 249 windows[0].GetDisplayVideoRect(), 244 250 windows[0].GetVideoRect(), true, 245 GetFilters(), db_letterbox_colour); 251 GetFilters(), !codec_is_std(gl_codec_id), 252 db_letterbox_colour); 246 253 if (success) 247 254 { 248 255 bool temp_deinterlacing = m_deinterlacing; … … 276 283 bool VideoOutputOpenGL::CreateBuffers(void) 277 284 { 278 285 QMutexLocker locker(&gl_context_lock); 279 280 bool success = true;281 286 vbuffers.Init(31, true, 1, 12, 4, 2, false); 282 success &= vbuffers.CreateBuffers(windows[0].GetVideoDim().width(), 283 windows[0].GetVideoDim().height()); 287 return vbuffers.CreateBuffers(windows[0].GetVideoDim().width(), 288 windows[0].GetVideoDim().height()); 289 } 284 290 291 bool VideoOutputOpenGL::CreatePauseFrame(void) 292 { 285 293 av_pause_frame.height = vbuffers.GetScratchFrame()->height; 286 294 av_pause_frame.width = vbuffers.GetScratchFrame()->width; 287 295 av_pause_frame.bpp = vbuffers.GetScratchFrame()->bpp; … … 290 298 av_pause_frame.frameNumber = vbuffers.GetScratchFrame()->frameNumber; 291 299 292 300 if (!av_pause_frame.buf) 293 { 294 success = false; 295 } 296 else 297 { 298 int size = av_pause_frame.width * av_pause_frame.height; 299 memset(av_pause_frame.buf, 0, size); 300 memset(av_pause_frame.buf + size, 127, size / 2); 301 } 301 return false; 302 302 303 return success; 303 int size = av_pause_frame.width * av_pause_frame.height; 304 memset(av_pause_frame.buf, 0, size); 305 memset(av_pause_frame.buf + size, 127, size / 2); 306 return true; 304 307 } 305 308 306 309 void VideoOutputOpenGL::ProcessFrame(VideoFrame *frame, OSD *osd, … … 312 315 if (!gl_videochain || !gl_context) 313 316 return; 314 317 318 bool sw_frame = codec_is_std(gl_codec_id); 315 319 bool deint_proc = m_deinterlacing && (m_deintFilter != NULL); 316 320 OpenGLLocker ctx_lock(gl_context); 317 321 … … 323 327 pauseframe = true; 324 328 } 325 329 326 if (filterList )330 if (filterList && sw_frame) 327 331 filterList->ProcessFrame(frame); 328 332 329 333 bool safepauseframe = pauseframe && !IsBobDeint(); 330 if ( deint_proc && m_deinterlaceBeforeOSD &&334 if (sw_frame && deint_proc && m_deinterlaceBeforeOSD && 331 335 (!pauseframe || safepauseframe)) 332 336 { 333 337 m_deintFilter->ProcessFrame(frame, scan); … … 339 343 ShowPIPs(frame, pipPlayers); 340 344 } 341 345 342 if ( (!pauseframe || safepauseframe) &&346 if (sw_frame && (!pauseframe || safepauseframe) && 343 347 deint_proc && !m_deinterlaceBeforeOSD) 344 348 { 345 349 m_deintFilter->ProcessFrame(frame, scan); … … 347 351 348 352 bool soft_bob = m_deinterlacing && (m_deintfiltername == "bobdeint"); 349 353 350 if (gl_videochain )354 if (gl_videochain && sw_frame) 351 355 gl_videochain->UpdateInputFrame(frame, soft_bob); 352 356 } 353 357 … … 371 375 framesPlayed = buffer->frameNumber + 1; 372 376 gl_context_lock.unlock(); 373 377 374 if (buffer->codec != FMT_YV12)375 return;378 //if (buffer->codec != FMT_YV12) 379 // return; 376 380 377 381 gl_videochain->SetVideoRect(vsz_enabled ? vsz_desired_display_rect : 378 382 windows[0].GetDisplayVideoRect(), … … 653 657 QSize(pipVideoWidth, pipVideoHeight), 654 658 dvr, position, 655 659 QRect(0, 0, pipVideoWidth, pipVideoHeight), 656 false, GetFilters() );660 false, GetFilters(), false); 657 661 gl_pipchain->SetMasterViewport(gl_videochain->GetViewPort()); 658 662 if (!success) 659 663 { … … 674 678 QSize(pipVideoWidth, pipVideoHeight), 675 679 dvr, position, 676 680 QRect(0, 0, pipVideoWidth, pipVideoHeight), 677 false, GetFilters() );681 false, GetFilters(), false); 678 682 679 683 gl_pipchain->SetMasterViewport(gl_videochain->GetViewPort()); 680 684 if (!success) -
libs/libmythtv/avformatdecoder.cpp
49 49 } 50 50 #endif // USING_VDPAU 51 51 52 #ifdef USING_VAAPI 53 #include "videoout_openglvaapi.h" 54 #endif // USING_VAAPI 55 52 56 extern "C" { 53 57 #include "avutil.h" 54 58 #include "ac3_parser.h" … … 92 96 void render_slice_vdpau(struct AVCodecContext *s, const AVFrame *src, 93 97 int offset[4], int y, int type, int height); 94 98 99 int get_avf_buffer_vaapi(struct AVCodecContext *c, AVFrame *pic); 100 95 101 static AVCodec *find_vdpau_decoder(AVCodec *c, enum CodecID id) 96 102 { 97 103 AVCodec *codec = c; … … 461 467 opts.decoders->append("vdpau"); 462 468 (*opts.equiv_decoders)["vdpau"].append("dummy"); 463 469 #endif 470 471 #ifdef USING_VAAPI 472 opts.decoders->append("vaapi"); 473 (*opts.equiv_decoders)["vaapi"].append("dummy"); 474 #endif 464 475 } 465 476 466 477 AvFormatDecoder::AvFormatDecoder(NuppelVideoPlayer *parent, … … 1368 1379 return fmt[i]; 1369 1380 } 1370 1381 1382 static bool IS_VAAPI_PIX_FMT(enum PixelFormat fmt) 1383 { 1384 return fmt == PIX_FMT_VAAPI_MOCO || 1385 fmt == PIX_FMT_VAAPI_IDCT || 1386 fmt == PIX_FMT_VAAPI_VLD; 1387 } 1388 1389 static enum PixelFormat get_format_vaapi(struct AVCodecContext *avctx, 1390 const enum PixelFormat *fmt) 1391 { 1392 if (!fmt) 1393 return PIX_FMT_NONE; 1394 int i = 0; 1395 for (; fmt[i] != PIX_FMT_NONE ; i++) 1396 if (IS_VAAPI_PIX_FMT(fmt[i])) 1397 break; 1398 return fmt[i]; 1399 } 1400 1371 1401 static bool IS_DR1_PIX_FMT(const enum PixelFormat fmt) 1372 1402 { 1373 1403 switch (fmt) … … 1472 1502 enc->draw_horiz_band = render_slice_vdpau; 1473 1503 enc->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD; 1474 1504 } 1505 else if (codec && IS_VAAPI_PIX_FMT(enc->pix_fmt)) 1506 { 1507 enc->get_buffer = get_avf_buffer_vaapi; 1508 enc->get_format = get_format_vaapi; 1509 enc->release_buffer = release_avf_buffer; 1510 enc->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD; // is this correct? 1511 } 1475 1512 else if (codec && codec->capabilities & CODEC_CAP_DR1) 1476 1513 { 1477 1514 enc->flags |= CODEC_FLAG_EMU_EDGE; … … 1954 1991 handled = true; 1955 1992 } 1956 1993 #endif // USING_VDPAU 1994 #ifdef USING_VAAPI 1995 MythCodecID vaapi_mcid; 1996 PixelFormat pix_fmt = PIX_FMT_YUV420P; 1997 vaapi_mcid = VideoOutputOpenGLVAAPI::GetBestSupportedCodec( 1998 width, height, mpeg_version(enc->codec_id), 1999 no_hardware_decoders, pix_fmt); 2000 2001 if (vaapi_mcid >= video_codec_id) 2002 { 2003 enc->codec_id = (CodecID)myth2av_codecid(vaapi_mcid); 2004 video_codec_id = vaapi_mcid; 2005 handled = true; 2006 if (!no_hardware_decoders && 2007 codec_is_vaapi_hw(video_codec_id)) 2008 { 2009 enc->pix_fmt = pix_fmt; 2010 } 2011 } 2012 #endif // USING_VAAPI 1957 2013 #ifdef USING_XVMC 1958 2014 1959 2015 bool force_xv = no_hardware_decoders; … … 2672 2728 } 2673 2729 } 2674 2730 2731 int get_avf_buffer_vaapi(struct AVCodecContext *c, AVFrame *pic) 2732 { 2733 AvFormatDecoder *nd = (AvFormatDecoder *)(c->opaque); 2734 VideoFrame *frame = nd->GetNVP()->GetNextVideoFrame(false); 2735 2736 pic->data[0] = frame->buf; 2737 pic->data[1] = frame->priv[0]; 2738 pic->data[2] = frame->priv[1]; 2739 2740 pic->linesize[0] = 0; 2741 pic->linesize[1] = 0; 2742 pic->linesize[2] = 0; 2743 2744 pic->opaque = frame; 2745 pic->type = FF_BUFFER_TYPE_USER; 2746 2747 pic->age = 256 * 256 * 256 * 64; 2748 2749 frame->pix_fmt = c->pix_fmt; 2750 2751 #ifdef USING_VAAPI 2752 if (nd->GetNVP()->getVideoOutput()) 2753 { 2754 VideoOutputOpenGLVAAPI *vo = 2755 dynamic_cast<VideoOutputOpenGLVAAPI*>(nd->GetNVP()->getVideoOutput()); 2756 c->hwaccel_context = (vaapi_context*)vo->GetVAAPIContext(); 2757 pic->data[3] = vo->GetSurfaceIDPointer(frame->buf); 2758 } 2759 #endif 2760 2761 return 0; 2762 } 2763 2675 2764 void AvFormatDecoder::DecodeDTVCC(const uint8_t *buf, uint len) 2676 2765 { 2677 2766 if (!len) -
libs/libmythtv/videoout_openglvaapi.cpp
1 #include "videoout_openglvaapi.h" 2 3 #define LOC QString("VidOutGLVAAPI: ") 4 #define LOC_ERR QString("VidOutGLVAAPI Error: ") 5 6 void VideoOutputOpenGLVAAPI::GetRenderOptions(render_opts &opts) 7 { 8 opts.renderers->append("openglvaapi"); 9 (*opts.deints)["openglvaapi"].append("vaapionefield"); 10 (*opts.deints)["openglvaapi"].append("vaapibobdeint"); 11 (*opts.deints)["openglvaapi"].append("none"); 12 (*opts.osds)["openglvaapi"].append("opengl2"); 13 14 if (opts.decoders->contains("vaapi")) 15 (*opts.safe_renderers)["vaapi"].append("openglvaapi"); 16 if (opts.decoders->contains("ffmpeg")) 17 (*opts.safe_renderers)["ffmpeg"].append("openglvaapi"); 18 if (opts.decoders->contains("libmpeg2")) 19 (*opts.safe_renderers)["libmpeg2"].append("openglvaapi"); 20 (*opts.safe_renderers)["dummy"].append("openglvaapi"); 21 (*opts.safe_renderers)["nuppel"].append("openglvaapi"); 22 23 opts.priorities->insert("openglvaapi", 110); 24 } 25 26 VideoOutputOpenGLVAAPI::VideoOutputOpenGLVAAPI(MythCodecID codec_id) 27 : VideoOutputOpenGL(codec_id), m_ctx(NULL) 28 { 29 if (gCoreContext->GetNumSetting("UseVideoModes", 0)) 30 display_res = DisplayRes::GetDisplayRes(true); 31 } 32 33 VideoOutputOpenGLVAAPI::~VideoOutputOpenGLVAAPI() 34 { 35 } 36 37 void VideoOutputOpenGLVAAPI::TearDown(void) 38 { 39 VideoOutputOpenGL::TearDown(); 40 delete m_ctx; 41 m_ctx = NULL; 42 } 43 44 bool VideoOutputOpenGLVAAPI::Init(int width, int height, float aspect, 45 WId winid, int winx, int winy, int winw, 46 int winh, WId embedid) 47 { 48 VERBOSE(VB_PLAYBACK, LOC + "Init"); 49 if (codec_is_vaapi_hw(gl_codec_id)) 50 if (!InitVAAPIContext(QSize(width, height))) 51 return false; 52 53 return VideoOutputOpenGL::Init(width, height, aspect, winid, winx, winy, 54 winw, winh, embedid); 55 } 56 57 bool VideoOutputOpenGLVAAPI::InputChanged(const QSize &input_size, float aspect, 58 MythCodecID av_codec_id, void *codec_private, 59 bool &aspect_only) 60 { 61 VERBOSE(VB_PLAYBACK, LOC + QString("InputChanged(%1,%2,%3) %4->%5") 62 .arg(input_size.width()).arg(input_size.height()).arg(aspect) 63 .arg(toString(gl_codec_id)).arg(toString(av_codec_id))); 64 65 if (!codec_is_vaapi_hw(av_codec_id)) 66 return VideoOutputOpenGL::InputChanged(input_size, aspect, av_codec_id, 67 codec_private, aspect_only); 68 69 QMutexLocker locker(&gl_context_lock); 70 bool cid_changed = (gl_codec_id != av_codec_id); 71 bool res_changed = input_size != windows[0].GetVideoDispDim(); 72 bool asp_changed = aspect != windows[0].GetVideoAspect(); 73 gl_codec_id = av_codec_id; 74 75 if (!res_changed && !cid_changed) 76 { 77 if (asp_changed) 78 { 79 aspect_only = true; 80 VideoAspectRatioChanged(aspect); 81 MoveResize(); 82 } 83 return true; 84 } 85 86 TearDown(); 87 QRect disp = windows[0].GetDisplayVisibleRect(); 88 if (Init(input_size.width(), input_size.height(), 89 aspect, gl_parent_win, disp.left(), disp.top(), 90 disp.width(), disp.height(), gl_embed_win)) 91 { 92 BestDeint(); 93 return true; 94 } 95 96 VERBOSE(VB_IMPORTANT, LOC_ERR + 97 QString("Failed to re-initialise video output.")); 98 errorState = kError_Unknown; 99 100 return false; 101 } 102 103 bool VideoOutputOpenGLVAAPI::InitVAAPIContext(QSize size) 104 { 105 if (m_ctx) 106 delete m_ctx; 107 m_ctx = new VAAPIContext(gl_codec_id); 108 if (m_ctx && m_ctx->Create(size)) 109 return true; 110 return false; 111 } 112 113 bool VideoOutputOpenGLVAAPI::CreateBuffers(void) 114 { 115 if (!codec_is_vaapi_hw(gl_codec_id) || !m_ctx) 116 return VideoOutputOpenGL::CreateBuffers(); 117 118 QMutexLocker locker(&gl_context_lock); 119 int num_buffers = m_ctx->GetNumBuffers(); 120 const QSize video_dim = windows[0].GetVideoDim(); 121 vbuffers.Init(num_buffers, true, 2, 1, 4, 1, false); // shouldn't need pause frame 122 123 bool ok = true; 124 for (int i = 0; i < num_buffers; i++) 125 { 126 ok &= vbuffers.CreateBuffer(video_dim.width(), 127 video_dim.height(), i, 128 m_ctx->GetVideoSurface(i)); 129 } 130 return ok; 131 } 132 133 void* VideoOutputOpenGLVAAPI::GetVAAPIContext(void) 134 { 135 if (m_ctx) 136 return &m_ctx->m_ctx; 137 return NULL; 138 } 139 140 void VideoOutputOpenGLVAAPI::SetProfile(void) 141 { 142 if (db_vdisp_profile) 143 db_vdisp_profile->SetVideoRenderer("openglvaapi"); 144 } 145 146 bool VideoOutputOpenGLVAAPI::ApproveDeintFilter(const QString &filtername) const 147 { 148 return filtername.contains("vaapi"); 149 } 150 151 uint8_t* VideoOutputOpenGLVAAPI::GetSurfaceIDPointer(void* buf) 152 { 153 if (m_ctx) 154 return m_ctx->GetSurfaceIDPointer(buf); 155 return NULL; 156 } 157 158 void VideoOutputOpenGLVAAPI::ProcessFrame(VideoFrame *frame, OSD *osd, 159 FilterChain *filterList, 160 const PIPMap &pipPlayers, 161 FrameScanType scan) 162 { 163 VideoOutputOpenGL::ProcessFrame(frame, osd, filterList, pipPlayers, scan); 164 if (codec_is_vaapi_hw(gl_codec_id) && m_ctx && gl_videochain && frame) 165 { 166 gl_context->makeCurrent(); 167 uint tex = gl_videochain->GetInputTexture(); 168 gl_context->EnableTextures(tex); 169 if (m_ctx->CopySurfaceToTexture(frame->buf, tex, 170 gl_videochain->GetTextureType())) 171 { 172 gl_videochain->SetInputUpdated(); 173 } 174 gl_context->doneCurrent(); 175 } 176 } 177 178 QStringList VideoOutputOpenGLVAAPI::GetAllowedRenderers( 179 MythCodecID myth_codec_id, const QSize &video_dim) 180 { 181 (void) video_dim; 182 QStringList list; 183 if ((codec_is_std(myth_codec_id) || codec_is_vaapi_hw(myth_codec_id)) && 184 !getenv("NO_VAAPI")) 185 { 186 list += "openglvaapi"; 187 } 188 return list; 189 } 190 191 MythCodecID VideoOutputOpenGLVAAPI::GetBestSupportedCodec( 192 uint width, uint height, 193 uint stream_type, bool no_acceleration, 194 PixelFormat &pix_fmt) 195 { 196 QSize size(width, height); 197 bool use_cpu = no_acceleration; 198 VideoDisplayProfile vdp; 199 vdp.SetInput(size); 200 QString dec = vdp.GetDecoder(); 201 202 MythCodecID test_cid = (MythCodecID)(kCodec_MPEG1_VAAPI + (stream_type-1)); 203 use_cpu |= !codec_is_vaapi_hw(test_cid); 204 use_cpu |= !VAAPIContext::IsFormatAccelerated(size, test_cid, pix_fmt); 205 if ((dec != "vaapi") || getenv("NO_VAAPI") || use_cpu) 206 return (MythCodecID)(kCodec_MPEG1 + (stream_type-1)); 207 208 return test_cid; 209 } -
libs/libmythtv/libmythtv.pro
344 344 345 345 using_glx_proc_addr_arb:DEFINES += USING_GLX_PROC_ADDR_ARB 346 346 347 using_vaapi: DEFINES += USING_VAAPI 348 using_vaapi: DEFINES += videoout_openglvaapi.h vaapicontext.h 349 using_vaapi: SOURCES += videoout_openglvaapi.cpp vaapicontext.cpp 350 using_vaapi: LIBS += -lva -lva-glx 351 347 352 # Misc. frontend 348 353 HEADERS += DetectLetterbox.h 349 354 SOURCES += DetectLetterbox.cpp -
libs/libmythtv/vaapicontext.cpp
1 #include <QHash> 2 3 #include "mythverbose.h" 4 #include "mythxdisplay.h" 5 #include "mythcodecid.h" 6 #include "vaapicontext.h" 7 8 #define LOC QString("VAAPI: ") 9 #define LOC_ERR QString("VAAPI Error: ") 10 #define NUM_VAAPI_BUFFERS 20 11 12 #define INIT_ST \ 13 VAStatus va_status; \ 14 bool ok = true; 15 16 #define CHECK_ST \ 17 ok &= (va_status == VA_STATUS_SUCCESS); \ 18 if (!ok) { \ 19 VERBOSE(VB_GENERAL, LOC_ERR + QString("Error at %1:%2 (#%3, %4)") \ 20 .arg(__FILE__).arg( __LINE__).arg(va_status) \ 21 .arg(vaErrorStr(va_status))); \ 22 } 23 24 #define CREATE_CHECK(arg1, arg2) \ 25 if (ok) \ 26 { \ 27 ok = arg1; \ 28 if (!ok) \ 29 VERBOSE(VB_IMPORTANT, LOC_ERR + arg2); \ 30 } 31 32 QString profileToString(VAProfile profile) 33 { 34 if (VAProfileMPEG2Simple == profile) return "MPEG2Simple"; 35 if (VAProfileMPEG2Main == profile) return "MPEG2Main"; 36 if (VAProfileMPEG4Simple == profile) return "MPEG4Simple"; 37 if (VAProfileMPEG4AdvancedSimple == profile) return "MPEG4AdvSimple"; 38 if (VAProfileMPEG4Main == profile) return "MPEG4Main"; 39 if (VAProfileH264Baseline == profile) return "H264Base"; 40 if (VAProfileH264Main == profile) return "H264Main"; 41 if (VAProfileH264High == profile) return "H264High"; 42 if (VAProfileVC1Simple == profile) return "VC1Simple"; 43 if (VAProfileVC1Main == profile) return "VC1Main"; 44 if (VAProfileVC1Advanced == profile) return "VC1Advanced"; 45 if (VAProfileH263Baseline == profile) return "H263Base"; 46 return "Unknown"; 47 } 48 49 QString entryToString(VAEntrypoint entry) 50 { 51 if (VAEntrypointVLD == entry) return "VLD "; 52 if (VAEntrypointIZZ == entry) return "IZZ "; 53 if (VAEntrypointIDCT == entry) return "IDCT "; 54 if (VAEntrypointMoComp == entry) return "MC "; 55 if (VAEntrypointDeblocking == entry) return "Deblock (UNSUPPORTED) "; 56 if (VAEntrypointEncSlice == entry) return "EncSlice (UNSUPPORTED) "; 57 return "Unknown"; 58 } 59 60 VAProfile preferredProfile(MythCodecID codec) 61 { 62 // FIXME handle unsupported codecs properly 63 if (kCodec_H263_VAAPI == codec) return VAProfileH263Baseline; 64 if (kCodec_MPEG4_VAAPI == codec) return VAProfileMPEG4AdvancedSimple; 65 if (kCodec_H264_VAAPI == codec) return VAProfileH264High; 66 if (kCodec_VC1_VAAPI == codec) return VAProfileVC1Advanced; 67 if (kCodec_WMV3_VAAPI == codec) return VAProfileVC1Main; 68 return VAProfileMPEG2Main; 69 } 70 71 bool VAAPIContext::IsFormatAccelerated(QSize size, MythCodecID codec, 72 PixelFormat &pix_fmt) 73 { 74 bool result = false; 75 VAAPIContext *ctx = new VAAPIContext(codec); 76 if (ctx) 77 { 78 result = ctx->CreateDummy(size); 79 pix_fmt = ctx->GetPixelFormat(); 80 } 81 delete ctx; 82 return result; 83 } 84 85 VAAPIContext::VAAPIContext(MythCodecID codec) 86 : m_codec(codec), m_display(NULL), 87 m_vaProfile(VAProfileMPEG2Main)/* ?? */, 88 m_vaEntrypoint(VAEntrypointEncSlice), 89 m_pix_fmt(PIX_FMT_YUV420P), m_numSurfaces(NUM_VAAPI_BUFFERS), 90 m_surfaces(NULL), m_surfaceData(NULL) 91 { 92 memset(&m_ctx, 0, sizeof(vaapi_context)); 93 } 94 95 VAAPIContext::~VAAPIContext() 96 { 97 INIT_ST 98 99 ClearGLXSurfaces(); 100 if (m_ctx.context_id) 101 { 102 va_status = vaDestroyContext(m_ctx.display, m_ctx.context_id); 103 CHECK_ST 104 } 105 if (m_ctx.config_id) 106 { 107 va_status = vaDestroyConfig(m_ctx.display, m_ctx.config_id); 108 CHECK_ST 109 } 110 if (m_surfaces) 111 { 112 va_status = vaDestroySurfaces(m_ctx.display, m_surfaces, m_numSurfaces); 113 CHECK_ST 114 } 115 116 if (m_ctx.display) 117 { 118 va_status = vaTerminate(m_ctx.display); 119 CHECK_ST 120 } 121 122 if (m_surfaces) 123 delete [] m_surfaces; 124 if (m_surfaceData) 125 delete [] m_surfaceData; 126 127 delete m_display; 128 VERBOSE(VB_PLAYBACK, LOC + "Deleted context"); 129 } 130 131 bool VAAPIContext::CreateDummy(QSize size)\ 132 { 133 m_size = size; 134 bool ok = true; 135 m_display = OpenMythXDisplay(); 136 CREATE_CHECK(!m_size.isEmpty(), "Invalid size") 137 CREATE_CHECK(m_display != NULL, "Invalid display") 138 CREATE_CHECK(InitDisplay(), "Invalid VADisplay") 139 CREATE_CHECK(InitProfiles(), "No supported profiles") 140 return ok; 141 } 142 143 bool VAAPIContext::Create(QSize size) 144 { 145 m_size = size; 146 bool ok = true; 147 m_display = OpenMythXDisplay(); 148 CREATE_CHECK(!m_size.isEmpty(), "Invalid size") 149 CREATE_CHECK(m_display != NULL, "Invalid display") 150 CREATE_CHECK(InitDisplay(), "Invalid VADisplay") 151 CREATE_CHECK(InitProfiles(), "No supported profiles") 152 CREATE_CHECK(InitBuffers(), "Failed to create buffers.") 153 CREATE_CHECK(InitContext(), "Failed to create context") 154 if (ok) 155 VERBOSE(VB_PLAYBACK, LOC + "Created context"); 156 return ok; 157 } 158 159 bool VAAPIContext::InitDisplay(void) 160 { 161 int major_ver, minor_ver; 162 m_ctx.display = vaGetDisplayGLX(m_display->GetDisplay()); 163 INIT_ST 164 va_status = vaInitialize(m_ctx.display, &major_ver, &minor_ver); 165 CHECK_ST 166 167 static bool debugged = false; 168 if (ok && !debugged) 169 { 170 debugged = true; 171 VERBOSE(VB_IMPORTANT, LOC + QString("Version: %1.%2") 172 .arg(major_ver).arg(minor_ver)); 173 VERBOSE(VB_IMPORTANT, LOC + QString("Vendor : %1") 174 .arg(vaQueryVendorString(m_ctx.display))); 175 } 176 return ok; 177 } 178 179 bool VAAPIContext::InitProfiles(void) 180 { 181 if (!codec_is_vaapi_hw(m_codec) || !m_ctx.display) 182 return false; 183 184 int max_profiles, max_entrypoints; 185 VAProfile profile_wanted = preferredProfile(m_codec); 186 VAProfile profile_found = VAProfileMPEG2Main; // FIXME 187 VAEntrypoint entry_found = VAEntrypointEncSlice; // unsupported value 188 189 max_profiles = vaMaxNumProfiles(m_ctx.display); 190 max_entrypoints = vaMaxNumEntrypoints(m_ctx.display); 191 VAProfile *profiles = new VAProfile[max_profiles]; 192 VAEntrypoint *entries = new VAEntrypoint[max_entrypoints]; 193 194 static bool debugged = false; 195 if (profiles && entries) 196 { 197 INIT_ST 198 int act_profiles, act_entries; 199 va_status = vaQueryConfigProfiles(m_ctx.display, 200 profiles, 201 &act_profiles); 202 CHECK_ST 203 if (ok && act_profiles > 0) 204 { 205 for (int i = 0; i < act_profiles; i++) 206 { 207 va_status = vaQueryConfigEntrypoints(m_ctx.display, 208 profiles[i], 209 entries, 210 &act_entries); 211 if (va_status == VA_STATUS_SUCCESS && act_entries > 0) 212 { 213 if (profiles[i] == profile_wanted) 214 { 215 profile_found = profile_wanted; 216 for (int j = 0; j < act_entries; j++) 217 if (entries[j] < entry_found) 218 entry_found = entries[j]; 219 } 220 221 if (!debugged) 222 { 223 QString entrylist = "Entrypoints: "; 224 for (int j = 0; j < act_entries; j++) 225 entrylist += entryToString(entries[j]); 226 VERBOSE(VB_IMPORTANT, LOC + QString("Profile: %1 %2") 227 .arg(profileToString(profiles[i])).arg(entrylist)); 228 } 229 } 230 } 231 } 232 debugged = true; 233 } 234 delete profiles; 235 delete entries; 236 237 VERBOSE(VB_PLAYBACK, LOC + QString("Desired profile for '%1': %2") 238 .arg(toString(m_codec)).arg(profileToString(profile_wanted))); 239 VERBOSE(VB_PLAYBACK, LOC + QString("Found profile %1 with entry %2") 240 .arg(profileToString(profile_found)).arg(entryToString(entry_found))); 241 242 if (profile_wanted != profile_found) 243 { 244 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to find supported profile."); 245 return false; 246 } 247 248 if (entry_found > VAEntrypointMoComp) 249 { 250 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to find suitable entry point."); 251 return false; 252 } 253 254 m_vaProfile = profile_wanted; 255 m_vaEntrypoint = entry_found; 256 if (VAEntrypointVLD == m_vaEntrypoint) 257 m_pix_fmt = PIX_FMT_VAAPI_VLD; 258 else if (VAEntrypointIDCT == m_vaEntrypoint) 259 m_pix_fmt = PIX_FMT_VAAPI_IDCT; 260 else if (VAEntrypointMoComp == m_vaEntrypoint) 261 m_pix_fmt = PIX_FMT_VAAPI_MOCO; 262 return true; 263 } 264 265 bool VAAPIContext::InitBuffers(void) 266 { 267 m_surfaces = new VASurfaceID[m_numSurfaces]; 268 m_surfaceData = new vaapi_surface[m_numSurfaces]; 269 270 if (!m_surfaces || !m_surfaceData) 271 return false; 272 273 INIT_ST 274 va_status = vaCreateSurfaces(m_ctx.display, m_size.width(), m_size.height(), 275 VA_RT_FORMAT_YUV420, m_numSurfaces, 276 m_surfaces); 277 CHECK_ST 278 279 for (int i =0; i < m_numSurfaces; i++) 280 m_surfaceData[i].m_id = m_surfaces[i]; 281 282 return ok; 283 } 284 285 bool VAAPIContext::InitContext(void) 286 { 287 if (!m_ctx.display || m_vaEntrypoint > VAEntrypointMoComp) 288 return false; 289 290 VAConfigAttrib attrib; 291 attrib.type = VAConfigAttribRTFormat; 292 INIT_ST 293 va_status = vaGetConfigAttributes(m_ctx.display, m_vaProfile, 294 m_vaEntrypoint, &attrib, 1); 295 CHECK_ST 296 297 if (!ok || !(attrib.value & VA_RT_FORMAT_YUV420)) 298 { 299 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to confirm YUV420 chroma"); 300 return false; 301 } 302 303 va_status = vaCreateConfig(m_ctx.display, m_vaProfile, m_vaEntrypoint, 304 &attrib, 1, &m_ctx.config_id); 305 CHECK_ST 306 if (!ok) 307 { 308 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to create decoder config."); 309 return false; 310 } 311 312 va_status = vaCreateContext(m_ctx.display, m_ctx.config_id, 313 m_size.width(), m_size.height(), VA_PROGRESSIVE, 314 m_surfaces, m_numSurfaces, 315 &m_ctx.context_id); 316 CHECK_ST 317 if (!ok) 318 { 319 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to create decoder context."); 320 return false; 321 } 322 return true; 323 } 324 325 void* VAAPIContext::GetVideoSurface(int i) 326 { 327 if (i < 0 || i >= m_numSurfaces) 328 return NULL; 329 return &m_surfaceData[i]; 330 } 331 332 uint8_t* VAAPIContext::GetSurfaceIDPointer(void* buf) 333 { 334 if (!buf) 335 return NULL; 336 const vaapi_surface *surf = (vaapi_surface*)buf; 337 return (uint8_t*)(uintptr_t)surf->m_id; 338 } 339 340 bool VAAPIContext::CopySurfaceToTexture(void* buf, uint texture, 341 uint texture_type) 342 { 343 if (!buf || !texture) 344 return false; 345 void* glx_surface = GetGLXSurface(texture, texture_type); 346 if (!glx_surface) 347 return false; 348 const vaapi_surface *surf = (vaapi_surface*)buf; 349 INIT_ST 350 va_status = vaCopySurfaceGLX(m_ctx.display, glx_surface, surf->m_id, 0); 351 CHECK_ST 352 return ok; 353 } 354 355 void* VAAPIContext::GetGLXSurface(uint texture, uint texture_type) 356 { 357 if (m_glxSurfaces.contains(texture)) 358 return m_glxSurfaces.value(texture); 359 360 361 void *glx_surface = NULL; 362 INIT_ST 363 glBindTexture(texture_type, texture); 364 va_status = vaCreateSurfaceGLX(m_ctx.display, texture_type, texture, 365 &glx_surface); 366 CHECK_ST 367 if (glx_surface) 368 m_glxSurfaces.insert(texture, glx_surface); 369 370 VERBOSE(VB_PLAYBACK, QString("Number of VAAPI GLX surfaces: %1") 371 .arg(m_glxSurfaces.size())); 372 return glx_surface; 373 } 374 375 void VAAPIContext::ClearGLXSurfaces(void) 376 { 377 INIT_ST 378 for (int i = 0; i < m_glxSurfaces.size(); i++) 379 { 380 va_status = vaDestroySurfaceGLX(m_ctx.display, m_glxSurfaces.value(i)); 381 CHECK_ST 382 } 383 m_glxSurfaces.clear(); 384 } -
libs/libmythtv/videoout_opengl.h
10 10 { 11 11 public: 12 12 static void GetRenderOptions(render_opts &opts, QStringList &cpudeints); 13 VideoOutputOpenGL( );14 ~VideoOutputOpenGL();13 VideoOutputOpenGL(MythCodecID codec_id); 14 virtual ~VideoOutputOpenGL(); 15 15 16 bool Init(int width, int height, float aspect, WId winid, 17 int winx, int winy, int winw, int winh, WId embedid = 0); 18 void TearDown(void); 16 virtual bool Init(int width, int height, float aspect, WId winid, 17 int winx, int winy, int winw, int winh, WId embedid = 0); 18 virtual void SetProfile(void); 19 virtual void TearDown(void); 19 20 20 21 void PrepareFrame(VideoFrame *buffer, FrameScanType, OSD *osd); 21 v oid ProcessFrame(VideoFrame *frame, OSD *osd,22 FilterChain *filterList,23 const PIPMap &pipPlayers,24 FrameScanType scan);25 v oid Show(FrameScanType );26 bool InputChanged(const QSize &input_size, float aspect,27 MythCodecID av_codec_id, void *codec_private,28 bool &aspect_only);22 virtual void ProcessFrame(VideoFrame *frame, OSD *osd, 23 FilterChain *filterList, 24 const PIPMap &pipPlayers, 25 FrameScanType scan); 26 virtual void Show(FrameScanType ); 27 virtual bool InputChanged(const QSize &input_size, float aspect, 28 MythCodecID av_codec_id, void *codec_private, 29 bool &aspect_only); 29 30 DisplayInfo GetDisplayInfo(void); 30 31 void UpdatePauseFrame(void); 31 32 void DrawUnusedRects(bool) { } … … 51 52 virtual bool ApproveDeintFilter(const QString& filtername) const; 52 53 virtual MythPainter *GetOSDPainter(void) { return (MythPainter*)gl_painter; } 53 54 54 private: 55 bool CreateBuffers(void); 55 protected: 56 virtual bool CreateBuffers(void); 57 bool CreatePauseFrame(void); 56 58 bool SetupContext(void); 57 59 bool SetupOpenGL(void); 58 60 void InitOSD(void); 59 61 62 MythCodecID gl_codec_id; 60 63 QMutex gl_context_lock; 61 64 MythRenderOpenGL *gl_context; 62 65 OpenGLVideo *gl_videochain; -
libs/libmythtv/openglvideo.h
44 44 QSize videoDim, QRect displayVisibleRect, 45 45 QRect displayVideoRect, QRect videoRect, 46 46 bool viewport_control, QString options, 47 bool hwaccel, 47 48 LetterBoxColour letterbox_colour = kLetterBoxColour_Black); 48 49 50 uint GetInputTexture(void); 51 uint GetTextureType(void); 52 void SetInputUpdated(void); 49 53 void UpdateInputFrame(const VideoFrame *frame, bool soft_bob = false); 50 54 51 55 /// \brief Public interface to AddFilter(OpenGLFilterType filter) … … 124 128 OpenGLFilterType defaultUpsize; 125 129 uint gl_features; 126 130 bool using_ycbcrtex; 131 bool using_hardwaretex; 127 132 LetterBoxColour gl_letterbox_colour; 128 133 }; 129 134 #endif // _OPENGL_VIDEO_H__ -
libs/libmythtv/openglvideo.cpp
84 84 textureRects(false), textureType(GL_TEXTURE_2D), 85 85 helperTexture(0), defaultUpsize(kGLFilterResize), 86 86 gl_features(0), using_ycbcrtex(false), 87 using_hardwaretex(false), 87 88 gl_letterbox_colour(kLetterBoxColour_Black) 88 89 { 89 90 } … … 139 140 QSize videoDim, QRect displayVisibleRect, 140 141 QRect displayVideoRect, QRect videoRect, 141 142 bool viewport_control, QString options, 143 bool hw_accel, 142 144 LetterBoxColour letterbox_colour) 143 145 { 144 146 gl_context = glcontext; … … 175 177 176 178 SetViewPort(display_visible_rect.size()); 177 179 178 bool use_pbo = gl_features & kGLExtPBufObj; 180 using_hardwaretex = hw_accel; 181 bool use_pbo = !using_hardwaretex && (gl_features & kGLExtPBufObj); 179 182 bool basic_features = gl_features & kGLExtFragProg; 180 183 bool full_features = basic_features && (gl_features & kGLExtFBufObj); 181 using_ycbcrtex = ! full_features && (gl_features & kGLYCbCrTex);184 using_ycbcrtex = !using_hardwaretex && !full_features && (gl_features & kGLYCbCrTex); 182 185 183 186 if (using_ycbcrtex) 184 187 basic_features = false; … … 192 195 QString("No OpenGL feature support for Bicubic filter.")); 193 196 } 194 197 195 if ((defaultUpsize != kGLFilterBicubic) && (gl_features & kGLExtRect)) 198 if (!using_hardwaretex && 199 (defaultUpsize != kGLFilterBicubic) && (gl_features & kGLExtRect)) 196 200 textureType = gl_context->GetTextureType(textureRects); 197 201 198 202 GLuint tex = 0; 199 203 bool ok = false; 200 204 201 if (basic_features )205 if (basic_features && !using_hardwaretex) 202 206 { 203 207 tex = CreateVideoTexture(actual_video_dim, inputTextureSize, use_pbo); 204 208 ok = tex && AddFilter(kGLFilterYUV2RGB); 205 209 } 206 else if (using_ycbcrtex )210 else if (using_ycbcrtex || using_hardwaretex) 207 211 { 208 212 tex = CreateVideoTexture(actual_video_dim, 209 213 inputTextureSize, use_pbo); 210 214 ok = tex && AddFilter(kGLFilterResize); 211 if (ok )215 if (ok && using_ycbcrtex) 212 216 VERBOSE(VB_PLAYBACK, LOC + QString("Using GL_MESA_ycbcr_texture for" 213 217 " colorspace conversion.")); 218 else if (ok && using_hardwaretex) 219 VERBOSE(VB_PLAYBACK, LOC + QString("Using plain RGBA tex for hw accel.")); 214 220 else 221 { 215 222 using_ycbcrtex = false; 223 using_hardwaretex = false; 224 } 216 225 } 217 226 218 227 if (ok) … … 707 716 tmp_tex = gl_context->CreateTexture(size, use_pbo, textureType, 708 717 GL_UNSIGNED_SHORT_8_8_MESA, 709 718 GL_YCBCR_MESA, GL_YCBCR_MESA); 719 else if (using_hardwaretex) 720 tmp_tex = gl_context->CreateTexture(size, use_pbo, textureType, 721 GL_UNSIGNED_BYTE, GL_RGBA, 722 GL_RGBA, GL_LINEAR, 723 GL_CLAMP_TO_EDGE); 710 724 else 711 725 tmp_tex = gl_context->CreateTexture(size, use_pbo, textureType); 712 726 tex_size = gl_context->GetTextureSize(textureType, size); … … 737 751 return QSize(w, h); 738 752 } 739 753 754 uint OpenGLVideo::GetInputTexture(void) 755 { 756 return inputTextures[0]; 757 } 758 759 uint OpenGLVideo::GetTextureType(void) 760 { 761 return textureType; 762 } 763 764 void OpenGLVideo::SetInputUpdated(void) 765 { 766 inputUpdated = true; 767 } 768 740 769 /** 741 770 * \fn OpenGLVideo::UpdateInputFrame(const VideoFrame *frame, bool soft_bob) 742 771 * Update the current input texture using the data from the given YV12 video … … 997 1026 program = filter->fragmentPrograms[prog_ref]; 998 1027 } 999 1028 1000 gl_context->DrawBitmap(textures, texture_count, target, &trect, &vrect,1001 program,1029 gl_context->DrawBitmap(textures, using_hardwaretex, texture_count, 1030 target, &trect, &vrect, program, 1002 1031 (useColourControl && type == kGLFilterYUV2RGB)); 1003 1032 1004 1033 inputs = filter->frameBufferTextures; -
libs/libmythtv/mythcodecid.h
76 76 77 77 kCodec_VDPAU_END, 78 78 79 kCodec_VAAPI_BEGIN = kCodec_VDPAU_END, 80 81 kCodec_MPEG1_VAAPI, 82 kCodec_MPEG2_VAAPI, 83 kCodec_H263_VAAPI, 84 kCodec_MPEG4_VAAPI, 85 kCodec_H264_VAAPI, 86 kCodec_VC1_VAAPI, 87 kCodec_WMV3_VAAPI, 88 89 kCodec_VAAPI_END, 79 90 } MythCodecID; 80 91 81 92 // MythCodecID convenience functions … … 93 104 (id < kCodec_VDPAU_END) 94 105 #define codec_is_vdpau_hw(id) (codec_is_vdpau(id) &&\ 95 106 (id != kCodec_H263_VDPAU)) 107 #define codec_is_vaapi(id) (id > kCodec_VAAPI_BEGIN) &&\ 108 (id < kCodec_VAAPI_END) 109 #define codec_is_vaapi_hw(id) (codec_is_vaapi(id) &&\ 110 (id != kCodec_H263_VAAPI)) 96 111 97 112 QString get_encoding_type(MythCodecID codecid); 98 113 QString get_decoder_name(MythCodecID codec_id, bool libmpeg2); -
libs/libmythtv/mythcodecid.cpp
92 92 case kCodec_WMV3_VDPAU: 93 93 return "WMV3 VDPAU"; 94 94 95 case kCodec_MPEG1_VAAPI: 96 return "MPEG1 VAAPI"; 97 case kCodec_MPEG2_VAAPI: 98 return "MPEG2 VAAPI"; 99 case kCodec_H263_VAAPI: 100 return "H.263 VAAPI"; 101 case kCodec_MPEG4_VAAPI: 102 return "MPEG4 VAAPI"; 103 case kCodec_H264_VAAPI: 104 return "H.264 VAAPI"; 105 case kCodec_VC1_VAAPI: 106 return "VC1 VAAPI"; 107 case kCodec_WMV3_VAAPI: 108 return "WMV3 VAAPI"; 109 95 110 default: 96 111 break; 97 112 } … … 228 243 vdpau = true; 229 244 break; 230 245 246 case kCodec_MPEG1_VAAPI: 247 ret = CODEC_ID_MPEG1VIDEO; 248 vld = idct = mc = true; 249 break; 250 case kCodec_MPEG2_VAAPI: 251 ret = CODEC_ID_MPEG2VIDEO; 252 vld = idct = mc = true; 253 break; 254 case kCodec_H263_VAAPI: 255 VERBOSE(VB_IMPORTANT, "Error: VAAPI H.263 not supported by ffmpeg"); 256 break; 257 case kCodec_MPEG4_VAAPI: 258 ret = CODEC_ID_MPEG4; 259 vld = true; 260 break; 261 case kCodec_H264_VAAPI: 262 ret = CODEC_ID_H264; 263 vld = true; 264 break; 265 case kCodec_VC1_VAAPI: 266 ret = CODEC_ID_VC1; 267 vld = true; 268 break; 269 case kCodec_WMV3_VAAPI: 270 ret = CODEC_ID_WMV3; 271 vld = true; 272 break; 273 231 274 default: 232 275 VERBOSE(VB_IMPORTANT, 233 276 QString("Error: MythCodecID %1 has not been " … … 283 326 case kCodec_MPEG2_VLD: 284 327 case kCodec_MPEG2_DVDV: 285 328 case kCodec_MPEG2_VDPAU: 329 case kCodec_MPEG2_VAAPI: 286 330 return "MPEG-2"; 287 331 288 332 case kCodec_H263: … … 291 335 case kCodec_H263_VLD: 292 336 case kCodec_H263_DVDV: 293 337 case kCodec_H263_VDPAU: 338 case kCodec_H263_VAAPI: 294 339 return "H.263"; 295 340 296 341 case kCodec_NUV_MPEG4: … … 300 345 case kCodec_MPEG4_VLD: 301 346 case kCodec_MPEG4_DVDV: 302 347 case kCodec_MPEG4_VDPAU: 348 case kCodec_MPEG4_VAAPI: 303 349 return "MPEG-4"; 304 350 305 351 case kCodec_H264: … … 338 384 if (codec_is_vdpau(codec_id)) 339 385 return "vdpau"; 340 386 387 if (codec_is_vaapi(codec_id)) 388 return "vaapi"; 389 341 390 return "ffmpeg"; 342 391 } -
libs/libmythtv/videooutbase.cpp
40 40 #include "videoout_vdpau.h" 41 41 #endif 42 42 43 #ifdef USING_VAAPI 44 #include "videoout_openglvaapi.h" 45 #endif 46 43 47 #include "videoout_null.h" 44 48 #include "dithertable.h" 45 49 … … 96 100 #ifdef USING_VDPAU 97 101 VideoOutputVDPAU::GetRenderOptions(opts); 98 102 #endif // USING_VDPAU 103 104 #ifdef USING_VAAPI 105 VideoOutputOpenGLVAAPI::GetRenderOptions(opts); 106 #endif // USING_VAAPI 99 107 } 100 108 101 109 /** … … 143 151 renderers += VideoOutputVDPAU::GetAllowedRenderers(codec_id, video_dim); 144 152 #endif // USING_VDPAU 145 153 154 #ifdef USING_VAAPI 155 renderers += VideoOutputOpenGLVAAPI::GetAllowedRenderers(codec_id, video_dim); 156 #endif // USING_VAAPI 157 146 158 VERBOSE(VB_PLAYBACK, LOC + "Allowed renderers: " + 147 159 to_comma_list(renderers)); 148 160 … … 197 209 198 210 #ifdef USING_OPENGL_VIDEO 199 211 if (renderer == "opengl") 200 vo = new VideoOutputOpenGL( );212 vo = new VideoOutputOpenGL(codec_id); 201 213 #endif // USING_OPENGL_VIDEO 202 214 203 215 #ifdef USING_VDPAU … … 205 217 vo = new VideoOutputVDPAU(codec_id); 206 218 #endif // USING_VDPAU 207 219 220 #ifdef USING_VAAPI 221 if (renderer == "openglvaapi") 222 vo = new VideoOutputOpenGLVAAPI(codec_id); 223 #endif // USING_VAAPI 224 208 225 #ifdef USING_XV 209 226 if (xvlist.contains(renderer)) 210 227 vo = new VideoOutputXv(codec_id); -
libs/libmythtv/vaapicontext.h
1 #ifndef VAAPICONTEXT_H 2 #define VAAPICONTEXT_H 3 4 extern "C" { 5 #include "libavcodec/vaapi.h" 6 } 7 8 #include "va/va.h" 9 #include "va/va_glx.h" 10 11 #include <QHash> 12 13 struct vaapi_surface 14 { 15 VASurfaceID m_id; 16 }; 17 18 class VAAPIContext 19 { 20 public: 21 static bool IsFormatAccelerated(QSize size, MythCodecID codec, 22 PixelFormat &pix_fmt); 23 VAAPIContext(MythCodecID codec); 24 ~VAAPIContext(); 25 26 bool Create(QSize size); 27 bool CreateDummy(QSize size); 28 void* GetVideoSurface(int i); 29 uint8_t* GetSurfaceIDPointer(void* buf); 30 31 int GetNumBuffers(void) { return m_numSurfaces; } 32 PixelFormat GetPixelFormat(void) { return m_pix_fmt; } 33 34 35 // temp hack 36 void ShowSurface(int win, QRect &rect, void* buf); 37 38 bool CopySurfaceToTexture(void* buf, uint texture, uint texture_type); 39 void* GetGLXSurface(uint texture, uint texture_type); 40 void ClearGLXSurfaces(void); 41 42 bool InitDisplay(void); 43 bool InitProfiles(void); 44 bool InitBuffers(void); 45 bool InitContext(void); 46 47 vaapi_context m_ctx; 48 MythCodecID m_codec; 49 QSize m_size; 50 MythXDisplay *m_display; 51 VAProfile m_vaProfile; 52 VAEntrypoint m_vaEntrypoint; 53 PixelFormat m_pix_fmt; 54 int m_numSurfaces; 55 VASurfaceID *m_surfaces; 56 vaapi_surface *m_surfaceData; 57 QHash<uint, void*> m_glxSurfaces; 58 59 }; 60 61 #endif // VAAPICONTEXT_H -
libs/libmythtv/videodisplayprofile.cpp
642 642 dec_name["xvmc-vld"] = QObject::tr("VIA XvMC"); 643 643 dec_name["macaccel"] = QObject::tr("Mac hardware acceleration"); 644 644 dec_name["vdpau"] = QObject::tr("NVidia VDPAU acceleration"); 645 dec_name["vaapi"] = QObject::tr("VA API"); 645 646 } 646 647 647 648 QString ret = decoder; … … 691 692 "VDPAU will attempt to use the graphics hardware to " 692 693 "accelerate video decoding and playback."); 693 694 695 if (decoder == "vaapi") 696 msg += QObject::tr( 697 "VAAPI will attempt to use the graphics hardware to " 698 "accelerate video decoding and playback."); 699 694 700 return msg; 695 701 } 696 702 … … 736 742 return QObject::tr("Yadif (2x, Hw)"); 737 743 else if ("openglyadif" == short_name) 738 744 return QObject::tr("Yadif (Hw)"); 739 else if ("vdpauonefield" == short_name )745 else if ("vdpauonefield" == short_name || "vaapionefield" == short_name) 740 746 return QObject::tr("One Field (1x, Hw)"); 741 else if ("vdpaubobdeint" == short_name )747 else if ("vdpaubobdeint" == short_name || "vaapibobdeint" == short_name) 742 748 return QObject::tr("Bob (2x, Hw)"); 743 749 else if ("vdpaubasic" == short_name) 744 750 return QObject::tr("Temporal (1x, Hw)"); … … 1237 1243 "This is the only video renderer for NVidia VDPAU decoding."); 1238 1244 } 1239 1245 1246 if (renderer == "openglvaapi") 1247 { 1248 msg = QObject::tr( 1249 "This is the only video renderer for VAAPI decoding."); 1250 } 1251 1240 1252 return msg; 1241 1253 } 1242 1254 … … 1358 1370 msg = kFieldOrderMsg + " " + kDoubleRateMsg; 1359 1371 else if (deint == "opengldoublerateyadif") 1360 1372 msg = kYadifMsg + " " + kDoubleRateMsg + " " + kUsingGPU; 1361 else if (deint == "vdpauonefield" )1373 else if (deint == "vdpauonefield" || deint == "vaapionefield") 1362 1374 msg = kOneFieldMsg + " " + kUsingGPU; 1363 else if (deint == "vdpaubobdeint" )1375 else if (deint == "vdpaubobdeint" || deint == "vaapibobdeint") 1364 1376 msg = kBobMsg + " " + kUsingGPU; 1365 1377 else if (deint == "vdpaubasic") 1366 1378 msg = kBasicMsg + " " + kUsingGPU; -
libs/libavutil/internal.h
242 242 #define log2f(x) log2(x) 243 243 #endif /* HAVE_LOG2F */ 244 244 245 #if !HAVE_LRINT246 static av_always_inline av_const long int lrint(double x)247 {248 return rint(x);249 }250 #endif /* HAVE_LRINT */251 252 245 #if !HAVE_LRINTF 253 246 static av_always_inline av_const long int lrintf(float x) 254 247 { … … 256 249 } 257 250 #endif /* HAVE_LRINTF */ 258 251 259 #if !HAVE_ROUND260 static av_always_inline av_const double round(double x)261 {262 return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);263 }264 #endif /* HAVE_ROUND */265 266 252 #if !HAVE_ROUNDF 267 253 static av_always_inline av_const float roundf(float x) 268 254 { -
libs/libmythui/mythrender_opengl.h
116 116 void DrawBitmap(uint tex, uint target, const QRect *src, const QRect *dst, 117 117 uint prog, int alpha = 255, int red = 255, int green = 255, 118 118 int blue = 255); 119 void DrawBitmap(uint *textures, uint texture_count, uint target,120 const QRectF *src, const QRectF *dst, uint prog,121 bool colour_control = false);119 void DrawBitmap(uint *textures, bool use_full_tex, uint texture_count, 120 uint target, const QRectF *src, const QRectF *dst, 121 uint prog, bool colour_control = false); 122 122 void DrawRect(const QRect &area, bool drawFill, 123 123 const QColor &fillColor, bool drawLine, 124 124 int lineWidth, const QColor &lineColor, -
libs/libmythui/mythrender_opengl.cpp
1075 1075 doneCurrent(); 1076 1076 } 1077 1077 1078 void MythRenderOpenGL::DrawBitmap(uint *textures, uint texture_count, 1078 void MythRenderOpenGL::DrawBitmap(uint *textures, bool use_full_tex, 1079 uint texture_count, 1079 1080 uint target, const QRectF *src, 1080 1081 const QRectF *dst, uint prog, 1081 1082 bool colour_control) … … 1094 1095 uint first = textures[0]; 1095 1096 if (!IsRectTexture(m_textures[first].m_type)) 1096 1097 { 1097 srcx1 = src->x() / m_textures[first].m_size.width(); 1098 srcx2 = srcx1 + src->width() / m_textures[first].m_size.width(); 1099 srcy1 = src->y() / m_textures[first].m_size.height(); 1100 srcy2 = srcy1 + src->height() / m_textures[first].m_size.height(); 1098 int width = use_full_tex ? m_textures[first].m_act_size.width() : 1099 m_textures[first].m_size.width(); 1100 int height = use_full_tex ? m_textures[first].m_act_size.height() : 1101 m_textures[first].m_size.height(); 1102 srcx1 = src->x() / width; 1103 srcx2 = srcx1 + src->width() / width; 1104 srcy1 = src->y() / height; 1105 srcy2 = srcy1 + src->height() / height; 1101 1106 } 1102 1107 else 1103 1108 {