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     uint8_t *mFirstPicture;
     59     int32_t mFirstPictureId;
     60 
     61     int32_t mPicId;  // Which output picture is for which input buffer?
     62 
     63     // OMX_BUFFERHEADERTYPE may be overkill, but it is convenient
     64     // for tracking the following fields: nFlags, nTimeStamp, etc.
     65     KeyedVector<int32_t, OMX_BUFFERHEADERTYPE *> mPicToHeaderMap;
     66     bool mHeadersDecoded;
     67 
     68     EOSStatus mEOSStatus;
     69 
     70     bool mSignalledError;
     71 
     72     status_t initDecoder();
     73     void drainAllOutputBuffers(bool eos);
     74     void drainOneOutputBuffer(int32_t picId, uint8_t *data);
     75     void saveFirstOutputBuffer(int32_t pidId, uint8_t *data);
     76     CropSettingsMode handleCropParams(const H264SwDecInfo& decInfo);
     77 
     78     DISALLOW_EVIL_CONSTRUCTORS(SoftAVC);
     79 };
     80 
     81 }  // namespace android
     82 
     83 #endif  // SOFT_AVC_H_
     84 
     85