omxvideoenctest.c File Reference

#include "omxvideoenctest.h"

Go to the source code of this file.

Defines

#define MPEG4_TYPE_SEL   1
#define COMPONENT_NAME_BASE   "OMX.st.video_encoder"
#define BASE_ROLE   "video_encoder.mpeg4"
#define COMPONENT_NAME_BASE_LEN   20

Functions

OMX_ERRORTYPE test_OMX_ComponentNameEnum ()
OMX_ERRORTYPE test_OMX_RoleEnum (OMX_STRING component_name)
OMX_ERRORTYPE test_OMX_ComponentEnumByRole (OMX_STRING role_name)
OMX_ERRORTYPE test_OpenClose (OMX_STRING component_name)
int find_encoder (char *searchname)
void display_help ()
int setPortParameters ()
int main (int argc, char **argv)
OMX_ERRORTYPE videosrcEventHandler (OMX_OUT OMX_HANDLETYPE hComponent, OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_EVENTTYPE eEvent, OMX_OUT OMX_U32 Data1, OMX_OUT OMX_U32 Data2, OMX_OUT OMX_PTR pEventData)
OMX_ERRORTYPE videosrcFillBufferDone (OMX_OUT OMX_HANDLETYPE hComponent, OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_BUFFERHEADERTYPE *pBuffer)
OMX_ERRORTYPE videoencEventHandler (OMX_OUT OMX_HANDLETYPE hComponent, OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_EVENTTYPE eEvent, OMX_OUT OMX_U32 Data1, OMX_OUT OMX_U32 Data2, OMX_OUT OMX_PTR pEventData)
OMX_ERRORTYPE videoencEmptyBufferDone (OMX_OUT OMX_HANDLETYPE hComponent, OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_BUFFERHEADERTYPE *pBuffer)
OMX_ERRORTYPE videoencFillBufferDone (OMX_OUT OMX_HANDLETYPE hComponent, OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_BUFFERHEADERTYPE *pBuffer)

Variables

OMX_CALLBACKTYPE videoenccallbacks
OMX_CALLBACKTYPE videosrccallbacks
appPrivateTypeappPriv
char * input_file
char * output_file
FILE * infile
FILE * outfile
int selectedType = 0
OMX_U32 in_width = 176
OMX_U32 in_height = 144
OMX_U32 frame_rate = 25
int buffer_in_size = 176*144*3/2
OMX_U32 buffer_out_size = 32768
OMX_U32 outbuf_colorconv_size
char codecName [10]
OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar
OMX_BUFFERHEADERTYPEpInBuffer [2]
OMX_BUFFERHEADERTYPEpOutBuffer [2]
OMX_BUFFERHEADERTYPEpSrcOutBuffer [2]
OMX_PARAM_PORTDEFINITIONTYPE paramPort
OMX_PARAM_COMPONENTROLETYPE paramRole
OMX_VIDEO_PARAM_PORTFORMATTYPE omxVideoParam
int flagIsOutputExpected
int flagIsInputExpected
int flagOutputReceived
int flagInputReceived
int flagIsFormatRequested
int flagIsWidth
int flagIsHeight
int flagIsCameraRequested
int flagSetupTunnel
int flagIsFPS


Detailed Description

Test application that uses a OpenMAX component, a generic video encoder. The application receives an video stream (.yuv) encode in Mpeg4 Video format(.m4v).

Copyright (C) 2008 STMicroelectronics Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

$Date$ Revision $Rev$ Author $Author$

Definition in file omxvideoenctest.c.


Define Documentation

#define BASE_ROLE   "video_encoder.mpeg4"

Definition at line 35 of file omxvideoenctest.c.

#define COMPONENT_NAME_BASE   "OMX.st.video_encoder"

Definition at line 34 of file omxvideoenctest.c.

#define COMPONENT_NAME_BASE_LEN   20

Definition at line 36 of file omxvideoenctest.c.

#define MPEG4_TYPE_SEL   1

defining global declarations

Definition at line 33 of file omxvideoenctest.c.


Function Documentation

void display_help (  ) 

help display

Definition at line 232 of file omxvideoenctest.c.

int find_encoder ( char *  searchname  ) 

Try to determine encoder type based on filename

Definition at line 215 of file omxvideoenctest.c.

References codecName.

int main ( int  argc,
char **  argv 
)

output file name check

determine the output file format in case of encoding

getting video source handle

getting video encoder handle

if tunneling option is given then set up the tunnel between the components

output buffer size calculation based on input dimension speculation

sending command to video encoder component to go to idle state

sending command to video source component to go to idle state

sending command to video encoder component to go to executing state

sending command to video source component to go to executing state

in tunneled case, disable the video components ports and then set parameters after that, ebnable those ports

state change of all components from executing to idle

sending command to all components to go to loaded state

freeing buffers of color conv and sink component

freeing buffers of video encoder input ports

closing the output file

closing the input file

