Ticket #6922: vdpauh264_stream_check.diff

File vdpauh264_stream_check.diff, 3.1 KB (added by markk, 14 years ago)

Test patch

  • libs/libmythtv/util-vdpau.cpp

     
    8686    pipOutputSurface(0),    pipAlpha(0),       pipBorder(0),
    8787    pipClear(0),            pipReady(0),       pipNeedsClear(false),
    8888    vdp_flip_target(0),     vdp_flip_queue(0), vdpauDecode(false),
    89     vdp_device(0),          errorCount(0),     errorState(kError_None),
     89    vdp_device(0),          decoderDescription(0),
     90    errorCount(0),          errorState(kError_None),
    9091    vdp_get_proc_address(NULL),       vdp_device_destroy(NULL),
    9192    vdp_get_error_string(NULL),       vdp_get_api_version(NULL),
    9293    vdp_get_information_string(NULL), vdp_video_surface_create(NULL),
     
    161162    return ok;
    162163}
    163164
    164 void VDPAUContext::Deinit(void)
     165void VDPAUContext::DestroyDecoder(void)
    165166{
    166167    if (decoder)
    167     {
    168168        vdp_decoder_destroy(decoder);
    169         decoder = NULL;
    170         pix_fmt = -1;
    171     }
     169    decoder = NULL;
     170    pix_fmt = -1;
     171    decoderDescription = 0;
     172}
     173
     174void VDPAUContext::Deinit(void)
     175{
     176    DestroyDecoder();
    172177    ClearReferenceFrames();
    173178    DeinitOSD();
    174179    FreeOutput();
     
    910915    checkOutputSurfaces = false;
    911916}
    912917
     918#define HASH_H264(arg) \
     919  ((uint64_t)arg.num_ref_frames << 56) + \
     920  ((uint64_t)arg.mb_adaptive_frame_field_flag << 48)
     921
    913922void VDPAUContext::Decode(VideoFrame *frame)
    914923{
    915924    if (!vdpauDecode)
     
    932941        return;
    933942    }
    934943
     944    if (decoder && frame->pix_fmt == PIX_FMT_VDPAU_H264)
     945    {
     946        if (HASH_H264(render->info.h264) != decoderDescription)
     947        {
     948            VERBOSE(VB_IMPORTANT, LOC +
     949                QString("h264 stream type has changed. Re-creating decoder."));
     950            VERBOSE(VB_PLAYBACK, LOC + QString("Old desc '%1'")
     951                .arg(HASH_H264(decoderDescription), 16, 16, QChar(48)));
     952            VERBOSE(VB_PLAYBACK, LOC + QString("New desc '%1'")
     953                .arg(HASH_H264(render->info.h264), 16, 16, QChar(48)));
     954            DestroyDecoder();
     955        }
     956    }
     957
    935958    if (frame->pix_fmt != pix_fmt)
    936959    {
    937960        if (decoder)
     
    944967
    945968        if (frame->pix_fmt == PIX_FMT_VDPAU_H264)
    946969        {
     970            decoderDescription = HASH_H264(render->info.h264);
    947971            maxReferences = render->info.h264.num_ref_frames;
    948972            if (maxReferences < 1 || maxReferences > 16)
    949973            {
  • libs/libmythtv/util-vdpau.h

     
    5252              QSize screen_size, bool color_control,
    5353              int color_key, MythCodecID mcodecid,
    5454              QString options);
     55    void DestroyDecoder(void);
    5556    void Deinit(void);
    5657    VideoErrorState GetError(void) { return errorState; }
    5758    bool IsErrored(void)
     
    190191
    191192    bool              vdpauDecode;
    192193    VdpDevice         vdp_device;
     194    uint64_t          decoderDescription;
    193195
    194196    int               errorCount;
    195197    VideoErrorState   errorState;