SoftHEVC.h revision 3b5a6b9fa6c6825a1d0b441429e2bb365b259827
1/* 2 * Copyright (C) 2014 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_HEVC_H_ 18 19#define SOFT_HEVC_H_ 20 21#include "SoftVideoDecoderOMXComponent.h" 22#include <sys/time.h> 23 24namespace android { 25 26#define ivd_aligned_malloc(alignment, size) memalign(alignment, size) 27#define ivd_aligned_free(buf) free(buf) 28 29/** Number of entries in the time-stamp array */ 30#define MAX_TIME_STAMPS 64 31 32/** Maximum number of cores supported by the codec */ 33#define CODEC_MAX_NUM_CORES 4 34 35#define CODEC_MAX_WIDTH 1920 36 37#define CODEC_MAX_HEIGHT 1088 38 39/** Input buffer size */ 40#define INPUT_BUF_SIZE (1024 * 1024) 41 42#define MIN(a, b) ((a) < (b)) ? (a) : (b) 43 44/** Used to remove warnings about unused parameters */ 45#define UNUSED(x) ((void)(x)) 46 47/** Get time */ 48#define GETTIME(a, b) gettimeofday(a, b); 49 50/** Compute difference between start and end */ 51#define TIME_DIFF(start, end, diff) \ 52 diff = ((end.tv_sec - start.tv_sec) * 1000000) + \ 53 (end.tv_usec - start.tv_usec); 54 55struct SoftHEVC: public SoftVideoDecoderOMXComponent { 56 SoftHEVC(const char *name, const OMX_CALLBACKTYPE *callbacks, 57 OMX_PTR appData, OMX_COMPONENTTYPE **component); 58 59protected: 60 virtual ~SoftHEVC(); 61 62 virtual void onQueueFilled(OMX_U32 portIndex); 63 virtual void onPortFlushCompleted(OMX_U32 portIndex); 64 virtual void onReset(); 65private: 66 // Number of input and output buffers 67 enum { 68 kNumBuffers = 8 69 }; 70 71 iv_obj_t *mCodecCtx; // Codec context 72 iv_mem_rec_t *mMemRecords; // Memory records requested by the codec 73 size_t mNumMemRecords; // Number of memory records requested by the codec 74 75 uint32_t mNewWidth; // New width after change in resolution 76 uint32_t mNewHeight; // New height after change in resolution 77 uint32_t mInitWidth; // Width used during codec creation 78 uint32_t mInitHeight; // Height used during codec creation 79 size_t mStride; // Stride to be used for display buffers 80 81 size_t mNumCores; // Number of cores to be uesd by the codec 82 83 struct timeval mTimeStart; // Time at the start of decode() 84 struct timeval mTimeEnd; // Time at the end of decode() 85 86 // Internal buffer to be used to flush out the buffers from decoder 87 uint8_t *mFlushOutBuffer; 88 89 // Status of entries in the timestamp array 90 bool mTimeStampsValid[MAX_TIME_STAMPS]; 91 92 // Timestamp array - Since codec does not take 64 bit timestamps, 93 // they are maintained in the plugin 94 OMX_S64 mTimeStamps[MAX_TIME_STAMPS]; 95 96 OMX_COLOR_FORMATTYPE mOmxColorFormat; // OMX Color format 97 IV_COLOR_FORMAT_T mIvColorFormat; // Ittiam Color format 98 99 bool mIsInFlush; // codec is flush mode 100 bool mReceivedEOS; // EOS is receieved on input port 101 bool mIsAdapting; // plugin in middle of change in resolution 102 103 status_t initDecoder(); 104 status_t deInitDecoder(); 105 status_t setFlushMode(); 106 status_t setParams(WORD32 stride, IVD_VIDEO_DECODE_MODE_T decMode); 107 status_t getVersion(); 108 status_t setNumCores(); 109 status_t resetDecoder(); 110 status_t resetPlugin(); 111 112 DISALLOW_EVIL_CONSTRUCTORS (SoftHEVC); 113}; 114 115} // namespace android 116 117#endif // SOFT_HEVC_H_ 118