int has_blocking(davs2_mgr_t *mgr)
{
    davs2_output_t *pics  = &mgr->outpics;
    davs2_outpic_t *pic   = NULL;
    davs2_frame_t  *frame = NULL;

    int decodingframes = 0, outputframes = 0;
    int i;

    /* is the expected frame already in the output list ? */
    for (pic = pics->pics; pic; pic = pic->next) {
        frame = pic->frame;

        if (frame->i_poc == pics->output) {
            /* the expected frame */
            return 0;
        } else if (frame->i_poc < pics->output) {
            /* a late frame: the output thread will dump it.*/
            return 0;
        }

        outputframes++;
    }

    /* is the expected frame still under decoding ? */
    for (i = 0; i < mgr->num_decoders; i++) {
        davs2_t *h = &mgr->decoders[i];

        if (h->task_info.task_status != TASK_FREE) {
            frame = h->fdec;

            if (frame != NULL) {
                if (frame->i_poc == pics->output) {
                    /* the expected frame will be put into the output list soon */
                    return 0;
                }

                if (frame->i_poc >= 0) {
                    decodingframes++;
                }
            }
        }
    }

    assert(outputframes + decodingframes <= mgr->dpbsize);

    /* the expected frame is neither in the output list nor under decoding */
    if (mgr->outpics.busy != 0) {
        /* one frame being delivered, soon it maybe free ? */
        return 0;
    }

    return 1;
}
int has_blocking(davs2_mgr_t *mgr)
{
    davs2_output_t *pics  = &mgr->outpics;
    davs2_outpic_t *pic   = NULL;
    davs2_frame_t  *frame = NULL;

    int decodingframes = 0, outputframes = 0;
    int i;

     
    for (pic = pics->pics; pic; pic = pic->next) {
        frame = pic->frame;

        if (frame->i_poc == pics->output) {
             
            return 0;
        } else if (frame->i_poc < pics->output) {
             
            return 0;
        }

        outputframes++;
    }

     
    for (i = 0; i < mgr->num_decoders; i++) {
        davs2_t *h = &mgr->decoders[i];

        if (h->task_info.task_status != TASK_FREE) {
            frame = h->fdec;

            if (frame != NULL) {
                if (frame->i_poc == pics->output) {
                     
                    return 0;
                }

                if (frame->i_poc >= 0) {
                    decodingframes++;
                }
            }
        }
    }

    assert(outputframes + decodingframes <= mgr->dpbsize);

     
    if (mgr->outpics.busy != 0) {
         
        return 0;
    }

    return 1;
}