/H264Dec/SoftAVC.h

http://github.com/mbebenita/Broadway · C Header · 106 lines · 63 code · 26 blank · 17 comment · 0 complexity · 72ba5a232d79cd277166da2ff86a8603 MD5 · raw file

  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. #ifndef SOFT_AVC_H_
  17. #define SOFT_AVC_H_
  18. #include "SimpleSoftOMXComponent.h"
  19. #include <utils/KeyedVector.h>
  20. #include "H264SwDecApi.h"
  21. #include "basetype.h"
  22. namespace android {
  23. struct SoftAVC : public SimpleSoftOMXComponent {
  24. SoftAVC(const char *name,
  25. const OMX_CALLBACKTYPE *callbacks,
  26. OMX_PTR appData,
  27. OMX_COMPONENTTYPE **component);
  28. protected:
  29. virtual ~SoftAVC();
  30. virtual OMX_ERRORTYPE internalGetParameter(
  31. OMX_INDEXTYPE index, OMX_PTR params);
  32. virtual OMX_ERRORTYPE internalSetParameter(
  33. OMX_INDEXTYPE index, const OMX_PTR params);
  34. virtual OMX_ERRORTYPE getConfig(OMX_INDEXTYPE index, OMX_PTR params);
  35. virtual void onQueueFilled(OMX_U32 portIndex);
  36. virtual void onPortFlushCompleted(OMX_U32 portIndex);
  37. virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
  38. private:
  39. enum {
  40. kInputPortIndex = 0,
  41. kOutputPortIndex = 1,
  42. kNumInputBuffers = 8,
  43. kNumOutputBuffers = 2,
  44. };
  45. enum EOSStatus {
  46. INPUT_DATA_AVAILABLE,
  47. INPUT_EOS_SEEN,
  48. OUTPUT_FRAMES_FLUSHED,
  49. };
  50. void *mHandle;
  51. size_t mInputBufferCount;
  52. uint32_t mWidth, mHeight, mPictureSize;
  53. uint32_t mCropLeft, mCropTop;
  54. uint32_t mCropWidth, mCropHeight;
  55. uint8_t *mFirstPicture;
  56. int32_t mFirstPictureId;
  57. int32_t mPicId; // Which output picture is for which input buffer?
  58. // OMX_BUFFERHEADERTYPE may be overkill, but it is convenient
  59. // for tracking the following fields: nFlags, nTimeStamp, etc.
  60. KeyedVector<int32_t, OMX_BUFFERHEADERTYPE *> mPicToHeaderMap;
  61. bool mHeadersDecoded;
  62. EOSStatus mEOSStatus;
  63. enum OutputPortSettingChange {
  64. NONE,
  65. AWAITING_DISABLED,
  66. AWAITING_ENABLED
  67. };
  68. OutputPortSettingChange mOutputPortSettingsChange;
  69. void initPorts();
  70. status_t initDecoder();
  71. void updatePortDefinitions();
  72. bool drainAllOutputBuffers();
  73. void drainOneOutputBuffer(int32_t picId, uint8_t *data);
  74. void saveFirstOutputBuffer(int32_t pidId, uint8_t *data);
  75. bool handleCropRectEvent(const CropParams* crop);
  76. bool handlePortSettingChangeEvent(const H264SwDecInfo *info);
  77. DISALLOW_EVIL_CONSTRUCTORS(SoftAVC);
  78. };
  79. } // namespace android
  80. #endif // SOFT_AVC_H_