Updated FFmpeg.

CQTexperiment
Christopher Snowhill 2018-02-18 20:44:10 -08:00
parent e1c33b5477
commit f400e068cf
44 changed files with 518 additions and 81 deletions

View File

@ -2,7 +2,7 @@
./configure --extra-cflags="-fPIC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=10.8" --extra-ldflags="-mmacosx-version-min=10.8"\
--enable-static --disable-shared --prefix=$HOME/Source/Repos/cog/ThirdParty/ffmpeg\
--enable-pic --enable-gpl --disable-doc --disable-ffplay\
--disable-ffprobe --disable-ffserver --disable-avdevice --disable-ffmpeg\
--disable-ffprobe --disable-avdevice --disable-ffmpeg\
--disable-postproc --disable-avfilter\
--disable-swscale --disable-network --disable-swscale-alpha --disable-vdpau\
--disable-dxva2 --disable-everything --enable-hwaccels\

View File

@ -634,6 +634,7 @@ enum AVCodecID {
AV_CODEC_ID_ATRAC3PAL,
AV_CODEC_ID_DOLBY_E,
AV_CODEC_ID_APTX,
AV_CODEC_ID_APTX_HD,
/* subtitle codecs */
AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
@ -767,7 +768,7 @@ typedef struct AVCodecDescriptor {
* Note: If the first 23 bits of the additional bytes are not 0, then damaged
* MPEG bitstreams could cause overread and segfault.
*/
#define AV_INPUT_BUFFER_PADDING_SIZE 32
#define AV_INPUT_BUFFER_PADDING_SIZE 64
/**
* @ingroup lavc_encoding
@ -3254,6 +3255,20 @@ typedef struct AVCodecContext {
* (with the display dimensions being determined by the crop_* fields).
*/
int apply_cropping;
/*
* Video decoding only. Sets the number of extra hardware frames which
* the decoder will allocate for use by the caller. This must be set
* before avcodec_open2() is called.
*
* Some hardware decoders require all frames that they will use for
* output to be defined in advance before decoding starts. For such
* decoders, the hardware frame pool must therefore be of a fixed size.
* The extra frames set here are on top of any number that the decoder
* needs internally in order to operate normally (for example, frames
* used as reference pictures).
*/
int extra_hw_frames;
} AVCodecContext;
#if FF_API_CODEC_GET_SET
@ -3439,6 +3454,9 @@ typedef struct AVCodec {
/**
* Initialize codec static data, called from avcodec_register().
*
* This is not intended for time consuming operations as it is
* run for every codec regardless of that codec being used.
*/
void (*init_static_data)(struct AVCodec *codec);
@ -3978,12 +3996,26 @@ typedef struct AVCodecParameters {
int seek_preroll;
} AVCodecParameters;
/**
* Iterate over all registered codecs.
*
* @param opaque a pointer where libavcodec will store the iteration state. Must
* point to NULL to start the iteration.
*
* @return the next registered codec or NULL when the iteration is
* finished
*/
const AVCodec *av_codec_iterate(void **opaque);
#if FF_API_NEXT
/**
* If c is NULL, returns the first registered codec,
* if c is non-NULL, returns the next registered codec after c,
* or NULL if c is the last one.
*/
attribute_deprecated
AVCodec *av_codec_next(const AVCodec *c);
#endif
/**
* Return the LIBAVCODEC_VERSION_INT constant.
@ -4000,6 +4032,7 @@ const char *avcodec_configuration(void);
*/
const char *avcodec_license(void);
#if FF_API_NEXT
/**
* Register the codec codec and initialize libavcodec.
*
@ -4008,6 +4041,7 @@ const char *avcodec_license(void);
*
* @see avcodec_register_all()
*/
attribute_deprecated
void avcodec_register(AVCodec *codec);
/**
@ -4020,7 +4054,9 @@ void avcodec_register(AVCodec *codec);
* @see av_register_codec_parser
* @see av_register_bitstream_filter
*/
attribute_deprecated
void avcodec_register_all(void);
#endif
/**
* Allocate an AVCodecContext and set its fields to default values. The
@ -5120,8 +5156,21 @@ typedef struct AVCodecParser {
struct AVCodecParser *next;
} AVCodecParser;
/**
* Iterate over all registered codec parsers.
*
* @param opaque a pointer where libavcodec will store the iteration state. Must
* point to NULL to start the iteration.
*
* @return the next registered codec parser or NULL when the iteration is
* finished
*/
const AVCodecParser *av_parser_iterate(void **opaque);
attribute_deprecated
AVCodecParser *av_parser_next(const AVCodecParser *c);
attribute_deprecated
void av_register_codec_parser(AVCodecParser *parser);
AVCodecParserContext *av_parser_init(int codec_id);
@ -5697,7 +5746,7 @@ attribute_deprecated
void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
/**
* @deprecated the old bitstream filtering API (using AVBitStreamFilterContext)
* is deprecated. Use av_bsf_next() from the new bitstream filtering API (using
* is deprecated. Use av_bsf_iterate() from the new bitstream filtering API (using
* AVBSFContext).
*/
attribute_deprecated
@ -5719,7 +5768,11 @@ const AVBitStreamFilter *av_bsf_get_by_name(const char *name);
* @return the next registered bitstream filter or NULL when the iteration is
* finished
*/
const AVBitStreamFilter *av_bsf_iterate(void **opaque);
#if FF_API_NEXT
attribute_deprecated
const AVBitStreamFilter *av_bsf_next(void **opaque);
#endif
/**
* Allocate a context for a given bitstream filter. The caller must fill in the
@ -5930,9 +5983,11 @@ attribute_deprecated
AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel);
#endif
#if FF_API_LOCKMGR
/**
* Lock operation used by lockmgr
*
* @deprecated Deprecated together with av_lockmgr_register().
*/
enum AVLockOp {
AV_LOCK_CREATE, ///< Create a mutex
@ -5963,8 +6018,13 @@ enum AVLockOp {
* mechanism (i.e. do not use a single static object to
* implement your lock manager). If cb is set to NULL the
* lockmgr will be unregistered.
*
* @deprecated This function does nothing, and always returns 0. Be sure to
* build with thread support to get basic thread safety.
*/
attribute_deprecated
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
#endif
/**
* Get the type of the given codec.

View File

@ -28,8 +28,8 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 8
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MINOR 11
#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
@ -126,6 +126,12 @@
#ifndef FF_API_USER_VISIBLE_AVHWACCEL
#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_LOCKMGR
#define FF_API_LOCKMGR (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_NEXT
#define FF_API_NEXT (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#endif /* AVCODEC_VERSION_H */

View File

@ -986,12 +986,17 @@ typedef struct AVStream {
*/
AVRational r_frame_rate;
#if FF_API_LAVF_FFSERVER
/**
* String containing pairs of key and values describing recommended encoder configuration.
* Pairs are separated by ','.
* Keys are separated from values by '='.
*
* @deprecated unused
*/
attribute_deprecated
char *recommended_encoder_configuration;
#endif
/**
* Codec parameters associated with this stream. Allocated and freed by
@ -1014,10 +1019,10 @@ typedef struct AVStream {
*****************************************************************
*/
#define MAX_STD_TIMEBASES (30*12+30+3+6)
/**
* Stream information used internally by avformat_find_stream_info()
*/
#define MAX_STD_TIMEBASES (30*12+30+3+6)
struct {
int64_t last_dts;
int64_t duration_gcd;
@ -1217,11 +1222,13 @@ attribute_deprecated
AVRational av_stream_get_r_frame_rate(const AVStream *s);
attribute_deprecated
void av_stream_set_r_frame_rate(AVStream *s, AVRational r);
#if FF_API_LAVF_FFSERVER
attribute_deprecated
char* av_stream_get_recommended_encoder_configuration(const AVStream *s);
attribute_deprecated
void av_stream_set_recommended_encoder_configuration(AVStream *s, char *configuration);
#endif
#endif
struct AVCodecParserContext *av_stream_get_parser(const AVStream *s);
@ -1268,6 +1275,11 @@ typedef struct AVProgram {
#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
(streams are added dynamically) */
#define AVFMTCTX_UNSEEKABLE 0x0002 /**< signal that the stream is definitely
not seekable, and attempts to call the
seek function will fail. For some
network protocols (e.g. HLS), this can
change dynamically at runtime. */
typedef struct AVChapter {
int id; ///< unique ID to identify the chapter
@ -1382,13 +1394,33 @@ typedef struct AVFormatContext {
*/
AVStream **streams;
#if FF_API_FORMAT_FILENAME
/**
* input or output filename
*
* - demuxing: set by avformat_open_input()
* - muxing: may be set by the caller before avformat_write_header()
*
* @deprecated Use url instead.
*/
attribute_deprecated
char filename[1024];
#endif
/**
* input or output URL. Unlike the old filename field, this field has no
* length restriction.
*
* - demuxing: set by avformat_open_input(), initialized to an empty
* string if url parameter was NULL in avformat_open_input().
* - muxing: may be set by the caller before calling avformat_write_header()
* (or avformat_init_output() if that is called first) to a string
* which is freeable by av_free(). Set to an empty string if it
* was NULL in avformat_init_output().
*
* Freed by libavformat in avformat_free_context().
*/
char *url;
/**
* Position of the first frame of the component, in
@ -1852,7 +1884,7 @@ typedef struct AVFormatContext {
*/
char *protocol_whitelist;
/*
/**
* A callback for opening new IO streams.
*
* Whenever a muxer or a demuxer needs to open an IO stream (typically from
@ -1979,6 +2011,7 @@ const char *avformat_configuration(void);
*/
const char *avformat_license(void);
#if FF_API_NEXT
/**
* Initialize libavformat and register all the muxers, demuxers and
* protocols. If you do not call this function, then you can select
@ -1987,31 +2020,44 @@ const char *avformat_license(void);
* @see av_register_input_format()
* @see av_register_output_format()
*/
attribute_deprecated
void av_register_all(void);
attribute_deprecated
void av_register_input_format(AVInputFormat *format);
attribute_deprecated
void av_register_output_format(AVOutputFormat *format);
#endif
/**
* Do global initialization of network components. This is optional,
* but recommended, since it avoids the overhead of implicitly
* doing the setup for each session.
* Do global initialization of network libraries. This is optional,
* and not recommended anymore.
*
* Calling this function will become mandatory if using network
* protocols at some major version bump.
* This functions only exists to work around thread-safety issues
* with older GnuTLS or OpenSSL libraries. If libavformat is linked
* to newer versions of those libraries, or if you do not use them,
* calling this function is unnecessary. Otherwise, you need to call
* this function before any other threads using them are started.
*
* This function will be deprecated once support for older GnuTLS and
* OpenSSL libraries is removed, and this function has no purpose
* anymore.
*/
int avformat_network_init(void);
/**
* Undo the initialization done by avformat_network_init.
* Undo the initialization done by avformat_network_init. Call it only
* once for each time you called avformat_network_init.
*/
int avformat_network_deinit(void);
#if FF_API_NEXT
/**
* If f is NULL, returns the first registered input format,
* if f is non-NULL, returns the next registered input format after f
* or NULL if f is the last one.
*/
attribute_deprecated
AVInputFormat *av_iformat_next(const AVInputFormat *f);
/**
@ -2019,7 +2065,31 @@ AVInputFormat *av_iformat_next(const AVInputFormat *f);
* if f is non-NULL, returns the next registered output format after f
* or NULL if f is the last one.
*/
attribute_deprecated
AVOutputFormat *av_oformat_next(const AVOutputFormat *f);
#endif
/**
* Iterate over all registered muxers.
*
* @param opaque a pointer where libavformat will store the iteration state. Must
* point to NULL to start the iteration.
*
* @return the next registered muxer or NULL when the iteration is
* finished
*/
const AVOutputFormat *av_muxer_iterate(void **opaque);
/**
* Iterate over all registered demuxers.
*
* @param opaque a pointer where libavformat will store the iteration state. Must
* point to NULL to start the iteration.
*
* @return the next registered demuxer or NULL when the iteration is
* finished
*/
const AVInputFormat *av_demuxer_iterate(void **opaque);
/**
* Allocate an AVFormatContext.

View File

@ -32,7 +32,7 @@
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 58
#define LIBAVFORMAT_VERSION_MINOR 3
#define LIBAVFORMAT_VERSION_MINOR 9
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@ -82,6 +82,18 @@
#ifndef FF_API_OLD_AVIO_EOF_0
#define FF_API_OLD_AVIO_EOF_0 (LIBAVFORMAT_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_LAVF_FFSERVER
#define FF_API_LAVF_FFSERVER (LIBAVFORMAT_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_FORMAT_FILENAME
#define FF_API_FORMAT_FILENAME (LIBAVFORMAT_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_OLD_RTSP_OPTIONS
#define FF_API_OLD_RTSP_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_NEXT
#define FF_API_NEXT (LIBAVFORMAT_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_R_FRAME_RATE

View File

@ -67,10 +67,15 @@ const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a);
void av_aes_ctr_set_random_iv(struct AVAESCTR *a);
/**
* Forcefully change the iv
* Forcefully change the 8-byte iv
*/
void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv);
/**
* Forcefully change the "full" 16-byte iv, including the counter
*/
void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv);
/**
* Increment the top 64 bit of the iv (performed after each frame)
*/

View File

@ -158,7 +158,7 @@ static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, in
*/
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
{
if (a&(~0xFF)) return (-a)>>31;
if (a&(~0xFF)) return (~a)>>31;
else return a;
}
@ -180,7 +180,7 @@ static av_always_inline av_const int8_t av_clip_int8_c(int a)
*/
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
{
if (a&(~0xFFFF)) return (-a)>>31;
if (a&(~0xFFFF)) return (~a)>>31;
else return a;
}

View File

@ -55,6 +55,7 @@
#define AV_CPU_FLAG_FMA3 0x10000 ///< Haswell FMA3 functions
#define AV_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1
#define AV_CPU_FLAG_BMI2 0x40000 ///< Bit Manipulation Instruction Set 2
#define AV_CPU_FLAG_AVX512 0x100000 ///< AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used
#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
#define AV_CPU_FLAG_VSX 0x0002 ///< ISA 2.06

View File

@ -1,5 +1,5 @@
/* Automatically generated by version.sh, do not manually edit! */
#ifndef AVUTIL_FFVERSION_H
#define AVUTIL_FFVERSION_H
#define FFMPEG_VERSION "N-89516-g97cf1d4c49"
#define FFMPEG_VERSION "N-90075-g647fa49495"
#endif /* AVUTIL_FFVERSION_H */

View File

@ -29,6 +29,8 @@
#include <stdint.h>
#include "version.h"
/**
* @defgroup lavu_hash Hash Functions
* @ingroup lavu_crypto
@ -179,7 +181,11 @@ void av_hash_init(struct AVHashContext *ctx);
* @param[in] src Data to be added to the hash context
* @param[in] len Size of the additional data
*/
#if FF_API_CRYPTO_SIZE_T
void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, int len);
#else
void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, size_t len);
#endif
/**
* Finalize a hash context and compute the actual hash value.

View File

@ -224,7 +224,7 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_X64)) && AV_HAVE_FAST_UNALIGNED
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_X64) || defined(_M_ARM64)) && AV_HAVE_FAST_UNALIGNED
# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))

View File

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2016 Neil Birkbeck <neil.birkbeck@gmail.com>
*
* This file is part of FFmpeg.

View File

@ -29,6 +29,8 @@
#include <stdint.h>
#include "version.h"
/**
* @defgroup lavu_murmur3 Murmur3
* @ingroup lavu_hash
@ -97,7 +99,11 @@ void av_murmur3_init(struct AVMurMur3 *c);
* @param[in] src Input data to update hash with
* @param[in] len Number of bytes to read from `src`
*/
#if FF_API_CRYPTO_SIZE_T
void av_murmur3_update(struct AVMurMur3 *c, const uint8_t *src, int len);
#else
void av_murmur3_update(struct AVMurMur3 *c, const uint8_t *src, size_t len);
#endif
/**
* Finish hashing and output digest value.

View File

@ -229,15 +229,15 @@ enum AVOptionType{
AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
AV_OPT_TYPE_DICT,
AV_OPT_TYPE_UINT64,
AV_OPT_TYPE_CONST = 128,
AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must point to two consecutive integers
AV_OPT_TYPE_PIXEL_FMT = MKBETAG('P','F','M','T'),
AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'),
AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must point to AVRational
AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '),
AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'),
AV_OPT_TYPE_CHANNEL_LAYOUT = MKBETAG('C','H','L','A'),
AV_OPT_TYPE_BOOL = MKBETAG('B','O','O','L'),
AV_OPT_TYPE_CONST,
AV_OPT_TYPE_IMAGE_SIZE, ///< offset must point to two consecutive integers
AV_OPT_TYPE_PIXEL_FMT,
AV_OPT_TYPE_SAMPLE_FMT,
AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational
AV_OPT_TYPE_DURATION,
AV_OPT_TYPE_COLOR,
AV_OPT_TYPE_CHANNEL_LAYOUT,
AV_OPT_TYPE_BOOL,
};
/**

View File

@ -66,7 +66,11 @@ int av_ripemd_init(struct AVRIPEMD* context, int bits);
* @param data input data to update hash with
* @param len input data length
*/
#if FF_API_CRYPTO_SIZE_T
void av_ripemd_update(struct AVRIPEMD* context, const uint8_t* data, unsigned int len);
#else
void av_ripemd_update(struct AVRIPEMD* context, const uint8_t* data, size_t len);
#endif
/**
* Finish hashing and output digest value.

View File

@ -79,8 +79,8 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 56
#define LIBAVUTIL_VERSION_MINOR 6
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_MINOR 7
#define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,8 +5,8 @@ includedir=/Users/chris/Source/Repos/cog/ThirdParty/ffmpeg/include
Name: libavcodec
Description: FFmpeg codec library
Version: 58.8.100
Requires: libswresample >= 3.0.101, libavutil >= 56.6.100
Version: 58.11.101
Requires: libswresample >= 3.0.101, libavutil >= 56.7.101
Requires.private:
Conflicts:
Libs: -L${libdir} -lavcodec -pthread -lm

View File

@ -5,8 +5,8 @@ includedir=/Users/chris/Source/Repos/cog/ThirdParty/ffmpeg/include
Name: libavformat
Description: FFmpeg container format library
Version: 58.3.100
Requires: libavcodec >= 58.8.100, libswresample >= 3.0.101, libavutil >= 56.6.100
Version: 58.9.100
Requires: libavcodec >= 58.11.101, libswresample >= 3.0.101, libavutil >= 56.7.101
Requires.private:
Conflicts:
Libs: -L${libdir} -lavformat -lm -lz

View File

@ -5,7 +5,7 @@ includedir=/Users/chris/Source/Repos/cog/ThirdParty/ffmpeg/include
Name: libavutil
Description: FFmpeg utility library
Version: 56.6.100
Version: 56.7.101
Requires:
Requires.private:
Conflicts:

View File

@ -6,7 +6,7 @@ includedir=/Users/chris/Source/Repos/cog/ThirdParty/ffmpeg/include
Name: libswresample
Description: FFmpeg audio resampling library
Version: 3.0.101
Requires: libavutil >= 56.6.100
Requires: libavutil >= 56.7.101
Requires.private:
Conflicts:
Libs: -L${libdir} -lswresample -lm

View File

@ -143,8 +143,6 @@ int main(int argc, char *argv[])
return 1;
}
/* register codecs and formats and other lavf/lavc components*/
av_register_all();
avformat_network_init();
op = argv[1];

View File

@ -74,9 +74,6 @@ int main(int argc, char *argv[])
}
input_filename = argv[1];
/* register codecs and formats and other lavf/lavc components*/
av_register_all();
/* slurp file content into buffer */
ret = av_file_map(input_filename, &buffer, &buffer_size, 0, NULL);
if (ret < 0)

View File

@ -94,9 +94,6 @@ int main(int argc, char **argv)
filename = argv[1];
outfilename = argv[2];
/* register all the codecs */
avcodec_register_all();
pkt = av_packet_alloc();
/* find the MPEG audio decoder */

View File

@ -101,8 +101,6 @@ int main(int argc, char **argv)
filename = argv[1];
outfilename = argv[2];
avcodec_register_all();
pkt = av_packet_alloc();
if (!pkt)
exit(1);

View File

@ -252,9 +252,6 @@ int main (int argc, char **argv)
video_dst_filename = argv[2];
audio_dst_filename = argv[3];
/* register all formats and codecs */
av_register_all();
/* open input file, and allocate format context */
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
fprintf(stderr, "Could not open source file %s\n", src_filename);

View File

@ -138,9 +138,6 @@ int main(int argc, char **argv)
}
filename = argv[1];
/* register all the codecs */
avcodec_register_all();
/* find the MP2 encoder */
codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
if (!codec) {

View File

@ -84,8 +84,6 @@ int main(int argc, char **argv)
filename = argv[1];
codec_name = argv[2];
avcodec_register_all();
/* find the mpeg1video encoder */
codec = avcodec_find_encoder_by_name(codec_name);
if (!codec) {

View File

@ -129,8 +129,6 @@ int main(int argc, char **argv)
}
src_filename = argv[1];
av_register_all();
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
fprintf(stderr, "Could not open source file %s\n", src_filename);
exit(1);

View File

@ -228,7 +228,6 @@ int main(int argc, char **argv)
exit(1);
}
av_register_all();
avfilter_register_all();
if ((ret = open_input_file(argv[1])) < 0)

View File

@ -222,7 +222,6 @@ int main(int argc, char **argv)
exit(1);
}
av_register_all();
avfilter_register_all();
if ((ret = open_input_file(argv[1])) < 0)

View File

@ -114,7 +114,6 @@ int main(int argc, char **argv)
in_uri = argv[1];
out_uri = argv[2];
av_register_all();
avformat_network_init();
if ((ret = av_dict_set(&options, "listen", "2", 0)) < 0) {

View File

@ -163,8 +163,6 @@ int main(int argc, char *argv[])
return -1;
}
av_register_all();
type = av_hwdevice_find_type_by_name(argv[1]);
if (type == AV_HWDEVICE_TYPE_NONE) {
fprintf(stderr, "Device type %s is not supported.\n", argv[1]);

View File

@ -44,7 +44,6 @@ int main (int argc, char **argv)
return 1;
}
av_register_all();
if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL)))
return ret;

