Ticket #5324: mythtv-vid-20.diff

File mythtv-vid-20.diff, 9.5 KB (added by mark.kendall@…, 16 years ago)

Add a GPU based YADIF deinterlacer

  • libs/libmythtv/openglvideo.cpp

    diff -ur -X excl mythtv-vid-19/libs/libmythtv/openglvideo.cpp mythtv-vid-20/libs/libmythtv/openglvideo.cpp
    old new  
    11991199+ field_calc + deint_end_bot
    12001200};
    12011201
     1202static const QString yadif_setup =
     1203"TEMP a,b,c,e,f,g,h,j,k,l;\n"
     1204"TEMP a1,b1,f1,g1,h1,i1,j1,l1,m1,n1;\n"
     1205"ALIAS d1 = f;\n"
     1206"ALIAS k1 = g;\n"
     1207"ALIAS c1 = prev;\n"
     1208"ALIAS e1 = mov;\n"
     1209"ALIAS p0 = res;\n"
     1210"ALIAS p1 = c;\n"
     1211"ALIAS p3 = h;\n"
     1212"ALIAS spred1 = a;\n"
     1213"ALIAS spred2 = b;\n"
     1214"ALIAS spred3 = c;\n"
     1215"ALIAS spred4 = e;\n"
     1216"ALIAS spred5 = f;\n"
     1217"ALIAS sscore = g;\n"
     1218"ALIAS score1 = h;\n"
     1219"ALIAS score2 = j;\n"
     1220"ALIAS score3 = k;\n"
     1221"ALIAS score4 = l;\n"
     1222"ALIAS if1 = a1;\n"
     1223"ALIAS if2 = b1;\n"
     1224"TEMP p2, p4;\n"
     1225"ALIAS diff1 = a;\n"
     1226"ALIAS diff2 = b;\n"
     1227"TEMP diff0;\n";
     1228
     1229static const QString yadif_spatial_sample =
     1230"ADD tmp, tex, {%5, %3, 0.0, 0.0};\n"
     1231"TEX e1, tmp, texture[1], %1;\n"
     1232"ADD tmp, tmp, {%5, 0.0, 0.0, 0.0};\n"
     1233"TEX f1, tmp, texture[1], %1;\n"
     1234"ADD tmp, tmp, {%5, 0.0, 0.0, 0.0};\n"
     1235"TEX g1, tmp, texture[1], %1;\n"
     1236"SUB tmp, tmp, {0.0, %4, 0.0, 0.0};\n"
     1237"TEX n1, tmp, texture[1], %1;\n"
     1238"SUB tmp, tmp, {%5, 0.0, 0.0, 0.0};\n"
     1239"TEX m1, tmp, texture[1], %1;\n"
     1240"SUB tmp, tmp, {%5, 0.0, 0.0, 0.0};\n"
     1241"TEX l1, tmp, texture[1], %1;\n"
     1242
     1243"SUB tmp, tex, {%5, %3, 0.0, 0.0};\n"
     1244"TEX j1, tmp, texture[1], %1;\n"
     1245"SUB tmp, tmp, {%5, 0.0, 0.0, 0.0};\n"
     1246"TEX i1, tmp, texture[1], %1;\n"
     1247"SUB tmp, tmp, {%5, 0.0, 0.0, 0.0};\n"
     1248"TEX h1, tmp, texture[1], %1;\n"
     1249"ADD tmp, tmp, {0.0, %4, 0.0, 0.0};\n"
     1250"TEX a1, tmp, texture[1], %1;\n"
     1251"ADD tmp, tmp, {%5, 0.0, 0.0, 0.0};\n"
     1252"TEX b1, tmp, texture[1], %1;\n"
     1253"ADD tmp, tmp, {%5, 0.0, 0.0, 0.0};\n"
     1254"TEX c1, tmp, texture[1], %1;\n";
     1255
     1256static const QString yadif_calc =
     1257"LRP p0, 0.5, c, h;\n"
     1258"MOV p1, f;\n"
     1259"LRP p2, 0.5, d, i;\n"
     1260"MOV p3, g;\n"
     1261"LRP p4, 0.5, e, j;\n"
     1262
     1263"SUB diff0, d, i;\n"
     1264"ABS diff0, diff0;\n"
     1265"SUB tmp, a, f;\n"
     1266"ABS tmp, tmp;\n"
     1267"SUB diff1, b, g;\n"
     1268"ABS diff1, diff1;\n"
     1269"LRP diff1, 0.5, diff1, tmp;\n"
     1270"SUB tmp, k, f;\n"
     1271"ABS tmp, tmp;\n"
     1272"SUB diff2, g, l;\n"
     1273"ABS diff2, diff2;\n"
     1274"LRP diff2, 0.5, diff2, tmp;\n"
     1275"MAX diff0, diff0, diff1;\n"
     1276"MAX diff0, diff0, diff2;\n"
     1277
     1278// mode < 2
     1279"SUB tmp, p0, p1;\n"
     1280"SUB other, p4, p3;\n"
     1281"MIN spred1, tmp, other;\n"
     1282"MAX spred2, tmp, other;\n"
     1283"SUB tmp, p2, p1;\n"
     1284"SUB other, p2, p3;\n"
     1285"MAX spred1, spred1, tmp;\n"
     1286"MAX spred1, spred1, other;\n"
     1287"MIN spred2, spred2, tmp;\n"
     1288"MIN spred2, spred2, other;\n"
     1289"MAX spred1, spred2, -spred1;\n"
     1290"MAX diff0, diff0, spred1;\n"
     1291
     1292// spatial prediction
     1293"LRP spred1, 0.5, d1, k1;\n"
     1294"LRP spred2, 0.5, c1, l1;\n"
     1295"LRP spred3, 0.5, b1, m1;\n"
     1296"LRP spred4, 0.5, e1, j1;\n"
     1297"LRP spred5, 0.5, f1, i1;\n"
     1298
     1299"SUB sscore, c1, j1;\n"
     1300"ABS sscore, sscore;\n"
     1301"SUB tmp, d1, k1;\n"
     1302"ABS tmp, tmp;\n"
     1303"ADD sscore, sscore, tmp;\n"
     1304"SUB tmp, e1, l1;\n"
     1305"ABS tmp, tmp;\n"
     1306"ADD sscore, sscore, tmp;\n"
     1307"SUB sscore, sscore, 1.0;\n"
     1308
     1309"SUB score1, b1, k1;\n"
     1310"ABS score1, score1;\n"
     1311"SUB tmp, c1, l1;\n"
     1312"ABS tmp, tmp;\n"
     1313"ADD score1, score1, tmp;\n"
     1314"SUB tmp, d1, m1;\n"
     1315"ABS tmp, tmp;\n"
     1316"ADD score1, score1, tmp;\n"
     1317
     1318"SUB score2, a1, l1;\n"
     1319"ABS score2, score2;\n"
     1320"SUB tmp, b1, m1;\n"
     1321"ABS tmp, tmp;\n"
     1322"ADD score2, score2, tmp;\n"
     1323"SUB tmp, c1, n1;\n"
     1324"ABS tmp, tmp;\n"
     1325"ADD score2, score2, tmp;\n"
     1326
     1327"SUB score3, d1, i1;\n"
     1328"ABS score3, score3;\n"
     1329"SUB tmp, e1, j1;\n"
     1330"ABS tmp, tmp;\n"
     1331"ADD score3, score3, tmp;\n"
     1332"SUB tmp, f1, k1;\n"
     1333"ABS tmp, tmp;\n"
     1334"ADD score3, score3, tmp;\n"
     1335
     1336"SUB score4, e1, h1;\n"
     1337"ABS score4, score4;\n"
     1338"SUB tmp, f1, i1;\n"
     1339"ABS tmp, tmp;\n"
     1340"ADD score4, score4, tmp;\n"
     1341"SUB tmp, g1, j1;\n"
     1342"ABS tmp, tmp;\n"
     1343"ADD score4, score4, tmp;\n"
     1344"SUB if1, sscore, score1;\n"
     1345"SUB if2, score1, score2;\n"
     1346"CMP if2, if1, -1.0, if2;\n"
     1347"CMP spred1, if1, spred1, spred2;\n"
     1348"CMP spred1, if2, spred1, spred3;\n"
     1349"CMP sscore, if1, sscore, score1;\n"
     1350"CMP sscore, if2, sscore, score2;\n"
     1351"SUB if1, sscore, score3;\n"
     1352"SUB if2, score3, score4;\n"
     1353"CMP if2, if1, -1.0, if2;\n"
     1354"CMP spred1, if1, spred1, spred4;\n"
     1355"CMP spred1, if2, spred1, spred5;\n"
     1356"ADD spred4, p2, diff0;\n"
     1357"SUB spred5, p2, diff0;\n"
     1358"SUB if1, spred4, spred1;\n"
     1359"SUB if2, spred1, spred5;\n"
     1360"CMP spred1, if1, spred4, spred1;\n"
     1361"CMP spred1, if2, spred5, spred1;\n";
     1362
     1363static const QString yadif[2] = {
     1364yadif_setup +
     1365"TEMP d;\n"
     1366"ALIAS i = current;\n"
     1367"TEX current, tex, texture[1], %1;\n"
     1368"TEX d, tex, texture[2], %1;\n"
     1369"ADD tmp, tex, {0.0, %3, 0.0, 0.0};\n"
     1370"TEX a, tmp, texture[2], %1;\n"
     1371"TEX f, tmp, texture[1], %1;\n"
     1372"TEX k, tmp, texture[0], %1;\n"
     1373"ADD tmp, tex, {0.0, %4, 0.0, 0.0};\n"
     1374"TEX c, tmp, texture[2], %1;\n"
     1375"TEX h, tmp, texture[1], %1;\n"
     1376"SUB tmp, tex, {0.0, %3, 0.0, 0.0};\n"
     1377"TEX b, tmp, texture[2], %1;\n"
     1378"TEX g, tmp, texture[1], %1;\n"
     1379"TEX l, tmp, texture[0], %1;\n"
     1380"SUB tmp, tex, {0.0, %4, 0.0, 0.0};\n"
     1381"TEX e, tmp, texture[2], %1;\n"
     1382"TEX j, tmp, texture[1], %1;\n"
     1383+ yadif_spatial_sample
     1384+ yadif_calc
     1385+ field_calc +
     1386"CMP res, prev, current, spred1;\n"
     1387,
     1388yadif_setup +
     1389"TEMP i;\n"
     1390"ALIAS d = current;\n"
     1391"TEX current, tex, texture[1], %1;\n"
     1392"TEX i, tex, texture[0], %1;\n"
     1393"ADD tmp, tex, {0.0, %3, 0.0, 0.0};\n"
     1394"TEX a, tmp, texture[2], %1;\n"
     1395"TEX f, tmp, texture[1], %1;\n"
     1396"TEX k, tmp, texture[0], %1;\n"
     1397"ADD tmp, tex, {0.0, %4, 0.0, 0.0};\n"
     1398"TEX c, tmp, texture[1], %1;\n"
     1399"TEX h, tmp, texture[0], %1;\n"
     1400"SUB tmp, tex, {0.0, %3, 0.0, 0.0};\n"
     1401"TEX b, tmp, texture[2], %1;\n"
     1402"TEX g, tmp, texture[1], %1;\n"
     1403"TEX l, tmp, texture[0], %1;\n"
     1404"SUB tmp, tex, {0.0, %4, 0.0, 0.0};\n"
     1405"TEX e, tmp, texture[1], %1;\n"
     1406"TEX j, tmp, texture[0], %1;\n"
     1407+ yadif_spatial_sample
     1408+ yadif_calc
     1409+ field_calc +
     1410"CMP res, prev, spred1, current;\n"
     1411};
     1412
    12021413QString OpenGLVideo::GetProgramString(OpenGLFilterType name,
    12031414                                      QString deint, FrameScanType field)
    12041415{
     
    12401451                    deint_bit = kerneldeint[tmp_field];
    12411452                    if (!tmp_field) { need_tex = false; }
    12421453                }
     1454                else if (deint == "openglyadif" ||
     1455                         deint == "opengldoublerateyadif")
     1456                {
     1457                    deint_bit = yadif[tmp_field];
     1458                    need_tex = false;
     1459                }
    12431460                else
    12441461                {
    12451462                    VERBOSE(VB_PLAYBACK, LOC +
     
    12791496    ret.replace("%1", temp);
    12801497
    12811498    float lineHeight = 1.0f;
     1499    float colWidth   = 1.0f;
    12821500
    12831501    if (!textureRects &&
    12841502       (inputTextureSize.height() > 0))
    12851503    {
    12861504        lineHeight /= inputTextureSize.height();
     1505        colWidth   /= inputTextureSize.width();
    12871506    }
    12881507
    12891508    float fieldSize = 1.0f / (lineHeight * 2.0);
     
    12911510    ret.replace("%2", temp.setNum(fieldSize, 'f', 8));
    12921511    ret.replace("%3", temp.setNum(lineHeight, 'f', 8));
    12931512    ret.replace("%4", temp.setNum(lineHeight * 2.0, 'f', 8));
     1513    ret.replace("%5", temp.setNum(colWidth, 'f', 8));
    12941514
    12951515    ret += "END";
    12961516
  • libs/libmythtv/videodisplayprofile.cpp

    diff -ur -X excl mythtv-vid-19/libs/libmythtv/videodisplayprofile.cpp mythtv-vid-20/libs/libmythtv/videodisplayprofile.cpp
    old new  
    689689        return QObject::tr("Linear blend (2x, HW)");
    690690    else if ("opengldoubleratefieldorder" == short_name)
    691691        return QObject::tr("Interlaced (2x, Hw)");
     692    else if ("opengldoublerateyadif" == short_name)
     693        return QObject::tr("Yadif (2x, Hw)");
     694    else if ("openglyadif" == short_name)
     695        return QObject::tr("Yadif (Hw)");
     696
    692697    return "";
    693698}
    694699
     
    12451250        msg = kLinearBlendMsg + " " + kUsingOpenGL;
    12461251    else if (deint == "openglkerneldeint")
    12471252        msg = kKernelMsg + " " + kUsingOpenGL;
     1253    else if (deint == "openglyadif")
     1254        msg = kYadifMsg + " " + kUsingOpenGL;
    12481255    else if (deint == "opengldoubleratelinearblend")
    12491256        msg = kLinearBlendMsg + " " + kUsingOpenGLWorkaround;
    12501257    else if (deint == "opengldoublerateonefield")
     
    12611268        msg = kYadifMsg;
    12621269    else if (deint == "yadifdoubleprocessdeint")
    12631270        msg = kYadifMsg + " " +  kDoubleRateMsg;
     1271    else if (deint == "opengldoublerateyadif")
     1272        msg = kYadifMsg + " " +  kUsingOpenGLWorkaround;
    12641273    else
    12651274        msg = QObject::tr("'%1' has not been documented yet.").arg(deint);
    12661275
     
    14351444"openglkerneldeint"
    14361445"openglonefield"
    14371446"openglbobdeint"
     1447"openglyadif"
    14381448"opengldoubleratelinearblend"
    14391449"opengldoublerateonefield"
    14401450"opengldoubleratekerneldeint"
    14411451"opengldoubleratefieldorder"
     1452"opengldoublerateyadif"
    14421453*/
    14431454
    14441455void VideoDisplayProfile::init_statics(void)
     
    14881499    safe_deint["opengl"] += "opengllinearblend";
    14891500    safe_deint["opengl"] += "openglonefield";
    14901501    safe_deint["opengl"] += "openglkerneldeint";
    1491 
    14921502    safe_deint["opengl"] += "bobdeint";
    14931503    safe_deint["opengl"] += "openglbobdeint";
    14941504    safe_deint["opengl"] += "opengldoubleratelinearblend";
    14951505    safe_deint["opengl"] += "opengldoublerateonefield";
    14961506    safe_deint["opengl"] += "opengldoubleratekerneldeint";
    14971507    safe_deint["opengl"] += "opengldoubleratefieldorder";
     1508    safe_deint["opengl"] += "opengldoublerateyadif";
     1509    safe_deint["opengl"] += "openglyadif";
    14981510
    14991511    safe_osd["xv-blit"]     += "softblend";
    15001512    safe_osd["xvmc-blit"]   += "chromakey";