1bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber/*
2bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * Copyright (C) 2011 The Android Open Source Project
3bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber *
4bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
5bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * you may not use this file except in compliance with the License.
6bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * You may obtain a copy of the License at
7bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber *
8bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
9bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber *
10bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * Unless required by applicable law or agreed to in writing, software
11bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
12bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * See the License for the specific language governing permissions and
14bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * limitations under the License.
15bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber */
16bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
17bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber//#define LOG_NDEBUG 0
18bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#define LOG_TAG "SoftAMR"
19bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include <utils/Log.h>
20bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
21bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include "SoftAMR.h"
22bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
23bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include "gsmamr_dec.h"
24bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include "pvamrwbdecoder.h"
25bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
26bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include <media/stagefright/foundation/ADebug.h>
27bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
28bbba88cb1bdc34705d1477208990a06904c022e7Andreas Hubernamespace android {
29bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
30bbba88cb1bdc34705d1477208990a06904c022e7Andreas Hubertemplate<class T>
31bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huberstatic void InitOMXParams(T *params) {
32bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nSize = sizeof(T);
33bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nVersion.s.nVersionMajor = 1;
34bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nVersion.s.nVersionMinor = 0;
35bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nVersion.s.nRevision = 0;
36bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nVersion.s.nStep = 0;
37bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber}
38bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
39bbba88cb1bdc34705d1477208990a06904c022e7Andreas HuberSoftAMR::SoftAMR(
40bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        const char *name,
41bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        const OMX_CALLBACKTYPE *callbacks,
42bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        OMX_PTR appData,
43bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        OMX_COMPONENTTYPE **component)
44bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    : SimpleSoftOMXComponent(name, callbacks, appData, component),
45bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mMode(MODE_NARROW),
46bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mState(NULL),
47bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mDecoderBuf(NULL),
48bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mDecoderCookie(NULL),
49bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mInputBufferCount(0),
50bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mAnchorTimeUs(0),
51bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mNumSamplesOutput(0),
52bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mSignalledError(false),
53bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mOutputPortSettingsChange(NONE) {
54bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    if (!strcmp(name, "OMX.google.amrwb.decoder")) {
55bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        mMode = MODE_WIDE;
56bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    } else {
57bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        CHECK(!strcmp(name, "OMX.google.amrnb.decoder"));
58bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    }
59