Ejemplo n.º 1
0
static void
goo_engine_outport_cb (GooPort* port, OMX_BUFFERHEADERTYPE* buffer,
                       gpointer data)
{
    g_assert (GOO_IS_PORT (port));
    g_assert (buffer != NULL);
    g_assert (GOO_IS_COMPONENT (data));

    GooComponent* component = GOO_COMPONENT (data);
    GooEngine* self = GOO_ENGINE (
                          g_object_get_data (G_OBJECT (component), "engine")
                      );

    g_assert (self->outstream != NULL);

    if (buffer->nFilledLen <= 0 &&
            (buffer->nFlags & OMX_BUFFERFLAG_EOS) != 0x1)
    {
        GOO_OBJECT_ERROR (self, "Empty buffer received!!");
    }

    if (buffer->nFilledLen > 0)
    {
        GOO_OBJECT_DEBUG (self, "%d bytes written",
                          buffer->nFilledLen);
        fwrite (buffer->pBuffer, 1, buffer->nFilledLen,
                self->outstream);
        /* fflush (self->outfile); */
    }

    /* we count the empty buffer only if it have de EOS flag */
    if ((buffer->nFilledLen > 0) ||
            ((buffer->nFlags & OMX_BUFFERFLAG_EOS) == 0x1 &&
             buffer->nFilledLen == 0))
    {
        g_atomic_int_inc (&self->outcount);
    }

    /* if we assigned the number of buffer to process */
    if (self->numbuffers != 0 && self->outcount == self->numbuffers)
    {
        goo_port_set_eos (port);
    }

    if ((buffer->nFlags & OMX_BUFFERFLAG_EOS) == 0x1 ||
            goo_port_is_eos (port))
    {
        goo_component_set_done (self->component);
    }

    goo_component_release_buffer (component, buffer);

    return;
}
Ejemplo n.º 2
0
static void
goo_ti_sparkdec_validate_ports_definitions (GooComponent* component)
{
        g_assert (GOO_IS_TI_SPARKDEC (component));
        GooTiSparkDec* self = GOO_TI_SPARKDEC (component);
        g_assert (component->cur_state == OMX_StateLoaded);

        OMX_INDEXTYPE index;

	GOO_RUN (
		OMX_GetExtensionIndex (component->handle,
					"OMX.TI.VideoDecode.Param.IsSparkInput",
				       &index)
		);

	GOO_RUN (
		OMX_SetParameter (component->handle,
				  index, &self->bIsSparkInput)
		);

	GOO_OBJECT_DEBUG (self, "is_spark_input = %d", self->bIsSparkInput);

        OMX_PARAM_PORTDEFINITIONTYPE *param;        
        GOO_OBJECT_DEBUG (self, "Entering");
        
        {	/* input */
            GooIterator* iter =
            	goo_component_iterate_input_ports (component);
            goo_iterator_nth (iter, 0);
            GooPort* port = GOO_PORT (goo_iterator_get_current (iter));
            g_assert (port != NULL);
                
            param = GOO_PORT_GET_DEFINITION (port);
                
            param->format.video.cMIMEType = "SPARK";                
            param->format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
			param->format.video.bFlagErrorConcealment = OMX_FALSE;
			
			switch (param->format.video.eColorFormat)
            {
            	case OMX_COLOR_FormatCbYCrY:                
                    param->nBufferSize =
                            param->format.video.nFrameWidth *
                            param->format.video.nFrameHeight * 2;
                    break;
            	case OMX_COLOR_FormatYUV420Planar:
                    param->nBufferSize =
                            (param->format.video.nFrameWidth *
                            param->format.video.nFrameHeight) * 1.5;
                    break;
            	default:
                    GOO_OBJECT_ERROR (self, "Not valid color format");
                    g_assert (FALSE);
					break;
            }
            
            param->format.video.eColorFormat = OMX_VIDEO_CodingUnused;
                					 
            GOO_OBJECT_DEBUG (self, " Input port nFrameWidth : %d nFrameHeight : %d",
                					    param->format.video.nFrameWidth,
                					    param->format.video.nFrameHeight);
                                               
            g_object_unref (iter);
            g_object_unref (port);
        }

        /* output */
        {
            GooIterator* iter =
                    goo_component_iterate_output_ports (component);
            goo_iterator_nth (iter, 0);
            GooPort* port = GOO_PORT (goo_iterator_get_current (iter));
            g_assert (port != NULL);

            param = GOO_PORT_GET_DEFINITION (port);

			param->format.video.cMIMEType = "video/x-raw-yuv";
            param->format.video.pNativeRender = NULL;
            param->format.video.bFlagErrorConcealment = OMX_FALSE;
            param->format.video.eCompressionFormat =OMX_VIDEO_CodingUnused;
            
            switch (param->format.video.eColorFormat)
            {
	            case OMX_COLOR_FormatCbYCrY:                
                    param->nBufferSize =
                            param->format.video.nFrameWidth *
                            param->format.video.nFrameHeight * 2;
                    break;
    	        case OMX_COLOR_FormatYUV420Planar:
                    param->nBufferSize =
                            (param->format.video.nFrameWidth *
                            param->format.video.nFrameHeight) * 1.5;
                    break;
        	    default:
                    GOO_OBJECT_ERROR (self, "Not valid color format");
                    g_assert (FALSE);
					break;
            }
            
            GOO_OBJECT_DEBUG (self, "Output port nFrameWidth : %d nFrameHeight : %d",
            						param->format.video.nFrameWidth,
            						param->format.video.nFrameHeight);
              
                g_object_unref (iter);
                g_object_unref (port);
        }

        GOO_OBJECT_DEBUG (self, "Exit");
        
        return;
}
Ejemplo n.º 3
0
static void
goo_ti_mpeg4dec_720p_validate_ports_definitions (GooComponent* component)
{
	g_assert (GOO_IS_TI_MPEG4DEC720P (component));
	GooTiMpeg4Dec720p* self = GOO_TI_MPEG4DEC720P (component);
	g_assert (component->cur_state == OMX_StateLoaded);

	OMX_PARAM_PORTDEFINITIONTYPE *param;

	GOO_OBJECT_DEBUG (self, "Entering");

	/* input */
	{
		GooIterator* iter =
			goo_component_iterate_input_ports (component);
		goo_iterator_nth (iter, 0);
		GooPort* port = GOO_PORT (goo_iterator_get_current (iter));
		g_assert (port != NULL);

		param = GOO_PORT_GET_DEFINITION (port);

		param->format.video.cMIMEType = "MPEG";
		param->format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
		param->format.video.bFlagErrorConcealment = OMX_FALSE;

		/* ever? */
		switch (param->format.video.eColorFormat)
		{
		case OMX_COLOR_FormatCbYCrY:
		case OMX_COLOR_FormatYCbYCr:
				param->nBufferSize =
					param->format.video.nFrameWidth *
					param->format.video.nFrameHeight / 2;
			break;
		case OMX_COLOR_FormatYUV420PackedPlanar:
			param->nBufferSize =
				(param->format.video.nFrameWidth *
				 param->format.video.nFrameHeight * 3) / 8;
			break;
		default:
			GOO_OBJECT_ERROR (self, "Not valid color format");
			g_assert (FALSE);
		}

		g_object_unref (iter);
		g_object_unref (port);
	}

	/* output */
	{
		GooIterator* iter =
			goo_component_iterate_output_ports (component);
		goo_iterator_nth (iter, 0);
		GooPort* port = GOO_PORT (goo_iterator_get_current (iter));
		g_assert (port != NULL);

		param = GOO_PORT_GET_DEFINITION (port);

		switch (param->format.video.eColorFormat)
		{
		case OMX_COLOR_FormatCbYCrY:
		case OMX_COLOR_FormatYCbYCr:
			param->nBufferSize =
				param->format.video.nFrameWidth *
				param->format.video.nFrameHeight * 2;
			break;
		case OMX_COLOR_FormatYUV420PackedPlanar:
			param->nBufferSize =
				param->format.video.nFrameWidth *
				param->format.video.nFrameHeight * 1.5;
			break;
		default:
			GOO_OBJECT_ERROR (self, "Not valid color format");
			g_assert (FALSE);
		}

                param->format.video.cMIMEType = "YUV";
                param->format.video.pNativeRender = NULL;
                param->format.video.bFlagErrorConcealment = OMX_FALSE;
		param->format.video.eCompressionFormat =
			OMX_VIDEO_CodingUnused;

		/** @todo validate frame size, bitrate and framerate */

		g_object_unref (iter);
		g_object_unref (port);
	}

	GOO_OBJECT_DEBUG (self, "Exit");

	return;
}