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