mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 07:23:11 +02:00
generic-pc: add Pig function to cVideo / GLFB
This commit is contained in:
@@ -417,7 +417,7 @@ void GLFramebuffer::render()
|
|||||||
glBindTexture(GL_TEXTURE_2D, mState.displaytex);
|
glBindTexture(GL_TEXTURE_2D, mState.displaytex);
|
||||||
drawSquare(zoom, xscale);
|
drawSquare(zoom, xscale);
|
||||||
glBindTexture(GL_TEXTURE_2D, mState.osdtex);
|
glBindTexture(GL_TEXTURE_2D, mState.osdtex);
|
||||||
drawSquare(1.0);
|
drawSquare(1.0, -100);
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
@@ -472,6 +472,31 @@ void GLFramebuffer::drawSquare(float size, float x_factor)
|
|||||||
0.0, 1.0,
|
0.0, 1.0,
|
||||||
1.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();
|
glPushMatrix();
|
||||||
glScalef(size * x_factor, size, size);
|
glScalef(size * x_factor, size, size);
|
||||||
|
@@ -78,6 +78,7 @@ cVideo::cVideo(int, void *, void *)
|
|||||||
buf_num = 0;
|
buf_num = 0;
|
||||||
buf_in = 0;
|
buf_in = 0;
|
||||||
buf_out = 0;
|
buf_out = 0;
|
||||||
|
pig_x = pig_y = pig_w = pig_h = 0;
|
||||||
display_aspect = DISPLAY_AR_16_9;
|
display_aspect = DISPLAY_AR_16_9;
|
||||||
display_crop = DISPLAY_AR_MODE_LETTERBOX;
|
display_crop = DISPLAY_AR_MODE_LETTERBOX;
|
||||||
v_format = VIDEO_FORMAT_MPEG2;
|
v_format = VIDEO_FORMAT_MPEG2;
|
||||||
@@ -325,8 +326,12 @@ int cVideo::getBlank(void)
|
|||||||
return 0;
|
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)
|
void cVideo::getPictureInfo(int &width, int &height, int &rate)
|
||||||
|
@@ -121,7 +121,8 @@ typedef enum
|
|||||||
#define VDEC_MAXBUFS 0x30
|
#define VDEC_MAXBUFS 0x30
|
||||||
class cVideo : public OpenThreads::Thread
|
class cVideo : public OpenThreads::Thread
|
||||||
{
|
{
|
||||||
public:
|
friend class GLFramebuffer;
|
||||||
|
private:
|
||||||
/* called from GL thread */
|
/* called from GL thread */
|
||||||
class SWFramebuffer : public std::vector<unsigned char>
|
class SWFramebuffer : public std::vector<unsigned char>
|
||||||
{
|
{
|
||||||
@@ -142,6 +143,7 @@ class cVideo : public OpenThreads::Thread
|
|||||||
AVRational mAR;
|
AVRational mAR;
|
||||||
};
|
};
|
||||||
int buf_in, buf_out, buf_num;
|
int buf_in, buf_out, buf_num;
|
||||||
|
public:
|
||||||
/* constructor & destructor */
|
/* constructor & destructor */
|
||||||
cVideo(int mode, void *, void *);
|
cVideo(int mode, void *, void *);
|
||||||
~cVideo(void);
|
~cVideo(void);
|
||||||
@@ -205,6 +207,10 @@ class cVideo : public OpenThreads::Thread
|
|||||||
DISPLAY_AR display_aspect;
|
DISPLAY_AR display_aspect;
|
||||||
DISPLAY_AR_MODE display_crop;
|
DISPLAY_AR_MODE display_crop;
|
||||||
int output_h;
|
int output_h;
|
||||||
|
int pig_x;
|
||||||
|
int pig_y;
|
||||||
|
int pig_w;
|
||||||
|
int pig_h;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user