Home | History | Annotate | Download | only in h264dec
      1 /*
      2  * Copyright (C) 2011 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_AVC_H_
     18 
     19 #define SOFT_AVC_H_
     20 
     21 #include "SoftVideoDecoderOMXComponent.h"
     22 #include <utils/KeyedVector.h>
     23 
     24 #include "H264SwDecApi.h"
     25 #include "basetype.h"
     26 
     27 namespace android {
     28 
     29 struct SoftAVC : public SoftVideoDecoderOMXComponent {
     30     SoftAVC(const char *name,
     31             const OMX_CALLBACKTYPE *callbacks,
     32             OMX_PTR appData,
     33             OMX_COMPONENTTYPE **component);
     34 
     35 protected:
     36     virtual ~SoftAVC();
     37 
     38     virtual void onQueueFilled(OMX_U32 portIndex);
     39     virtual void onPortFlushCompleted(OMX_U32 portIndex);
     40     virtual void onReset();
     41 
     42 private:
     43     enum {
     44         kNumInputBuffers  = 8,
     45         kNumOutputBuffers = 2,
     46     };
     47 
     48     enum EOSStatus {
     49         INPUT_DATA_AVAILABLE,
     50         INPUT_EOS_SEEN,
     51         OUTPUT_FRAMES_FLUSHED,
     52     };
     53 
     54     void *mHandle;
     55 
     56     size_t mInputBufferCount;
     57 
     58     uint32_t mPictureSize;
     59 
     60     uint8_t *mFirstPicture;
     61     int32_t mFirstPictureId;
     62 
     63     int32_t mPicId;  // Which output picture is for which input buffer?
     64 
     65     // OMX_BUFFERHEADERTYPE may be overkill, but it is convenient
     66     // for tracking the following fields: nFlags, nTimeStamp, etc.
     67     KeyedVector<int32_t, OMX_BUFFERHEADERTYPE *> mPicToHeaderMap;
     68     bool mHeadersDecoded;
     69 
     70     EOSStatus mEOSStatus;
     71 
     72     bool mSignalledError;
     73 
     74     status_t initDecoder();
     75     void drainAllOutputBuffers(bool eos);
     76     void drainOneOutputBuffer(int32_t picId, uint8_t *data);
     77     void saveFirstOutputBuffer(int32_t pidId, uint8_t *data);
     78     bool handleCropRectEvent(const CropParams* crop);
     79     bool handlePortSettingChangeEvent(const H264SwDecInfo *info);
     80 
     81     DISALLOW_EVIL_CONSTRUCTORS(SoftAVC);
     82 };
     83 
     84 }  // namespace android
     85 
     86 #endif  // SOFT_AVC_H_
     87 
     88