1/* 2 * Copyright (C) 2016 The Android Open Source Project 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#ifndef SOFT_VP8_ENCODER_H_ 18 19#define SOFT_VP8_ENCODER_H_ 20 21#include "SoftVPXEncoder.h" 22 23#include <OMX_VideoExt.h> 24#include <OMX_IndexExt.h> 25 26#include <hardware/gralloc.h> 27 28#include "vpx/vpx_encoder.h" 29#include "vpx/vpx_codec.h" 30#include "vpx/vp8cx.h" 31 32namespace android { 33 34// Exposes a vp8 encoder as an OMX Component 35// 36// In addition to the base class settings, Only following encoder settings are 37// available: 38// - token partitioning 39struct SoftVP8Encoder : public SoftVPXEncoder { 40 SoftVP8Encoder(const char *name, 41 const OMX_CALLBACKTYPE *callbacks, 42 OMX_PTR appData, 43 OMX_COMPONENTTYPE **component); 44 45protected: 46 // Returns current values for requested OMX 47 // parameters 48 virtual OMX_ERRORTYPE internalGetParameter( 49 OMX_INDEXTYPE index, OMX_PTR param); 50 51 // Validates, extracts and stores relevant OMX 52 // parameters 53 virtual OMX_ERRORTYPE internalSetParameter( 54 OMX_INDEXTYPE index, const OMX_PTR param); 55 56 // Populates |mCodecInterface| with codec specific settings. 57 virtual void setCodecSpecificInterface(); 58 59 // Sets codec specific configuration. 60 virtual void setCodecSpecificConfiguration(); 61 62 // Initializes codec specific encoder settings. 63 virtual vpx_codec_err_t setCodecSpecificControls(); 64 65 // Gets vp8 specific parameters. 66 OMX_ERRORTYPE internalGetVp8Params( 67 OMX_VIDEO_PARAM_VP8TYPE* vp8Params); 68 69 // Handles vp8 specific parameters. 70 OMX_ERRORTYPE internalSetVp8Params( 71 const OMX_VIDEO_PARAM_VP8TYPE* vp8Params); 72 73private: 74 // Max value supported for DCT partitions 75 static const uint32_t kMaxDCTPartitions = 3; 76 77 // vp8 specific configuration parameter 78 // that enables token partitioning of 79 // the stream into substreams 80 int32_t mDCTPartitions; 81 82 // Encoder profile corresponding to OMX level parameter 83 // 84 // The inconsistency in the naming is caused by 85 // OMX spec referring vpx profiles (g_profile) 86 // as "levels" whereas using the name "profile" for 87 // something else. 88 OMX_VIDEO_VP8LEVELTYPE mLevel; 89 90 DISALLOW_EVIL_CONSTRUCTORS(SoftVP8Encoder); 91}; 92 93} // namespace android 94 95#endif // SOFT_VP8_ENCODER_H_ 96