xref: /aosp_15_r20/frameworks/av/media/libstagefright/codecs/vorbis/dec/SoftVorbis.h (revision ec779b8e0859a360c3d303172224686826e6e0e1)
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_VORBIS_H_
18 
19 #define SOFT_VORBIS_H_
20 
21 #include <media/stagefright/omx/SimpleSoftOMXComponent.h>
22 
23 struct vorbis_dsp_state;
24 struct vorbis_info;
25 
26 namespace android {
27 
28 struct SoftVorbis : public SimpleSoftOMXComponent {
29     SoftVorbis(const char *name,
30             const OMX_CALLBACKTYPE *callbacks,
31             OMX_PTR appData,
32             OMX_COMPONENTTYPE **component);
33 
34 protected:
35     virtual ~SoftVorbis();
36 
37     virtual OMX_ERRORTYPE internalGetParameter(
38             OMX_INDEXTYPE index, OMX_PTR params);
39 
40     virtual OMX_ERRORTYPE internalSetParameter(
41             OMX_INDEXTYPE index, const OMX_PTR params);
42 
43     virtual void onQueueFilled(OMX_U32 portIndex);
44     virtual void onPortFlushCompleted(OMX_U32 portIndex);
45     virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
46     virtual void onReset();
47 
48 private:
49     enum {
50         kNumBuffers = 4,
51         kMaxNumSamplesPerBuffer = 8192 * 2
52     };
53 
54     size_t mInputBufferCount;
55 
56     vorbis_dsp_state *mState;
57     vorbis_info *mVi;
58 
59     int64_t mAnchorTimeUs;
60     int64_t mNumFramesOutput;
61     int32_t mNumFramesLeftOnPage;
62     bool mSawInputEos;
63     bool mSignalledOutputEos;
64     bool mSignalledError;
65 
66     enum {
67         NONE,
68         AWAITING_DISABLED,
69         AWAITING_ENABLED
70     } mOutputPortSettingsChange;
71 
72     void initPorts();
73     status_t initDecoder();
74     bool isConfigured() const;
75     void handleEOS();
76 
77     DISALLOW_EVIL_CONSTRUCTORS(SoftVorbis);
78 };
79 
80 }  // namespace android
81 
82 #endif  // SOFT_VORBIS_H_
83 
84