1/* 2* Copyright (c) 2009-2011 Intel Corporation. All rights reserved. 3* 4* Licensed under the Apache License, Version 2.0 (the "License"); 5* you may not use this file except in compliance with the License. 6* You may obtain a copy of the License at 7* 8* http://www.apache.org/licenses/LICENSE-2.0 9* 10* Unless required by applicable law or agreed to in writing, software 11* distributed under the License is distributed on an "AS IS" BASIS, 12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13* See the License for the specific language governing permissions and 14* limitations under the License. 15*/ 16 17 18// #define LOG_NDEBUG 0 19#define LOG_TAG "OMXVideoDecoder" 20#include <wrs_omxil_core/log.h> 21#include "OMXVideoDecoderH263.h" 22 23// Be sure to have an equal string in VideoDecoderHost.cpp (libmix) 24static const char* H263_MIME_TYPE = "video/h263"; 25 26OMXVideoDecoderH263::OMXVideoDecoderH263() { 27 LOGV("OMXVideoDecoderH263 is constructed."); 28 mVideoDecoder = createVideoDecoder(H263_MIME_TYPE); 29 if (!mVideoDecoder) { 30 LOGE("createVideoDecoder failed for \"%s\"", H263_MIME_TYPE); 31 } 32 mNativeBufferCount = OUTPORT_NATIVE_BUFFER_COUNT; 33 BuildHandlerList(); 34} 35 36OMXVideoDecoderH263::~OMXVideoDecoderH263() { 37 LOGV("OMXVideoDecoderH263 is destructed."); 38} 39 40OMX_ERRORTYPE OMXVideoDecoderH263::InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput) { 41 // OMX_PARAM_PORTDEFINITIONTYPE 42 paramPortDefinitionInput->nBufferCountActual = INPORT_ACTUAL_BUFFER_COUNT; 43 paramPortDefinitionInput->nBufferCountMin = INPORT_MIN_BUFFER_COUNT; 44 paramPortDefinitionInput->nBufferSize = INPORT_BUFFER_SIZE; 45 paramPortDefinitionInput->format.video.cMIMEType = (OMX_STRING)H263_MIME_TYPE; 46 paramPortDefinitionInput->format.video.eCompressionFormat = OMX_VIDEO_CodingH263; 47 48 // OMX_VIDEO_PARAM_H263TYPE 49 memset(&mParamH263, 0, sizeof(mParamH263)); 50 SetTypeHeader(&mParamH263, sizeof(mParamH263)); 51 mParamH263.nPortIndex = INPORT_INDEX; 52 // TODO: check eProfile/eLevel 53 mParamH263.eProfile = OMX_VIDEO_H263ProfileBaseline; 54 mParamH263.eLevel = OMX_VIDEO_H263Level70; //OMX_VIDEO_H263Level10; 55 56 return OMX_ErrorNone; 57} 58 59OMX_ERRORTYPE OMXVideoDecoderH263::ProcessorInit(void) { 60 return OMXVideoDecoderBase::ProcessorInit(); 61} 62 63OMX_ERRORTYPE OMXVideoDecoderH263::ProcessorDeinit(void) { 64 return OMXVideoDecoderBase::ProcessorDeinit(); 65} 66 67OMX_ERRORTYPE OMXVideoDecoderH263::ProcessorProcess( 68 OMX_BUFFERHEADERTYPE ***pBuffers, 69 buffer_retain_t *retains, 70 OMX_U32 numberBuffers) { 71 72 return OMXVideoDecoderBase::ProcessorProcess(pBuffers, retains, numberBuffers); 73} 74 75OMX_ERRORTYPE OMXVideoDecoderH263::PrepareConfigBuffer(VideoConfigBuffer *p) { 76 return OMXVideoDecoderBase::PrepareConfigBuffer(p); 77} 78 79OMX_ERRORTYPE OMXVideoDecoderH263::PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p) { 80 return OMXVideoDecoderBase::PrepareDecodeBuffer(buffer, retain, p); 81} 82 83OMX_ERRORTYPE OMXVideoDecoderH263::BuildHandlerList(void) { 84 OMXVideoDecoderBase::BuildHandlerList(); 85 AddHandler(OMX_IndexParamVideoH263, GetParamVideoH263, SetParamVideoH263); 86 AddHandler(OMX_IndexParamVideoProfileLevelQuerySupported, GetParamVideoH263ProfileLevel, SetParamVideoH263ProfileLevel); 87 return OMX_ErrorNone; 88} 89 90OMX_ERRORTYPE OMXVideoDecoderH263::GetParamVideoH263(OMX_PTR pStructure) { 91 OMX_ERRORTYPE ret; 92 OMX_VIDEO_PARAM_H263TYPE *p = (OMX_VIDEO_PARAM_H263TYPE *)pStructure; 93 CHECK_TYPE_HEADER(p); 94 CHECK_PORT_INDEX(p, INPORT_INDEX); 95 96 memcpy(p, &mParamH263, sizeof(*p)); 97 return OMX_ErrorNone; 98} 99 100OMX_ERRORTYPE OMXVideoDecoderH263::SetParamVideoH263(OMX_PTR pStructure) { 101 OMX_ERRORTYPE ret; 102 OMX_VIDEO_PARAM_H263TYPE *p = (OMX_VIDEO_PARAM_H263TYPE *)pStructure; 103 CHECK_TYPE_HEADER(p); 104 CHECK_PORT_INDEX(p, INPORT_INDEX); 105 CHECK_SET_PARAM_STATE(); 106 107 // TODO: do we need to check if port is enabled? 108 // TODO: see SetPortH263Param implementation - Can we make simple copy???? 109 memcpy(&mParamH263, p, sizeof(mParamH263)); 110 return OMX_ErrorNone; 111} 112 113OMX_ERRORTYPE OMXVideoDecoderH263::GetParamVideoH263ProfileLevel(OMX_PTR pStructure) { 114 OMX_ERRORTYPE ret; 115 OMX_VIDEO_PARAM_PROFILELEVELTYPE *p = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pStructure; 116 CHECK_TYPE_HEADER(p); 117 118 struct ProfileLevelTable { 119 OMX_U32 profile; 120 OMX_U32 level; 121 } plTable[] = { 122 {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level70} 123 }; 124 125 OMX_U32 count = sizeof(plTable)/sizeof(ProfileLevelTable); 126 CHECK_ENUMERATION_RANGE(p->nProfileIndex,count); 127 128 p->eProfile = plTable[p->nProfileIndex].profile; 129 p->eLevel = plTable[p->nProfileIndex].level; 130 131 return OMX_ErrorNone; 132} 133 134OMX_ERRORTYPE OMXVideoDecoderH263::SetParamVideoH263ProfileLevel(OMX_PTR) { 135 LOGW("SetParamVideoH263ProfileLevel is not supported."); 136 return OMX_ErrorUnsupportedSetting; 137} 138 139OMX_COLOR_FORMATTYPE OMXVideoDecoderH263::GetOutputColorFormat(int width) 140{ 141#ifdef USE_GEN_HW 142 return (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_NV12_X_TILED_INTEL; 143#else 144 return OMXVideoDecoderBase::GetOutputColorFormat(width); 145#endif 146} 147 148OMX_ERRORTYPE OMXVideoDecoderH263::SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p) { 149 OMX_ERRORTYPE ret; 150 CHECK_TYPE_HEADER(p); 151 CHECK_PORT_INDEX(p, OUTPORT_INDEX); 152 153 p->nBufferCountActual = OUTPORT_NATIVE_BUFFER_COUNT; 154 return OMXVideoDecoderBase::SetMaxOutputBufferCount(p); 155} 156 157DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.H263", "video_decoder.h263", OMXVideoDecoderH263); 158 159