Fix epggrid scolling with tvguide

This commit is contained in:
jojo61 2020-03-26 12:36:00 +01:00
parent 14ba527a45
commit f756334187
2 changed files with 73 additions and 23 deletions

View File

@ -331,6 +331,7 @@ void cOglGlyph::LoadTexture(FT_BitmapGlyph ftGlyph) {
extern "C" void GlxInitopengl();
extern "C" void GlxDrawopengl();
extern "C" void GlxDestroy();
extern "C" void makejpg(uint8_t *data, int width, int height);
/****************************************************************************************
* cOglFont
****************************************************************************************/
@ -475,6 +476,7 @@ cOglFb::cOglFb(GLint width, GLint height, GLint viewPortWidth, GLint viewPortHei
initiated = false;
fb = 0;
texture = 0;
this->width = width;
this->height = height;
this->viewPortWidth = viewPortWidth;
@ -495,8 +497,7 @@ cOglFb::~cOglFb(void) {
bool cOglFb::Init(void) {
initiated = true;
glGenTextures(1, &texture);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -770,6 +771,7 @@ cOglCmdRenderFbToBufferFb::cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer,
this->drawPortX = (GLfloat)drawPortX;
this->drawPortY = (GLfloat)drawPortY;
this->transparency = transparency;
}
bool cOglCmdRenderFbToBufferFb::Execute(void) {
@ -780,15 +782,15 @@ bool cOglCmdRenderFbToBufferFb::Execute(void) {
GLfloat texY1 = drawPortY / (GLfloat)fb->Height();
GLfloat texX2 = texX1 + 1.0f;
GLfloat texY2 = texY1 + 1.0f;
if (fb->Scrollable()) {
GLfloat pageHeight = (GLfloat)fb->ViewportHeight() / (GLfloat)fb->Height();
texX1 = abs(drawPortX) / (GLfloat)fb->Width();
texY1 = 1.0f - pageHeight - abs(drawPortY) / (GLfloat)fb->Height();
texX2 = texX1 + (GLfloat)fb->ViewportWidth() / (GLfloat)fb->Width();
// texX2 = texX1 + (GLfloat)fb->ViewportWidth() / (GLfloat)fb->Width();
x2 = x + fb->Width();
texY2 = texY1 + pageHeight;
}
GLfloat quadVertices[] = {
// Pos // TexCoords
x , y , texX1, texY2, //left top
@ -805,9 +807,11 @@ bool cOglCmdRenderFbToBufferFb::Execute(void) {
VertexBuffers[vbTexture]->SetShaderProjectionMatrix(buffer->Width(), buffer->Height());
buffer->Bind();
if (!fb->BindTexture())
return false;
VertexBuffers[vbTexture]->Bind();
VertexBuffers[vbTexture]->Bind();
VertexBuffers[vbTexture]->SetVertexData(quadVertices);
VertexBuffers[vbTexture]->DrawArrays();
VertexBuffers[vbTexture]->Unbind();
@ -829,14 +833,13 @@ bool cOglCmdCopyBufferToOutputFb::Execute(void) {
pthread_mutex_lock(&OSDMutex);
fb->BindRead();
oFb->BindWrite();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
if (posd)
glReadPixels(0, 0 ,fb->Width(), fb->Height(),GL_RGBA,GL_UNSIGNED_BYTE,posd);
glFlush();
oFb->Unbind();
pthread_mutex_unlock(&OSDMutex);
ActivateOsd(oFb->texture,x, y, fb->Width() ,fb->Height());
return true;
@ -1237,7 +1240,6 @@ bool cOglCmdDrawText::Execute(void) {
if ( xGlyph > fb->Width() - 1 )
break;
}
glBindTexture(GL_TEXTURE_2D, 0);
VertexBuffers[vbText]->Unbind();
fb->Unbind();
@ -1264,7 +1266,7 @@ cOglCmdDrawImage::~cOglCmdDrawImage(void) {
bool cOglCmdDrawImage::Execute(void) {
GLuint texture;
#ifdef USE_DRM
pthread_mutex_lock(&OSDMutex);
// pthread_mutex_lock(&OSDMutex);
GlxDrawopengl(); // here we need the Shared Context for upload
GlxCheck();
#endif
@ -1290,7 +1292,7 @@ bool cOglCmdDrawImage::Execute(void) {
#ifdef USE_DRM
GlxInitopengl(); // Reset Context
GlxCheck();
pthread_mutex_unlock(&OSDMutex);
// pthread_mutex_unlock(&OSDMutex);
#endif
GLfloat x1 = x; //left
@ -1382,7 +1384,7 @@ cOglCmdStoreImage::~cOglCmdStoreImage(void) {
bool cOglCmdStoreImage::Execute(void) {
#ifdef USE_DRM
pthread_mutex_lock(&OSDMutex);
// pthread_mutex_lock(&OSDMutex);
GlxDrawopengl(); // here we need the Shared Context for upload
GlxCheck();
#endif
@ -1408,7 +1410,7 @@ bool cOglCmdStoreImage::Execute(void) {
#ifdef USE_DRM
GlxInitopengl(); // Reset Context
GlxCheck();
pthread_mutex_lock(&OSDMutex);
// pthread_mutex_lock(&OSDMutex);
#endif
return true;
}
@ -1826,7 +1828,6 @@ void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) {
memcpy(argb, Image.Data(), sizeof(tColor) * Image.Width() * Image.Height());
oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y()));
SetDirty();
MarkDrawPortDirty(cRect(Point, cSize(Image.Width(), Image.Height())).Intersected(DrawPort().Size()));
}
@ -1834,6 +1835,7 @@ void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) {
void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) {
if (!oglThread->Active())
return;
if (ImageHandle < 0 && oglThread->GetImageRef(ImageHandle)) {
sOglImage *img = oglThread->GetImageRef(ImageHandle);
oglThread->DoCmd(new cOglCmdDrawTexture(fb, img, Point.X(), Point.Y()));
@ -1874,6 +1876,7 @@ void cOglPixmap::DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor C
(index == 0 ? ColorBg : index == 1 ? ColorFg :
Bitmap.Color(index)) : Bitmap.Color(index));
}
oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Bitmap.Width(), Bitmap.Height(), Point.X(), Point.Y(), Overlay));
SetDirty();
MarkDrawPortDirty(cRect(Point, cSize(Bitmap.Width(), Bitmap.Height())).Intersected(DrawPort().Size()));
@ -1892,7 +1895,6 @@ void cOglPixmap::DrawText(const cPoint &Point, const char *s, tColor ColorFg, tC
Utf8ToArray(s, symbols, len + 1);
else
symbols[0] = 0;
int x = Point.X();
int y = Point.Y();
int w = Font->Width(s);
@ -1995,7 +1997,7 @@ cOglOsd::cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglT
int osdWidth = 0;
int osdHeight = 0;
pthread_mutex_lock(&OSDMutex);
// pthread_mutex_lock(&OSDMutex);
VideoGetOsdSize(&osdWidth, &osdHeight);
// osdWidth = 1920;
// osdHeight = 1080;
@ -2014,7 +2016,7 @@ cOglOsd::cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglT
oglThread->DoCmd(new cOglCmdInitOutputFb(oFb));
}
pthread_mutex_unlock(&OSDMutex);
// pthread_mutex_unlock(&OSDMutex);
}
cOglOsd::~cOglOsd() {
@ -2080,6 +2082,7 @@ void cOglOsd::DestroyPixmap(cPixmap *Pixmap) {
return;
if (!Pixmap)
return;
LOCK_PIXMAPS;
int start = 1;
if (isSubtitleOsd)
@ -2121,7 +2124,7 @@ void cOglOsd::Flush(void) {
oglThread->DoCmd(new cOglCmdRenderFbToBufferFb( oglPixmaps[i]->Fb(),
bFb,
oglPixmaps[i]->ViewPort().X(),
(!isSubtitleOsd) ? oglPixmaps[i]->ViewPort().Y() : 0,
(!isSubtitleOsd) ? oglPixmaps[i]->ViewPort().Y() : 0,
oglPixmaps[i]->Alpha(),
oglPixmaps[i]->DrawPort().X(),
oglPixmaps[i]->DrawPort().Y()));
@ -2142,3 +2145,4 @@ void cOglOsd::DrawScaledBitmap(int x, int y, const cBitmap &Bitmap, double Facto
int yNew = y - oglPixmaps[0]->ViewPort().Y();
oglPixmaps[0]->DrawBitmap(cPoint(x, yNew), Bitmap);
}

56
video.c
View File

@ -2492,7 +2492,6 @@ void createTextureDst(CuvidDecoder * decoder, int anz, unsigned int size_x, unsi
void generateVAAPIImage(CuvidDecoder * decoder, int index, const AVFrame * frame, int image_width, int image_height)
{
VAStatus status;
uint64_t first_time;
@ -3036,7 +3035,7 @@ int get_RGB(CuvidDecoder * decoder)
if (OsdShown == 1) {
if (OSDtexture)
glDeleteTextures(1, &OSDtexture);
pthread_mutex_lock(&OSDMutex);
// pthread_mutex_lock(&OSDMutex);
glGenTextures(1, &OSDtexture);
glBindTexture(GL_TEXTURE_2D, OSDtexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, OSDxsize, OSDysize, 0, GL_RGBA, GL_UNSIGNED_BYTE, posd);
@ -3044,7 +3043,7 @@ int get_RGB(CuvidDecoder * decoder)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
pthread_mutex_unlock(&OSDMutex);
// pthread_mutex_unlock(&OSDMutex);
OsdShown = 2;
}
@ -4370,10 +4369,10 @@ static void CuvidSyncDecoder(CuvidDecoder * decoder)
}
#endif
if (abs(diff) > 5000 * 90) { // more than 5s
err = CuvidMessage(2, "video: audio/video difference too big\n");
err = CuvidMessage(2, "video: audio/video difference too big %d\n",diff/90);
// decoder->SyncCounter = 1;
// usleep(10);
// goto out;
// goto out;
} else if (diff > 100 * 90) {
// FIXME: this quicker sync step, did not work with new code!
err = CuvidMessage(4, "video: slow down video, duping frame %d\n", diff / 90);
@ -6958,4 +6957,51 @@ void GlxDestroy() {
}
#endif
#if 0 // for debug only
#include <sys/stat.h>
extern uint8_t *CreateJpeg(uint8_t *, int *, int, int, int);
void makejpg(uint8_t *data, int width, int height) {
static int count=0;
int i,n=0,gpu=0;;
char buf[32],FileName[32];
uint8_t *rgb;
uint8_t *jpg_image;
int size,size1;
if (data == NULL) {
data = malloc(width*height*4);
gpu=1;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, data);
}
// n = snprintf(buf, sizeof(buf), "P6\n%d\n%d\n255\n", width, height);
sprintf(FileName,"/tmp/test%d.jpg",count++);
rgb = malloc(width * height * 3 + n);
if (!rgb) {
printf("Unable to get RGB Memory \n");
return;
}
// memcpy(rgb, buf, n); // header
size = width * height * 4;
for (i = 0; i < size / 4; ++i) { // convert bgra -> rgb
rgb[n + i * 3 + 0] = data[i * 4 + 2];
rgb[n + i * 3 + 1] = data[i * 4 + 1];
rgb[n + i * 3 + 2] = data[i * 4 + 0];
}
if (gpu)
free(data);
jpg_image = CreateJpeg(rgb, &size1, 90, width, height);
int fd = open(FileName, O_WRONLY | O_CREAT | O_NOFOLLOW | O_TRUNC, DEFFILEMODE);
write(fd,jpg_image,size1);
close(fd);
free(rgb);
}
#endif