Java tutorial
//package com.java2s; /* * Copyright (C) 2014 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. */ import java.nio.ByteBuffer; public class Main { /** * Returns the number of audio samples represented by the given DTS frame. * * @param data The frame to parse. * @return The number of audio samples represented by the frame. */ public static int parseDtsAudioSampleCount(byte[] data) { // See ETSI TS 102 114 subsection 5.4.1. int nblks = ((data[4] & 0x01) << 6) | ((data[5] & 0xFC) >> 2); return (nblks + 1) * 32; } /** * Like {@link #parseDtsAudioSampleCount(byte[])} but reads from a byte buffer. The buffer * position is not modified. */ public static int parseDtsAudioSampleCount(ByteBuffer data) { // See ETSI TS 102 114 subsection 5.4.1. int position = data.position(); int nblks = ((data.get(position + 4) & 0x01) << 6) | ((data.get(position + 5) & 0xFC) >> 2); return (nblks + 1) * 32; } }