Ticket #6130: vdpau_optimisations.diff
File vdpau_optimisations.diff, 23.4 KB (added by , 17 years ago) |
---|
-
libs/libmythtv/util-vdpau.cpp
19 19 #define LOC QString("VDPAU: ") 20 20 #define LOC_ERR QString("VDPAU Error: ") 21 21 22 #define NUM_OUTPUT_SURFACES 2 22 #define MIN_OUTPUT_SURFACES 2 23 #define MAX_OUTPUT_SURFACES 6 23 24 #define NUM_REFERENCE_FRAMES 3 24 25 25 26 #define ARSIZE(x) (sizeof(x) / sizeof((x)[0])) … … 59 60 VDPAUContext::VDPAUContext() 60 61 : nextframedelay(0), lastframetime(0), 61 62 pix_fmt(-1), maxVideoWidth(0), maxVideoHeight(0), 62 videoSurfaces(0), surface_render(0), numSurfaces(0), 63 videoSurface(0), outputSurface(0), decoder(0), 63 maxReferences(2), checkVideoSurfaces(10), 64 outputSize(QSize(0,0)), videoSurface(0), outputSurface(0), 65 checkOutputSurfaces(false), decoder(0), 64 66 videoMixer(0), surfaceNum(0), osdVideoSurface(0), 65 67 osdOutputSurface(0), osdVideoMixer(0), osdAlpha(0), 66 68 osdSize(QSize(0,0)), osdReady(false), deintAvail(false), 67 69 deinterlacer("notset"), deinterlacing(false), currentFrameNum(-1), 68 70 needDeintRefs(false), useColorControl(false), 69 71 pipOutputSurface(0), pipAlpha(0), pipBorder(0), 70 pipClear(0), pipReady(0), pipLayerSize(QSize(0,0)),72 pipClear(0), pipReady(0), 71 73 pipNeedsClear(false), vdp_flip_target(NULL), vdp_flip_queue(NULL), 72 74 vdpauDecode(false), vdp_device(NULL), errored(false) 73 75 { 74 memset(outputSurfaces, 0, sizeof(outputSurfaces));75 76 } 76 77 77 78 VDPAUContext::~VDPAUContext() … … 82 83 Window win, QSize screen_size, 83 84 bool color_control, MythCodecID mcodecid) 84 85 { 86 outputSize = screen_size; 87 85 88 if ((kCodec_VDPAU_BEGIN < mcodecid) && (mcodecid < kCodec_VDPAU_END)) 86 89 vdpauDecode = true; 87 90 … … 95 98 if (!ok) 96 99 return ok; 97 100 98 ok = InitOutput( screen_size);101 ok = InitOutput(); 99 102 if (!ok) 100 103 return ok; 101 104 … … 521 524 } 522 525 } 523 526 527 int VDPAUContext::AddBuffer(int width, int height) 528 { 529 VdpStatus vdp_st; 530 bool ok = true; 531 532 video_surface tmp; 533 tmp.surface = 0; 534 535 vdp_st = vdp_video_surface_create( 536 vdp_device, 537 vdp_chroma_type, 538 width, 539 height, 540 &(tmp.surface) 541 ); 542 CHECK_ST 543 544 if (!ok || !tmp.surface) 545 { 546 VERBOSE(VB_PLAYBACK, LOC_ERR + 547 QString("Failed to create video surface.")); 548 return -1; 549 } 550 551 if (vdpauDecode) 552 { 553 vdpau_render_state_t new_rend; 554 memset(&new_rend, 0, sizeof(vdpau_render_state_t)); 555 new_rend.magic = MP_VDPAU_RENDER_MAGIC; 556 new_rend.state = 0; 557 new_rend.surface = tmp.surface; 558 tmp.render = new_rend; 559 } 560 561 videoSurfaces.push_back(tmp); 562 return GetNumBufs() - 1; 563 } 564 524 565 bool VDPAUContext::InitBuffers(int width, int height, int numbufs) 525 566 { 526 567 int num_bufs = numbufs; … … 561 602 return false; 562 603 } 563 604 564 videoSurfaces = (VdpVideoSurface *)malloc(sizeof(VdpVideoSurface) * num_bufs);565 if (vdpauDecode)566 {567 surface_render = (vdpau_render_state_t*)malloc(sizeof(vdpau_render_state_t) * num_bufs);568 memset(surface_render, 0, sizeof(vdpau_render_state_t) * num_bufs);569 }570 571 numSurfaces = num_bufs;572 573 605 for (i = 0; i < num_bufs; i++) 574 606 { 575 vdp_st = vdp_video_surface_create( 576 vdp_device, 577 vdp_chroma_type, 578 width, 579 height, 580 &(videoSurfaces[i]) 581 ); 582 CHECK_ST 583 584 if (!ok) 607 int tmp = AddBuffer(width, height); 608 if (tmp != i) 585 609 { 586 VERBOSE(VB_PLAYBACK, LOC_ERR + 587 QString("Failed to create video surface.")); 610 VERBOSE(VB_IMPORTANT, LOC + 611 QString("Failed to add buffer %1 of %2") 612 .arg(i+1).arg(num_bufs)); 588 613 return false; 589 614 } 590 591 if (vdpauDecode)592 {593 surface_render[i].magic = MP_VDPAU_RENDER_MAGIC;594 surface_render[i].state = 0;595 surface_render[i].surface = videoSurfaces[i];596 }597 615 } 598 616 599 617 // clear video surfaces to black … … 617 635 for (i = 0; i < num_bufs; i++) 618 636 { 619 637 vdp_video_surface_put_bits_y_cb_cr( 620 videoSurfaces[i] ,638 videoSurfaces[i].surface, 621 639 VDP_YCBCR_FORMAT_YV12, 622 640 planes, 623 641 pitches … … 707 725 CHECK_ST 708 726 } 709 727 710 if (videoSurfaces )728 if (videoSurfaces.size()) 711 729 { 712 for (i = 0; i < numSurfaces; i++)730 for (i = 0; i < GetNumBufs(); i++) 713 731 { 714 if (videoSurfaces[i] )732 if (videoSurfaces[i].surface) 715 733 { 716 734 vdp_st = vdp_video_surface_destroy( 717 videoSurfaces[i] );735 videoSurfaces[i].surface); 718 736 CHECK_ST 719 737 } 720 738 } 721 free(videoSurfaces); 722 videoSurfaces = NULL; 739 videoSurfaces.clear(); 723 740 } 724 725 if (surface_render) 726 free(surface_render); 727 surface_render = NULL; 741 checkVideoSurfaces = 10; 728 742 } 729 743 730 bool VDPAUContext::InitOutput( QSize size)744 bool VDPAUContext::InitOutput(void) 731 745 { 732 746 VdpStatus vdp_st; 733 747 bool ok = true; … … 750 764 QString("Output surface chroma format not supported.")); 751 765 return false; 752 766 } 753 else if (max_width < (uint) size.width() ||754 max_height < (uint) size.height())767 else if (max_width < (uint)outputSize.width() || 768 max_height < (uint)outputSize.height()) 755 769 { 756 770 VERBOSE(VB_PLAYBACK, LOC_ERR + 757 771 QString("Output surface - too large (%1x%2 > %3x%4).") 758 .arg( size.width()).arg(size.height())772 .arg(outputSize.width()).arg(outputSize.height()) 759 773 .arg(max_width).arg(max_height)); 760 774 return false; 761 775 } 762 776 763 for (i = 0; i < NUM_OUTPUT_SURFACES; i++)777 for (i = 0; i < MIN_OUTPUT_SURFACES; i++) 764 778 { 779 VdpOutputSurface tmp; 765 780 vdp_st = vdp_output_surface_create( 766 781 vdp_device, 767 782 VDP_RGBA_FORMAT_B8G8R8A8, 768 size.width(),769 size.height(),770 & outputSurfaces[i]783 outputSize.width(), 784 outputSize.height(), 785 &tmp 771 786 ); 772 787 CHECK_ST 773 788 … … 777 792 QString("Failed to create output surface.")); 778 793 return false; 779 794 } 795 outputSurfaces.push_back(tmp); 780 796 } 781 797 782 798 outRect.x0 = 0; 783 799 outRect.y0 = 0; 784 outRect.x1 = size.width();785 outRect.y1 = size.height();800 outRect.x1 = outputSize.width(); 801 outRect.y1 = outputSize.height(); 786 802 surfaceNum = 0; 787 803 return ok; 788 804 } … … 794 810 795 811 VdpStatus vdp_st; 796 812 bool ok = true; 797 int i;813 uint i; 798 814 799 for (i = 0; i < NUM_OUTPUT_SURFACES; i++)815 for (i = 0; i < outputSurfaces.size(); i++) 800 816 { 801 817 if (outputSurfaces[i]) 802 818 { … … 805 821 CHECK_ST 806 822 } 807 823 } 824 outputSurfaces.clear(); 825 outputSize = QSize(0,0); 826 checkOutputSurfaces = false; 808 827 } 809 828 810 829 void VDPAUContext::Decode(VideoFrame *frame) … … 818 837 819 838 VdpStatus vdp_st; 820 839 bool ok = true; 821 vdpau_render_state_t *render ;840 vdpau_render_state_t *render = (vdpau_render_state_t *)frame->buf; 822 841 823 842 if (frame->pix_fmt != pix_fmt) 824 843 { 825 uint32_t max_references = 2;826 827 844 if (frame->pix_fmt == PIX_FMT_VDPAU_H264_MAIN || 828 845 frame->pix_fmt == PIX_FMT_VDPAU_H264_HIGH) 829 846 { 830 uint32_t round_width = (frame->width + 15) & ~15; 831 uint32_t round_height = (frame->height + 15) & ~15; 832 uint32_t surf_size = (round_width * round_height * 3) / 2; 833 max_references = (12 * 1024 * 1024) / surf_size; 834 if (max_references > 16) 835 max_references = 16; 847 if (render) 848 maxReferences = render->info.h264.num_ref_frames; 849 850 if (maxReferences < 1 || maxReferences > 16) 851 { 852 uint32_t round_width = (frame->width + 15) & ~15; 853 uint32_t round_height = (frame->height + 15) & ~15; 854 uint32_t surf_size = (round_width * round_height * 3) / 2; 855 maxReferences = (12 * 1024 * 1024) / surf_size; 856 } 857 if (maxReferences > 16) 858 maxReferences = 16; 836 859 } 837 860 838 861 VdpDecoderProfile vdp_decoder_profile; … … 858 881 vdp_decoder_profile, 859 882 frame->width, 860 883 frame->height, 861 max _references,884 maxReferences, 862 885 &decoder 863 886 ); 864 887 CHECK_ST … … 868 891 pix_fmt = frame->pix_fmt; 869 892 VERBOSE(VB_PLAYBACK, LOC + 870 893 QString("Created VDPAU decoder (%1 ref frames)") 871 .arg(max _references));894 .arg(maxReferences)); 872 895 } 873 896 else 874 897 { … … 877 900 } 878 901 } 879 902 880 render = (vdpau_render_state_t *)frame->buf;881 903 if (!render || !decoder) 882 904 return; 883 905 … … 891 913 CHECK_ST 892 914 } 893 915 894 voidVDPAUContext::PrepareVideo(VideoFrame *frame, QRect video_rect,916 int VDPAUContext::PrepareVideo(VideoFrame *frame, QRect video_rect, 895 917 QRect display_video_rect, 896 QSize screen_size, FrameScanType scan, 897 bool pause_frame) 918 FrameScanType scan, bool pause_frame) 898 919 { 920 int ret = (maxReferences + (deinterlacing ? 5 : 3)) - GetNumBufs(); 921 if (ret < 0 || !vdpauDecode || (checkVideoSurfaces != 1)) 922 ret = 0; 923 // once we've tried to add video surfaces, try to increase 924 // the number of output surfaces 925 if (checkVideoSurfaces == 1) 926 checkOutputSurfaces = true; 927 928 if (checkVideoSurfaces > 0) 929 checkVideoSurfaces--; 930 899 931 VdpStatus vdp_st; 900 932 bool ok = true; 901 933 VdpTime dummy; … … 914 946 { 915 947 render = (vdpau_render_state_t *)frame->buf; 916 948 if (!render) 917 return ;949 return ret; 918 950 919 951 videoSurface = render->surface; 920 952 } … … 924 956 if (deint) 925 957 surf = (currentFrameNum + 1) % NUM_REFERENCE_FRAMES; 926 958 927 videoSurface = videoSurfaces[surf] ;959 videoSurface = videoSurfaces[surf].surface; 928 960 929 961 uint32_t pitches[3] = { 930 962 frame->pitches[0], … … 943 975 pitches); 944 976 CHECK_ST; 945 977 if (!ok) 946 return ;978 return ret; 947 979 } 948 980 else if (!frame) 949 981 { 950 982 deint = false; 951 983 if (!videoSurface) 952 videoSurface = videoSurfaces[0] ;984 videoSurface = videoSurfaces[0].surface; 953 985 } 954 986 955 if (outRect.x1 != (uint)screen_size.width() ||956 outRect.y1 != (uint)screen_size.height())957 {958 FreeOutput();959 InitOutput(screen_size);960 }961 962 987 // fix broken/missing negative rect clipping in vdpau 963 988 if (display_video_rect.top() < 0 && display_video_rect.height() > 0) 964 989 { … … 980 1005 display_video_rect.setLeft(0); 981 1006 } 982 1007 983 outRect.x0 = 0;984 outRect.y0 = 0;985 outRect.x1 = screen_size.width();986 outRect.y1 = screen_size.height();987 988 1008 VdpRect srcRect; 989 1009 srcRect.x0 = video_rect.left(); 990 1010 srcRect.y0 = video_rect.top(); … … 1032 1052 int ref = (currentFrameNum + i - 1) % NUM_REFERENCE_FRAMES; 1033 1053 if (ref < 0) 1034 1054 ref = 0; 1035 refs[i] = videoSurfaces[ref] ;1055 refs[i] = videoSurfaces[ref].surface; 1036 1056 } 1037 1057 } 1038 1058 … … 1099 1119 if (pipReady) 1100 1120 pipReady--; 1101 1121 pipNeedsClear = true; 1122 1123 return ret; 1102 1124 } 1103 1125 1104 1126 void VDPAUContext::DisplayNextFrame(void) … … 1133 1155 ); 1134 1156 CHECK_ST 1135 1157 1136 surfaceNum = surfaceNum ^ 1; 1158 surfaceNum++; 1159 if (surfaceNum >= (int)(outputSurfaces.size())) 1160 surfaceNum = 0; 1161 1162 if (checkOutputSurfaces) 1163 AddOutputSurfaces(); 1137 1164 } 1138 1165 1166 void VDPAUContext::AddOutputSurfaces(void) 1167 { 1168 checkOutputSurfaces = false; 1169 VdpStatus vdp_st; 1170 bool ok = true; 1171 1172 int cnt = 0; 1173 int extra = MAX_OUTPUT_SURFACES - outputSurfaces.size(); 1174 if (extra <= 0) 1175 return; 1176 1177 for (int i = 0; i < extra; i++) 1178 { 1179 VdpOutputSurface tmp; 1180 vdp_st = vdp_output_surface_create( 1181 vdp_device, 1182 VDP_RGBA_FORMAT_B8G8R8A8, 1183 outputSize.width(), 1184 outputSize.height(), 1185 &tmp 1186 ); 1187 // suppress non-fatal error messages 1188 ok &= (vdp_st == VDP_STATUS_OK); 1189 1190 if (!ok) 1191 break; 1192 1193 outputSurfaces.push_back(tmp); 1194 cnt++; 1195 } 1196 VERBOSE(VB_PLAYBACK, LOC + QString("Using %1 output surfaces (max %2)") 1197 .arg(outputSurfaces.size()).arg(MAX_OUTPUT_SURFACES)); 1198 } 1199 1139 1200 void VDPAUContext::SetNextFrameDisplayTimeOffset(int delayus) 1140 1201 { 1141 1202 nextframedelay = delayus; 1142 1203 } 1143 1204 1144 bool VDPAUContext::InitOSD( QSize osd_size)1205 bool VDPAUContext::InitOSD(void) 1145 1206 { 1146 1207 if (!vdp_device) 1147 1208 return false; … … 1149 1210 VdpStatus vdp_st; 1150 1211 bool ok = true; 1151 1212 1152 uint width = o sd_size.width();1153 uint height = o sd_size.height();1213 uint width = outputSize.width(); 1214 uint height = outputSize.height(); 1154 1215 VdpBool supported = false; 1155 1216 1156 1217 vdp_st = vdp_video_surface_query_get_put_bits_y_cb_cr_capabilities( … … 1282 1343 } 1283 1344 else 1284 1345 { 1285 osdSize = osd_size;1286 1346 osdRect.x0 = 0; 1287 1347 osdRect.y0 = 0; 1288 1348 osdRect.x1 = width; … … 1296 1356 return ok; 1297 1357 } 1298 1358 1299 osdSize = QSize(0,0);1300 1359 return ok; 1301 1360 } 1302 1361 1303 1362 void VDPAUContext::UpdateOSD(void* const planes[3], 1304 QSize size,1305 1363 void* const alpha[1]) 1306 1364 { 1307 if (size != osdSize)1308 return;1309 1310 1365 VdpStatus vdp_st; 1311 1366 bool ok = true; 1312 1367 1313 1368 // upload OSD YV12 data 1314 uint32_t pitches[3] = {size.width(), size.width()>>1, size.width()>>1}; 1369 uint32_t pitches[3] = {outputSize.width(), 1370 outputSize.width()>>1, 1371 outputSize.width()>>1}; 1315 1372 void * const realplanes[3] = { planes[0], planes[2], planes[1] }; 1316 1373 1317 1374 vdp_st = vdp_video_surface_put_bits_y_cb_cr(osdVideoSurface, … … 1346 1403 // upload OSD alpha data 1347 1404 if (ok) 1348 1405 { 1349 uint32_t pitch[1] = { size.width()};1406 uint32_t pitch[1] = {outputSize.width()}; 1350 1407 vdp_st = vdp_bitmap_surface_put_bits_native( 1351 1408 osdAlpha, 1352 1409 alpha, … … 1765 1822 VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME, 1766 1823 0, 1767 1824 NULL, 1768 videoSurfaces[0] ,1825 videoSurfaces[0].surface, 1769 1826 0, 1770 1827 NULL, 1771 1828 &srcRect, … … 1811 1868 pipClear = 0; 1812 1869 } 1813 1870 1814 pipLayerSize = QSize(0, 0);1815 1871 pipReady = 0; 1816 1872 } 1817 1873 1818 bool VDPAUContext::InitPIPLayer( QSize screen_size)1874 bool VDPAUContext::InitPIPLayer(void) 1819 1875 { 1820 if (pipLayerSize != screen_size)1821 DeinitPIPLayer();1822 1823 1876 bool ok = true; 1824 1877 VdpStatus vdp_st; 1825 1878 … … 1828 1881 vdp_st = vdp_output_surface_create( 1829 1882 vdp_device, 1830 1883 VDP_RGBA_FORMAT_B8G8R8A8, 1831 screen_size.width(),1832 screen_size.height(),1884 outputSize.width(), 1885 outputSize.height(), 1833 1886 &pipOutputSurface 1834 1887 ); 1835 1888 CHECK_ST … … 1922 1975 1923 1976 if (ok && pipNeedsClear) 1924 1977 { 1925 pipLayerSize = screen_size;1926 1978 vdp_st = vdp_output_surface_render_bitmap_surface( 1927 1979 pipOutputSurface, 1928 1980 NULL, -
libs/libmythtv/util-vdpau.h
13 13 VdpVideoSurface videoSurface; 14 14 VdpVideoMixer videoMixer; 15 15 }; 16 17 struct video_surface 18 { 19 VdpVideoSurface surface; 20 vdpau_render_state_t render; 21 }; 22 16 23 class NuppelVideoPlayer; 17 24 18 25 class VDPAUContext … … 27 34 void Deinit(void); 28 35 bool IsErrored(void) { return errored; } 29 36 37 int AddBuffer(int width, int height); 30 38 bool InitBuffers(int width, int height, int numbufs); 31 39 void FreeBuffers(void); 32 void *GetRenderData(int i) 33 { if (i < numSurfaces && i >= 0) return (void*)&(surface_render[i]);40 void *GetRenderData(int i) 41 { if (i < GetNumBufs() && i >= 0) return (void*)&(videoSurfaces[i].render); 34 42 return NULL; 35 43 } 36 int GetNumBufs(void) { return numSurfaces; }44 int GetNumBufs(void) { return videoSurfaces.size(); } 37 45 38 bool InitOutput( QSize size);46 bool InitOutput(void); 39 47 void FreeOutput(void); 40 48 41 49 void Decode(VideoFrame *frame); 42 50 43 voidPrepareVideo(VideoFrame *frame, QRect video_rect,51 int PrepareVideo(VideoFrame *frame, QRect video_rect, 44 52 QRect display_video_rect, 45 QSize screen_size, FrameScanType scan, 46 bool pause_frame); 53 FrameScanType scan, bool pause_frame); 47 54 void DisplayNextFrame(void); 48 55 void SetNextFrameDisplayTimeOffset(int delayus); 49 bool InitOSD(QSize osd_size); 50 void UpdateOSD(void* const planes[3], QSize size, 51 void* const alpha[1]); 56 bool InitOSD(void); 57 void UpdateOSD(void* const planes[3], void* const alpha[1]); 52 58 void DisableOSD(void) { osdReady = false; } 53 59 void DeinitOSD(void); 54 60 … … 63 69 PictureAttributeSupported GetSupportedPictureAttributes(void) const; 64 70 int SetPictureAttribute(PictureAttribute attributeType, int newValue); 65 71 66 bool InitPIPLayer( QSize screen_size);72 bool InitPIPLayer(void); 67 73 bool ShowPIP(NuppelVideoPlayer *pipplayer, 68 74 VideoFrame * frame, QRect position, 69 75 bool pip_is_active); … … 76 82 77 83 bool InitFlipQueue(Window win); 78 84 void DeinitFlipQueue(void); 79 85 void AddOutputSurfaces(void); 80 86 bool UpdateReferenceFrames(VideoFrame *frame); 81 87 bool InitColorControl(void); 82 88 bool SetPictureAttributes(void); 83 84 89 85 90 void DeinitPIPLayer(void); 86 91 bool InitPIP(NuppelVideoPlayer *pipplayer, QSize vid_size); … … 92 97 93 98 uint maxVideoWidth; 94 99 uint maxVideoHeight; 95 VdpVideoSurface *videoSurfaces;96 vdpau_render_state_t *surface_render;97 int numSurfaces;100 vector<video_surface> videoSurfaces; 101 uint32_t maxReferences; 102 int checkVideoSurfaces; 98 103 99 VdpOutputSurface outputSurfaces[2]; 104 QSize outputSize; 105 vector<VdpOutputSurface> outputSurfaces; 100 106 VdpVideoSurface videoSurface; 101 107 VdpOutputSurface outputSurface; 108 bool checkOutputSurfaces; 102 109 103 110 VdpDecoder decoder; 104 111 VdpVideoMixer videoMixer; … … 135 142 VdpBitmapSurface pipClear; 136 143 QMap<NuppelVideoPlayer*,vdpauPIP> pips; 137 144 int pipReady; 138 QSize pipLayerSize;139 145 bool pipNeedsClear; 140 146 141 147 VdpPresentationQueueTarget vdp_flip_target; -
libs/libmythtv/videoout_xv.cpp
84 84 #define XVMC_CHROMA_FORMAT_420 0x00000001 85 85 #endif 86 86 87 #define NUM_VDPAU_BUFFERS 1787 #define NUM_VDPAU_BUFFERS 6 88 88 89 89 static QStringList allowed_video_renderers( 90 90 MythCodecID codec_id, Display *display, Screen *screen, Window curwin); … … 1672 1672 if (osd_renderer == "vdpau" && vdpau) 1673 1673 { 1674 1674 vdpau_use_osd = true; 1675 if (!vdpau->InitOSD( GetTotalOSDBounds().size()))1675 if (!vdpau->InitOSD()) 1676 1676 { 1677 1677 vdpau_use_osd = false; 1678 1678 VERBOSE(VB_IMPORTANT, LOC + "Init VDPAU osd failed."); … … 3128 3128 if (!vdpau) 3129 3129 return; 3130 3130 3131 vdpau->PrepareVideo(3131 int extra_bufs = vdpau->PrepareVideo( 3132 3132 frame, windows[0].GetVideoRect(), windows[0].GetDisplayVideoRect(), 3133 windows[0].GetDisplayVisibleRect().size(),scan, pause);3133 scan, pause); 3134 3134 3135 if (extra_bufs) 3136 { 3137 vbuffers.begin_lock(kVideoBuffer_avail); 3138 QSize vid_dim = windows[0].GetVideoDim(); 3139 vbuffers.Add(vid_dim.width(), vid_dim.height(), vdpau, extra_bufs); 3140 vbuffers.end_lock(); 3141 } 3142 3135 3143 #endif 3136 3144 3137 3145 if (pause) … … 3704 3712 #ifdef USING_VDPAU 3705 3713 if (vdpau && vdpau_use_pip && VideoOutputSubType() == XVideoVDPAU) 3706 3714 { 3707 if (vdpau->InitPIPLayer( dvr.size()))3715 if (vdpau->InitPIPLayer()) 3708 3716 vdpau_use_pip = vdpau->ShowPIP(pipplayer, pipimage, 3709 3717 position, pipActive); 3710 3718 pipplayer->ReleaseCurrentFrame(pipimage); … … 4954 4962 offsets[1] = surface->u; 4955 4963 offsets[2] = surface->v; 4956 4964 alpha[0] = surface->alpha; 4957 vdpau->UpdateOSD(offsets, visible,alpha);4965 vdpau->UpdateOSD(offsets, alpha); 4958 4966 #endif // USING_VDPAU 4959 4967 } 4960 4968 else if (gl_use_osd_opengl2) -
libs/libmythtv/videobuffers.h
165 165 166 166 #ifdef USING_VDPAU 167 167 bool CreateBuffers(int width, int height, VDPAUContext *ctx); 168 void Add(int width, int height, VDPAUContext *ctx, int num); 168 169 #endif 169 170 170 171 QString GetStatus(int n=-1) const; // debugging method -
libs/libmythtv/videobuffers.cpp
1164 1164 } 1165 1165 1166 1166 #ifdef USING_VDPAU 1167 static unsigned char *ffmpeg_vdpau_hack = (unsigned char*) 1168 "avlib should not use this private data in VDPAU mode."; 1169 1167 1170 bool VideoBuffers::CreateBuffers(int width, int height, VDPAUContext *ctx) 1168 1171 { 1169 static unsigned char *ffmpeg_vdpau_hack = (unsigned char*)1170 "avlib should not use this private data in VDPAU mode.";1171 1172 1172 if (!ctx) 1173 1173 return false; 1174 1174 … … 1191 1191 } 1192 1192 return true; 1193 1193 } 1194 1195 void VideoBuffers::Add(int width, int height, VDPAUContext *ctx, int num) 1196 { 1197 if (!ctx) 1198 return; 1199 1200 int cnt = 0; 1201 QMutexLocker locker(&global_lock); 1202 1203 for (int i =0; i < num; i++) 1204 { 1205 int new_surf = ctx->AddBuffer(width, height); 1206 if (new_surf > 0) 1207 { 1208 int ref = allocSize(); 1209 if (ref != new_surf) 1210 { 1211 VERBOSE(VB_PLAYBACK, QString("VideoBuffers::Add - ") + 1212 QString("mis-match between VideoBuffers and VDPAU.")); 1213 continue; 1214 } 1215 VideoFrame tmp; 1216 memset(&tmp, 0, sizeof(VideoFrame)); 1217 buffers.push_back(tmp); 1218 init(&buffers[ref], FMT_VDPAU, (unsigned char*)ctx->GetRenderData(new_surf), width, height, -1, 0); 1219 vbufferMap[at(ref)] = ref; 1220 numbuffers = allocSize(); 1221 buffers[ref].priv[0] = ffmpeg_vdpau_hack; 1222 buffers[ref].priv[1] = ffmpeg_vdpau_hack; 1223 enqueue(kVideoBuffer_avail, at(ref)); 1224 cnt++; 1225 } 1226 else 1227 { 1228 continue; 1229 } 1230 } 1231 VERBOSE(VB_PLAYBACK, 1232 QString("Added %1 VDPAU video buffer(s) (%2 requested).") 1233 .arg(cnt).arg(num)); 1234 return; 1235 } 1194 1236 #endif 1195 1237 1196 1238 #ifdef USING_XVMC