Ticket #5643: mythtv_refresh_rate_auto_pickv2.patch

File mythtv_refresh_rate_auto_pickv2.patch, 8.1 KB (added by henrik.sorensen@…, 16 years ago)
  • mythtv/libs/libmythtv/NuppelVideoPlayer.cpp

     
    633633            GetDecoder()->GetVideoCodecID(),
    634634            GetDecoder()->GetVideoCodecPrivate(),
    635635            video_disp_dim, video_aspect,
    636             widget->winId(), display_rect, 0 /*embedid*/);
     636            widget->winId(), display_rect, (video_frame_rate * play_speed),
     637            0 /*embedid*/);
    637638
    638639        if (!videoOutput)
    639640        {
     
    648649        videoOutput->SetVideoScalingAllowed(db_scale);
    649650
    650651        // We need to tell it this for automatic deinterlacer settings
    651         videoOutput->SetVideoFrameRate(video_frame_rate * play_speed);
     652        //videoOutput->SetVideoFrameRate(video_frame_rate * play_speed);
    652653
    653654        if (videoOutput->hasMCAcceleration() && !decode_extra_audio)
    654655        {
  • mythtv/libs/libmythtv/videooutbase.cpp

     
    6767        void          *codec_priv,
    6868        const QSize   &video_dim, float        video_aspect,
    6969        WId            win_id,    const QRect &display_rect,
     70        float          video_playback_rate,
    7071        WId            embed_id)
    7172{
    7273    (void) codec_priv;
     
    169170            if (vo->Init(
    170171                    video_dim.width(), video_dim.height(), video_aspect,
    171172                    win_id, display_rect.x(), display_rect.y(),
    172                     display_rect.width(), display_rect.height(), embed_id))
     173                    display_rect.width(), display_rect.height(),
     174                    video_playback_rate, embed_id))
    173175            {
    174176                return vo;
    175177            }
     
    363365 * \return true if successful, false otherwise.
    364366 */
    365367bool VideoOutput::Init(int width, int height, float aspect, WId winid,
    366                        int winx, int winy, int winw, int winh, WId embedid)
     368                       int winx, int winy, int winw, int winh,
     369                       float prate, WId embedid)
    367370{
    368371    (void)winid;
    369372    (void)embedid;
     
    389392
    390393    embedding = false;
    391394
     395    SetVideoFrameRate(prate);
     396
    392397    return true;
    393398}
    394399
     
    405410
    406411void VideoOutput::SetVideoFrameRate(float playback_fps)
    407412{
     413    video_playback_rate = playback_fps;
    408414    db_vdisp_profile->SetOutput(playback_fps);
    409415}
    410416
  • mythtv/libs/libmythtv/videoout_xv.h

     
    6060   ~VideoOutputXv();
    6161
    6262    bool Init(int width, int height, float aspect, WId winid,
    63               int winx, int winy, int winw, int winh, WId embedid = 0);
     63              int winx, int winy, int winw, int winh,
     64              float videoPlaybackRate, WId embedid = 0);
    6465
    6566    bool SetDeinterlacingEnabled(bool);
    6667    bool SetupDeinterlace(bool interlaced, const QString& ovrf="");
  • mythtv/libs/libmythtv/videoout_xv.cpp

     
    405405    if ((width == 1920 || width == 1440) && height == 1088)
    406406        height = 1080; // ATSC 1920x1080
    407407
    408     if (display_res && display_res->SwitchToVideo(width, height))
     408    if (display_res && display_res->SwitchToVideo(width, height, (short) roundf(video_playback_rate)))
    409409    {
    410410        // Switching to custom display resolution succeeded
    411411        // Make a note of the new size
     
    15751575 */
    15761576bool VideoOutputXv::Init(
    15771577    int width, int height, float aspect,
    1578     WId winid, int winx, int winy, int winw, int winh, WId embedid)
     1578    WId winid, int winx, int winy, int winw, int winh,
     1579    float prate, WId embedid)
    15791580{
    15801581    needrepaint = true;
    15811582
     
    16091610    // Basic setup
    16101611    VideoOutput::Init(width, height, aspect,
    16111612                      winid, winx, winy, winw, winh,
    1612                       embedid);
     1613                      prate, embedid);
    16131614
    16141615    // Set resolution/measurements (check XRandR, Xinerama, config settings)
    16151616    InitDisplayMeasurements(width, height);
  • mythtv/libs/libmythtv/videooutbase.h

     
    3636        void          *codec_priv,
    3737        const QSize   &video_dim, float        video_aspect,
    3838        WId            win_id,    const QRect &display_rect,
     39        float          video_playback_rate,
    3940        WId            embed_id);
    4041
    4142    VideoOutput();
     
    4344
    4445    virtual bool Init(int width, int height, float aspect,
    4546                      WId winid, int winx, int winy, int winw,
    46                       int winh, WId embedid = 0);
     47                      int winh, float video_playback_rate, WId embedid = 0);
    4748    virtual void InitOSD(OSD *osd);
    4849    virtual void SetVideoFrameRate(float);
    4950
     
    276277    QSize   video_dim;        ///< Pixel dimensions of video buffer
    277278    QSize   video_disp_dim;   ///< Pixel dimensions of video display area
    278279    float   video_aspect;     ///< Physical aspect ratio of video
     280    float   video_playback_rate;  ///< Playback frame rate of video
    279281
    280282    /// Normally this is the same as videoAspect, but may not be
    281283    /// if the user has toggled the aspect override mode.
  • mythtv/libs/libmyth/DisplayRes.cpp

     
    3737    // Initialize GUI mode
    3838    mode[GUI].Init();
    3939    tW = tH = 0;
    40     gContext->GetResolutionSetting("GuiVidMode", tW, tH);
     40    gContext->GetResolutionSetting("GuiVidMode", tW, tH, tAspect, tRate);
    4141    GetDisplaySize(tW_mm, tH_mm);
    4242    gContext->GetResolutionSetting("DisplaySize", tW_mm, tH_mm);
    43     mode[GUI] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, 0);
     43    mode[GUI] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, tRate);
    4444
    4545
    4646    // Initialize default VIDEO mode
     
    8686{
    8787    tmode next_mode = VIDEO; // default VIDEO mode
    8888    DisplayResScreen next = mode[next_mode];
     89    next.AddRefreshRate(irate);
    8990
    9091    // try to find video override mode
    9192    uint key = DisplayResScreen::CalcKey(iwidth, iheight, irate);
     
    130131    // need to change video mode?
    131132    short target_rate = 0;
    132133    DisplayResScreen::FindBestMatch(GetVideoModes(), next, target_rate);
    133     bool chg = !(next == last) || !(last.RefreshRate() == target_rate);
     134    // If GuiVidModeRefreshRate is 0, assume any refresh rate is good enough.
     135    bool chg = !(next == last) || (next.RefreshRate() !=0 && !(last.RefreshRate() == target_rate));
    134136
    135137    VERBOSE(VB_PLAYBACK, QString("Trying %1x%2 %3 Hz")
    136138            .arg(next.Width()).arg(next.Height()).arg(target_rate));
  • mythtv/libs/libmyth/DisplayResScreen.cpp

     
    8989        if (dsr[i].Width()==d.Width() && dsr[i].Height()==d.Height())
    9090        {
    9191            const vector<short>& rates = dsr[i].RefreshRates();
    92             if (rates.size())
     92            if (rates.size() && d.RefreshRate() != 0)
    9393            {
    94                 vector<short>::const_iterator it =
    95                     find(rates.begin(), rates.end(), d.RefreshRate());
    96                 target_rate = (it == rates.end()) ? *(--rates.end()) : *it;
    97                 return i;
     94                for (uint j=0; j < rates.size(); ++j)
     95                {
     96                    // Multiple of target_rate will do
     97                    if (rates[j] % d.RefreshRate() == 0)
     98                    {
     99                        target_rate = rates[j];
     100                        return i;
     101                    }
     102                }
     103                target_rate = rates[rates.size() - 1];
    98104            }
     105            return i;
    99106        }
    100107    }
    101108    return -1;