chromium/third_party/ffmpeg/libavformat/mov_chan.h

/*
 * Copyright (c) 2011 Justin Ruggles
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

/**
 * mov 'chan' tag reading/writing.
 * @author Justin Ruggles
 */

#ifndef AVFORMAT_MOV_CHAN_H
#define AVFORMAT_MOV_CHAN_H

#include <stdint.h>

#include "libavutil/channel_layout.h"
#include "libavcodec/codec_id.h"
#include "libavcodec/codec_par.h"
#include "avformat.h"

/**
 * Channel Layout Tag
 * This tells which channels are present in the audio stream and the order in
 * which they appear.
 *
 * @note We're using the channel layout tag to indicate channel order
 *       when the value is greater than 0x10000. The Apple documentation has
 *       some contradictions as to how this is actually supposed to be handled.
 *
 *       Core Audio File Format Spec:
 *           "The high 16 bits indicates a specific ordering of the channels."
 *       Core Audio Data Types Reference:
 *           "These identifiers specify the channels included in a layout but
 *            do not specify a particular ordering of those channels."
 */
enum MovChannelLayoutTag {};

/**
 * Get the channel layout tag for the specified codec id and channel layout.
 * If the layout tag was not found, use a channel bitmap if possible.
 *
 * @param[in]  codec_id        codec id
 * @param[in]  channel_layout  channel layout
 * @param[out] bitmap          channel bitmap
 * @return                     channel layout tag
 */
int ff_mov_get_channel_layout_tag(const AVCodecParameters *par,
                                       uint32_t *layout,
                                       uint32_t *bitmap,
                                       uint32_t **pchannel_desc);

/**
 * Read 'chan' tag from the input stream.
 *
 * @param s     AVFormatContext
 * @param pb    AVIOContext
 * @param st    The stream to set codec values for
 * @param size  Remaining size in the 'chan' tag
 * @return      0 if ok, or negative AVERROR code on failure
 */
int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
                     int64_t size);

/**
 * Get ISO/IEC 23001-8 ChannelConfiguration from AVChannelLayout.
 *
 */
int ff_mov_get_channel_config_from_layout(const AVChannelLayout *layout, int *config);

/**
 * Get AVChannelLayout from ISO/IEC 23001-8 ChannelConfiguration.
 *
 * @return 1  if the config was unknown, layout is untouched in this case
 *         0  if the config was found
 *         <0 on error
 */
int ff_mov_get_channel_layout_from_config(int config, AVChannelLayout *layout, uint64_t omitted_channel_map);

/**
 * Get ISO/IEC 23001-8 OutputChannelPosition from AVChannelLayout.
 */
int ff_mov_get_channel_positions_from_layout(const AVChannelLayout *layout,
                                             uint8_t *position, int position_num);

/**
 * Read 'chnl' tag from the input stream.
 *
 * @param s     AVFormatContext
 * @param pb    AVIOContext
 * @param st    The stream to set codec values for
 * @return      0 if ok, or negative AVERROR code on failure
 */
int ff_mov_read_chnl(AVFormatContext *s, AVIOContext *pb, AVStream *st);

#endif /* AVFORMAT_MOV_CHAN_H */