Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54f85325 authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Merge changes I8785e725,I26f4b725,Ib717faa5,I45adfe7c,I7127b124, ... am: b8578f9e

parents a57cda46 b8578f9e
Loading
Loading
Loading
Loading

TEST_MAPPING

100755 → 100644
+6 −0
Original line number Diff line number Diff line
@@ -62,6 +62,12 @@
    {
      "name" : "net_test_btif_hf_client_service"
    },
    {
      "name" : "libaptx_enc_tests"
    },
    {
      "name" : "libaptxhd_enc_tests"
    },
    {
      "name" : "net_test_stack_btm"
    }
+0 −2
Original line number Diff line number Diff line
@@ -10,7 +10,5 @@
  ],
  "name": "com.android.btservices",
  "requireNativeLibs": [
    "libaptX_encoder.so",
    "libaptXHD_encoder.so"
  ]
}
+35 −0
Original line number Diff line number Diff line
tidy_errors = [
    "*",
    "-altera-struct-pack-align",
    "-altera-unroll-loops",
    "-bugprone-narrowing-conversions",
    "-cppcoreguidelines-avoid-magic-numbers",
    "-cppcoreguidelines-init-variables",
    "-cppcoreguidelines-narrowing-conversions",
    "-hicpp-signed-bitwise",
    "-readability-identifier-length",
    "-readability-magic-numbers",
]

cc_library_static {
    name: "libaptx_enc",
    host_supported: true,
    export_include_dirs: ["include"],
    srcs: [
        "src/aptXbtenc.c",
        "src/ProcessSubband.c",
        "src/QmfConv.c",
        "src/QuantiseDifference.c",
    ],
    cflags: ["-O2", "-Werror", "-Wall", "-Wextra"],
    tidy: true,
    tidy_checks: tidy_errors,
    tidy_checks_as_errors: tidy_errors,
    min_sdk_version: "Tiramisu",
    apex_available: [
        "com.android.btservices",
    ],
    visibility: [
        "//packages/modules/Bluetooth:__subpackages__",
    ],
}
+26 −7
Original line number Diff line number Diff line
/**
 * Copyright (C) 2022 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 exposes a public interface to allow clients to invoke aptX
@@ -9,6 +24,8 @@
#ifndef APTXBTENC_H
#define APTXBTENC_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
@@ -35,15 +52,17 @@ APTXBTENCEXPORT const char* aptxbtenc_version(void);
 * The function returns 0 if no error occurred during the initialisation. */
APTXBTENCEXPORT int aptxbtenc_init(void* _state, short endian);

/* aptxbtenc_setsync_mode is used to initialise the sync mode in the encoder state structure.
 * _state should be a pointer to the encoder structure (stereo, though strictly-speaking it is dual channel).
 * 'sync_mode' is an enumerated type  {stereo=0, dualmono=1, no_sync=2}
 * The function returns 0 if no error occurred during the initialisation. */
/* aptxbtenc_setsync_mode is used to initialise the sync mode in the encoder
 * state structure. _state should be a pointer to the encoder structure (stereo,
 * though strictly-speaking it is dual channel). 'sync_mode' is an enumerated
 * type  {stereo=0, dualmono=1, no_sync=2} The function returns 0 if no error
 * occurred during the initialisation. */
APTXBTENCEXPORT int aptxbtenc_setsync_mode(void* _state, int32_t sync_mode);

/* StereoEncode will take 8 audio samples (16-bit per sample)
 * and generate one 32-bit codeword with autosync inserted. */
APTXBTENCEXPORT int aptxbtenc_encodestereo(void* _state, void* _pcmL, void* _pcmR, void* _buffer);
APTXBTENCEXPORT int aptxbtenc_encodestereo(void* _state, void* _pcmL,
                                           void* _pcmR, void* _buffer);

#ifdef __cplusplus
}  //  /extern "C"
+69 −48
Original line number Diff line number Diff line
/**
 * Copyright (C) 2022 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.
 */
