From 03b9213423dbf38a974677ad021fe8e9fba17881 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Fri, 19 Apr 2013 13:56:00 +0100 Subject: [PATCH] Set the 'widescreen' flag on recordings with an average aspect ratio of 16:9 or 2.21 --- mythtv/libs/libmyth/programinfo.cpp | 36 +++++++++++++++++++++++++++ mythtv/libs/libmyth/programinfo.h | 1 + mythtv/libs/libmythbase/mythversion.h | 2 +- mythtv/libs/libmythtv/tv_rec.cpp | 11 +++++--- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp index b797bb6ab68..968a85ce224 100644 --- a/mythtv/libs/libmyth/programinfo.cpp +++ b/mythtv/libs/libmyth/programinfo.cpp @@ -3864,6 +3864,42 @@ uint ProgramInfo::QueryAverageFrameRate(void) const return load_markup_datum(MARK_VIDEO_RATE, chanid, recstartts); } +MarkTypes ProgramInfo::QueryAverageAspectRatio(void ) const +{ + MSqlQuery query(MSqlQuery::InitCon()); + query.prepare("SELECT recordedmarkup.type " + "FROM recordedmarkup " + "WHERE recordedmarkup.chanid = :CHANID AND " + " recordedmarkup.starttime = :STARTTIME AND " + " recordedmarkup.type >= :ASPECTSTART AND " + " recordedmarkup.type <= :ASPECTEND " + "GROUP BY recordedmarkup.type " + "ORDER BY SUM( ( SELECT IFNULL(rm.mark, recordedmarkup.mark)" + " FROM recordedmarkup AS rm " + " WHERE rm.chanid = recordedmarkup.chanid AND " + " rm.starttime = recordedmarkup.starttime AND " + " rm.type = recordedmarkup.type AND " + " rm.mark > recordedmarkup.mark " + " ORDER BY rm.mark ASC LIMIT 1 " + " ) - recordedmarkup.mark " + " ) DESC " + "LIMIT 1"); + query.bindValue(":CHANID", chanid); + query.bindValue(":STARTTIME", recstartts); + query.bindValue(":ASPECTSTART", MARK_ASPECT_4_3); // 11 + query.bindValue(":ASPECTEND", MARK_ASPECT_CUSTOM); // 14 + + if (!query.exec()) + { + MythDB::DBError("QueryAverageAspectRatio", query); + return MARK_UNSET; + } + + query.next(); + + return static_cast(query.value(0).toInt()); +} + /** \brief If present in recording this loads total duration of the * main video stream from database's stream markup table. */ diff --git a/mythtv/libs/libmyth/programinfo.h b/mythtv/libs/libmyth/programinfo.h index f81c21d524b..6e8e26375db 100644 --- a/mythtv/libs/libmyth/programinfo.h +++ b/mythtv/libs/libmyth/programinfo.h @@ -543,6 +543,7 @@ class MPUBLIC ProgramInfo uint QueryAverageWidth(void) const; uint QueryAverageHeight(void) const; uint QueryAverageFrameRate(void) const; + MarkTypes QueryAverageAspectRatio(void) const; int64_t QueryTotalDuration(void) const; int64_t QueryTotalFrames(void) const; QString QueryRecordingGroup(void) const; diff --git a/mythtv/libs/libmythbase/mythversion.h b/mythtv/libs/libmythbase/mythversion.h index f50d2464641..9a21594c42c 100644 --- a/mythtv/libs/libmythbase/mythversion.h +++ b/mythtv/libs/libmythbase/mythversion.h @@ -12,7 +12,7 @@ /// Update this whenever the plug-in ABI changes. /// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and /// libmythui class methods in exported headers. -#define MYTH_BINARY_VERSION "0.27.20130413-1" +#define MYTH_BINARY_VERSION "0.27.20130419-1" /** \brief Increment this whenever the MythTV network protocol changes. * diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp index 1e3863b4028..6eb57659f3b 100644 --- a/mythtv/libs/libmythtv/tv_rec.cpp +++ b/mythtv/libs/libmythtv/tv_rec.cpp @@ -22,15 +22,17 @@ #include "dtvrecorder.h" #include "livetvchain.h" #include "programinfo.h" +#include "mythlogging.h" +#include "channelbase.h" #include "atsctables.h" #include "dtvchannel.h" #include "eitscanner.h" #include "mythconfig.h" #include "remoteutil.h" #include "ringbuffer.h" -#include "mythlogging.h" #include "v4lchannel.h" #include "dialogbox.h" +#include "cardutil.h" #include "jobqueue.h" #include "mythdb.h" #include "tv_rec.h" @@ -896,11 +898,14 @@ void TVRec::FinishedRecording(RecordingInfo *curRec, RecordingQuality *recq) } // Get the width and set the videoprops + MarkTypes aspectRatio = curRec->QueryAverageAspectRatio(); uint avg_height = curRec->QueryAverageHeight(); curRec->SaveVideoProperties( - VID_1080 | VID_720 | VID_DAMAGED, + VID_1080 | VID_720 | VID_DAMAGED | VID_WIDESCREEN, ((avg_height > 1000) ? VID_1080 : ((avg_height > 700) ? VID_720 : 0)) | - ((is_good) ? 0 : VID_DAMAGED)); + ((is_good) ? 0 : VID_DAMAGED) | + ((aspectRatio == MARK_ASPECT_16_9) || + (aspectRatio == MARK_ASPECT_2_21_1)) ? VID_WIDESCREEN : 0); // Make sure really short recordings have positive run time. if (curRec->GetRecordingEndTime() <= curRec->GetRecordingStartTime())