Ticket #6922: h264_stream_check_v3.diff

File h264_stream_check_v3.diff, 3.1 KB (added by markk, 2 years ago)

Correctly detects and acts upon the stream change but resumed playback is still intermittently broken

  • libs/libmythtv/videoout_vdpau.h

     
    105105 
    106106    uint                 m_decoder; 
    107107    int                  m_pix_fmt; 
     108    uint64_t             m_decoder_description; 
     109    bool                 m_force_reinit; 
    108110 
    109111    int                  m_frame_delay; 
    110112    QMutex               m_lock; 
  • libs/libmythtv/videoout_vdpau.cpp

     
    2727    m_need_deintrefs(false), m_video_mixer(0), m_mixer_features(kVDPFeatNone), 
    2828    m_checked_surface_ownership(false), 
    2929    m_checked_output_surfaces(false), 
    30     m_decoder(0),            m_pix_fmt(-1),    m_frame_delay(0), 
     30    m_decoder(0),            m_pix_fmt(-1),    m_decoder_description(0), 
     31    m_force_reinit(false),   m_frame_delay(0), 
    3132    m_lock(QMutex::Recursive), m_pip_layer(0), m_pip_surface(0), 
    3233    m_pip_ready(false), 
    3334    m_osd_layer(0),          m_osd_surface(0), m_osd_output_surface(0), 
     
    130131    m_decoder = 0; 
    131132    m_render = NULL; 
    132133    m_pix_fmt = -1; 
     134    m_decoder_description = 0; 
    133135} 
    134136 
    135137bool VideoOutputVDPAU::InitBuffers(void) 
     
    481483    m_checked_surface_ownership = true; 
    482484} 
    483485 
     486#define HASH_H264(arg) \ 
     487  ((uint64_t)arg.num_ref_frames << 56) + \ 
     488  ((uint64_t)arg.mb_adaptive_frame_field_flag << 48) 
     489 
    484490void VideoOutputVDPAU::DrawSlice(VideoFrame *frame, int x, int y, int w, int h) 
    485491{ 
    486492    (void)x; 
     
    505511        return; 
    506512    } 
    507513 
     514    if (frame->pix_fmt == PIX_FMT_VDPAU_H264 && 
     515        frame->pix_fmt == m_pix_fmt && m_decoder && 
     516        HASH_H264(render->info.h264) != m_decoder_description) 
     517    { 
     518        VERBOSE(VB_IMPORTANT, LOC + 
     519            QString("h264 stream type has changed.")); 
     520        VERBOSE(VB_PLAYBACK, LOC + QString("Old desc '%1'") 
     521            .arg(m_decoder_description, 16, 16, QChar(48))); 
     522        VERBOSE(VB_PLAYBACK, LOC + QString("New desc '%1'") 
     523            .arg(HASH_H264(render->info.h264), 16, 16, QChar(48))); 
     524        m_force_reinit = true; 
     525        InputChanged(windows[0].GetVideoDispDim(), windows[0].GetVideoAspect(), 
     526                     m_codec_id, NULL); 
     527    } 
     528 
    508529    if (frame->pix_fmt != m_pix_fmt) 
    509530    { 
    510531        if (m_decoder) 
     
    518539        uint max_refs = 2; 
    519540        if (frame->pix_fmt == PIX_FMT_VDPAU_H264) 
    520541        { 
     542            m_decoder_description = HASH_H264(render->info.h264); 
    521543            max_refs = render->info.h264.num_ref_frames; 
    522544            if (max_refs < 1 || max_refs > 16) 
    523545            { 
     
    619641    bool res_changed = input_size  != windows[0].GetVideoDispDim(); 
    620642    bool asp_changed = aspect      != windows[0].GetVideoAspect(); 
    621643 
     644    if (m_force_reinit) 
     645    { 
     646        VERBOSE(VB_IMPORTANT, LOC + QString("Forcing reinit.")); 
     647        cid_changed = true; 
     648        m_force_reinit = false; 
     649    } 
     650 
    622651    if (!res_changed && !cid_changed) 
    623652    { 
    624653        if (asp_changed)