Ticket #4872: detectLetterboxV11.patch

File detectLetterboxV11.patch, 27.9 KB (added by Rob Smith, 15 years ago)

v10 updated to r20240

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    2929#include "mythdbcon.h"
    3030#include "dialogbox.h"
    3131#include "NuppelVideoPlayer.h"
     32#include "DetectLetterbox.h"
    3233#include "audiooutput.h"
    3334#include "recordingprofile.h"
    3435#include "osdtypes.h"
     
    272273      // Debugging variables
    273274      output_jmeter(NULL)
    274275{
     276
     277    // Playback (output) zoom control
     278    detect_letter_box = new DetectLetterbox(this);
     279
    275280    vbimode = VBIMode::Parse(gContext->GetSetting("VbiFormat"));
    276281
    277282    commrewindamount = gContext->GetNumSetting("CommRewindAmount",0);
     
    14041409    buffer->timecode = timecode;
    14051410
    14061411    videoOutput->ReleaseFrame(buffer);
     1412
     1413    detect_letter_box->Detect(buffer);
    14071414}
    14081415
    14091416/** \fn NuppelVideoPlayer::DiscardVideoFrame(VideoFrame*)
     
    28772884    // handle scan type changes
    28782885    AutoDeint(frame);
    28792886
     2887    detect_letter_box->SwitchTo(frame);
     2888
    28802889    FrameScanType ps = m_scan;
    28812890    if (kScan_Detect == m_scan || kScan_Ignore == m_scan)
    28822891        ps = kScan_Progressive;
     
    52735282{
    52745283    if (videoOutput)
    52755284    {
     5285        detect_letter_box->SetDetectLetterbox(false);
    52765286        videoOutput->ToggleAdjustFill(adjustfillMode);
    52775287        ReinitOSD();
    52785288    }
  • libs/libmythtv/DetectLetterbox.cpp

     
     1// -*- Mode: c++ -*-
     2
     3// Qt headers
     4#include <QApplication>
     5#include <QKeyEvent>
     6
     7// MythTV headers
     8#include "DetectLetterbox.h"
     9#include "NuppelVideoPlayer.h"
     10#include "videoouttypes.h"
     11#include "videoout_xv.h"
     12
     13DetectLetterbox::DetectLetterbox(NuppelVideoPlayer* const nvp)
     14{
     15    int dbAdjustFill = gContext->GetNumSetting("AdjustFill", 0);
     16    isDetectLetterbox = dbAdjustFill >= kAdjustFill_AutoDetect_DefaultOff;
     17    detectLetterboxDefaultMode = (AdjustFillMode) max((int) kAdjustFill_Off,
     18                                 dbAdjustFill - kAdjustFill_AutoDetect_DefaultOff);
     19    detectLetterboxSwitchFrame = -1;
     20    detectLetterboxPossibleHalfFrame = -1;
     21    detectLetterboxPossibleFullFrame = -1;
     22    detectLetterboxDetectedMode = nvp->GetAdjustFill();
     23    detectLetterboxLimit = gContext->GetNumSetting("DetectLeterboxLimit", 75);
     24    nupple_video_player = nvp;
     25}
     26
     27DetectLetterbox::~DetectLetterbox()
     28{
     29}
     30
     31/** \fn DetectLetterbox::Detect(VideoFrame*)
     32 *  \brief Detects if this frame is or is not letterboxed
     33 *
     34 *  If a change is detected detectLetterboxSwitchFrame and
     35 *  detectLetterboxDetectedMode are set.
     36 */
     37void DetectLetterbox::Detect(VideoFrame *frame)
     38{
     39    unsigned char *buf = frame->buf;
     40    int *pitches = frame->pitches;
     41    int *offsets = frame->offsets;
     42    const int width = frame->width;
     43    const int height = frame->height;
     44    const long long frameNumber = frame->frameNumber;
     45    const int NUMBER_OF_DETECTION_LINES = 3; // How many lines are we looking at
     46    const int THRESHOLD = 5; // Y component has to not vary more than this in the bars
     47    const int HORIZONTAL_THRESHOLD = 4; // How tolerant are we that the image has horizontal edges
     48
     49    // If the black bars is larger than this limit we switch to Half or Full Mode
     50    //    const int fullLimit = (int) (((height - width * 9 / 16) / 2) * detectLetterboxLimit / 100);
     51    //    const int halfLimit = (int) (((height - width * 9 / 14) / 2) * detectLetterboxLimit / 100);
     52    // If the black bars is larger than this limit we switch to Half or Full Mode
     53    const int fullLimit = (int) ((height * (1 - nupple_video_player->GetVideoAspect() * 9 / 16) / 2) * detectLetterboxLimit / 100);
     54    const int halfLimit = (int) ((height * (1 - nupple_video_player->GetVideoAspect() * 9 / 14) / 2) * detectLetterboxLimit / 100);
     55
     56    const int xPos[] = {width / 4, width / 2, width * 3 / 4};    // Lines to scan for black letterbox edge
     57    int topHits = 0, bottomHits = 0, minTop = 0, minBottom = 0, maxTop = 0, maxBottom = 0;
     58    int topHit[] = {0, 0, 0}, bottomHit[] = {0, 0, 0};
     59
     60    if (!GetDetectLetterbox())
     61        return;
     62
     63    if (!nupple_video_player->getVideoOutput())
     64        return;
     65
     66    switch (frame->codec) {
     67        case FMT_YV12:
     68            if (frameNumber == 1)
     69                VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: YV12 frame format detected"));
     70            break;
     71        default:
     72            VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: The source is not a supported frame format (was %1)").arg(frame->codec));
     73            isDetectLetterbox = false;
     74            return;
     75    }
     76
     77    if (frameNumber < 0)
     78    {
     79        VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Strange frame number %1").arg(frameNumber));
     80        return;
     81    }
     82
     83    if (nupple_video_player->GetVideoAspect() > 1.5)
     84    {
     85        if (detectLetterboxDetectedMode != detectLetterboxDefaultMode)
     86        {
     87            VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: The source is already in widescreen (aspect: %1)").arg(nupple_video_player->GetVideoAspect()));
     88            detectLetterboxLock.lock();
     89            detectLetterboxConsecutiveCounter = 0;
     90            detectLetterboxDetectedMode = detectLetterboxDefaultMode;
     91            detectLetterboxSwitchFrame = frameNumber;
     92            detectLetterboxLock.unlock();
     93        }
     94        else
     95        {
     96            detectLetterboxConsecutiveCounter++;
     97        }
     98        VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: The source is already in widescreen (aspect: %1)").arg(nupple_video_player->GetVideoAspect()));
     99        isDetectLetterbox = false;
     100        return;
     101    }
     102
     103    // Establish the level of light in the edge
     104    int averageY = 0;
     105    for (int detectionLine = 0; detectionLine < NUMBER_OF_DETECTION_LINES; detectionLine++)
     106    {
     107        averageY += buf[offsets[0] + 5 * pitches[0]            + xPos[detectionLine]];
     108        averageY += buf[offsets[0] + (height - 6) * pitches[0] + xPos[detectionLine]];
     109    }
     110    averageY /= NUMBER_OF_DETECTION_LINES * 2;
     111    if (averageY > 64) // To bright to be a letterbox border
     112        averageY = 0;
     113
     114    // Scan the detection lines
     115    for (int y = 5; y < height / 4; y++) // skip first pixels incase of noise in the edge
     116    {
     117        for (int detectionLine = 0; detectionLine < NUMBER_OF_DETECTION_LINES; detectionLine++)
     118        {
     119            int Y = buf[offsets[0] +  y     * pitches[0] +  xPos[detectionLine]];
     120            int U = buf[offsets[1] + (y>>1) * pitches[1] + (xPos[detectionLine]>>1)];
     121            int V = buf[offsets[2] + (y>>1) * pitches[2] + (xPos[detectionLine]>>1)];
     122            if ((!topHit[detectionLine]) &&
     123                ( Y > averageY + THRESHOLD || Y < averageY - THRESHOLD ||
     124                  U < 128 - 32 || U > 128 + 32 ||
     125                  V < 128 - 32 || V > 128 + 32 ))
     126            {
     127                topHit[detectionLine] = y;
     128                topHits++;
     129                if (!minTop)
     130                    minTop = y;
     131                maxTop = y;
     132            }
     133
     134            Y = buf[offsets[0] + (height-y-1     ) * pitches[0] + xPos[detectionLine]];
     135            U = buf[offsets[1] + (height-y-1 >> 1) * pitches[1] + (xPos[detectionLine]>>1)];
     136            V = buf[offsets[2] + (height-y-1 >> 1) * pitches[2] + (xPos[detectionLine]>>1)];
     137            if ((!bottomHit[detectionLine]) &&
     138                ( Y > averageY + THRESHOLD || Y < averageY - THRESHOLD ||
     139                  U < 128 - 32 || U > 128 + 32 ||
     140                  V < 128 - 32 || V > 128 + 32 ))
     141            {
     142                bottomHit[detectionLine] = y;
     143                bottomHits++;
     144                if (!minBottom)
     145                    minBottom = y;
     146                maxBottom = y;
     147            }
     148        }
     149
     150        if (topHits == NUMBER_OF_DETECTION_LINES && bottomHits == NUMBER_OF_DETECTION_LINES)
     151        {
     152            break;
     153        }
     154    }
     155    if (topHits != NUMBER_OF_DETECTION_LINES) maxTop = height / 4;
     156    if (!minTop) minTop = height / 4;
     157    if (bottomHits != NUMBER_OF_DETECTION_LINES) maxBottom = height / 4;
     158    if (!minBottom) minBottom = height / 4;
     159
     160    bool horizontal = ((minTop && maxTop - minTop < HORIZONTAL_THRESHOLD) &&
     161                       (minBottom && maxBottom - minBottom < HORIZONTAL_THRESHOLD));
     162
     163    if (detectLetterboxSwitchFrame > frameNumber) // user is reversing
     164    {
     165        detectLetterboxLock.lock();
     166        detectLetterboxDetectedMode = nupple_video_player->GetAdjustFill();
     167        detectLetterboxSwitchFrame = -1;
     168        detectLetterboxPossibleHalfFrame = -1;
     169        detectLetterboxPossibleFullFrame = -1;
     170        detectLetterboxLock.unlock();
     171    }
     172
     173    if (minTop < halfLimit || minBottom < halfLimit)
     174        detectLetterboxPossibleHalfFrame = -1;
     175    if (minTop < fullLimit || minBottom < fullLimit)
     176        detectLetterboxPossibleFullFrame = -1;
     177
     178    if (detectLetterboxDetectedMode != kAdjustFill_Full)
     179    {
     180        if (detectLetterboxPossibleHalfFrame == -1 &&
     181            minTop > halfLimit && minBottom > halfLimit) {
     182            detectLetterboxPossibleHalfFrame = frameNumber;
     183        }
     184    }
     185    else
     186    {
     187        if (detectLetterboxPossibleHalfFrame == -1 &&
     188            minTop < fullLimit && minBottom < fullLimit) {
     189            detectLetterboxPossibleHalfFrame = frameNumber;
     190        }
     191    }
     192    if (detectLetterboxPossibleFullFrame == -1 && minTop > fullLimit && minBottom > fullLimit)
     193        detectLetterboxPossibleFullFrame = frameNumber;
     194
     195    if ( maxTop < halfLimit || maxBottom < halfLimit) // Not to restrictive when switching to off
     196    {
     197        // No Letterbox
     198        if (detectLetterboxDetectedMode != detectLetterboxDefaultMode)
     199        {
     200            VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Non Letterbox detected on line: %1 (limit: %2)").arg(min(maxTop, maxBottom)).arg(halfLimit));
     201            detectLetterboxLock.lock();
     202            detectLetterboxConsecutiveCounter = 0;
     203            detectLetterboxDetectedMode = detectLetterboxDefaultMode;
     204            detectLetterboxSwitchFrame = frameNumber;
     205            detectLetterboxLock.unlock();
     206        }
     207        else
     208        {
     209            detectLetterboxConsecutiveCounter++;
     210        }
     211    }
     212    else if (horizontal && minTop > halfLimit && minBottom > halfLimit &&
     213             maxTop < fullLimit && maxBottom < fullLimit)
     214    {
     215        // Letterbox (with narrow bars)
     216        if (detectLetterboxDetectedMode != kAdjustFill_Half)
     217        {
     218            VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Narrow Letterbox detected on line: %1 (limit: %2) frame: %3").arg(minTop).arg(halfLimit).arg(detectLetterboxPossibleHalfFrame));
     219            detectLetterboxLock.lock();
     220            detectLetterboxConsecutiveCounter = 0;
     221            if (detectLetterboxDetectedMode == kAdjustFill_Full &&
     222                detectLetterboxSwitchFrame != -1) {
     223                // Do not change switch frame if switch to Full mode has not been executed yet
     224            }
     225            else
     226                detectLetterboxSwitchFrame = detectLetterboxPossibleHalfFrame;
     227            detectLetterboxDetectedMode = kAdjustFill_Half;
     228            detectLetterboxLock.unlock();
     229        }
     230        else
     231        {
     232            detectLetterboxConsecutiveCounter++;
     233        }
     234    }
     235    else if (horizontal && minTop > fullLimit && minBottom > fullLimit)
     236    {
     237        // Letterbox
     238        detectLetterboxPossibleHalfFrame = -1;
     239        if (detectLetterboxDetectedMode != kAdjustFill_Full)
     240        {
     241            VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Detected Letterbox on line: %1 (limit: %2) frame: %2").arg(minTop).arg(fullLimit).arg(detectLetterboxPossibleFullFrame));
     242            detectLetterboxLock.lock();
     243            detectLetterboxConsecutiveCounter = 0;
     244            detectLetterboxDetectedMode = kAdjustFill_Full;
     245            detectLetterboxSwitchFrame = detectLetterboxPossibleFullFrame;
     246            detectLetterboxLock.unlock();
     247        }
     248        else
     249        {
     250            detectLetterboxConsecutiveCounter++;
     251        }
     252    }
     253    else
     254    {
     255        if (detectLetterboxConsecutiveCounter <= 3)
     256            detectLetterboxConsecutiveCounter = 0;
     257    }
     258}
     259
     260/** \fn DetectLetterbox::SwitchTo(VideoFrame*)
     261 *  \brief Switch to the mode detected by DetectLetterbox
     262 *
     263 *  Switch fill mode if a switch was detected for this frame.
     264 */
     265void DetectLetterbox::SwitchTo(VideoFrame *frame)
     266{
     267    if (!GetDetectLetterbox())
     268        return;
     269
     270    if (detectLetterboxSwitchFrame != -1)
     271    {
     272        detectLetterboxLock.lock();
     273        if (detectLetterboxSwitchFrame <= frame->frameNumber &&
     274            detectLetterboxConsecutiveCounter > 3)
     275        {
     276            if (nupple_video_player->GetAdjustFill() != detectLetterboxDetectedMode)
     277            {
     278                VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Switched to %1 on frame %2 (%3)").arg(detectLetterboxDetectedMode).arg(frame->frameNumber).arg(detectLetterboxSwitchFrame));
     279                nupple_video_player->getVideoOutput()->ToggleAdjustFill(detectLetterboxDetectedMode);
     280                nupple_video_player->ReinitOSD();
     281            }
     282            detectLetterboxSwitchFrame = -1;
     283        }
     284        else if (detectLetterboxSwitchFrame <= frame->frameNumber)
     285            VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Not Switched to %1 on frame %2 (%3) Not enough consecutive detections (%4)").arg(detectLetterboxDetectedMode).arg(frame->frameNumber).arg(detectLetterboxSwitchFrame).arg(detectLetterboxConsecutiveCounter));
     286
     287        detectLetterboxLock.unlock();
     288    }
     289}
     290
     291void DetectLetterbox::SetDetectLetterbox(bool detect)
     292{
     293    isDetectLetterbox = detect;
     294    detectLetterboxSwitchFrame = -1;
     295    detectLetterboxDetectedMode = nupple_video_player->GetAdjustFill();
     296}
     297
     298bool DetectLetterbox::GetDetectLetterbox()
     299{
     300    return isDetectLetterbox;
     301}
     302
     303/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • libs/libmythtv/libmythtv.pro

     
    363363    # Misc. frontend
    364364    HEADERS += guidegrid.h              infostructs.h
    365365    HEADERS += ttfont.h
     366    HEADERS += DetectLetterbox.h
    366367    SOURCES += guidegrid.cpp            infostructs.cpp
    367368    SOURCES += ttfont.cpp
     369    SOURCES += DetectLetterbox.cpp
    368370
    369371    using_mheg {
    370372        # DSMCC stuff
  • libs/libmythtv/tv_play.h

     
    3535class OSD;
    3636class RemoteEncoder;
    3737class NuppelVideoPlayer;
     38class DetectLetterbox;
    3839class RingBuffer;
    3940class ProgramInfo;
    4041class MythDialog;
  • libs/libmythtv/DetectLetterbox.h

     
     1// -*- Mode: c++ -*-
     2
     3#include "NuppelVideoPlayer.h"
     4
     5using namespace std;
     6
     7class NuppelVideoPlayer;
     8
     9class MPUBLIC DetectLetterbox
     10{
     11public:
     12    DetectLetterbox(NuppelVideoPlayer* const nvp);
     13    ~DetectLetterbox();
     14    void SetDetectLetterbox(bool detect);
     15    bool GetDetectLetterbox();
     16    void Detect(VideoFrame *frame);
     17    void SwitchTo(VideoFrame *frame);
     18
     19private:
     20    bool isDetectLetterbox;
     21
     22    AdjustFillMode detectLetterboxDefaultMode;
     23    AdjustFillMode detectLetterboxDetectedMode; // Wich mode was last detected
     24    long long detectLetterboxSwitchFrame; // On wich frame was the mode switch detected
     25    long long detectLetterboxPossibleHalfFrame;
     26    long long detectLetterboxPossibleFullFrame;
     27    int detectLetterboxConsecutiveCounter;
     28
     29    NuppelVideoPlayer *nupple_video_player;
     30
     31    int detectLetterboxLimit;
     32    QMutex detectLetterboxLock;
     33};
     34
     35/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • libs/libmythtv/NuppelVideoPlayer.h

     
    4949struct SwsContext;
    5050class InteractiveTV;
    5151class NSAutoreleasePool;
     52class DetectLetterbox;
    5253
    5354struct TextContainer
    5455{
     
    162163    void SetBookmark(void);
    163164    void SetKeyframeDistance(int keyframedistance);
    164165    void SetVideoParams(int w, int h, double fps, int keydist,
    165                         float a = 1.33333, FrameScanType scan = kScan_Ignore, 
     166                        float a = 1.33333, FrameScanType scan = kScan_Ignore,
    166167                        bool video_codec_changed = false);
    167168    void SetFileLength(int total, int frames);
    168169    void Zoom(ZoomDirection direction);
     
    402403        { tc_wrap[TC_AUDIO] = 0LL; return tc_wrap[TC_AUDIO]; }
    403404    long long ResyncAudioTimecodeOffset(void)
    404405        { tc_wrap[TC_AUDIO] = LONG_LONG_MIN; return 0L; }
    405     long long GetAudioTimecodeOffset(void) const 
     406    long long GetAudioTimecodeOffset(void) const
    406407        { return tc_wrap[TC_AUDIO]; }
    407408    void SaveAudioTimecodeOffset(long long v)
    408409        { savedAudioTimecodeOffset = v; }
     
    416417    void ActivateDVDButton(void);
    417418    void GoToDVDMenu(QString str);
    418419    void GoToDVDProgram(bool direction);
    419     void HideDVDButton(bool hide) 
     420    void HideDVDButton(bool hide)
    420421    {
    421422        hidedvdbutton = hide;
    422423    }
    423424
     425    // Playback (output) zoom automation
     426    DetectLetterbox *detect_letter_box;
     427
    424428    // Position Map Stuff
    425429    bool PosMapFromEnc(unsigned long long          start,
    426430                       QMap<long long, long long> &posMap);
     
    619623    long long rewindtime;
    620624    QString m_recusage;
    621625
    622     // -- end state stuff -- 
     626    // -- end state stuff --
    623627
    624628
    625629    // Input Video Attributes
     
    627631    QSize    video_dim;       ///< Video (input) buffer width & height
    628632    double   video_frame_rate;///< Video (input) Frame Rate (often inaccurate)
    629633    float    video_aspect;    ///< Video (input) Apect Ratio
    630     float    forced_video_aspect; 
     634    float    forced_video_aspect;
    631635    /// Video (input) Scan Type (interlaced, progressive, detect, ignore...)
    632636    FrameScanType m_scan;
    633637    /// Set when the user selects a scan type, overriding the detected one
     
    783787    float      next_play_speed;
    784788    bool       next_normal_speed;
    785789
    786     float      play_speed;   
    787     bool       normal_speed; 
     790    float      play_speed;
     791    bool       normal_speed;
    788792    int        frame_interval;///< always adjusted for play_speed
    789793
    790     int        ffrew_skip;   
     794    int        ffrew_skip;
    791795
    792796    // Audio and video synchronization stuff
    793797    VideoSync *videosync;
     
    811815    short int *warplbuff;
    812816    short int *warprbuff;
    813817    int        warpbuffsize;
    814  
     818
    815819    // Time Code stuff
    816820    int        prevtc;        ///< 32 bit timecode if last VideoFrame shown
    817821    int        tc_avcheck_framecounter;
  • libs/libmythtv/tv_play.cpp

     
    3030#include "guidegrid.h"
    3131//#include "progfind.h"
    3232#include "NuppelVideoPlayer.h"
     33#include "DetectLetterbox.h"
    3334#include "programinfo.h"
    3435#include "udpnotify.h"
    3536#include "vsync.h"
     
    952953            pthread_detach(ddMapLoader);
    953954        }
    954955    }
    955    
     956
    956957    if (osdMenuEntries)
    957958        delete osdMenuEntries;
    958959
     
    51155116        return;
    51165117    }
    51175118
    5118    
     5119
    51195120    VERBOSE(VB_PLAYBACK, LOC +
    51205121            QString("PxPToggleType() converting from %1 to %2 -- begin")
    51215122            .arg(before).arg(after));
     
    94539454    {
    94549455        ToggleAdjustFill(actx, (AdjustFillMode) action.right(1).toInt());
    94559456    }
     9457    else if (action == "AUTODETECT_FILL")
     9458    {
     9459        actx->nvp->detect_letter_box->SetDetectLetterbox(!actx->nvp->detect_letter_box->GetDetectLetterbox());
     9460    }
    94569461    else if (action == "GUIDE")
    94579462        EditSchedule(actx, kScheduleProgramGuide);
    94589463    else if (action == "FINDER")
     
    95649569void TV::ShowOSDTreeMenu(const PlayerContext *ctx)
    95659570{
    95669571    int osdMenuCount = osdMenuEntries->GetCount();
    9567    
     9572
    95689573    if (treeMenu)
    95699574    {
    95709575        for (uint i = 0; i < player.size(); i++)
     
    99649969    ctx->UnlockDeleteNVP(__FILE__, __LINE__);
    99659970
    99669971    OSDGenericTree *af_item = new OSDGenericTree(treeMenu, tr("Adjust Fill"));
     9972    OSDGenericTree *subitem = new OSDGenericTree(af_item, tr("Auto Detect"),
     9973                                 "AUTODETECT_FILL",
     9974                                 (ctx->nvp->detect_letter_box->GetDetectLetterbox()) ? 1 : 0,
     9975                                 NULL, "ADJUSTFILLGROUP");
     9976
    99679977    for (int i = kAdjustFill_Off; i < kAdjustFill_END; i++)
    99689978    {
    99699979        bool sel = (i != kAdjustFill_Off) ? (adjustfill == i) :
  • libs/libmythtv/videoouttypes.h

     
    5454    kAdjustFill_Half,
    5555    kAdjustFill_Full,
    5656    kAdjustFill_Stretch,
    57     kAdjustFill_END
     57    kAdjustFill_END,
     58    kAdjustFill_AutoDetect_DefaultOff = 16,
     59    kAdjustFill_AutoDetect_DefaultHalf
    5860} AdjustFillMode;
    5961
    6062typedef enum LetterBoxColour
     
    234236        case kAdjustFill_Toggle:
    235237        case kAdjustFill_Off:
    236238        case kAdjustFill_END: break;
     239        case kAdjustFill_AutoDetect_DefaultOff: ret = QObject::tr("Auto Detect (Default Off)");    break;
     240        case kAdjustFill_AutoDetect_DefaultHalf: ret = QObject::tr("Auto Detect (Default Half)");    break;
    237241    }
    238242
    239243    ret.detach();
  • libs/libmythtv/videooutbase.cpp

     
    222222 *         vo->ReleaseFrame(frame); // enqueues frame in "used" queue
    223223 *     }
    224224 * }
    225  * 
     225 *
    226226 * // In the displaying thread
    227227 * while (playing)
    228228 * {
     
    257257 *        update an OSD for example.
    258258 *
    259259 *  The VideoBuffers class handles the buffer tracking,
    260  *  see it for more details on the states a buffer can 
     260 *  see it for more details on the states a buffer can
    261261 *  take before it becomes available for reuse.
    262262 *
    263263 * \see VideoBuffers, NuppelVideoPlayer
     
    265265
    266266/**
    267267 * \fn VideoOutput::VideoOutput()
    268  * \brief This constructor for VideoOutput must be followed by an 
     268 * \brief This constructor for VideoOutput must be followed by an
    269269 *        Init(int,int,float,WId,int,int,int,int,WId) call.
    270270 */
    271271VideoOutput::VideoOutput() :
     
    364364    if (db_vdisp_profile)
    365365        db_vdisp_profile->SetInput(windows[0].GetVideoDim());
    366366
     367/*
     368    aspectoverride  = db_aspectoverride;
     369    // If autodection is enabled. Start in the defaultmode
     370    adjustfill      = db_adjustfill >= kAdjustFill_AutoDetect_DefaultOff ?
     371        (AdjustFillMode) (db_adjustfill - kAdjustFill_AutoDetect_DefaultOff) : db_adjustfill;
     372*/
     373
     374    VideoAspectRatioChanged(aspect); // apply aspect ratio and letterbox mode
     375
    367376    return mainSuccess;
    368377}
    369378
     
    410419 * \return true if successful, false otherwise.
    411420 * \param overridefilter optional, explicitly use this nondefault deint filter
    412421 */
    413 bool VideoOutput::SetupDeinterlace(bool interlaced, 
     422bool VideoOutput::SetupDeinterlace(bool interlaced,
    414423                                   const QString& overridefilter)
    415424{
    416425    PIPState pip_state = windows[0].GetPIPState();
     
    434443
    435444    m_deinterlacing = interlaced;
    436445
    437     if (m_deinterlacing) 
     446    if (m_deinterlacing)
    438447    {
    439448        m_deinterlaceBeforeOSD = true;
    440449
    441450        VideoFrameType itmp = FMT_YV12;
    442451        VideoFrameType otmp = FMT_YV12;
    443452        int btmp;
    444        
     453
    445454        if (db_vdisp_profile)
    446455            m_deintfiltername = db_vdisp_profile->GetFilteredDeint(overridefilter);
    447456        else
     
    474483            }
    475484        }
    476485
    477         if (m_deintFilter == NULL) 
     486        if (m_deintFilter == NULL)
    478487        {
    479488            VERBOSE(VB_IMPORTANT,QString("Couldn't load deinterlace filter %1")
    480489                    .arg(m_deintfiltername));
     
    518527 *   All adaptive full framerate deinterlacers require an extra
    519528 *   ProcessFrame() call.
    520529 *
    521  *  \return true if deint name contains doubleprocess 
     530 *  \return true if deint name contains doubleprocess
    522531 */
    523532bool VideoOutput::IsExtraProcessingRequired(void) const
    524533{
     
    592601        db_vdisp_profile->SetInput(windows[0].GetVideoDim());
    593602
    594603    BestDeint();
    595    
     604
    596605    DiscardFrames(true);
    597606
    598607    return true;
     
    622631 * \fn VideoOutput::StopEmbedding(void)
    623632 * \brief Tells video output to stop embedding video in an existing window.
    624633 * \sa EmbedInWidget(WId, int, int, int, int)
    625  */ 
     634 */
    626635void VideoOutput::StopEmbedding(void)
    627636{
    628637    windows[0].StopEmbedding();
     
    943952    const QSize pipVideoDim    = pipplayer->GetVideoBufferSize();
    944953
    945954    // If PiP is not initialized to values we like, silently ignore the frame.
    946     if ((video_aspect <= 0) || (pipVideoAspect <= 0) || 
     955    if ((video_aspect <= 0) || (pipVideoAspect <= 0) ||
    947956        (frame->height <= 0) || (frame->width <= 0) ||
    948957        !pipimage || !pipimage->buf || pipimage->codec != FMT_YV12)
    949958    {
     
    986995#else
    987996            img_resample(pip_scaling_context, &img_out, &img_in);
    988997#endif
    989          
     998
    990999            if (pipActive)
    9911000            {
    9921001                AVPicture img_padded;
     
    9991008                               pip_display_size.height(),
    10001009                               pip_display_size.width(),
    10011010                               PIX_FMT_YUV420P, 10, 10, 10, 10, color);
    1002                
     1011
    10031012                pipbuf = pip_tmp_buf2;
    10041013            }
    10051014            else
     
    10251034
    10261035    uint pip_height = pip_tmp_image.height;
    10271036    uint height[3] = { pip_height, pip_height>>1, pip_height>>1 };
    1028    
     1037
    10291038    for (int p = 0; p < 3; p++)
    10301039    {
    10311040        for (uint h = 2; h < height[p]; h++)
    10321041        {
    1033             memcpy((frame->buf + frame->offsets[p]) + (h + yoff2[p]) * 
     1042            memcpy((frame->buf + frame->offsets[p]) + (h + yoff2[p]) *
    10341043                   frame->pitches[p] + xoff2[p],
    10351044                   (pip_tmp_image.buf + pip_tmp_image.offsets[p]) + h *
    10361045                   pip_tmp_image.pitches[p], pip_tmp_image.pitches[p]);
     
    12221231 *  converted to greyscale.
    12231232 *
    12241233 * \return 1 if changed, -1 on error and 0 otherwise
    1225  */ 
     1234 */
    12261235int VideoOutput::DisplayOSD(VideoFrame *frame, OSD *osd, int stride,
    12271236                            int revision)
    12281237{
     
    12861295/**
    12871296 * \fn VideoOutput::CopyFrame(VideoFrame*, const VideoFrame*)
    12881297 * \brief Copies frame data from one VideoFrame to another.
    1289  * 
     1298 *
    12901299 *  Note: The frames must have the same width, height, and format.
    12911300 * \param to   The destination frame.
    1292  * \param from The source frame 
     1301 * \param from The source frame
    12931302 */
    12941303void VideoOutput::CopyFrame(VideoFrame *to, const VideoFrame *from)
    12951304{
     
    13101319        memcpy(to->buf + to->offsets[1], from->buf + from->offsets[1],
    13111320               from->pitches[1] * (from->height>>1));
    13121321        memcpy(to->buf + to->offsets[2], from->buf + from->offsets[2],
    1313                from->pitches[2] * (from->height>>1));       
     1322               from->pitches[2] * (from->height>>1));
    13141323    }
    13151324    else
    13161325    {
  • programs/mythfrontend/globalsettings.cpp

     
    24282428{
    24292429    HostComboBox *gc = new HostComboBox("AdjustFill");
    24302430    gc->setLabel(QObject::tr("Zoom"));
     2431    gc->addSelection(toString(kAdjustFill_AutoDetect_DefaultOff), QString::number(kAdjustFill_AutoDetect_DefaultOff));
     2432    gc->addSelection(toString(kAdjustFill_AutoDetect_DefaultHalf), QString::number(kAdjustFill_AutoDetect_DefaultHalf));
    24312433    for (int m = kAdjustFill_Off; m < kAdjustFill_END; m++)
    24322434        gc->addSelection(toString((AdjustFillMode)m), QString::number(m));
    24332435    gc->setHelpText(QObject::tr(