View File

@ -564,9 +564,6 @@ int main(int argc, char **argv)
AVDictionary *opt = NULL;
int i;
/* Initialize libavcodec, and register all codecs and formats. */
av_register_all();
if (argc < 2) {
printf("usage: %s output_file\n"
"API example program to output a media file with libavformat.\n"

View File

@ -150,8 +150,6 @@ int main(int argc, char **argv)
int ret, i;
av_register_all();
if (argc < 3) {
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
return 1;
@ -210,7 +208,6 @@ int main(int argc, char **argv)
video_st->codecpar->extradata_size);
decoder_ctx->extradata_size = video_st->codecpar->extradata_size;
}
decoder_ctx->refcounted_frames = 1;
decoder_ctx->opaque = &decode;
decoder_ctx->get_format = get_format;

View File

@ -65,8 +65,6 @@ int main(int argc, char **argv)
in_filename = argv[1];
out_filename = argv[2];
av_register_all();
if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0) {
fprintf(stderr, "Could not open input file '%s'", in_filename);
goto end;

View File

@ -171,8 +171,11 @@ static int open_output_file(const char *filename,
goto cleanup;
}
av_strlcpy((*output_format_context)->filename, filename,
sizeof((*output_format_context)->filename));
if (!((*output_format_context)->url = av_strdup(filename))) {
fprintf(stderr, "Could not allocate url.\n");
error = AVERROR(ENOMEM);
goto cleanup;
}
/* Find the encoder to be used by its name. */
if (!(output_codec = avcodec_find_encoder(AV_CODEC_ID_AAC))) {
@ -750,8 +753,6 @@ int main(int argc, char **argv)
exit(1);
}
/* Register all codecs and formats so that they can be used. */
av_register_all();
/* Open the input file for reading. */
if (open_input_file(argv[1], &input_format_context,
&input_codec_context))

View File

@ -517,7 +517,6 @@ int main(int argc, char **argv)
return 1;
}
av_register_all();
avfilter_register_all();
if ((ret = open_input_file(argv[1])) < 0)

