Ticket #10322: 0001-libmythtv-Improved-letterbox-detection.patch

File 0001-libmythtv-Improved-letterbox-detection.patch, 22.8 KB (added by Lawrence Rust <lvr@…>, 7 years ago)
  • mythtv/libs/libmythtv/DetectLetterbox.cpp

    From 65e1627c975ce0768a331c914f8af2fbd30703ef Mon Sep 17 00:00:00 2001
    From: Lawrence Rust <lvr@softsystem.co.uk>
    Date: Sun, 29 Jan 2012 10:20:39 +0100
    Subject: [PATCH] libmythtv: Improved letterbox detection
    
    Add auto detection and fill of letterboxed widescreen movies.
    Reduced rate of frame scanning to reduce CPU load.
    Improve optimisation opportunities.
    
    Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
    ---
     mythtv/libs/libmythtv/DetectLetterbox.cpp |  331 ++++++++++++++++-------------
     mythtv/libs/libmythtv/DetectLetterbox.h   |   16 +-
     mythtv/libs/libmythtv/mhi.cpp             |    2 +-
     mythtv/libs/libmythtv/tv_play.cpp         |    2 +-
     4 files changed, 192 insertions(+), 159 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/DetectLetterbox.cpp b/mythtv/libs/libmythtv/DetectLetterbox.cpp
    index 58cf2c1..6bacc79 100644
    a b  
    11// -*- Mode: c++ -*-
     2#include <algorithm>
     3using std::min;
     4using std::max;
     5
     6#include <QMutexLocker>
    27
    38// MythTV headers
    49#include "DetectLetterbox.h"
     
    611#include "videoouttypes.h"
    712#include "mythcorecontext.h"
    813
    9 DetectLetterbox::DetectLetterbox(MythPlayer* const player)
     14DetectLetterbox::DetectLetterbox(MythPlayer *player)
     15:   isDetectLetterbox(false),
     16    firstFrameChecked(-1),
     17    detectLetterboxDefaultMode(kAdjustFill_Off),
     18    detectLetterboxDetectedMode(kAdjustFill_Toggle),
     19    detectLetterboxSwitchFrame(0),
     20    detectLetterboxPossibleHalfFrame(-1),
     21    detectLetterboxPossibleFullFrame(-1),
     22    detectLetterboxConsecutiveCounter(0),
     23    m_player(player),
     24    detectLetterboxLimit(gCoreContext->GetNumSetting("DetectLeterboxLimit", 75))
    1025{
    1126    int dbAdjustFill = gCoreContext->GetNumSetting("AdjustFill", 0);
    1227    isDetectLetterbox = dbAdjustFill >= kAdjustFill_AutoDetect_DefaultOff;
    13     firstFrameChecked = 0;
    1428    detectLetterboxDefaultMode = (AdjustFillMode) max((int) kAdjustFill_Off,
    1529                                 dbAdjustFill - kAdjustFill_AutoDetect_DefaultOff);
    16     detectLetterboxSwitchFrame = -1;
    17     detectLetterboxPossibleHalfFrame = -1;
    18     detectLetterboxPossibleFullFrame = -1;
    19     detectLetterboxConsecutiveCounter = 0;
    20     detectLetterboxDetectedMode = player->GetAdjustFill();
    21     detectLetterboxLimit = gCoreContext->GetNumSetting("DetectLeterboxLimit", 75);
    22     m_player = player;
    2330}
    2431
    2532DetectLetterbox::~DetectLetterbox()
    DetectLetterbox::~DetectLetterbox() 
    3239 *  If a change is detected detectLetterboxSwitchFrame and
    3340 *  detectLetterboxDetectedMode are set.
    3441 */
     42const int CONSECUTIVE_COUNTS = 4;
    3543void DetectLetterbox::Detect(VideoFrame *frame)
    3644{
    37     unsigned char *buf = frame->buf;
    38     int *pitches = frame->pitches;
    39     int *offsets = frame->offsets;
    40     const int width = frame->width;
    41     const int height = frame->height;
    42     const long long frameNumber = frame->frameNumber;
    43     const int NUMBER_OF_DETECTION_LINES = 3; // How many lines are we looking at
     45    const int NUMBER_OF_DETECTION_LINES = 11; // How many lines are we looking at
    4446    const int THRESHOLD = 5; // Y component has to not vary more than this in the bars
    4547    const int HORIZONTAL_THRESHOLD = 4; // How tolerant are we that the image has horizontal edges
    46 
    47     // If the black bars is larger than this limit we switch to Half or Full Mode
    48     //    const int fullLimit = (int) (((height - width * 9 / 16) / 2) * detectLetterboxLimit / 100);
    49     //    const int halfLimit = (int) (((height - width * 9 / 14) / 2) * detectLetterboxLimit / 100);
    50     // If the black bars is larger than this limit we switch to Half or Full Mode
    51     const int fullLimit = (int) ((height * (1 - m_player->GetVideoAspect() * 9 / 16) / 2) * detectLetterboxLimit / 100);
    52     const int halfLimit = (int) ((height * (1 - m_player->GetVideoAspect() * 9 / 14) / 2) * detectLetterboxLimit / 100);
    53 
    54     const int xPos[] = {width / 4, width / 2, width * 3 / 4};    // Lines to scan for black letterbox edge
    55     int topHits = 0, bottomHits = 0, minTop = 0, minBottom = 0, maxTop = 0, maxBottom = 0;
    56     int topHit[] = {0, 0, 0}, bottomHit[] = {0, 0, 0};
     48    const int VMARGIN = 5; // skip first lines in case of noise in the top/bottom edges
    5749
    5850    if (!GetDetectLetterbox())
    5951        return;
    void DetectLetterbox::Detect(VideoFrame *frame) 
    6153    if (!m_player->GetVideoOutput())
    6254        return;
    6355
     56    const long long frameNumber = frame->frameNumber;
     57    if (frameNumber < 0)
     58    {
     59        LOG(VB_PLAYBACK, LOG_INFO,
     60                QString("Detect Letterbox: Strange frame number %1")
     61                .arg(frameNumber));
     62        return;
     63    }
     64
     65    // If the frame format has been detected then check less frequently
     66    if (detectLetterboxSwitchFrame == -1 && (frameNumber % 16) > 0)
     67        return;
     68
    6469    switch (frame->codec) {
    6570        case FMT_YV12:
    66             if (!firstFrameChecked)
     71            if (firstFrameChecked == -1)
    6772            {
    6873                firstFrameChecked = frameNumber;
    6974                LOG(VB_PLAYBACK, LOG_INFO,
    void DetectLetterbox::Detect(VideoFrame *frame) 
    7176            }
    7277            break;
    7378        default:
    74             LOG(VB_PLAYBACK, LOG_INFO,
    75                 QString("Detect Letterbox: The source is not "
     79            if (firstFrameChecked == -1)
     80            {
     81                firstFrameChecked = frameNumber;
     82                LOG(VB_PLAYBACK, LOG_INFO,
     83                     QString("Detect Letterbox: The source is not "
    7684                        "a supported frame format (was %1)").arg(frame->codec));
    77             isDetectLetterbox = false;
     85            }
    7886            return;
    7987    }
    8088
    81     if (frameNumber < 0)
    82     {
    83         LOG(VB_PLAYBACK, LOG_INFO,
    84              QString("Detect Letterbox: Strange frame number %1")
    85                  .arg(frameNumber));
    86         return;
    87     }
    8889
    89     if (m_player->GetVideoAspect() > 1.5)
     90    // If the OSD interactive (MHEG) window is visible then always show fullframe
     91    // NB this benefits from a mod to MHIContext::UpdateOSD to make the
     92    // interactive window invisible if there's nothing on screen
     93    if (m_player->itvVisible)
    9094    {
    91         if (detectLetterboxDetectedMode != detectLetterboxDefaultMode)
    92         {
    93             LOG(VB_PLAYBACK, LOG_INFO,
    94                 QString("Detect Letterbox: The source is "
    95                         "already in widescreen (aspect: %1)")
    96                     .arg(m_player->GetVideoAspect()));
    97             detectLetterboxLock.lock();
    98             detectLetterboxConsecutiveCounter = 0;
    99             detectLetterboxDetectedMode = detectLetterboxDefaultMode;
    100             detectLetterboxSwitchFrame = frameNumber;
    101             detectLetterboxLock.unlock();
    102         }
    103         else
     95        m_player->LockOSD();
     96        OSD *osd = m_player->GetOSD();
     97        bool vis = osd && osd->IsWindowVisible(OSD_WIN_INTERACT);
     98        m_player->UnlockOSD();
     99
     100        if (vis)
    104101        {
    105             detectLetterboxConsecutiveCounter++;
     102            if (detectLetterboxDetectedMode != kAdjustFill_Off)
     103            {
     104                VERBOSE(VB_PLAYBACK, "Detect Letterbox: OSD forcing full frame");
     105                detectLetterboxConsecutiveCounter = CONSECUTIVE_COUNTS;
     106                detectLetterboxDetectedMode = kAdjustFill_Off;
     107                detectLetterboxSwitchFrame = frameNumber;
     108            }
     109            else
     110            {
     111                detectLetterboxConsecutiveCounter++;
     112            }
     113            return;
    106114        }
    107         LOG(VB_PLAYBACK, LOG_INFO,
    108             QString("Detect Letterbox: The source is already "
    109                     "in widescreen (aspect: %1)")
    110                 .arg(m_player->GetVideoAspect()));
    111         isDetectLetterbox = false;
    112         return;
    113115    }
    114116
     117    unsigned char * const buf = frame->buf;
     118    int * const pitches = frame->pitches;
     119    int * const offsets = frame->offsets;
     120    const int width = frame->width;
     121    const int height = frame->height;
     122    const double aspect = m_player->GetVideoAspect();
     123    const bool widescreen = aspect > 1.5;
     124
     125    // Lines to scan for black letterbox edge
     126    int xPos[NUMBER_OF_DETECTION_LINES];
     127    for (int i = 0; i < NUMBER_OF_DETECTION_LINES; ++i)
     128        xPos[i] =  (width * (i+1)) / (NUMBER_OF_DETECTION_LINES + 1);
     129
    115130    // Establish the level of light in the edge
    116131    int averageY = 0;
    117132    for (int detectionLine = 0;
    118133         detectionLine < NUMBER_OF_DETECTION_LINES;
    119134         detectionLine++)
    120135    {
    121         averageY += buf[offsets[0] + 5 * pitches[0]            + xPos[detectionLine]];
    122         averageY += buf[offsets[0] + (height - 6) * pitches[0] + xPos[detectionLine]];
     136        averageY += buf[offsets[0] + VMARGIN * pitches[0]                + xPos[detectionLine]];
     137        averageY += buf[offsets[0] + (height - VMARGIN - 1) * pitches[0] + xPos[detectionLine]];
    123138    }
    124139    averageY /= NUMBER_OF_DETECTION_LINES * 2;
    125     if (averageY > 64) // To bright to be a letterbox border
    126         averageY = 0;
     140    if (averageY > 40) // Too bright to be a letterbox border
     141        averageY = 16;
     142    if (averageY < THRESHOLD)
     143        averageY = THRESHOLD;
     144
     145    int topHit[NUMBER_OF_DETECTION_LINES] = {0};
     146    int bottomHit[NUMBER_OF_DETECTION_LINES] = {0};
    127147
    128148    // Scan the detection lines
    129     for (int y = 5; y < height / 4; y++) // skip first pixels incase of noise in the edge
     149    int topHits = 0, bottomHits = 0;
     150    int minTop = 0, minBottom = 0, maxTop = 0, maxBottom = 0;
     151    for (int y = VMARGIN; y < height / 4; y++)
    130152    {
    131153        for (int detectionLine = 0;
    132154             detectionLine < NUMBER_OF_DETECTION_LINES;
    void DetectLetterbox::Detect(VideoFrame *frame) 
    169191            break;
    170192        }
    171193    }
    172     if (topHits != NUMBER_OF_DETECTION_LINES) maxTop = height / 4;
    173     if (!minTop) minTop = height / 4;
    174     if (bottomHits != NUMBER_OF_DETECTION_LINES) maxBottom = height / 4;
    175     if (!minBottom) minBottom = height / 4;
    176194
    177     bool horizontal = ((minTop && maxTop - minTop < HORIZONTAL_THRESHOLD) &&
    178                        (minBottom && maxBottom - minBottom < HORIZONTAL_THRESHOLD));
     195    // Check for black frame
     196    if ((minTop == 0 && maxTop == 0) || (minBottom == 0 && maxBottom == 0))
     197        return;
     198
     199    // If the black bars are larger than this limit we switch to Half or Full Mode
     200    int fullLimit, halfLimit;
     201    if (widescreen)
     202    {
     203        const double kZoomHalf = 7.0 / 6, kZoomFull = 4.0 / 3;
     204        fullLimit = (int) ((height * (1 - 1 / (kZoomFull * kZoomFull)) * 0.5) * (detectLetterboxLimit / 100.0));
     205        halfLimit = (int) ((height * (1 - 1 / (kZoomHalf * kZoomHalf)) * 0.5) * (detectLetterboxLimit / 100.0));
     206    }
     207    else
     208    {
     209        fullLimit = (int) ((height * (1 - aspect * (9.0 / 16)) * 0.5) * (detectLetterboxLimit / 100.0));
     210        halfLimit = (int) ((height * (1 - aspect * (9.0 / 14)) * 0.5) * (detectLetterboxLimit / 100.0));
     211    }
     212
     213    QMutexLocker lock(&detectLetterboxLock);
    179214
    180215    if (detectLetterboxSwitchFrame > frameNumber) // user is reversing
    181216    {
    182         detectLetterboxLock.lock();
    183217        detectLetterboxDetectedMode = m_player->GetAdjustFill();
    184218        detectLetterboxSwitchFrame = -1;
    185219        detectLetterboxPossibleHalfFrame = -1;
    186220        detectLetterboxPossibleFullFrame = -1;
    187         detectLetterboxLock.unlock();
    188221    }
    189222
    190223    if (minTop < halfLimit || minBottom < halfLimit)
    191224        detectLetterboxPossibleHalfFrame = -1;
    192     if (minTop < fullLimit || minBottom < fullLimit)
    193         detectLetterboxPossibleFullFrame = -1;
    194 
    195     if (detectLetterboxDetectedMode != kAdjustFill_Full)
     225    else if (detectLetterboxPossibleHalfFrame == -1)
    196226    {
    197         if (detectLetterboxPossibleHalfFrame == -1 &&
    198             minTop > halfLimit && minBottom > halfLimit) {
     227        if (detectLetterboxDetectedMode != kAdjustFill_Full)
    199228            detectLetterboxPossibleHalfFrame = frameNumber;
    200         }
    201     }
    202     else
    203     {
    204         if (detectLetterboxPossibleHalfFrame == -1 &&
    205             minTop < fullLimit && minBottom < fullLimit) {
     229        else if (minTop < fullLimit && minBottom < fullLimit)
    206230            detectLetterboxPossibleHalfFrame = frameNumber;
    207         }
    208231    }
    209     if (detectLetterboxPossibleFullFrame == -1 &&
    210         minTop > fullLimit && minBottom > fullLimit)
     232
     233    if (minTop < fullLimit || minBottom < fullLimit)
     234        detectLetterboxPossibleFullFrame = -1;
     235    else if (detectLetterboxPossibleFullFrame == -1)
    211236        detectLetterboxPossibleFullFrame = frameNumber;
    212237
    213     if ( maxTop < halfLimit || maxBottom < halfLimit) // Not to restrictive when switching to off
     238    bool flatTop = (maxTop - minTop) < HORIZONTAL_THRESHOLD;
     239    bool flatBot = (maxBottom - minBottom) < HORIZONTAL_THRESHOLD;
     240
     241    if (flatTop && minTop >= fullLimit &&
     242        flatBot && minBottom >= fullLimit)
    214243    {
    215         // No Letterbox
    216         if (detectLetterboxDetectedMode != detectLetterboxDefaultMode)
     244        // Letterbox
     245        detectLetterboxPossibleHalfFrame = -1;
     246        if (detectLetterboxDetectedMode != kAdjustFill_Full)
    217247        {
    218             LOG(VB_PLAYBACK, LOG_INFO,
    219                 QString("Detect Letterbox: Non Letterbox "
    220                         "detected on line: %1 (limit: %2)")
    221                     .arg(min(maxTop, maxBottom)).arg(halfLimit));
    222             detectLetterboxLock.lock();
     248            LOG(VB_PLAYBACK, LOG_INFO, QString("Detect Letterbox: Letterbox "
     249                    "detected on line:%1 (limit:%2..%3) frame:%4 Y:%5")
     250                    .arg(min(minTop,minBottom)).arg(halfLimit).arg(fullLimit)
     251                    .arg(detectLetterboxPossibleFullFrame).arg(averageY));
    223252            detectLetterboxConsecutiveCounter = 0;
    224             detectLetterboxDetectedMode = detectLetterboxDefaultMode;
    225             detectLetterboxSwitchFrame = frameNumber;
    226             detectLetterboxLock.unlock();
     253            detectLetterboxDetectedMode = kAdjustFill_Full;
     254            detectLetterboxSwitchFrame = detectLetterboxPossibleFullFrame;
    227255        }
    228256        else
    229257        {
    230258            detectLetterboxConsecutiveCounter++;
    231259        }
    232260    }
    233     else if (horizontal && minTop > halfLimit && minBottom > halfLimit &&
    234              maxTop < fullLimit && maxBottom < fullLimit)
     261    else if ( (flatTop || flatBot) &&
     262        minTop >= halfLimit &&
     263        minBottom >= halfLimit)
    235264    {
    236265        // Letterbox (with narrow bars)
    237         if (detectLetterboxDetectedMode != kAdjustFill_Half)
     266        detectLetterboxPossibleFullFrame = -1;
     267        if (detectLetterboxPossibleHalfFrame == -1)
     268            detectLetterboxConsecutiveCounter = 0;
     269        else if (detectLetterboxDetectedMode != kAdjustFill_Half)
    238270        {
    239             LOG(VB_PLAYBACK, LOG_INFO,
    240                 QString("Detect Letterbox: Narrow Letterbox "
    241                         "detected on line: %1 (limit: %2) frame: %3")
    242                     .arg(minTop).arg(halfLimit)
    243                     .arg(detectLetterboxPossibleHalfFrame));
    244             detectLetterboxLock.lock();
     271            LOG(VB_PLAYBACK, LOG_INFO, QString("Detect Letterbox: Narrow Letterbox "
     272                    "detected on line:%1 (limit:%2..%3) frame:%4 Y:%5")
     273                    .arg(min(minTop,minBottom)).arg(halfLimit).arg(fullLimit)
     274                    .arg(detectLetterboxPossibleHalfFrame).arg(averageY));
    245275            detectLetterboxConsecutiveCounter = 0;
    246             if (detectLetterboxDetectedMode == kAdjustFill_Full &&
    247                 detectLetterboxSwitchFrame != -1) {
    248                 // Do not change switch frame if switch to Full mode has not been executed yet
    249             }
    250             else
     276            // Do not change switch frame if switch to Full mode has not been executed yet
     277            if (detectLetterboxDetectedMode != kAdjustFill_Full ||
     278                detectLetterboxSwitchFrame == -1)
     279            {
    251280                detectLetterboxSwitchFrame = detectLetterboxPossibleHalfFrame;
     281            }
    252282            detectLetterboxDetectedMode = kAdjustFill_Half;
    253             detectLetterboxLock.unlock();
    254283        }
    255284        else
    256285        {
    257286            detectLetterboxConsecutiveCounter++;
    258287        }
    259288    }
    260     else if (horizontal && minTop > fullLimit && minBottom > fullLimit)
     289    // Not too restrictive when switching to off
     290    else if ( (minTop > 0 && minTop < halfLimit) ||
     291        (minBottom > 0 && minBottom < halfLimit) )
    261292    {
    262         // Letterbox
     293        // No Letterbox
    263294        detectLetterboxPossibleHalfFrame = -1;
    264         if (detectLetterboxDetectedMode != kAdjustFill_Full)
     295        detectLetterboxPossibleFullFrame = -1;
     296        const AdjustFillMode mode = widescreen  ?
     297            kAdjustFill_Off : detectLetterboxDefaultMode;
     298        if (detectLetterboxDetectedMode != mode)
    265299        {
    266             LOG(VB_PLAYBACK, LOG_INFO,
    267                 QString("Detect Letterbox: Detected Letterbox "
    268                         "on line: %1 (limit: %2) frame: %3").arg(minTop)
    269                     .arg(fullLimit).arg(detectLetterboxPossibleFullFrame));
    270             detectLetterboxLock.lock();
     300            LOG(VB_PLAYBACK, LOG_INFO, QString("Detect Letterbox: Full frame %1 "
     301                    "detected on line:%2 (limit:%3..%4) Y:%5")
     302                    .arg(widescreen ? "WS" : "4:3")
     303                    .arg(min(minTop, minBottom)).arg(halfLimit).arg(fullLimit).arg(averageY));
    271304            detectLetterboxConsecutiveCounter = 0;
    272             detectLetterboxDetectedMode = kAdjustFill_Full;
    273             detectLetterboxSwitchFrame = detectLetterboxPossibleFullFrame;
    274             detectLetterboxLock.unlock();
     305            detectLetterboxDetectedMode = mode;
     306            detectLetterboxSwitchFrame = frameNumber;
    275307        }
    276308        else
    277309        {
    void DetectLetterbox::Detect(VideoFrame *frame) 
    280312    }
    281313    else
    282314    {
    283         if (detectLetterboxConsecutiveCounter <= 3)
     315        if (detectLetterboxConsecutiveCounter < CONSECUTIVE_COUNTS)
    284316            detectLetterboxConsecutiveCounter = 0;
    285317    }
    286318}
    void DetectLetterbox::SwitchTo(VideoFrame *frame) 
    295327    if (!GetDetectLetterbox())
    296328        return;
    297329
     330    QMutexLocker lock(&detectLetterboxLock);
     331
    298332    if (detectLetterboxSwitchFrame == -1)
    299333        return;
    300334
    301     detectLetterboxLock.lock();
    302     if (detectLetterboxSwitchFrame <= frame->frameNumber &&
    303         detectLetterboxConsecutiveCounter > 3)
     335    if (detectLetterboxSwitchFrame > frame->frameNumber)
     336        return;
     337
     338    if (m_player->GetAdjustFill() == detectLetterboxDetectedMode)
     339        return;
     340
     341    if (detectLetterboxConsecutiveCounter >= CONSECUTIVE_COUNTS)
    304342    {
    305         if (m_player->GetAdjustFill() != detectLetterboxDetectedMode)
    306         {
    307             LOG(VB_PLAYBACK, LOG_INFO,
    308                 QString("Detect Letterbox: Switched to %1 "
    309                         "on frame %2 (%3)").arg(detectLetterboxDetectedMode)
    310                     .arg(frame->frameNumber)
    311                     .arg(detectLetterboxSwitchFrame));
    312             m_player->GetVideoOutput()->
    313                       ToggleAdjustFill(detectLetterboxDetectedMode);
    314             m_player->ReinitOSD();
    315         }
     343        LOG(VB_PLAYBACK, LOG_INFO, QString("Detect Letterbox: Switched to %1 "
     344                "on frame %2 (%3)").arg(toString(detectLetterboxDetectedMode))
     345                .arg(frame->frameNumber).arg(detectLetterboxSwitchFrame));
     346
     347        m_player->GetVideoOutput()->ToggleAdjustFill(detectLetterboxDetectedMode);
     348        m_player->ReinitOSD();
    316349        detectLetterboxSwitchFrame = -1;
    317350    }
    318     else if (detectLetterboxSwitchFrame <= frame->frameNumber)
    319         LOG(VB_PLAYBACK, LOG_INFO,
    320             QString("Detect Letterbox: Not Switched to %1 on frame %2 "
    321                     "(%3) Not enough consecutive detections (%4)")
    322                 .arg(detectLetterboxDetectedMode)
     351    else
     352    {
     353        LOG(VB_PLAYBACK, LOG_DEBUG,
     354                QString("Detect Letterbox: Not Switched to %1 on frame %2 "
     355                        "(%3) Not enough consecutive detections (%4)")
     356                .arg(toString(detectLetterboxDetectedMode))
    323357                .arg(frame->frameNumber).arg(detectLetterboxSwitchFrame)
    324358                .arg(detectLetterboxConsecutiveCounter));
    325 
    326     detectLetterboxLock.unlock();
     359    }
    327360}
    328361
    329362void DetectLetterbox::SetDetectLetterbox(bool detect)
    330363{
     364    QMutexLocker lock(&detectLetterboxLock);
     365
    331366    isDetectLetterbox = detect;
    332367    detectLetterboxSwitchFrame = -1;
    333     detectLetterboxDetectedMode = m_player->GetAdjustFill();
    334     firstFrameChecked = 0;
     368    detectLetterboxDetectedMode = kAdjustFill_Toggle;
     369    firstFrameChecked = -1;
    335370}
    336371
    337372bool DetectLetterbox::GetDetectLetterbox() const
  • mythtv/libs/libmythtv/DetectLetterbox.h

    diff --git a/mythtv/libs/libmythtv/DetectLetterbox.h b/mythtv/libs/libmythtv/DetectLetterbox.h
    index 60904fa..73c578b 100644
    a b  
    22
    33#include "mythplayer.h"
    44
    5 using namespace std;
    6 
    75class MythPlayer;
    86
    97class MTV_PUBLIC DetectLetterbox
    108{
    119public:
    12     DetectLetterbox(MythPlayer* const player);
     10    DetectLetterbox(MythPlayer *player);
    1311    ~DetectLetterbox();
    1412    void SetDetectLetterbox(bool detect);
    1513    bool GetDetectLetterbox() const;
    public: 
    1816
    1917private:
    2018    bool isDetectLetterbox;
    21     int firstFrameChecked;
     19    long long firstFrameChecked;
    2220
    2321    AdjustFillMode detectLetterboxDefaultMode;
    24     AdjustFillMode detectLetterboxDetectedMode; // Wich mode was last detected
    25     long long detectLetterboxSwitchFrame; // On wich frame was the mode switch detected
     22    AdjustFillMode detectLetterboxDetectedMode; // Which mode was last detected
     23    long long detectLetterboxSwitchFrame; // On which frame the mode switch was detected
    2624    long long detectLetterboxPossibleHalfFrame;
    2725    long long detectLetterboxPossibleFullFrame;
    2826    int detectLetterboxConsecutiveCounter;
    2927
    30     MythPlayer *m_player;
     28    MythPlayer * const m_player;
    3129
    32     int detectLetterboxLimit;
    33     QMutex detectLetterboxLock;
     30    int const detectLetterboxLimit;
     31    mutable QMutex detectLetterboxLock;
    3432};
    3533
    3634/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • mythtv/libs/libmythtv/mhi.cpp

    diff --git a/mythtv/libs/libmythtv/mhi.cpp b/mythtv/libs/libmythtv/mhi.cpp
    index 1631495..94b578d 100644
    a b void MHIContext::UpdateOSD(InteractiveScreen *osdWindow, 
    528528    }
    529529    osdWindow->OptimiseDisplayedArea();
    530530    // N.B. bypasses OSD class hence no expiry set
    531     osdWindow->SetVisible(true);
     531    osdWindow->SetVisible(!m_display.empty());
    532532}
    533533
    534534void MHIContext::GetInitialStreams(int &audioTag, int &videoTag)
  • mythtv/libs/libmythtv/tv_play.cpp

    diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
    index 5a9f8d1..523b031 100644
    a b void TV::OSDDialogEvent(int result, QString text, QString action) 
    1004010040    }
    1004110041    else if (action == "AUTODETECT_FILL")
    1004210042    {
    10043         actx->player->detect_letter_box->SetDetectLetterbox(!actx->player->detect_letter_box->GetDetectLetterbox());
     10043        actx->player->detect_letter_box->SetDetectLetterbox(true);
    1004410044    }
    1004510045    else if (action == ACTION_GUIDE)
    1004610046        EditSchedule(actx, kScheduleProgramGuide);