#include <OMX_Types.h>
#include <OMX_Component.h>
#include <OMX_Core.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <omx_base_filter.h>
#include <omx_base_video_port.h>
#include <ffmpeg/avcodec.h>
#include <ffmpeg/avformat.h>
#include <ffmpeg/avutil.h>
#include <ffmpeg/swscale.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.h.
#define COLOR_CONV_BASE_NAME "OMX.st.video_colorconv.ffmpeg" |
Definition at line 47 of file omx_ffmpeg_colorconv_component.h.
#define COLOR_CONV_FFMPEG_NAME "OMX.st.video_colorconv.ffmpeg" |
Definition at line 48 of file omx_ffmpeg_colorconv_component.h.
#define COLOR_CONV_FFMPEG_ROLE "video_colorconv.ffmpeg" |
Definition at line 49 of file omx_ffmpeg_colorconv_component.h.
#define MAX | ( | a, | |||
b | ) | (((a) > (b)) ? (a) : (b)) |
Definition at line 52 of file omx_ffmpeg_colorconv_component.h.
#define MIN | ( | a, | |||
b | ) | (((a) < (b)) ? (a) : (b)) |
Definition at line 51 of file omx_ffmpeg_colorconv_component.h.
Referenced by omx_maddec_component_BufferMgmtCallback().
#define omx_ffmpeg_colorconv_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; \ \ enum PixelFormat ffmpeg_pxlfmt;
Definition at line 57 of file omx_ffmpeg_colorconv_component.h.
#define omx_ffmpeg_colorconv_component_PrivateType_FIELDS |
Value:
omx_base_filter_PrivateType_FIELDS \ \ unsigned char *in_buffer; \ \ unsigned char *conv_buffer; \ \ AVFrame *in_frame; \ \ AVFrame *conv_frame; \ \ unsigned int in_alloc_size; \ \ unsigned int conv_alloc_size;
Definition at line 75 of file omx_ffmpeg_colorconv_component.h.
OMX_S32 calcStride | ( | OMX_U32 | width, | |
OMX_COLOR_FORMATTYPE | omx_pxlfmt | |||
) |
stride calculation
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 omx_fbdev_sink_component_Private->product of input width and byte per pixel |
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.
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.
Referenced by omx_fbdev_sink_component_Constructor(), omx_fbdev_sink_component_SetParameter(), omx_ffmpeg_colorconv_component_BufferMgmtCallback(), omx_ffmpeg_colorconv_component_Constructor(), omx_ffmpeg_colorconv_component_SetParameter(), and omx_img_copy().
enum PixelFormat find_ffmpeg_pxlfmt | ( | OMX_COLOR_FORMATTYPE | omx_pxlfmt | ) |
finds pixel format
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.
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_IN OMX_HANDLETYPE | hComponent, | |
OMX_IN OMX_INDEXTYPE | nIndex, | |||
OMX_INOUT OMX_PTR | pComponentConfigStructure | |||
) |
OMX_ERRORTYPE omx_ffmpeg_colorconv_component_GetParameter | ( | OMX_IN OMX_HANDLETYPE | hComponent, | |
OMX_IN OMX_INDEXTYPE | nParamIndex, | |||
OMX_INOUT OMX_PTR | ComponentParameterStructure | |||
) |
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_IN OMX_HANDLETYPE | hComponent, | |
OMX_IN OMX_INDEXTYPE | nIndex, | |||
OMX_IN OMX_PTR | pComponentConfigStructure | |||
) |
OMX_ERRORTYPE omx_ffmpeg_colorconv_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 | |||
) |
image copy function
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().