View File

@ -125,8 +125,6 @@ int main(int argc, char *argv[])
goto close;
}
avcodec_register_all();
err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
NULL, NULL, 0);
if (err < 0) {
@ -217,8 +215,7 @@ close:
fclose(fout);
av_frame_free(&sw_frame);
av_frame_free(&hw_frame);
if (avctx)
avcodec_free_context(&avctx);
avcodec_free_context(&avctx);
av_buffer_unref(&hw_device_ctx);
return err;

View File

@ -0,0 +1,304 @@
/*
* Video Acceleration API (video transcoding) transcode sample
*
* 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
*/
/**
* @file
* Intel VAAPI-accelerated transcoding example.
*
* @example vaapi_transcode.c
* This example shows how to do VAAPI-accelerated transcoding.
* Usage: vaapi_transcode input_stream codec output_stream
* e.g: - vaapi_transcode input.mp4 h264_vaapi output_h264.mp4
* - vaapi_transcode input.mp4 vp9_vaapi output_vp9.ivf
*/
#include <stdio.h>
#include <errno.h>
#include <libavutil/hwcontext.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
static AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
static AVBufferRef *hw_device_ctx = NULL;
static AVCodecContext *decoder_ctx = NULL, *encoder_ctx = NULL;
static int video_stream = -1;
static AVStream *ost;
static int initialized = 0;
static enum AVPixelFormat get_vaapi_format(AVCodecContext *ctx,
const enum AVPixelFormat *pix_fmts)
{
const enum AVPixelFormat *p;
for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
if (*p == AV_PIX_FMT_VAAPI)
return *p;
}
fprintf(stderr, "Unable to decode this file using VA-API.\n");
return AV_PIX_FMT_NONE;
}
static int open_input_file(const char *filename)
{
int ret;
AVCodec *decoder = NULL;
AVStream *video = NULL;
if ((ret = avformat_open_input(&ifmt_ctx, filename, NULL, NULL)) < 0) {
fprintf(stderr, "Cannot open input file '%s', Error code: %s\n",
filename, av_err2str(ret));
return ret;
}
if ((ret = avformat_find_stream_info(ifmt_ctx, NULL)) < 0) {
fprintf(stderr, "Cannot find input stream information. Error code: %s\n",
av_err2str(ret));
return ret;
}
ret = av_find_best_stream(ifmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &decoder, 0);
if (ret < 0) {
fprintf(stderr, "Cannot find a video stream in the input file. "
"Error code: %s\n", av_err2str(ret));
return ret;
}
video_stream = ret;
if (!(decoder_ctx = avcodec_alloc_context3(decoder)))
return AVERROR(ENOMEM);
video = ifmt_ctx->streams[video_stream];
if ((ret = avcodec_parameters_to_context(decoder_ctx, video->codecpar)) < 0) {
fprintf(stderr, "avcodec_parameters_to_context error. Error code: %s\n",
av_err2str(ret));
return ret;
}
decoder_ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
if (!decoder_ctx->hw_device_ctx) {
fprintf(stderr, "A hardware device reference create failed.\n");
return AVERROR(ENOMEM);
}
decoder_ctx->get_format = get_vaapi_format;
if ((ret = avcodec_open2(decoder_ctx, decoder, NULL)) < 0)
fprintf(stderr, "Failed to open codec for decoding. Error code: %s\n",
av_err2str(ret));
return ret;
}
static int encode_write(AVFrame *frame)
{
int ret = 0;
AVPacket enc_pkt;
av_init_packet(&enc_pkt);
enc_pkt.data = NULL;
enc_pkt.size = 0;
if ((ret = avcodec_send_frame(encoder_ctx, frame)) < 0) {
fprintf(stderr, "Error during encoding. Error code: %s\n", av_err2str(ret));
goto end;
}
while (1) {
ret = avcodec_receive_packet(encoder_ctx, &enc_pkt);
if (ret)
break;
enc_pkt.stream_index = 0;
av_packet_rescale_ts(&enc_pkt, ifmt_ctx->streams[video_stream]->time_base,
ofmt_ctx->streams[0]->time_base);
ret = av_interleaved_write_frame(ofmt_ctx, &enc_pkt);
if (ret < 0) {
fprintf(stderr, "Error during writing data to output file. "
"Error code: %s\n", av_err2str(ret));
return -1;
}
}
end:
if (ret == AVERROR_EOF)
return 0;
ret = ((ret == AVERROR(EAGAIN)) ? 0:-1);
return ret;
}
static int dec_enc(AVPacket *pkt, AVCodec *enc_codec)
{
AVFrame *frame;
int ret = 0;
ret = avcodec_send_packet(decoder_ctx, pkt);
if (ret < 0) {
fprintf(stderr, "Error during decoding. Error code: %s\n", av_err2str(ret));
return ret;
}
while (ret >= 0) {
if (!(frame = av_frame_alloc()))
return AVERROR(ENOMEM);
ret = avcodec_receive_frame(decoder_ctx, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
av_frame_free(&frame);
return 0;
} else if (ret < 0) {
fprintf(stderr, "Error while decoding. Error code: %s\n", av_err2str(ret));
goto fail;
}
if (!initialized) {
/* we need to ref hw_frames_ctx of decoder to initialize encoder's codec.
Only after we get a decoded frame, can we obtain its hw_frames_ctx */
encoder_ctx->hw_frames_ctx = av_buffer_ref(decoder_ctx->hw_frames_ctx);
if (!encoder_ctx->hw_frames_ctx) {
ret = AVERROR(ENOMEM);
goto fail;
}
/* set AVCodecContext Parameters for encoder, here we keep them stay
* the same as decoder.
* xxx: now the the sample can't handle resolution change case.
*/
encoder_ctx->time_base = av_inv_q(decoder_ctx->framerate);
encoder_ctx->pix_fmt = AV_PIX_FMT_VAAPI;
encoder_ctx->width = decoder_ctx->width;
encoder_ctx->height = decoder_ctx->height;
if ((ret = avcodec_open2(encoder_ctx, enc_codec, NULL)) < 0) {
fprintf(stderr, "Failed to open encode codec. Error code: %s\n",
av_err2str(ret));
goto fail;
}
if (!(ost = avformat_new_stream(ofmt_ctx, enc_codec))) {
fprintf(stderr, "Failed to allocate stream for output format.\n");
ret = AVERROR(ENOMEM);
goto fail;
}
ost->time_base = encoder_ctx->time_base;
ret = avcodec_parameters_from_context(ost->codecpar, encoder_ctx);
if (ret < 0) {
fprintf(stderr, "Failed to copy the stream parameters. "
"Error code: %s\n", av_err2str(ret));
goto fail;
}
/* write the stream header */
if ((ret = avformat_write_header(ofmt_ctx, NULL)) < 0) {
fprintf(stderr, "Error while writing stream header. "
"Error code: %s\n", av_err2str(ret));
goto fail;
}
initialized = 1;
}
if ((ret = encode_write(frame)) < 0)
fprintf(stderr, "Error during encoding and writing.\n");
fail:
av_frame_free(&frame);
if (ret < 0)
return ret;
}
return 0;
}
int main(int argc, char **argv)
{
int ret = 0;
AVPacket dec_pkt;
AVCodec *enc_codec;
if (argc != 4) {
fprintf(stderr, "Usage: %s <input file> <encode codec> <output file>\n"
"The output format is guessed according to the file extension.\n"
"\n", argv[0]);
return -1;
}
ret = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, NULL, NULL, 0);
if (ret < 0) {
fprintf(stderr, "Failed to create a VAAPI device. Error code: %s\n", av_err2str(ret));
return -1;
}
if ((ret = open_input_file(argv[1])) < 0)
goto end;
if (!(enc_codec = avcodec_find_encoder_by_name(argv[2]))) {
fprintf(stderr, "Could not find encoder '%s'\n", argv[2]);
ret = -1;
goto end;
}
if ((ret = (avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, argv[3]))) < 0) {
fprintf(stderr, "Failed to deduce output format from file extension. Error code: "
"%s\n", av_err2str(ret));
goto end;
}
if (!(encoder_ctx = avcodec_alloc_context3(enc_codec))) {
ret = AVERROR(ENOMEM);
goto end;
}
ret = avio_open(&ofmt_ctx->pb, argv[3], AVIO_FLAG_WRITE);
if (ret < 0) {
fprintf(stderr, "Cannot open output file. "
"Error code: %s\n", av_err2str(ret));
goto end;
}
/* read all packets and only transcoding video */
while (ret >= 0) {
if ((ret = av_read_frame(ifmt_ctx, &dec_pkt)) < 0)
break;
if (video_stream == dec_pkt.stream_index)
ret = dec_enc(&dec_pkt, enc_codec);
av_packet_unref(&dec_pkt);
}
/* flush decoder */
dec_pkt.data = NULL;
dec_pkt.size = 0;
ret = dec_enc(&dec_pkt, enc_codec);
av_packet_unref(&dec_pkt);
/* flush encoder */
ret = encode_write(NULL);
/* write the trailer for output stream */
av_write_trailer(ofmt_ctx);
end:
avformat_close_input(&ifmt_ctx);
avformat_close_input(&ofmt_ctx);
avcodec_free_context(&decoder_ctx);
avcodec_free_context(&encoder_ctx);
av_buffer_unref(&hw_device_ctx);
return ret;
}