omx_fbdev_sink_component.h File Reference

#include <OMX_Types.h>
#include <OMX_Component.h>
#include <OMX_Core.h>
#include <OMX_Video.h>
#include <OMX_IVCommon.h>
#include <pthread.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include <omx_base_video_port.h>
#include <omx_base_sink.h>
#include <linux/fb.h>

Go to the source code of this file.

Defines

#define FBDEV_FILENAME   "/dev/fb0"
#define MAX_NUM_OF_fbdev_sink_component_INSTANCES   2
#define omx_fbdev_sink_component_PortType_FIELDS
#define omx_fbdev_sink_component_PrivateType_FIELDS

Functions

OMX_ERRORTYPE omx_fbdev_sink_component_Constructor (OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName)
OMX_ERRORTYPE omx_fbdev_sink_component_Destructor (OMX_COMPONENTTYPE *openmaxStandComp)
OMX_ERRORTYPE omx_fbdev_sink_component_Init (OMX_COMPONENTTYPE *openmaxStandComp)
OMX_ERRORTYPE omx_fbdev_sink_component_Deinit (OMX_COMPONENTTYPE *openmaxStandComp)
OMX_ERRORTYPE omx_fbdev_sink_component_MessageHandler (OMX_COMPONENTTYPE *, internalRequestMessageType *)
void omx_fbdev_sink_component_BufferMgmtCallback (OMX_COMPONENTTYPE *openmaxStandComp, OMX_BUFFERHEADERTYPE *pInputBuffer)
OMX_ERRORTYPE omx_fbdev_sink_component_SetConfig (OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE omx_fbdev_sink_component_GetParameter (OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR ComponentParameterStructure)
OMX_ERRORTYPE omx_fbdev_sink_component_SetParameter (OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR ComponentParameterStructure)
OMX_ERRORTYPE omx_fbdev_sink_component_GetConfig (OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_INOUT OMX_PTR pComponentConfigStructure)
OMX_COLOR_FORMATTYPE find_omx_pxlfmt (struct fb_var_screeninfo *vscr_info)
enum PixelFormat find_ffmpeg_pxlfmt (OMX_COLOR_FORMATTYPE omx_pxlfmt)
OMX_S32 calcStride (OMX_U32 width, OMX_COLOR_FORMATTYPE omx_pxlfmt)
void omx_img_copy (OMX_U8 *src_ptr, OMX_S32 src_stride, OMX_U32 src_width, OMX_U32 src_height, OMX_S32 src_offset_x, OMX_S32 src_offset_y, OMX_U8 *dest_ptr, OMX_S32 dest_stride, OMX_U32 dest_width, OMX_U32 dest_height, OMX_S32 dest_offset_x, OMX_S32 dest_offset_y, OMX_S32 cpy_width, OMX_U32 cpy_height, OMX_COLOR_FORMATTYPE colorformat, OMX_COLOR_FORMATTYPE fbpxlfmt)
long GetTime ()


Detailed Description

OpenMAX FBDEV sink component. This component is a video sink that copies data to a Linux framebuffer device.

Originally developed by Peter Littlefield Copyright (C) 2007 STMicroelectronics and Agere Systems

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$

OpenMAX FBDEV sink component. This component is a video sink that copies data to a >inux framebuffer device.

Originally developed by Peter Littlefield Copyright (C) 2007 STMicroelectronics and Agere Systems

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 omx_fbdev_sink_component.h.


Define Documentation

#define FBDEV_FILENAME   "/dev/fb0"

Filename of devnode for framebuffer device Should somehow be passed from client

Definition at line 53 of file omx_fbdev_sink_component.h.

Referenced by omx_fbdev_sink_component_Init().

#define MAX_NUM_OF_fbdev_sink_component_INSTANCES   2

Maximum number of sink component instances

Definition at line 56 of file omx_fbdev_sink_component.h.

Referenced by omx_fbdev_sink_component_Constructor().

#define omx_fbdev_sink_component_PortType_FIELDS

Value:

omx_base_video_PortType_FIELDS \ \
  OMX_CONFIG_RECTTYPE omxConfigCrop; \ \
  OMX_CONFIG_ROTATIONTYPE omxConfigRotate; \ \
  OMX_CONFIG_MIRRORTYPE omxConfigMirror; \ \
  OMX_CONFIG_SCALEFACTORTYPE omxConfigScale; \ \
  OMX_CONFIG_POINTTYPE omxConfigOutputPosition;
FBDEV sink port component port structure.

Definition at line 61 of file omx_fbdev_sink_component.h.

#define omx_fbdev_sink_component_PrivateType_FIELDS

Value:

omx_base_sink_PrivateType_FIELDS \ \
  int fd; \ \
  struct fb_var_screeninfo vscr_info; \ \
  struct fb_fix_screeninfo fscr_info; \ \
  unsigned char *scr_ptr; \ \
  OMX_COLOR_FORMATTYPE fbpxlfmt; \ \
  OMX_U32 fbwidth; \ \
  OMX_U32 fbheight; \ \
  OMX_U32 fbbpp; \ \
  OMX_S32 fbstride; \ \
  OMX_U32 product;
FBDEV sink port component private structure. see the define above

Definition at line 78 of file omx_fbdev_sink_component.h.


Function Documentation

OMX_S32 calcStride ( OMX_U32  width,
OMX_COLOR_FORMATTYPE  omx_pxlfmt 
)

finds video stride from input dimension and color format

This function takes two inputs -

Parameters:
width is the input picture width
omx_pxlfmt is the input openmax standard pixel format It calculates the byte per pixel needed to display the picture with the input omx_pxlfmt The output stride for display is thus omx_fbdev_sink_component_Private->product of input width and byte per pixel
This function takes two inputs -
Parameters:
width is the input picture width
omx_pxlfmt is the input openmax standard pixel format It calculates the byte per pixel needed to display the picture with the input omx_pxlfmt The output stride for display is thus product of input width and byte per pixel

Definition at line 291 of file omx_fbdev_sink_component.c.

enum PixelFormat find_ffmpeg_pxlfmt ( OMX_COLOR_FORMATTYPE  omx_pxlfmt  ) 

finds FFmpeg supported pixel format from input OpenMAX standard pixel format

Figure out equivalent FFmpeg PixelFormat based on OMX_COLOR_FORMATTYPE

Parameters:
omx_pxlfmt is the input OpenMAX standard pixel format output is the FFmpeg library supported pixel format corresponding to this input pixel format this output FFmpeg pixel format will be needed in port parameter settings

Definition at line 50 of file omx_ffmpeg_colorconv_component.c.

Referenced by omx_ffmpeg_colorconv_component_SetParameter().

OMX_COLOR_FORMATTYPE find_omx_pxlfmt ( struct fb_var_screeninfo *  vscr_info  ) 

function prototypes of some internal functions finds OpenMAX standard pixel format from screen info

Returns the OpenMAX color format type corresponding to an fbdev fb_var_screeninfo structure

Parameters:
vscr_info contains the frame buffer display settings We extract the rgba configuration of the frame buffer from this structure and thereby apply the appropriate OpenMAX standard color format equivalent to this configuration the r,g,b,a content length is needed to get the bit per pixel values r,g,b,a content offsets determine their respective positions

check if gray scale - if so then, switch according to bit per pixel criteria

now check the rgba components and set the corresponding color formats

Definition at line 373 of file omx_fbdev_sink_component.c.

References OMX_COLOR_Format12bitRGB444, OMX_COLOR_Format16bitARGB1555, OMX_COLOR_Format16bitARGB4444, OMX_COLOR_Format16bitBGR565, OMX_COLOR_Format16bitRGB565, OMX_COLOR_Format18bitARGB1665, OMX_COLOR_Format18bitRGB666, OMX_COLOR_Format19bitARGB1666, OMX_COLOR_Format24bitARGB1887, OMX_COLOR_Format24bitBGR888, OMX_COLOR_Format24bitRGB888, OMX_COLOR_Format25bitARGB1888, OMX_COLOR_Format32bitARGB8888, OMX_COLOR_Format32bitBGRA8888, OMX_COLOR_Format8bitRGB332, OMX_COLOR_FormatL16, OMX_COLOR_FormatL2, OMX_COLOR_FormatL24, OMX_COLOR_FormatL32, OMX_COLOR_FormatL4, OMX_COLOR_FormatL8, OMX_COLOR_FormatMonochrome, and OMX_COLOR_FormatUnused.

Referenced by omx_fbdev_sink_component_Init().

long GetTime (  ) 

Returns a time value in milliseconds based on a clock starting at some arbitrary base. Given a call to GetTime that returns a value of n a subsequent call to GetTime made m milliseconds later should return a value of (approximately) (n+m). This method is used, for instance, to compute the duration of call.

Definition at line 48 of file omx_fbdev_sink_component.c.

Referenced by omx_fbdev_sink_component_BufferMgmtCallback().

void omx_fbdev_sink_component_BufferMgmtCallback ( OMX_COMPONENTTYPE openmaxStandComp,
OMX_BUFFERHEADERTYPE pInputBuffer 
)

buffer management callback function takes one input buffer and displays its contents

FIXME: Configuration values should be clamped to prevent memory trampling and potential segfaults. It might be best to store clamped AND unclamped values on a per-port basis so that OMX_GetConfig can still return the unclamped ones.

getting current time

Copy image data into in_buffer

Definition at line 955 of file omx_fbdev_sink_component.c.

References GetTime(), HEIGHT_OFFSET, OMX_BUFFERHEADERTYPE::nFilledLen, OMX_BASE_SINK_INPUTPORT_INDEX, omx_img_copy(), OMX_MirrorBoth, OMX_MirrorVertical, OMX_BUFFERHEADERTYPE::pBuffer, and OMX_COMPONENTTYPE::pComponentPrivate.

Referenced by omx_fbdev_sink_component_Constructor().

OMX_ERRORTYPE omx_fbdev_sink_component_Constructor ( OMX_COMPONENTTYPE openmaxStandComp,
OMX_STRING  cComponentName 
)

The Constructor

Parameters:
cComponentName is the name of the constructed component

we could create our own port structures here fixme maybe the base class could use a "port factory" function pointer?

Allocate Ports and call port constructor.

Domain specific section for the allocated port.

Set configs

set the function pointers

Definition at line 57 of file omx_fbdev_sink_component.c.

References base_video_port_Constructor(), calcStride(), DEB_LEV_ERR, DEB_LEV_FUNCTION_NAME, DEB_LEV_PARAMS, DEBUG, err, OMX_COMPONENTTYPE::GetParameter, MAX_NUM_OF_fbdev_sink_component_INSTANCES, omx_base_sink_Constructor(), OMX_BASE_SINK_INPUTPORT_INDEX, OMX_COLOR_Format24bitRGB888, OMX_ErrorInsufficientResources, OMX_ErrorNone, omx_fbdev_sink_component_BufferMgmtCallback(), omx_fbdev_sink_component_Destructor(), omx_fbdev_sink_component_GetParameter(), omx_fbdev_sink_component_MessageHandler(), omx_fbdev_sink_component_SetParameter(), OMX_MirrorNone, OMX_TRUE, OMX_COMPONENTTYPE::pComponentPrivate, setHeader(), and OMX_COMPONENTTYPE::SetParameter.

Referenced by omx_component_library_Setup().

OMX_ERRORTYPE omx_fbdev_sink_component_Deinit ( OMX_COMPONENTTYPE openmaxStandComp  ) 

The deinitialization function It deallocates the frame buffer memory, and closes frame buffer

Definition at line 273 of file omx_fbdev_sink_component.c.

References OMX_ErrorHardware, OMX_ErrorNone, and OMX_COMPONENTTYPE::pComponentPrivate.

Referenced by omx_fbdev_sink_component_MessageHandler().

OMX_ERRORTYPE omx_fbdev_sink_component_Destructor ( OMX_COMPONENTTYPE openmaxStandComp  ) 

OMX_ERRORTYPE omx_fbdev_sink_component_GetConfig ( OMX_IN OMX_HANDLETYPE  hComponent,
OMX_IN OMX_INDEXTYPE  nIndex,
OMX_INOUT OMX_PTR  pComponentConfigStructure 
)

OMX_ERRORTYPE omx_fbdev_sink_component_GetParameter ( OMX_IN OMX_HANDLETYPE  hComponent,
OMX_IN OMX_INDEXTYPE  nParamIndex,
OMX_INOUT OMX_PTR  ComponentParameterStructure 
)

OMX_ERRORTYPE omx_fbdev_sink_component_Init ( OMX_COMPONENTTYPE openmaxStandComp  ) 

The initialization function This function opens the frame buffer device and allocates memory for display also it finds the frame buffer supported display formats

frame buffer display configuration get

From the frame buffer display rgb formats, find the corresponding standard OMX format It is needed to convert the input rgb content onto frame buffer supported rgb content

the allocated memory has more vertical reolution than needed because we want to show the output displayed not at the corner of screen, but at the centre of upper part of screen

memory map frame buf memory

Definition at line 195 of file omx_fbdev_sink_component.c.

References calcStride2(), DEB_LEV_ERR, DEB_LEV_PARAMS, DEB_LEV_SIMPLE_SEQ, DEBUG, FBDEV_FILENAME, find_omx_pxlfmt(), HEIGHT_OFFSET, OMX_BASE_SINK_INPUTPORT_INDEX, OMX_COLOR_FormatUnused, OMX_ErrorHardware, OMX_ErrorNone, OMX_ErrorUnsupportedSetting, and OMX_COMPONENTTYPE::pComponentPrivate.

Referenced by omx_fbdev_sink_component_MessageHandler().

OMX_ERRORTYPE omx_fbdev_sink_component_MessageHandler ( OMX_COMPONENTTYPE ,
internalRequestMessageType  
)

OMX_ERRORTYPE omx_fbdev_sink_component_SetConfig ( OMX_IN OMX_HANDLETYPE  hComponent,
OMX_IN OMX_INDEXTYPE  nIndex,
OMX_IN OMX_PTR  pComponentConfigStructure 
)

OMX_ERRORTYPE omx_fbdev_sink_component_SetParameter ( OMX_IN OMX_HANDLETYPE  hComponent,
OMX_IN OMX_INDEXTYPE  nParamIndex,
OMX_IN OMX_PTR  ComponentParameterStructure 
)

void omx_img_copy ( OMX_U8 src_ptr,
OMX_S32  src_stride,
OMX_U32  src_width,
OMX_U32  src_height,
OMX_S32  src_offset_x,
OMX_S32  src_offset_y,
OMX_U8 dest_ptr,
OMX_S32  dest_stride,
OMX_U32  dest_width,
OMX_U32  dest_height,
OMX_S32  dest_offset_x,
OMX_S32  dest_offset_y,
OMX_S32  cpy_width,
OMX_U32  cpy_height,
OMX_COLOR_FORMATTYPE  colorformat,
OMX_COLOR_FORMATTYPE  fbpxlfmt 
)

image copy function

This function copies source image to destination image of required dimension and color formats

Parameters:
src_ptr is the source image strting pointer
src_stride is the source image stride (src_width * byte_per_pixel)
src_width is source image width & src_height is source image height
src_offset_x & src_offset_y are x,y offset values (if any) from starting pointer
dest_ptr is the destination image strting pointer
dest_stride is the destination image stride (dest_width * byte_per_pixel)
dest_width is destination image width & dest_height is destination image height
dest_offset_x dest_offset_y are x,y offset values (if any) from starting pointer
cpy_width cpy_height is the source image copy width and height - it determines the portion of source image to be copied from source to destination image
colorformat is the source image color format

CAUTION: We don't do any checking of boundaries! (FIXME - see omx_ffmpeg_colorconv_component_BufferMgmtCallback) Input frame is planar, not interleaved Feel free to add more formats if implementing them

Watch out for odd or non-multiple-of-4 (4:1:1) luma resolutions (I don't check)

Planar vs. PackedPlanar will have to be handled differently if/when slicing is implemented

OpenMAX IL spec says chroma channels are subsampled by 4x horizontally AND vertically in YUV 4:1:1. Conventional wisdom (wiki) tells us that it is only subsampled horizontally. Following OpenMAX spec anyway. Technically I guess this would be YUV 4:1:0.

Planar vs. PackedPlanar will have to be handled differently if/when slicing is implemented

Planar vs. PackedPlanar will have to be handled differently if/when slicing is implemented

Pointers to the start of each plane to make things easier

Figure out total offsets

If input stride is negative, reverse source row order

Pointers to use with memcpy

Pointers to destination planes to make things easier

Figure out total offsets

If output stride is negative, reverse destination row order

Pointers to use with memcpy

fbpxlfmt is the output (frame buffer supported) image color format here fbpxlfmt is OMX_COLOR_Format32bitARGB8888 always because the frame buffer has configuration of rgba 8/0 8/0 8/0 8/0 with pixel depth 8 if other configuration frame buffer is employed then appropriate conversion policy should be written

Definition at line 501 of file omx_fbdev_sink_component.c.

References calcStride(), DEB_LEV_ERR, DEB_LEV_SIMPLE_SEQ, DEBUG, OMX_COLOR_Format16bitARGB1555, OMX_COLOR_Format16bitBGR565, OMX_COLOR_Format16bitRGB565, OMX_COLOR_Format24bitBGR888, OMX_COLOR_Format24bitRGB888, OMX_COLOR_Format32bitARGB8888, OMX_COLOR_Format32bitBGRA8888, OMX_COLOR_Format8bitRGB332, OMX_COLOR_FormatYUV411PackedPlanar, OMX_COLOR_FormatYUV411Planar, OMX_COLOR_FormatYUV420PackedPlanar, OMX_COLOR_FormatYUV420Planar, OMX_COLOR_FormatYUV422PackedPlanar, and OMX_COLOR_FormatYUV422Planar.

Referenced by omx_fbdev_sink_component_BufferMgmtCallback(), and omx_ffmpeg_colorconv_component_BufferMgmtCallback().


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