Ticket #1822: xvmc_dvd_menus_attempt1.diff

File xvmc_dvd_menus_attempt1.diff, 14.2 KB (added by skamithi, 18 years ago)

attempt to resolve internal dvd player issues with XVmc. use XV when in dvd menu..turn XVMC back on when watching the main title.

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    254254      isDummy(false),               
    255255      // DVD stuff
    256256      indvdstillframe(false), hidedvdbutton(true),
    257       need_change_dvd_track(0),
     257      need_change_dvd_track(0), dvd_video_codec_changing(false),
    258258      // Debugging variables
    259259      output_jmeter(NULL)
    260260{
     
    596596    vidExitLock.lock();
    597597    videofiltersLock.lock();
    598598
     599    VERBOSE(VB_PLAYBACK, QString("DELETE ME in ReinitVideo"));
    599600    float aspect = (forced_video_aspect > 0) ? forced_video_aspect : video_aspect;
    600601    videoOutput->InputChanged(video_width, video_height, aspect,
    601602                              GetDecoder()->GetVideoCodecID());
     
    848849
    849850void NuppelVideoPlayer::SetVideoParams(int width, int height, double fps,
    850851                                       int keyframedistance, float aspect,
    851                                        FrameScanType scan)
     852                                       FrameScanType scan, bool video_codec_changed)
    852853{
     854    VERBOSE(VB_PLAYBACK, QString("DELETE ME entered SetVideoParams"));
    853855    if (width == 0 || height == 0 || isnan(aspect) || isnan(fps))
    854856        return;
    855857
     858    VERBOSE(VB_PLAYBACK, QString("DELETE ME passed step 1 in SetVideoParams"));
     859           
    856860    if ((video_width  == width ) && (video_height     == height) &&
    857861        (video_aspect == aspect) && (video_frame_rate == fps   ) &&
    858         ((keyframedistance <= 0) || (keyframedistance == keyframedist)))
     862        ((keyframedistance <= 0) || (keyframedistance == keyframedist)) &&
     863        !video_codec_changed)
    859864    {
    860865        return;
    861866    }
     
    874879        frame_interval = (int)(1000000.0f / video_frame_rate / temp_speed);
    875880    }
    876881
     882    VERBOSE(VB_PLAYBACK, QString("DELETE ME in SetVideoParam about to reinitvideo"));
    877883    if (videoOutput)
    878884        ReinitVideo();
    879885
     
    25922598
    25932599        if (ringBuffer->isDVD())
    25942600        {
     2601            if (dvd_video_codec_changing)
     2602                continue;
     2603           
    25952604            int nbframes = videoOutput->ValidVideoFrames();
    25962605            if (nbframes < 2)
    25972606            {
  • libs/libmythtv/avformatdecoder.cpp

     
    278278      lastccptsu(0),
    279279      using_null_videoout(use_null_videoout),
    280280      video_codec_id(kCodec_NONE),
     281      video_codec_changed(false),
    281282      maxkeyframedist(-1),
    282283      // Closed Caption & Teletext decoders
    283284      ccd608(new CC608Decoder(parent)),
     
    292293      disable_passthru(false),
    293294      // DVD
    294295      lastdvdtitle(-1), lastcellstart(0),
    295       dvdmenupktseen(false), dvdvideopause(false)
     296      dvdmenupktseen(false), dvdvideopause(false),
     297      xvmc_enabled(false)
    296298{
    297299    bzero(&params, sizeof(AVFormatParameters));
    298300    bzero(prvpkt, 3 * sizeof(char));
     
    803805        av_free_packet(&pkt1);
    804806        ringBuffer->Seek(0,SEEK_SET);
    805807        ringBuffer->DVD()->IgnoreStillOrWait(false);
     808        QString dec = gContext->GetSetting("PreferredMPEG2Decoder", "ffmpeg");
     809        if (dec.contains("xvmc"))
     810            xvmc_enabled = true;
    806811    }
    807812    else
    808813    {
     
    944949{
    945950    float aspect_ratio;
    946951
     952    directrendering = false;
     953
    947954    if (selectedStream)
    948955    {
    949956        fps = normalized_fps(stream, enc);
     
    986992        SetLowBuffers(false);
    987993    }
    988994
     995    VERBOSE(VB_PLAYBACK, QString("DELETE ME in initvideocodec codec %1 codec name %2").arg(codec->id).
     996            arg(codec->name));
    989997    if (codec && (codec->id == CODEC_ID_MPEG2VIDEO_XVMC ||
    990998                  codec->id == CODEC_ID_MPEG2VIDEO_XVMC_VLD))
    991999    {
     1000        VERBOSE(VB_PLAYBACK, QString("DELETE ME in initvideocodec codec %1..IS XVMC").arg(codec->id));
    9921001        enc->flags |= CODEC_FLAG_EMU_EDGE;
    9931002        enc->get_buffer = get_avf_buffer_xvmc;
    9941003        enc->release_buffer = release_avf_buffer_xvmc;
     
    10271036        }
    10281037
    10291038        GetNVP()->SetVideoParams(align_width, align_height, fps,
    1030                                  keyframedist, aspect_ratio, kScan_Detect);
     1039                                 keyframedist, aspect_ratio, kScan_Detect, video_codec_changed);
     1040        video_codec_changed = false;
    10311041    }
    10321042}
    10331043
     
    12961306                d->DestroyMPEG2();
    12971307                h264_kf_seq->Reset();
    12981308#ifdef USING_XVMC
     1309                VERBOSE(VB_PLAYBACK, QString("DELETE ME ScanStreams using null %1 stream type %2")
     1310                        .arg(using_null_videoout).arg(xvmc_stream_type(enc->codec_id)));
    12991311                if (!using_null_videoout && xvmc_stream_type(enc->codec_id))
    13001312                {
    13011313                    // HACK -- begin
     
    13071319                        enc->codec_id = CODEC_ID_MPEG2VIDEO;
    13081320                    // HACK -- end
    13091321
     1322                    bool force_xv = false;
     1323                    if (ringBuffer->InDVDMenuOrStillFrame() &&
     1324                        xvmc_enabled)
     1325                    {
     1326                        force_xv = true;
     1327                        enc->pix_fmt = PIX_FMT_YUV420P;
     1328                    }
     1329                   
    13101330                    MythCodecID mcid;
    13111331                    mcid = VideoOutputXv::GetBestSupportedCodec(
    13121332                        /* disp dim     */ enc->width, enc->height,
    13131333                        /* osd dim      */ /*enc->width*/ 0, /*enc->height*/ 0,
    13141334                        /* mpeg type    */ xvmc_stream_type(enc->codec_id),
    13151335                        /* xvmc pix fmt */ xvmc_pixel_format(enc->pix_fmt),
    1316                         /* test surface */ kCodec_NORMAL_END > video_codec_id);
     1336                        /* test surface */ kCodec_NORMAL_END > video_codec_id,
     1337                        /* force_xv     */ force_xv);
    13171338                    bool vcd, idct, mc;
    13181339                    enc->codec_id = myth2av_codecid(mcid, vcd, idct, mc);
     1340                    if (mcid != video_codec_id)
     1341                        video_codec_changed = true;
     1342                    VERBOSE(VB_PLAYBACK, QString("DELETE ME ScanStreams video_codec_changed %1 mcid %2 force_xv %3 xvmc_enabled %4 in dvdmenuOrStillFrame %5").arg(video_codec_changed).arg(mcid).arg(force_xv).arg(xvmc_enabled).arg(ringBuffer->InDVDMenuOrStillFrame()));
    13191343                    video_codec_id = mcid;
    1320                     if (kCodec_NORMAL_END < mcid && kCodec_STD_XVMC_END > mcid)
     1344                    if (!force_xv && kCodec_NORMAL_END < mcid && kCodec_STD_XVMC_END > mcid)
    13211345                    {
    13221346                        enc->pix_fmt = (idct) ?
    13231347                            PIX_FMT_XVMC_MPEG2_IDCT : PIX_FMT_XVMC_MPEG2_MC;
     
    27702794            {
    27712795                int current_width = curstream->codec->width;
    27722796                int video_width = GetNVP()->GetVideoWidth();
    2773                 if (video_width > 0 && video_width != current_width)
     2797                bool switch_to_xv = false;
     2798                bool switch_to_xvmc = false;
     2799                if (xvmc_enabled && GetNVP() && GetNVP()->getVideoOutput())
    27742800                {
     2801                    bool xvmc_active = GetNVP()->getVideoOutput()->hasMCAcceleration();
     2802                    bool indvdmenu   = ringBuffer->InDVDMenuOrStillFrame();
     2803                    VERBOSE(VB_PLAYBACK, QString("DELETE ME xvmc_active %1 indvdmenuorstillframe %2").arg(xvmc_active).arg(indvdmenu));
     2804                    if (indvdmenu && xvmc_active)
     2805                        switch_to_xv = true;
     2806                    else if (!indvdmenu && !xvmc_active)
     2807                        switch_to_xvmc = true;
     2808                    VERBOSE(VB_PLAYBACK, QString("DELETE ME switch_to_xv %1 switch_to_xvmc %2").arg(switch_to_xv).arg(switch_to_xvmc));
     2809                }
     2810               
     2811                if ((video_width > 0 && video_width != current_width) ||
     2812                    switch_to_xv || switch_to_xvmc)
     2813                {
     2814                    GetNVP()->DVDVideoCodecChanging(true);
    27752815                    av_free_packet(pkt);
    27762816                    CloseCodecs();
    27772817                    ScanStreams(false);
     
    27812821                        long long cellstartpos = ringBuffer->DVD()->GetCellStartPos();
    27822822                        ringBuffer->DVD()->Seek(cellstartpos, SEEK_SET);
    27832823                    }
     2824                    GetNVP()->DVDVideoCodecChanging(false);
    27842825                    continue;
    27852826                }
    27862827            }
     
    30803121                                                  &gotpicture, ptr, len);
    30813122                    else
    30823123                    {
     3124                        VERBOSE(VB_PLAYBACK, QString("DELETE ME context codec %1 pixfmt %2")
     3125                                .arg(context->codec_id).arg(context->pix_fmt));
    30833126                        ret = avcodec_decode_video(context, &mpa_pic,
    30843127                                                   &gotpicture, ptr, len);
    30853128                        // Reparse it to not drop the DVD still frame
  • 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, bool video_codec_changed = false);
    155155    void SetFileLength(int total, int frames);
    156156    void Zoom(int direction);
    157157    void ClearBookmark(void);
     
    387387    {
    388388        hidedvdbutton = hide;
    389389    }
    390 
     390    void DVDVideoCodecChanging(bool setting) { dvd_video_codec_changing = setting; }
     391   
    391392  protected:
    392393    void DisplayPauseFrame(void);
    393394    void DisplayNormalFrame(void);
     
    769770    bool indvdstillframe;
    770771    bool hidedvdbutton;
    771772    int need_change_dvd_track;
     773    bool dvd_video_codec_changing; ///< true if switching from Xv <-->XVMC
    772774
    773775    // Debugging variables
    774776    Jitterometer *output_jmeter;
  • 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

     
    207207
    208208    VideoOutput::InputChanged(width, height, aspect, av_codec_id);
    209209
     210    VERBOSE(VB_PLAYBACK, QString("DELETE ME InputChanged cid_changed %1 res_changed %2")
     211            .arg(cid_changed).arg(res_changed));
    210212    if (!res_changed && !cid_changed)
    211213    {
    212214        if (VideoOutputSubType() == XVideo)
     
    649651 *
    650652 * \sideeffect sets av_pause_frame.
    651653 */
    652 void VideoOutputXv::CreatePauseFrame(void)
     654void VideoOutputXv::CreatePauseFrame(VOSType subtype)
    653655{
    654656    // All methods but XvMC use a pause frame, create it if needed
    655     if (VideoOutputSubType() <= XVideo)
     657    VERBOSE(VB_PLAYBACK, QString("DELETE ME CreatePauseFrame Now Video Type %1").arg(VideoOutputSubType()));
     658    if (subtype <= XVideo)
    656659    {
     660        VERBOSE(VB_PLAYBACK, QString("DELETE ME CreatePauseFrame Now "));
    657661        vbuffers.LockFrame(&av_pause_frame, "CreatePauseFrame");
    658662
    659663        if (av_pause_frame.buf)
     
    992996MythCodecID VideoOutputXv::GetBestSupportedCodec(
    993997    uint width,       uint height,
    994998    uint osd_width,   uint osd_height,
    995     uint stream_type, int xvmc_chroma,    bool test_surface)
     999    uint stream_type, int xvmc_chroma,   
     1000    bool test_surface, bool force_xv)
    9961001{
    9971002    (void)width, (void)height, (void)osd_width, (void)osd_height;
    9981003    (void)stream_type, (void)xvmc_chroma, (void)test_surface;
    9991004
     1005    if (force_xv)
     1006        return (MythCodecID)(kCodec_MPEG1 + (stream_type-1));
    10001007#ifdef USING_XVMC
    10011008    Display *disp = MythXOpenDisplay();
    10021009
     
    17181725
    17191726    }
    17201727
     1728    VERBOSE(VB_PLAYBACK, QString("DELETE ME In CreateBuffers..ok %1 about to CreatePauseFrame").arg(ok));
    17211729    if (ok)
    1722         CreatePauseFrame();
     1730        CreatePauseFrame(subtype);
    17231731
    17241732    return ok;
    17251733}
     
    17721780
    17731781    if (delete_pause_frame)
    17741782    {
     1783        VERBOSE(VB_PLAYBACK, QString("DELETE ME deleting pause frame DeleteBuffers"));
    17751784        if (av_pause_frame.buf)
    17761785        {
    17771786            delete [] av_pause_frame.buf;
  • libs/libmythtv/avformatdecoder.h

     
    227227
    228228    bool using_null_videoout;
    229229    MythCodecID video_codec_id;
     230    bool video_codec_changed;
    230231
    231232    int maxkeyframedist;
    232233
     
    254255    uint lastcellstart;
    255256    bool dvdmenupktseen;
    256257    bool dvdvideopause;
     258    bool xvmc_enabled;
     259    bool xvmc_active;
    257260
    258261};
    259262
  • 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;
    20812082    return 0;
    20822083}
    20832084