1 /* 2 * Copyright 2023, 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 #pragma once 18 19 namespace android { 20 21 inline constexpr uint32_t kSpdifEncodedChannelCount = 2u; 22 inline constexpr uint32_t kSpdifDataTypeAc3 = 1u; 23 inline constexpr uint32_t kSpdifDataTypeEac3 = 21u; 24 inline constexpr uint32_t kSpdifRateMultiplierEac3 = 4u; 25 26 // Burst preamble defined in IEC61937-1 27 inline constexpr uint16_t kSpdifSync1 = 0xF872; // Pa 28 inline constexpr uint16_t kSpdifSync2 = 0x4E1F; // Pb 29 30 // Returns the SPDIF rate multiplier for the audio format, or zero if not supported. spdif_rate_multiplier(audio_format_t format)31inline int spdif_rate_multiplier(audio_format_t format) { 32 switch (format) { 33 case AUDIO_FORMAT_E_AC3: 34 case AUDIO_FORMAT_E_AC3_JOC: 35 return 4; 36 case AUDIO_FORMAT_AC3: 37 case AUDIO_FORMAT_DTS: 38 case AUDIO_FORMAT_DTS_HD: 39 return 1; 40 default: 41 return 0; 42 } 43 } 44 45 } // namespace android 46