Example #1
0
int ipanel_av_init(void)
{
	struct pes_retrieve_param pes_service;
	
	struct VDecPIPInfo vInitInfo;
	struct MPSource_CallBack vMPCallBack;
	struct PIPSource_CallBack vPIPCallBack;

	MEMSET((UINT8 *)&io_parameter, 0, sizeof(struct io_param));
	PID_list[0]=0;
	PID_list[1]=0;
	PID_list[2]=0;
	video_status	=  0;
	audioPid   =  0;
	videoPid   =  0;
	pcrPid     =  0;
	
	vdec_set_output ( g_decv_dev,	MP_MODE, &vInitInfo, &vMPCallBack, &vPIPCallBack );
	//if(RET_SUCCESS!= VDec_Decode(0,ALL_PIC,	FALSE,0,FALSE,FALSE,FALSE))
	//	ASSERT(0);
	vpo_win_mode ( g_vpo_dev, VPO_MAINWIN, &vMPCallBack, &vPIPCallBack );
#ifdef VDEC_AV_SYNC
	vdec_sync_mode ( g_decv_dev, 0x00, VDEC_SYNC_I | VDEC_SYNC_P | VDEC_SYNC_B );
	deca_set_sync_mode ( g_deca_dev, ADEC_SYNC_PTS );
#endif

	//Binding Video Decoder to DMX
	pes_service.device = g_decv_dev;
	pes_service.filter_idx = 0;
	pes_service.retrieve_fmt = PES_HEADER_DISCARDED;
	pes_service.str_type = VIDEO_STR;
	pes_service.request_write = vdec_vbv_request ;
	pes_service.update_write = vdec_vbv_update ;
	dmx_io_control ( g_dmx_dev, DMX_BINDING_PES_RETRIEVE, ( UINT32 ) ( &pes_service ) );

	//Binding Audio Decoder to DMX
	pes_service.device = g_deca_dev;
	pes_service.filter_idx = 1;
	pes_service.retrieve_fmt = PES_HEADER_DISCARDED;
	pes_service.str_type = AUDIO_STR;
	pes_service.request_write = deca_request_write;
	pes_service.update_write = deca_update_write ;
	dmx_io_control ( g_dmx_dev, DMX_BINDING_PES_RETRIEVE, ( UINT32 ) ( &pes_service ) );
	
	return 0;
}
Example #2
0
/* Set the View Mode of VPO Window */
void hde_set_mode(UINT32 mode)
{
    struct MPSource_CallBack MPCallBack;
    struct PIPSource_CallBack PIPCallBack;
    struct VDec_StatusInfo vdec_info;
    struct VDecPIPInfo tInitInfo;
    UINT32 waittime=0, wait_total_time = 0;
    struct vdec_device *pDecvDevice = (struct vdec_device *)get_selected_decoder();
    BOOL need_to_wait = FALSE;
    BOOL need_to_set_output = FALSE;
    UINT8 ulock = 0;
    struct nim_device *nim = (struct nim_device *)dev_get_by_id(HLD_DEV_TYPE_NIM, 0);
    struct vpo_device *pDisDevice = (struct vpo_device *)dev_get_by_type(NULL, HLD_DEV_TYPE_DIS);
#ifdef DUAL_VIDEO_OUTPUT
    struct vpo_device *pDisDevice_O = (struct vpo_device *)dev_get_by_id(HLD_DEV_TYPE_DIS, 1);
#endif
    struct vpo_io_get_info dis_info;

    switch(mode)
    {
    case VIEW_MODE_PREVIEW:
        if ((l_hde_mode != mode) || (l_hde_uIsPreviewResize == 1))
        {
            ENTER_CCHDE_API();
#if(	VDEC27_PREVIEW_SOLUTION == VDEC27_PREVIEW_VE_SCALE)

#ifdef HDTV_SUPPORT
            /* Check Frame Size, If Input Frame is HD, Set VE to Dview Mode */
            vpo_ioctl(pDisDevice, VPO_IO_GET_INFO, (UINT32) &dis_info);
#ifdef DUAL_VIDEO_OUTPUT
            vpo_ioctl(pDisDevice_O, VPO_IO_GET_INFO, (UINT32) &dis_info);
#endif
            if(is_cur_decoder_avc())
            {
                vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
                if(vdec_info.pic_width > 720 || vdec_info.pic_height > 576)
                {
                    need_to_wait = TRUE;
                }
                else
                    need_to_wait = FALSE;
            }
            else
            {
                need_to_wait = TRUE;
                vdec_stop(pDecvDevice,TRUE,TRUE);
            }
            if(need_to_wait)
            {
                tInitInfo.adv_setting.init_mode = 1;
                tInitInfo.adv_setting.out_sys = dis_info.tvsys;
                tInitInfo.adv_setting.bprogressive = dis_info.bprogressive;
#ifdef DUAL_VIDEO_OUTPUT
                if(is_cur_decoder_avc())
#else
                if(0)
#endif
                {
                    vdec_set_output(pDecvDevice,DUAL_PREVIEW_MODE, &tInitInfo, &MPCallBack, &PIPCallBack);
                }
                else
                {
                    vdec_set_output(pDecvDevice,	DUAL_PREVIEW_MODE, &tInitInfo, &MPCallBack, &PIPCallBack);
                }
            }
            if(!is_cur_decoder_avc())
            {
                vdec_start(pDecvDevice);
            }
            if(is_cur_decoder_avc() && need_to_wait)
            {
                struct dmx_device *dmx = (struct dmx_device *)dev_get_by_id(HLD_DEV_TYPE_DMX, 0);

                //For H264, we have to wait for 1st picture decoded, then call vpo_zoom, otherwise, it could cause below issue:
                //1. DE under run, because DE can scale down HD full size picture to preview size
                //2. In full screen mode, VE mapping is H264 mapping mode, in preview mode, VE mapping is MPEG2 mapping mode
                //--Michael Xie 2007/8/29
                wait_total_time = VE_MODE_SWITCH_TIME;
                while(waittime<wait_total_time)
                {
                    nim_get_lock(nim, &ulock);
                    if(!ulock)
                        break;
                    if(RET_SUCCESS == dmx_io_control(dmx, IS_AV_SCRAMBLED, 0))
                        break;
                    vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
                    if(vdec_info.uFirstPicShowed)
                    {
                        wait_total_time = H264_VE_MODE_SWITCH_TIME;
                    }

                    if(vdec_info.output_mode == PREVIEW_MODE)
                    {
                        osal_task_sleep(100);
                        break;
                    }
                    osal_task_sleep(1);
                    waittime++;
                }
            }

            vpo_zoom(pDisDevice, &l_hde_rectSrcFull_adjusted, &l_hde_rectScrnPreview);
#ifdef DUAL_VIDEO_OUTPUT
            vpo_zoom(pDisDevice_O, &l_hde_rectSrcFull_adjusted, &l_hde_rectScrnPreview);
#endif

#else
            //Set Video Decoder Output Mode (PREVIEW_MODE)
            tInitInfo.src_rect.uStartX = l_hde_rectSrcFull_adjusted.uStartX>>1;
            tInitInfo.src_rect.uStartY= l_hde_rectSrcFull_adjusted.uStartY>>1;
            tInitInfo.src_rect.uWidth = PICTURE_WIDTH - 2*tInitInfo.src_rect.uStartX;
            tInitInfo.src_rect.uHeight = PICTURE_HEIGHT - 2*tInitInfo.src_rect.uStartY;
            tInitInfo.dst_rect.uStartX = l_hde_rectScrnPreview.uStartX;
            tInitInfo.dst_rect.uStartY= l_hde_rectScrnPreview.uStartY;
            tInitInfo.dst_rect.uWidth = l_hde_rectScrnPreview.uWidth;
            tInitInfo.dst_rect.uHeight = l_hde_rectScrnPreview.uHeight;
            vdec_set_output(pDecvDevice,PREVIEW_MODE, &tInitInfo, &MPCallBack,&PIPCallBack);

            //Wait Video Decoder Output Mode Switch to PREVIEW_MODE
            vdec_info.output_mode = VIEW_MODE_FULL;
            while((vdec_info.output_mode != PREVIEW_MODE)&&(waittime<VE_MODE_SWITCH_TIME))
            {
                nim_get_lock(nim, &ulock);
                if(!ulock)
                    break;
                osal_task_sleep(1);
                waittime++;
                vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
            }

            //Switch Video Decoder Output Mode to PREVIEW_MODE Forcely
            if(vdec_info.output_mode != PREVIEW_MODE)
            {
                PRINTF("switch to preview forcely\n");

                vdec_stop(pDecvDevice,sys_data_get_cur_chan_mode() == PROG_TV_MODE,FALSE);
                vdec_set_output(pDecvDevice,PREVIEW_MODE, &tInitInfo, &MPCallBack,&PIPCallBack);
                vdec_start(pDecvDevice);
            }
#endif
#elif(VDEC27_PREVIEW_SOLUTION == VDEC27_PREVIEW_DE_SCALE)
            //If is DE Scale Operation, then adjust VPO Full Srceen to Preview Screen directly
            if(0 == l_hde_preview_method)
                vpo_zoom(pDisDevice, &l_hde_rectSrcFull_adjusted, &l_hde_rectScrnPreview);
            //If is VE Scale Operation, first set Video Decoder Output Mode(PIP_MODE),
            //then adjust VPO Full Srceen to Preview Screen
            else if(1 == l_hde_preview_method)
            {
                if(l_hde_mode == VIEW_MODE_PREVIEW)
                {
                    vpo_zoom(pDisDevice, &l_hde_rectSrcFull_adjusted, &l_hde_rectScrnPreview);
                }
                else
                {
                    //Set Video Decoder Output Mode (IND_PIP_MODE)
                    tInitInfo.src_rect.uStartX = l_hde_rectSrcFull_adjusted.uStartX>>1;
                    tInitInfo.src_rect.uStartY= l_hde_rectSrcFull_adjusted.uStartY>>1;
                    tInitInfo.src_rect.uWidth = PICTURE_WIDTH - 2*tInitInfo.src_rect.uStartX;
                    tInitInfo.src_rect.uHeight = PICTURE_HEIGHT - 2*tInitInfo.src_rect.uStartY;
                    tInitInfo.dst_rect.uStartX = l_hde_rectScrnPreview.uStartX;
                    tInitInfo.dst_rect.uStartY= l_hde_rectScrnPreview.uStartY;
                    tInitInfo.dst_rect.uWidth = l_hde_rectScrnPreview.uWidth;
                    tInitInfo.dst_rect.uHeight = l_hde_rectScrnPreview.uHeight;
                    tInitInfo.pipSize.uWidth=l_hde_rectScrnPreview.uWidth;
                    tInitInfo.pipSize.uHeight=l_hde_rectScrnPreview.uHeight/5;
                    vdec_set_output(pDecvDevice,IND_PIP_MODE, &tInitInfo, &MPCallBack,&PIPCallBack);

                    //After Video Decoder Output Mode switch to PIP_MODE, then adjust VPO
                    vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
                    if(VDEC27_STOPPED == vdec_info.uCurStatus)
                    {
                        vpo_zoom(pDisDevice, &l_hde_rectSrcFull_adjusted, &l_hde_rectScrnPreview);
                    }
                    else
                    {
                        waittime = 0;
                        while((vdec_info.output_mode != PIP_MODE)&&(waittime<VE_MODE_SWITCH_TIME_29E))
                        {
                            nim_get_lock(nim, &ulock);
                            if(!ulock)
                                break;
                            osal_task_sleep(20);
                            waittime += 20;
                            vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
                        }
                        if(vdec_info.output_mode != PIP_MODE)
                        {
                            vdec_stop(pDecvDevice,TRUE,FALSE);
                            vdec_set_output(pDecvDevice,IND_PIP_MODE, &tInitInfo, &MPCallBack,&PIPCallBack);
                            vdec_start(pDecvDevice);
                            vpo_zoom(pDisDevice, &l_hde_rectSrcFull_adjusted, &l_hde_rectScrnPreview);
                        }
                        else
                        {
                            vpo_zoom(pDisDevice, &l_hde_rectSrcFull_adjusted, &l_hde_rectScrnPreview);
                        }
                    }
                    vpo_ioctl(pDisDevice, VPO_IO_ADJUST_LM_IN_PREVIEW, 1);

                }
            }
#endif
        }
        l_hde_uIsPreviewResize = 0;
        LEAVE_CCHDE_API();
        break;
    case VIEW_MODE_MULTI:
        break;
    case VIEW_MODE_FULL:
    default:
        if (l_hde_mode != mode)
        {
            ENTER_CCHDE_API();
#if(	VDEC27_PREVIEW_SOLUTION == VDEC27_PREVIEW_VE_SCALE)
#ifdef HDTV_SUPPORT
            // convert VE to MP mode
            vpo_ioctl(pDisDevice, VPO_IO_GET_INFO, (UINT32) &dis_info);
#ifdef DUAL_VIDEO_OUTPUT
            vpo_ioctl(pDisDevice_O, VPO_IO_GET_INFO, (UINT32) &dis_info);
#endif
            need_to_set_output = FALSE;
            if(is_cur_decoder_avc())
            {
                vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
                if(vdec_info.pic_width > 720 || vdec_info.pic_height > 576)
                {
                    need_to_wait = TRUE;
                }
                else if(vdec_info.pic_width == 0 || vdec_info.pic_height == 0)
                {
                    need_to_set_output = TRUE;
                }
                else
                    need_to_wait = FALSE;
            }
            else
            {
                need_to_wait = TRUE;
                vdec_stop(pDecvDevice,TRUE,TRUE);
            }

            if(need_to_wait || need_to_set_output)
            {
                tInitInfo.adv_setting.init_mode = 0;
                tInitInfo.adv_setting.out_sys = dis_info.tvsys;
                tInitInfo.adv_setting.bprogressive = dis_info.bprogressive;
#ifdef DUAL_VIDEO_OUTPUT
                if(is_cur_decoder_avc())
#else
                if(0)
#endif
                {
                    vdec_set_output(pDecvDevice,DUAL_MODE, &tInitInfo, &MPCallBack, &PIPCallBack);
                }
                else
                {
                    vdec_set_output(pDecvDevice,DUAL_MODE, &tInitInfo, &MPCallBack, &PIPCallBack);
                }
            }
            if(!is_cur_decoder_avc())
            {
                vdec_start(pDecvDevice);
            }

            vpo_zoom(pDisDevice, &l_hde_rectSrcFull, &l_hde_rectScrnFull);
#ifdef DUAL_VIDEO_OUTPUT
            vpo_zoom(pDisDevice_O, &l_hde_rectSrcFull, &l_hde_rectScrnFull);
#endif
            osal_task_sleep(50);
            if(is_cur_decoder_avc() && need_to_wait)
            {
                struct dmx_device *dmx = (struct dmx_device *)dev_get_by_id(HLD_DEV_TYPE_DMX, 0);

                wait_total_time = VE_MODE_SWITCH_TIME;
                while(waittime<wait_total_time)
                {
                    nim_get_lock(nim, &ulock);
                    if(!ulock)
                        break;
                    if(RET_SUCCESS == dmx_io_control(dmx, IS_AV_SCRAMBLED, 0))
                        break;
                    vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
                    if(vdec_info.uFirstPicShowed)
                    {
                        wait_total_time = H264_VE_MODE_SWITCH_TIME;
                    }

                    if(vdec_info.output_mode == MP_MODE)
                    {
                        break;
                    }
                    osal_task_sleep(1);
                    waittime++;
                }
            }

#else
            //Set Video Decoder Output Mode (MP_MODE)
            tInitInfo.buse_sml_buf = FALSE;
            tInitInfo.src_rect.uStartX = l_hde_rectSrcFull.uStartX;
            tInitInfo.src_rect.uStartY= l_hde_rectSrcFull.uStartY;
            tInitInfo.src_rect.uWidth = l_hde_rectSrcFull.uWidth;
            tInitInfo.src_rect.uHeight = l_hde_rectSrcFull.uHeight;
            tInitInfo.dst_rect.uStartX = l_hde_rectScrnFull.uStartX;
            tInitInfo.dst_rect.uStartY= l_hde_rectScrnFull.uStartY;
            tInitInfo.dst_rect.uWidth = l_hde_rectScrnFull.uWidth;
            tInitInfo.dst_rect.uHeight = l_hde_rectScrnFull.uHeight;
            vdec_set_output(pDecvDevice,MP_MODE, &tInitInfo, &MPCallBack,&PIPCallBack);

            //Wait Video Decoder Output Mode Switch to MP_MODE
            vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
            while(((vdec_info.output_mode != MP_MODE)||(vdec_info.use_sml_buf))&&(waittime<VE_MODE_SWITCH_TIME))
            {
                nim_get_lock(nim, &ulock);
                if(!ulock)
                    break;
                osal_task_sleep(1);
                waittime++;
                vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
            }
            //Switch Video Decoder Output Mode to MP_MODE Forcely
            if((vdec_info.output_mode != MP_MODE)||(vdec_info.use_sml_buf))
            {
                PRINTF("switch to mp forcely\n");

                vdec_stop(pDecvDevice,TRUE,FALSE);
                vdec_set_output(pDecvDevice,MP_MODE, &tInitInfo, &MPCallBack,&PIPCallBack);
                vdec_start(pDecvDevice);
            }
#endif
#elif(VDEC27_PREVIEW_SOLUTION == VDEC27_PREVIEW_DE_SCALE)
            //If is DE Scale Operation, then adjust VPO to Full Srceen directly
            if(0 == l_hde_preview_method)
                vpo_zoom(pDisDevice, &l_hde_rectSrcFull, &l_hde_rectScrnFull);
            //If is VE Scale Operation, first set Video Decoder Output Mode(MP_MODE),
            //then adjust VPO to Full Srceen
            else if(1 == l_hde_preview_method)
            {
                //Set Video Decoder Output Mode (MP_MODE)
                tInitInfo.src_rect.uStartX = l_hde_rectSrcFull.uStartX;
                tInitInfo.src_rect.uStartY= l_hde_rectSrcFull.uStartY;
                tInitInfo.src_rect.uWidth = l_hde_rectSrcFull.uWidth;
                tInitInfo.src_rect.uHeight = l_hde_rectSrcFull.uHeight;
                tInitInfo.dst_rect.uStartX = l_hde_rectScrnFull.uStartX;
                tInitInfo.dst_rect.uStartY= l_hde_rectScrnFull.uStartY;
                tInitInfo.dst_rect.uWidth = l_hde_rectScrnFull.uWidth;
                tInitInfo.dst_rect.uHeight = l_hde_rectScrnFull.uHeight;
                vdec_set_output(pDecvDevice,MP_MODE, &tInitInfo, &MPCallBack,&PIPCallBack);

                //After Video Decoder Output Mode switch to MP_MODE, then adjust VPO
                vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
                if(VDEC27_STOPPED == vdec_info.uCurStatus)
                {
                    vpo_zoom(pDisDevice, &l_hde_rectSrcFull, &l_hde_rectScrnFull);
                }
                else
                {
                    waittime = 0;
                    while((vdec_info.output_mode != MP_MODE)&&(waittime<VE_MODE_SWITCH_TIME_29E))
                    {
                        nim_get_lock(nim, &ulock);
                        if(!ulock)
                            break;
                        osal_task_sleep(20);
                        waittime += 20;
                        vdec_io_control(pDecvDevice, VDEC_IO_GET_STATUS, (UINT32)&vdec_info);
                    }
                    if(vdec_info.output_mode != MP_MODE)
                    {
                        vdec_stop(pDecvDevice,TRUE,FALSE);
                        vdec_set_output(pDecvDevice,MP_MODE, &tInitInfo, &MPCallBack,&PIPCallBack);
                        vdec_start(pDecvDevice);
                        vpo_zoom(pDisDevice, &l_hde_rectSrcFull, &l_hde_rectScrnFull);
                    }
                    else
                    {
                        vpo_zoom(pDisDevice, &l_hde_rectSrcFull, &l_hde_rectScrnFull);
                    }
                }

                vpo_ioctl(pDisDevice, VPO_IO_ADJUST_LM_IN_PREVIEW, 0);
            }
#endif
            LEAVE_CCHDE_API();
        }
    }