1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00
FFmpeg/libavcodec/opus_parse.h
Andreas Rheinhardt 4fc2531fff avcodec/opus: Move stuff shared by decoder and parser to a new file
opus.h (which is used by all the Opus code) currently includes
several structures only used by the parser and the decoder;
several elements of OpusContext are even only used by the decoder.

This commit therefore moves the part of OpusContext that is shared
between these two components (and used by ff_opus_parse_extradata())
out into a new structure and moves all the other accompanying
structures and functions to a new header, opus_parse.h; the
functions itself are also moved to a new file, opus_parse.c.
(This also allows to remove several spurious dependencies
of the Opus parser and encoder.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:04:41 +02:00

78 lines
2.8 KiB
C

/*
* Opus decoder/parser common functions and structures
* Copyright (c) 2012 Andrew D'Addesio
* Copyright (c) 2013-2014 Mozilla Corporation
*
* 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
*/
#ifndef AVCODEC_OPUS_PARSE_H
#define AVCODEC_OPUS_PARSE_H
#include <stdint.h>
#include "avcodec.h"
#include "opus.h"
typedef struct OpusPacket {
int packet_size; /**< packet size */
int data_size; /**< size of the useful data -- packet size - padding */
int code; /**< packet code: specifies the frame layout */
int stereo; /**< whether this packet is mono or stereo */
int vbr; /**< vbr flag */
int config; /**< configuration: tells the audio mode,
** bandwidth, and frame duration */
int frame_count; /**< frame count */
int frame_offset[MAX_FRAMES]; /**< frame offsets */
int frame_size[MAX_FRAMES]; /**< frame sizes */
int frame_duration; /**< frame duration, in samples @ 48kHz */
enum OpusMode mode; /**< mode */
enum OpusBandwidth bandwidth; /**< bandwidth */
} OpusPacket;
// a mapping between an opus stream and an output channel
typedef struct ChannelMap {
int stream_idx;
int channel_idx;
// when a single decoded channel is mapped to multiple output channels, we
// write to the first output directly and copy from it to the others
// this field is set to 1 for those copied output channels
int copy;
// this is the index of the output channel to copy from
int copy_idx;
// this channel is silent
int silence;
} ChannelMap;
typedef struct OpusParseContext {
int nb_streams;
int nb_stereo_streams;
int16_t gain_i;
ChannelMap *channel_maps;
} OpusParseContext;
int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
int self_delimited);
int ff_opus_parse_extradata(AVCodecContext *avctx, OpusParseContext *s);
#endif /* AVCODEC_OPUS_PARSE_H */