361 lines
11 KiB
C
361 lines
11 KiB
C
/*
|
|
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program 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 General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
* Description:
|
|
*/
|
|
/*
|
|
* copyright (c) 2001 Fabrice Bellard
|
|
*
|
|
* 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_AVCODEC_H
|
|
#define AVCODEC_AVCODEC_H
|
|
|
|
#ifndef __MW__
|
|
#include <inttypes.h>
|
|
#else
|
|
#include <core/types.h>
|
|
#endif
|
|
|
|
|
|
#define FF_INPUT_BUFFER_PADDING_SIZE 8
|
|
|
|
enum CodecID {
|
|
CODEC_ID_NONE,
|
|
|
|
/* various PCM "codecs" */
|
|
CODEC_ID_PCM_S16LE = 0x10000,
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M_THP,
|
|
CODEC_ID_ADPCM_IMA_AMV,
|
|
CODEC_ID_ADPCM_EA_R1,
|
|
CODEC_ID_ADPCM_EA_R3,
|
|
CODEC_ID_ADPCM_EA_R2,
|
|
CODEC_ID_ADPCM_IMA_EA_SEAD,
|
|
CODEC_ID_ADPCM_IMA_EA_EACS,
|
|
CODEC_ID_ADPCM_EA_XAS,
|
|
CODEC_ID_ADPCM_EA_MAXIS_XA,
|
|
CODEC_ID_ADPCM_IMA_ISS,
|
|
|
|
/* AMR */
|
|
CODEC_ID_AMR_NB = 0x12000,
|
|
CODEC_ID_AMR_WB,
|
|
|
|
/* RealAudio codecs*/
|
|
CODEC_ID_RA_144 = 0x13000,
|
|
CODEC_ID_RA_288,
|
|
|
|
/* various DPCM codecs */
|
|
CODEC_ID_ROQ_DPCM = 0x14000,
|
|
CODEC_ID_INTERPLAY_DPCM,
|
|
CODEC_ID_XAN_DPCM,
|
|
CODEC_ID_SOL_DPCM,
|
|
|
|
/* audio codecs */
|
|
CODEC_ID_MP2 = 0x15000,
|
|
CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
|
|
CODEC_ID_AAC,
|
|
CODEC_ID_AC3,
|
|
CODEC_ID_DTS,
|
|
CODEC_ID_VORBIS,
|
|
CODEC_ID_DVAUDIO,
|
|
CODEC_ID_WMAV1,
|
|
CODEC_ID_WMAV2,
|
|
CODEC_ID_MACE3,
|
|
CODEC_ID_MACE6,
|
|
CODEC_ID_VMDAUDIO,
|
|
CODEC_ID_SONIC,
|
|
CODEC_ID_SONIC_LS,
|
|
CODEC_ID_FLAC,
|
|
CODEC_ID_MP3ADU,
|
|
CODEC_ID_MP3ON4,
|
|
CODEC_ID_SHORTEN,
|
|
CODEC_ID_ALAC,
|
|
CODEC_ID_WESTWOOD_SND1,
|
|
CODEC_ID_GSM, ///< as in Berlin toast format
|
|
CODEC_ID_QDM2,
|
|
CODEC_ID_COOK,
|
|
CODEC_ID_TRUESPEECH,
|
|
CODEC_ID_TTA,
|
|
CODEC_ID_SMACKAUDIO,
|
|
CODEC_ID_QCELP,
|
|
CODEC_ID_WAVPACK,
|
|
CODEC_ID_DSICINAUDIO,
|
|
CODEC_ID_IMC,
|
|
CODEC_ID_MUSEPACK7,
|
|
CODEC_ID_MLP,
|
|
CODEC_ID_GSM_MS, /* as found in WAV */
|
|
CODEC_ID_ATRAC3,
|
|
CODEC_ID_VOXWARE,
|
|
CODEC_ID_APE,
|
|
CODEC_ID_NELLYMOSER,
|
|
CODEC_ID_MUSEPACK8,
|
|
CODEC_ID_SPEEX,
|
|
CODEC_ID_WMAVOICE,
|
|
CODEC_ID_WMAPRO,
|
|
CODEC_ID_WMALOSSLESS,
|
|
CODEC_ID_ATRAC3P,
|
|
CODEC_ID_EAC3,
|
|
CODEC_ID_SIPR,
|
|
CODEC_ID_MP1,
|
|
CODEC_ID_TWINVQ,
|
|
CODEC_ID_TRUEHD,
|
|
CODEC_ID_MP4ALS,
|
|
CODEC_ID_ATRAC1,
|
|
|
|
/* subtitle codecs */
|
|
CODEC_ID_DVD_SUBTITLE = 0x17000,
|
|
CODEC_ID_DVB_SUBTITLE,
|
|
CODEC_ID_TEXT, ///< raw UTF-8 text
|
|
CODEC_ID_XSUB,
|
|
CODEC_ID_SSA,
|
|
CODEC_ID_MOV_TEXT,
|
|
CODEC_ID_HDMV_PGS_SUBTITLE,
|
|
CODEC_ID_DVB_TELETEXT,
|
|
|
|
/* other specific kind of codecs (generally used for attachments) */
|
|
CODEC_ID_TTF = 0x18000,
|
|
|
|
CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
|
|
|
|
CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
|
|
* stream (only used by libavformat) */
|
|
};
|
|
|
|
enum SampleFormat {
|
|
SAMPLE_FMT_NONE = -1,
|
|
SAMPLE_FMT_U8, ///< unsigned 8 bits
|
|
SAMPLE_FMT_S16, ///< signed 16 bits
|
|
SAMPLE_FMT_S32, ///< signed 32 bits
|
|
SAMPLE_FMT_FLT, ///< float
|
|
SAMPLE_FMT_DBL, ///< double
|
|
SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec
|
|
};
|
|
|
|
enum CodecType {
|
|
CODEC_TYPE_UNKNOWN = -1,
|
|
CODEC_TYPE_VIDEO,
|
|
CODEC_TYPE_AUDIO,
|
|
CODEC_TYPE_DATA,
|
|
CODEC_TYPE_SUBTITLE,
|
|
CODEC_TYPE_ATTACHMENT,
|
|
CODEC_TYPE_NB
|
|
};
|
|
|
|
/* Audio channel masks */
|
|
#define CH_FRONT_LEFT 0x00000001
|
|
#define CH_FRONT_RIGHT 0x00000002
|
|
#define CH_FRONT_CENTER 0x00000004
|
|
#define CH_LOW_FREQUENCY 0x00000008
|
|
#define CH_BACK_LEFT 0x00000010
|
|
#define CH_BACK_RIGHT 0x00000020
|
|
#define CH_FRONT_LEFT_OF_CENTER 0x00000040
|
|
#define CH_FRONT_RIGHT_OF_CENTER 0x00000080
|
|
#define CH_BACK_CENTER 0x00000100
|
|
#define CH_SIDE_LEFT 0x00000200
|
|
#define CH_SIDE_RIGHT 0x00000400
|
|
#define CH_TOP_CENTER 0x00000800
|
|
#define CH_TOP_FRONT_LEFT 0x00001000
|
|
#define CH_TOP_FRONT_CENTER 0x00002000
|
|
#define CH_TOP_FRONT_RIGHT 0x00004000
|
|
#define CH_TOP_BACK_LEFT 0x00008000
|
|
#define CH_TOP_BACK_CENTER 0x00010000
|
|
#define CH_TOP_BACK_RIGHT 0x00020000
|
|
#define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
|
|
#define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT.
|
|
|
|
/* Audio channel convenience macros */
|
|
#define CH_LAYOUT_MONO (CH_FRONT_CENTER)
|
|
#define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT)
|
|
#define CH_LAYOUT_2_1 (CH_LAYOUT_STEREO|CH_BACK_CENTER)
|
|
#define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER)
|
|
#define CH_LAYOUT_4POINT0 (CH_LAYOUT_SURROUND|CH_BACK_CENTER)
|
|
#define CH_LAYOUT_2_2 (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT)
|
|
#define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT)
|
|
#define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT)
|
|
#define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY)
|
|
#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
|
|
#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
|
|
#define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT)
|
|
#define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT)
|
|
#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
|
|
CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
|
|
#define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT)
|
|
|
|
/* in bytes */
|
|
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
|
|
|
|
typedef struct AVCodecContext {
|
|
/**
|
|
* information on struct for av_log
|
|
* - set by avcodec_alloc_context
|
|
*/
|
|
const void *av_class;
|
|
/**
|
|
* the average bitrate
|
|
* - encoding: Set by user; unused for constant quantizer encoding.
|
|
* - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
|
|
*/
|
|
int bit_rate;
|
|
|
|
/**
|
|
* number of bits the bitstream is allowed to diverge from the reference.
|
|
* the reference can be CBR (for CBR pass1) or VBR (for pass2)
|
|
* - encoding: Set by user; unused for constant quantizer encoding.
|
|
* - decoding: unused
|
|
*/
|
|
int bit_rate_tolerance;
|
|
|
|
/**
|
|
* CODEC_FLAG_*.
|
|
* - encoding: Set by user.
|
|
* - decoding: Set by user.
|
|
*/
|
|
int flags;
|
|
|
|
/**
|
|
* Some codecs need additional format info. It is stored here.
|
|
* If any muxer uses this then ALL demuxers/parsers AND encoders for the
|
|
* specific codec MUST set it correctly otherwise stream copy breaks.
|
|
* In general use of this field by muxers is not recommanded.
|
|
* - encoding: Set by libavcodec.
|
|
* - decoding: Set by libavcodec. (FIXME: Is this OK?)
|
|
*/
|
|
int sub_id;
|
|
|
|
/**
|
|
* Motion estimation algorithm used for video coding.
|
|
* 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
|
|
* 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
|
|
* - encoding: MUST be set by user.
|
|
* - decoding: unused
|
|
*/
|
|
int me_method;
|
|
|
|
/**
|
|
* some codecs need / can use extradata like Huffman tables.
|
|
* mjpeg: Huffman tables
|
|
* rv10: additional flags
|
|
* mpeg4: global headers (they can be in the bitstream or here)
|
|
* The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
|
|
* than extradata_size to avoid prolems if it is read with the bitstream reader.
|
|
* The bytewise contents of extradata must not depend on the architecture or CPU endianness.
|
|
* - encoding: Set/allocated/freed by libavcodec.
|
|
* - decoding: Set/allocated/freed by user.
|
|
*/
|
|
uint8_t *extradata;
|
|
int extradata_size;
|
|
|
|
/* audio only */
|
|
int sample_rate; ///< samples per second
|
|
int channels; ///< number of audio channels
|
|
|
|
/**
|
|
* audio sample format
|
|
* - encoding: Set by user.
|
|
* - decoding: Set by libavcodec.
|
|
*/
|
|
enum SampleFormat sample_fmt; ///< sample format
|
|
|
|
/* The following data should not be initialized. */
|
|
/**
|
|
* Samples per packet, initialized when calling 'init'.
|
|
*/
|
|
int frame_size;
|
|
int frame_number; ///< audio or video frame number
|
|
|
|
char codec_name[32];
|
|
enum CodecType codec_type; /* see CODEC_TYPE_xxx */
|
|
enum CodecID codec_id; /* see CODEC_ID_xxx */
|
|
|
|
/**
|
|
* Bits per sample/pixel of internal libavcodec pixel/sample format.
|
|
* This field is applicable only when sample_fmt is SAMPLE_FMT_S32.
|
|
* - encoding: set by user.
|
|
* - decoding: set by libavcodec.
|
|
*/
|
|
int bits_per_raw_sample;
|
|
|
|
int block_align;
|
|
|
|
/**
|
|
* Audio channel layout.
|
|
* - encoding: set by user.
|
|
* - decoding: set by libavcodec.
|
|
*/
|
|
int64_t channel_layout;
|
|
} AVCodecContext;
|
|
|
|
#endif /* AVCODEC_AVCODEC_H */
|