C++程序  |  262行  |  6.68 KB

/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// This file is automagically generated by hashgen, do not edit

/** \file IID_to_MPH.c Interface ID to MPH mapping */

#include <SLES/OpenSLES.h>
#include "MPH.h"
#include <assert.h>
#include <string.h>

extern const struct SLInterfaceID_ SL_IID_array[MPH_MAX];

/** \brief Map SLInterfaceID to its minimal perfect hash (MPH), or -1 if unknown */

int IID_to_MPH(const SLInterfaceID iid)
{
#define MAX_HASH_VALUE 180
  static const unsigned char asso_values[] =
    {
       35,  20,  79,  99, 181, 181,  74, 181, 181, 181,
      181, 181, 181, 181,  84, 181,  79,  59, 181, 181,
      181, 181,  54, 181,  69,  39, 181, 181,  29, 181,
      181,  85,   5, 181, 181, 181, 181, 181,  49, 181,
       24, 181, 181, 181,  14, 181, 117, 181, 181, 181,
      181, 181,   9, 181, 181, 181, 181, 181,  14, 100,
      181,   9,  24, 181,  50, 181, 181, 181, 181, 127,
      181, 181, 107,  85, 181, 181, 181, 181, 181, 181,
      181, 181, 181, 181, 181, 181, 127, 181,  19, 181,
      181, 181,   9, 181, 181, 181,  25, 122,  14, 107,
      181, 181, 181, 181, 181, 181, 181,   4, 181, 102,
      181, 181,   0, 181,   4,  97, 122, 181,  72,  45,
      181, 181, 105, 181, 181, 181,  87, 181,  30, 181,
      181, 181, 181, 181, 181, 107, 125, 181, 181, 181,
      181, 181,  80,  82, 181,  77, 181, 120, 181, 181,
      181, 181, 181,  97, 181, 181,  87, 181, 181,  65,
        5, 181,  57, 181, 181,  82, 115, 181, 181,  52,
      181,  72,  55, 181, 181,  62, 181,  45, 181, 181,
      181, 181,  32, 181,  32,  30, 181, 181, 181, 181,
      181, 181,   0, 181, 181, 181, 110,  47, 181, 181,
      181, 181, 181, 181, 181, 181, 120, 181, 181, 181,
      100,  47, 181, 181, 181,  37, 181, 181,   2, 181,
      181, 181, 181,  27,  10, 181, 181,  27, 181, 181,
      181, 181, 181, 181,  22, 181,  75, 181, 181, 181,
       10,  12, 181, 181,  70, 181,   7,   7, 181, 181,
      181, 105,   2, 125, 181, 181
    };
    static const signed char hash_to_MPH[] = {
        MPH_ANDROIDEFFECTSEND,
        -1,
        MPH_XADYNAMICINTERFACEMANAGEMENT,
        -1,
        MPH_XAAUDIODECODERCAPABILITIES,
        MPH_XALED,
        -1,
        MPH_BASSBOOST,
        -1,
        MPH_XAOUTPUTMIX,
        MPH_MIDITIME,
        -1,
        MPH_RECORD,
        -1,
        MPH_AUDIOIODEVICECAPABILITIES,
        MPH_MUTESOLO,
        -1,
        MPH_VOLUME,
        -1,
        MPH_ANDROIDCONFIGURATION,
        MPH_XASNAPSHOT,
        -1,
        MPH_XAIMAGECONTROLS,
        -1,
        MPH_SEEK,
        MPH_3DLOCATION,
        -1,
        MPH_XATHREADSYNC,
        -1,
        MPH_XAIMAGEDECODERCAPABILITIES,
        MPH_XACAMERACAPABILITIES,
        -1,
        MPH_XAVOLUME,
        -1,
        MPH_VIBRA,
        MPH_XAIMAGEEFFECTS,
        -1,
        MPH_XAPLAY,
        -1,
        MPH_PRESETREVERB,
        MPH_XAOBJECT,
        -1,
        MPH_XACONFIGEXTENSION,
        -1,
        MPH_EQUALIZER,
        MPH_XAVIBRA,
        -1,
        MPH_3DMACROSCOPIC,
        -1,
        MPH_PITCH,
        MPH_ENGINECAPABILITIES,
        -1,
        MPH_XAMETADATAEXTRACTION,
        -1,
        MPH_3DDOPPLER,
        MPH_XAVIDEODECODERCAPABILITIES,
        -1,
        MPH_RATEPITCH,
        -1,
        MPH_ANDROIDAUTOMATICGAINCONTROL,
        MPH_AUDIODECODERCAPABILITIES,
        -1,
        MPH_XARADIO,
        -1,
        MPH_OUTPUTMIXEXT,
        MPH_ENVIRONMENTALREVERB,
        -1,
        MPH_XAVIDEOPOSTPROCESSING,
        -1,
        MPH_3DCOMMIT,
        MPH_OUTPUTMIX,
        -1,
        MPH_METADATATRAVERSAL,
        -1,
        MPH_XASEEK,
        MPH_XASTREAMINFORMATION,
        -1,
        MPH_DEVICEVOLUME,
        -1,
        MPH_OBJECT,
        MPH_VIRTUALIZER,
        -1,
        MPH_XARDS,
        -1,
        MPH_XAVIDEOENCODER,
        MPH_PLAY,
        -1,
        MPH_XADYNAMICSOURCE,
        -1,
        MPH_3DGROUPING,
        MPH_XAVIDEOENCODERCAPABILITIES,
        -1,
        MPH_XAPREFETCHSTATUS,
        -1,
        MPH_XAMETADATATRAVERSAL,
        MPH_XAEQUALIZER,
        -1,
        MPH_BUFFERQUEUE,
        -1,
        MPH_ANDROIDBUFFERQUEUESOURCE,
        MPH_XARECORD,
        -1,
        MPH_XAMETADATAINSERTION,
        -1,
        MPH_XADEVICEVOLUME,
        MPH_ANDROIDNOISESUPPRESSION,
        -1,
        MPH_ENGINE,
        -1,
        MPH_MIDIMUTESOLO,
        MPH_METADATAEXTRACTION,
        -1,
        MPH_XACAMERA,
        -1,
        -1,
        MPH_PREFETCHSTATUS,
        -1,
        MPH_LED,
        -1,
        -1,
        MPH_XAAUDIOENCODER,
        -1,
        MPH_XAENGINE,
        -1,
        -1,
        MPH_ANDROIDEFFECTCAPABILITIES,
        -1,
        MPH_MIDIMESSAGE,
        -1,
        -1,
        MPH_VISUALIZATION,
        -1,
        MPH_3DSOURCE,
        -1,
        -1,
        MPH_PLAYBACKRATE,
        -1,
        MPH_XAAUDIOENCODERCAPABILITIES,
        -1,
        -1,
        MPH_EFFECTSEND,
        -1,
        MPH_XAAUDIOIODEVICECAPABILITIES,
        -1,
        -1,
        MPH_NULL,
        -1,
        MPH_ANDROIDACOUSTICECHOCANCELLATION,
        -1,
        -1,
        MPH_XAIMAGEENCODERCAPABILITIES,
        -1,
        MPH_ANDROIDEFFECT,
        -1,
        -1,
        MPH_MIDITEMPO,
        -1,
        MPH_XAPLAYBACKRATE,
        -1,
        -1,
        MPH_DYNAMICINTERFACEMANAGEMENT,
        -1,
        MPH_DYNAMICSOURCE,
        -1,
        -1,
        MPH_ANDROIDSIMPLEBUFFERQUEUE,
        -1,
        MPH_THREADSYNC,
        -1,
        -1,
        MPH_AUDIOENCODERCAPABILITIES,
        -1,
        -1,
        -1,
        -1,
        MPH_XAIMAGEENCODER,
        -1,
        -1,
        -1,
        -1,
        MPH_AUDIOENCODER
    };
    if (&SL_IID_array[0] <= iid && &SL_IID_array[MPH_MAX] > iid)
        return iid - &SL_IID_array[0];
    if (NULL != iid) {
        unsigned key = asso_values[((unsigned char *)iid)[8]] +
            asso_values[((unsigned char *)iid)[0]];
        if (key <= MAX_HASH_VALUE) {
            int MPH = hash_to_MPH[key];
            if (MPH >= 0) {
                assert(MPH < MPH_MAX);
                SLInterfaceID trial = &SL_IID_array[MPH];
                if (!memcmp(iid, trial, sizeof(struct SLInterfaceID_)))
                    return MPH;
            }
        }
    }
    return -1;
}