Definition at line 298 of file omxvideoenctest.c.

References BASE_ROLE, buffer_in_size, buffer_out_size, codecName, COMPONENT_NAME_BASE, COMPONENT_NAME_BASE_LEN, OMX_PARAM_COMPONENTROLETYPE::cRole, DEB_LEV_ERR, DEB_LEV_PARAMS, DEB_LEV_SIMPLE_SEQ, DEBUG, DEFAULT_MESSAGES, display_help(), appPrivateType::encoderEventSem, appPrivateType::eofSem, err, flagInputReceived, flagIsCameraRequested, flagIsFormatRequested, flagIsFPS, flagIsHeight, flagIsInputExpected, flagIsOutputExpected, flagIsWidth, flagOutputReceived, flagSetupTunnel, frame_rate, in_height, in_width, infile, input_file, MPEG4_TYPE_SEL, OMX_BUFFERHEADERTYPE::nFilledLen, OMX_BUFFERHEADERTYPE::nOffset, OMX_AllocateBuffer, OMX_CommandStateSet, OMX_Deinit(), OMX_EmptyThisBuffer, OMX_ErrorNone, OMX_FillThisBuffer, OMX_FreeBuffer, OMX_FreeHandle(), OMX_GetHandle(), OMX_GetParameter, OMX_IndexParamStandardComponentRole, OMX_Init(), OMX_MAX_STRINGNAME_SIZE, OMX_SendCommand, OMX_SetupTunnel(), OMX_StateExecuting, OMX_StateIdle, OMX_StateLoaded, OMX_TRUE, OMX_UseBuffer, outfile, output_file, OMX_BUFFERHEADERTYPE::pBuffer, selectedType, setHeader(), setPortParameters(), appPrivateType::sourceEventSem, test_OMX_ComponentEnumByRole(), test_OMX_ComponentNameEnum(), test_OMX_RoleEnum(), test_OpenClose(), tsem_down(), tsem_init(), appPrivateType::videoenchandle, and appPrivateType::videosrchandle.

int setPortParameters (  ) 

this function sets the video source and encoder port characteristics

setting the color converter and sink component chararacteristics, if selected - both in tunneled as well as non tunneled case

setting the color conv input port width, height it will be same as the video decoder output port width, height

setting the color converter output width height it will be same as input dimensions

setting the input color format of color converter component it will be same as output yuv color format of the decoder component

setting output RGB color format of the color converter component

if video sink component is selected then set its input port settings accroding to the output port settings of the color converter component

Definition at line 267 of file omxvideoenctest.c.

References COLOR_CONV_OUT_RGB_FORMAT, appPrivateType::colorconv_handle, DEB_LEV_ERR, DEB_LEV_SIMPLE_SEQ, DEBUG, DEFAULT_MESSAGES, OMX_VIDEO_PARAM_PORTFORMATTYPE::eColorFormat, OMX_VIDEO_PORTDEFINITIONTYPE::eColorFormat, err, appPrivateType::fbdev_sink_handle, flagIsCameraRequested, flagIsColorConvRequested, flagIsSinkRequested, OMX_PARAM_PORTDEFINITIONTYPE::format, frame_rate, in_height, in_width, OMX_PARAM_PORTDEFINITIONTYPE::nBufferSize, OMX_VIDEO_PORTDEFINITIONTYPE::nFrameHeight, OMX_VIDEO_PORTDEFINITIONTYPE::nFrameWidth, OMX_VIDEO_PARAM_PORTFORMATTYPE::nPortIndex, OMX_PARAM_PORTDEFINITIONTYPE::nPortIndex, OMX_COLOR_FormatYUV420Planar, OMX_ErrorBadParameter, OMX_ErrorNone, OMX_GetParameter, OMX_IndexParamPortDefinition, OMX_IndexParamVideoPortFormat, OMX_SetParameter, out_height, out_width, setHeader(), OMX_PARAM_PORTDEFINITIONTYPE::video, appPrivateType::videoenchandle, appPrivateType::videosrchandle, and OMX_VIDEO_PORTDEFINITIONTYPE::xFramerate.

Referenced by main(), and videodecEventHandler().

OMX_ERRORTYPE test_OMX_ComponentEnumByRole ( OMX_STRING  role_name  ) 

OMX_ERRORTYPE test_OMX_ComponentNameEnum (  ) 

OMX_ERRORTYPE test_OMX_RoleEnum ( OMX_STRING  component_name  ) 

OMX_ERRORTYPE test_OpenClose ( OMX_STRING  component_name  ) 

OMX_ERRORTYPE videoencEmptyBufferDone ( OMX_OUT OMX_HANDLETYPE  hComponent,
OMX_OUT OMX_PTR  pAppData,
OMX_OUT OMX_BUFFERHEADERTYPE pBuffer 
)

