Home | History | Annotate | Download | only in audio_utils
      1 /*
      2  * Copyright (C) 2014 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 #ifndef ANDROID_AUDIO_CHANNELS_H
     18 #define ANDROID_AUDIO_CHANNELS_H
     19 
     20 /** \cond */
     21 __BEGIN_DECLS
     22 /** \endcond */
     23 
     24 /**
     25  * Expands or contracts sample data from one interleaved channel format to another.
     26  * Expanded channels are filled with zeros and put at the end of each audio frame.
     27  * Contracted channels are omitted from the end of each audio frame.
     28  *
     29  *   \param in_buff              points to the buffer of samples
     30  *   \param in_buff_chans        Specifies the number of channels in the input buffer.
     31  *   \param out_buff             points to the buffer to receive converted samples.
     32  *   \param out_buff_chans       Specifies the number of channels in the output buffer.
     33  *   \param sample_size_in_bytes Specifies the number of bytes per sample. 1, 2, 3, 4 are
     34  *     currently valid.
     35  *   \param num_in_bytes         size of input buffer in BYTES
     36  *
     37  * \return
     38  *   the number of BYTES of output data or 0 if an error occurs.
     39  *
     40  * \note
     41  *   The out and sums buffers must either be completely separate (non-overlapping), or
     42  *   they must both start at the same address. Partially overlapping buffers are not supported.
     43  */
     44 size_t adjust_channels(const void* in_buff, size_t in_buff_chans,
     45                        void* out_buff, size_t out_buff_chans,
     46                        unsigned sample_size_in_bytes, size_t num_in_bytes);
     47 
     48 /**
     49  * Expands or contracts sample data from one interleaved channel format to another.
     50  * Extra expanded channels are left alone in the output buffer.
     51  * Contracted channels are omitted from the end of each audio frame.
     52  *
     53  *   \param in_buff              points to the buffer of samples
     54  *   \param in_buff_chans        Specifies the number of channels in the input buffer.
     55  *   \param out_buff             points to the buffer to receive converted samples.
     56  *   \param out_buff_chans       Specifies the number of channels in the output buffer.
     57  *   \param sample_size_in_bytes Specifies the number of bytes per sample. 1, 2, 3, 4 are
     58  *     currently valid.
     59  *   \param num_in_bytes         size of input buffer in BYTES
     60  *
     61  * \return
     62  *   the number of BYTES of output data or 0 if an error occurs.
     63  *
     64  * \note
     65  *   The out and in buffers must either be completely separate (non-overlapping), or
     66  *   they must both start at the same address. Partially overlapping buffers are not supported.
     67  */
     68 size_t adjust_selected_channels(const void* in_buff, size_t in_buff_chans,
     69                        void* out_buff, size_t out_buff_chans,
     70                        unsigned sample_size_in_bytes, size_t num_in_bytes);
     71 
     72 /** \cond */
     73 __END_DECLS
     74 /** \endcond */
     75 
     76 #endif
     77