/*------------------------------------------------------------------------------
 *
 *  All declarations relevant for aptxEncode. This function allows clients
@@ -15,41 +30,48 @@

#include "AptxParameters.h"
#include "DitherGenerator.h"
#include "Qmf.h"
#include "Quantiser.h"
#include "SubbandFunctionsCommon.h"
#include "Qmf.h"


/* Function to carry out a single-channel aptX encode on 4 new PCM samples */
XBT_INLINE_ void aptxEncode(int32_t pcm[4], Qmf_storage* Qmf_St, Encoder_data* EncoderDataPt)
{
XBT_INLINE_ void aptxEncode(int32_t pcm[4], Qmf_storage* Qmf_St,
                            Encoder_data* EncoderDataPt) {
  int32_t predVals[4];
  int32_t qCodes[4];
  int32_t aqmfOutputs[4];

  /* Extract the previous predicted values and quantised codes into arrays */
   for (int i = 0; i < 4; i++)
   {
  for (int i = 0; i < 4; i++) {
    predVals[i] = EncoderDataPt->m_SubbandData[i].m_predData.m_predVal;
    qCodes[i] = EncoderDataPt->m_qdata[i].qCode;
  }

  /* Update codeword history, then generate new dither values. */
   EncoderDataPt->m_codewordHistory = xbtEncupdateCodewordHistory(qCodes, EncoderDataPt->m_codewordHistory);
   EncoderDataPt->m_dithSyncRandBit = xbtEncgenerateDither(EncoderDataPt->m_codewordHistory, EncoderDataPt->m_ditherOutputs);
  EncoderDataPt->m_codewordHistory =
      xbtEncupdateCodewordHistory(qCodes, EncoderDataPt->m_codewordHistory);
  EncoderDataPt->m_dithSyncRandBit = xbtEncgenerateDither(
      EncoderDataPt->m_codewordHistory, EncoderDataPt->m_ditherOutputs);

  /* Run the analysis QMF */
  QmfAnalysisFilter(pcm, Qmf_St, predVals, aqmfOutputs);

  /* Run the quantiser for each subband */
   quantiseDifferenceLL(aqmfOutputs[0], EncoderDataPt->m_ditherOutputs[0], EncoderDataPt->m_SubbandData[0].m_iqdata.delta, &EncoderDataPt->m_qdata[0]);
   quantiseDifferenceLH(aqmfOutputs[1], EncoderDataPt->m_ditherOutputs[1], EncoderDataPt->m_SubbandData[1].m_iqdata.delta, &EncoderDataPt->m_qdata[1]);
   quantiseDifferenceHL(aqmfOutputs[2], EncoderDataPt->m_ditherOutputs[2], EncoderDataPt->m_SubbandData[2].m_iqdata.delta, &EncoderDataPt->m_qdata[2]);
   quantiseDifferenceHH(aqmfOutputs[3], EncoderDataPt->m_ditherOutputs[3], EncoderDataPt->m_SubbandData[3].m_iqdata.delta, &EncoderDataPt->m_qdata[3]);
  quantiseDifferenceLL(aqmfOutputs[0], EncoderDataPt->m_ditherOutputs[0],
                       EncoderDataPt->m_SubbandData[0].m_iqdata.delta,
                       &EncoderDataPt->m_qdata[0]);
  quantiseDifferenceLH(aqmfOutputs[1], EncoderDataPt->m_ditherOutputs[1],
                       EncoderDataPt->m_SubbandData[1].m_iqdata.delta,
                       &EncoderDataPt->m_qdata[1]);
  quantiseDifferenceHL(aqmfOutputs[2], EncoderDataPt->m_ditherOutputs[2],
                       EncoderDataPt->m_SubbandData[2].m_iqdata.delta,
                       &EncoderDataPt->m_qdata[2]);
  quantiseDifferenceHH(aqmfOutputs[3], EncoderDataPt->m_ditherOutputs[3],
                       EncoderDataPt->m_SubbandData[3].m_iqdata.delta,
                       &EncoderDataPt->m_qdata[3]);
}

XBT_INLINE_ void aptxPostEncode(Encoder_data* EncoderDataPt)
{
XBT_INLINE_ void aptxPostEncode(Encoder_data* EncoderDataPt) {
  /* Run the remaining subband processing for each subband */
  /* Manual inlining on the 4 subband */
  processSubbandLL(EncoderDataPt->m_qdata[0].qCode,
@@ -73,7 +95,6 @@ XBT_INLINE_ void aptxPostEncode(Encoder_data* EncoderDataPt)
                 &EncoderDataPt->m_SubbandData[3].m_iqdata);
}


#ifdef _GCC
#pragma GCC visibility pop
#endif
Loading