Ticket #4567: 4567-v3.patch

File 4567-v3.patch, 34.0 KB (added by danielk, 12 years ago)

Patch that also makes sure that the NVP and videoouput classes use the right video frame size (buffer vs. displayed).

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    170170      totalFrames(0),               totalLength(0),
    171171      rewindtime(0),                m_recusage(inUseID),
    172172      // Input Video Attributes
    173       video_width(0), video_height(0), video_size(0),
     173      video_disp_dim(0,0), video_dim(0,0),
    174174      video_frame_rate(29.97f), video_aspect(4.0f / 3.0f),
    175175      forced_video_aspect(-1),
    176176      m_scan(kScan_Interlaced),     m_scan_locked(false),
     
    592592    if (using_null_videoout)
    593593    {
    594594        videoOutput = new VideoOutputNull();
    595         if (!videoOutput->Init(video_width, video_height, video_aspect,
    596                                0, 0, 0, 0, 0, 0))
     595        if (!videoOutput->Init(video_disp_dim.width(), video_disp_dim.height(),
     596                               video_aspect, 0, 0, 0, 0, 0, 0))
    597597        {
    598598            errored = true;
    599599            return false;
     
    626626            return false;
    627627        }
    628628
    629         const QSize video_dim(video_width, video_height);
    630629        const QRect display_rect(0, 0, widget->width(), widget->height());
    631630
    632631        videoOutput = VideoOutput::Create(
    633632            GetDecoder()->GetCodecDecoderName(),
    634633            GetDecoder()->GetVideoCodecID(),
    635634            GetDecoder()->GetVideoCodecPrivate(),
    636             video_dim, video_aspect,
     635            video_disp_dim, video_aspect,
    637636            widget->winId(), display_rect, 0 /*embedid*/);
    638637
    639638        if (!videoOutput)
     
    701700
    702701    float aspect = (forced_video_aspect > 0) ? forced_video_aspect : video_aspect;
    703702
    704     videoOutput->InputChanged(QSize(video_width, video_height), aspect,
     703    videoOutput->InputChanged(video_disp_dim, aspect,
    705704                              GetDecoder()->GetVideoCodecID(),
    706705                              GetDecoder()->GetVideoCodecPrivate());
    707706
     
    989988    if (width == 0 || height == 0 || isnan(aspect) || isnan(fps))
    990989        return;
    991990
    992     if ((video_width  == width ) && (video_height     == height) &&
     991    if ((video_disp_dim == QSize(width, height)) &&
    993992        (video_aspect == aspect) && (video_frame_rate == fps   ) &&
    994993        ((keyframedistance <= 0) || (keyframedistance == keyframedist)) &&
    995994        !video_codec_changed)
     
    997996        return;
    998997    }
    999998
    1000     video_width  = (width  > 0) ? width  : video_width;
    1001     video_height = (height > 0) ? height : video_height;
    1002     video_size   = (video_height * video_width * 3) / 2;
     999    video_dim    = QSize((width + 15) & ~0xf, (height + 15) & ~0xf);
     1000    video_disp_dim=QSize(width, height);
    10031001    video_aspect = (aspect > 0.0f) ? aspect : video_aspect;
    10041002    keyframedist = (keyframedistance > 0) ? keyframedistance : keyframedist;
    10051003
     
    10171015    if (IsErrored())
    10181016        return;
    10191017
    1020     SetScanType(detectInterlace(scan, m_scan, video_frame_rate, video_height));
     1018    SetScanType(detectInterlace(scan, m_scan, video_frame_rate,
     1019                                video_disp_dim.height()));
    10211020    m_scan_locked  = false;
    10221021    m_scan_tracker = (m_scan == kScan_Interlaced) ? 2 : 0;
    10231022}
     
    12381237        VideoFrameType itmp = FMT_YV12;
    12391238        VideoFrameType otmp = FMT_YV12;
    12401239        int btmp;
    1241         postfilt_width = video_width;
    1242         postfilt_height = video_height;
     1240        postfilt_width = video_dim.width();
     1241        postfilt_height = video_dim.height();
    12431242
    12441243        videoFilters = FiltMan->LoadFilters(
    12451244            filters, itmp, otmp, postfilt_width, postfilt_height, btmp);
     
    14821481
    14831482VideoFrame *NuppelVideoPlayer::GetCurrentFrame(int &w, int &h)
    14841483{
    1485     w = video_width;
    1486     h = video_height;
     1484    w = video_dim.width();
     1485    h = video_dim.height();
    14871486
    14881487    VideoFrame *retval = NULL;
    14891488
     
    26342633    {
    26352634        // We need to make a preview copy of the frame...
    26362635        QMutexLocker locker(&yuv_lock);
    2637         QSize vsize = QSize(video_width, video_height);
     2636        QSize vsize = video_dim;
    26382637        if ((vsize            != yuv_scaler_in_size) ||
    26392638            (yuv_desired_size != yuv_scaler_out_size))
    26402639        {
     
    54425441                .arg(m_playbackinfo->recstartts.toString("yyyyMMddhhmmss")));
    54435442    }
    54445443
    5445     if ((video_width <= 0) || (video_height <= 0))
     5444    if ((video_dim.width() <= 0) || (video_dim.height() <= 0))
    54465445    {
    54475446        VERBOSE(VB_PLAYBACK, QString("NVP: Video Resolution invalid %1x%2")
    5448             .arg(video_width).arg(video_height));
     5447                .arg(video_dim.width()).arg(video_dim.height()));
    54495448
    54505449        // This is probably an audio file, just return a grey frame.
    54515450        vw = 640;
     
    55415540        return NULL;
    55425541    }
    55435542
    5544     avpicture_fill(&orig, data, PIX_FMT_YUV420P, video_width, video_height);
     5543    avpicture_fill(&orig, data, PIX_FMT_YUV420P,
     5544                   video_dim.width(), video_dim.height());
    55455545
    5546     avpicture_deinterlace(&orig, &orig, PIX_FMT_YUV420P, video_width,
    5547                           video_height);
     5546    avpicture_deinterlace(&orig, &orig, PIX_FMT_YUV420P,
     5547                          video_dim.width(), video_dim.height());
    55485548
    5549     bufflen = video_width * video_height * 4;
     5549    bufflen = video_dim.width() * video_dim.height() * 4;
    55505550    outputbuf = new unsigned char[bufflen];
    55515551
    5552     avpicture_fill(&retbuf, outputbuf, PIX_FMT_RGBA32, video_width,
    5553                    video_height);
     5552    avpicture_fill(&retbuf, outputbuf, PIX_FMT_RGBA32,
     5553                   video_dim.width(), video_dim.height());
    55545554
    55555555    img_convert(&retbuf, PIX_FMT_RGBA32, &orig, PIX_FMT_YUV420P,
    5556                 video_width, video_height);
     5556                video_dim.width(), video_dim.height());
    55575557
    5558     vw = video_width;
    5559     vh = video_height;
     5558    vw = video_dim.width();
     5559    vh = video_dim.height();
    55605560    ar = video_aspect;
    55615561
    55625562    DiscardVideoFrame(frame);
     
    67166716                // a 720x576 video resolution to fit the current OSD resolution
    67176717                float vsize = 576.0;
    67186718                if (ringBuffer->isDVD())
    6719                     vsize = (float)video_height;
     6719                    vsize = (float) video_disp_dim.height();
    67206720
    67216721                float hmult = osd->GetSubtitleBounds().width() / 720.0;
    67226722                float vmult = osd->GetSubtitleBounds().height() / vsize;
     
    70277027        }
    70287028
    70297029        // scale highlight image to match OSD size, if required
    7030         float hmult = osd->GetSubtitleBounds().width() / (float)video_width;
    7031         float vmult = osd->GetSubtitleBounds().height() / (float)video_height;
     7030        // TODO FIXME This is pretty bogus, it does not adjust for zooming
     7031        //   or scaling at all, nor does it account for OSD renderers
     7032        //   where the OSD resolution != video resolution.
     7033        float hmult = osd->GetSubtitleBounds().width() /
     7034            (float) video_disp_dim.width();
     7035        float vmult = osd->GetSubtitleBounds().height() /
     7036            (float) video_disp_dim.height();
    70327037
    70337038        if ((hmult < 0.99) || (hmult > 1.01) || (vmult < 0.99) || (vmult > 1.01))
    70347039        {
  • libs/libmythtv/videoout_d3d.cpp

     
    120120    VideoOutput::InputChanged(input_size, aspect, av_codec_id, codec_private);
    121121    db_vdisp_profile->SetVideoRenderer("didect3d");
    122122
    123     if (input_size.width()  == m_InputCX &&
    124         input_size.height() == m_InputCY)
     123    if (video_dim.width() == m_InputCX && video_dim.height() == m_InputCY)
    125124    {
    126125        MoveResize();
    127126        return true;
    128127    }
    129128
    130     m_InputCX = input_size.width();
    131     m_InputCY = input_size.height();
     129    m_InputCX = video_dim.width();
     130    m_InputCY = video_dim.height();
    132131    VERBOSE(VB_PLAYBACK, LOC + "InputChanged, x="<< m_InputCX
    133132            << ", y=" << m_InputCY);
    134133
    135     video_dim = input_size;
    136134    vbuffers.DeleteBuffers();
    137135
    138136    MoveResize();
     
    469467
    470468    m_hWnd = winid;
    471469
    472     m_InputCX  = width;
    473     m_InputCY = height;
     470    m_InputCX = video_dim.width();
     471    m_InputCY = video_dim.height();
    474472
    475     if (!vbuffers.CreateBuffers(width, height))
     473    if (!vbuffers.CreateBuffers(video_dim.width(), video_dim.height()))
    476474        return false;
    477475
    478476    if (!InitD3D())
  • libs/libmythtv/videoout_quartz.cpp

     
    12711271            .arg(input_size.height()).arg(aspect));
    12721272
    12731273    bool cid_changed = (myth_codec_id != av_codec_id);
    1274     bool res_changed = input_size != video_dim;
     1274    bool res_changed = input_size != video_disp_dim;
    12751275    bool asp_changed = aspect != video_aspect;
    12761276
    12771277    VideoOutput::InputChanged(input_size, aspect, av_codec_id, codec_private);
     
    13031303
    13041304    DeleteQuartzBuffers();
    13051305
    1306     data->srcWidth  = input_size.width();
    1307     data->srcHeight = input_size.height();
     1306    data->srcWidth  = video_dim.width();
     1307    data->srcHeight = video_dim.height();
    13081308    data->srcAspect = aspect;
    13091309    data->srcMode   = db_aspectoverride;
    13101310
     
    13591359    VideoOutput::Init(width, height, aspect, winid,
    13601360                      winx, winy, winw, winh, embedid);
    13611361
    1362     data->srcWidth  = width;
    1363     data->srcHeight = height;
     1362    data->srcWidth  = video_dim.width();
     1363    data->srcHeight = video_dim.height();
    13641364    data->srcAspect = aspect;
    13651365    data->srcMode   = db_aspectoverride;
    13661366
  • libs/libmythtv/avformatdecoder.cpp

     
    7070                       int offset[4], int y, int type, int height);
    7171void decode_cc_dvd(struct AVCodecContext *c, const uint8_t *buf, int buf_size);
    7272
    73 static void align_dimensions(AVCodecContext *avctx, uint &width, uint &height)
    74 {
    75     // minimum buffer alignment
    76     avcodec_align_dimensions(avctx, (int*)&width, (int*)&height);
    77     // minimum MPEG alignment
    78     width  = (width  + 15) & (~0xf);
    79     height = (height + 15) & (~0xf);
    80 }
    81 
    8273static void myth_av_log(void *ptr, int level, const char* fmt, va_list vl)
    8374{
    8475    static QString full_line("");
     
    11401131
    11411132    if (selectedStream)
    11421133    {
    1143         uint align_width  = enc->width;
    1144         uint align_height = enc->height;
     1134        uint width  = enc->width;
     1135        uint height = enc->height;
    11451136
    1146         align_dimensions(enc, align_width, align_height);
    1147 
    1148         if (align_width == 0 && align_height == 0)
     1137        if (width == 0 && height == 0)
    11491138        {
    11501139            VERBOSE(VB_PLAYBACK, LOC + "InitVideoCodec "
    1151                     "failed to align dimensions, resetting decoder.");
    1152             align_width = 640;
    1153             align_height = 480;
     1140                    "invalid dimensions, resetting decoder.");
     1141            width = 640;
     1142            height = 480;
    11541143            fps = 29.97;
    11551144            aspect_ratio = 4.0 / 3;
    11561145        }
    11571146
    1158         GetNVP()->SetVideoParams(align_width, align_height, fps,
     1147        GetNVP()->SetVideoParams(width, height, fps,
    11591148                                 keyframedist, aspect_ratio, kScan_Detect,
    11601149                                 dvd_video_codec_changed);
    11611150    }
     
    23532342
    23542343            if (changed)
    23552344            {
    2356                 uint awidth = width, aheight = height;
    2357                 align_dimensions(context, awidth, aheight);
    2358 
    2359                 GetNVP()->SetVideoParams(awidth, aheight, seqFPS,
     2345                GetNVP()->SetVideoParams(width, height, seqFPS,
    23602346                                         keyframedist, aspect,
    23612347                                         kScan_Detect);
    23622348               
     
    24332419
    24342420        if (changed)
    24352421        {
    2436             uint awidth = width, aheight = height;
    2437             align_dimensions(context, awidth, aheight);
    2438 
    2439             GetNVP()->SetVideoParams(awidth, aheight, seqFPS,
     2422            GetNVP()->SetVideoParams(width, height, seqFPS,
    24402423                                     keyframedist, aspect_ratio,
    24412424                                     kScan_Detect);
    24422425
     
    32073190            if (!d->HasMPEG2Dec())
    32083191            {
    32093192                int current_width = curstream->codec->width;
    3210                 int video_width = GetNVP()->GetVideoWidth();
     3193                int video_width = GetNVP()->GetVideoDisplayedDim().width();
    32113194                if (dvd_xvmc_enabled && GetNVP() && GetNVP()->getVideoOutput())
    32123195                {
    32133196                    bool dvd_xvmc_active = false;
  • libs/libmythtv/DVDRingBuffer.cpp

     
    10211021    if (!parent)
    10221022        return false;
    10231023
    1024     int videoheight = parent->GetVideoHeight();
    1025     int videowidth = parent->GetVideoWidth();
     1024    QSize video_disp_dim = parent->GetVideoDisplayedDim();
     1025    int videoheight = video_disp_dim.height();
     1026    int videowidth = video_disp_dim.width();
    10261027
    10271028    int32_t button;
    10281029    pci_t *pci;
  • libs/libmythtv/videoout_directfb.cpp

     
    344344    return v;
    345345}
    346346
     347/// Correct for underalignment
     348static QSize fix_alignment(QSize raw)
     349{
     350    return QSize((raw.width()  + 15) & (~0xf),
     351                 (raw.height() + 15) & (~0xf));
     352}
     353
    347354bool VideoOutputDirectfb::Init(int width, int height, float aspect, WId winid,
    348355                               int winx, int winy, int winw, int winh,
    349356                               WId embedid)
     
    467474        return false;
    468475    }
    469476
     477    video_dim = fix_alignment(QSize(width, height));
     478
    470479    // Find an output layer that supports a format we can deal with.
    471480    // begin with the video format we have as input, fall back to others
    472481
    473482    data->videoLayerConfig.flags = (DFBDisplayLayerConfigFlags)
    474483        (DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT);
    475     data->videoLayerConfig.width = width;
    476     data->videoLayerConfig.height = height;
     484    data->videoLayerConfig.width = video_dim.width();
     485    data->videoLayerConfig.height = video_dim.height();
    477486    data->videoLayerConfig.pixelformat = DSPF_I420;
    478487
    479488    fberr = data->dfb->EnumDisplayLayers(data->dfb, layer_cb, data);
     
    607616                  kKeepPrebuffer);
    608617    desc.flags = (DFBSurfaceDescriptionFlags)
    609618        (DSDESC_HEIGHT | DSDESC_WIDTH | DSDESC_PIXELFORMAT);
    610     desc.width = width;
    611     desc.height = height;
     619    desc.width = video_dim.width();
     620    desc.height = video_dim.height();
    612621    desc.pixelformat = data->videoLayerConfig.pixelformat;
    613622
    614623    if (!data->CreateBuffers(vbuffers, desc))
     
    913922
    914923    desc.flags = (DFBSurfaceDescriptionFlags)
    915924        (DSDESC_HEIGHT | DSDESC_WIDTH | DSDESC_PIXELFORMAT);
    916     desc.width  = input_size.width();
    917     desc.height = input_size.height();
     925    desc.width  = video_dim.width();
     926    desc.height = video_dim.height();
    918927    desc.pixelformat = data->videoLayerConfig.pixelformat;
    919928
    920929    data->DeleteBuffers(vbuffers);
  • libs/libmythtv/NuppelVideoPlayer.h

     
    177177    void ToggleAdjustFill(AdjustFillMode adjustfillMode = kAdjustFill_Toggle);
    178178
    179179    // Gets
    180     int     GetVideoWidth(void) const         { return video_width; }
    181     int     GetVideoHeight(void) const        { return video_height; }
     180    QSize   GetVideoBufferDim(void) const     { return video_dim; }
     181    QSize   GetVideoDisplayedDim(void) const  { return video_disp_dim; }
    182182    float   GetVideoAspect(void) const        { return video_aspect; }
    183183    float   GetFrameRate(void) const          { return video_frame_rate; }
    184184
     
    591591
    592592
    593593    // Input Video Attributes
    594     int      video_width;     ///< Video (input) width
    595     int      video_height;    ///< Video (input) height
    596     int      video_size;      ///< Video (input) buffer size in bytes
     594    QSize    video_disp_dim;  ///< Video (input) width & height
     595    QSize    video_dim;       ///< Video (input) buffer width & height
    597596    double   video_frame_rate;///< Video (input) Frame Rate (often inaccurate)
    598597    float    video_aspect;    ///< Video (input) Apect Ratio
    599598    float    forced_video_aspect;
  • libs/libmythtv/videoout_null.cpp

     
    7979
    8080    QMutexLocker locker(&global_lock);
    8181
     82    bool res_changed = input_size != video_disp_dim;
     83
    8284    VideoOutput::InputChanged(input_size, aspect, av_codec_id, codec_private);
    8385
    84     if (input_size.width()  == vbuffers.GetScratchFrame()->width &&
    85         input_size.height() == vbuffers.GetScratchFrame()->height)
     86    if (!res_changed)
    8687    {
    8788        vbuffers.Clear(GUID_I420_PLANAR);
    8889        MoveResize();
    8990        return true;
    9091    }
    9192
    92     video_dim = input_size;
    93 
    9493    vbuffers.DiscardFrames(true);
    9594    vbuffers.DeleteBuffers();
    9695
     
    123122
    124123    QMutexLocker locker(&global_lock);
    125124
     125    VideoOutput::Init(width, height, aspect, winid,
     126                      winx, winy, winw, winh, embedid);
     127
    126128    vbuffers.Init(kNumBuffers, true, kNeedFreeFrames,
    127129                  kPrebufferFramesNormal, kPrebufferFramesSmall,
    128130                  kKeepPrebuffer);
    129     VideoOutput::Init(width, height, aspect, winid,
    130                       winx, winy, winw, winh, embedid);
    131131
    132     video_dim = QSize(width, height);
    133 
    134     if (!vbuffers.CreateBuffers(width, height))
     132    if (!vbuffers.CreateBuffers(video_dim.width(), video_dim.height()))
    135133        return false;
     134
    136135    CreatePauseFrame();
    137136
    138137    db_vdisp_profile->SetVideoRenderer("null");
  • libs/libmythtv/videooutbase.cpp

     
    4747#define LOC_ERR QString("VideoOutput, Error: ")
    4848
    4949static QSize fix_1080i(QSize raw);
     50static QSize fix_alignment(QSize raw);
    5051static float fix_aspect(float raw);
    5152static QString to_comma_list(const QStringList &list);
    5253
     
    375376    }
    376377
    377378    display_visible_rect = QRect(0, 0, winw, winh);
    378     video_dim            = QSize(width, height);
    379     video_rect           = QRect(QPoint(winx, winy), fix_1080i(video_dim));
     379    video_disp_dim       = fix_1080i(QSize(width, height));
     380    video_dim            = fix_alignment(QSize(width, height));
     381    video_rect           = QRect(QPoint(winx, winy), video_disp_dim);
    380382
    381383    db_vdisp_profile->SetInput(video_dim);
    382384
     
    603605    (void)myth_codec_id;
    604606    (void)codec_private;
    605607
    606     video_dim = input_size;
     608    video_disp_dim = fix_1080i(input_size);
     609    video_dim      = fix_alignment(input_size);
    607610
    608611    db_vdisp_profile->SetInput(video_dim);
    609612
     
    710713QRect VideoOutput::GetVisibleOSDBounds(
    711714    float &visible_aspect, float &font_scaling, float themeaspect) const
    712715{
    713     float dv_w = ((float)video_dim.width())  / display_video_rect.width();
    714     float dv_h = ((float)video_dim.height()) / display_video_rect.height();
     716    float dv_w = (((float)video_disp_dim.width())  /
     717                  display_video_rect.width());
     718    float dv_h = (((float)video_disp_dim.height()) /
     719                  display_video_rect.height());
    715720
    716721    uint right_overflow = max((display_video_rect.width()
    717722                                + display_video_rect.left())
     
    723728    // top left and bottom right corners respecting letterboxing
    724729    QPoint tl = QPoint((uint) ceil(max(-display_video_rect.left(),0)*dv_w),
    725730                       (uint) ceil(max(-display_video_rect.top(),0)*dv_h));
    726     QPoint br = QPoint((uint) floor(video_dim.width()-(right_overflow*dv_w)),
    727                        (uint) floor(video_dim.height()-(lower_overflow*dv_h)));
     731    QPoint br = QPoint(
     732        (uint) floor(video_disp_dim.width()  - (right_overflow * dv_w)),
     733        (uint) floor(video_disp_dim.height() - (lower_overflow * dv_h)));
    728734    // adjust for overscan
    729735    if ((db_scale_vert > 0.0f) || (db_scale_horiz > 0.0f))
    730736    {
     
    762768 */
    763769QRect VideoOutput::GetTotalOSDBounds(void) const
    764770{
    765     return QRect(QPoint(0, 0), video_dim);
     771    return QRect(QPoint(0, 0), video_disp_dim);
    766772}
    767773
    768774/** \fn VideoOutput::ApplyManualScaleAndMove(void)
     
    869875    if (db_scale_horiz > 0)
    870876    {
    871877        float tmp = 1.0f - 2.0f * db_scale_horiz;
    872         video_rect.moveLeft((int) round(video_dim.width() * db_scale_horiz));
    873         video_rect.setWidth((int) round(video_dim.width() * tmp));
     878        video_rect.moveLeft(
     879            (int) round(video_disp_dim.width() * db_scale_horiz));
     880        video_rect.setWidth((int) round(video_disp_dim.width() * tmp));
    874881
    875882        int xoff = db_move.x();
    876883        if (xoff > 0)
     
    11021109void VideoOutput::MoveResize(void)
    11031110{
    11041111    // Preset all image placement and sizing variables.
    1105     video_rect         = QRect(QPoint(0, 0), fix_1080i(video_dim));
     1112    video_rect         = QRect(QPoint(0, 0), video_disp_dim);
    11061113    display_video_rect = display_visible_rect;
    11071114
    11081115    // Avoid too small frames for audio only streams (for OSD).
    11091116    if ((video_rect.width() <= 0) || (video_rect.height() <= 0))
    11101117    {
    1111         video_dim  = display_visible_rect.size();
    1112         video_rect = QRect(QPoint(0, 0), video_dim);
     1118        video_disp_dim = display_visible_rect.size();
     1119        video_dim      = fix_alignment(display_visible_rect.size());
     1120        video_rect     = QRect(QPoint(0, 0), video_dim);
    11131121    }
    11141122
    11151123    // Apply various modifications
     
    14111419
    14121420    VideoFrame *pipimage = pipplayer->GetCurrentFrame(pipw, piph);
    14131421    float pipVideoAspect = pipplayer->GetVideoAspect();
    1414     uint  pipVideoWidth  = pipplayer->GetVideoWidth();
    1415     uint  pipVideoHeight = pipplayer->GetVideoHeight();
     1422    QSize pipVideoDim    = pipplayer->GetVideoBufferDim();
     1423    uint  pipVideoWidth  = pipVideoDim.width();
     1424    uint  pipVideoHeight = pipVideoDim.height();
    14161425
    14171426    // If PiP is not initialized to values we like, silently ignore the frame.
    14181427    if ((video_aspect <= 0) || (pipVideoAspect <= 0) ||
     
    14451454    }
    14461455
    14471456    // adjust for non-square pixels on screen
    1448     float dispPixelAdj = (GetDisplayAspect() * video_dim.height()) /
    1449         video_dim.width();
     1457    float dispPixelAdj =
     1458        (GetDisplayAspect() * video_disp_dim.height())/video_disp_dim.width();
    14501459
    14511460    // adjust for non-square pixels in video
    14521461    float vidPixelAdj  = pipVideoWidth / (pipVideoAspect * pipVideoHeight);
     
    18261835    return raw;
    18271836}
    18281837
     1838/// Correct for underalignment
     1839static QSize fix_alignment(QSize raw)
     1840{
     1841    return QSize((raw.width()  + 15) & (~0xf),
     1842                 (raw.height() + 15) & (~0xf));
     1843}
     1844
    18291845/// Correct for rounding errors
    18301846static float fix_aspect(float raw)
    18311847{
  • libs/libmythtv/videoout_xv.cpp

     
    235235    QMutexLocker locker(&global_lock);
    236236
    237237    bool cid_changed = (myth_codec_id != av_codec_id);
    238     bool res_changed = input_size != video_dim;
     238    bool res_changed = input_size != video_disp_dim;
    239239    bool asp_changed = aspect != video_aspect;
    240240
    241241    VideoOutput::InputChanged(input_size, aspect, av_codec_id, codec_private);
     
    253253
    254254    DeleteBuffers(VideoOutputSubType(),
    255255                  cid_changed || (OpenGL == VideoOutputSubType()));
    256     ResizeForVideo((uint) input_size.width(), (uint) input_size.height());
     256    ResizeForVideo((uint) video_disp_dim.width(),
     257                   (uint) video_disp_dim.height());
    257258
    258259    if (cid_changed && (OpenGL != VideoOutputSubType()))
    259260    {
     
    318319    QSize dvr2 = QSize(display_visible_rect.width()  & ~0x3,
    319320                       display_visible_rect.height() & ~0x1);
    320321
    321     QSize sz = (chroma_osd || gl_use_osd_opengl2) ? dvr2 : video_dim;
     322    QSize sz = (chroma_osd || gl_use_osd_opengl2) ? dvr2 : video_disp_dim;
    322323    return QRect(QPoint(0,0), sz);
    323324}
    324325
     
    379380
    380381void VideoOutputXv::ResizeForVideo(void)
    381382{
    382     ResizeForVideo(video_dim.width(), video_dim.height());
     383    ResizeForVideo(video_disp_dim.width(), video_disp_dim.height());
    383384}
    384385
    385386void VideoOutputXv::ResizeForGui(void)
     
    30863087    int pipw, piph;
    30873088    VideoFrame *pipimage = pipplayer->GetCurrentFrame(pipw, piph);
    30883089    float pipVideoAspect = pipplayer->GetVideoAspect();
    3089     uint  pipVideoWidth  = pipplayer->GetVideoWidth();
    3090     uint  pipVideoHeight = pipplayer->GetVideoHeight();
     3090    QSize pipVideoDim    = pipplayer->GetVideoBufferDim();
     3091    uint  pipVideoWidth  = pipVideoDim.width();
     3092    uint  pipVideoHeight = pipVideoDim.height();
    30913093
    30923094    // If PiP is not initialized to values we like, silently ignore the frame.
    30933095    if ((pipVideoAspect <= 0) || !pipimage ||
     
    40734075    QRect position;
    40744076    float pipVideoAspect = 1.3333f;
    40754077    // set height
    4076     int tmph = (video_dim.height() * db_pip_size) / 100;
     4078    int tmph = (video_disp_dim.height() * db_pip_size) / 100;
    40774079    // adjust for aspect override modes...
    40784080    int letterXadj = 0;
    40794081    int letterYadj = 0;
     
    41064108            break;
    41074109        case kPIPBottomLeft:
    41084110            xoff += letterXadj;
    4109             yoff = video_dim.height() - position.height() -
     4111            yoff = video_disp_dim.height() - position.height() -
    41104112                yoff - letterYadj;
    41114113            break;
    41124114        case kPIPTopRight:
    4113             xoff = video_dim.width() - position.width() -
     4115            xoff = video_disp_dim.width() - position.width() -
    41144116                    xoff - letterXadj;
    41154117            yoff = yoff + letterYadj;
    41164118            break;
    41174119        case kPIPBottomRight:
    4118             xoff = video_dim.width() - position.width() -
     4120            xoff = video_disp_dim.width() - position.width() -
    41194121                    xoff - letterXadj;
    4120             yoff = video_dim.height() - position.height() -
     4122            yoff = video_disp_dim.height() - position.height() -
    41214123                   yoff - letterYadj;
    41224124            break;
    41234125    }
  • libs/libmythtv/videooutbase.h

     
    273273    float   display_aspect;   ///< Physical aspect ratio of playback window
    274274
    275275    // Video dimensions
    276     QSize   video_dim;        ///< Pixel dimensions of video
     276    QSize   video_dim;        ///< Pixel dimensions of video buffer
     277    QSize   video_disp_dim;   ///< Pixel dimensions of video display area
    277278    float   video_aspect;     ///< Physical aspect ratio of video
    278279
    279280    /// Normally this is the same as videoAspect, but may not be
  • libs/libmythtv/videoout_ivtv.cpp

     
    418418    VideoOutput::Init(width, height, aspect, winid, winx, winy, winw, winh,
    419419                      embedid);
    420420
    421     osdbufsize = width * height * 4;
     421    osdbufsize = video_dim.width() * video_dim.height() * 4;
    422422
    423423    MoveResize();
    424424
  • libs/libmythtv/videoout_dx.cpp

     
    110110
    111111    db_vdisp_profile->SetVideoRenderer("directx");
    112112
    113     XJ_width  = input_size.width();
    114     XJ_height = input_size.height();
     113    XJ_width  = video_dim.width();
     114    XJ_height = video_dim.height();
    115115
    116116    vbuffers.DeleteBuffers();
    117117   
     
    171171
    172172    wnd = winid;
    173173
    174     XJ_width  = width;
    175     XJ_height = height;
     174    XJ_width  = video_dim.width();
     175    XJ_height = video_dim.height();
    176176
    177177    vbuffers.CreateBuffers(XJ_width, XJ_height);
    178178    MoveResize();
  • programs/mythtranscode/transcode.cpp

     
    468468
    469469    QString vidsetting = NULL, audsetting = NULL, vidfilters = NULL;
    470470
    471     int video_width = nvp->GetVideoWidth();
    472     int video_height = nvp->GetVideoHeight();
     471    QSize buf_size = nvp->GetVideoBufferDim();
     472    int video_width = buf_size.width();
     473    int video_height = buf_size.height();
    473474     
    474475    if (video_height == 1088) {
    475476       VERBOSE(VB_IMPORTANT, "Found video height of 1088.  This is unusual and "
     
    864865                    nvr->SetNewVideoParams(video_aspect);
    865866                }
    866867
    867                 if (video_width != nvp->GetVideoWidth() ||
    868                     video_height != nvp->GetVideoHeight())
     868                QSize buf_size = nvp->GetVideoBufferDim();
     869
     870                if (video_width != buf_size.width() ||
     871                    video_height != buf_size.height())
    869872                {
    870                     video_width = nvp->GetVideoWidth();
    871                     video_height = nvp->GetVideoHeight();
     873                    video_width = buf_size.width();
     874                    video_height = buf_size.height();
    872875
    873876                    VERBOSE(VB_IMPORTANT, QString("Resizing from %1x%2 to %3x%4")
    874877                        .arg(video_width).arg(video_height)
     
    926929                nvr->SetNewVideoParams(video_aspect);
    927930            }
    928931
    929             if (video_width != nvp->GetVideoWidth() ||
    930                 video_height != nvp->GetVideoHeight())
     932
     933            QSize buf_size = nvp->GetVideoBufferDim();
     934
     935            if (video_width != buf_size.width() ||
     936                video_height != buf_size.height())
    931937            {
    932                 video_width = nvp->GetVideoWidth();
    933                 video_height = nvp->GetVideoHeight();
     938                video_width = buf_size.width();
     939                video_height = buf_size.height();
     940
    934941                VERBOSE(VB_IMPORTANT, QString("Resizing from %1x%2 to %3x%4")
    935942                        .arg(video_width).arg(video_height)
    936943                        .arg(newWidth).arg(newHeight));
  • programs/mythcommflag/HistogramAnalyzer.cpp

     
    203203    if (monochromatic)
    204204        return FrameAnalyzer::ANALYZE_OK;
    205205
    206     unsigned int width = nvp->GetVideoWidth();
    207     unsigned int height = nvp->GetVideoHeight();
     206    QSize buf_dim = nvp->GetVideoBufferDim();
     207    unsigned int width  = buf_dim.width();
     208    unsigned int height = buf_dim.height();
    208209
    209210    if (logoFinder && (logo = logoFinder->getTemplate(&logorr1, &logocc1,
    210211                    &logowidth, &logoheight)))
  • programs/mythcommflag/TemplateFinder.cpp

     
    786786    QString tmpldims, nvpdims;
    787787
    788788    (void)nframes; /* gcc */
    789     width = nvp->GetVideoWidth();
    790     height = nvp->GetVideoHeight();
     789    QSize buf_dim = nvp->GetVideoBufferDim();
     790    width  = buf_dim.width();
     791    height = buf_dim.height();
    791792    nvpdims = QString("%1x%2").arg(width).arg(height);
    792793
    793794    if (debug_template)
  • programs/mythcommflag/BlankFrameDetector.cpp

     
    400400
    401401    fps = nvp->GetFrameRate();
    402402
     403    QSize video_disp_dim = nvp->GetVideoDisplayedDim();
     404
    403405    VERBOSE(VB_COMMFLAG, QString(
    404406                "BlankFrameDetector::nuppelVideoPlayerInited %1x%2")
    405             .arg(nvp->GetVideoWidth())
    406             .arg(nvp->GetVideoHeight()));
     407            .arg(video_disp_dim.width())
     408            .arg(video_disp_dim.height()));
    407409
    408410    return ares;
    409411}
  • programs/mythcommflag/SceneChangeDetector.cpp

     
    144144    scdiff = new unsigned short[nframes];
    145145    memset(scdiff, 0, nframes * sizeof(*scdiff));
    146146
     147    QSize video_disp_dim = nvp->GetVideoDisplayedDim();
     148
    147149    VERBOSE(VB_COMMFLAG, QString(
    148150                "SceneChangeDetector::nuppelVideoPlayerInited %1x%2")
    149             .arg(nvp->GetVideoWidth())
    150             .arg(nvp->GetVideoHeight()));
     151            .arg(video_disp_dim.width())
     152            .arg(video_disp_dim.height()));
    151153
    152154    return ares;
    153155}
  • programs/mythcommflag/PGMConverter.cpp

     
    3838    if (width != -1)
    3939        return 0;
    4040
    41     width = nvp->GetVideoWidth();
    42     height = nvp->GetVideoHeight();
     41    QSize buf_dim = nvp->GetVideoBufferDim();
     42    width  = buf_dim.width();
     43    height = buf_dim.height();
    4344
    4445#ifdef PGM_CONVERT_GREYSCALE
    4546    if (avpicture_alloc(&pgm, PIX_FMT_GRAY8, width, height))
  • programs/mythcommflag/ClassicCommDetector.cpp

     
    8787
    8888void ClassicCommDetector::Init()
    8989{
    90     width = nvp->GetVideoWidth();
    91     height = nvp->GetVideoHeight();
     90    QSize video_disp_dim = nvp->GetVideoDisplayedDim();
     91    width  = video_disp_dim.width();
     92    height = video_disp_dim.height();
    9293    fps = nvp->GetFrameRate();
    9394
    9495    preRoll  = (long long)(max(0,recordingStartedAt.secsTo(startedAt)) * fps);