Пример #1
0
void ipu_buffer_update(ipu_lib_handle_t* ipu_handle, const unsigned char* input_data, unsigned char* output_data)
{
	global_ipu_handle= ipu_handle;

	if(!skip_next_frame)
		MEMCPY(ipu_handle->inbuf_start[0], input_data, ipu_handle->ifr_size);

	next_update_index = mxc_ipu_lib_task_buf_update(ipu_handle, 0, 0, 0, ipu_output_callback, output_data);

	skip_next_frame = (next_update_index == -1);
}
OMX_ERRORTYPE IpulibRender::IpulibRenderFrame(OMX_PTR pFrame)
{
	int ret;

	/* call ipu task */
	ret = mxc_ipu_lib_task_buf_update(&ipu_handle, (int)pFrame, NULL, NULL, NULL, NULL);
	if(ret < 0)
	{
		LOG_ERROR("mxc_ipu_lib_task_buf_update failed, ret: %d\n", ret);
		return OMX_ErrorHardware;
	}

	return OMX_ErrorNone;
}
Пример #3
0
void ipu_disp_loop_thread(void *arg)
{
	struct decode *dec = (struct decode *)arg;
	DecHandle handle = dec->handle;
	struct vpu_display *disp = dec->disp;
	int index = -1, disp_clr_index, tmp_idx[3] = {0,0,0}, err, mode;
	pthread_attr_t attr;

	ipu_running = 1;

	pthread_attr_init(&attr);
	pthread_attr_setschedpolicy(&attr, SCHED_RR);

	while(1) {
		disp_clr_index = index;
		index = dequeue_buf(&(disp->ipu_q));
		if (index < 0) {
			wait_queue();
			ipu_waiting = 0;
			index = dequeue_buf(&(disp->ipu_q));
			if (index < 0) {
				info_msg("thread is going to finish\n");
				break;
			}
		}

		if (disp->ncount == 0) {
			disp->input.user_def_paddr[0] = disp->ipu_bufs[index].ipu_paddr;
			/* For video de-interlace, Low/Medium motion */
			tmp_idx[0] = index;
		} else if ((disp->deinterlaced == 1) && (disp->input.motion_sel != HIGH_MOTION) && (disp->ncount == 1)) {
			disp->input.user_def_paddr[1] = disp->ipu_bufs[index].ipu_paddr;
			/* For video de-interlace, Low/Medium motion */
			tmp_idx[1] = index;
		} else if ((disp->ncount == 1) || ((disp->deinterlaced == 1) && (disp->input.motion_sel != HIGH_MOTION) &&
						 (disp->ncount == 2))) {
			disp->input.user_def_paddr[disp->ncount] = disp->ipu_bufs[index].ipu_paddr;
			mode = (disp->deinterlaced == 1) ? (OP_STREAM_MODE | TASK_VDI_VF_MODE) : (OP_STREAM_MODE | TASK_PP_MODE);
			err = mxc_ipu_lib_task_init(&(disp->input), NULL, &(disp->output), mode, &(disp->ipu_handle));
			if (err < 0) {
				err_msg("mxc_ipu_lib_task_init failed, err %d\n", err);
				quitflag = 1;
				return;
			}
			/* it only enable ipu task and finish first frame */
			err = mxc_ipu_lib_task_buf_update(&(disp->ipu_handle), 0, 0, 0, NULL, NULL);
			if (err < 0) {
				err_msg("mxc_ipu_lib_task_buf_update failed, err %d\n", err);
				quitflag = 1;
				break;
			}
			/* For video de-interlace, Low/Medium motion */
			tmp_idx[2] = index;
			if ((disp->deinterlaced == 1) && (disp->input.motion_sel != HIGH_MOTION))
				disp_clr_index = tmp_idx[0];
		} else {
			err = mxc_ipu_lib_task_buf_update(&(disp->ipu_handle), disp->ipu_bufs[index].ipu_paddr,
					0, 0, NULL, NULL);
			if (err < 0) {
				err_msg("mxc_ipu_lib_task_buf_update failed, err %d\n", err);
				quitflag = 1;
				break;
			}
			/* For video de-interlace, Low/Medium motion */
			if ((disp->deinterlaced == 1) && (disp->input.motion_sel != HIGH_MOTION)) {
				tmp_idx[0] = tmp_idx[1];
				tmp_idx[1] = tmp_idx[2];
				tmp_idx[2] = index;
				disp_clr_index = tmp_idx[0];
			}
		}

		if ((dec->cmdl->format != STD_MJPG) && (disp_clr_index >= 0) && (!disp->stopping) &&
		    !((disp->deinterlaced == 1) && (disp->input.motion_sel != HIGH_MOTION) && (disp->ncount < 2))) {
			err = vpu_DecClrDispFlag(handle, disp_clr_index);
			if (err) {
				err_msg("vpu_DecClrDispFlag failed Error code %d\n", err);
				quitflag = 1;
				break;
			}
		}
		disp->ncount++;
	}
	mxc_ipu_lib_task_uninit(&(disp->ipu_handle));
	pthread_attr_destroy(&attr);
	info_msg("Disp loop thread exit\n");
	ipu_running = 0;
	return;
}
OMX_ERRORTYPE VideoProcessorComponent::VideoProcessor_ProcessData( OMX_PTR buf)
{
    OMX_ERRORTYPE eRetVal = OMX_ErrorNone;
    OMX_BUFFERHEADERTYPE *pOutBuffer;
    OMX_U32 size = 0;
    int ret;

    VP_DEBUG(" Process data %p\n",buf);

    /* call ipu task */
    ret = mxc_ipu_lib_task_buf_update(&ipu_handle, (int)buf, NULL, NULL, ipu_output_cb, this);
    if(ret < 0)
    {
        VP_ERROR("mxc_ipu_lib_task_buf_update failed.\n");
        SendEvent(OMX_EventError, OMX_ErrorHardware, 0, NULL);
        return OMX_ErrorHardware;
    }

    /* check if processing buffer is empty */
    if(pInBufHdr[0] == NULL)
    {
        VP_ERROR("processing buffer queue is empty.\n");
        SendEvent(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
        return OMX_ErrorUndefined;
    }

    if(bUseEGLImage == OMX_TRUE)
    {
        pOutBuffer = pOutBufHdr[0];
        pOutBufHdr[0] = pOutBufHdr[1];
        pOutBufHdr[1] = NULL;
    }
    else
        ports[VP_OUT_PORT]->GetBuffer(&pOutBuffer);

    pOutBuffer->nTimeStamp = pInBufHdr[0]->nTimeStamp;
    pOutBuffer->nFlags = pInBufHdr[0]->nFlags;

    /* return processed input buffer */
    ports[VP_IN_PORT]->SendBuffer(pInBufHdr[0]);
    pInBufHdr[0] = pInBufHdr[1];
    pInBufHdr[1] = NULL;

    if(pInBufHdr[0]->nFlags & OMX_BUFFERFLAG_EOS)
    {
        printf("VPP send EOS buffer.\n");
        pOutBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
    }

    /* check if need to flush previous frame */
    if(bFlush == OMX_FALSE)
    {
        size = (nOutWidth&(~7)) * nOutHeight * pxlfmt2bpp(eOutColorFmt)/8;
        if(bUseEGLImage != OMX_TRUE)
            fsl_osal_memcpy(pOutBuffer->pBuffer, ipu_handle.outbuf_start[nOutBufIdx], size);
        pOutBuffer->nFilledLen = size;
        pOutBuffer->nOffset = 0;
        nOutFrames++ ;

        //printf("Send eglImage: %p\n", pOutBuffer->pPlatformPrivate);

        ports[VP_OUT_PORT]->SendBuffer(pOutBuffer);
    }
    else
        bFlush = OMX_FALSE;

    VP_DEBUG(" Exit process data\n");
    return eRetVal;
}
Пример #5
0
void ipu_disp_loop_thread(void *arg)
{
	struct DecodingInstance *dec = (struct DecodingInstance *)arg;
	struct vpu_display *disp = dec->disp;
	int index = -1, disp_clr_index, tmp_idx[3] = {0,0,0}, err, mode;
	pthread_attr_t attr;

	ipu_running = 1;

	pthread_attr_init(&attr);
	pthread_attr_setschedpolicy(&attr, SCHED_RR);

	while(1) {
		disp_clr_index = index;
		index = dequeue_buf(&(disp->ipu_q));
		if (index < 0) {
			wait_queue();
			ipu_waiting = 0;
			index = dequeue_buf(&(disp->ipu_q));
			if (index < 0) {
				fputs("thread is going to finish\n", stderr);
				break;
			}
		}

		if (disp->ncount == 0) {
			disp->input.user_def_paddr[0] = disp->ipu_bufs[index].ipu_paddr;
			/* For video de-interlace, Low/Medium motion */
			tmp_idx[0] = index;
		}else if ((disp->ncount == 1)) {
			disp->input.user_def_paddr[disp->ncount] = disp->ipu_bufs[index].ipu_paddr;
			mode = (OP_STREAM_MODE | TASK_PP_MODE);
			err = mxc_ipu_lib_task_init(&(disp->input), NULL, &(disp->output), mode, &(disp->ipu_handle));
			if (err < 0) {
				fprintf(stderr, "mxc_ipu_lib_task_init failed, err %d\n", err);
				quitflag = 1;
				return;
			}
			/* it only enable ipu task and finish first frame */
			err = mxc_ipu_lib_task_buf_update(&(disp->ipu_handle), 0, 0, 0, NULL, NULL);
			if (err < 0) {
				fprintf(stderr, "mxc_ipu_lib_task_buf_update failed, err %d\n", err);
				quitflag = 1;
				break;
			}
		} else {
			err = mxc_ipu_lib_task_buf_update(&(disp->ipu_handle), disp->ipu_bufs[index].ipu_paddr,
					0, 0, NULL, NULL);
			if (err < 0) {
				fprintf(stderr, "mxc_ipu_lib_task_buf_update failed, err %d\n", err);
				quitflag = 1;
				break;
			}

		}

		disp->ncount++;
	}
	mxc_ipu_lib_task_uninit(&(disp->ipu_handle));
	pthread_attr_destroy(&attr);
	fputs("Disp loop thread exit\n", stderr);
	ipu_running = 0;
	return;
}