OMX_ERRORTYPE videoencEventHandler ( OMX_OUT OMX_HANDLETYPE  hComponent,
OMX_OUT OMX_PTR  pAppData,
OMX_OUT OMX_EVENTTYPE  eEvent,
OMX_OUT OMX_U32  Data1,
OMX_OUT OMX_U32  Data2,
OMX_OUT OMX_PTR  pEventData 
)

OMX_ERRORTYPE videoencFillBufferDone ( OMX_OUT OMX_HANDLETYPE  hComponent,
OMX_OUT OMX_PTR  pAppData,
OMX_OUT OMX_BUFFERHEADERTYPE pBuffer 
)

OMX_ERRORTYPE videosrcEventHandler ( OMX_OUT OMX_HANDLETYPE  hComponent,
OMX_OUT OMX_PTR  pAppData,
OMX_OUT OMX_EVENTTYPE  eEvent,
OMX_OUT OMX_U32  Data1,
OMX_OUT OMX_U32  Data2,
OMX_OUT OMX_PTR  pEventData 
)

OMX_ERRORTYPE videosrcFillBufferDone ( OMX_OUT OMX_HANDLETYPE  hComponent,
OMX_OUT OMX_PTR  pAppData,
OMX_OUT OMX_BUFFERHEADERTYPE pBuffer 
)

if there is color conv component in processing state then send this buffer, in non tunneled case else in non tunneled case, write the output buffer contents in the specified output file

Definition at line 738 of file omxvideoenctest.c.

References appPrivateType::colorconv_handle, DEB_LEV_ERR, DEBUG, DEFAULT_MESSAGES, err, flagIsColorConvRequested, flagSetupTunnel, OMX_BUFFERHEADERTYPE::nFilledLen, OMX_BUFFERFLAG_EOS, OMX_EmptyThisBuffer, OMX_ErrorNone, OMX_FillThisBuffer, OMX_GetState, OMX_StateExecuting, OMX_StatePause, OMX_TRUE, outfile, OMX_BUFFERHEADERTYPE::pBuffer, and appPrivateType::videoenchandle.


Variable Documentation

global variables

Definition at line 51 of file omxvideoenctest.c.

int buffer_in_size = 176*144*3/2

Definition at line 60 of file omxvideoenctest.c.

Definition at line 61 of file omxvideoenctest.c.

char codecName[10]

Definition at line 63 of file omxvideoenctest.c.

Referenced by find_encoder(), and main().

OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar

Definition at line 65 of file omxvideoenctest.c.

Definition at line 258 of file omxvideoenctest.c.

Definition at line 262 of file omxvideoenctest.c.

Referenced by main(), setPortParameters(), and videoencEmptyBufferDone().

Definition at line 259 of file omxvideoenctest.c.

int flagIsFPS

Definition at line 264 of file omxvideoenctest.c.

Referenced by main().

Definition at line 261 of file omxvideoenctest.c.

Referenced by main().

Definition at line 256 of file omxvideoenctest.c.

Referenced by main().

Definition at line 255 of file omxvideoenctest.c.

Definition at line 260 of file omxvideoenctest.c.

Referenced by main().

Definition at line 257 of file omxvideoenctest.c.

Definition at line 263 of file omxvideoenctest.c.

Definition at line 59 of file omxvideoenctest.c.

Referenced by main(), and setPortParameters().

Definition at line 58 of file omxvideoenctest.c.

Referenced by main(), omx_ffmpeg_colorconv_component_Init(), and setPortParameters().

Definition at line 57 of file omxvideoenctest.c.

Referenced by main(), omx_ffmpeg_colorconv_component_Init(), and setPortParameters().

FILE* infile

Definition at line 54 of file omxvideoenctest.c.

Referenced by main(), and videoencEmptyBufferDone().

char* input_file

Definition at line 53 of file omxvideoenctest.c.

Definition at line 72 of file omxvideoenctest.c.

Definition at line 62 of file omxvideoenctest.c.

FILE * outfile

Definition at line 54 of file omxvideoenctest.c.

char * output_file

Definition at line 53 of file omxvideoenctest.c.

Definition at line 70 of file omxvideoenctest.c.

Definition at line 71 of file omxvideoenctest.c.

used with video encoder

Definition at line 68 of file omxvideoenctest.c.

Definition at line 68 of file omxvideoenctest.c.

Definition at line 68 of file omxvideoenctest.c.

int selectedType = 0

Definition at line 55 of file omxvideoenctest.c.

Initial value:

 { 
    .EventHandler = videoencEventHandler,
    .EmptyBufferDone = videoencEmptyBufferDone,
    .FillBufferDone = videoencFillBufferDone
  }

Definition at line 38 of file omxvideoenctest.c.

Initial value:

 { 
    .EventHandler = videosrcEventHandler,
    .EmptyBufferDone = NULL,
    .FillBufferDone = videosrcFillBufferDone
  }

Definition at line 44 of file omxvideoenctest.c.


Generated for OpenMAX Bellagio rel. 0.3.5-svn by  doxygen 1.5.1
SourceForge.net Logo