From 77baa4250533814a0a7619212106248485e38fb8 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 May 2013 18:28:53 +0200 Subject: [PATCH 1/7] GLFB: implement missing functions * output format (screen size) setting * aspect ratio setting * cropping, scaling (letterbox/panscan) * full screen mode (experimental, hit "f" key) * add EPG key ("e") Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/7c00b1d46be6ebeb0437955f3bcb96310d627a48 Author: Stefan Seyfried Date: 2013-05-05 (Sun, 05 May 2013) ------------------ This commit was generated by Migit --- generic-pc/glfb.cpp | 164 +++++++++++++++++++++++++++++++++++--------- generic-pc/glfb.h | 25 +++++-- 2 files changed, 153 insertions(+), 36 deletions(-) diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index 93c48d1..1560ff3 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -19,9 +19,8 @@ based on Carjay's neutrino-hd-dvbapi work, see http://gitorious.org/neutrino-hd/neutrino-hd-dvbapi - TODO: AV-Sync code is not existent yet + TODO: AV-Sync code is "experimental" at best cleanup carjay's crazy 3D stuff :-) - video mode setting (4:3, 16:9, panscan...) */ #include @@ -60,9 +59,19 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn { mState.width = x; mState.height = y; - mX = y * 16 / 9; /* hard coded 16:9 initial aspect ratio for now */ - mY = y; - mVA = 1.0; + mX = &_mX[0]; + mY = &_mY[0]; + *mX = x; + *mY = y; + av_reduce(&mOA.num, &mOA.den, x, y, INT_MAX); + mVA = mOA; /* initial aspect ratios are from the FB resolution, those */ + _mVA = mVA; /* will be updated by the videoDecoder functions anyway */ + mVAchanged = true; + mCrop = DISPLAY_AR_MODE_PANSCAN; + zoom = 1.0; + xscale = 1.0; + const char *tmp = getenv("GLFB_FULLSCREEN"); + mFullscreen = !!(tmp); mState.blit = true; last_apts = 0; @@ -118,6 +127,7 @@ void GLFramebuffer::initKeys() mKeyMap[0x0d] = KEY_OK; mKeyMap[0x1b] = KEY_EXIT; + mKeyMap['e'] = KEY_EPG; mKeyMap['i'] = KEY_INFO; mKeyMap['m'] = KEY_MENU; @@ -162,6 +172,7 @@ void GLFramebuffer::run() glutDisplayFunc(GLFramebuffer::rendercb); glutKeyboardFunc(GLFramebuffer::keyboardcb); glutSpecialFunc(GLFramebuffer::specialcb); + glutReshapeFunc(GLFramebuffer::resizecb); setupGLObjects(); /* needs GLEW prototypes */ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutMainLoop(); @@ -181,7 +192,7 @@ void GLFramebuffer::setupCtx() char const *argv[2] = { "neutrino", 0 }; lt_info("GLFB: GL thread starting\n"); glutInit(&argc, const_cast(argv)); - glutInitWindowSize(mX, mY); + glutInitWindowSize(mX[0], mY[0]); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("Neutrino"); } @@ -247,6 +258,13 @@ void GLFramebuffer::releaseGLObjects() { lt_debug_c("GLFB::%s: 0x%x\n", __func__, key); struct input_event ev; + if (key == 'f') + { + lt_info_c("GLFB::%s: toggle fullscreen\n", __func__); + gThiz->mFullscreen = !(gThiz->mFullscreen); + gThiz->mReInit = true; + return; + } std::map::const_iterator i = gThiz->mKeyMap.find(key); if (i == gThiz->mKeyMap.end()) return; @@ -281,21 +299,39 @@ int sleep_us = 30000; void GLFramebuffer::render() { - if (!mReInit) /* for example if window is resized */ - checkReinit(); - if(mShutDown) glutLeaveMainLoop(); + mReInitLock.lock(); if (mReInit) { + int xoff = 0; + int yoff = 0; + mVAchanged = true; mReInit = false; - glViewport(0, 0, mX, mY); - glutReshapeWindow(mX, mY); + mX = &_mX[mFullscreen]; + mY = &_mY[mFullscreen]; + if (mFullscreen) { + int x = glutGet(GLUT_SCREEN_WIDTH); + int y = glutGet(GLUT_SCREEN_HEIGHT); + *mX = x; + *mY = y; + AVRational a = { x, y }; + if (av_cmp_q(a, mOA) < 0) + *mY = x * mOA.den / mOA.num; + else if (av_cmp_q(a, mOA) > 0) + *mX = y * mOA.num / mOA.den; + xoff = (x - *mX) / 2; + yoff = (y - *mY) / 2; + } else + *mX = *mY * mOA.num / mOA.den; + lt_info("%s: reinit mX:%d mY:%d xoff:%d yoff:%d fs %d\n", + __func__, *mX, *mY, xoff, yoff, mFullscreen); + glViewport(xoff, yoff, *mX, *mY); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - float aspect = static_cast(mX)/mY; - float osdaspect = 1.0/(static_cast(16.0)/9); + float aspect = static_cast(*mX)/ *mY; + float osdaspect = static_cast(mOA.den) / mOA.num; // if(!mState.go3d) { glOrtho(aspect*-osdaspect, aspect*osdaspect, -1.0, 1.0, -1.0, 1.0 ); @@ -316,6 +352,11 @@ void GLFramebuffer::render() glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } + mReInitLock.unlock(); + if (mFullscreen) + glutFullScreen(); + else if (*mX != glutGet(GLUT_WINDOW_WIDTH) || *mY != glutGet(GLUT_WINDOW_HEIGHT)) + glutReshapeWindow(*mX, *mY); bltDisplayBuffer(); /* decoded video stream */ if (mState.blit) { @@ -345,12 +386,60 @@ void GLFramebuffer::render() } else #endif + if (mVAchanged) { - glBindTexture(GL_TEXTURE_2D, mState.displaytex); - drawSquare(1.0, mVA / (16.0/9)); - glBindTexture(GL_TEXTURE_2D, mState.osdtex); - drawSquare(1.0); + mVAchanged = false; + zoom = 1.0; + xscale = 1.0; + int cmp = (mCrop == DISPLAY_AR_MODE_NONE) ? 0 : av_cmp_q(mVA, mOA); + const AVRational a149 = { 14, 9 }; + switch (cmp) { + default: + case INT_MIN: /* invalid */ + case 0: /* identical */ + lt_debug("%s: mVA == mOA (or fullscreen mode :-)\n", __func__); + break; + case 1: /* mVA > mOA -- video is wider than display */ + lt_debug("%s: mVA > mOA\n", __func__); + xscale = av_q2d(mVA) / av_q2d(mOA); + switch (mCrop) { + case DISPLAY_AR_MODE_PANSCAN: + break; + case DISPLAY_AR_MODE_LETTERBOX: + zoom = av_q2d(mOA) / av_q2d(mVA); + break; + case DISPLAY_AR_MODE_PANSCAN2: + zoom = av_q2d(mOA) / av_q2d(a149); + break; + default: + break; + } + break; + case -1: /* mVA < mOA -- video is taller than display */ + lt_debug("%s: mVA < mOA\n", __func__); + xscale = av_q2d(mVA) / av_q2d(mOA); + switch (mCrop) { + case DISPLAY_AR_MODE_LETTERBOX: + break; + case DISPLAY_AR_MODE_PANSCAN2: + if (av_cmp_q(a149, mOA) < 0) { + zoom = av_q2d(mVA) * av_q2d(a149) / av_q2d(mOA); + break; + } + /* fallthrough for output format 14:9 */ + case DISPLAY_AR_MODE_PANSCAN: + zoom = av_q2d(mOA) / av_q2d(mVA); + break; + default: + break; + } + break; + } } + glBindTexture(GL_TEXTURE_2D, mState.displaytex); + drawSquare(zoom, xscale); + glBindTexture(GL_TEXTURE_2D, mState.osdtex); + drawSquare(1.0); glFlush(); glutSwapBuffers(); @@ -363,22 +452,29 @@ void GLFramebuffer::render() glutPostRedisplay(); } - -void GLFramebuffer::checkReinit() +/* static */ void GLFramebuffer::resizecb(int w, int h) { - int x = glutGet(GLUT_WINDOW_WIDTH); - int y = glutGet(GLUT_WINDOW_HEIGHT); - if ( x != mX || y != mY ) - { - mX = x; - mY = y; - /* fix aspect ratio */ - if (x < mY * 16 / 9) - mX = mY * 16 / 9; - else - mY = mX * 9 / 16; + gThiz->checkReinit(w, h); +} + +void GLFramebuffer::checkReinit(int x, int y) +{ + static int last_x = 0, last_y = 0; + + mReInitLock.lock(); + if (mReInit == false && (x != *mX || y != *mY)) { + if (x != *mX && abs(x - last_x) > 2) { + *mX = x; + *mY = *mX * mOA.den / mOA.num; + } else if (y != *mY && abs(y - last_y) > 2) { + *mY = y; + *mX = *mY * mOA.num / mOA.den; + } mReInit = true; } + mReInitLock.unlock(); + last_x = x; + last_y = y; } #if 0 @@ -489,8 +585,12 @@ void GLFramebuffer::bltDisplayBuffer() return; AVRational a = buf->AR(); - if (a.den != 0) - mVA = static_cast(w * a.num) / h / a.den; + if (a.den != 0 && a.num != 0 && av_cmp_q(a, _mVA)) { + _mVA = a; + /* _mVA is the raw buffer's aspect, mVA is the real scaled output aspect */ + av_reduce(&mVA.num, &mVA.den, w * a.num, h * a.den, INT_MAX); + mVAchanged = true; + } glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mState.displaypbo); glBufferData(GL_PIXEL_UNPACK_BUFFER, buf->size(), &(*buf)[0], GL_STREAM_DRAW_ARB); diff --git a/generic-pc/glfb.h b/generic-pc/glfb.h index 71c78b2..74eea35 100644 --- a/generic-pc/glfb.h +++ b/generic-pc/glfb.h @@ -19,12 +19,16 @@ #ifndef __glthread__ #define __glthread__ #include +#include #include #include #include #include #include #include /* for screeninfo etc. */ +extern "C" { +#include +} class GLFramebuffer : public OpenThreads::Thread { @@ -39,16 +43,28 @@ public: int getOSDHeight() { return mState.height; } void blit() { mState.blit = true; } + void setOutputFormat(AVRational a, int h, int c) { mOA = a; *mY = h; mCrop = c; mReInit = true; } + void clear(); fb_var_screeninfo getScreenInfo() { return screeninfo; } private: fb_var_screeninfo screeninfo; - int mX; /* window size */ - int mY; - float mVA; /* video aspect ratio */; + int *mX; + int *mY; + int _mX[2]; /* output window size */ + int _mY[2]; /* [0] = normal, [1] = fullscreen */ + AVRational mOA; /* output window aspect ratio */ + AVRational mVA; /* video aspect ratio */ + AVRational _mVA; /* for detecting changes in mVA */ + bool mVAchanged; + float zoom; /* for cropping */ + float xscale; /* and aspect ratio */ + int mCrop; /* DISPLAY_AR_MODE */ + bool mFullscreen; /* fullscreen? */ bool mReInit; /* setup things for GL */ + OpenThreads::Mutex mReInitLock; bool mShutDown; /* if set main loop is left */ bool mInitDone; /* condition predicate */ // OpenThreads::Condition mInitCond; /* condition variable for init */ @@ -61,11 +77,12 @@ private: int input_fd; int64_t last_apts; - void checkReinit(); /* e.g. in case window was resized */ static void rendercb(); /* callback for GLUT */ void render(); /* actual render function */ static void keyboardcb(unsigned char key, int x, int y); static void specialcb(int key, int x, int y); + static void resizecb(int w, int h); + void checkReinit(int w, int h); /* e.g. in case window was resized */ void initKeys(); /* setup key bindings for window */ void setupCtx(); /* create the window and make the context current */ From 1a6e19441f0f272bab8851d4a0adf7e899bc4f82 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 May 2013 18:45:05 +0200 Subject: [PATCH 2/7] generic/cVideo: implement setAspectRatio / setVideoSystem Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/4cb2f75305671b4055a6f60082169c8cd52a782d Author: Stefan Seyfried Date: 2013-05-05 (Sun, 05 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/video.cpp | 60 +++++++++++++++++++++++++++++++++++++++--- generic-pc/video_lib.h | 6 +++++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index cc34a83..429c3d9 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -40,17 +40,28 @@ extern "C" { #include "video_lib.h" #include "dmx_lib.h" +#include "glfb.h" #include "lt_debug.h" #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) cVideo *videoDecoder = NULL; extern cDemux *videoDemux; +extern GLFramebuffer *glfb; int system_rev = 0; static uint8_t *dmxbuf; static int bufpos; +static const AVRational aspect_ratios[6] = { + { 1, 1 }, + { 4, 3 }, + { 14, 9 }, + { 16, 9 }, + { 20, 9 }, + { -1,-1 } +}; + cVideo::cVideo(int, void *, void *) { lt_debug("%s\n", __func__); @@ -63,6 +74,8 @@ cVideo::cVideo(int, void *, void *) buf_num = 0; buf_in = 0; buf_out = 0; + display_aspect = DISPLAY_AR_16_9; + display_crop = DISPLAY_AR_MODE_LETTERBOX; v_format = VIDEO_FORMAT_MPEG2; } @@ -73,8 +86,15 @@ cVideo::~cVideo(void) videoDecoder = NULL; } -int cVideo::setAspectRatio(int, int) +int cVideo::setAspectRatio(int vformat, int cropping) { + lt_info("%s(%d, %d)\n", __func__, vformat, cropping); + if (vformat >= 0) + display_aspect = (DISPLAY_AR) vformat; + if (cropping >= 0) + display_crop = (DISPLAY_AR_MODE) cropping; + if (display_aspect < DISPLAY_AR_RAW) /* don't know what to do with this */ + glfb->setOutputFormat(aspect_ratios[display_aspect], output_h, display_crop); return 0; } @@ -137,8 +157,43 @@ int cVideo::setBlank(int) return 1; } -int cVideo::SetVideoSystem(int, bool) +int cVideo::SetVideoSystem(int system, bool) { + int h; + switch(system) + { + case VIDEO_STD_NTSC: + case VIDEO_STD_480P: + h = 480; + break; + case VIDEO_STD_1080I60: + case VIDEO_STD_1080I50: + case VIDEO_STD_1080P30: + case VIDEO_STD_1080P24: + case VIDEO_STD_1080P25: + case VIDEO_STD_1080P50: + h = 1080; + break; + case VIDEO_STD_720P50: + case VIDEO_STD_720P60: + h = 720; + break; + case VIDEO_STD_AUTO: + lt_info("%s: VIDEO_STD_AUTO not implemented\n", __func__); + // fallthrough + case VIDEO_STD_SECAM: + case VIDEO_STD_PAL: + case VIDEO_STD_576P: + h = 576; + break; + default: + lt_info("%s: unhandled value %d\n", __func__, system); + return 0; + } + v_std = (VIDEO_STD) system; + output_h = h; + if (display_aspect < DISPLAY_AR_RAW) /* don't know what to do with this */ + glfb->setOutputFormat(aspect_ratios[display_aspect], output_h, display_crop); return 0; } @@ -334,7 +389,6 @@ void cVideo::run(void) sws_scale(convert, frame->data, frame->linesize, 0, c->height, rgbframe->data, rgbframe->linesize); sws_freeContext(convert); - // TODO: locking needed! if (dec_w != c->width || dec_h != c->height) { lt_info("%s: pic changed %dx%d -> %dx%d\n", __func__, dec_w, dec_h, c->width, c->height); diff --git a/generic-pc/video_lib.h b/generic-pc/video_lib.h index 7fbbf30..0352512 100644 --- a/generic-pc/video_lib.h +++ b/generic-pc/video_lib.h @@ -6,7 +6,9 @@ #include #include #include "../common/cs_types.h" +extern "C" { #include +} typedef enum { ANALOG_SD_RGB_CINCH = 0x00, @@ -197,7 +199,11 @@ class cVideo : public OpenThreads::Thread bool w_h_changed; bool thread_running; VIDEO_FORMAT v_format; + VIDEO_STD v_std; OpenThreads::Mutex buf_m; + DISPLAY_AR display_aspect; + DISPLAY_AR_MODE display_crop; + int output_h; }; #endif From 402ec04fcff209d190dac8861d04a9b9693ecccd Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 May 2013 18:53:41 +0200 Subject: [PATCH 3/7] generic-pc: use HD framebuffer resolution Use 1280x720 instead of 720x576 as default. The resolution can be changed via the environment variable GLFB_RESOLUTION. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/eb9d2f44efaf3b608960641cb7e2717363afa418 Author: Stefan Seyfried Date: 2013-05-05 (Sun, 05 May 2013) ------------------ This commit was generated by Migit --- generic-pc/init.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/generic-pc/init.cpp b/generic-pc/init.cpp index 4c4481a..ad272f9 100644 --- a/generic-pc/init.cpp +++ b/generic-pc/init.cpp @@ -1,3 +1,4 @@ +#include #include #include "init_lib.h" @@ -14,8 +15,26 @@ void init_td_api() if (!initialized) lt_debug_init(); lt_info("%s begin, initialized=%d, debug=0x%02x\n", __func__, (int)initialized, debuglevel); - if (! glfb) - glfb = new GLFramebuffer(720, 576); /* hard coded to PAL resolution for now */ + if (! glfb) { + int x = 1280, y = 720; /* default OSD FB resolution */ + /* + * export GLFB_RESOLUTION=720,576 + * to restore old default behviour + */ + const char *tmp = getenv("GLFB_RESOLUTION"); + const char *p = NULL; + if (tmp) + p = strchr(tmp, ','); + if (p) { + x = atoi(tmp); + y = atoi(p + 1); + } + lt_info("%s: setting GL Framebuffer size to %dx%d\n", __func__, x, y); + if (!p) + lt_info("%s: export GLFB_RESOLUTION=\",\" to set another resolution\n", __func__); + + glfb = new GLFramebuffer(x, y); /* hard coded to PAL resolution for now */ + } initialized = true; } From 6f49d0294da571dcb655ab5e7d29accf4012396c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 May 2013 20:14:12 +0200 Subject: [PATCH 4/7] cRecord: fix compiler warning (type mismatch) Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/88b8aa7b8f78f22c07b99342c3c765395d34b430 Author: Stefan Seyfried Date: 2013-05-05 (Sun, 05 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libspark/record.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libspark/record.cpp b/libspark/record.cpp index 79497a8..9ed6e36 100644 --- a/libspark/record.cpp +++ b/libspark/record.cpp @@ -174,7 +174,6 @@ void cRecord::RecordThread() lt_info("%s: begin\n", __func__); #define BUFSIZE (1 << 20) /* 1MB */ #define READSIZE (BUFSIZE / 16) - ssize_t r = 0; int buf_pos = 0; int queued = 0; uint8_t *buf; @@ -197,6 +196,7 @@ void cRecord::RecordThread() dmx->Start(); bool overflow = false; + int r = 0; while (exit_flag == RECORD_RUNNING) { if (buf_pos < BUFSIZE) @@ -204,10 +204,10 @@ void cRecord::RecordThread() int toread = BUFSIZE - buf_pos; if (toread > READSIZE) toread = READSIZE; - r = dmx->Read(buf + buf_pos, toread, 50); - lt_debug("%s: buf_pos %6d r %6d / %6d\n", __func__, - buf_pos, (int)r, BUFSIZE - buf_pos); - if (r < 0) + ssize_t s = dmx->Read(buf + buf_pos, toread, 50); + lt_debug("%s: buf_pos %6d s %6d / %6d\n", __func__, + buf_pos, (int)s, BUFSIZE - buf_pos); + if (s < 0) { if (errno != EAGAIN && (errno != EOVERFLOW || !overflow)) { @@ -220,7 +220,7 @@ void cRecord::RecordThread() else { overflow = false; - buf_pos += r; + buf_pos += s; } } else From d16e9dd5902fb95e7675957d4de95758bdb51310 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 May 2013 00:19:45 +0200 Subject: [PATCH 5/7] GLFB: hide mouse cursor Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/2e54579ba6d928ea6ce84531a95153d4c43240b6 Author: Stefan Seyfried Date: 2013-05-06 (Mon, 06 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/glfb.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index 1560ff3..5327dd4 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -169,6 +169,7 @@ void GLFramebuffer::run() else { gThiz = this; + glutSetCursor(GLUT_CURSOR_NONE); glutDisplayFunc(GLFramebuffer::rendercb); glutKeyboardFunc(GLFramebuffer::keyboardcb); glutSpecialFunc(GLFramebuffer::specialcb); From bd55ecb62468fb8387157a4b2753398005246c45 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 May 2013 00:25:29 +0200 Subject: [PATCH 6/7] GLFB: slightly better fullscreen handling Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/9cc35ff0cc6201ab12b13c5f51831f75a9865eee Author: Stefan Seyfried Date: 2013-05-06 (Mon, 06 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/glfb.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index 5327dd4..68d9838 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -261,7 +261,7 @@ void GLFramebuffer::releaseGLObjects() struct input_event ev; if (key == 'f') { - lt_info_c("GLFB::%s: toggle fullscreen\n", __func__); + lt_info_c("GLFB::%s: toggle fullscreen %s\n", __func__, gThiz->mFullscreen?"off":"on"); gThiz->mFullscreen = !(gThiz->mFullscreen); gThiz->mReInit = true; return; @@ -324,6 +324,7 @@ void GLFramebuffer::render() *mX = y * mOA.num / mOA.den; xoff = (x - *mX) / 2; yoff = (y - *mY) / 2; + glutFullScreen(); } else *mX = *mY * mOA.num / mOA.den; lt_info("%s: reinit mX:%d mY:%d xoff:%d yoff:%d fs %d\n", @@ -354,9 +355,7 @@ void GLFramebuffer::render() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } mReInitLock.unlock(); - if (mFullscreen) - glutFullScreen(); - else if (*mX != glutGet(GLUT_WINDOW_WIDTH) || *mY != glutGet(GLUT_WINDOW_HEIGHT)) + if (!mFullscreen && (*mX != glutGet(GLUT_WINDOW_WIDTH) || *mY != glutGet(GLUT_WINDOW_HEIGHT))) glutReshapeWindow(*mX, *mY); bltDisplayBuffer(); /* decoded video stream */ @@ -463,7 +462,7 @@ void GLFramebuffer::checkReinit(int x, int y) static int last_x = 0, last_y = 0; mReInitLock.lock(); - if (mReInit == false && (x != *mX || y != *mY)) { + if (!mFullscreen && !mReInit && (x != *mX || y != *mY)) { if (x != *mX && abs(x - last_x) > 2) { *mX = x; *mY = *mX * mOA.den / mOA.num; From 8cf48de3502d8c4b14bceee2ac44ec1281c73330 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 May 2013 00:32:48 +0200 Subject: [PATCH 7/7] GLFB: remove unused 3D cube code Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/6336dc4f942bc0f61dec7a02104e243f2a351eb5 Author: Stefan Seyfried Date: 2013-05-06 (Mon, 06 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/glfb.cpp | 84 +++------------------------------------------ generic-pc/glfb.h | 2 -- 2 files changed, 5 insertions(+), 81 deletions(-) diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index 68d9838..399d486 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -20,7 +20,6 @@ http://gitorious.org/neutrino-hd/neutrino-hd-dvbapi TODO: AV-Sync code is "experimental" at best - cleanup carjay's crazy 3D stuff :-) */ #include @@ -334,19 +333,10 @@ void GLFramebuffer::render() glLoadIdentity(); float aspect = static_cast(*mX)/ *mY; float osdaspect = static_cast(mOA.den) / mOA.num; -// if(!mState.go3d) - { - glOrtho(aspect*-osdaspect, aspect*osdaspect, -1.0, 1.0, -1.0, 1.0 ); - glClearColor(0.0, 0.0, 0.0, 1.0); - } -#if 0 - else - { /* carjay is crazy... :-) */ - gluPerspective(45.0, static_cast(mX)/mY, 0.05, 1000.0); - glTranslatef(0.0, 0.0, -2.0); - glClearColor(0.25, 0.25, 0.25, 1.0); - } -#endif + + glOrtho(aspect*-osdaspect, aspect*osdaspect, -1.0, 1.0, -1.0, 1.0 ); + glClearColor(0.0, 0.0, 0.0, 1.0); + glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_BLEND); @@ -368,24 +358,7 @@ void GLFramebuffer::render() glBindTexture(GL_TEXTURE_2D, mState.osdtex); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -#if 0 - // cube test - if(mState.go3d) - { - glEnable(GL_DEPTH_TEST); - static float ydeg = 0.0; - glPushMatrix(); - glRotatef(ydeg, 0.0, 1.0, 0.0); - glBindTexture(GL_TEXTURE_2D, mState.displaytex); - drawCube(0.5); - glScalef(1.01, 1.01, 1.01); - glBindTexture(GL_TEXTURE_2D, mState.osdtex); - drawCube(0.5); - glPopMatrix(); - ydeg += 0.75f; - } - else -#endif + if (mVAchanged) { mVAchanged = false; @@ -477,53 +450,6 @@ void GLFramebuffer::checkReinit(int x, int y) last_y = y; } -#if 0 -void GLFramebuffer::drawCube(float size) -{ - GLfloat vertices[] = { - 1.0f, 1.0f, 1.0f, - -1.0f, 1.0f, 1.0f, - -1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, -1.0f, - 1.0f, 1.0f, -1.0f, - -1.0f, 1.0f, -1.0f, - -1.0f, -1.0f, -1.0f - }; - - GLubyte indices[] = { - 0, 1, 2, 3, /* front */ - 0, 3, 4, 5, /* right */ - 0, 5, 6, 1, /* top */ - 1, 6, 7, 2, /* left */ - 7, 4, 3, 2, /* bottom */ - 4, 7, 6, 5 /* back */ - }; - - GLfloat texcoords[] = { - 1.0, 0.0, // v0 - 0.0, 0.0, // v1 - 0.0, 1.0, // v2 - 1.0, 1.0, // v3 - 0.0, 1.0, // v4 - 0.0, 0.0, // v5 - 1.0, 0.0, // v6 - 1.0, 1.0 // v7 - }; - - glPushMatrix(); - glScalef(size, size, size); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, vertices); - glTexCoordPointer(2, GL_FLOAT, 0, texcoords); - glDrawElements(GL_QUADS, 24, GL_UNSIGNED_BYTE, indices); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glPopMatrix(); -} -#endif - void GLFramebuffer::drawSquare(float size, float x_factor) { GLfloat vertices[] = { diff --git a/generic-pc/glfb.h b/generic-pc/glfb.h index 74eea35..c6999d5 100644 --- a/generic-pc/glfb.h +++ b/generic-pc/glfb.h @@ -89,7 +89,6 @@ private: void setupOSDBuffer(); /* create the OSD buffer */ void setupGLObjects(); /* PBOs, textures and stuff */ void releaseGLObjects(); - // void drawCube(float size); /* cubes are the building blocks of our society */ void drawSquare(float size, float x_factor = 1); /* do not be square */ struct { @@ -99,7 +98,6 @@ private: GLuint pbo; /* PBO we use for transfer to texture */ GLuint displaytex; /* holds the display texture */ GLuint displaypbo; - //int go3d; bool blit; } mState;