xref: /aosp_15_r20/frameworks/av/media/libstagefright/codecs/amrnb/dec/SoftAMR.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_AMR_H_
18 
19 #define SOFT_AMR_H_
20 
21 #include <media/stagefright/omx/SimpleSoftOMXComponent.h>
22 #include "gsmamr_dec.h"
23 #include "pvamrwbdecoder.h"
24 
25 namespace android {
26 
27 struct SoftAMR : public SimpleSoftOMXComponent {
28     SoftAMR(const char *name,
29             const OMX_CALLBACKTYPE *callbacks,
30             OMX_PTR appData,
31             OMX_COMPONENTTYPE **component);
32 
33 protected:
34     virtual ~SoftAMR();
35 
36     virtual OMX_ERRORTYPE internalGetParameter(
37             OMX_INDEXTYPE index, OMX_PTR params);
38 
39     virtual OMX_ERRORTYPE internalSetParameter(
40             OMX_INDEXTYPE index, const OMX_PTR params);
41 
42     virtual void onQueueFilled(OMX_U32 portIndex);
43     virtual void onPortFlushCompleted(OMX_U32 portIndex);
44     virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
45     virtual void onReset();
46 
47 private:
48     enum {
49         kNumBuffers             = 4,
50         kSampleRateNB           = 8000,
51         kSampleRateWB           = 16000,
52         kNumSamplesPerFrameNB   = 160,
53         kNumSamplesPerFrameWB   = 320,
54     };
55 
56     enum {
57         MODE_NARROW,
58         MODE_WIDE
59 
60     } mMode;
61 
62     void *mState;
63     void *mDecoderBuf;
64     int16_t *mDecoderCookie;
65     RX_State_wb mRxState{};
66 
67     size_t mInputBufferCount;
68     int64_t mAnchorTimeUs;
69     int64_t mNumSamplesOutput;
70 
71     bool mSignalledError;
72 
73     enum {
74         NONE,
75         AWAITING_DISABLED,
76         AWAITING_ENABLED
77     } mOutputPortSettingsChange;
78 
79     int16_t mInputSampleBuffer[477];
80 
81     void initPorts();
82     status_t initDecoder();
83     bool isConfigured() const;
84 
85     DISALLOW_EVIL_CONSTRUCTORS(SoftAMR);
86 };
87 
88 }  // namespace android
89 
90 #endif  // SOFT_AMR_H_
91 
92