diff --git modules/codec/avcodec/avcommon.h modules/codec/avcodec/avcommon.h index f967473b472af234a740accdff5ac30a0ea91a81..e8f0a067f88655018214bba192e9fe9c4aefc167 100644 --- modules/codec/avcodec/avcommon.h +++ modules/codec/avcodec/avcommon.h @@ -45,19 +45,18 @@ #define AV_OPTIONS_TEXT "Advanced options" #define AV_OPTIONS_LONGTEXT "Advanced options, in the form {opt=val,opt2=val2}." -static inline AVDictionary *vlc_av_get_options(const char *psz_opts) +static inline void vlc_av_get_options(const char *psz_opts, AVDictionary** pp_dict) { - AVDictionary *options = NULL; config_chain_t *cfg = NULL; config_ChainParseOptions(&cfg, psz_opts); while (cfg) { config_chain_t *next = cfg->p_next; - av_dict_set(&options, cfg->psz_name, cfg->psz_value, - AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); + av_dict_set(pp_dict, cfg->psz_name, cfg->psz_value, 0); + free(cfg->psz_name); + free(cfg->psz_value); free(cfg); cfg = next; } - return options; } static inline void vlc_init_avutil(vlc_object_t *obj) diff --git modules/codec/avcodec/avcommon_compat.h modules/codec/avcodec/avcommon_compat.h index 3c66a1e1b30a2ac742adbe40225cc363590c9b98..d3864448b7f059cfc72fc84262e8e728de8a6c0a 100644 --- modules/codec/avcodec/avcommon_compat.h +++ modules/codec/avcodec/avcommon_compat.h @@ -2,7 +2,7 @@ * avcodec.h: decoder and encoder using libavcodec ***************************************************************************** * Copyright (C) 2001-2013 VLC authors and VideoLAN - * $Id: 3fc14dc163885eb5ac80d955e3159a506f0dcfed $ + * $Id: 8f9c12081cf8524424d4611822a69a3a16cf1f05 $ * * Authors: Laurent Aimar * Jean-Baptiste Kempf @@ -25,6 +25,8 @@ #ifndef AVCOMMON_COMPAT_H #define AVCOMMON_COMPAT_H 1 +#define AVPROVIDER(lib) ((lib##_VERSION_MICRO < 100) ? "libav" : "ffmpeg") + #ifdef HAVE_LIBAVCODEC_AVCODEC_H #include @@ -36,447 +38,44 @@ ( (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 ) ) ) -#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 +#ifndef AV_CODEC_FLAG_OUTPUT_CORRUPT +# define AV_CODEC_FLAG_OUTPUT_CORRUPT CODEC_FLAG_OUTPUT_CORRUPT #endif -#ifndef AV_CH_BACK_CENTER -# define AV_CH_BACK_CENTER CH_BACK_CENTER +#ifndef AV_CODEC_FLAG_GRAY +# define AV_CODEC_FLAG_GRAY CODEC_FLAG_GRAY #endif -#ifndef AV_CH_SIDE_LEFT -# define AV_CH_SIDE_LEFT CH_SIDE_LEFT +#ifndef AV_CODEC_FLAG_DR1 +# define AV_CODEC_FLAG_DR1 CODEC_FLAG_DR1 #endif -#ifndef AV_CH_SIDE_RIGHT -# define AV_CH_SIDE_RIGHT CH_SIDE_RIGHT +#ifndef AV_CODEC_FLAG_DELAY +# define AV_CODEC_FLAG_DELAY CODEC_FLAG_DELAY #endif -#ifndef AV_CH_TOP_CENTER -# define AV_CH_TOP_CENTER CH_TOP_CENTER +#ifndef AV_CODEC_FLAG2_FAST +# define AV_CODEC_FLAG2_FAST CODEC_FLAG2_FAST #endif -#ifndef AV_CH_TOP_FRONT_LEFT -# define AV_CH_TOP_FRONT_LEFT CH_TOP_FRONT_LEFT +#ifndef FF_INPUT_BUFFER_PADDING_SIZE +# define FF_INPUT_BUFFER_PADDING_SIZE AV_INPUT_BUFFER_PADDING_SIZE #endif -#ifndef AV_CH_TOP_FRONT_CENTER -# define AV_CH_TOP_FRONT_CENTER CH_TOP_FRONT_CENTER +#ifndef AV_CODEC_FLAG_INTERLACED_DCT +# define AV_CODEC_FLAG_INTERLACED_DCT CODEC_FLAG_INTERLACED_DCT #endif -#ifndef AV_CH_TOP_FRONT_RIGHT -# define AV_CH_TOP_FRONT_RIGHT CH_TOP_FRONT_RIGHT +#ifndef AV_CODEC_FLAG_INTERLACED_ME +# define AV_CODEC_FLAG_INTERLACED_ME CODEC_FLAG_INTERLACED_ME #endif -#ifndef AV_CH_TOP_BACK_LEFT -# define AV_CH_TOP_BACK_LEFT CH_TOP_BACK_LEFT +#ifndef AV_CODEC_FLAG_GLOBAL_HEADER +# define AV_CODEC_FLAG_GLOBAL_HEADER CODEC_FLAG_GLOBAL_HEADER #endif -#ifndef AV_CH_TOP_BACK_CENTER -# define AV_CH_TOP_BACK_CENTER CH_TOP_BACK_CENTER +#ifndef AV_CODEC_FLAG_LOW_DELAY +# define AV_CODEC_FLAG_LOW_DELAY CODEC_FLAG_LOW_DELAY #endif -#ifndef AV_CH_TOP_BACK_RIGHT -# define AV_CH_TOP_BACK_RIGHT CH_TOP_BACK_RIGHT +#ifndef AV_CODEC_CAP_SMALL_LAST_FRAME +# define AV_CODEC_CAP_SMALL_LAST_FRAME CODEC_CAP_SMALL_LAST_FRAME #endif -#ifndef AV_CH_STEREO_LEFT -# define AV_CH_STEREO_LEFT CH_STEREO_LEFT +#ifndef AV_INPUT_BUFFER_MIN_SIZE +# define AV_INPUT_BUFFER_MIN_SIZE FF_MIN_BUFFER_SIZE #endif -#ifndef AV_CH_STEREO_RIGHT -# define AV_CH_STEREO_RIGHT CH_STEREO_RIGHT -#endif - -#endif /* LIBAVCODEC_VERSION_MAJOR < 54 */ - -#if !LIBAVCODEC_VERSION_CHECK(54, 25, 0, 51, 100) -#define AVCodecID CodecID - -enum { - AV_CODEC_ID_NONE, - - /* video codecs */ - AV_CODEC_ID_MPEG1VIDEO, - AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding - AV_CODEC_ID_MPEG2VIDEO_XVMC, - AV_CODEC_ID_H261, - AV_CODEC_ID_H263, - AV_CODEC_ID_RV10, - AV_CODEC_ID_RV20, - AV_CODEC_ID_MJPEG, - AV_CODEC_ID_MJPEGB, - AV_CODEC_ID_LJPEG, - AV_CODEC_ID_SP5X, - AV_CODEC_ID_JPEGLS, - AV_CODEC_ID_MPEG4, - AV_CODEC_ID_RAWVIDEO, - AV_CODEC_ID_MSMPEG4V1, - AV_CODEC_ID_MSMPEG4V2, - AV_CODEC_ID_MSMPEG4V3, - AV_CODEC_ID_WMV1, - AV_CODEC_ID_WMV2, - AV_CODEC_ID_H263P, - AV_CODEC_ID_H263I, - AV_CODEC_ID_FLV1, - AV_CODEC_ID_SVQ1, - AV_CODEC_ID_SVQ3, - AV_CODEC_ID_DVVIDEO, - AV_CODEC_ID_HUFFYUV, - AV_CODEC_ID_CYUV, - AV_CODEC_ID_H264, - AV_CODEC_ID_INDEO3, - AV_CODEC_ID_VP3, - AV_CODEC_ID_THEORA, - AV_CODEC_ID_ASV1, - AV_CODEC_ID_ASV2, - AV_CODEC_ID_FFV1, - AV_CODEC_ID_4XM, - AV_CODEC_ID_VCR1, - AV_CODEC_ID_CLJR, - AV_CODEC_ID_MDEC, - AV_CODEC_ID_ROQ, - AV_CODEC_ID_INTERPLAY_VIDEO, - AV_CODEC_ID_XAN_WC3, - AV_CODEC_ID_XAN_WC4, - AV_CODEC_ID_RPZA, - AV_CODEC_ID_CINEPAK, - AV_CODEC_ID_WS_VQA, - AV_CODEC_ID_MSRLE, - AV_CODEC_ID_MSVIDEO1, - AV_CODEC_ID_IDCIN, - AV_CODEC_ID_8BPS, - AV_CODEC_ID_SMC, - AV_CODEC_ID_FLIC, - AV_CODEC_ID_TRUEMOTION1, - AV_CODEC_ID_VMDVIDEO, - AV_CODEC_ID_MSZH, - AV_CODEC_ID_ZLIB, - AV_CODEC_ID_QTRLE, - AV_CODEC_ID_SNOW, - AV_CODEC_ID_TSCC, - AV_CODEC_ID_ULTI, - AV_CODEC_ID_QDRAW, - AV_CODEC_ID_VIXL, - AV_CODEC_ID_QPEG, - AV_CODEC_ID_PNG, - AV_CODEC_ID_PPM, - AV_CODEC_ID_PBM, - AV_CODEC_ID_PGM, - AV_CODEC_ID_PGMYUV, - AV_CODEC_ID_PAM, - AV_CODEC_ID_FFVHUFF, - AV_CODEC_ID_RV30, - AV_CODEC_ID_RV40, - AV_CODEC_ID_VC1, - AV_CODEC_ID_WMV3, - AV_CODEC_ID_LOCO, - AV_CODEC_ID_WNV1, - AV_CODEC_ID_AASC, - AV_CODEC_ID_INDEO2, - AV_CODEC_ID_FRAPS, - AV_CODEC_ID_TRUEMOTION2, - AV_CODEC_ID_BMP, - AV_CODEC_ID_CSCD, - AV_CODEC_ID_MMVIDEO, - AV_CODEC_ID_ZMBV, - AV_CODEC_ID_AVS, - AV_CODEC_ID_SMACKVIDEO, - AV_CODEC_ID_NUV, - AV_CODEC_ID_KMVC, - AV_CODEC_ID_FLASHSV, - AV_CODEC_ID_CAVS, - AV_CODEC_ID_JPEG2000, - AV_CODEC_ID_VMNC, - AV_CODEC_ID_VP5, - AV_CODEC_ID_VP6, - AV_CODEC_ID_VP6F, - AV_CODEC_ID_TARGA, - AV_CODEC_ID_DSICINVIDEO, - AV_CODEC_ID_TIERTEXSEQVIDEO, - AV_CODEC_ID_TIFF, - AV_CODEC_ID_GIF, -#if LIBAVCODEC_VERSION_MAJOR == 53 - AV_CODEC_ID_FFH264, -#endif - AV_CODEC_ID_DXA, - AV_CODEC_ID_DNXHD, - AV_CODEC_ID_THP, - AV_CODEC_ID_SGI, - AV_CODEC_ID_C93, - AV_CODEC_ID_BETHSOFTVID, - AV_CODEC_ID_PTX, - AV_CODEC_ID_TXD, - AV_CODEC_ID_VP6A, - AV_CODEC_ID_AMV, - AV_CODEC_ID_VB, - AV_CODEC_ID_PCX, - AV_CODEC_ID_SUNRAST, - AV_CODEC_ID_INDEO4, - AV_CODEC_ID_INDEO5, - AV_CODEC_ID_MIMIC, - AV_CODEC_ID_RL2, -#if LIBAVCODEC_VERSION_MAJOR == 53 - AV_CODEC_ID_8SVX_EXP, - AV_CODEC_ID_8SVX_FIB, -#endif - AV_CODEC_ID_ESCAPE124, - AV_CODEC_ID_DIRAC, - AV_CODEC_ID_BFI, - AV_CODEC_ID_CMV, - AV_CODEC_ID_MOTIONPIXELS, - AV_CODEC_ID_TGV, - AV_CODEC_ID_TGQ, - AV_CODEC_ID_TQI, - AV_CODEC_ID_AURA, - AV_CODEC_ID_AURA2, - AV_CODEC_ID_V210X, - AV_CODEC_ID_TMV, - AV_CODEC_ID_V210, - AV_CODEC_ID_DPX, - AV_CODEC_ID_MAD, - AV_CODEC_ID_FRWU, - AV_CODEC_ID_FLASHSV2, - AV_CODEC_ID_CDGRAPHICS, - AV_CODEC_ID_R210, - AV_CODEC_ID_ANM, - AV_CODEC_ID_BINKVIDEO, - AV_CODEC_ID_IFF_ILBM, - AV_CODEC_ID_IFF_BYTERUN1, - AV_CODEC_ID_KGV1, - AV_CODEC_ID_YOP, - AV_CODEC_ID_VP8, - AV_CODEC_ID_PICTOR, - AV_CODEC_ID_ANSI, - AV_CODEC_ID_A64_MULTI, - AV_CODEC_ID_A64_MULTI5, - AV_CODEC_ID_R10K, - AV_CODEC_ID_MXPEG, - AV_CODEC_ID_LAGARITH, - AV_CODEC_ID_PRORES, - AV_CODEC_ID_JV, - AV_CODEC_ID_DFA, - AV_CODEC_ID_WMV3IMAGE, - AV_CODEC_ID_VC1IMAGE, -#if LIBAVCODEC_VERSION_MAJOR == 53 - AV_CODEC_ID_G723_1, - AV_CODEC_ID_G729, -#endif - AV_CODEC_ID_UTVIDEO, - AV_CODEC_ID_BMV_VIDEO, - AV_CODEC_ID_VBLE, - AV_CODEC_ID_DXTORY, - AV_CODEC_ID_V410, - AV_CODEC_ID_XWD, - AV_CODEC_ID_CDXL, - AV_CODEC_ID_XBM, - AV_CODEC_ID_ZEROCODEC, - AV_CODEC_ID_MSS1, - AV_CODEC_ID_MSA1, - AV_CODEC_ID_TSCC2, - AV_CODEC_ID_MTS2, - AV_CODEC_ID_CLLC, - - /* various PAV_CM "codecs" */ - AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs - AV_CODEC_ID_PCM_S16LE = 0x10000, - AV_CODEC_ID_PCM_S16BE, - AV_CODEC_ID_PCM_U16LE, - AV_CODEC_ID_PCM_U16BE, - AV_CODEC_ID_PCM_S8, - AV_CODEC_ID_PCM_U8, - AV_CODEC_ID_PCM_MULAW, - AV_CODEC_ID_PCM_ALAW, - AV_CODEC_ID_PCM_S32LE, - AV_CODEC_ID_PCM_S32BE, - AV_CODEC_ID_PCM_U32LE, - AV_CODEC_ID_PCM_U32BE, - AV_CODEC_ID_PCM_S24LE, - AV_CODEC_ID_PCM_S24BE, - AV_CODEC_ID_PCM_U24LE, - AV_CODEC_ID_PCM_U24BE, - AV_CODEC_ID_PCM_S24DAUD, - AV_CODEC_ID_PCM_ZORK, - AV_CODEC_ID_PCM_S16LE_PLANAR, - AV_CODEC_ID_PCM_DVD, - AV_CODEC_ID_PCM_F32BE, - AV_CODEC_ID_PCM_F32LE, - AV_CODEC_ID_PCM_F64BE, - AV_CODEC_ID_PCM_F64LE, - AV_CODEC_ID_PCM_BLURAY, - AV_CODEC_ID_PCM_LXF, - AV_CODEC_ID_S302M, - AV_CODEC_ID_PCM_S8_PLANAR, - - /* various ADPAV_CM codecs */ - AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, - AV_CODEC_ID_ADPCM_IMA_WAV, - AV_CODEC_ID_ADPCM_IMA_DK3, - AV_CODEC_ID_ADPCM_IMA_DK4, - AV_CODEC_ID_ADPCM_IMA_WS, - AV_CODEC_ID_ADPCM_IMA_SMJPEG, - AV_CODEC_ID_ADPCM_MS, - AV_CODEC_ID_ADPCM_4XM, - AV_CODEC_ID_ADPCM_XA, - AV_CODEC_ID_ADPCM_ADX, - AV_CODEC_ID_ADPCM_EA, - AV_CODEC_ID_ADPCM_G726, - AV_CODEC_ID_ADPCM_CT, - AV_CODEC_ID_ADPCM_SWF, - AV_CODEC_ID_ADPCM_YAMAHA, - AV_CODEC_ID_ADPCM_SBPRO_4, - AV_CODEC_ID_ADPCM_SBPRO_3, - AV_CODEC_ID_ADPCM_SBPRO_2, - AV_CODEC_ID_ADPCM_THP, - AV_CODEC_ID_ADPCM_IMA_AMV, - AV_CODEC_ID_ADPCM_EA_R1, - AV_CODEC_ID_ADPCM_EA_R3, - AV_CODEC_ID_ADPCM_EA_R2, - AV_CODEC_ID_ADPCM_IMA_EA_SEAD, - AV_CODEC_ID_ADPCM_IMA_EA_EACS, - AV_CODEC_ID_ADPCM_EA_XAS, - AV_CODEC_ID_ADPCM_EA_MAXIS_XA, - AV_CODEC_ID_ADPCM_IMA_ISS, - AV_CODEC_ID_ADPCM_G722, - AV_CODEC_ID_ADPCM_IMA_APC, - - /* AMR */ - AV_CODEC_ID_AMR_NB = 0x12000, - AV_CODEC_ID_AMR_WB, - - /* RealAudio codecs*/ - AV_CODEC_ID_RA_144 = 0x13000, - AV_CODEC_ID_RA_288, - - /* various DPAV_CM codecs */ - AV_CODEC_ID_ROQ_DPCM = 0x14000, - AV_CODEC_ID_INTERPLAY_DPCM, - AV_CODEC_ID_XAN_DPCM, - AV_CODEC_ID_SOL_DPCM, - - /* audio codecs */ - AV_CODEC_ID_MP2 = 0x15000, - AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 - AV_CODEC_ID_AAC, - AV_CODEC_ID_AC3, - AV_CODEC_ID_DTS, - AV_CODEC_ID_VORBIS, - AV_CODEC_ID_DVAUDIO, - AV_CODEC_ID_WMAV1, - AV_CODEC_ID_WMAV2, - AV_CODEC_ID_MACE3, - AV_CODEC_ID_MACE6, - AV_CODEC_ID_VMDAUDIO, -#if LIBAVCODEC_VERSION_MAJOR == 53 - AV_CODEC_ID_SONIC, - AV_CODEC_ID_SONIC_LS, -#endif - AV_CODEC_ID_FLAC, - AV_CODEC_ID_MP3ADU, - AV_CODEC_ID_MP3ON4, - AV_CODEC_ID_SHORTEN, - AV_CODEC_ID_ALAC, - AV_CODEC_ID_WESTWOOD_SND1, - AV_CODEC_ID_GSM, ///< as in Berlin toast format - AV_CODEC_ID_QDM2, - AV_CODEC_ID_COOK, - AV_CODEC_ID_TRUESPEECH, - AV_CODEC_ID_TTA, - AV_CODEC_ID_SMACKAUDIO, - AV_CODEC_ID_QCELP, - AV_CODEC_ID_WAVPACK, - AV_CODEC_ID_DSICINAUDIO, - AV_CODEC_ID_IMC, - AV_CODEC_ID_MUSEPACK7, - AV_CODEC_ID_MLP, - AV_CODEC_ID_GSM_MS, /* as found in WAV */ - AV_CODEC_ID_ATRAC3, -#if LIBAVCODEC_VERSION_MAJOR < 56 - AV_CODEC_ID_VOXWARE, -#endif - AV_CODEC_ID_APE, - AV_CODEC_ID_NELLYMOSER, - AV_CODEC_ID_MUSEPACK8, - AV_CODEC_ID_SPEEX, - AV_CODEC_ID_WMAVOICE, - AV_CODEC_ID_WMAPRO, - AV_CODEC_ID_WMALOSSLESS, - AV_CODEC_ID_ATRAC3P, - AV_CODEC_ID_EAC3, - AV_CODEC_ID_SIPR, - AV_CODEC_ID_MP1, - AV_CODEC_ID_TWINVQ, - AV_CODEC_ID_TRUEHD, - AV_CODEC_ID_MP4ALS, - AV_CODEC_ID_ATRAC1, - AV_CODEC_ID_BINKAUDIO_RDFT, - AV_CODEC_ID_BINKAUDIO_DCT, - AV_CODEC_ID_AAC_LATM, - AV_CODEC_ID_QDMC, - AV_CODEC_ID_CELT, -#if LIBAVCODEC_VERSION_MAJOR > 53 - AV_CODEC_ID_G723_1, - AV_CODEC_ID_G729, - AV_CODEC_ID_8SVX_EXP, - AV_CODEC_ID_8SVX_FIB, -#endif - AV_CODEC_ID_BMV_AUDIO, - AV_CODEC_ID_RALF, - AV_CODEC_ID_IAC, - AV_CODEC_ID_ILBC, - - /* subtitle codecs */ - AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. - AV_CODEC_ID_DVD_SUBTITLE = 0x17000, - AV_CODEC_ID_DVB_SUBTITLE, - AV_CODEC_ID_TEXT, ///< raw UTF-8 text - AV_CODEC_ID_XSUB, - AV_CODEC_ID_SSA, - AV_CODEC_ID_MOV_TEXT, - AV_CODEC_ID_HDMV_PGS_SUBTITLE, - AV_CODEC_ID_DVB_TELETEXT, - AV_CODEC_ID_SRT, - - /* other specific kind of codecs (generally used for attachments) */ - AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. - AV_CODEC_ID_TTF = 0x18000, - - AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it - - AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS - * stream (only used by libavformat) */ - AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems - * stream (only used by libavformat) */ - AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. -}; - -#endif /* LIBAVCODEC_VERSION < 54.25 */ - -#if LIBAVCODEC_VERSION_MAJOR < 54 -# define avcodec_alloc_context3(a) avcodec_alloc_context() -# define avcodec_open2(a, b, c) avcodec_open(a, b) -# define err_recognition error_recognition +#ifndef FF_MAX_B_FRAMES +# define FF_MAX_B_FRAMES 16 // FIXME: remove this #endif #endif /* HAVE_LIBAVCODEC_AVCODEC_H */ @@ -492,18 +91,10 @@ enum { ( (LIBAVUTIL_VERSION_MICRO < 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( a, b, c ) ) || \ (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( a, d, e ) ) ) -#if LIBAVUTIL_VERSION_MAJOR < 52 && !defined(AV_CPU_FLAG_MMXEXT) -# define AV_CPU_FLAG_MMXEXT AV_CPU_FLAG_MMX2 -#endif - #if !LIBAVUTIL_VERSION_CHECK( 52, 11, 0, 32, 100 ) # define AV_PIX_FMT_FLAG_HWACCEL PIX_FMT_HWACCEL #endif -#if !LIBAVUTIL_VERSION_CHECK( 51, 44, 0, 76, 100 ) -# define av_pix_fmt_desc_get(a) &av_pix_fmt_descriptors[a] -#endif - #endif /* HAVE_LIBAVUTIL_AVUTIL_H */ #if LIBAVUTIL_VERSION_MAJOR >= 55 diff --git modules/codec/avcodec/encoder.c modules/codec/avcodec/encoder.c index 9020576e0c0b3533c9d9760c3474941c43a6bd0c..d7d45e7183f1bf393df77cda972ee1fba6a59566 100644 --- modules/codec/avcodec/encoder.c +++ modules/codec/avcodec/encoder.c @@ -284,6 +284,24 @@ static void probe_video_frame_rate( encoder_t *p_enc, AVCodecContext *p_context, msg_Dbg( p_enc, "Time base set to %d/%d", p_context->time_base.num, p_context->time_base.den ); } +static void add_av_option_int( encoder_t *p_enc, AVDictionary** pp_dict, const char* psz_name, int i_value ) +{ + char buff[32]; + if ( snprintf( buff, sizeof(buff), "%d", i_value ) < 0 ) + return; + if( av_dict_set( pp_dict, psz_name, buff, 0 ) < 0 ) + msg_Warn( p_enc, "Failed to set encoder option %s", psz_name ); +} + +static void add_av_option_float( encoder_t *p_enc, AVDictionary** pp_dict, const char* psz_name, float f_value ) +{ + char buff[128]; + if ( snprintf( buff, sizeof(buff), "%f", f_value ) < 0 ) + return; + if( av_dict_set( pp_dict, psz_name, buff, 0 ) < 0 ) + msg_Warn( p_enc, "Failed to set encoder option %s", psz_name ); +} + int OpenEncoder( vlc_object_t *p_this ) { encoder_t *p_enc = (encoder_t *)p_this; @@ -493,6 +511,8 @@ int OpenEncoder( vlc_object_t *p_this ) } free( psz_val ); + AVDictionary *options = NULL; + if( p_enc->fmt_in.i_cat == VIDEO_ES ) { if( !p_enc->fmt_in.video.i_visible_width || !p_enc->fmt_in.video.i_visible_height ) @@ -521,7 +541,7 @@ int OpenEncoder( vlc_object_t *p_this ) p_context->lumi_masking = p_sys->f_lumi_masking; p_context->dark_masking = p_sys->f_dark_masking; p_context->p_masking = p_sys->f_p_masking; - p_context->border_masking = p_sys->f_border_masking; + add_av_option_float( p_enc, &options, "border_mask", p_sys->f_border_masking ); #if (LIBAVCODEC_VERSION_MAJOR < 55) p_context->luma_elim_threshold = p_sys->i_luma_elim; p_context->chroma_elim_threshold = p_sys->i_chroma_elim; @@ -535,7 +555,7 @@ int OpenEncoder( vlc_object_t *p_this ) if( !p_context->max_b_frames && ( p_enc->fmt_out.i_codec == VLC_CODEC_MPGV || p_enc->fmt_out.i_codec == VLC_CODEC_MP2V ) ) - p_context->flags |= CODEC_FLAG_LOW_DELAY; + p_context->flags |= AV_CODEC_FLAG_LOW_DELAY; av_reduce( &p_context->sample_aspect_ratio.num, &p_context->sample_aspect_ratio.den, @@ -593,16 +613,16 @@ int OpenEncoder( vlc_object_t *p_this ) } else { - p_context->flags |= CODEC_FLAG_INTERLACED_DCT; + p_context->flags |= AV_CODEC_FLAG_INTERLACED_DCT; if ( p_sys->b_interlace_me ) - p_context->flags |= CODEC_FLAG_INTERLACED_ME; + p_context->flags |= AV_CODEC_FLAG_INTERLACED_ME; } } p_context->trellis = p_sys->b_trellis; if ( p_sys->i_qmin > 0 && p_sys->i_qmin == p_sys->i_qmax ) - p_context->flags |= CODEC_FLAG_QSCALE; + p_context->flags |= AV_CODEC_FLAG_QSCALE; /* These codecs cause libavcodec to exit if thread_count is > 1. See libavcodec/mpegvideo_enc.c:MPV_encode_init and libavcodec/svq3.c , WMV2 calls MPV_encode_init also. @@ -638,12 +658,14 @@ int OpenEncoder( vlc_object_t *p_this ) if( p_sys->i_qmin > 0 ) { p_context->qmin = p_sys->i_qmin; - p_context->mb_lmin = p_context->lmin = p_sys->i_qmin * FF_QP2LAMBDA; + p_context->mb_lmin = p_sys->i_qmin * FF_QP2LAMBDA; + add_av_option_int( p_enc, &options, "lmin", p_context->mb_lmin); } if( p_sys->i_qmax > 0 ) { p_context->qmax = p_sys->i_qmax; - p_context->mb_lmax = p_context->lmax = p_sys->i_qmax * FF_QP2LAMBDA; + p_context->mb_lmax = p_sys->i_qmax * FF_QP2LAMBDA; + add_av_option_int( p_enc, &options, "lmax", p_context->mb_lmax); } p_context->max_qdiff = 3; @@ -651,12 +673,12 @@ int OpenEncoder( vlc_object_t *p_this ) if( p_sys->i_quality && !p_enc->fmt_out.i_bitrate ) { - p_context->flags |= CODEC_FLAG_QSCALE; + p_context->flags |= AV_CODEC_FLAG_QSCALE; p_context->global_quality = p_sys->i_quality; } else { - p_context->rc_qsquish = 1.0; + av_dict_set(&options, "qsquish", "1.0", 0); /* Default to 1/2 second buffer for given bitrate unless defined otherwise*/ if( !p_sys->i_rc_buffer_size ) { @@ -670,7 +692,7 @@ int OpenEncoder( vlc_object_t *p_this ) /* This is from ffmpeg's ffmpeg.c : */ p_context->rc_initial_buffer_occupancy = p_sys->i_rc_buffer_size * 3/4; - p_context->rc_buffer_aggressivity = p_sys->f_rc_buffer_aggressivity; + add_av_option_float( p_enc, &options, "rc_buffer_aggressivity", p_sys->f_rc_buffer_aggressivity ); } } else if( p_enc->fmt_in.i_cat == AUDIO_ES ) @@ -807,20 +829,23 @@ int OpenEncoder( vlc_object_t *p_this ) if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" ) ) { p_context->qmin = 10; - p_context->mb_lmin = p_context->lmin = 10 * FF_QP2LAMBDA; + p_context->mb_lmin = 10 * FF_QP2LAMBDA; + add_av_option_int( p_enc, &options, "lmin", p_context->mb_lmin ); } if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmax" ) ) { p_context->qmax = 42; - p_context->mb_lmax = p_context->lmax = 42 * FF_QP2LAMBDA; + p_context->mb_lmax = 42 * FF_QP2LAMBDA; + add_av_option_int( p_enc, &options, "lmax", p_context->mb_lmax ); } } else { if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" ) ) { p_context->qmin = 1; - p_context->mb_lmin = p_context->lmin = FF_QP2LAMBDA; + p_context->mb_lmin = FF_QP2LAMBDA; + add_av_option_int( p_enc, &options, "lmin", p_context->mb_lmin ); } } @@ -845,7 +870,7 @@ int OpenEncoder( vlc_object_t *p_this ) /* Make sure we get extradata filled by the encoder */ p_context->extradata_size = 0; p_context->extradata = NULL; - p_context->flags |= CODEC_FLAG_GLOBAL_HEADER; + p_context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; if( p_enc->i_threads >= 1) p_context->thread_count = p_enc->i_threads; @@ -854,10 +879,10 @@ int OpenEncoder( vlc_object_t *p_this ) int ret; char *psz_opts = var_InheritString(p_enc, ENC_CFG_PREFIX "options"); - AVDictionary *options = NULL; - if (psz_opts && *psz_opts) - options = vlc_av_get_options(psz_opts); - free(psz_opts); + if (psz_opts) { + vlc_av_get_options(psz_opts, &options); + free(psz_opts); + } vlc_avcodec_lock(); ret = avcodec_open2( p_context, p_codec, options ? &options : NULL ); @@ -982,7 +1007,7 @@ errmsg: } } - p_context->flags &= ~CODEC_FLAG_GLOBAL_HEADER; + p_context->flags &= ~AV_CODEC_FLAG_GLOBAL_HEADER; if( p_enc->fmt_in.i_cat == AUDIO_ES ) { @@ -992,7 +1017,7 @@ errmsg: p_sys->i_sample_bytes = (p_enc->fmt_in.audio.i_bitspersample / 8); p_sys->i_frame_size = p_context->frame_size > 1 ? p_context->frame_size : - FF_MIN_BUFFER_SIZE; + AV_INPUT_BUFFER_MIN_SIZE; p_sys->i_buffer_out = av_samples_get_buffer_size(NULL, p_sys->p_context->channels, p_sys->i_frame_size, p_sys->p_context->sample_fmt, DEFAULT_ALIGN); @@ -1359,7 +1384,7 @@ static block_t *handle_delay_buffer( encoder_t *p_enc, encoder_sys_t *p_sys, int } if(unlikely( ( (leftover + buffer_delay) < p_sys->i_buffer_out ) && - !(p_sys->p_codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME ))) + !(p_sys->p_codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME ))) { msg_Dbg( p_enc, "No small last frame support, padding"); size_t padding_size = p_sys->i_buffer_out - (leftover+buffer_delay); diff --git modules/codec/avcodec/video.c modules/codec/avcodec/video.c index a720fd80f1369a06776a13cac591a0002da1f37c..f0e0c8e90786da47aaa12102dc9ec4aeacf3f010 100644 --- modules/codec/avcodec/video.c +++ modules/codec/avcodec/video.c @@ -251,11 +251,11 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, var_InheritInteger( p_dec, "avcodec-error-resilience" ); if( var_CreateGetBool( p_dec, "grayscale" ) ) - p_sys->p_context->flags |= CODEC_FLAG_GRAY; + p_sys->p_context->flags |= AV_CODEC_FLAG_GRAY; /* ***** Output always the frames ***** */ #if LIBAVCODEC_VERSION_CHECK(55, 23, 1, 40, 101) - p_sys->p_context->flags |= CODEC_FLAG_OUTPUT_CORRUPT; + p_sys->p_context->flags |= AV_CODEC_FLAG_OUTPUT_CORRUPT; #endif i_val = var_CreateGetInteger( p_dec, "avcodec-vismv" ); @@ -268,7 +268,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, else if( i_val == 1 ) p_sys->p_context->skip_loop_filter = AVDISCARD_NONREF; if( var_CreateGetBool( p_dec, "avcodec-fast" ) ) - p_sys->p_context->flags2 |= CODEC_FLAG2_FAST; + p_sys->p_context->flags2 |= AV_CODEC_FLAG2_FAST; /* ***** libavcodec frame skipping ***** */ p_sys->b_hurry_up = var_CreateGetBool( p_dec, "avcodec-hurry-up" ); @@ -295,7 +295,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, p_sys->b_direct_rendering = false; p_sys->i_direct_rendering_used = -1; if( var_CreateGetBool( p_dec, "avcodec-dr" ) && - (p_sys->p_codec->capabilities & CODEC_CAP_DR1) && + (p_sys->p_codec->capabilities & AV_CODEC_CAP_DR1) && /* No idea why ... but this fixes flickering on some TSCC streams */ p_sys->i_codec_id != AV_CODEC_ID_TSCC && p_sys->i_codec_id != AV_CODEC_ID_CSCD && p_sys->i_codec_id != AV_CODEC_ID_CINEPAK && @@ -306,6 +306,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, p_sys->b_direct_rendering = true; } +#ifdef CODEC_FLAG_EMU_EDGE /* libavcodec doesn't properly release old pictures when frames are skipped */ //if( p_sys->b_hurry_up ) p_sys->b_direct_rendering = false; if( p_sys->b_direct_rendering ) @@ -317,6 +318,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, { msg_Dbg( p_dec, "direct rendering is disabled" ); } +#endif p_sys->p_context->get_format = ffmpeg_GetFormat; /* Always use our get_buffer wrapper so we can calculate the @@ -427,7 +429,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, if( p_dec->fmt_out.video.p_palette ) *p_dec->fmt_out.video.p_palette = *p_dec->fmt_in.video.p_palette; } - else if( p_sys->i_codec_id != CODEC_ID_MSVIDEO1 && p_sys->i_codec_id != CODEC_ID_CINEPAK ) + else if( p_sys->i_codec_id != AV_CODEC_ID_MSVIDEO1 && p_sys->i_codec_id != AV_CODEC_ID_CINEPAK ) { p_sys->p_context->palctrl = &p_sys->palette; } @@ -484,7 +486,7 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) } p_block = *pp_block; - if(!p_block && !(p_sys->p_codec->capabilities & CODEC_CAP_DELAY) ) + if(!p_block && !(p_sys->p_codec->capabilities & AV_CODEC_CAP_DELAY) ) return NULL; if( p_sys->b_delayed_open ) @@ -594,13 +596,13 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) p_sys->b_flush = ( p_block->i_flags & BLOCK_FLAG_END_OF_SEQUENCE ) != 0; p_block = block_Realloc( p_block, 0, - p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE ); + p_block->i_buffer + AV_INPUT_BUFFER_PADDING_SIZE ); if( !p_block ) return NULL; - p_block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE; + p_block->i_buffer -= AV_INPUT_BUFFER_PADDING_SIZE; *pp_block = p_block; memset( p_block->p_buffer + p_block->i_buffer, 0, - FF_INPUT_BUFFER_PADDING_SIZE ); + AV_INPUT_BUFFER_PADDING_SIZE ); } while( !p_block || p_block->i_buffer > 0 || p_sys->b_flush ) @@ -621,7 +623,7 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) } else { - /* Return delayed frames if codec has CODEC_CAP_DELAY */ + /* Return delayed frames if codec has AV_CODEC_CAP_DELAY */ pkt.data = NULL; pkt.size = 0; } @@ -711,8 +713,15 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) } /* Compute the PTS */ +#ifdef FF_API_PKT_PTS + mtime_t i_pts = p_sys->p_ff_pic->pts; + + if (i_pts == AV_NOPTS_VALUE ) + i_pts = p_sys->p_ff_pic->pkt_dts; +#else mtime_t i_pts = p_sys->p_ff_pic->pkt_pts; +#endif if (i_pts <= VLC_TS_INVALID) i_pts = p_sys->p_ff_pic->pkt_dts; @@ -874,7 +883,7 @@ static void ffmpeg_InitCodec( decoder_t *p_dec ) p_sys->p_context->extradata_size = i_size + 12; p = p_sys->p_context->extradata = av_malloc( p_sys->p_context->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE ); + AV_INPUT_BUFFER_PADDING_SIZE ); if( !p ) return; @@ -911,13 +920,13 @@ static void ffmpeg_InitCodec( decoder_t *p_dec ) { p_sys->p_context->extradata_size = i_size; p_sys->p_context->extradata = - av_malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE ); + av_malloc( i_size + AV_INPUT_BUFFER_PADDING_SIZE ); if( p_sys->p_context->extradata ) { memcpy( p_sys->p_context->extradata, p_dec->fmt_in.p_extra, i_size ); memset( p_sys->p_context->extradata + i_size, - 0, FF_INPUT_BUFFER_PADDING_SIZE ); + 0, AV_INPUT_BUFFER_PADDING_SIZE ); } } }