OMXVideoDecoderVP8.cpp revision ab82a0fd294f033d336bc53cdffe8d1708d947cc
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 <utils/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 BuildHandlerList(); 33} 34 35OMXVideoDecoderVP8::~OMXVideoDecoderVP8() { 36 LOGV("OMXVideoDecoderVP8 is destructed."); 37} 38 39OMX_ERRORTYPE OMXVideoDecoderVP8::InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput) { 40 // OMX_PARAM_PORTDEFINITIONTYPE 41 paramPortDefinitionInput->nBufferCountActual = INPORT_ACTUAL_BUFFER_COUNT; 42 paramPortDefinitionInput->nBufferCountMin = INPORT_MIN_BUFFER_COUNT; 43 paramPortDefinitionInput->nBufferSize = INPORT_BUFFER_SIZE; 44 paramPortDefinitionInput->format.video.cMIMEType = (OMX_STRING)VP8_MIME_TYPE; 45 paramPortDefinitionInput->format.video.eCompressionFormat = OMX_VIDEO_CodingVPX; 46 47 // OMX_VIDEO_PARAM_VP8TYPE 48 memset(&mParamVp8, 0, sizeof(mParamVp8)); 49 SetTypeHeader(&mParamVp8, sizeof(mParamVp8)); 50 mParamVp8.nPortIndex = INPORT_INDEX; 51 mParamVp8.eProfile = OMX_VIDEO_VP8ProfileMain; 52 mParamVp8.eLevel = OMX_VIDEO_VP8Level_Version0; 53 54 return OMX_ErrorNone; 55} 56 57OMX_ERRORTYPE OMXVideoDecoderVP8::ProcessorInit(void) { 58 return OMXVideoDecoderBase::ProcessorInit(); 59} 60 61OMX_ERRORTYPE OMXVideoDecoderVP8::ProcessorDeinit(void) { 62 return OMXVideoDecoderBase::ProcessorDeinit(); 63} 64 65OMX_ERRORTYPE OMXVideoDecoderVP8::ProcessorProcess( 66 OMX_BUFFERHEADERTYPE ***pBuffers, 67 buffer_retain_t *retains, 68 OMX_U32 numberBuffers) { 69 70 return OMXVideoDecoderBase::ProcessorProcess(pBuffers, retains, numberBuffers); 71} 72 73OMX_ERRORTYPE OMXVideoDecoderVP8::PrepareConfigBuffer(VideoConfigBuffer *p) { 74 return OMXVideoDecoderBase::PrepareConfigBuffer(p); 75} 76 77OMX_ERRORTYPE OMXVideoDecoderVP8::PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p) { 78 return OMXVideoDecoderBase::PrepareDecodeBuffer(buffer, retain, p); 79} 80 81OMX_ERRORTYPE OMXVideoDecoderVP8::BuildHandlerList(void) { 82 OMXVideoDecoderBase::BuildHandlerList(); 83 AddHandler(OMX_IndexParamVideoVp8, GetParamVideoVp8, SetParamVideoVp8); 84 return OMX_ErrorNone; 85} 86 87OMX_ERRORTYPE OMXVideoDecoderVP8::GetParamVideoVp8(OMX_PTR pStructure) { 88 OMX_ERRORTYPE ret; 89 OMX_VIDEO_PARAM_VP8TYPE *p = (OMX_VIDEO_PARAM_VP8TYPE *)pStructure; 90 CHECK_TYPE_HEADER(p); 91 CHECK_PORT_INDEX(p, INPORT_INDEX); 92 93 memcpy(p, &mParamVp8, sizeof(*p)); 94 return OMX_ErrorNone; 95} 96 97OMX_ERRORTYPE OMXVideoDecoderVP8::SetParamVideoVp8(OMX_PTR pStructure) { 98 OMX_ERRORTYPE ret; 99 OMX_VIDEO_PARAM_VP8TYPE *p = (OMX_VIDEO_PARAM_VP8TYPE *)pStructure; 100 CHECK_TYPE_HEADER(p); 101 CHECK_PORT_INDEX(p, INPORT_INDEX); 102 CHECK_SET_PARAM_STATE(); 103 104 // TODO: do we need to check if port is enabled? 105 memcpy(&mParamVp8, p, sizeof(mParamVp8)); 106 return OMX_ErrorNone; 107} 108 109 110DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.VPX", "video_decoder.vpx", OMXVideoDecoderVP8); 111 112 113