Ticket #4872: detectLetterboxV12.patch

File detectLetterboxV12.patch, 27.6 KB (added by Rob Smith, 15 years ago)

Updated for r21047

  • mythtv/libs/libmythtv/NuppelVideoPlayer.cpp

     
    3131#include "mythdbcon.h"
    3232#include "dialogbox.h"
    3333#include "NuppelVideoPlayer.h"
     34#include "DetectLetterbox.h"
    3435#include "audiooutput.h"
    3536#include "recordingprofile.h"
    3637#include "osdtypes.h"
     
    275276      // Debugging variables
    276277      output_jmeter(NULL)
    277278{
     279
     280    // Playback (output) zoom control
     281    detect_letter_box = new DetectLetterbox(this);
     282
    278283    vbimode = VBIMode::Parse(gContext->GetSetting("VbiFormat"));
    279284
    280285    commrewindamount = gContext->GetNumSetting("CommRewindAmount",0);
     
    14451450    buffer->timecode = timecode;
    14461451
    14471452    videoOutput->ReleaseFrame(buffer);
     1453
     1454    detect_letter_box->Detect(buffer);
    14481455}
    14491456
    14501457/** \fn NuppelVideoPlayer::DiscardVideoFrame(VideoFrame*)
     
    29072914    // handle scan type changes
    29082915    AutoDeint(frame);
    29092916
     2917    detect_letter_box->SwitchTo(frame);
     2918
    29102919    FrameScanType ps = m_scan;
    29112920    if (kScan_Detect == m_scan || kScan_Ignore == m_scan)
    29122921        ps = kScan_Progressive;
     
    53205329{
    53215330    if (videoOutput)
    53225331    {
     5332        detect_letter_box->SetDetectLetterbox(false);
    53235333        videoOutput->ToggleAdjustFill(adjustfillMode);
    53245334        ReinitOSD();
    53255335    }
  • mythtv/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: */
  • mythtv/libs/libmythtv/libmythtv.pro

     
    357357    # Misc. frontend
    358358    HEADERS += ttfont.h
    359359    SOURCES += ttfont.cpp
     360    HEADERS += DetectLetterbox.h
     361    SOURCES += DetectLetterbox.cpp
    360362
    361363    using_mheg {
    362364        # DSMCC stuff
  • mythtv/libs/libmythtv/tv_play.h

     
    3737class OSD;
    3838class RemoteEncoder;
    3939class NuppelVideoPlayer;
     40class DetectLetterbox;
    4041class RingBuffer;
    4142class ProgramInfo;
    4243class MythDialog;
  • mythtv/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: */
  • mythtv/libs/libmythtv/NuppelVideoPlayer.h

     
    4646struct SwsContext;
    4747class InteractiveTV;
    4848class NSAutoreleasePool;
     49class DetectLetterbox;
    4950
    5051struct TextContainer
    5152{
     
    159160    void SetBookmark(void);
    160161    void SetKeyframeDistance(int keyframedistance);
    161162    void SetVideoParams(int w, int h, double fps, int keydist,
    162                         float a = 1.33333, FrameScanType scan = kScan_Ignore, 
     163                        float a = 1.33333, FrameScanType scan = kScan_Ignore,
    163164                        bool video_codec_changed = false);
    164165    void SetFileLength(int total, int frames);
    165166    void Zoom(ZoomDirection direction);
     
    400401        { tc_wrap[TC_AUDIO] = 0LL; return tc_wrap[TC_AUDIO]; }
    401402    long long ResyncAudioTimecodeOffset(void)
    402403        { tc_wrap[TC_AUDIO] = LONG_LONG_MIN; return 0L; }
    403     long long GetAudioTimecodeOffset(void) const 
     404    long long GetAudioTimecodeOffset(void) const
    404405        { return tc_wrap[TC_AUDIO]; }
    405406    void SaveAudioTimecodeOffset(long long v)
    406407        { savedAudioTimecodeOffset = v; }
     
    414415    void ActivateDVDButton(void);
    415416    void GoToDVDMenu(QString str);
    416417    void GoToDVDProgram(bool direction);
    417     void HideDVDButton(bool hide) 
     418    void HideDVDButton(bool hide)
    418419    {
    419420        hidedvdbutton = hide;
    420421    }
    421422
     423    // Playback (output) zoom automation
     424    DetectLetterbox *detect_letter_box;
     425
    422426    // Position Map Stuff
    423427    bool PosMapFromEnc(unsigned long long          start,
    424428                       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
     
    780784    float      next_play_speed;
    781785    bool       next_normal_speed;
    782786
    783     float      play_speed;   
    784     bool       normal_speed; 
     787    float      play_speed;
     788    bool       normal_speed;
    785789    int        frame_interval;///< always adjusted for play_speed
    786790
    787     int        ffrew_skip;   
     791    int        ffrew_skip;
    788792
    789793    // Audio and video synchronization stuff
    790794    VideoSync *videosync;
     
    808812    short int *warplbuff;
    809813    short int *warprbuff;
    810814    int        warpbuffsize;
    811  
     815
    812816    // Time Code stuff
    813817    int        prevtc;        ///< 32 bit timecode if last VideoFrame shown
    814818    int        tc_avcheck_framecounter;
  • mythtv/libs/libmythtv/tv_play.cpp

     
    2828#include "remoteencoder.h"
    2929#include "remoteutil.h"
    3030#include "NuppelVideoPlayer.h"
     31#include "DetectLetterbox.h"
    3132#include "programinfo.h"
    3233#include "udpnotify.h"
    3334#include "vsync.h"
     
    97249725    {
    97259726        ToggleAdjustFill(actx, (AdjustFillMode) action.right(1).toInt());
    97269727    }
     9728    else if (action == "AUTODETECT_FILL")
     9729    {
     9730        actx->nvp->detect_letter_box->SetDetectLetterbox(!actx->nvp->detect_letter_box->GetDetectLetterbox());
     9731    }
    97279732    else if (action == "GUIDE")
    97289733        EditSchedule(actx, kScheduleProgramGuide);
    97299734    else if (action.left(10) == "CHANGROUP_")
     
    1031510320    ctx->UnlockDeleteNVP(__FILE__, __LINE__);
    1031610321
    1031710322    OSDGenericTree *af_item = new OSDGenericTree(treeMenu, tr("Adjust Fill"));
     10323    OSDGenericTree *subitem = new OSDGenericTree(af_item, tr("Auto Detect"),
     10324                                 "AUTODETECT_FILL",
     10325                                 (ctx->nvp->detect_letter_box->GetDetectLetterbox()) ? 1 : 0,
     10326                                 NULL, "ADJUSTFILLGROUP");
     10327
    1031810328    for (int i = kAdjustFill_Off; i < kAdjustFill_END; i++)
    1031910329    {
    1032010330        bool sel = (i != kAdjustFill_Off) ? (adjustfill == i) :
  • mythtv/libs/libmythtv/videoouttypes.h

     
    5656    kAdjustFill_Full,
    5757    kAdjustFill_HorizontalStretch,
    5858    kAdjustFill_VerticalStretch,
    59     kAdjustFill_END
     59    kAdjustFill_END,
     60    kAdjustFill_AutoDetect_DefaultOff = 16,
     61    kAdjustFill_AutoDetect_DefaultHalf
    6062} AdjustFillMode;
    6163
    6264typedef enum LetterBoxColour
     
    258260        case kAdjustFill_Toggle:
    259261        case kAdjustFill_Off:
    260262        case kAdjustFill_END: break;
     263        case kAdjustFill_AutoDetect_DefaultOff: ret = QObject::tr("Auto Detect (Default Off)");    break;
     264        case kAdjustFill_AutoDetect_DefaultHalf: ret = QObject::tr("Auto Detect (Default Half)");    break;
    261265    }
    262266
    263267    ret.detach();
  • mythtv/libs/libmythtv/videooutbase.cpp

     
    239239 *         vo->ReleaseFrame(frame); // enqueues frame in "used" queue
    240240 *     }
    241241 * }
    242  * 
     242 *
    243243 * // In the displaying thread
    244244 * while (playing)
    245245 * {
     
    274274 *        update an OSD for example.
    275275 *
    276276 *  The VideoBuffers class handles the buffer tracking,
    277  *  see it for more details on the states a buffer can 
     277 *  see it for more details on the states a buffer can
    278278 *  take before it becomes available for reuse.
    279279 *
    280280 * \see VideoBuffers, NuppelVideoPlayer
     
    282282
    283283/**
    284284 * \fn VideoOutput::VideoOutput()
    285  * \brief This constructor for VideoOutput must be followed by an 
     285 * \brief This constructor for VideoOutput must be followed by an
    286286 *        Init(int,int,float,WId,int,int,int,int,WId) call.
    287287 */
    288288VideoOutput::VideoOutput() :
     
    391391    if (db_vdisp_profile)
    392392        db_vdisp_profile->SetInput(windows[0].GetVideoDim());
    393393
     394/*
     395    aspectoverride  = db_aspectoverride;
     396    // If autodection is enabled. Start in the defaultmode
     397    adjustfill      = db_adjustfill >= kAdjustFill_AutoDetect_DefaultOff ?
     398        (AdjustFillMode) (db_adjustfill - kAdjustFill_AutoDetect_DefaultOff) : db_adjustfill;
     399*/
     400
     401    VideoAspectRatioChanged(aspect); // apply aspect ratio and letterbox mode
     402
    394403    return mainSuccess;
    395404}
    396405
     
    448457 * \return true if successful, false otherwise.
    449458 * \param overridefilter optional, explicitly use this nondefault deint filter
    450459 */
    451 bool VideoOutput::SetupDeinterlace(bool interlaced, 
     460bool VideoOutput::SetupDeinterlace(bool interlaced,
    452461                                   const QString& overridefilter)
    453462{
    454463    PIPState pip_state = windows[0].GetPIPState();
     
    472481
    473482    m_deinterlacing = interlaced;
    474483
    475     if (m_deinterlacing) 
     484    if (m_deinterlacing)
    476485    {
    477486        m_deinterlaceBeforeOSD = true;
    478487
    479488        VideoFrameType itmp = FMT_YV12;
    480489        VideoFrameType otmp = FMT_YV12;
    481490        int btmp;
    482        
     491
    483492        if (db_vdisp_profile)
    484493            m_deintfiltername = db_vdisp_profile->GetFilteredDeint(overridefilter);
    485494        else
     
    512521            }
    513522        }
    514523
    515         if (m_deintFilter == NULL) 
     524        if (m_deintFilter == NULL)
    516525        {
    517526            VERBOSE(VB_IMPORTANT,QString("Couldn't load deinterlace filter %1")
    518527                    .arg(m_deintfiltername));
     
    556565 *   All adaptive full framerate deinterlacers require an extra
    557566 *   ProcessFrame() call.
    558567 *
    559  *  \return true if deint name contains doubleprocess 
     568 *  \return true if deint name contains doubleprocess
    560569 */
    561570bool VideoOutput::IsExtraProcessingRequired(void) const
    562571{
     
    630639        db_vdisp_profile->SetInput(windows[0].GetVideoDim());
    631640
    632641    BestDeint();
    633    
     642
    634643    DiscardFrames(true);
    635644
    636645    return true;
     
    665674 * \fn VideoOutput::StopEmbedding(void)
    666675 * \brief Tells video output to stop embedding video in an existing window.
    667676 * \sa EmbedInWidget(WId, int, int, int, int)
    668  */ 
     677 */
    669678void VideoOutput::StopEmbedding(void)
    670679{
    671680    windows[0].StopEmbedding();
     
    986995    const QSize pipVideoDim    = pipplayer->GetVideoBufferSize();
    987996
    988997    // If PiP is not initialized to values we like, silently ignore the frame.
    989     if ((video_aspect <= 0) || (pipVideoAspect <= 0) || 
     998    if ((video_aspect <= 0) || (pipVideoAspect <= 0) ||
    990999        (frame->height <= 0) || (frame->width <= 0) ||
    9911000        !pipimage || !pipimage->buf || pipimage->codec != FMT_YV12)
    9921001    {
     
    10251034
    10261035            sws_scale(pip_scaling_context, img_in.data, img_in.linesize, 0,
    10271036                      piph, img_out.data, img_out.linesize);
    1028          
     1037
    10291038            if (pipActive)
    10301039            {
    10311040                AVPicture img_padded;
     
    10381047                               pip_display_size.height(),
    10391048                               pip_display_size.width(),
    10401049                               PIX_FMT_YUV420P, 10, 10, 10, 10, color);
    1041                
     1050
    10421051                pipbuf = pip_tmp_buf2;
    10431052            }
    10441053            else
     
    10641073
    10651074    uint pip_height = pip_tmp_image.height;
    10661075    uint height[3] = { pip_height, pip_height>>1, pip_height>>1 };
    1067    
     1076
    10681077    for (int p = 0; p < 3; p++)
    10691078    {
    10701079        for (uint h = 2; h < height[p]; h++)
    10711080        {
    1072             memcpy((frame->buf + frame->offsets[p]) + (h + yoff2[p]) * 
     1081            memcpy((frame->buf + frame->offsets[p]) + (h + yoff2[p]) *
    10731082                   frame->pitches[p] + xoff2[p],
    10741083                   (pip_tmp_image.buf + pip_tmp_image.offsets[p]) + h *
    10751084                   pip_tmp_image.pitches[p], pip_tmp_image.pitches[p]);
     
    12481257 *  converted to greyscale.
    12491258 *
    12501259 * \return 1 if changed, -1 on error and 0 otherwise
    1251  */ 
     1260 */
    12521261int VideoOutput::DisplayOSD(VideoFrame *frame, OSD *osd, int stride,
    12531262                            int revision)
    12541263{
     
    13121321/**
    13131322 * \fn VideoOutput::CopyFrame(VideoFrame*, const VideoFrame*)
    13141323 * \brief Copies frame data from one VideoFrame to another.
    1315  * 
     1324 *
    13161325 *  Note: The frames must have the same width, height, and format.
    13171326 * \param to   The destination frame.
    1318  * \param from The source frame 
     1327 * \param from The source frame
    13191328 */
    13201329void VideoOutput::CopyFrame(VideoFrame *to, const VideoFrame *from)
    13211330{
     
    13361345        memcpy(to->buf + to->offsets[1], from->buf + from->offsets[1],
    13371346               from->pitches[1] * (from->height>>1));
    13381347        memcpy(to->buf + to->offsets[2], from->buf + from->offsets[2],
    1339                from->pitches[2] * (from->height>>1));       
     1348               from->pitches[2] * (from->height>>1));
    13401349    }
    13411350    else
    13421351    {
  • mythtv/programs/mythfrontend/globalsettings.cpp

     
    24172417{
    24182418    HostComboBox *gc = new HostComboBox("AdjustFill");
    24192419    gc->setLabel(QObject::tr("Zoom"));
     2420    gc->addSelection(toString(kAdjustFill_AutoDetect_DefaultOff), QString::number(kAdjustFill_AutoDetect_DefaultOff));
     2421    gc->addSelection(toString(kAdjustFill_AutoDetect_DefaultHalf), QString::number(kAdjustFill_AutoDetect_DefaultHalf));
    24202422    for (int m = kAdjustFill_Off; m < kAdjustFill_END; m++)
    24212423        gc->addSelection(toString((AdjustFillMode)m), QString::number(m));
    24222424    gc->setHelpText(QObject::tr(