[-]
[+]
|
Changed |
_service:tar_git:droid-camres.spec
|
|
[-]
[+]
|
Changed |
_service:tar_git:droid-camres-1.2.0.tar.bz2/jolla-camera-hw-template.txt
^
|
@@ -32,6 +32,7 @@
imageResolution='@PRIVIDEORES@'
videoResolution='@PRIVIDEORES@'
viewfinderResolution='@PRIVF169RES@'
+videoFrameRate=@PRIVIDEOFPS@
isoValues=[0, 100, 200, 400]
whiteBalanceValues=[0, 3, 2, 6, 5]
focusDistanceValues=[4, 16]
@@ -43,6 +44,7 @@
imageResolution='@SECVIDEORES@'
videoResolution='@SECVIDEORES@'
viewfinderResolution='@SECVF169RES@'
+videoFrameRate=@SECVIDEOFPS@
isoValues=[0, 100, 200, 400]
whiteBalanceValues=[0, 3, 2, 6, 5]
focusDistanceValues=[4]
|
[-]
[+]
|
Changed |
_service:tar_git:droid-camres-1.2.0.tar.bz2/src/camres.cpp
^
|
@@ -169,6 +169,7 @@
const GstStructure *s = gst_caps_get_structure(caps, x);
const GValue *width = gst_structure_get_value(s, "width");
const GValue *height = gst_structure_get_value(s, "height");
+ const GValue *fps = gst_structure_get_value(s, "framerate");
if (!width || !height)
{
@@ -177,51 +178,43 @@
bool width_is_list = GST_VALUE_HOLDS_LIST(width) ? true : false;
bool height_is_list = GST_VALUE_HOLDS_LIST(height) ? true : false;
+ bool fps_is_list = GST_VALUE_HOLDS_LIST(fps) ? true : false;
- if (!width_is_list && !height_is_list)
+ for (guint wc = 0; wc == 0 || (width_is_list && wc < gst_value_list_get_size(width)); wc++)
{
- tmp = QString("%1x%2").arg(g_value_get_int(width)).arg(g_value_get_int(height));
- if (!res.contains(tmp))
- res.append(tmp);
- }
- else if (width_is_list && height_is_list)
- {
- guint ws = gst_value_list_get_size(width);
- guint hs = gst_value_list_get_size(width);
- for (guint wc = 0; wc < ws; wc++)
+ int w = g_value_get_int(width_is_list?gst_value_list_get_value(width, wc): width);
+ for (guint hc = 0; hc == 0 || (height_is_list && hc < gst_value_list_get_size(height)); hc++)
{
- int w = g_value_get_int(gst_value_list_get_value(width, wc));
- for (guint hc = 0; hc < hs; hc++)
+ int h = g_value_get_int(height_is_list?gst_value_list_get_value(height, hc): height);
+ for (guint fc = 0; fc == 0 || (fps_is_list && fc < gst_value_list_get_size(fps)); fc++)
{
- int h = g_value_get_int(gst_value_list_get_value(height, hc));
- tmp = QString("%1x%2").arg(w).arg(h);
+ const GValue *fps_val = fps_is_list?gst_value_list_get_value(fps, fc): fps;
+ if (GST_VALUE_HOLDS_FRACTION(fps_val))
+ {
+ tmp = QString("%1x%2@%3/%4").arg(w).arg(h)
+ .arg(gst_value_get_fraction_numerator(fps_val))
+ .arg(gst_value_get_fraction_denominator(fps_val));
+ }
+ else if (GST_VALUE_HOLDS_FRACTION_RANGE(fps_val))
+ {
+ const GValue *fps_min = gst_value_get_fraction_range_min(fps_val);
+ const GValue *fps_max = gst_value_get_fraction_range_max(fps_val);
+ tmp = QString("%1x%2@%3/%4-%5/%6").arg(w).arg(h)
+ .arg(gst_value_get_fraction_numerator(fps_min))
+ .arg(gst_value_get_fraction_denominator(fps_min))
+ .arg(gst_value_get_fraction_numerator(fps_max))
+ .arg(gst_value_get_fraction_denominator(fps_max));
+ }
+ else
+ {
+ fprintf(stderr, "Camres error: Unknown framerate type\n");
+ tmp = QString("%1x%2").arg(w).arg(h);
+ }
if (!res.contains(tmp))
res.append(tmp);
}
}
}
- else if (width_is_list)
- {
- int h = g_value_get_int(height);
- for (guint i = 0; i < gst_value_list_get_size(width); i++)
- {
- int w = g_value_get_int(gst_value_list_get_value(width, i));
- tmp = QString("%1x%2").arg(w).arg(h);
- if (!res.contains(tmp))
- res.append(tmp);
- }
- }
- else if (height_is_list)
- {
- int w = g_value_get_int(width);
- for (guint i = 0; i < gst_value_list_get_size(height); i++)
- {
- int h = g_value_get_int(gst_value_list_get_value(height, i));
- tmp = QString("%1x%2").arg(w).arg(h);
- if (!res.contains(tmp))
- res.append(tmp);
- }
- }
}
return res;
@@ -232,11 +225,13 @@
static QMap<float, QString> ratios;
int width, height;
- width = size.split("x").at(0).toInt();
- height = size.split("x").at(1).toInt();
+ width = size.split(QRegExp("[x@]")).at(0).toInt();
+ height = size.split(QRegExp("[x@]")).at(1).toInt();
if (ratios.isEmpty())
{
+ ratios[0.7] = "3:4";
+ ratios[0.8] = "4:5";
ratios[1.0] = "1:1";
ratios[1.2] = "5:4";
ratios[1.3] = "4:3";
@@ -274,8 +269,8 @@
{
for (m=0 ; m<resolutions.at(j).second.size(); m++)
{
- width = resolutions.at(j).second.at(m).split("x").at(0).toInt();
- height = resolutions.at(j).second.at(m).split("x").at(1).toInt();
+ width = resolutions.at(j).second.at(m).split(QRegExp("[x@]")).at(0).toInt();
+ height = resolutions.at(j).second.at(m).split(QRegExp("[x@]")).at(1).toInt();
if (qMin(screenGeometry.height(), screenGeometry.width()) >=
qMin(width, height) &&
@@ -284,7 +279,7 @@
{
if (Camres::aspectRatioForResolution(resolutions.at(j).second.at(m)).compare(Camres::aspectRatioForResolution(size)) == 0)
{
- return resolutions.at(j).second.at(m);
+ return resolutions.at(j).second.at(m).split('@').first();
}
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:droid-camres-1.2.0.tar.bz2/src/outputgen.cpp
^
|
@@ -92,13 +92,16 @@
QStringList res = resolutions.at(i).at(j).second;
*ts << S(8) << "\"" << resolutions.at(i).at(j).first.split("-").first().toLower() << "\":" << endl << S(8) << "[" << endl;
-
+ QStringList repeatCheck;
for (m=0 ; m<res.size() ; m++)
{
- *ts << S(12) << "{ \"resolution\": \"" << res.at(m) << "\", "
- << "\"viewFinder\": \"" << Camres::findBestViewFinderForResolution(res.at(m), resolutions.at(i), screenGeometry) << "\", "
- << "\"aspectRatio\": \"" << Camres::aspectRatioForResolution(res.at(m)) << "\" }"
+ QString thisRes = res.at(m).split('@').first();
+ if (repeatCheck.contains(thisRes)) continue;
+ *ts << S(12) << "{ \"resolution\": \"" << thisRes << "\", "
+ << "\"viewFinder\": \"" << Camres::findBestViewFinderForResolution(thisRes, resolutions.at(i), screenGeometry) << "\", "
+ << "\"aspectRatio\": \"" << Camres::aspectRatioForResolution(thisRes) << "\" }"
<< ((m == res.size()-1) ? "" : ",") << endl;
+ repeatCheck << thisRes;
}
*ts << S(8) << "]";
@@ -165,49 +168,75 @@
QString camKey = cameras.at(i).first.left(3).toUpper();
for (j=0 ; j<resolutions.at(i).size() ; j++)
{
+ QString resType = resolutions.at(i).at(j).first;
QStringList res = resolutions.at(i).at(j).second;
+ QString prefix;
+ bool isVideo = false;
- if (resolutions.at(i).at(j).first.startsWith("viewfinder"))
+ if (resType.startsWith("viewfinder"))
{
- for (m=0 ; m<res.size() ; m++)
- {
- if (qMin(screenGeometry.height(), screenGeometry.width()) >=
- qMin(res.at(m).split("x").at(0).toInt(), res.at(m).split("x").at(1).toInt()) &&
- qMax(screenGeometry.height(), screenGeometry.width()) >=
- qMax(res.at(m).split("x").at(0).toInt(), res.at(m).split("x").at(1).toInt()))
- {
- if (Camres::aspectRatioForResolution(res.at(m)).compare("4:3") == 0 && map.value("@" + camKey + "VF43RES@").isEmpty())
- {
- map.insert("@" + camKey + "VF43RES@", res.at(m));
- }
- else if (Camres::aspectRatioForResolution(res.at(m)).compare("16:9") == 0 && map.value("@" + camKey + "VF169RES@").isEmpty())
- {
- map.insert("@" + camKey + "VF169RES@", res.at(m));
- }
- }
- }
+ prefix = "@" + camKey + "VF";
+ }
+ else if (resType.startsWith("image"))
+ {
+ prefix = "@" + camKey + "IMAGE";
}
- else if (resolutions.at(i).at(j).first.startsWith("image"))
+ else if (resType.startsWith("video"))
{
- for (m=0 ; m<res.size() ; m++)
+ prefix = "@" + camKey + "VIDEO";
+ isVideo = true;
+ }
+ else continue; // unknown resolution type
+
+ QMap<QString, int> sizes;
+ int topFramerate = 0;
+ for (m=0 ; m<res.size() ; m++)
+ {
+ QList<QString> resBits = res.at(m).split(QRegExp("[x@\\-\\/]"));
+ int size = resBits.at(0).toInt() * resBits.at(1).toInt();
+ if (!resType.startsWith("viewfinder") || (
+ qMin(screenGeometry.height(), screenGeometry.width()) >=
+ qMin(resBits.at(0).toInt(), resBits.at(1).toInt()) &&
+ qMax(screenGeometry.height(), screenGeometry.width()) >=
+ qMax(resBits.at(0).toInt(), resBits.at(1).toInt())))
{
- if (Camres::aspectRatioForResolution(res.at(m)).compare("4:3") == 0 && map.value("@" + camKey + "IMAGE43RES@").isEmpty())
+ QString aspect = "";
+ if (Camres::aspectRatioForResolution(res.at(m)).compare("4:3") == 0)
{
- map.insert("@" + camKey + "IMAGE43RES@", res.at(m));
+ if (isVideo) continue;
+ aspect = "43";
}
- else if (Camres::aspectRatioForResolution(res.at(m)).compare("16:9") == 0 && map.value("@" + camKey + "IMAGE169RES@").isEmpty())
+ else if (Camres::aspectRatioForResolution(res.at(m)).compare("16:9") == 0)
{
- map.insert("@" + camKey + "IMAGE169RES@", res.at(m));
+ if (!isVideo) aspect = "169";
}
- }
- }
- else if (resolutions.at(i).at(j).first.startsWith("video"))
- {
- for (m=0 ; m<res.size() ; m++)
- {
- if (Camres::aspectRatioForResolution(res.at(m)).compare("16:9") == 0 && map.value("@" + camKey + "VIDEORES@").isEmpty())
+ else continue;
+ int framerate = 0;
+ if (isVideo)
{
- map.insert("@" + camKey + "VIDEORES@", res.at(m));
+ switch (resBits.size())
+ {
+ case 4:
+ framerate = resBits.at(2).toInt()/resBits.at(3).toInt();
+ break;
+ case 6: // take the top of the range
+ framerate = resBits.at(4).toInt()/resBits.at(5).toInt();
+ break;
+ default:
+ // video framerate without fps. skip
+ continue;
+ }
+ }
+ QString key = prefix + aspect + "RES@";
+ if ((map.value(key).isEmpty() || size >= sizes.value(key)) && framerate >= topFramerate)
+ {
+ map.insert(key, resBits.at(0)+"x"+resBits.at(1));
+ sizes.insert(key, size);
+ if (isVideo)
+ {
+ map.insert(prefix+"FPS@", QString::number(framerate));
+ topFramerate = framerate;
+ }
}
}
}
|