#include <omxcore.h>
#include <omx_ffmpeg_colorconv_component.h>
Go to the source code of this file.
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_ffmpeg_colorconv_component.c.
#define DEFAULT_HEIGHT 288 |
Definition at line 40 of file omx_ffmpeg_colorconv_component.c.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
#define DEFAULT_VIDEO_INPUT_BUF_SIZE DEFAULT_WIDTH*DEFAULT_HEIGHT*3/2 |
define the max input buffer size
Definition at line 42 of file omx_ffmpeg_colorconv_component.c.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
#define DEFAULT_WIDTH 352 |
Definition at line 39 of file omx_ffmpeg_colorconv_component.c.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
#define MAX_COMPONENT_VIDEOCOLORCONV 2 |
Maximum Number of Video Color Converter Component Instance
Definition at line 34 of file omx_ffmpeg_colorconv_component.c.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
OMX_S32 calcStride | ( | OMX_U32 | width, | |
OMX_COLOR_FORMATTYPE | omx_pxlfmt | |||
) |
This function takes two inputs -
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 128 of file omx_ffmpeg_colorconv_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_FormatCbYCrY, OMX_COLOR_FormatCrYCbY, OMX_COLOR_FormatL16, OMX_COLOR_FormatL2, OMX_COLOR_FormatL24, OMX_COLOR_FormatL32, OMX_COLOR_FormatL4, OMX_COLOR_FormatL8, OMX_COLOR_FormatMonochrome, OMX_COLOR_FormatRawBayer10bit, OMX_COLOR_FormatRawBayer8bit, OMX_COLOR_FormatRawBayer8bitcompressed, OMX_COLOR_FormatYCbYCr, OMX_COLOR_FormatYCrYCb, OMX_COLOR_FormatYUV411PackedPlanar, OMX_COLOR_FormatYUV411Planar, OMX_COLOR_FormatYUV420PackedPlanar, OMX_COLOR_FormatYUV420Planar, OMX_COLOR_FormatYUV420SemiPlanar, OMX_COLOR_FormatYUV422PackedPlanar, OMX_COLOR_FormatYUV422Planar, OMX_COLOR_FormatYUV422SemiPlanar, and OMX_COLOR_FormatYUV444Interleaved.
enum PixelFormat find_ffmpeg_pxlfmt | ( | OMX_COLOR_FORMATTYPE | omx_pxlfmt | ) |
Figure out equivalent FFmpeg PixelFormat based on OMX_COLOR_FORMATTYPE
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.
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_FormatCbYCrY, OMX_COLOR_FormatCrYCbY, OMX_COLOR_FormatL16, OMX_COLOR_FormatL2, OMX_COLOR_FormatL24, OMX_COLOR_FormatL32, OMX_COLOR_FormatL4, OMX_COLOR_FormatL8, OMX_COLOR_FormatMonochrome, OMX_COLOR_FormatRawBayer10bit, OMX_COLOR_FormatRawBayer8bit, OMX_COLOR_FormatRawBayer8bitcompressed, OMX_COLOR_FormatUnused, OMX_COLOR_FormatYCbYCr, OMX_COLOR_FormatYCrYCb, OMX_COLOR_FormatYUV411PackedPlanar, OMX_COLOR_FormatYUV411Planar, OMX_COLOR_FormatYUV420PackedPlanar, OMX_COLOR_FormatYUV420Planar, OMX_COLOR_FormatYUV420SemiPlanar, OMX_COLOR_FormatYUV422PackedPlanar, OMX_COLOR_FormatYUV422Planar, OMX_COLOR_FormatYUV422SemiPlanar, and OMX_COLOR_FormatYUV444Interleaved.
Referenced by omx_ffmpeg_colorconv_component_SetParameter().
void omx_ffmpeg_colorconv_component_BufferMgmtCallback | ( | OMX_COMPONENTTYPE * | openmaxStandComp, | |
OMX_BUFFERHEADERTYPE * | pInputBuffer, | |||
OMX_BUFFERHEADERTYPE * | pOutputBuffer | |||
) |
This function is used to process the input buffer and provide one output buffer
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.
Definition at line 712 of file omx_ffmpeg_colorconv_component.c.
References calcStride(), DEB_LEV_FULL_SEQ, DEBUG, OMX_BUFFERHEADERTYPE::nFilledLen, OMX_BASE_FILTER_INPUTPORT_INDEX, OMX_BASE_FILTER_OUTPUTPORT_INDEX, omx_img_copy(), OMX_MirrorBoth, OMX_MirrorVertical, OMX_BUFFERHEADERTYPE::pBuffer, and OMX_COMPONENTTYPE::pComponentPrivate.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
OMX_ERRORTYPE omx_ffmpeg_colorconv_component_Constructor | ( | OMX_COMPONENTTYPE * | openmaxStandComp, | |
OMX_STRING | cComponentName | |||
) |
The Constructor
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 ports.
Definition at line 205 of file omx_ffmpeg_colorconv_component.c.
References base_video_port_Constructor(), calcStride(), DEB_LEV_FUNCTION_NAME, DEBUG, DEFAULT_HEIGHT, DEFAULT_VIDEO_INPUT_BUF_SIZE, DEFAULT_WIDTH, err, OMX_COMPONENTTYPE::GetConfig, OMX_COMPONENTTYPE::GetParameter, MAX_COMPONENT_VIDEOCOLORCONV, omx_base_filter_Constructor(), OMX_BASE_FILTER_INPUTPORT_INDEX, OMX_BASE_FILTER_OUTPUTPORT_INDEX, OMX_COLOR_Format24bitRGB888, OMX_COLOR_FormatYUV420Planar, OMX_ErrorInsufficientResources, OMX_ErrorNone, OMX_FALSE, omx_ffmpeg_colorconv_component_BufferMgmtCallback(), omx_ffmpeg_colorconv_component_Destructor(), omx_ffmpeg_colorconv_component_GetConfig(), omx_ffmpeg_colorconv_component_GetParameter(), omx_ffmpeg_colorconv_component_SetConfig(), omx_ffmpeg_colorconv_component_SetParameter(), OMX_MirrorNone, OMX_TRUE, omx_video_colorconv_MessageHandler(), omx_video_colorconv_UseEGLImage(), OMX_COMPONENTTYPE::pComponentPrivate, OMX_COMPONENTTYPE::SetConfig, setHeader(), OMX_COMPONENTTYPE::SetParameter, and OMX_COMPONENTTYPE::UseEGLImage.
Referenced by omx_component_library_Setup().
OMX_ERRORTYPE omx_ffmpeg_colorconv_component_Deinit | ( | OMX_COMPONENTTYPE * | openmaxStandComp | ) |
The Deinitialization function This function dealloates the frames and buffers to store the color converterted output from input yuv
Definition at line 415 of file omx_ffmpeg_colorconv_component.c.
References err, OMX_ErrorNone, and OMX_COMPONENTTYPE::pComponentPrivate.
Referenced by omx_video_colorconv_MessageHandler().
OMX_ERRORTYPE omx_ffmpeg_colorconv_component_Destructor | ( | OMX_COMPONENTTYPE * | openmaxStandComp | ) |
The destructor
Definition at line 344 of file omx_ffmpeg_colorconv_component.c.
References DEB_LEV_FUNCTION_NAME, DEBUG, omx_base_filter_Destructor(), OMX_ErrorNone, and OMX_COMPONENTTYPE::pComponentPrivate.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
OMX_ERRORTYPE omx_ffmpeg_colorconv_component_GetConfig | ( | OMX_HANDLETYPE | hComponent, | |
OMX_INDEXTYPE | nIndex, | |||
OMX_PTR | pComponentConfigStructure | |||
) |
Definition at line 924 of file omx_ffmpeg_colorconv_component.c.
References checkHeader(), DEB_LEV_SIMPLE_SEQ, DEBUG, err, OMX_CONFIG_POINTTYPE::nPortIndex, OMX_CONFIG_SCALEFACTORTYPE::nPortIndex, OMX_CONFIG_MIRRORTYPE::nPortIndex, OMX_CONFIG_ROTATIONTYPE::nPortIndex, OMX_CONFIG_RECTTYPE::nPortIndex, omx_base_component_GetConfig(), OMX_BASE_FILTER_INPUTPORT_INDEX, OMX_BASE_FILTER_OUTPUTPORT_INDEX, OMX_ErrorBadParameter, OMX_ErrorBadPortIndex, OMX_ErrorNone, OMX_ErrorUnsupportedIndex, OMX_IndexConfigCommonInputCrop, OMX_IndexConfigCommonMirror, OMX_IndexConfigCommonOutputCrop, OMX_IndexConfigCommonOutputPosition, OMX_IndexConfigCommonRotate, OMX_IndexConfigCommonScale, and OMX_COMPONENTTYPE::pComponentPrivate.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
OMX_ERRORTYPE omx_ffmpeg_colorconv_component_GetParameter | ( | OMX_HANDLETYPE | hComponent, | |
OMX_INDEXTYPE | nParamIndex, | |||
OMX_PTR | ComponentParameterStructure | |||
) |
Definition at line 1109 of file omx_ffmpeg_colorconv_component.c.
References checkHeader(), DEB_LEV_SIMPLE_SEQ, DEBUG, err, OMX_VIDEO_PARAM_PORTFORMATTYPE::nPortIndex, omx_base_component_GetParameter(), OMX_ErrorBadParameter, OMX_ErrorBadPortIndex, OMX_ErrorNone, OMX_IndexParamVideoInit, OMX_IndexParamVideoPortFormat, and OMX_COMPONENTTYPE::pComponentPrivate.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
OMX_ERRORTYPE omx_ffmpeg_colorconv_component_Init | ( | OMX_COMPONENTTYPE * | openmaxStandComp | ) |
The Initialization function This function alloates the frames and buffers to store the color converterted output from input yuv
Definition at line 370 of file omx_ffmpeg_colorconv_component.c.
References DEB_LEV_ERR, DEBUG, err, in_height, in_width, OMX_BASE_FILTER_INPUTPORT_INDEX, OMX_BASE_FILTER_OUTPUTPORT_INDEX, OMX_ErrorInsufficientResources, OMX_ErrorNone, out_height, out_width, and OMX_COMPONENTTYPE::pComponentPrivate.
Referenced by omx_video_colorconv_MessageHandler().
OMX_ERRORTYPE omx_ffmpeg_colorconv_component_SetConfig | ( | OMX_HANDLETYPE | hComponent, | |
OMX_INDEXTYPE | nIndex, | |||
OMX_PTR | pComponentConfigStructure | |||
) |
Definition at line 805 of file omx_ffmpeg_colorconv_component.c.
References checkHeader(), DEB_LEV_SIMPLE_SEQ, DEBUG, OMX_CONFIG_MIRRORTYPE::eMirror, err, OMX_CONFIG_RECTTYPE::nHeight, OMX_CONFIG_RECTTYPE::nLeft, OMX_CONFIG_POINTTYPE::nPortIndex, OMX_CONFIG_SCALEFACTORTYPE::nPortIndex, OMX_CONFIG_MIRRORTYPE::nPortIndex, OMX_CONFIG_ROTATIONTYPE::nPortIndex, OMX_CONFIG_RECTTYPE::nPortIndex, OMX_CONFIG_ROTATIONTYPE::nRotation, OMX_CONFIG_RECTTYPE::nTop, OMX_CONFIG_RECTTYPE::nWidth, OMX_CONFIG_POINTTYPE::nX, OMX_CONFIG_POINTTYPE::nY, omx_base_component_SetConfig(), OMX_BASE_FILTER_INPUTPORT_INDEX, OMX_BASE_FILTER_OUTPUTPORT_INDEX, OMX_ErrorBadParameter, OMX_ErrorBadPortIndex, OMX_ErrorNone, OMX_ErrorUnsupportedIndex, OMX_ErrorUnsupportedSetting, OMX_IndexConfigCommonInputCrop, OMX_IndexConfigCommonMirror, OMX_IndexConfigCommonOutputCrop, OMX_IndexConfigCommonOutputPosition, OMX_IndexConfigCommonRotate, OMX_IndexConfigCommonScale, OMX_MirrorBoth, OMX_MirrorHorizontal, OMX_COMPONENTTYPE::pComponentPrivate, OMX_CONFIG_SCALEFACTORTYPE::xHeight, and OMX_CONFIG_SCALEFACTORTYPE::xWidth.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
OMX_ERRORTYPE omx_ffmpeg_colorconv_component_SetParameter | ( | OMX_HANDLETYPE | hComponent, | |
OMX_INDEXTYPE | nParamIndex, | |||
OMX_PTR | ComponentParameterStructure | |||
) |
no real pixel format supported by ffmpeg for this user input color format so return bad parameter error to user application
Definition at line 1031 of file omx_ffmpeg_colorconv_component.c.
References OMX_VIDEO_PORTDEFINITIONTYPE::bFlagErrorConcealment, calcStride(), DEB_LEV_ERR, DEB_LEV_SIMPLE_SEQ, DEBUG, OMX_VIDEO_PARAM_PORTFORMATTYPE::eColorFormat, OMX_VIDEO_PARAM_PORTFORMATTYPE::eCompressionFormat, err, find_ffmpeg_pxlfmt(), OMX_PARAM_PORTDEFINITIONTYPE::format, OMX_VIDEO_PORTDEFINITIONTYPE::nBitrate, OMX_PARAM_PORTDEFINITIONTYPE::nBufferCountActual, OMX_VIDEO_PORTDEFINITIONTYPE::nFrameHeight, OMX_VIDEO_PORTDEFINITIONTYPE::nFrameWidth, OMX_VIDEO_PARAM_PORTFORMATTYPE::nPortIndex, OMX_PARAM_PORTDEFINITIONTYPE::nPortIndex, omx_base_component_ParameterSanityCheck(), omx_base_component_SetParameter(), OMX_ErrorBadParameter, OMX_ErrorNone, OMX_ErrorUnsupportedSetting, OMX_IndexParamPortDefinition, OMX_IndexParamVideoPortFormat, OMX_VIDEO_CodingUnused, OMX_COMPONENTTYPE::pComponentPrivate, OMX_PARAM_PORTDEFINITIONTYPE::video, and OMX_VIDEO_PORTDEFINITIONTYPE::xFramerate.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
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 | |||
) |
This function copies source inmage to destination image of required dimension and color formats
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 |
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.
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
Definition at line 456 of file omx_ffmpeg_colorconv_component.c.
References calcStride(), DEB_LEV_ERR, DEBUG, OMX_COLOR_FormatYUV411PackedPlanar, OMX_COLOR_FormatYUV411Planar, OMX_COLOR_FormatYUV420PackedPlanar, OMX_COLOR_FormatYUV420Planar, OMX_COLOR_FormatYUV422PackedPlanar, and OMX_COLOR_FormatYUV422Planar.
OMX_ERRORTYPE omx_video_colorconv_MessageHandler | ( | OMX_COMPONENTTYPE * | openmaxStandComp, | |
internalRequestMessageType * | message | |||
) |
Definition at line 1151 of file omx_ffmpeg_colorconv_component.c.
References DEB_LEV_ERR, DEB_LEV_SIMPLE_SEQ, DEBUG, err, internalRequestMessageType::messageParam, internalRequestMessageType::messageType, omx_base_component_MessageHandler(), OMX_CommandStateSet, OMX_ErrorNone, omx_ffmpeg_colorconv_component_Deinit(), omx_ffmpeg_colorconv_component_Init(), OMX_StateExecuting, OMX_StateIdle, and OMX_COMPONENTTYPE::pComponentPrivate.
Referenced by omx_ffmpeg_colorconv_component_Constructor().
OMX_ERRORTYPE omx_video_colorconv_UseEGLImage | ( | OMX_HANDLETYPE | hComponent, | |
OMX_BUFFERHEADERTYPE ** | ppBufferHdr, | |||
OMX_U32 | nPortIndex, | |||
OMX_PTR | pAppPrivate, | |||
void * | eglImage | |||
) |
Definition at line 1183 of file omx_ffmpeg_colorconv_component.c.
References DEB_LEV_ERR, DEBUG, OMX_PARAM_PORTDEFINITIONTYPE::nBufferSize, OMX_ErrorBadPortIndex, omx_base_PortType::Port_UseBuffer, and omx_base_PortType::sPortParam.
Referenced by omx_ffmpeg_colorconv_component_Constructor().