Recent

Author Topic: [Solved] Slow calls to DLL ?  (Read 8554 times)

cwlyj001

  • New Member
  • *
  • Posts: 23
Re: [Solved] Slow calls to DLL ?
« Reply #30 on: February 27, 2024, 10:45:22 am »
Debugging the source code of ffmpeg avcodec_decode_video2, The files involved mainly include h264dec. c, h264_slice. c, and h264_cabac.c。
The main functions are h264_decode_frame ->decodedeal_units ->decode_slice.
The function that takes the longest time is decode_slice. Decode_slice Internal
Brief process: ff_init_cabac_decoder ->ff_h264_init_cabac_states->Ff_h264_decode_mbm_cabac.

In the FPC environment, ff_h264_init_cabac_states and ff_h264_decode_mbm_cabac
The execution efficiency of is only 1/6 of that in the QT environment.

Posting the source code of ff_h264_init_cabac_states will mainly take time on the for loop. Exactly, ff_h264_decode_mb_cabac is also in the
a large amount of for loop, because the h264 frame is composed of many macro blocks, ff_h264_decode_mb_cabac only decodes a single macro block.

void ff_h264_init_cabac_states(const H264Context *h, H264SliceContext *sl)
{
    int ii;
    const int8_t (*tab)[2];
    const int slice_qp = av_clip(sl->qscale - 6*(h->ps.sps->bit_depth_luma-8), 0, 51);

    if (sl->slice_type_nos == AV_PICTURE_TYPE_I)
          tab = cabac_context_init_I;
    else                               
          tab = cabac_context_init_PB[sl->cabac_init_idc];

    //calculate pre-state
    for( ii= 0; ii < 1024; ii++ ) {
        int pre = 2*(((tab[ii][0] * slice_qp) >>4 ) + tab[ii][1]) - 127;

        pre^= pre>>31;
        if(pre > 124)
            pre= 124 + (pre&1);

        sl->cabac_state[ii] =  pre;
    }
}

cwlyj001

  • New Member
  • *
  • Posts: 23
Re: [Solved] Slow calls to DLL ?
« Reply #31 on: February 27, 2024, 10:46:27 am »
Further debugging, ff_h264_init_cabac_states mainly takes time on for loop
Under qt, ff_h264_init_cabac_states costs 6 clock_t, while under fpc, it costs 36 clock_t.

 

TinyPortal © 2005-2018