Ticket #1822: xvmc_dvd_menu_attempt2.diff

File xvmc_dvd_menu_attempt2.diff, 14.2 KB (added by skamithi, 17 years ago)

thx to robin for testing. another variable in mpeg12 needed to be reinitialized when switching back to XV from Via XVMC.

  • 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);
     
    986993        SetLowBuffers(false);
    987994    }
    988995
     996    VERBOSE(VB_PLAYBACK, QString("DELETE ME in initvideocodec codec %1 codec name %2").arg(codec->id).
     997            arg(codec->name));
    989998    if (codec && (codec->id == CODEC_ID_MPEG2VIDEO_XVMC ||
    990999                  codec->id == CODEC_ID_MPEG2VIDEO_XVMC_VLD))
    9911000    {
     1001        VERBOSE(VB_PLAYBACK, QString("DELETE ME in initvideocodec codec %1..IS XVMC").arg(codec->id));
    9921002        enc->flags |= CODEC_FLAG_EMU_EDGE;
    9931003        enc->get_buffer = get_avf_buffer_xvmc;
    9941004        enc->release_buffer = release_avf_buffer_xvmc;
     
    10271037        }
    10281038
    10291039        GetNVP()->SetVideoParams(align_width, align_height, fps,
    1030                                  keyframedist, aspect_ratio, kScan_Detect);
     1040                                 keyframedist, aspect_ratio, kScan_Detect, video_codec_changed);
     1041        video_codec_changed = false;
    10311042    }
    10321043}
    10331044
     
    13541365                d->DestroyMPEG2();
    13551366                h264_kf_seq->Reset();
    13561367#ifdef USING_XVMC
     1368                VERBOSE(VB_PLAYBACK, QString("DELETE ME ScanStreams using null %1 stream type %2")
     1369                        .arg(using_null_videoout).arg(xvmc_stream_type(enc->codec_id)));
    13571370                if (!using_null_videoout && xvmc_stream_type(enc->codec_id))
    13581371                {
    13591372                    // HACK -- begin
     
    13651378                        enc->codec_id = CODEC_ID_MPEG2VIDEO;
    13661379                    // HACK -- end
    13671380
     1381                    bool force_xv = false;
     1382                    if (ringBuffer->InDVDMenuOrStillFrame() &&
     1383                        xvmc_enabled)
     1384                    {
     1385                        force_xv = true;
     1386                        enc->pix_fmt = PIX_FMT_YUV420P;
     1387                    }
     1388                   
    13681389                    MythCodecID mcid;
    13691390                    mcid = VideoOutputXv::GetBestSupportedCodec(
    13701391                        /* disp dim     */ enc->width, enc->height,
    13711392                        /* osd dim      */ /*enc->width*/ 0, /*enc->height*/ 0,
    13721393                        /* mpeg type    */ xvmc_stream_type(enc->codec_id),
    13731394                        /* xvmc pix fmt */ xvmc_pixel_format(enc->pix_fmt),
    1374                         /* test surface */ kCodec_NORMAL_END > video_codec_id);
     1395                        /* test surface */ kCodec_NORMAL_END > video_codec_id,
     1396                        /* force_xv     */ force_xv);
    13751397                    bool vcd, idct, mc;
    13761398                    enc->codec_id = myth2av_codecid(mcid, vcd, idct, mc);
     1399                    if (mcid != video_codec_id)
     1400                        video_codec_changed = true;
     1401                    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()));
    13771402                    video_codec_id = mcid;
    1378                     if (kCodec_NORMAL_END < mcid && kCodec_STD_XVMC_END > mcid)
     1403                    if (!force_xv && kCodec_NORMAL_END < mcid && kCodec_STD_XVMC_END > mcid)
    13791404                    {
    13801405                        enc->pix_fmt = (idct) ?
    13811406                            PIX_FMT_XVMC_MPEG2_IDCT : PIX_FMT_XVMC_MPEG2_MC;
     
    28302855            {
    28312856                int current_width = curstream->codec->width;
    28322857                int video_width = GetNVP()->GetVideoWidth();
    2833                 if (video_width > 0 && video_width != current_width)
     2858                bool switch_to_xv = false;
     2859                bool switch_to_xvmc = false;
     2860                if (xvmc_enabled && GetNVP() && GetNVP()->getVideoOutput())
    28342861                {
     2862                    bool xvmc_active = GetNVP()->getVideoOutput()->hasMCAcceleration();
     2863                    bool indvdmenu   = ringBuffer->InDVDMenuOrStillFrame();
     2864                    VERBOSE(VB_PLAYBACK, QString("DELETE ME xvmc_active %1 indvdmenuorstillframe %2").arg(xvmc_active).arg(indvdmenu));
     2865                    if (indvdmenu && xvmc_active)
     2866                        switch_to_xv = true;
     2867                    else if (!indvdmenu && !xvmc_active)
     2868                        switch_to_xvmc = true;
     2869                    VERBOSE(VB_PLAYBACK, QString("DELETE ME switch_to_xv %1 switch_to_xvmc %2").arg(switch_to_xv).arg(switch_to_xvmc));
     2870                }
     2871               
     2872                if ((video_width > 0 && video_width != current_width) ||
     2873                    switch_to_xv || switch_to_xvmc)
     2874                {
     2875                    GetNVP()->DVDVideoCodecChanging(true);
    28352876                    av_free_packet(pkt);
    28362877                    CloseCodecs();
    28372878                    ScanStreams(false);
     
    28412882                        long long cellstartpos = ringBuffer->DVD()->GetCellStartPos();
    28422883                        ringBuffer->DVD()->Seek(cellstartpos, SEEK_SET);
    28432884                    }
     2885                    GetNVP()->DVDVideoCodecChanging(false);
    28442886                    continue;
    28452887                }
    28462888            }
     
    31403182                                                  &gotpicture, ptr, len);
    31413183                    else
    31423184                    {
     3185                        VERBOSE(VB_PLAYBACK, QString("DELETE ME context codec %1 pixfmt %2")
     3186                                .arg(context->codec_id).arg(context->pix_fmt));
    31433187                        ret = avcodec_decode_video(context, &mpa_pic,
    31443188                                                   &gotpicture, ptr, len);
    31453189                        // 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(subtype);
     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

     
    228228
    229229    bool using_null_videoout;
    230230    MythCodecID video_codec_id;
     231    bool video_codec_changed;
    231232
    232233    int maxkeyframedist;
    233234
     
    255256    uint lastcellstart;
    256257    bool dvdmenupktseen;
    257258    bool dvdvideopause;
     259    bool xvmc_enabled;
     260    bool xvmc_active;
    258261
    259262};
    260263
  • 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