Ticket #1822: xvmc_dvd_menu_attempt3.diff

File xvmc_dvd_menu_attempt3.diff, 12.3 KB (added by skamithi, 20 years ago)

attempt 3. basically attempt 2 patch, cleaned up... with some changes to dvdringbufferpriv. added seekLock mutex so only on thread can access the seek function at any time. It actually fixed the problem I noted with mergedFB in #2215. It may actually fix the original problem reported in #2215..who knows :)

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    848848
    849849void NuppelVideoPlayer::SetVideoParams(int width, int height, double fps,
    850850                                       int keyframedistance, float aspect,
    851                                        FrameScanType scan)
     851                                       FrameScanType scan, bool video_codec_changed)
    852852{
    853853    if (width == 0 || height == 0 || isnan(aspect) || isnan(fps))
    854854        return;
    855855
    856856    if ((video_width  == width ) && (video_height     == height) &&
    857857        (video_aspect == aspect) && (video_frame_rate == fps   ) &&
    858         ((keyframedistance <= 0) || (keyframedistance == keyframedist)))
     858        ((keyframedistance <= 0) || (keyframedistance == keyframedist)) &&
     859        !video_codec_changed)
    859860    {
    860861        return;
    861862    }
  • libs/libmythtv/avformatdecoder.cpp

     
    292292      disable_passthru(false),
    293293      // DVD
    294294      lastdvdtitle(-1), lastcellstart(0),
    295       dvdmenupktseen(false), dvdvideopause(false)
     295      dvdmenupktseen(false), dvdvideopause(false),
     296      dvd_xvmc_enabled(false), dvd_video_codec_changed(false)
    296297{
    297298    bzero(&params, sizeof(AVFormatParameters));
    298299    bzero(prvpkt, 3 * sizeof(char));
     
    803804        av_free_packet(&pkt1);
    804805        ringBuffer->Seek(0,SEEK_SET);
    805806        ringBuffer->DVD()->IgnoreStillOrWait(false);
     807        QString dec = gContext->GetSetting("PreferredMPEG2Decoder", "ffmpeg");
     808        if (dec.contains("xvmc"))
     809            dvd_xvmc_enabled = true;
    806810    }
    807811    else
    808812    {
     
    944948{
    945949    float aspect_ratio;
    946950
     951    directrendering = false;
     952
    947953    if (selectedStream)
    948954    {
    949955        fps = normalized_fps(stream, enc);
     
    10271033        }
    10281034
    10291035        GetNVP()->SetVideoParams(align_width, align_height, fps,
    1030                                  keyframedist, aspect_ratio, kScan_Detect);
     1036                                 keyframedist, aspect_ratio, kScan_Detect,
     1037                                 dvd_video_codec_changed);
     1038        dvd_video_codec_changed = false;
    10311039    }
    10321040}
    10331041
     
    13651373                        enc->codec_id = CODEC_ID_MPEG2VIDEO;
    13661374                    // HACK -- end
    13671375
     1376                    bool force_xv = false;
     1377                    if (ringBuffer->InDVDMenuOrStillFrame() &&
     1378                        dvd_xvmc_enabled)
     1379                    {
     1380                        force_xv = true;
     1381                        enc->pix_fmt = PIX_FMT_YUV420P;
     1382                    }
     1383                   
    13681384                    MythCodecID mcid;
    13691385                    mcid = VideoOutputXv::GetBestSupportedCodec(
    13701386                        /* disp dim     */ enc->width, enc->height,
    13711387                        /* osd dim      */ /*enc->width*/ 0, /*enc->height*/ 0,
    13721388                        /* mpeg type    */ xvmc_stream_type(enc->codec_id),
    13731389                        /* xvmc pix fmt */ xvmc_pixel_format(enc->pix_fmt),
    1374                         /* test surface */ kCodec_NORMAL_END > video_codec_id);
     1390                        /* test surface */ kCodec_NORMAL_END > video_codec_id,
     1391                        /* force_xv     */ force_xv);
    13751392                    bool vcd, idct, mc;
    13761393                    enc->codec_id = myth2av_codecid(mcid, vcd, idct, mc);
     1394                    if (mcid != video_codec_id)
     1395                        dvd_video_codec_changed = true;
    13771396                    video_codec_id = mcid;
    1378                     if (kCodec_NORMAL_END < mcid && kCodec_STD_XVMC_END > mcid)
     1397                    if (!force_xv && kCodec_NORMAL_END < mcid && kCodec_STD_XVMC_END > mcid)
    13791398                    {
    13801399                        enc->pix_fmt = (idct) ?
    13811400                            PIX_FMT_XVMC_MPEG2_IDCT : PIX_FMT_XVMC_MPEG2_MC;
     
    28302849            {
    28312850                int current_width = curstream->codec->width;
    28322851                int video_width = GetNVP()->GetVideoWidth();
    2833                 if (video_width > 0 && video_width != current_width)
     2852                bool switch_to_xv = false;
     2853                bool switch_to_xvmc = false;
     2854                if (dvd_xvmc_enabled && GetNVP() && GetNVP()->getVideoOutput())
    28342855                {
     2856                    bool dvd_xvmc_active = GetNVP()->getVideoOutput()->hasMCAcceleration();
     2857                    bool indvdmenu   = ringBuffer->InDVDMenuOrStillFrame();
     2858                    if (indvdmenu && dvd_xvmc_active)
     2859                        switch_to_xv = true;
     2860                    else if (!indvdmenu && !dvd_xvmc_active)
     2861                        switch_to_xvmc = true;
     2862                }
     2863               
     2864                if ((video_width > 0 && video_width != current_width) ||
     2865                    switch_to_xv || switch_to_xvmc)
     2866                {
    28352867                    av_free_packet(pkt);
    28362868                    CloseCodecs();
    28372869                    ScanStreams(false);
     2870                    QMutexLocker locker(&avcodeclock);
    28382871                    allowedquit = true;
    28392872                    if (ringBuffer->DVD()->InStillFrame())
    2840                     {
    2841                         long long cellstartpos = ringBuffer->DVD()->GetCellStartPos();
    2842                         ringBuffer->DVD()->Seek(cellstartpos, SEEK_SET);
    2843                     }
     2873                        ringBuffer->DVD()->SeekCellStart();
    28442874                    continue;
    28452875                }
    28462876            }
  • libs/libmythtv/DVDRingBuffer.cpp

     
    6969            (NumMenuButtons() > 0));
    7070}
    7171
     72long long DVDRingBufferPriv::NormalSeek(long long pos, int whence)
     73{
     74    QMutexLocker lock(&seekLock);
     75    return Seek(pos, whence);
     76}
     77
    7278long long DVDRingBufferPriv::Seek(long long pos, int whence)
    7379{
    7480    dvdnav_status_t dvdRet = dvdnav_sector_search(this->dvdnav, pos / DVD_BLOCK_SIZE , whence);
     
    900906    return currentTime;
    901907}
    902908
    903 long long DVDRingBufferPriv::GetCellStartPos(void)
    904 {
    905     gotoCellStart = true;
    906     return cellstartPos;
    907 }
    908 
    909909uint DVDRingBufferPriv::GetAudioLanguage(int id)
    910910{
    911911    int8_t channel = dvdnav_get_audio_logical_stream(dvdnav,id);
     
    10201020    return false;
    10211021}
    10221022
     1023void DVDRingBufferPriv::SeekCellStart(void)
     1024{
     1025    QMutexLocker lock(&seekLock);
     1026    gotoCellStart = true;
     1027    Seek(cellstartPos, SEEK_SET);
     1028}
     1029
    10231030/**
    10241031 * \brief converts palette values from YUV to RGB
    10251032 */
  • libs/libmythtv/NuppelVideoPlayer.h

     
    151151    void SetBookmark(void);
    152152    void SetKeyframeDistance(int keyframedistance);
    153153    void SetVideoParams(int w, int h, double fps, int keydist,
    154                         float a = 1.33333, FrameScanType scan = kScan_Ignore);
     154                        float a = 1.33333, FrameScanType scan = kScan_Ignore,
     155                        bool video_codec_changed = false);
    155156    void SetFileLength(int total, int frames);
    156157    void Zoom(int direction);
    157158    void ClearBookmark(void);
  • libs/libmythtv/RingBuffer.cpp

     
    11601160#ifdef USING_FRONTEND
    11611161    else if (dvdPriv)
    11621162    {
    1163         dvdPriv->Seek(pos, whence);
     1163        dvdPriv->NormalSeek(pos, whence);
    11641164    }
    11651165#endif // USING_FRONTEND
    11661166    else
  • libs/libmythtv/DVDRingBuffer.h

     
    5050    void ReleaseMenuButton(void);
    5151
    5252    bool IgnoringStillorWait(void) { return skipstillorwait; }
    53     long long GetCellStartPos(void);
    5453    uint ButtonPosX(void) { return hl_startx; }
    5554    uint ButtonPosY(void) { return hl_starty; }
    5655    uint GetAudioLanguage(int id);
     
    8079    bool nextTrack(void);
    8180    void prevTrack(void);
    8281    int  safe_read(void *data, unsigned sz);
    83     long long Seek(long long pos, int whence);
     82    long long NormalSeek(long long pos, int whence);
    8483    void SkipStillFrame(void);
    8584    void WaitSkip(void);
    8685    void GoToMenu(const QString str);
     
    9897    int   GetTrack(uint type);
    9998    uint8_t GetNumAudioChannels(int id);
    10099    void JumpToTitle(bool change) { jumptotitle = change; }
    101    
     100    void SeekCellStart(void);
     101
    102102    void SetParent(NuppelVideoPlayer *p) { parent = p; }
     103
     104
    103105   
    104106  protected:
    105107    dvdnav_t      *dvdnav;
     
    160162    NuppelVideoPlayer *parent;
    161163
    162164    QMutex menuBtnLock;
     165    QMutex seekLock;
    163166
     167    long long Seek(long long pos, int whence);
    164168    bool DrawMenuButton(uint8_t *spu_pkt, int buf_size);
    165169    bool DVDButtonUpdate(bool b_mode);
    166170    void ClearMenuSPUParameters(void);
  • libs/libmythtv/videoout_xv.h

     
    9494    static MythCodecID GetBestSupportedCodec(uint width, uint height,
    9595                                             uint osd_width, uint osd_height,
    9696                                             uint stream_type, int xvmc_chroma,
    97                                              bool test_surface);
     97                                             bool test_surface, bool force_xv);
    9898
    9999    static int GrabSuitableXvPort(Display* disp, Window root,
    100100                                  MythCodecID type,
     
    144144    bool CreateBuffers(VOSType subtype);
    145145    vector<void*> CreateXvMCSurfaces(uint num, bool create_xvmc_blocks);
    146146    vector<unsigned char*> CreateShmImages(uint num, bool use_xv);
    147     void CreatePauseFrame(void);
     147    void CreatePauseFrame(VOSType subtype);
    148148    void CopyFrame(VideoFrame *to, const VideoFrame *from);
    149149
    150150    void DeleteBuffers(VOSType subtype, bool delete_pause_frame);
  • libs/libmythtv/videoout_xv.cpp

     
    649649 *
    650650 * \sideeffect sets av_pause_frame.
    651651 */
    652 void VideoOutputXv::CreatePauseFrame(void)
     652void VideoOutputXv::CreatePauseFrame(VOSType subtype)
    653653{
    654654    // All methods but XvMC use a pause frame, create it if needed
    655     if (VideoOutputSubType() <= XVideo)
     655    if (subtype <= XVideo)
    656656    {
    657657        vbuffers.LockFrame(&av_pause_frame, "CreatePauseFrame");
    658658
     
    992992MythCodecID VideoOutputXv::GetBestSupportedCodec(
    993993    uint width,       uint height,
    994994    uint osd_width,   uint osd_height,
    995     uint stream_type, int xvmc_chroma,    bool test_surface)
     995    uint stream_type, int xvmc_chroma,   
     996    bool test_surface, bool force_xv)
    996997{
    997998    (void)width, (void)height, (void)osd_width, (void)osd_height;
    998999    (void)stream_type, (void)xvmc_chroma, (void)test_surface;
    9991000
     1001    if (force_xv)
     1002        return (MythCodecID)(kCodec_MPEG1 + (stream_type-1));
    10001003#ifdef USING_XVMC
    10011004    Display *disp = MythXOpenDisplay();
    10021005
     
    17191722    }
    17201723
    17211724    if (ok)
    1722         CreatePauseFrame();
     1725        CreatePauseFrame(subtype);
    17231726
    17241727    return ok;
    17251728}
  • libs/libmythtv/avformatdecoder.h

     
    255255    uint lastcellstart;
    256256    bool dvdmenupktseen;
    257257    bool dvdvideopause;
     258    bool dvd_xvmc_enabled;
     259    bool dvd_video_codec_changed;
    258260
    259261};
    260262
  • libs/libavcodec/mpeg12.c

     
    20782078    s->mpeg_enc_ctx.picture_number = 0;
    20792079    s->repeat_field = 0;
    20802080    s->mpeg_enc_ctx.codec_id= avctx->codec->id;
     2081    avctx->xvmc_acceleration = 0;
     2082    avctx->xvmc_vld_hwslice  = 0;
    20812083    return 0;
    20822084}
    20832085