Ticket #5324: mythtv-vid-21.diff
File mythtv-vid-21.diff, 9.8 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/openglcontext.cpp
diff -ur -X excl mythtv-vid-20/libs/libmythtv/openglcontext.cpp mythtv-vid-21/libs/libmythtv/openglcontext.cpp
old new 617 617 bzero(scratch, tmp_size); 618 618 619 619 GLint check; 620 621 glTexImage2D(tmp->m_type, 0, tmp->m_internal_fmt, 622 size.width(), size.height(), 0, 623 tmp->m_data_fmt , tmp->m_data_type, scratch); 620 if (tmp->m_type == GL_TEXTURE_1D) 621 { 622 glTexImage1D(tmp->m_type, 0, tmp->m_internal_fmt, 623 size.width(), 0, 624 tmp->m_data_fmt , tmp->m_data_type, scratch); 625 } 626 else 627 { 628 glTexImage2D(tmp->m_type, 0, tmp->m_internal_fmt, 629 size.width(), size.height(), 0, 630 tmp->m_data_fmt , tmp->m_data_type, scratch); 631 } 624 632 glGetTexLevelParameteriv(tmp->m_type, 0, GL_TEXTURE_WIDTH, &check); 625 633 626 634 delete [] scratch; … … 1028 1036 return tmp_pbo; 1029 1037 } 1030 1038 1039 uint OpenGLContext::CreateHelperTexture(void) 1040 { 1041 MakeCurrent(true); 1042 1043 uint width = m_max_tex_size; 1044 1045 uint tmp_tex = CreateTexture(QSize(width, 1), QSize(width, 1), 1046 false, 1047 GL_TEXTURE_1D, GL_FLOAT, 1048 GL_RGBA, GL_RGBA16, 1049 GL_NEAREST, GL_REPEAT); 1050 1051 if (!tmp_tex) 1052 { 1053 DeleteTexture(tmp_tex); 1054 return 0; 1055 } 1056 1057 float *buf = NULL; 1058 buf = new float[m_priv->m_textures[tmp_tex].m_data_size]; 1059 float *ref = buf; 1060 1061 for (uint i = 0; i < width; i++) 1062 { 1063 float x = (((float)i) + 0.5f) / (float)width; 1064 store_bicubic_weights(x, ref); 1065 ref += 4; 1066 } 1067 store_bicubic_weights(0, buf); 1068 store_bicubic_weights(1, &buf[(width - 1) << 2]); 1069 1070 EnableTextures(tmp_tex); 1071 glBindTexture(m_priv->m_textures[tmp_tex].m_type, tmp_tex); 1072 glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA16, width, 0, GL_RGBA, GL_FLOAT, buf); 1073 1074 VERBOSE(VB_PLAYBACK, LOC + 1075 QString("Created bicubic helper texture (%1 samples)") 1076 .arg(width)); 1077 1078 delete [] buf; 1079 1080 MakeCurrent(false); 1081 1082 return tmp_tex; 1083 } 1084 1031 1085 int OpenGLContext::SetPictureAttribute( 1032 1086 PictureAttribute attribute, int newValue) 1033 1087 { -
libs/libmythtv/openglcontext.h
diff -ur -X excl mythtv-vid-20/libs/libmythtv/openglcontext.h mythtv-vid-21/libs/libmythtv/openglcontext.h
old new 110 110 int SetPictureAttribute(PictureAttribute attributeType, int newValue); 111 111 PictureAttributeSupported GetSupportedPictureAttributes(void) const; 112 112 void SetColourParams(void); 113 uint CreateHelperTexture(void); 113 114 114 115 private: 115 116 void Init2DState(void); … … 192 193 PictureAttributeSupported GetSupportedPictureAttributes(void) const 193 194 { return kPictureAttributeSupported_None; } 194 195 void SetColourParams(void); 196 uint CreateHelperTexture(void); 195 197 }; 196 198 197 199 #endif //!USING_OPENGL -
libs/libmythtv/openglvideo.cpp
diff -ur -X excl mythtv-vid-20/libs/libmythtv/openglvideo.cpp mythtv-vid-21/libs/libmythtv/openglvideo.cpp
old new 44 44 inputTextureSize(0,0), currentFrameNum(0), 45 45 inputUpdated(false), 46 46 textureRects(false), textureType(GL_TEXTURE_2D), 47 helperTexture(0), defaultResize(kGLFilterResize), 47 48 convertSize(0,0), convertBuf(NULL), 48 49 49 50 videoResize(false), videoResizeRect(0,0,0,0), … … 62 63 { 63 64 ShutDownYUV2RGB(); 64 65 66 if (helperTexture) 67 gl_context->DeleteTexture(helperTexture); 68 helperTexture = 0; 69 65 70 DeleteTextures(&inputTextures); 66 71 DeleteTextures(&referenceTextures); 67 72 … … 110 115 inputUpdated = false; 111 116 gl_letterbox_colour = letterbox_colour; 112 117 113 gl_context->GetTextureType(textureType, textureRects); 118 if (defaultResize != kGLFilterBicubic) 119 gl_context->GetTextureType(textureType, textureRects); 114 120 115 121 SetViewPort(display_visible_rect.size()); 116 122 … … 192 198 { 193 199 bool resize = ((video_dim.height() < display_video_rect.height()) || 194 200 (video_dim.width() < display_video_rect.width())); 201 resize &= !filters.count(kGLFilterResize); 202 resize &= !filters.count(kGLFilterBicubic); 195 203 196 if (resize && !filters.count(kGLFilterResize)) 197 AddFilter(kGLFilterResize); 198 else if (!resize && filters.count(kGLFilterResize) && 199 !filters.count(kGLFilterYUV2RGBA)) 200 RemoveFilter(kGLFilterResize); 204 if (resize) 205 AddFilter(defaultResize); 201 206 202 207 glfilt_map_t::reverse_iterator it; 203 208 … … 303 308 temp->numInputs = 1; 304 309 GLuint program = 0; 305 310 311 if (filter == kGLFilterBicubic) 312 { 313 if (helperTexture) 314 gl_context->DeleteTexture(helperTexture); 315 316 helperTexture = gl_context->CreateHelperTexture(); 317 if (!helperTexture) 318 success = false; 319 } 320 306 321 if (filter != kGLFilterNone && filter != kGLFilterResize) 307 322 { 308 323 program = AddFragmentProgram(filter); … … 880 895 } 881 896 } 882 897 898 if (helperTexture && type == kGLFilterBicubic) 899 { 900 glActiveTexture(GL_TEXTURE0 + active_tex); 901 glBindTexture(GL_TEXTURE_1D/*N.B.*/, helperTexture); 902 } 903 883 904 // enable fragment program and set any environment variables 884 905 if ((type != kGLFilterNone) && (type != kGLFilterResize)) 885 906 { … … 1021 1042 ret = kGLFilterYUV2RGBA; 1022 1043 else if (filter.contains("resize")) 1023 1044 ret = kGLFilterResize; 1045 else if (filter.contains("bicubic")) 1046 ret = kGLFilterBicubic; 1024 1047 1025 1048 return ret; 1026 1049 } … … 1038 1061 return "osd"; 1039 1062 case kGLFilterResize: 1040 1063 return "resize"; 1064 case kGLFilterBicubic: 1065 return "bicubic"; 1041 1066 } 1042 1067 1043 1068 return ""; … … 1410 1435 "CMP res, prev, spred1, current;\n" 1411 1436 }; 1412 1437 1438 static const QString bicubic = 1439 "TEMP coord, coord2, cdelta, parmx, parmy, a, b, c, d;\n" 1440 "MAD coord.xy, fragment.texcoord[0], {%6, %7}, {0.5, 0.5};\n" 1441 "TEX parmx, coord.x, texture[1], 1D;\n" 1442 "TEX parmy, coord.y, texture[1], 1D;\n" 1443 "MUL cdelta.xz, parmx.rrgg, {-%5, 0, %5, 0};\n" 1444 "MUL cdelta.yw, parmy.rrgg, {0, -%3, 0, %3};\n" 1445 "ADD coord, fragment.texcoord[0].xyxy, cdelta.xyxw;\n" 1446 "ADD coord2, fragment.texcoord[0].xyxy, cdelta.zyzw;\n" 1447 "TEX a, coord.xyxy, texture[0], 2D;\n" 1448 "TEX b, coord.zwzw, texture[0], 2D;\n" 1449 "TEX c, coord2.xyxy, texture[0], 2D;\n" 1450 "TEX d, coord2.zwzw, texture[0], 2D;\n" 1451 "LRP a, parmy.b, a, b;\n" 1452 "LRP c, parmy.b, c, d;\n" 1453 "LRP result.color, parmx.b, a, c;\n"; 1454 1413 1455 QString OpenGLVideo::GetProgramString(OpenGLFilterType name, 1414 1456 QString deint, FrameScanType field) 1415 1457 { … … 1487 1529 case kGLFilterResize: 1488 1530 break; 1489 1531 1532 case kGLFilterBicubic: 1533 1534 ret += bicubic; 1535 break; 1536 1490 1537 default: 1491 1538 VERBOSE(VB_PLAYBACK, LOC_ERR + "Unknown fragment program."); 1492 1539 break; … … 1497 1544 1498 1545 float lineHeight = 1.0f; 1499 1546 float colWidth = 1.0f; 1547 QSize fb_size = GetTextureSize(video_dim); 1500 1548 1501 1549 if (!textureRects && 1502 1550 (inputTextureSize.height() > 0)) … … 1511 1559 ret.replace("%3", temp.setNum(lineHeight, 'f', 8)); 1512 1560 ret.replace("%4", temp.setNum(lineHeight * 2.0, 'f', 8)); 1513 1561 ret.replace("%5", temp.setNum(colWidth, 'f', 8)); 1562 ret.replace("%6", temp.setNum((float)fb_size.width(), 'f', 1)); 1563 ret.replace("%7", temp.setNum((float)fb_size.height(), 'f', 1)); 1514 1564 1515 1565 ret += "END"; 1516 1566 -
libs/libmythtv/openglvideo.h
diff -ur -X excl mythtv-vid-20/libs/libmythtv/openglvideo.h mythtv-vid-21/libs/libmythtv/openglvideo.h
old new 21 21 22 22 // Frame scaling/resizing filters 23 23 kGLFilterResize, 24 kGLFilterBicubic, 24 25 }; 25 26 26 27 enum DisplayBuffer … … 127 128 bool inputUpdated; 128 129 bool textureRects; 129 130 uint textureType; 131 uint helperTexture; 132 OpenGLFilterType defaultResize; 130 133 131 134 QSize convertSize; 132 135 unsigned char *convertBuf; -
libs/libmythtv/util-opengl.cpp
diff -ur -X excl mythtv-vid-20/libs/libmythtv/util-opengl.cpp mythtv-vid-21/libs/libmythtv/util-opengl.cpp
old new 911 911 dst_1 += dwrap; dst_2 += dwrap; dst_3 += dwrap; dst_4 += dwrap; 912 912 } 913 913 } 914 915 void store_bicubic_weights(float x, float *dst) 916 { 917 float w0 = (((-1 * x + 3) * x - 3) * x + 1) / 6; 918 float w1 = ((( 3 * x - 6) * x + 0) * x + 4) / 6; 919 float w2 = (((-3 * x + 3) * x + 3) * x + 1) / 6; 920 float w3 = ((( 1 * x + 0) * x + 0) * x + 0) / 6; 921 *dst++ = 1 + x - w1 / (w0 + w1); 922 *dst++ = 1 - x + w3 / (w2 + w3); 923 *dst++ = w0 + w1; 924 *dst++ = 0; 925 } -
libs/libmythtv/util-opengl.h
diff -ur -X excl mythtv-vid-20/libs/libmythtv/util-opengl.h mythtv-vid-21/libs/libmythtv/util-opengl.h
old new 128 128 const int *pitches, 129 129 const QSize size); 130 130 131 void store_bicubic_weights(float x, float *dst); 132 131 133 __GLXextFuncPtr get_gl_proc_address(const QString &procName); 132 134 133 135 int get_gl_texture_rect_type(const QString &extensions);