00001
00030 #ifndef _OMX_FFMPEG_COLORCONV_COMPONENT_H_
00031 #define _OMX_FFMPEG_COLORCONV_COMPONENT_H_
00032
00033 #ifdef HAVE_CONFIG_H
00034 #include "config.h"
00035 #endif
00036
00037 #include <OMX_Types.h>
00038 #include <OMX_Component.h>
00039 #include <OMX_Core.h>
00040 #include <pthread.h>
00041 #include <stdlib.h>
00042 #include <string.h>
00043 #include <omx_base_filter.h>
00044 #include <omx_base_video_port.h>
00045
00046 #if FFMPEG_LIBNAME_HEADERS
00047 #include <libavcodec/avcodec.h>
00048 #include <libavformat/avformat.h>
00049 #include <libavutil/avutil.h>
00050 #include <libswscale/swscale.h>
00051 #else
00052 #include <ffmpeg/avcodec.h>
00053 #include <ffmpeg/avformat.h>
00054 #include <ffmpeg/avutil.h>
00055 #include <ffmpeg/swscale.h>
00056 #endif
00057
00058 #define COLOR_CONV_BASE_NAME "OMX.st.video_colorconv.ffmpeg"
00059 #define COLOR_CONV_FFMPEG_NAME "OMX.st.video_colorconv.ffmpeg"
00060 #define COLOR_CONV_FFMPEG_ROLE "video_colorconv.ffmpeg"
00061
00062 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
00063 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
00064
00067 DERIVEDCLASS(omx_ffmpeg_colorconv_component_PortType, omx_base_video_PortType)
00068 #define omx_ffmpeg_colorconv_component_PortType_FIELDS omx_base_video_PortType_FIELDS \
00069 \
00070 OMX_CONFIG_RECTTYPE omxConfigCrop; \
00071 \
00072 OMX_CONFIG_ROTATIONTYPE omxConfigRotate; \
00073 \
00074 OMX_CONFIG_MIRRORTYPE omxConfigMirror; \
00075 \
00076 OMX_CONFIG_SCALEFACTORTYPE omxConfigScale; \
00077 \
00078 OMX_CONFIG_POINTTYPE omxConfigOutputPosition; \
00079 \
00080 enum PixelFormat ffmpeg_pxlfmt;
00081 ENDCLASS(omx_ffmpeg_colorconv_component_PortType)
00082
00083
00085 DERIVEDCLASS(omx_ffmpeg_colorconv_component_PrivateType, omx_base_filter_PrivateType)
00086 #define omx_ffmpeg_colorconv_component_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \
00087 \
00088 unsigned char *in_buffer; \
00089 \
00090 unsigned char *conv_buffer; \
00091 \
00092 AVFrame *in_frame; \
00093 \
00094 AVFrame *conv_frame; \
00095 \
00096 unsigned int in_alloc_size; \
00097 \
00098 unsigned int conv_alloc_size;
00099 ENDCLASS(omx_ffmpeg_colorconv_component_PrivateType)
00100
00101
00102 OMX_ERRORTYPE omx_ffmpeg_colorconv_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName);
00103 OMX_ERRORTYPE omx_ffmpeg_colorconv_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp);
00104 OMX_ERRORTYPE omx_ffmpeg_colorconv_component_Init(OMX_COMPONENTTYPE *openmaxStandComp);
00105 OMX_ERRORTYPE omx_ffmpeg_colorconv_component_Deinit(OMX_COMPONENTTYPE *openmaxStandComp);
00106 OMX_ERRORTYPE omx_video_colorconv_MessageHandler(OMX_COMPONENTTYPE* openmaxStandComp,internalRequestMessageType *message);
00107
00108 void omx_ffmpeg_colorconv_component_BufferMgmtCallback(
00109 OMX_COMPONENTTYPE *openmaxStandComp,
00110 OMX_BUFFERHEADERTYPE* inputbuffer,
00111 OMX_BUFFERHEADERTYPE* outputbuffer);
00112
00113 OMX_ERRORTYPE omx_ffmpeg_colorconv_component_SetConfig(
00114 OMX_IN OMX_HANDLETYPE hComponent,
00115 OMX_IN OMX_INDEXTYPE nIndex,
00116 OMX_IN OMX_PTR pComponentConfigStructure);
00117
00118 OMX_ERRORTYPE omx_ffmpeg_colorconv_component_GetParameter(
00119 OMX_IN OMX_HANDLETYPE hComponent,
00120 OMX_IN OMX_INDEXTYPE nParamIndex,
00121 OMX_INOUT OMX_PTR ComponentParameterStructure);
00122
00123 OMX_ERRORTYPE omx_ffmpeg_colorconv_component_SetParameter(
00124 OMX_IN OMX_HANDLETYPE hComponent,
00125 OMX_IN OMX_INDEXTYPE nParamIndex,
00126 OMX_IN OMX_PTR ComponentParameterStructure);
00127
00128 OMX_ERRORTYPE omx_ffmpeg_colorconv_component_GetConfig(
00129 OMX_IN OMX_HANDLETYPE hComponent,
00130 OMX_IN OMX_INDEXTYPE nIndex,
00131 OMX_INOUT OMX_PTR pComponentConfigStructure);
00132
00134 enum PixelFormat find_ffmpeg_pxlfmt(OMX_COLOR_FORMATTYPE omx_pxlfmt);
00135
00137 OMX_S32 calcStride(OMX_U32 width, OMX_COLOR_FORMATTYPE omx_pxlfmt);
00138
00140 void omx_img_copy(OMX_U8* src_ptr, OMX_S32 src_stride, OMX_U32 src_width, OMX_U32 src_height,
00141 OMX_S32 src_offset_x, OMX_S32 src_offset_y,
00142 OMX_U8* dest_ptr, OMX_S32 dest_stride, OMX_U32 dest_width, OMX_U32 dest_height,
00143 OMX_S32 dest_offset_x, OMX_S32 dest_offset_y,
00144 OMX_S32 cpy_width, OMX_U32 cpy_height, OMX_COLOR_FORMATTYPE colorformat );
00145
00146
00147 OMX_ERRORTYPE omx_video_colorconv_UseEGLImage (
00148 OMX_HANDLETYPE hComponent,
00149 OMX_BUFFERHEADERTYPE** ppBufferHdr,
00150 OMX_U32 nPortIndex,
00151 OMX_PTR pAppPrivate,
00152 void* eglImage);
00153
00154 #endif