OMXVideoDecoderVP8.cpp revision 26a110c2a29667599733db5173a751e670b366a5
1/* 2* Copyright (c) 2012 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 "OMXVideoDecoderVP8.h" 22 23// Be sure to have an equal string in VideoDecoderHost.cpp (libmix) 24static const char* VP8_MIME_TYPE = "video/x-vnd.on2.vp8"; 25 26OMXVideoDecoderVP8::OMXVideoDecoderVP8() { 27 LOGV("OMXVideoDecoderVP8 is constructed."); 28 mVideoDecoder = createVideoDecoder(VP8_MIME_TYPE); 29 if (!mVideoDecoder) { 30 LOGE("createVideoDecoder failed for \"%s\"", VP8_MIME_TYPE); 31 } 32 // Override default native buffer count defined in the base class 33 mNativeBufferCount = OUTPORT_NATIVE_BUFFER_COUNT; 34 BuildHandlerList(); 35} 36 37OMXVideoDecoderVP8::~OMXVideoDecoderVP8() { 38 LOGV("OMXVideoDecoderVP8 is destructed."); 39} 40 41OMX_ERRORTYPE OMXVideoDecoderVP8::InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput) { 42 // OMX_PARAM_PORTDEFINITIONTYPE 43 paramPortDefinitionInput->nBufferCountActual = INPORT_ACTUAL_BUFFER_COUNT; 44 paramPortDefinitionInput->nBufferCountMin = INPORT_MIN_BUFFER_COUNT; 45 paramPortDefinitionInput->nBufferSize = INPORT_BUFFER_SIZE; 46 paramPortDefinitionInput->format.video.cMIMEType = (OMX_STRING)VP8_MIME_TYPE; 47 paramPortDefinitionInput->format.video.eCompressionFormat = OMX_VIDEO_CodingVP8; 48 49 // OMX_VIDEO_PARAM_VP8TYPE 50 memset(&mParamVp8, 0, sizeof(mParamVp8)); 51 SetTypeHeader(&mParamVp8, sizeof(mParamVp8)); 52 mParamVp8.nPortIndex = INPORT_INDEX; 53 mParamVp8.eProfile = OMX_VIDEO_VP8ProfileMain; 54 mParamVp8.eLevel = OMX_VIDEO_VP8Level_Version0; 55 56 return OMX_ErrorNone; 57} 58 59OMX_ERRORTYPE OMXVideoDecoderVP8::ProcessorInit(void) { 60 return OMXVideoDecoderBase::ProcessorInit(); 61} 62 63OMX_ERRORTYPE OMXVideoDecoderVP8::ProcessorDeinit(void) { 64 return OMXVideoDecoderBase::ProcessorDeinit(); 65} 66 67OMX_ERRORTYPE OMXVideoDecoderVP8::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 OMXVideoDecoderVP8::PrepareConfigBuffer(VideoConfigBuffer *p) { 76 return OMXVideoDecoderBase::PrepareConfigBuffer(p); 77} 78 79OMX_ERRORTYPE OMXVideoDecoderVP8::PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p) { 80 return OMXVideoDecoderBase::PrepareDecodeBuffer(buffer, retain, p); 81} 82 83OMX_ERRORTYPE OMXVideoDecoderVP8::BuildHandlerList(void) { 84 OMXVideoDecoderBase::BuildHandlerList(); 85 AddHandler((OMX_INDEXTYPE)OMX_IndexParamVideoVp8, GetParamVideoVp8, SetParamVideoVp8); 86 return OMX_ErrorNone; 87} 88 89OMX_ERRORTYPE OMXVideoDecoderVP8::GetParamVideoVp8(OMX_PTR pStructure) { 90 OMX_ERRORTYPE ret; 91 OMX_VIDEO_PARAM_VP8TYPE *p = (OMX_VIDEO_PARAM_VP8TYPE *)pStructure; 92 CHECK_TYPE_HEADER(p); 93 CHECK_PORT_INDEX(p, INPORT_INDEX); 94 95 memcpy(p, &mParamVp8, sizeof(*p)); 96 return OMX_ErrorNone; 97} 98 99OMX_ERRORTYPE OMXVideoDecoderVP8::SetParamVideoVp8(OMX_PTR pStructure) { 100 OMX_ERRORTYPE ret; 101 OMX_VIDEO_PARAM_VP8TYPE *p = (OMX_VIDEO_PARAM_VP8TYPE *)pStructure; 102 CHECK_TYPE_HEADER(p); 103 CHECK_PORT_INDEX(p, INPORT_INDEX); 104 CHECK_SET_PARAM_STATE(); 105 106 // TODO: do we need to check if port is enabled? 107 memcpy(&mParamVp8, p, sizeof(mParamVp8)); 108 return OMX_ErrorNone; 109} 110 111OMX_COLOR_FORMATTYPE OMXVideoDecoderVP8::GetOutputColorFormat(int width, int height) 112{ 113#ifdef USE_GEN_HW 114#ifdef USE_X_TILE 115 return (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_NV12_X_TILED_INTEL; 116#else 117 return (OMX_COLOR_FORMATTYPE)OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled; 118#endif 119#else 120 return OMXVideoDecoderBase::GetOutputColorFormat(width, height); 121#endif 122} 123 124OMX_ERRORTYPE OMXVideoDecoderVP8::SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p) { 125 OMX_ERRORTYPE ret; 126 CHECK_TYPE_HEADER(p); 127 CHECK_PORT_INDEX(p, OUTPORT_INDEX); 128 129 p->nBufferCountActual = OUTPORT_NATIVE_BUFFER_COUNT; 130 return OMXVideoDecoderBase::SetMaxOutputBufferCount(p); 131} 132DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.VP8", "video_decoder.vp8", OMXVideoDecoderVP8); 133 134 135