diff -ur -X excl mythtvopengl2/libs/libmythtv/openglvideo.cpp mythtvopengl3/libs/libmythtv/openglvideo.cpp
old
|
new
|
|
35 | 35 | }; |
36 | 36 | |
37 | 37 | OpenGLVideo::OpenGLVideo() : |
38 | | gl_context(NULL), videoSize(0,0), |
| 38 | gl_context(NULL), video_dim(0,0), |
39 | 39 | viewportSize(0,0), masterViewportSize(0,0), |
40 | | visibleRect(0,0,0,0), videoRect(0,0,0,0), |
41 | | frameRect(0,0,0,0), frameBufferRect(0,0,0,0), |
| 40 | display_visible_rect(0,0,0,0), display_video_rect(0,0,0,0), |
| 41 | video_rect(0,0,0,0), frameBufferRect(0,0,0,0), |
42 | 42 | softwareDeinterlacer(QString::null), |
43 | 43 | hardwareDeinterlacing(false), |
44 | 44 | useColourControl(false), viewportControl(false), |
… |
… |
|
89 | 89 | |
90 | 90 | // locking ok |
91 | 91 | bool OpenGLVideo::Init(OpenGLContext *glcontext, bool colour_control, |
92 | | QSize video_size, QRect visible_rect, |
93 | | QRect video_rect, QRect frame_rect, |
| 92 | QSize videoDim, QRect displayVisibleRect, |
| 93 | QRect displayVideoRect, QRect videoRect, |
94 | 94 | bool viewport_control, bool osd) |
95 | 95 | { |
96 | 96 | gl_context = glcontext; |
97 | | videoSize = video_size; |
98 | | visibleRect = visible_rect; |
99 | | videoRect = video_rect; |
100 | | frameRect = frame_rect; |
| 97 | video_dim = videoDim; |
| 98 | display_visible_rect = displayVisibleRect; |
| 99 | display_video_rect = displayVideoRect; |
| 100 | video_rect = videoRect; |
101 | 101 | masterViewportSize = QSize(1920, 1080); |
102 | 102 | |
103 | | QSize rect = GetTextureSize(videoSize); |
| 103 | QSize rect = GetTextureSize(video_dim); |
104 | 104 | |
105 | 105 | frameBufferRect = QRect(QPoint(0,0), rect); |
106 | 106 | softwareDeinterlacer = ""; |
… |
… |
|
114 | 114 | currentFrameNum = -1; |
115 | 115 | inputUpdated = false; |
116 | 116 | |
117 | | SetViewPort(visibleRect.size()); |
| 117 | SetViewPort(display_visible_rect.size()); |
118 | 118 | InitOpenGL(); |
119 | 119 | |
120 | 120 | if (osd) |
121 | 121 | { |
122 | | QSize osdsize = visibleRect.size(); |
| 122 | QSize osdsize = display_visible_rect.size(); |
123 | 123 | QSize half_size(osdsize.width() >> 1, osdsize.height() >>1); |
124 | 124 | GLuint alphatex = CreateVideoTexture(osdsize, inputTextureSize); |
125 | 125 | GLuint utex = CreateVideoTexture(half_size, inputTextureSize); |
… |
… |
|
141 | 141 | } |
142 | 142 | else |
143 | 143 | { |
144 | | QSize half_size(videoSize.width() >> 1, videoSize.height() >>1); |
| 144 | QSize half_size(video_dim.width() >> 1, video_dim.height() >>1); |
145 | 145 | GLuint utex = CreateVideoTexture(half_size, inputTextureSize); |
146 | 146 | GLuint vtex = CreateVideoTexture(half_size, inputTextureSize); |
147 | | GLuint ytex = CreateVideoTexture(videoSize, inputTextureSize);; |
| 147 | GLuint ytex = CreateVideoTexture(video_dim, inputTextureSize);; |
148 | 148 | |
149 | 149 | if ((ytex && utex && vtex) && AddFilter(kGLFilterYUV2RGB)) |
150 | 150 | { |
… |
… |
|
167 | 167 | "Falling back to software conversion.\n\t\t\t" |
168 | 168 | "Any opengl filters will also be disabled."); |
169 | 169 | |
170 | | GLuint rgb24tex = CreateVideoTexture(videoSize, inputTextureSize); |
| 170 | GLuint rgb24tex = CreateVideoTexture(video_dim, inputTextureSize); |
171 | 171 | |
172 | 172 | if (rgb24tex && AddFilter(kGLFilterResize)) |
173 | 173 | { |
… |
… |
|
213 | 213 | // if video rectangle is smaller than display rectangle, add resize stage |
214 | 214 | // to improve performance |
215 | 215 | |
216 | | bool needResize = ((videoSize.height() != videoRect.height()) || |
217 | | (videoSize.width() < videoRect.width())); |
| 216 | bool needResize = ((video_dim.height() != display_video_rect.height()) || |
| 217 | (video_dim.width() < display_video_rect.width())); |
218 | 218 | if (needResize && !filters.count(kGLFilterResize) && |
219 | 219 | !(AddFilter(kGLFilterResize))) |
220 | 220 | { |
… |
… |
|
239 | 239 | if (buffers_diff > 0) |
240 | 240 | { |
241 | 241 | uint tmp_buf, tmp_tex; |
242 | | QSize fb_size = GetTextureSize(videoSize); |
| 242 | QSize fb_size = GetTextureSize(video_dim); |
243 | 243 | for (int i = 0; i < buffers_diff; i++) |
244 | 244 | { |
245 | 245 | if (!AddFrameBuffer(tmp_buf, tmp_tex, fb_size)) |
… |
… |
|
485 | 485 | // locking ok |
486 | 486 | void OpenGLVideo::SetViewPort(const QSize &viewPortSize) |
487 | 487 | { |
488 | | uint w = max(viewPortSize.width(), videoSize.width()); |
489 | | uint h = max(viewPortSize.height(), videoSize.height()); |
| 488 | uint w = max(viewPortSize.width(), video_dim.width()); |
| 489 | uint h = max(viewPortSize.height(), video_dim.height()); |
490 | 490 | |
491 | 491 | viewportSize = QSize(w, h); |
492 | 492 | |
… |
… |
|
579 | 579 | // locking ok |
580 | 580 | void OpenGLVideo::UpdateInputFrame(const VideoFrame *frame) |
581 | 581 | { |
582 | | if (frame->width != videoSize.width() || |
583 | | frame->height != videoSize.height() || |
| 582 | if (frame->width != video_dim.width() || |
| 583 | frame->height != video_dim.height() || |
584 | 584 | frame->width < 1 || |
585 | 585 | frame->height < 1) |
586 | 586 | { |
… |
… |
|
590 | 590 | |
591 | 591 | if (filters.count(kGLFilterYUV2RGB) && (frame->codec == FMT_YV12)) |
592 | 592 | { |
593 | | UpdateInput(frame->buf, frame->offsets, 0, FMT_YV12, videoSize); |
| 593 | UpdateInput(frame->buf, frame->offsets, 0, FMT_YV12, video_dim); |
594 | 594 | return; |
595 | 595 | } |
596 | 596 | |
597 | 597 | // software yuv2rgb |
598 | | if (convertSize != videoSize) |
| 598 | if (convertSize != video_dim) |
599 | 599 | { |
600 | 600 | ShutDownYUV2RGB(); |
601 | 601 | |
602 | 602 | VERBOSE(VB_PLAYBACK, LOC + "Init software conversion."); |
603 | 603 | |
604 | | convertSize = videoSize; |
| 604 | convertSize = video_dim; |
605 | 605 | convertBuf = new unsigned char[ |
606 | | (videoSize.width() * videoSize.height() * 3) + 128]; |
| 606 | (video_dim.width() * video_dim.height() * 3) + 128]; |
607 | 607 | } |
608 | 608 | |
609 | 609 | if (convertBuf) |
… |
… |
|
667 | 667 | // TODO shouldn't this take a QSize, not QRect? |
668 | 668 | void OpenGLVideo::SetVideoResize(const QRect &rect) |
669 | 669 | { |
670 | | bool abort = ((rect.right() > videoSize.width()) || |
671 | | (rect.bottom() > videoSize.height()) || |
672 | | (rect.width() > videoSize.width()) || |
673 | | (rect.height() > videoSize.height())); |
| 670 | bool abort = ((rect.right() > video_dim.width()) || |
| 671 | (rect.bottom() > video_dim.height()) || |
| 672 | (rect.width() > video_dim.width()) || |
| 673 | (rect.height() > video_dim.height())); |
674 | 674 | |
675 | 675 | // if resize == existing frame, no need to carry on |
676 | 676 | |
677 | | abort |= !rect.left() && !rect.top() && (rect.size() == videoSize); |
| 677 | abort |= !rect.left() && !rect.top() && (rect.size() == video_dim); |
678 | 678 | |
679 | 679 | if (!abort) |
680 | 680 | { |
… |
… |
|
698 | 698 | { |
699 | 699 | // FIXME video aspect == display aspect |
700 | 700 | |
701 | | if ((videoSize.height() <= 0) || (videoSize.width() <= 0)) |
| 701 | if ((video_dim.height() <= 0) || (video_dim.width() <= 0)) |
702 | 702 | return; |
703 | 703 | |
704 | | float height = visibleRect.height(); |
| 704 | float height = display_visible_rect.height(); |
705 | 705 | float new_top = height - ((float)videoResizeRect.bottom() / |
706 | | (float)videoSize.height()) * height; |
| 706 | (float)video_dim.height()) * height; |
707 | 707 | float new_bottom = height - ((float)videoResizeRect.top() / |
708 | | (float)videoSize.height()) * height; |
| 708 | (float)video_dim.height()) * height; |
709 | 709 | |
710 | | left = (((float) videoResizeRect.left() / (float) videoSize.width()) * |
711 | | visibleRect.width()); |
712 | | right = (((float) videoResizeRect.right() / (float) videoSize.width()) * |
713 | | visibleRect.width()); |
| 710 | left = (((float) videoResizeRect.left() / (float) video_dim.width()) * |
| 711 | display_visible_rect.width()); |
| 712 | right = (((float) videoResizeRect.right() / (float) video_dim.width()) * |
| 713 | display_visible_rect.width()); |
714 | 714 | |
715 | 715 | top = new_top; |
716 | 716 | bottom = new_bottom; |
… |
… |
|
787 | 787 | if (!inputUpdated && type == kGLFilterYUV2RGBA) |
788 | 788 | { |
789 | 789 | inputs = filter->frameBufferTextures; |
790 | | inputsize = videoSize; |
| 790 | inputsize = video_dim; |
791 | 791 | continue; |
792 | 792 | } |
793 | 793 | |
… |
… |
|
797 | 797 | (!(softwareDeinterlacing && softwareDeinterlacer == "bobdeint"))) |
798 | 798 | { |
799 | 799 | inputs = filter->frameBufferTextures; |
800 | | inputsize = videoSize; |
| 800 | inputsize = video_dim; |
801 | 801 | continue; |
802 | 802 | } |
803 | 803 | |
804 | 804 | // texture coordinates |
805 | | float t_right = (float)videoSize.width(); |
806 | | float t_bottom = (float)videoSize.height(); |
| 805 | float t_right = (float)video_dim.width(); |
| 806 | float t_bottom = (float)video_dim.height(); |
807 | 807 | float t_top = 0.0f; |
808 | 808 | float t_left = 0.0f; |
809 | | float trueheight = (float)videoSize.height(); |
| 809 | float trueheight = (float)video_dim.height(); |
810 | 810 | |
811 | 811 | // only apply overscan on last filter |
812 | 812 | if (filter->outputBuffer == kDefaultBuffer) |
813 | 813 | { |
814 | | t_left = (float)frameRect.left(); |
815 | | t_right = (float)frameRect.width() + t_left; |
816 | | t_top = (float)frameRect.top(); |
817 | | t_bottom = (float)frameRect.height() + t_top; |
| 814 | t_left = (float)video_rect.left(); |
| 815 | t_right = (float)video_rect.width() + t_left; |
| 816 | t_top = (float)video_rect.top(); |
| 817 | t_bottom = (float)video_rect.height() + t_top; |
818 | 818 | } |
819 | 819 | |
820 | 820 | if (!gl_context->IsFeatureSupported(kGLExtRect) && |
… |
… |
|
827 | 827 | trueheight /= inputsize.height(); |
828 | 828 | } |
829 | 829 | |
830 | | float line_height = (trueheight / (float)videoSize.height()); |
| 830 | float line_height = (trueheight / (float)video_dim.height()); |
831 | 831 | float bob = line_height / 2.0f; |
832 | 832 | |
833 | 833 | if (type == kGLFilterBobDeintDFR) |
… |
… |
|
881 | 881 | // vertex coordinates |
882 | 882 | QRect display = (filter->frameBuffers.empty() || |
883 | 883 | filter->outputBuffer == kDefaultBuffer) ? |
884 | | videoRect : frameBufferRect; |
| 884 | display_video_rect : frameBufferRect; |
885 | 885 | |
886 | 886 | float vleft = display.left(); |
887 | 887 | float vright = display.right(); |
… |
… |
|
908 | 908 | if (viewportControl) |
909 | 909 | { |
910 | 910 | glClear(GL_COLOR_BUFFER_BIT); |
911 | | SetViewPortPrivate(visibleRect.size()); |
| 911 | SetViewPortPrivate(display_visible_rect.size()); |
912 | 912 | } |
913 | 913 | else |
914 | 914 | { |
… |
… |
|
1042 | 1042 | gl_context->BindFramebuffer(0); |
1043 | 1043 | |
1044 | 1044 | inputs = filter->frameBufferTextures; |
1045 | | inputsize = videoSize; |
| 1045 | inputsize = video_dim; |
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | currentFrameNum = frame; |
diff -ur -X excl mythtvopengl2/libs/libmythtv/openglvideo.h mythtvopengl3/libs/libmythtv/openglvideo.h
old
|
new
|
|
55 | 55 | ~OpenGLVideo(); |
56 | 56 | |
57 | 57 | bool Init(OpenGLContext *glcontext, bool colour_control, |
58 | | QSize video_size, QRect visible_rect, |
59 | | QRect video_rect, QRect frame_rect, |
| 58 | QSize videoDim, QRect displayVisibleRect, |
| 59 | QRect displayVideoRect, QRect videoRect, |
60 | 60 | bool viewport_control, bool osd = FALSE); |
61 | 61 | |
62 | 62 | void UpdateInputFrame(const VideoFrame *frame); |
… |
… |
|
80 | 80 | |
81 | 81 | void SetMasterViewport(QSize size) { masterViewportSize = size; } |
82 | 82 | QSize GetViewPort(void) const { return viewportSize; } |
83 | | void SetVideoRect(const QRect &vidrect, const QRect &framerect) |
84 | | { videoRect = vidrect; frameRect = framerect;} |
85 | | QSize GetVideoSize(void) const { return videoSize; } |
| 83 | void SetVideoRect(const QRect &dispvidrect, const QRect &vidrect) |
| 84 | { display_video_rect = dispvidrect; video_rect = vidrect;} |
| 85 | QSize GetVideoSize(void) const { return video_dim; } |
86 | 86 | void SetVideoResize(const QRect &rect); |
87 | 87 | void DisableVideoResize(void); |
88 | 88 | int SetPictureAttribute(PictureAttribute attributeType, int newValue); |
… |
… |
|
114 | 114 | void SetTextureFilters(vector<uint> *textures, int filt); |
115 | 115 | |
116 | 116 | OpenGLContext *gl_context; |
117 | | QSize videoSize; |
| 117 | QSize video_dim; |
118 | 118 | QSize viewportSize; |
119 | 119 | QSize masterViewportSize; |
120 | | QRect visibleRect; |
121 | | QRect videoRect; |
122 | | QRect frameRect; |
| 120 | QRect display_visible_rect; |
| 121 | QRect display_video_rect; |
| 122 | QRect video_rect; |
123 | 123 | QRect frameBufferRect; |
124 | 124 | QString softwareDeinterlacer; |
125 | 125 | bool hardwareDeinterlacing; |