Skip to content

Commit

Permalink
Set the 'widescreen' flag on recordings with an average aspect ratio …
Browse files Browse the repository at this point in the history
…of 16:9 or 2.21
  • Loading branch information
stuartm committed Apr 19, 2013
1 parent 57dc35f commit 03b9213
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
36 changes: 36 additions & 0 deletions mythtv/libs/libmyth/programinfo.cpp
Expand Up @@ -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<MarkTypes>(query.value(0).toInt());
}

/** \brief If present in recording this loads total duration of the
* main video stream from database's stream markup table.
*/
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmyth/programinfo.h
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -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.
*
Expand Down
11 changes: 8 additions & 3 deletions mythtv/libs/libmythtv/tv_rec.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 03b9213

Please sign in to comment.