Ticket #13311: 20180819_1111_vaaapi.patch
File 20180819_1111_vaaapi.patch, 25.0 KB (added by , 6 years ago) |
---|
-
mythtv/configure
diff --git a/mythtv/configure b/mythtv/configure index 07c67f7ebb5..2f1e147ddac 100755
a b Advanced options (experts only): 134 134 --disable-vdpau disable NVidia VDPAU hardware acceleration. 135 135 --disable-crystalhd disable Broadcom CrystalHD hardware decoder support 136 136 --disable-vaapi disable VAAPI hardware accelerated video decoding 137 --disable-vaapi2 disable VAAPI@ hardware accelerated video decoding 137 138 --disable-openmax disable OpenMAX hardware accelerated video decoding 138 139 --disable-dxva2 disable hardware accelerated decoding on windows 139 140 --disable-mediacodec disable hardware accelerated decoding on android … … HWACCEL_AUTODETECT_LIBRARY_LIST=" 1401 1402 crystalhd 1402 1403 dxva2 1403 1404 vaapi 1405 vaapi2 1404 1406 vda 1405 1407 vdpau 1406 1408 " … … USING_LIST=' 2040 2042 opengl 2041 2043 opengles 2042 2044 vaapi 2045 vaapi2 2043 2046 vdpau 2044 2047 openmax 2045 2048 mediacodec … … if enabled x11 ; then 7273 7276 echo "xv support ${xv-no}" 7274 7277 echo "VDPAU support ${vdpau-no}" 7275 7278 echo "VAAPI support ${vaapi-no}" 7279 echo "VAAPI2 support ${vaapi2-no}" 7276 7280 echo "CrystalHD support ${crystalhd-no}" 7277 7281 echo "OpenMAX support ${openmax-no}" 7278 7282 if enabled openmax ; then -
mythtv/libs/libmythtv/avformatdecoder.cpp
diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp index 6b9cca5663a..69a99ac4cc2 100644
a b extern "C" { 70 70 #include <QtAndroidExtras> 71 71 #endif 72 72 73 #ifdef USING_VAAPI2 74 #include "vaapi2context.h" 75 #endif 76 73 77 extern "C" { 74 78 #include "libavutil/avutil.h" 75 79 #include "libavutil/error.h" … … void AvFormatDecoder::GetDecoders(render_opts &opts) 385 389 opts.decoders->append("vaapi"); 386 390 (*opts.equiv_decoders)["vaapi"].append("dummy"); 387 391 #endif 392 #ifdef USING_VAAPI2 393 opts.decoders->append("vaapi2"); 394 (*opts.equiv_decoders)["vaapi2"].append("dummy"); 395 #endif 388 396 #ifdef USING_MEDIACODEC 389 397 opts.decoders->append("mediacodec"); 390 398 (*opts.equiv_decoders)["mediacodec"].append("dummy"); … … enum AVPixelFormat get_format_dxva2(struct AVCodecContext *avctx, 1520 1528 } 1521 1529 #endif 1522 1530 1523 #ifdef USING_VAAPI 1531 1524 1532 static bool IS_VAAPI_PIX_FMT(enum AVPixelFormat fmt) 1525 1533 { 1526 1534 return fmt == AV_PIX_FMT_VAAPI_MOCO || … … static bool IS_VAAPI_PIX_FMT(enum AVPixelFormat fmt) 1528 1536 fmt == AV_PIX_FMT_VAAPI_VLD; 1529 1537 } 1530 1538 1539 #ifdef USING_VAAPI 1540 1531 1541 // Declared separately to allow attribute 1532 1542 static enum AVPixelFormat get_format_vaapi(struct AVCodecContext *, 1533 1543 const enum AVPixelFormat *) MUNUSED; … … enum AVPixelFormat get_format_vaapi(struct AVCodecContext *avctx, 1554 1564 } 1555 1565 #endif 1556 1566 1567 #ifdef USING_VAAPI2 1568 static enum AVPixelFormat get_format_vaapi2(struct AVCodecContext *avctx, 1569 const enum AVPixelFormat *valid_fmts) 1570 { 1571 enum AVPixelFormat ret = AV_PIX_FMT_NONE; 1572 while (*valid_fmts != AV_PIX_FMT_NONE) { 1573 if (IS_VAAPI_PIX_FMT(*valid_fmts)) 1574 { 1575 ret = *valid_fmts; 1576 break; 1577 } 1578 valid_fmts++; 1579 } 1580 1581 // AVBufferRef* dev_ctx = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI); 1582 // AVBufferRef* frame_ctx = av_hwframe_ctx_alloc(dev_ctx); 1583 // avctx->hw_frames_ctx = frame_ctx; 1584 // avctx->hwaccel_context = 1585 return ret; 1586 } 1587 #endif 1588 1557 1589 #ifdef USING_MEDIACODEC 1558 1590 static enum AVPixelFormat get_format_mediacodec(struct AVCodecContext *avctx, 1559 1591 const enum AVPixelFormat *valid_fmts) … … void AvFormatDecoder::InitVideoCodec(AVStream *stream, AVCodecContext *enc, 1634 1666 else 1635 1667 #endif 1636 1668 #ifdef USING_VAAPI 1637 if (CODEC_IS_VAAPI(codec, enc) )1669 if (CODEC_IS_VAAPI(codec, enc) && codec_is_vaapi(video_codec_id)) 1638 1670 { 1639 1671 enc->get_buffer2 = get_avf_buffer_vaapi; 1640 1672 enc->get_format = get_format_vaapi; … … void AvFormatDecoder::InitVideoCodec(AVStream *stream, AVCodecContext *enc, 1649 1681 enc->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD; 1650 1682 } 1651 1683 else 1684 #endif 1685 #ifdef USING_VAAPI2 1686 if (codec_is_vaapi2(video_codec_id)) 1687 { 1688 enc->get_format = get_format_vaapi2; 1689 // TODO - check return code from following call 1690 Vaapi2Context::HwDecoderInit(enc); 1691 } 1692 else 1652 1693 #endif 1653 1694 if (codec && codec->capabilities & AV_CODEC_CAP_DR1) 1654 1695 { … … int AvFormatDecoder::ScanStreams(bool novideo) 2542 2583 foundgpudecoder = true; 2543 2584 } 2544 2585 } 2586 #endif // USING_MEDIACODEC 2587 #ifdef USING_VAAPI2 2588 if (!foundgpudecoder) 2589 { 2590 MythCodecID vaapi2_mcid; 2591 AVPixelFormat pix_fmt = AV_PIX_FMT_YUV420P; 2592 vaapi2_mcid = Vaapi2Context::GetBestSupportedCodec( 2593 &codec, dec, mpeg_version(enc->codec_id), 2594 pix_fmt); 2595 2596 if (codec_is_vaapi2(vaapi2_mcid)) 2597 { 2598 gCodecMap->freeCodecContext(ic->streams[selTrack]); 2599 enc = gCodecMap->getCodecContext(ic->streams[selTrack], codec); 2600 video_codec_id = vaapi2_mcid; 2601 foundgpudecoder = true; 2602 } 2603 } 2545 2604 #endif // USING_MEDIACODEC 2546 2605 } 2547 2606 // default to mpeg2 … … int AvFormatDecoder::ScanStreams(bool novideo) 2563 2622 2564 2623 use_frame_timing = false; 2565 2624 if (! private_dec 2566 && (codec_is_std(video_codec_id) || codec_is_mediacodec(video_codec_id))) 2625 && (codec_is_std(video_codec_id) 2626 || codec_is_mediacodec(video_codec_id)) 2627 || codec_is_vaapi2(video_codec_id)) 2567 2628 use_frame_timing = true; 2568 2629 2569 2630 if (FlagIsSet(kDecodeSingleThreaded)) … … bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic) 3847 3908 } 3848 3909 else if (!directrendering) 3849 3910 { 3911 AVFrame *tmp_frame = NULL; 3912 3913 if (IS_VAAPI_PIX_FMT((AVPixelFormat)mpa_pic->format)) 3914 { 3915 int ret = 0; 3916 tmp_frame = av_frame_alloc(); 3917 /* retrieve data from GPU to CPU */ 3918 if ((ret = av_hwframe_transfer_data(tmp_frame, mpa_pic, 0)) < 0) { 3919 LOG(VB_GENERAL, LOG_ERR, LOC 3920 + QString("Error %1 transferring the data to system memory") 3921 .arg(ret)); 3922 av_frame_free(&tmp_frame); 3923 return false; 3924 } 3925 } 3926 else 3927 tmp_frame = mpa_pic; 3928 3850 3929 AVFrame tmppicture; 3851 3930 3852 3931 VideoFrame *xf = picframe; … … bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic) 3854 3933 3855 3934 unsigned char *buf = picframe->buf; 3856 3935 av_image_fill_arrays(tmppicture.data, tmppicture.linesize, 3857 buf, AV_PIX_FMT_YUV420P, context->width,3858 context->height, IMAGE_ALIGN);3936 buf, AV_PIX_FMT_YUV420P, tmp_frame->width, 3937 tmp_frame->height, IMAGE_ALIGN); 3859 3938 tmppicture.data[0] = buf + picframe->offsets[0]; 3860 3939 tmppicture.data[1] = buf + picframe->offsets[1]; 3861 3940 tmppicture.data[2] = buf + picframe->offsets[2]; … … bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic) 3864 3943 tmppicture.linesize[2] = picframe->pitches[2]; 3865 3944 3866 3945 QSize dim = get_video_dim(*context); 3867 sws_ctx = sws_getCachedContext(sws_ctx, context->width,3868 context->height, context->pix_fmt,3869 context->width, context->height,3946 sws_ctx = sws_getCachedContext(sws_ctx, tmp_frame->width, 3947 tmp_frame->height, (AVPixelFormat)tmp_frame->format, 3948 tmp_frame->width, tmp_frame->height, 3870 3949 AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, 3871 3950 NULL, NULL, NULL); 3872 3951 if (!sws_ctx) … … bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic) 3874 3953 LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to allocate sws context"); 3875 3954 return false; 3876 3955 } 3877 sws_scale(sws_ctx, mpa_pic->data, mpa_pic->linesize, 0, dim.height(),3956 sws_scale(sws_ctx, tmp_frame->data, tmp_frame->linesize, 0, dim.height(), 3878 3957 tmppicture.data, tmppicture.linesize); 3879 3958 3880 3959 if (xf) … … bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic) 3887 3966 xf->aspect = current_aspect; 3888 3967 m_parent->DiscardVideoFrame(xf); 3889 3968 } 3969 if (tmp_frame) 3970 av_frame_free(&tmp_frame); 3890 3971 } 3891 3972 else if (!picframe) 3892 3973 { -
mythtv/libs/libmythtv/libmythtv.pro
diff --git a/mythtv/libs/libmythtv/libmythtv.pro b/mythtv/libs/libmythtv/libmythtv.pro index 939ca20984b..75efa55ec13 100644
a b using_frontend { 505 505 using_opengl_video:DEFINES += USING_GLVAAPI 506 506 } 507 507 508 using_vaapi2 { 509 DEFINES += USING_VAAPI2 510 HEADERS += vaapi2context.h 511 SOURCES += vaapi2context.cpp 512 } 513 508 514 using_mediacodec { 509 515 DEFINES += USING_MEDIACODEC 510 516 HEADERS += mediacodeccontext.h -
mythtv/libs/libmythtv/mythcodecid.cpp
diff --git a/mythtv/libs/libmythtv/mythcodecid.cpp b/mythtv/libs/libmythtv/mythcodecid.cpp index b2023512b5f..cff4ba03585 100644
a b QString toString(MythCodecID codecid) 123 123 case kCodec_HEVC_MEDIACODEC: 124 124 return "HEVC MEDIACODEC"; 125 125 126 case kCodec_MPEG1_VAAPI2: 127 return "MPEG1 VAAPI2"; 128 case kCodec_MPEG2_VAAPI2: 129 return "MPEG2 VAAPI2"; 130 case kCodec_H263_VAAPI2: 131 return "H.263 VAAPI2"; 132 case kCodec_MPEG4_VAAPI2: 133 return "MPEG4 VAAPI2"; 134 case kCodec_H264_VAAPI2: 135 return "H.264 VAAPI2"; 136 case kCodec_VC1_VAAPI2: 137 return "VC1 VAAPI2"; 138 case kCodec_WMV3_VAAPI2: 139 return "WMV3 VAAPI2"; 140 case kCodec_VP8_VAAPI2: 141 return "VP8 VAAPI2"; 142 case kCodec_VP9_VAAPI2: 143 return "VP9 VAAPI2"; 144 case kCodec_HEVC_VAAPI2: 145 return "HEVC VAAPI2"; 146 126 147 default: 127 148 break; 128 149 } … … int myth2av_codecid(MythCodecID codec_id, bool &vdpau) 305 326 ret = AV_CODEC_ID_HEVC; 306 327 break; 307 328 329 case kCodec_MPEG1_VAAPI2: 330 ret = AV_CODEC_ID_MPEG1VIDEO; 331 break; 332 case kCodec_MPEG2_VAAPI2: 333 ret = AV_CODEC_ID_MPEG2VIDEO; 334 break; 335 case kCodec_H263_VAAPI2: 336 ret = AV_CODEC_ID_H263; 337 break; 338 case kCodec_MPEG4_VAAPI2: 339 ret = AV_CODEC_ID_MPEG4; 340 break; 341 case kCodec_H264_VAAPI2: 342 ret = AV_CODEC_ID_H264; 343 break; 344 case kCodec_VC1_VAAPI2: 345 ret = AV_CODEC_ID_VC1; 346 break; 347 case kCodec_WMV3_VAAPI2: 348 ret = AV_CODEC_ID_WMV3; 349 break; 350 case kCodec_VP8_VAAPI2: 351 ret = AV_CODEC_ID_VP8; 352 break; 353 case kCodec_VP9_VAAPI2: 354 ret = AV_CODEC_ID_VP9; 355 break; 356 case kCodec_HEVC_VAAPI2: 357 ret = AV_CODEC_ID_HEVC; 358 break; 359 308 360 default: 309 361 LOG(VB_GENERAL, LOG_ERR, 310 362 QString("Error: MythCodecID %1 has not been " … … QString get_encoding_type(MythCodecID codecid) 356 408 case kCodec_MPEG1_VAAPI: 357 409 case kCodec_MPEG1_DXVA2: 358 410 case kCodec_MPEG1_MEDIACODEC: 411 case kCodec_MPEG1_VAAPI2: 359 412 case kCodec_MPEG2: 360 413 case kCodec_MPEG2_VDPAU: 361 414 case kCodec_MPEG2_VAAPI: 362 415 case kCodec_MPEG2_DXVA2: 363 416 case kCodec_MPEG2_MEDIACODEC: 417 case kCodec_MPEG2_VAAPI2: 364 418 return "MPEG-2"; 365 419 366 420 case kCodec_H263: … … QString get_encoding_type(MythCodecID codecid) 368 422 case kCodec_H263_VAAPI: 369 423 case kCodec_H263_DXVA2: 370 424 case kCodec_H263_MEDIACODEC: 425 case kCodec_H263_VAAPI2: 371 426 return "H.263"; 372 427 373 428 case kCodec_NUV_MPEG4: … … QString get_encoding_type(MythCodecID codecid) 376 431 case kCodec_MPEG4_VAAPI: 377 432 case kCodec_MPEG4_DXVA2: 378 433 case kCodec_MPEG4_MEDIACODEC: 434 case kCodec_MPEG4_VAAPI2: 379 435 return "MPEG-4"; 380 436 381 437 case kCodec_H264: … … QString get_encoding_type(MythCodecID codecid) 383 439 case kCodec_H264_VAAPI: 384 440 case kCodec_H264_DXVA2: 385 441 case kCodec_H264_MEDIACODEC: 442 case kCodec_H264_VAAPI2: 386 443 return "H.264"; 387 444 388 445 case kCodec_VC1: … … QString get_encoding_type(MythCodecID codecid) 390 447 case kCodec_VC1_VAAPI: 391 448 case kCodec_VC1_DXVA2: 392 449 case kCodec_VC1_MEDIACODEC: 450 case kCodec_VC1_VAAPI2: 393 451 return "VC-1"; 394 452 395 453 case kCodec_WMV3: … … QString get_encoding_type(MythCodecID codecid) 397 455 case kCodec_WMV3_VAAPI: 398 456 case kCodec_WMV3_DXVA2: 399 457 case kCodec_WMV3_MEDIACODEC: 458 case kCodec_WMV3_VAAPI2: 400 459 return "WMV3"; 401 460 402 461 case kCodec_VP8: … … QString get_encoding_type(MythCodecID codecid) 404 463 case kCodec_VP8_VAAPI: 405 464 case kCodec_VP8_DXVA2: 406 465 case kCodec_VP8_MEDIACODEC: 466 case kCodec_VP8_VAAPI2: 407 467 return "VP8"; 408 468 409 469 case kCodec_VP9: … … QString get_encoding_type(MythCodecID codecid) 411 471 case kCodec_VP9_VAAPI: 412 472 case kCodec_VP9_DXVA2: 413 473 case kCodec_VP9_MEDIACODEC: 474 case kCodec_VP9_VAAPI2: 414 475 return "VP8"; 415 476 416 477 case kCodec_HEVC: … … QString get_encoding_type(MythCodecID codecid) 418 479 case kCodec_HEVC_VAAPI: 419 480 case kCodec_HEVC_DXVA2: 420 481 case kCodec_HEVC_MEDIACODEC: 482 case kCodec_HEVC_VAAPI2: 421 483 return "HEVC"; 422 484 423 485 case kCodec_NONE: … … QString get_encoding_type(MythCodecID codecid) 426 488 case kCodec_VAAPI_END: 427 489 case kCodec_DXVA2_END: 428 490 case kCodec_MEDIACODEC_END: 491 case kCodec_VAAPI2_END: 429 492 return QString(); 430 493 } 431 494 … … QString get_decoder_name(MythCodecID codec_id) 446 509 if (codec_is_mediacodec(codec_id)) 447 510 return "mediacodec"; 448 511 512 if (codec_is_vaapi2(codec_id)) 513 return "vaapi2"; 514 449 515 return "ffmpeg"; 450 516 } -
mythtv/libs/libmythtv/mythcodecid.h
diff --git a/mythtv/libs/libmythtv/mythcodecid.h b/mythtv/libs/libmythtv/mythcodecid.h index ce3620467d9..f1d225d4beb 100644
a b typedef enum 91 91 92 92 kCodec_MEDIACODEC_END, 93 93 94 kCodec_VAAPI2_BEGIN = kCodec_MEDIACODEC_END, 95 96 kCodec_MPEG1_VAAPI2, 97 kCodec_MPEG2_VAAPI2, 98 kCodec_H263_VAAPI2, 99 kCodec_MPEG4_VAAPI2, 100 kCodec_H264_VAAPI2, 101 kCodec_VC1_VAAPI2, 102 kCodec_WMV3_VAAPI2, 103 kCodec_VP8_VAAPI2, 104 kCodec_VP9_VAAPI2, 105 kCodec_HEVC_VAAPI2, 106 107 kCodec_VAAPI2_END, 108 94 109 } MythCodecID; 95 110 96 111 // MythCodecID convenience functions … … typedef enum 113 128 (id == kCodec_VC1_DXVA2))) 114 129 #define codec_is_mediacodec(id) ((id > kCodec_MEDIACODEC_BEGIN) && \ 115 130 (id < kCodec_MEDIACODEC_END)) 131 #define codec_is_vaapi2(id) ((id > kCodec_VAAPI2_BEGIN) && \ 132 (id < kCodec_VAAPI2_END)) 116 133 117 #define codec_sw_copy(id) (codec_is_std(id) || codec_is_mediacodec(id) )134 #define codec_sw_copy(id) (codec_is_std(id) || codec_is_mediacodec(id) || codec_is_vaapi2(id)) 118 135 119 136 QString get_encoding_type(MythCodecID codecid); 120 137 QString get_decoder_name(MythCodecID codec_id); … … int mpeg_version(int codec_id); 156 173 #define CODEC_IS_MEDIACODEC(codec) (0) 157 174 #endif 158 175 159 #define CODEC_IS_HWACCEL(codec, enc) (CODEC_IS_VDPAU(codec) || \160 CODEC_IS_VAAPI(codec, enc) || \161 CODEC_IS_DXVA2(codec, enc) || \162 CODEC_IS_MEDIACODEC(codec))163 164 176 #endif // _MYTH_CODEC_ID_H_ -
new file mythtv/libs/libmythtv/vaapi2context.cpp
diff --git a/mythtv/libs/libmythtv/vaapi2context.cpp b/mythtv/libs/libmythtv/vaapi2context.cpp new file mode 100644 index 00000000000..2cd275b36b9
- + 1 ////////////////////////////////////////////////////////////////////////////// 2 // Copyright (c) 2017 MythTV Developers <mythtv-dev@mythtv.org> 3 // 4 // This is part of MythTV (https://www.mythtv.org) 5 // 6 // This program is free software; you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation; either version 2 of the License, or 9 // (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 // 20 // You should have received a copy of the GNU General Public License 21 // along with this program. If not, see <http://www.gnu.org/licenses/>. 22 // 23 ////////////////////////////////////////////////////////////////////////////// 24 25 #include "vaapi2context.h" 26 27 #include "mythlogging.h" 28 29 extern "C" { 30 #include "libavutil/pixfmt.h" 31 #include "libavutil/hwcontext.h" 32 #include "libavcodec/avcodec.h" 33 } 34 35 #define LOC QString("VAAPI2: ") 36 37 MythCodecID Vaapi2Context::GetBestSupportedCodec( 38 AVCodec **ppCodec, 39 const QString &decoder, 40 uint stream_type, 41 AVPixelFormat &pix_fmt) 42 { 43 enum AVHWDeviceType type = AV_HWDEVICE_TYPE_VAAPI; 44 45 AVPixelFormat fmt = AV_PIX_FMT_NONE; 46 if (decoder == "vaapi2") 47 { 48 for (int i = 0;; i++) { 49 const AVCodecHWConfig *config = avcodec_get_hw_config(*ppCodec, i); 50 if (!config) { 51 LOG(VB_PLAYBACK, LOG_INFO, LOC + 52 QString("Decoder %1 does not support device type %2.") 53 .arg((*ppCodec)->name).arg(av_hwdevice_get_type_name(type))); 54 break; 55 } 56 if (config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX && 57 config->device_type == type) { 58 fmt = config->pix_fmt; 59 break; 60 } 61 } 62 } 63 if (fmt == AV_PIX_FMT_NONE) 64 return (MythCodecID)(kCodec_MPEG1 + (stream_type - 1)); 65 else 66 { 67 LOG(VB_PLAYBACK, LOG_INFO, LOC + 68 QString("Decoder %1 supports device type %2.") 69 .arg((*ppCodec)->name).arg(av_hwdevice_get_type_name(type))); 70 pix_fmt = fmt; 71 return (MythCodecID)(kCodec_MPEG1_VAAPI2 + (stream_type - 1)); 72 } 73 } 74 75 int Vaapi2Context::HwDecoderInit(AVCodecContext *ctx) 76 { 77 int ret = 0; 78 AVBufferRef *hw_device_ctx = NULL; 79 80 ret = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, 81 NULL, NULL, 0); 82 if (ret < 0) 83 { 84 char error[AV_ERROR_MAX_STRING_SIZE]; 85 LOG(VB_GENERAL, LOG_ERR, LOC + 86 QString("av_hwdevice_ctx_create error: %1 (%2)") 87 .arg(av_make_error_string(error, sizeof(error), ret)) 88 .arg(ret)); 89 } 90 else 91 ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx); 92 93 return ret; 94 } -
new file mythtv/libs/libmythtv/vaapi2context.h
diff --git a/mythtv/libs/libmythtv/vaapi2context.h b/mythtv/libs/libmythtv/vaapi2context.h new file mode 100644 index 00000000000..d8d9408530a
- + 1 ////////////////////////////////////////////////////////////////////////////// 2 // Copyright (c) 2017 MythTV Developers <mythtv-dev@mythtv.org> 3 // 4 // This is part of MythTV (https://www.mythtv.org) 5 // 6 // This program is free software; you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation; either version 2 of the License, or 9 // (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 // 20 // You should have received a copy of the GNU General Public License 21 // along with this program. If not, see <http://www.gnu.org/licenses/>. 22 // 23 ////////////////////////////////////////////////////////////////////////////// 24 25 26 #ifndef VAAPI2CONTEXT_H 27 #define VAAPI2CONTEXT_H 28 29 #include "mythcodecid.h" 30 31 extern "C" { 32 #include "libavcodec/avcodec.h" 33 } 34 35 class Vaapi2Context 36 { 37 public: 38 static MythCodecID GetBestSupportedCodec(AVCodec **ppCodec, 39 const QString &decoder, 40 uint stream_type, 41 AVPixelFormat &pix_fmt); 42 static int HwDecoderInit(AVCodecContext *ctx); 43 }; 44 45 #endif // VIDEOOUTOPENGLMEDIACODEC_H 46 No newline at end of file -
mythtv/libs/libmythtv/videodisplayprofile.cpp
diff --git a/mythtv/libs/libmythtv/videodisplayprofile.cpp b/mythtv/libs/libmythtv/videodisplayprofile.cpp index 700ee3bb990..5afdc0f2282 100644
a b QString VideoDisplayProfile::GetDecoderName(const QString &decoder) 852 852 dec_name["dxva2"] = QObject::tr("Windows hardware acceleration"); 853 853 dec_name["vda"] = QObject::tr("Mac VDA hardware acceleration"); 854 854 dec_name["mediacodec"] = QObject::tr("Android MediaCodec decoder"); 855 dec_name["vaapi2"] = QObject::tr("VAAPI2 acceleration"); 855 856 } 856 857 857 858 QString ret = decoder; … … QString VideoDisplayProfile::GetDecoderHelp(QString decoder) 913 914 "Mediacodec will use the graphics hardware to " 914 915 "accelerate video decoding on Android. "); 915 916 917 if (decoder == "vaapi2") 918 msg += QObject::tr( 919 "VAAPI2 is a new implemtation of VAAPI to will use the graphics hardware to " 920 "accelerate video decoding on Android. "); 921 916 922 return msg; 917 923 } 918 924 … … void VideoDisplayProfile::CreateProfiles(const QString &hostname) 1468 1474 CreateProfile(groupid, 1, "", "", "", 1469 1475 "mediacodec", 4, true, "opengl", 1470 1476 "opengl2", true, 1477 "opengldoubleratelinearblend", "opengllinearblend", 1478 ""); 1479 } 1480 #endif 1481 1482 #ifdef USING_VAAPI2 1483 if (!profiles.contains("VAAPI2 Normal")) { 1484 (void) QObject::tr("VAAPI2 Normal", 1485 "Sample: VAAPI2 Normal"); 1486 groupid = CreateProfileGroup("VAAPI2 Normal", hostname); 1487 CreateProfile(groupid, 1, "", "", "", 1488 "vaapi2", 4, true, "opengl", 1489 "opengl2", true, 1471 1490 "none", "none", 1472 1491 ""); 1473 1492 } -
mythtv/libs/libmythtv/videoout_opengl.cpp
diff --git a/mythtv/libs/libmythtv/videoout_opengl.cpp b/mythtv/libs/libmythtv/videoout_opengl.cpp index b689947d738..b287086009e 100644
a b void VideoOutputOpenGL::GetRenderOptions(render_opts &opts, 40 40 (*opts.safe_renderers)["openmax"].append("opengl"); 41 41 if (opts.decoders->contains("mediacodec")) 42 42 (*opts.safe_renderers)["mediacodec"].append("opengl"); 43 if (opts.decoders->contains("vaapi2")) 44 (*opts.safe_renderers)["vaapi2"].append("opengl"); 43 45 opts.priorities->insert("opengl", 65); 44 46 45 47 // lite profile - no colourspace control, GPU deinterlacing … … bool VideoOutputOpenGL::InputChanged(const QSize &video_dim_buf, 270 272 StopEmbedding(); 271 273 } 272 274 273 if (!codec_is_std(av_codec_id) && !codec_is_mediacodec(av_codec_id)) 275 if (!codec_is_std(av_codec_id) 276 && !codec_is_mediacodec(av_codec_id) 277 && !codec_is_vaapi2(av_codec_id)) 274 278 { 275 279 LOG(VB_GENERAL, LOG_ERR, LOC + "New video codec is not supported."); 276 280 errorState = kError_Unknown; … … QStringList VideoOutputOpenGL::GetAllowedRenderers( 741 745 { 742 746 list << "opengl" << "opengl-lite"; 743 747 } 744 else if (codec_is_mediacodec(myth_codec_id) && !getenv("NO_OPENGL")) 748 else if ((codec_is_mediacodec(myth_codec_id) || codec_is_vaapi2(myth_codec_id)) 749 && !getenv("NO_OPENGL")) 745 750 { 746 751 list << "opengl"; 747 752 }