/*****************************************************************************
* avcodec.h: decoder and encoder using libavcodec
*****************************************************************************
- * Copyright (C) 2001-2008 the VideoLAN team
+ * Copyright (C) 2001-2008 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
- * 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
+ * This program 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.
*
* 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.
+ * 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 General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "chroma.h"
+#include "avcommon.h"
+
/* VLC <-> avcodec tables */
int GetFfmpegCodec( vlc_fourcc_t i_fourcc, int *pi_cat,
- int *pi_ffmpeg_codec, const char **ppsz_name );
-int GetVlcFourcc( int i_ffmpeg_codec, int *pi_cat,
+ unsigned *pi_ffmpeg_codec, const char **ppsz_name );
+int GetVlcFourcc( unsigned i_ffmpeg_codec, int *pi_cat,
vlc_fourcc_t *pi_fourcc, const char **ppsz_name );
-void GetVlcAudioFormat( vlc_fourcc_t *, unsigned *pi_bits, int i_sample_fmt );
-
-picture_t * DecodeVideo( decoder_t *, block_t ** );
-block_t * DecodeAudio( decoder_t *, block_t ** );
-subpicture_t *DecodeSubtitle( decoder_t *p_dec, block_t ** );
+vlc_fourcc_t GetVlcAudioFormat( int i_sample_fmt );
/* Video encoder module */
int OpenEncoder ( vlc_object_t * );
void CloseDeinterlace( vlc_object_t * );
/* Video Decoder */
-int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
- AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
+int InitVideoDec( decoder_t *, AVCodecContext *, const AVCodec * );
void EndVideoDec( decoder_t *p_dec );
/* Audio Decoder */
-int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
- AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
-void EndAudioDec( decoder_t *p_dec );
+int InitAudioDec( decoder_t *, AVCodecContext *, const AVCodec * );
/* Subtitle Decoder */
-int InitSubtitleDec( decoder_t *p_dec, AVCodecContext *p_context,
- AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
-void EndSubtitleDec( decoder_t *p_dec );
+int InitSubtitleDec( decoder_t *, AVCodecContext *, const AVCodec * );
/* Initialize decoder */
int ffmpeg_OpenCodec( decoder_t *p_dec );
+void ffmpeg_CloseCodec( decoder_t *p_dec );
/*****************************************************************************
* Module descriptor help strings
*****************************************************************************/
#define DR_TEXT N_("Direct rendering")
/* FIXME Does somebody who knows what it does, explain */
-#define DR_LONGTEXT N_("Direct rendering")
#define ERROR_TEXT N_("Error resilience")
#define ERROR_LONGTEXT N_( \
#define CODEC_TEXT N_( "Codec name" )
#define CODEC_LONGTEXT N_( "Internal libavcodec codec name" )
-/* TODO: Use a predefined list, with 0,1,2,4,7 */
-#define VISMV_TEXT N_( "Visualize motion vectors" )
-#define VISMV_LONGTEXT N_( \
- "You can overlay the motion vectors (arrows showing how the images move) "\
- "on the image. This value is a mask, based on these values:\n"\
- "1 - visualize forward predicted MVs of P frames\n" \
- "2 - visualize forward predicted MVs of B frames\n" \
- "4 - visualize backward predicted MVs of B frames\n" \
- "To visualize all vectors, the value should be 7." )
-
-#define LOWRES_TEXT N_( "Low resolution decoding" )
-#define LOWRES_LONGTEXT N_( "Only decode a low resolution version of " \
- "the video. This requires less processing power" )
-
#define SKIPLOOPF_TEXT N_( "Skip the loop filter for H.264 decoding" )
#define SKIPLOOPF_LONGTEXT N_( "Skipping the loop filter (aka deblocking) " \
"usually has a detrimental effect on quality. However it provides a big " \
"hev1 and hev2 are currently supported only with libfdk-aac enabled libavcodec" )
#define AVCODEC_COMMON_MEMBERS \
- int i_cat; \
- int i_codec_id; \
- const char *psz_namecodec; \
AVCodecContext *p_context; \
- AVCodec *p_codec; \
+ const AVCodec *p_codec; \
bool b_delayed_open;
#ifndef AV_VERSION_INT
# define HAVE_AVCODEC_MT
#endif
-
-/* LIBAVCODEC_VERSION_CHECK checks for the right version of libav and FFmpeg
- * a is the major version
- * b and c the minor and micro versions of libav
- * d and e the minor and micro versions of FFmpeg */
-#define LIBAVCODEC_VERSION_CHECK( a, b, c, d, e ) \
- (LIBAVCODEC_VERSION_MICRO < 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, b, c ) ) || \
- (LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, d, e ) )
-
-
-/* Ugly ifdefinitions to provide backwards compatibility with older ffmpeg/libav
- * versions */
-#ifndef AV_CPU_FLAG_FORCE
-# define AV_CPU_FLAG_FORCE FF_MM_FORCE
-# define AV_CPU_FLAG_MMX FF_MM_MMX
-# define AV_CPU_FLAG_3DNOW FF_MM_3DNOW
-# define AV_CPU_FLAG_MMX2 FF_MM_MMX2
-# define AV_CPU_FLAG_SSE FF_MM_SSE
-# define AV_CPU_FLAG_SSE2 FF_MM_SSE2
-# define AV_CPU_FLAG_SSE2SLOW FF_MM_SSE2SLOW
-# define AV_CPU_FLAG_3DNOWEXT FF_MM_3DNOWEXT
-# define AV_CPU_FLAG_SSE3 FF_MM_SSE3
-# define AV_CPU_FLAG_SSE3SLOW FF_MM_SSE3SLOW
-# define AV_CPU_FLAG_SSSE3 FF_MM_SSSE3
-# define AV_CPU_FLAG_SSE4 FF_MM_SSE4
-# define AV_CPU_FLAG_SSE42 FF_MM_SSE42
-# define AV_CPU_FLAG_IWMMXT FF_MM_IWMMXT
-# define AV_CPU_FLAG_ALTIVEC FF_MM_ALTIVEC
-#endif
-
-#if LIBAVUTIL_VERSION_MAJOR < 52 && !defined(AV_CPU_FLAG_MMXEXT)
-# define AV_CPU_FLAG_MMXEXT AV_CPU_FLAG_MMX2
-#endif
-
-#if LIBAVCODEC_VERSION_MAJOR < 54
-# define AV_PICTURE_TYPE_B FF_B_TYPE
-# define AV_PICTURE_TYPE_I FF_I_TYPE
-# define AV_PICTURE_TYPE_P FF_P_TYPE
-
-# define AV_SAMPLE_FMT_NONE SAMPLE_FMT_NONE
-# define AV_SAMPLE_FMT_U8 SAMPLE_FMT_U8
-# define AV_SAMPLE_FMT_S16 SAMPLE_FMT_S16
-# define AV_SAMPLE_FMT_S32 SAMPLE_FMT_S32
-# define AV_SAMPLE_FMT_FLT SAMPLE_FMT_FLT
-# define AV_SAMPLE_FMT_DBL SAMPLE_FMT_DBL
-
-#ifndef AV_CH_FRONT_LEFT
-# define AV_CH_FRONT_LEFT CH_FRONT_LEFT
-#endif
-#ifndef AV_CH_FRONT_RIGHT
-# define AV_CH_FRONT_RIGHT CH_FRONT_RIGHT
-#endif
-#ifndef AV_CH_FRONT_CENTER
-# define AV_CH_FRONT_CENTER CH_FRONT_CENTER
-#endif
-#ifndef AV_CH_LOW_FREQUENCY
-# define AV_CH_LOW_FREQUENCY CH_LOW_FREQUENCY
-#endif
-#ifndef AV_CH_BACK_LEFT
-# define AV_CH_BACK_LEFT CH_BACK_LEFT
-#endif
-#ifndef AV_CH_BACK_RIGHT
-# define AV_CH_BACK_RIGHT CH_BACK_RIGHT
-#endif
-#ifndef AV_CH_FRONT_LEFT_OF_CENTER
-# define AV_CH_FRONT_LEFT_OF_CENTER CH_FRONT_LEFT_OF_CENTER
-#endif
-#ifndef AV_CH_FRONT_RIGHT_OF_CENTER
-# define AV_CH_FRONT_RIGHT_OF_CENTER CH_FRONT_RIGHT_OF_CENTER
-#endif
-#ifndef AV_CH_BACK_CENTER
-# define AV_CH_BACK_CENTER CH_BACK_CENTER
-#endif
-#ifndef AV_CH_SIDE_LEFT
-# define AV_CH_SIDE_LEFT CH_SIDE_LEFT
-#endif
-#ifndef AV_CH_SIDE_RIGHT
-# define AV_CH_SIDE_RIGHT CH_SIDE_RIGHT
-#endif
-#ifndef AV_CH_TOP_CENTER
-# define AV_CH_TOP_CENTER CH_TOP_CENTER
-#endif
-#ifndef AV_CH_TOP_FRONT_LEFT
-# define AV_CH_TOP_FRONT_LEFT CH_TOP_FRONT_LEFT
-#endif
-#ifndef AV_CH_TOP_FRONT_CENTER
-# define AV_CH_TOP_FRONT_CENTER CH_TOP_FRONT_CENTER
-#endif
-#ifndef AV_CH_TOP_FRONT_RIGHT
-# define AV_CH_TOP_FRONT_RIGHT CH_TOP_FRONT_RIGHT
-#endif
-#ifndef AV_CH_TOP_BACK_LEFT
-# define AV_CH_TOP_BACK_LEFT CH_TOP_BACK_LEFT
-#endif
-#ifndef AV_CH_TOP_BACK_CENTER
-# define AV_CH_TOP_BACK_CENTER CH_TOP_BACK_CENTER
-#endif
-#ifndef AV_CH_TOP_BACK_RIGHT
-# define AV_CH_TOP_BACK_RIGHT CH_TOP_BACK_RIGHT
-#endif
-#ifndef AV_CH_STEREO_LEFT
-# define AV_CH_STEREO_LEFT CH_STEREO_LEFT
-#endif
-#ifndef AV_CH_STEREO_RIGHT
-# define AV_CH_STEREO_RIGHT CH_STEREO_RIGHT
-#endif
-
-
-#endif
-
-#ifndef AV_PKT_FLAG_KEY
-# define AV_PKT_FLAG_KEY PKT_FLAG_KEY
-#endif