diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index c5a0cc0..2db24d8 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -417,7 +417,7 @@ void GLFramebuffer::render() glBindTexture(GL_TEXTURE_2D, mState.displaytex); drawSquare(zoom, xscale); glBindTexture(GL_TEXTURE_2D, mState.osdtex); - drawSquare(1.0); + drawSquare(1.0, -100); glFlush(); glutSwapBuffers(); @@ -472,6 +472,31 @@ void GLFramebuffer::drawSquare(float size, float x_factor) 0.0, 1.0, 1.0, 1.0, }; + if (x_factor > -99.0) { /* x_factor == -100 => OSD */ + if (videoDecoder && + videoDecoder->pig_x > 0 && videoDecoder->pig_y > 0 && + videoDecoder->pig_w > 0 && videoDecoder->pig_h > 0) { + /* these calculations even consider cropping and panscan mode + * maybe this could be done with some clever opengl tricks? */ + double w2 = (double)mState.width * 0.5l; + double h2 = (double)mState.height * 0.5l; + double x = (double)(videoDecoder->pig_x - w2) / w2 / x_factor / size; + double y = (double)(h2 - videoDecoder->pig_y) / h2 / size; + double w = (double)videoDecoder->pig_w / w2; + double h = (double)videoDecoder->pig_h / h2; + x += ((1.0l - x_factor * size) / 2.0l) * w / x_factor / size; + y += ((size - 1.0l) / 2.0l) * h / size; + vertices[0] = x + w; /* top right x */ + vertices[1] = y; /* top right y */ + vertices[2] = x; /* top left x */ + vertices[3] = y; /* top left y */ + vertices[4] = x; /* bottom left x */ + vertices[5] = y - h; /* bottom left y */ + vertices[6] = vertices[0]; /* bottom right x */ + vertices[7] = vertices[5]; /* bottom right y */ + } + } else + x_factor = 1.0; /* OSD */ glPushMatrix(); glScalef(size * x_factor, size, size); diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index 341f6e9..5c4616f 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -78,6 +78,7 @@ cVideo::cVideo(int, void *, void *) buf_num = 0; buf_in = 0; buf_out = 0; + pig_x = pig_y = pig_w = pig_h = 0; display_aspect = DISPLAY_AR_16_9; display_crop = DISPLAY_AR_MODE_LETTERBOX; v_format = VIDEO_FORMAT_MPEG2; @@ -325,8 +326,12 @@ int cVideo::getBlank(void) return 0; } -void cVideo::Pig(int, int, int, int, int, int) +void cVideo::Pig(int x, int y, int w, int h, int, int) { + pig_x = x; + pig_y = y; + pig_w = w; + pig_h = h; } void cVideo::getPictureInfo(int &width, int &height, int &rate) diff --git a/generic-pc/video_lib.h b/generic-pc/video_lib.h index 55a0d8d..36f9892 100644 --- a/generic-pc/video_lib.h +++ b/generic-pc/video_lib.h @@ -121,7 +121,8 @@ typedef enum #define VDEC_MAXBUFS 0x30 class cVideo : public OpenThreads::Thread { - public: + friend class GLFramebuffer; + private: /* called from GL thread */ class SWFramebuffer : public std::vector { @@ -142,6 +143,7 @@ class cVideo : public OpenThreads::Thread AVRational mAR; }; int buf_in, buf_out, buf_num; + public: /* constructor & destructor */ cVideo(int mode, void *, void *); ~cVideo(void); @@ -205,6 +207,10 @@ class cVideo : public OpenThreads::Thread DISPLAY_AR display_aspect; DISPLAY_AR_MODE display_crop; int output_h; + int pig_x; + int pig_y; + int pig_w; + int pig_h; }; #endif