コード例 #1
0
ファイル: fbm.c プロジェクト: BPI-SINOVOIP/cedarx-libs
s32 fbm_flush(Handle h)
{
    fbm_t* 		  fbm;
    frame_info_t* frame;

    fbm = (fbm_t*)h;

    if(fbm == NULL)
        return -1;

    if (lock(fbm) != 0)
    {
        return -1;
    }

	while((frame = fbm_dequeue(&fbm->display_queue)) != NULL)
	{
		fbm_enqueue(&fbm->empty_queue, frame);
        frame->status = FS_EMPTY;
	}

    unlock(fbm);

    return 0;
}
コード例 #2
0
ファイル: libcedarx.c プロジェクト: ssvb/libcedarx
static Handle fbm_request_display_frame(Handle h)
{
    Handle hdl = NULL;
    fbm_t* fbm = (fbm_t*)h;
    display_frame_t* frame_info;
    vpicture_t* vpicture;
    cedarx_picture_t *picture;
    
    if(fbm && fbm->decoder) {
        pthread_mutex_lock(&fbm->mutex);
        frame_info = fbm_dequeue(&fbm->decoded_queue);
        if(frame_info) {
            picture = &frame_info->picture;
            vpicture = &frame_info->vpicture;
            picture->width = vpicture->width;					
            picture->height = vpicture->height;					
            picture->top_offset = vpicture->top_offset;				
            picture->left_offset = vpicture->left_offset;			
            picture->display_width = vpicture->display_width;			
            picture->display_height = vpicture->display_height;
            picture->is_progressive	= vpicture->is_progressive;		
            picture->top_field_first = vpicture->top_field_first;		
            picture->repeat_top_field = vpicture->repeat_top_field;		
            picture->repeat_bottom_field = vpicture->repeat_bottom_field;		
            picture->frame_rate	= vpicture->frame_rate;		
            picture->pts = vpicture->pts;

            if (fbm->decoder->update_buffer)
                fbm->decoder->update_buffer(picture, fbm->decoder->sys);
            hdl = picture->sys;
            switch (frame_info->status) {
                case FS_DECODER_DISCARD:
                    frame_info->status = FS_BINDING;
                    fbm_enqueue_tail(&fbm->bind_queue, frame_info);
                    break;
                case FS_DECODER_SHARED:
                    if (fbm->decoder->lock_buffer)
                        fbm->decoder->lock_buffer(picture, fbm->decoder->sys);
                    frame_info->status = FS_DECODER_SHARE_DISCARD;
                    break;
                default:
                    printf("Fatal Error: invalid frame(%d) at %s:%s:%d!!!!\n", \
                        frame_info->status, __FILE__, __FUNCTION__, __LINE__);
                    break;
            }
        }
        pthread_mutex_unlock(&fbm->mutex);
    }
    return hdl;
}
コード例 #3
0
ファイル: fbm.c プロジェクト: BPI-SINOVOIP/cedarx-libs
vpicture_t* fbm_decoder_request_frame(Handle h)
{
	u32           i;
    fbm_t*        fbm;
    frame_info_t* frame_info;
    
    fbm = (fbm_t*)h;
    
    if(fbm == NULL)
        return NULL;

    frame_info = NULL;
    
    for(i=0; i<FBM_REQUEST_FRAME_WAIT_TIME/10; i++)
    {
    	lock(fbm);
        
    	frame_info = fbm_dequeue(&fbm->empty_queue);
    	if(frame_info != NULL)
    	{
        	frame_info->status = FS_DECODER_USING;
    	}
        
    	unlock(fbm);

    	if(frame_info != NULL)
    		break;
    	else
    		sys_sleep(10);
    }

    if(frame_info != NULL)
    {
        return &frame_info->picture;
    }
    else
        return NULL;
}
コード例 #4
0
ファイル: fbm.c プロジェクト: BPI-SINOVOIP/cedarx-libs
vpicture_t* fbm_display_request_frame(Handle h)
{
    fbm_t*        fbm;
    frame_info_t* frame_info;
    
    fbm = (fbm_t*)h;
    
    if(fbm == NULL)
        return NULL;
        
    frame_info = NULL;
    
    if(lock(fbm) != 0)
        return NULL;

    frame_info = fbm_dequeue(&fbm->display_queue);

    unlock(fbm);
    
    if(frame_info != NULL)
        return &frame_info->picture;
    else
        return NULL;
}
コード例 #5
0
ファイル: libcedarx.c プロジェクト: rellla/libcedarx
static vpicture_t* fbm_request_decoder_frame(Handle h)
{
    fbm_t* fbm;
    display_frame_t* frame_info;
    vpicture_t* vpicture = NULL;
    cedarx_picture_t *picture;
    
    fbm = (fbm_t*)h;
    if(fbm && fbm->decoder && fbm->decoder->request_buffer) {
        pthread_mutex_lock(&fbm->mutex);
        cedarx_picture_t pic;
        
        memset(&pic, 0, sizeof(cedarx_picture_t));
        if (fbm->decoder->greedy && !fbm->exhausted) {
            frame_info = fbm_dequeue(&fbm->empty_queue);
            if(frame_info) {
                fbm->decoder->request_buffer(&pic, fbm->decoder->sys);
                if (pic.sys) {
                    picture = &frame_info->picture;
                    vpicture = &frame_info->vpicture;
                    vpicture->size_y        = pic.size_y[0];
                    vpicture->size_u        = pic.size_u[0];
                    vpicture->size_v        = pic.size_v[0];
                    vpicture->size_alpha    = pic.size_alpha[0];
                    vpicture->size_y2       = pic.size_y[1];
                    vpicture->size_u2       = pic.size_u[1];
                    vpicture->size_v2       = pic.size_v[1];
                    vpicture->size_alpha2   = pic.size_alpha[1];
                    vpicture->y             = pic.y[0];
                    vpicture->u             = pic.u[0];
                    vpicture->v             = pic.v[0];
                    vpicture->alpha         = pic.alpha[0];
                    vpicture->y2            = pic.y[1];
                    vpicture->u2            = pic.u[1];
                    vpicture->v2            = pic.v[1];
                    vpicture->alpha2        = pic.alpha[1];
                    picture->size_y[0]      = pic.size_y[0];
                    picture->size_u[0]      = pic.size_u[0];
                    picture->size_v[0]      = pic.size_v[0];
                    picture->size_alpha[0]  = pic.size_alpha[0];
                    picture->size_y[1]      = pic.size_y[1];
                    picture->size_u[1]      = pic.size_u[1];
                    picture->size_v[1]      = pic.size_v[1];
                    picture->size_alpha[1]  = pic.size_alpha[1];
                    picture->y[0]           = pic.y[0];
                    picture->u[0]           = pic.u[0];
                    picture->v[0]           = pic.v[0];
                    picture->alpha[0]       = pic.alpha[0];
                    picture->y[1]           = pic.y[1];
                    picture->u[1]           = pic.u[1];
                    picture->v[1]           = pic.v[1];
                    picture->alpha[1]       = pic.alpha[1];
                    picture->sys            = pic.sys;
                    frame_info->status = FS_DECODER_USING;
                } else {
                    fbm_enqueue(&fbm->empty_queue, frame_info);
                }
            } else {
                fbm->exhausted = 1;  
            }
        } else {
            fbm->decoder->request_buffer(&pic, fbm->decoder->sys);
            if (pic.sys) {
                frame_info = fbm_pick(&fbm->bind_queue, pic.sys);
                if(frame_info) {
                    vpicture = &frame_info->vpicture;
                    frame_info->status = FS_DECODER_USING;
                } else {
                    frame_info = fbm_dequeue(&fbm->empty_queue);
                    if(!frame_info) {
                        if (fbm->init_frame_num < FBM_MAX_FRAME_NUM) {
                            frame_info = &fbm->frames[fbm->init_frame_num];
                            frame_info->vpicture.id = fbm->init_frame_num;
                            frame_info->vpicture._3d_mode = fbm->mode;
                            frame_info->status = FS_EMPTY;
                            fbm->init_frame_num ++;
                        }
                    }
                    
                    if(frame_info) {
                        picture = &frame_info->picture;
                        vpicture = &frame_info->vpicture;
                        vpicture->size_y        = pic.size_y[0];
                        vpicture->size_u        = pic.size_u[0];
                        vpicture->size_v        = pic.size_v[0];
                        vpicture->size_alpha    = pic.size_alpha[0];
                        vpicture->size_y2       = pic.size_y[1];
                        vpicture->size_u2       = pic.size_u[1];
                        vpicture->size_v2       = pic.size_v[1];
                        vpicture->size_alpha2   = pic.size_alpha[1];
                        vpicture->y             = pic.y[0];
                        vpicture->u             = pic.u[0];
                        vpicture->v             = pic.v[0];
                        vpicture->alpha         = pic.alpha[0];
                        vpicture->y2            = pic.y[1];
                        vpicture->u2            = pic.u[1];
                        vpicture->v2            = pic.v[1];
                        vpicture->alpha2        = pic.alpha[1];
                        picture->size_y[0]      = pic.size_y[0];
                        picture->size_u[0]      = pic.size_u[0];
                        picture->size_v[0]      = pic.size_v[0];
                        picture->size_alpha[0]  = pic.size_alpha[0];
                        picture->size_y[1]      = pic.size_y[1];
                        picture->size_u[1]      = pic.size_u[1];
                        picture->size_v[1]      = pic.size_v[1];
                        picture->size_alpha[1]  = pic.size_alpha[1];
                        picture->y[0]           = pic.y[0];
                        picture->u[0]           = pic.u[0];
                        picture->v[0]           = pic.v[0];
                        picture->alpha[0]       = pic.alpha[0];
                        picture->y[1]           = pic.y[1];
                        picture->u[1]           = pic.u[1];
                        picture->v[1]           = pic.v[1];
                        picture->alpha[1]       = pic.alpha[1];
                        picture->sys            = pic.sys;
                        frame_info->status = FS_DECODER_USING;
                    } else {
                        if (fbm->decoder->release_buffer)
                            fbm->decoder->release_buffer(&pic, fbm->decoder->sys);
                    }
                }
            }
        }
        pthread_mutex_unlock(&fbm->mutex);
    }
    
    return vpicture;
}