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 "SoftVorbis"
19bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include <utils/Log.h>
20bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
21bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include "SoftVorbis.h"
22bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
23bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include <media/stagefright/foundation/ADebug.h>
24bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include <media/stagefright/MediaDefs.h>
25bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
26bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huberextern "C" {
27bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    #include <Tremolo/codec_internal.h>
28bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
29bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb);
30bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb);
31bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb);
32bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber}
33bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
34bbba88cb1bdc34705d1477208990a06904c022e7Andreas Hubernamespace android {
35bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
36bbba88cb1bdc34705d1477208990a06904c022e7Andreas Hubertemplate<class T>
37bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huberstatic void InitOMXParams(T *params) {
38bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nSize = sizeof(T);
39bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nVersion.s.nVersionMajor = 1;
40bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nVersion.s.nVersionMinor = 0;
41bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nVersion.s.nRevision = 0;
42bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    params->nVersion.s.nStep = 0;
43bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber}
44bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
45bbba88cb1bdc34705d1477208990a06904c022e7Andreas HuberSoftVorbis::SoftVorbis(
46bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        const char *name,
47bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        const OMX_CALLBACKTYPE *callbacks,
48bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        OMX_PTR appData,
49bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        OMX_COMPONENTTYPE **component)
50bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    : SimpleSoftOMXComponent(name, callbacks, appData, component),
51bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mInputBufferCount(0),
52bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mState(NULL),
53bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mVi(NULL),
54bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mAnchorTimeUs(0),
55bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mNumFramesOutput(0),
56bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mNumFramesLeftOnPage(-1),
57bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber      mOutputPortSettingsChange(NONE) {
58bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    initPorts();
59