diff --git a/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj b/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj index f1d63d81a..5496ce859 100644 --- a/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj +++ b/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj @@ -19,7 +19,6 @@ 8352D49B1CDDB8B2009D16AA /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8352D49A1CDDB8B2009D16AA /* VideoToolbox.framework */; }; 8352D49D1CDDB8C0009D16AA /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8352D49C1CDDB8C0009D16AA /* CoreMedia.framework */; }; 8352D49F1CDDB8D7009D16AA /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8352D49E1CDDB8D7009D16AA /* CoreVideo.framework */; }; - 8352D4A21CDDC0BC009D16AA /* FFMPEGFileProtocols.m in Sources */ = {isa = PBXBuildFile; fileRef = 8352D4A11CDDC0BC009D16AA /* FFMPEGFileProtocols.m */; }; 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; B09E942F0D747F410064F138 /* FFMPEGDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = B09E942E0D747F410064F138 /* FFMPEGDecoder.m */; }; /* End PBXBuildFile section */ @@ -41,8 +40,6 @@ 8352D49A1CDDB8B2009D16AA /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; }; 8352D49C1CDDB8C0009D16AA /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; 8352D49E1CDDB8D7009D16AA /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; }; - 8352D4A01CDDC0BC009D16AA /* FFMPEGFileProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFMPEGFileProtocols.h; sourceTree = ""; }; - 8352D4A11CDDC0BC009D16AA /* FFMPEGFileProtocols.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFMPEGFileProtocols.m; sourceTree = ""; }; 8384913818081F6C00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* FFMPEG.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FFMPEG.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -119,8 +116,6 @@ B09E94370D747FAD0064F138 /* Plugin.h */, B09E942D0D747F410064F138 /* FFMPEGDecoder.h */, B09E942E0D747F410064F138 /* FFMPEGDecoder.m */, - 8352D4A01CDDC0BC009D16AA /* FFMPEGFileProtocols.h */, - 8352D4A11CDDC0BC009D16AA /* FFMPEGFileProtocols.m */, ); name = Classes; sourceTree = ""; @@ -226,7 +221,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8352D4A21CDDC0BC009D16AA /* FFMPEGFileProtocols.m in Sources */, B09E942F0D747F410064F138 /* FFMPEGDecoder.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Plugins/FFMPEG/FFMPEGDecoder.h b/Plugins/FFMPEG/FFMPEGDecoder.h index efe828e58..6af899e8e 100644 --- a/Plugins/FFMPEG/FFMPEGDecoder.h +++ b/Plugins/FFMPEG/FFMPEGDecoder.h @@ -14,6 +14,7 @@ @interface FFMPEGDecoder : NSObject { + id source; BOOL seekable; int channels; int bitsPerSample; @@ -24,6 +25,8 @@ int bitrate; @private + unsigned char *buffer; + AVIOContext *ioCtx; int streamIndex; AVFormatContext *formatCtx; AVCodecContext *codecCtx; diff --git a/Plugins/FFMPEG/FFMPEGDecoder.m b/Plugins/FFMPEG/FFMPEGDecoder.m index fd57ecb31..f1e4e1437 100644 --- a/Plugins/FFMPEG/FFMPEGDecoder.m +++ b/Plugins/FFMPEG/FFMPEGDecoder.m @@ -8,7 +8,6 @@ // test #import "FFMPEGDecoder.h" -#import "FFMPEGFileProtocols.h" #include @@ -16,6 +15,23 @@ #define ST_BUFF 2048 +int ffmpeg_read(void *opaque, uint8_t *buf, int buf_size) +{ + id source = (__bridge id) opaque; + return (int) [source read:buf amount:buf_size]; +} + +int ffmpeg_write(void *opaque, uint8_t *buf, int buf_size) +{ + return -1; +} + +int64_t ffmpeg_seek(void *opaque, int64_t offset, int whence) +{ + id source = (__bridge id) opaque; + return [source seek:offset whence:whence] ? [source tell] : -1; +} + @implementation FFMPEGDecoder @@ -52,7 +68,6 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) av_log_set_flags(AV_LOG_SKIP_REPEATED); av_log_set_level(AV_LOG_ERROR); av_register_all(); - registerCogProtocols(); av_lockmgr_register(lockmgr_callback); } } @@ -65,6 +80,8 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) lastDecodedFrame = NULL; codecCtx = NULL; formatCtx = NULL; + ioCtx = NULL; + buffer = NULL; } return self; } @@ -72,32 +89,60 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) - (BOOL)open:(id)s { int errcode, i; - const char *filename = [[[[s url] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] UTF8String]; + + source = s; formatCtx = NULL; totalFrames = 0; framesRead = 0; // register all available codecs + + buffer = av_malloc(128 * 1024); + if (!buffer) + { + ALog(@"Out of memory!"); + return NO; + } + + ioCtx = avio_alloc_context(buffer, 128 * 1024, 0, (__bridge void *)source, ffmpeg_read, ffmpeg_write, ffmpeg_seek); + if (!ioCtx) + { + ALog(@"Unable to create AVIO context"); + return NO; + } + + formatCtx = avformat_alloc_context(); + if (!formatCtx) + { + ALog(@"Unable to allocate AVFormat context"); + return NO; + } + + formatCtx->pb = ioCtx; - if ((errcode = avformat_open_input(&formatCtx, filename, NULL, NULL)) < 0) + if ((errcode = avformat_open_input(&formatCtx, "", NULL, NULL)) < 0) { char errDescr[4096]; av_strerror(errcode, errDescr, 4096); - ALog(@"ERROR OPENING FILE, errcode = %d, error = %s", errcode, errDescr); + ALog(@"Error opening file, errcode = %d, error = %s", errcode, errDescr); return NO; } - if(avformat_find_stream_info(formatCtx, NULL) < 0) + if((errcode = avformat_find_stream_info(formatCtx, NULL)) < 0) { - ALog(@"CAN'T FIND STREAM INFO!"); + char errDescr[4096]; + av_strerror(errcode, errDescr, 4096); + ALog(@"Can't find stream info, errcode = %d, error = %s", errcode, errDescr); return NO; } streamIndex = -1; + AVCodecParameters *codecPar; + for(i = 0; i < formatCtx->nb_streams; i++) { - codecCtx = formatCtx->streams[i]->codec; - if(codecCtx->codec_type == AVMEDIA_TYPE_AUDIO) + codecPar = formatCtx->streams[i]->codecpar; + if(codecPar->codec_type == AVMEDIA_TYPE_AUDIO) { DLog(@"audio codec found"); streamIndex = i; @@ -109,6 +154,23 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) ALog(@"no audio codec found"); return NO; } + + codecCtx = avcodec_alloc_context3(NULL); + if (!codecCtx) + { + ALog(@"could not allocate codec context"); + return NO; + } + + if ( (errcode = avcodec_parameters_to_context(codecCtx, codecPar)) < 0 ) + { + char errDescr[4096]; + av_strerror(errcode, errDescr, 4096); + ALog(@"Can't copy codec parameters to context, errcode = %d, error = %s", errcode, errDescr); + return NO; + } + + av_codec_set_pkt_timebase(codecCtx, formatCtx->streams[streamIndex]->time_base); AVCodec * codec = avcodec_find_decoder(codecCtx->codec_id); if (!codec) { @@ -116,8 +178,10 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) return NO; } - if (avcodec_open2(codecCtx, codec, NULL) < 0) { - ALog(@"could not open codec"); + if ( (errcode = avcodec_open2(codecCtx, codec, NULL)) < 0) { + char errDescr[4096]; + av_strerror(errcode, errDescr, 4096); + ALog(@"could not open codec, errcode = %d, error = %s", errcode, errDescr); return NO; } @@ -165,7 +229,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) } totalFrames = codecCtx->sample_rate * ((float)formatCtx->duration/AV_TIME_BASE); - bitrate = (codecCtx->bit_rate) / 1000; + bitrate = (int)((codecCtx->bit_rate) / 1000); framesRead = 0; endOfStream = NO; @@ -188,9 +252,13 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) if (lastDecodedFrame) { av_free(lastDecodedFrame); lastDecodedFrame = NULL; } - if (codecCtx) { avcodec_close(codecCtx); codecCtx = NULL; } + if (codecCtx) { avcodec_close(codecCtx); avcodec_free_context(&codecCtx); codecCtx = NULL; } if (formatCtx) { avformat_close_input(&(formatCtx)); formatCtx = NULL; } + + if (ioCtx) { av_free(ioCtx); ioCtx = NULL; buffer = NULL; } + + if (buffer) { av_free(buffer); buffer = NULL; } } - (void)dealloc @@ -210,6 +278,8 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) int bytesToRead = frames * frameSize; int bytesRead = 0; + int errcode; + int8_t* targetBuf = (int8_t*) buf; memset(buf, 0, bytesToRead); @@ -230,10 +300,14 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) { // consume next chunk of encoded data from input stream av_packet_unref(lastReadPacket); - if(av_read_frame(formatCtx, lastReadPacket) < 0) + if((errcode = av_read_frame(formatCtx, lastReadPacket)) < 0) { - DLog(@"End of stream"); - endOfStream = YES; + if (errcode == AVERROR_EOF) + { + DLog(@"End of stream"); + endOfStream = YES; + } + if (formatCtx->pb && formatCtx->pb->error) break; } if (lastReadPacket->stream_index != streamIndex) @@ -269,10 +343,9 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) } while (!gotFrame && len > 0); if (len < 0) { - char errbuf[4096]; - av_strerror(len, errbuf, 4096); - ALog(@"Error decoding: len = %d, gotFrame = %d, strerr = %s", len, gotFrame, errbuf); - + char errDescr[4096]; + av_strerror(len, errDescr, 4096); + ALog(@"Error decoding packet, gotFrame = %d, errcode = %d, error = %s", gotFrame, len, errDescr); dataSize = 0; readNextPacket = YES; } @@ -313,7 +386,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) int framesReadNow = bytesRead / frameSize; if ( totalFrames && ( framesRead + framesReadNow > totalFrames ) ) - framesReadNow = totalFrames - framesRead; + framesReadNow = (int)(totalFrames - framesRead); framesRead += framesReadNow; @@ -361,7 +434,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) + (NSArray *)fileTypes { - return [NSArray arrayWithObjects:@"wma", @"asf", @"xwma", @"tak", @"mp3", @"mp2", @"m2a", @"mpa", @"ape", @"ac3", @"dts", @"dtshd", @"at3", @"wav", @"tta", @"vqf", @"vqe", @"vql", nil]; + return [NSArray arrayWithObjects:@"wma", @"asf", @"xwma", @"xma", @"tak", @"mp3", @"mp2", @"m2a", @"mpa", @"ape", @"ac3", @"dts", @"dtshd", @"at3", @"wav", @"tta", @"vqf", @"vqe", @"vql", nil]; } + (NSArray *)mimeTypes diff --git a/Plugins/FFMPEG/FFMPEGFileProtocols.h b/Plugins/FFMPEG/FFMPEGFileProtocols.h deleted file mode 100644 index 8fc55c6b5..000000000 --- a/Plugins/FFMPEG/FFMPEGFileProtocols.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// FFMPEGFileProtocols.h -// FFMPEG -// -// Created by Christopher Snowhill on 10/4/13. -// Copyright 2013 __NoWork, Inc__. All rights reserved. -// - -#ifdef __cplusplus -extern "C" { -#endif -extern void registerCogProtocols(); -#ifdef __cplusplus -}; -#endif \ No newline at end of file diff --git a/Plugins/FFMPEG/FFMPEGFileProtocols.m b/Plugins/FFMPEG/FFMPEGFileProtocols.m deleted file mode 100644 index 1655304e0..000000000 --- a/Plugins/FFMPEG/FFMPEGFileProtocols.m +++ /dev/null @@ -1,150 +0,0 @@ -// -// FFMPEGFileProtocols.m -// FFMPEG -// -// Created by Christopher Snowhill on 10/4/13. -// Copyright 2013 __NoWork, Inc__. All rights reserved. -// - -#include "Plugin.h" - -#include -#include // INTERNAL -#include - -/* standard file protocol */ - -typedef struct FileContext { - const AVClass *class; - void *fd; -} FileContext; - -static const AVOption file_options[] = { - { NULL } -}; - -static const AVClass file_class = { - .class_name = "file", - .item_name = av_default_item_name, - .option = file_options, - .version = LIBAVUTIL_VERSION_INT, -}; - -static const AVClass http_class = { - .class_name = "http", - .item_name = av_default_item_name, - .option = file_options, - .version = LIBAVUTIL_VERSION_INT, -}; - -static const AVClass unpack_class = { - .class_name = "unpack", - .item_name = av_default_item_name, - .option = file_options, - .version = LIBAVUTIL_VERSION_INT, -}; - -static int file_read(URLContext *h, unsigned char *buf, int size) -{ - FileContext *c = h->priv_data; - NSObject* _fd = (__bridge NSObject *)(c->fd); - id __unsafe_unretained fd = (id) _fd; - return [fd read:buf amount:size]; -} - -static int file_check(URLContext *h, int mask) -{ - return mask & AVIO_FLAG_READ; -} - -static int file_open(URLContext *h, const char *filename, int flags) -{ - FileContext *c = h->priv_data; - id fd; - - if (flags & AVIO_FLAG_WRITE) { - return -1; - } - - NSString * urlString = [NSString stringWithUTF8String:filename]; - NSURL * url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; - - id audioSourceClass = NSClassFromString(@"AudioSource"); - fd = [audioSourceClass audioSourceForURL:url]; - - if (![fd open:url]) - return -1; - - c->fd = (void*)CFBridgingRetain(fd); - - return 0; -} - -static int http_open(URLContext *h, const char *filename, int flags) -{ - int rval = file_open( h, filename, flags ); - h->is_streamed = 1; - return rval; -} - -/* XXX: use llseek */ -static int64_t file_seek(URLContext *h, int64_t pos, int whence) -{ - FileContext *c = h->priv_data; - NSObject* _fd = (__bridge NSObject *)(c->fd); - id __unsafe_unretained fd = (id) _fd; - return [fd seek:pos whence:whence] ? [fd tell] : -1; -} - -static int64_t http_seek(URLContext *h, int64_t pos, int whence) -{ - return -1; -} - -static int file_close(URLContext *h) -{ - FileContext *c = h->priv_data; - CFBridgingRelease(c->fd); - return 0; -} - -static URLProtocol ff_file_protocol = { - .name = "file", - .url_open = file_open, - .url_read = file_read, - .url_seek = file_seek, - .url_close = file_close, - .url_check = file_check, - .priv_data_size = sizeof(FileContext), - .priv_data_class = &file_class, -}; - -static URLProtocol ff_http_protocol = { - .name = "http", - .url_open = http_open, - .url_read = file_read, - .url_seek = http_seek, - .url_close = file_close, - .url_check = file_check, - .priv_data_size = sizeof(FileContext), - .flags = URL_PROTOCOL_FLAG_NETWORK, - .priv_data_class = &http_class, -}; - -static URLProtocol ff_unpack_protocol = { - .name = "unpack", - .url_open = file_open, - .url_read = file_read, - .url_seek = file_seek, - .url_close = file_close, - .url_check = file_check, - .priv_data_size = sizeof(FileContext), - .priv_data_class = &unpack_class, -}; - -void registerCogProtocols() -{ - ffurl_register_protocol(&ff_file_protocol); - ffurl_register_protocol(&ff_http_protocol); - ffurl_register_protocol(&ff_unpack_protocol); -} diff --git a/Scripts/ffmpeg-build.sh b/Scripts/ffmpeg-build.sh index 40ebddaba..a5682e1c8 100755 --- a/Scripts/ffmpeg-build.sh +++ b/Scripts/ffmpeg-build.sh @@ -8,13 +8,14 @@ --disable-dxva2 --enable-hwaccels\ --disable-encoders --disable-muxers --disable-indevs --disable-outdevs\ --disable-devices --disable-filters --disable-parsers --enable-parser=ac3\ + --enable-parser=mpegaudio\ --enable-demuxer=ac3 --disable-bsfs --disable-bzlib --disable-protocols\ --disable-decoders --disable-decoder=libopus --disable-libopus\ --enable-decoder=wmapro --enable-decoder=wmav1 --enable-decoder=wmav2\ --enable-decoder=wmavoice --enable-decoder=wmalossless --enable-decoder=xma1\ --enable-decoder=xma2 --enable-decoder=dca --enable-decoder=ac3\ --disable-decoder=amrnb\ - --disable-demuxers --enable-demuxer=asf\ + --disable-demuxers --enable-demuxer=asf --enable-demuxer=xwma\ --enable-demuxer=mov --enable-demuxer=oma --enable-demuxer=ac3\ --disable-demuxer=amr --enable-demuxer=ogg\ --enable-demuxer=tak --enable-decoder=tak\ @@ -26,7 +27,6 @@ --enable-demuxer=dts --enable-demuxer=dtshd\ --enable-demuxer=mp3 --enable-decoder=mp3float\ --disable-libopencore-amrnb --disable-libopencore-amrwb\ - --disable-version3 --disable-mmx\ - --disable-yasm + --disable-version3 make -j8 diff --git a/ThirdParty/ffmpeg/include/libavcodec/avcodec.h b/ThirdParty/ffmpeg/include/libavcodec/avcodec.h index d8497655b..39713ed76 100644 --- a/ThirdParty/ffmpeg/include/libavcodec/avcodec.h +++ b/ThirdParty/ffmpeg/include/libavcodec/avcodec.h @@ -70,7 +70,95 @@ * @{ * @} * @} + */ + +/** + * @ingroup libavc + * @defgroup lavc_encdec send/receive encoding and decoding API overview + * @{ * + * The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/ + * avcodec_receive_packet() functions provide an encode/decode API, which + * decouples input and output. + * + * The API is very similar for encoding/decoding and audio/video, and works as + * follows: + * - Set up and open the AVCodecContext as usual. + * - Send valid input: + * - For decoding, call avcodec_send_packet() to give the decoder raw + * compressed data in an AVPacket. + * - For encoding, call avcodec_send_frame() to give the decoder an AVFrame + * containing uncompressed audio or video. + * In both cases, it is recommended that AVPackets and AVFrames are + * refcounted, or libavcodec might have to copy the input data. (libavformat + * always returns refcounted AVPackets, and av_frame_get_buffer() allocates + * refcounted AVFrames.) + * - Receive output in a loop. Periodically call one of the avcodec_receive_*() + * functions and process their output: + * - For decoding, call avcodec_receive_frame(). On success, it will return + * an AVFrame containing uncompressed audio or video data. + * - For encoding, call avcodec_receive_packet(). On success, it will return + * an AVPacket with a compressed frame. + * Repeat this call until it returns AVERROR(EAGAIN) or an error. The + * AVERROR(EAGAIN) return value means that new input data is required to + * return new output. In this case, continue with sending input. For each + * input frame/packet, the codec will typically return 1 output frame/packet, + * but it can also be 0 or more than 1. + * + * At the beginning of decoding or encoding, the codec might accept multiple + * input frames/packets without returning a frame, until its internal buffers + * are filled. This situation is handled transparently if you follow the steps + * outlined above. + * + * End of stream situations. These require "flushing" (aka draining) the codec, + * as the codec might buffer multiple frames or packets internally for + * performance or out of necessity (consider B-frames). + * This is handled as follows: + * - Instead of valid input, send NULL to the avcodec_send_packet() (decoding) + * or avcodec_send_frame() (encoding) functions. This will enter draining + * mode. + * - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet() + * (encoding) in a loop until AVERROR_EOF is returned. The functions will + * not return AVERROR(EAGAIN), unless you forgot to enter draining mode. + * - Before decoding can be resumed again, the codec has to be reset with + * avcodec_flush_buffers(). + * + * Using the API as outlined above is highly recommended. But it is also + * possible to call functions outside of this rigid schema. For example, you can + * call avcodec_send_packet() repeatedly without calling + * avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed + * until the codec's internal buffer has been filled up (which is typically of + * size 1 per output frame, after initial input), and then reject input with + * AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to + * read at least some output. + * + * Not all codecs will follow a rigid and predictable dataflow; the only + * guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on + * one end implies that a receive/send call on the other end will succeed. In + * general, no codec will permit unlimited buffering of input or output. + * + * This API replaces the following legacy functions: + * - avcodec_decode_video2() and avcodec_decode_audio4(): + * Use avcodec_send_packet() to feed input to the decoder, then use + * avcodec_receive_frame() to receive decoded frames after each packet. + * Unlike with the old video decoding API, multiple frames might result from + * a packet. For audio, splitting the input packet into frames by partially + * decoding packets becomes transparent to the API user. You never need to + * feed an AVPacket to the API twice. + * Additionally, sending a flush/draining packet is required only once. + * - avcodec_encode_video2()/avcodec_encode_audio2(): + * Use avcodec_send_frame() to feed input to the encoder, then use + * avcodec_receive_packet() to receive encoded packets. + * Providing user-allocated buffers for avcodec_receive_packet() is not + * possible. + * - The new API does not handle subtitles yet. + * + * Mixing new and old function calls on the same AVCodecContext is not allowed, + * and will result in undefined behavior. + * + * Some codecs might require using the new API; using the old API will return + * an error when calling it. + * @} */ /** @@ -92,7 +180,7 @@ * details. * * If you add a codec ID to this list, add it so that - * 1. no value of a existing codec ID changes (that would break ABI), + * 1. no value of an existing codec ID changes (that would break ABI), * 2. it is as close as possible to similar codecs * * After adding new codec IDs, do not forget to add an entry to the codec @@ -316,6 +404,11 @@ enum AVCodecID { AV_CODEC_ID_APNG, AV_CODEC_ID_DAALA, AV_CODEC_ID_CFHD, + AV_CODEC_ID_TRUEMOTION2RT, + AV_CODEC_ID_M101, + AV_CODEC_ID_MAGICYUV, + AV_CODEC_ID_SHEERVIDEO, + AV_CODEC_ID_YLC, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -398,6 +491,8 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_THP_LE, AV_CODEC_ID_ADPCM_PSX, AV_CODEC_ID_ADPCM_AICA, + AV_CODEC_ID_ADPCM_IMA_DAT4, + AV_CODEC_ID_ADPCM_MTAF, /* AMR */ AV_CODEC_ID_AMR_NB = 0x12000, @@ -500,6 +595,7 @@ enum AVCodecID { AV_CODEC_ID_INTERPLAY_ACM, AV_CODEC_ID_XMA1, AV_CODEC_ID_XMA2, + AV_CODEC_ID_DST, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. @@ -785,7 +881,7 @@ typedef struct RcOverride{ * Use only bitexact stuff (except (I)DCT). */ #define AV_CODEC_FLAG_BITEXACT (1 << 23) -/* Fx : Flag for h263+ extra options */ +/* Fx : Flag for H.263+ extra options */ /** * H.263 advanced intra coding / MPEG-4 AC prediction */ @@ -836,6 +932,10 @@ typedef struct RcOverride{ * Do not skip samples and export skip information as frame side data */ #define AV_CODEC_FLAG2_SKIP_MANUAL (1 << 29) +/** + * Do not reset ASS ReadOrder field on flush (subtitles decoding) + */ +#define AV_CODEC_FLAG2_RO_FLUSH_NOOP (1 << 30) /* Unsupported options : * Syntax Arithmetic coding (SAC) @@ -898,7 +998,7 @@ typedef struct RcOverride{ * are connected to a parser to split what they return into proper frames. * This flag is reserved to the very rare category of codecs which have a * bitstream that cannot be split into frames without timeconsuming - * operations like full decoding. Demuxers carring such bitstreams thus + * operations like full decoding. Demuxers carrying such bitstreams thus * may return multiple frames in a packet. This has many disadvantages like * prohibiting stream copy in many cases thus it should only be considered * as a last resort. @@ -1078,7 +1178,7 @@ typedef struct RcOverride{ * are connected to a parser to split what they return into proper frames. * This flag is reserved to the very rare category of codecs which have a * bitstream that cannot be split into frames without timeconsuming - * operations like full decoding. Demuxers carring such bitstreams thus + * operations like full decoding. Demuxers carrying such bitstreams thus * may return multiple frames in a packet. This has many disadvantages like * prohibiting stream copy in many cases thus it should only be considered * as a last resort. @@ -1158,7 +1258,7 @@ typedef struct RcOverride{ #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) #define MB_TYPE_QUANT 0x00010000 #define MB_TYPE_CBP 0x00020000 -//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) +// Note bits 24-31 are reserved for codec specific use (H.264 ref0, MPEG-1 0mv, ...) #endif /** @@ -1403,6 +1503,19 @@ enum AVPacketSideDataType { * side data includes updated metadata which appeared in the stream. */ AV_PKT_DATA_METADATA_UPDATE, + + /** + * MPEGTS stream ID, this is required to pass the stream ID + * information from the demuxer to the corresponding muxer. + */ + AV_PKT_DATA_MPEGTS_STREAM_ID, + + /** + * Mastering display metadata (based on SMPTE-2086:2014). This metadata + * should be associated with a video stream and containts data in the form + * of the AVMasteringDisplayMetadata struct. + */ + AV_PKT_DATA_MASTERING_DISPLAY_METADATA }; #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED @@ -1527,6 +1640,10 @@ enum AVFieldOrder { * version bump. * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user * applications. + * The name string for AVOptions options matches the associated command line + * parameter name and can be found in libavcodec/options_table.h + * The AVOption/command line parameter names differ in some cases from the C + * structure field names for historic reasons or brevity. * sizeof(AVCodecContext) must not be used outside libav*. */ typedef struct AVCodecContext { @@ -1635,9 +1752,9 @@ typedef struct AVCodecContext { /** * some codecs need / can use extradata like Huffman tables. - * mjpeg: Huffman tables + * MJPEG: Huffman tables * rv10: additional flags - * mpeg4: global headers (they can be in the bitstream or here) + * MPEG-4: global headers (they can be in the bitstream or here) * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger * than extradata_size to avoid problems if it is read with the bitstream reader. * The bytewise contents of extradata must not depend on the architecture or CPU endianness. @@ -1653,7 +1770,15 @@ typedef struct AVCodecContext { * timebase should be 1/framerate and timestamp increments should be * identically 1. * This often, but not always is the inverse of the frame rate or field rate - * for video. + * for video. 1/time_base is not the average frame rate if the frame rate is not + * constant. + * + * Like containers, elementary streams also can store timestamps, 1/time_base + * is the unit in which these timestamps are specified. + * As example of such codec time base see ISO/IEC 14496-2:2001(E) + * vop_time_increment_resolution and fixed_vop_rate + * (fixed_vop_rate == 0 implies that it is different from the framerate) + * * - encoding: MUST be set by user. * - decoding: the use of this field for decoding is deprecated. * Use framerate instead. @@ -1699,7 +1824,7 @@ typedef struct AVCodecContext { * picture width / height. * * @note Those fields may not match the values of the last - * AVFrame outputted by avcodec_decode_video2 due frame + * AVFrame output by avcodec_decode_video2 due frame * reordering. * * - encoding: MUST be set by user. @@ -1715,7 +1840,7 @@ typedef struct AVCodecContext { * the decoded frame is cropped before being output or lowres is enabled. * * @note Those field may not match the value of the last - * AVFrame outputted by avcodec_decode_video2 due frame + * AVFrame output by avcodec_receive_frame() due frame * reordering. * * - encoding: unused @@ -1742,7 +1867,7 @@ typedef struct AVCodecContext { * May be overridden by the decoder if it knows better. * * @note This field may not match the value of the last - * AVFrame outputted by avcodec_decode_video2 due frame + * AVFrame output by avcodec_receive_frame() due frame * reordering. * * - encoding: Set by user. @@ -1852,8 +1977,8 @@ typedef struct AVCodecContext { #endif /** - * qscale factor between P and I-frames - * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset). + * qscale factor between P- and I-frames + * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset). * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). * - encoding: Set by user. * - decoding: unused @@ -2065,7 +2190,7 @@ typedef struct AVCodecContext { */ int slice_flags; #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display -#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics) +#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics) #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1) #if FF_API_XVMC @@ -2156,14 +2281,14 @@ typedef struct AVCodecContext { #endif /** - * minimum MB lagrange multipler + * minimum MB Lagrange multiplier * - encoding: Set by user. * - decoding: unused */ int mb_lmin; /** - * maximum MB lagrange multipler + * maximum MB Lagrange multiplier * - encoding: Set by user. * - decoding: unused */ @@ -2178,7 +2303,6 @@ typedef struct AVCodecContext { #endif /** - * * - encoding: Set by user. * - decoding: unused */ @@ -2220,7 +2344,6 @@ typedef struct AVCodecContext { #endif /** - * * Note: Value depends upon the compare function used for fullpel ME. * - encoding: Set by user. * - decoding: unused @@ -2385,7 +2508,7 @@ typedef struct AVCodecContext { * to all data planes. data[] must hold as many pointers as it can. * extended_data must be allocated with av_malloc() and will be freed in * av_frame_unref(). - * * otherwise exended_data must point to data + * * otherwise extended_data must point to data * - buf[] must contain one or more pointers to AVBufferRef structures. Each of * the frame's data and extended_data pointers must be contained in these. That * is, one AVBufferRef for each allocated chunk of memory, not necessarily one @@ -2449,6 +2572,8 @@ typedef struct AVCodecContext { * Otherwise, the decoded frames must not be freed by the caller and are * only valid until the next decode call. * + * This is always automatically enabled if avcodec_receive_frame() is used. + * * - encoding: unused * - decoding: set by the caller before avcodec_open2(). */ @@ -2727,7 +2852,7 @@ typedef struct AVCodecContext { #define FF_BUG_TRUNCATED 16384 /** - * strictly follow the standard (MPEG4, ...). + * strictly follow the standard (MPEG-4, ...). * - encoding: Set by user. * - decoding: Set by user. * Setting this to STRICT or higher means the encoder and decoder will @@ -2798,9 +2923,9 @@ typedef struct AVCodecContext { * - decoding: Set by user. */ int debug_mv; -#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames -#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames -#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames +#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 // visualize forward predicted MVs of P-frames +#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 // visualize forward predicted MVs of B-frames +#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 // visualize backward predicted MVs of B-frames #endif /** @@ -2828,7 +2953,7 @@ typedef struct AVCodecContext { /** - * opaque 64bit number (generally a PTS) that will be reordered and + * opaque 64-bit number (generally a PTS) that will be reordered and * output in AVFrame.reordered_opaque * - encoding: unused * - decoding: Set by user. @@ -3093,9 +3218,9 @@ typedef struct AVCodecContext { #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15 -#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 0 -#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 1 -#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 2 +#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1 +#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2 +#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768 #define FF_PROFILE_JPEG2000_DCINEMA_2K 3 #define FF_PROFILE_JPEG2000_DCINEMA_4K 4 @@ -3207,7 +3332,8 @@ typedef struct AVCodecContext { * - decoding: For codecs that store a framerate value in the compressed * bitstream, the decoder may export it here. { 0, 1} when * unknown. - * - encoding: unused + * - encoding: May be used to signal the framerate of CFR content to an + * encoder. */ AVRational framerate; @@ -3355,6 +3481,30 @@ typedef struct AVCodecContext { AVPacketSideData *coded_side_data; int nb_coded_side_data; + /** + * Encoding only. + * + * For hardware encoders configured to use a hwaccel pixel format, this + * field should be set by the caller to a reference to the AVHWFramesContext + * describing input frames. AVHWFramesContext.format must be equal to + * AVCodecContext.pix_fmt. + * + * This field should be set before avcodec_open2() is called and is + * afterwards owned and managed by libavcodec. + */ + AVBufferRef *hw_frames_ctx; + + /** + * Control the form of AVSubtitle.rects[N]->ass + * - decoding: set by user + * - encoding: unused + */ + int sub_text_format; +#define FF_SUB_TEXT_FMT_ASS 0 +#if FF_API_ASS_TIMING +#define FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS 1 +#endif + } AVCodecContext; AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx); @@ -3474,6 +3624,21 @@ typedef struct AVCodec { int *got_packet_ptr); int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); int (*close)(AVCodecContext *); + /** + * Decode/encode API with decoupled packet/frame dataflow. The API is the + * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except + * that: + * - never called if the codec is closed or the wrong type, + * - AVPacket parameter change side data is applied right before calling + * AVCodec->send_packet, + * - if AV_CODEC_CAP_DELAY is not set, drain packets or frames are never sent, + * - only one drain packet is ever passed down (until the next flush()), + * - a drain AVPacket is always NULL (no need to check for avpkt->size). + */ + int (*send_frame)(AVCodecContext *avctx, const AVFrame *frame); + int (*send_packet)(AVCodecContext *avctx, const AVPacket *avpkt); + int (*receive_frame)(AVCodecContext *avctx, AVFrame *frame); + int (*receive_packet)(AVCodecContext *avctx, AVPacket *avpkt); /** * Flush buffers. * Will be called when seeking @@ -3739,6 +3904,164 @@ typedef struct AVSubtitle { int64_t pts; ///< Same as packet pts, in AV_TIME_BASE } AVSubtitle; +/** + * This struct describes the properties of an encoded stream. + * + * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must + * be allocated with avcodec_parameters_alloc() and freed with + * avcodec_parameters_free(). + */ +typedef struct AVCodecParameters { + /** + * General type of the encoded data. + */ + enum AVMediaType codec_type; + /** + * Specific type of the encoded data (the codec used). + */ + enum AVCodecID codec_id; + /** + * Additional information about the codec (corresponds to the AVI FOURCC). + */ + uint32_t codec_tag; + + /** + * Extra binary data needed for initializing the decoder, codec-dependent. + * + * Must be allocated with av_malloc() and will be freed by + * avcodec_parameters_free(). The allocated size of extradata must be at + * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding + * bytes zeroed. + */ + uint8_t *extradata; + /** + * Size of the extradata content in bytes. + */ + int extradata_size; + + /** + * - video: the pixel format, the value corresponds to enum AVPixelFormat. + * - audio: the sample format, the value corresponds to enum AVSampleFormat. + */ + int format; + + /** + * The average bitrate of the encoded data (in bits per second). + */ + int64_t bit_rate; + + /** + * The number of bits per sample in the codedwords. + * + * This is basically the bitrate per sample. It is mandatory for a bunch of + * formats to actually decode them. It's the number of bits for one sample in + * the actual coded bitstream. + * + * This could be for example 4 for ADPCM + * For PCM formats this matches bits_per_raw_sample + * Can be 0 + */ + int bits_per_coded_sample; + + /** + * This is the number of valid bits in each output sample. If the + * sample format has more bits, the least significant bits are additional + * padding bits, which are always 0. Use right shifts to reduce the sample + * to its actual size. For example, audio formats with 24 bit samples will + * have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32. + * To get the original sample use "(int32_t)sample >> 8"." + * + * For ADPCM this might be 12 or 16 or similar + * Can be 0 + */ + int bits_per_raw_sample; + + /** + * Codec-specific bitstream restrictions that the stream conforms to. + */ + int profile; + int level; + + /** + * Video only. The dimensions of the video frame in pixels. + */ + int width; + int height; + + /** + * Video only. The aspect ratio (width / height) which a single pixel + * should have when displayed. + * + * When the aspect ratio is unknown / undefined, the numerator should be + * set to 0 (the denominator may have any value). + */ + AVRational sample_aspect_ratio; + + /** + * Video only. The order of the fields in interlaced video. + */ + enum AVFieldOrder field_order; + + /** + * Video only. Additional colorspace characteristics. + */ + enum AVColorRange color_range; + enum AVColorPrimaries color_primaries; + enum AVColorTransferCharacteristic color_trc; + enum AVColorSpace color_space; + enum AVChromaLocation chroma_location; + + /** + * Video only. Number of delayed frames. + */ + int video_delay; + + /** + * Audio only. The channel layout bitmask. May be 0 if the channel layout is + * unknown or unspecified, otherwise the number of bits set must be equal to + * the channels field. + */ + uint64_t channel_layout; + /** + * Audio only. The number of audio channels. + */ + int channels; + /** + * Audio only. The number of audio samples per second. + */ + int sample_rate; + /** + * Audio only. The number of bytes per coded audio frame, required by some + * formats. + * + * Corresponds to nBlockAlign in WAVEFORMATEX. + */ + int block_align; + /** + * Audio only. Audio frame size, if known. Required by some formats to be static. + */ + int frame_size; + + /** + * Audio only. The amount of padding (in samples) inserted by the encoder at + * the beginning of the audio. I.e. this number of leading decoded samples + * must be discarded by the caller to get the original audio without leading + * padding. + */ + int initial_padding; + /** + * Audio only. The amount of padding (in samples) appended by the encoder to + * the end of the audio. I.e. this number of decoded samples must be + * discarded by the caller from the end of the stream to get the original + * audio without any trailing padding. + */ + int trailing_padding; + /** + * Audio only. Number of samples to skip after a discontinuity. + */ + int seek_preroll; +} AVCodecParameters; + /** * If c is NULL, returns the first registered codec, * if c is non-NULL, returns the next registered codec after c, @@ -3795,7 +4118,6 @@ void avcodec_register_all(void); * important mainly for encoders, e.g. libx264). * * @return An AVCodecContext filled with default values or NULL on failure. - * @see avcodec_get_context_defaults */ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); @@ -3805,16 +4127,14 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); */ void avcodec_free_context(AVCodecContext **avctx); +#if FF_API_GET_CONTEXT_DEFAULTS /** - * Set the fields of the given AVCodecContext to default values corresponding - * to the given codec (defaults may be codec-dependent). - * - * Do not call this function if a non-NULL codec has been passed - * to avcodec_alloc_context3() that allocated this AVCodecContext. - * If codec is non-NULL, it is illegal to call avcodec_open2() with a - * different codec on this AVCodecContext. + * @deprecated This function should not be used, as closing and opening a codec + * context multiple time is not supported. A new codec context should be + * allocated for each new use. */ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); +#endif /** * Get the AVClass for AVCodecContext. It can be used in combination with @@ -3824,6 +4144,7 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); */ const AVClass *avcodec_get_class(void); +#if FF_API_COPY_CONTEXT /** * Get the AVClass for AVFrame. It can be used in combination with * AV_OPT_SEARCH_FAKE_OBJ for examining options. @@ -3850,8 +4171,58 @@ const AVClass *avcodec_get_subtitle_rect_class(void); * avcodec_alloc_context3(NULL), but otherwise uninitialized * @param src source codec context * @return AVERROR() on error (e.g. memory allocation error), 0 on success + * + * @deprecated The semantics of this function are ill-defined and it should not + * be used. If you need to transfer the stream parameters from one codec context + * to another, use an intermediate AVCodecParameters instance and the + * avcodec_parameters_from_context() / avcodec_parameters_to_context() + * functions. */ +attribute_deprecated int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); +#endif + +/** + * Allocate a new AVCodecParameters and set its fields to default values + * (unknown/invalid/0). The returned struct must be freed with + * avcodec_parameters_free(). + */ +AVCodecParameters *avcodec_parameters_alloc(void); + +/** + * Free an AVCodecParameters instance and everything associated with it and + * write NULL to the supplied pointer. + */ +void avcodec_parameters_free(AVCodecParameters **par); + +/** + * Copy the contents of src to dst. Any allocated fields in dst are freed and + * replaced with newly allocated duplicates of the corresponding fields in src. + * + * @return >= 0 on success, a negative AVERROR code on failure. + */ +int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src); + +/** + * Fill the parameters struct based on the values from the supplied codec + * context. Any allocated fields in par are freed and replaced with duplicates + * of the corresponding fields in codec. + * + * @return >= 0 on success, a negative AVERROR code on failure + */ +int avcodec_parameters_from_context(AVCodecParameters *par, + const AVCodecContext *codec); + +/** + * Fill the codec context based on the values from the supplied codec + * parameters. Any allocated fields in codec that have a corresponding field in + * par are freed and replaced with duplicates of the corresponding field in par. + * Fields in codec that do not have a counterpart in par are not touched. + * + * @return >= 0 on success, a negative AVERROR code on failure. + */ +int avcodec_parameters_to_context(AVCodecContext *codec, + const AVCodecParameters *par); /** * Initialize the AVCodecContext to use the given AVCodec. Prior to using this @@ -3864,7 +4235,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); * @warning This function is not thread safe! * * @note Always call this function before using decoding routines (such as - * @ref avcodec_decode_video2()). + * @ref avcodec_receive_frame()). * * @code * avcodec_register_all(); @@ -3882,9 +4253,8 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); * @param avctx The context to initialize. * @param codec The codec to open this context for. If a non-NULL codec has been * previously passed to avcodec_alloc_context3() or - * avcodec_get_context_defaults3() for this context, then this - * parameter MUST be either NULL or equal to the previously passed - * codec. + * for this context, then this parameter MUST be either NULL or + * equal to the previously passed codec. * @param options A dictionary filled with AVCodecContext and codec-private options. * On return this object will be filled with options that were not found. * @@ -3899,9 +4269,13 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **op * (but not the AVCodecContext itself). * * Calling this function on an AVCodecContext that hasn't been opened will free - * the codec-specific data allocated in avcodec_alloc_context3() / - * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will - * do nothing. + * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL + * codec. Subsequent calls will do nothing. + * + * @note Do not use this function. Use avcodec_free_context() to destroy a + * codec context (either open or closed). Opening and closing a codec context + * multiple times is not supported anymore -- use multiple codec contexts + * instead. */ int avcodec_close(AVCodecContext *avctx); @@ -4169,7 +4543,6 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src); * @param src Source packet * * @return 0 on success AVERROR on failure. - * */ int av_packet_copy_props(AVPacket *dst, const AVPacket *src); @@ -4324,7 +4697,10 @@ enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos); * @return A negative error code is returned if an error occurred during * decoding, otherwise the number of bytes consumed from the input * AVPacket is returned. + * +* @deprecated Use avcodec_send_packet() and avcodec_receive_frame(). */ +attribute_deprecated int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt); @@ -4370,7 +4746,10 @@ int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. * @return On error a negative value is returned, otherwise the number of bytes * used or zero if no frame could be decompressed. + * + * @deprecated Use avcodec_send_packet() and avcodec_receive_frame(). */ +attribute_deprecated int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt); @@ -4406,6 +4785,129 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt); +/** + * Supply raw packet data as input to a decoder. + * + * Internally, this call will copy relevant AVCodecContext fields, which can + * influence decoding per-packet, and apply them when the packet is actually + * decoded. (For example AVCodecContext.skip_frame, which might direct the + * decoder to drop the frame contained by the packet sent with this function.) + * + * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE + * larger than the actual read bytes because some optimized bitstream + * readers read 32 or 64 bits at once and could read over the end. + * + * @warning Do not mix this API with the legacy API (like avcodec_decode_video2()) + * on the same AVCodecContext. It will return unexpected results now + * or in future libavcodec versions. + * + * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() + * before packets may be fed to the decoder. + * + * @param avctx codec context + * @param[in] avpkt The input AVPacket. Usually, this will be a single video + * frame, or several complete audio frames. + * Ownership of the packet remains with the caller, and the + * decoder will not write to the packet. The decoder may create + * a reference to the packet data (or copy it if the packet is + * not reference-counted). + * Unlike with older APIs, the packet is always fully consumed, + * and if it contains multiple frames (e.g. some audio codecs), + * will require you to call avcodec_receive_frame() multiple + * times afterwards before you can send a new packet. + * It can be NULL (or an AVPacket with data set to NULL and + * size set to 0); in this case, it is considered a flush + * packet, which signals the end of the stream. Sending the + * first flush packet will return success. Subsequent ones are + * unnecessary and will return AVERROR_EOF. If the decoder + * still has frames buffered, it will return them after sending + * a flush packet. + * + * @return 0 on success, otherwise negative error code: + * AVERROR(EAGAIN): input is not accepted right now - the packet must be + * resent after trying to read output + * AVERROR_EOF: the decoder has been flushed, and no new packets can + * be sent to it (also returned if more than 1 flush + * packet is sent) + * AVERROR(EINVAL): codec not opened, it is an encoder, or requires flush + * AVERROR(ENOMEM): failed to add packet to internal queue, or similar + * other errors: legitimate decoding errors + */ +int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt); + +/** + * Return decoded output data from a decoder. + * + * @param avctx codec context + * @param frame This will be set to a reference-counted video or audio + * frame (depending on the decoder type) allocated by the + * decoder. Note that the function will always call + * av_frame_unref(frame) before doing anything else. + * + * @return + * 0: success, a frame was returned + * AVERROR(EAGAIN): output is not available right now - user must try + * to send new input + * AVERROR_EOF: the decoder has been fully flushed, and there will be + * no more output frames + * AVERROR(EINVAL): codec not opened, or it is an encoder + * other negative values: legitimate decoding errors + */ +int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); + +/** + * Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet() + * to retrieve buffered output packets. + * + * @param avctx codec context + * @param[in] frame AVFrame containing the raw audio or video frame to be encoded. + * Ownership of the frame remains with the caller, and the + * encoder will not write to the frame. The encoder may create + * a reference to the frame data (or copy it if the frame is + * not reference-counted). + * It can be NULL, in which case it is considered a flush + * packet. This signals the end of the stream. If the encoder + * still has packets buffered, it will return them after this + * call. Once flushing mode has been entered, additional flush + * packets are ignored, and sending frames will return + * AVERROR_EOF. + * + * For audio: + * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame + * can have any number of samples. + * If it is not set, frame->nb_samples must be equal to + * avctx->frame_size for all frames except the last. + * The final frame may be smaller than avctx->frame_size. + * @return 0 on success, otherwise negative error code: + * AVERROR(EAGAIN): input is not accepted right now - the frame must be + * resent after trying to read output packets + * AVERROR_EOF: the encoder has been flushed, and no new frames can + * be sent to it + * AVERROR(EINVAL): codec not opened, refcounted_frames not set, it is a + * decoder, or requires flush + * AVERROR(ENOMEM): failed to add packet to internal queue, or similar + * other errors: legitimate decoding errors + */ +int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame); + +/** + * Read encoded data from the encoder. + * + * @param avctx codec context + * @param avpkt This will be set to a reference-counted packet allocated by the + * encoder. Note that the function will always call + * av_frame_unref(frame) before doing anything else. + * @return 0 on success, otherwise negative error code: + * AVERROR(EAGAIN): output is not available right now - user must try + * to send input + * AVERROR_EOF: the encoder has been fully flushed, and there will be + * no more output packets + * AVERROR(EINVAL): codec not opened, or it is an encoder + * other errors: legitimate decoding errors + */ +int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt); + + /** * @defgroup lavc_parsing Frame parsing * @{ @@ -4713,7 +5215,10 @@ AVCodec *avcodec_find_encoder_by_name(const char *name); * value of got_packet_ptr is undefined and should * not be used. * @return 0 on success, negative error code on failure + * + * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead */ +attribute_deprecated int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr); @@ -4749,7 +5254,10 @@ int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, * value of got_packet_ptr is undefined and should * not be used. * @return 0 on success, negative error code on failure + * + * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead */ +attribute_deprecated int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr); @@ -5134,7 +5642,13 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id); */ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes); +/** + * This function is the same as av_get_audio_frame_duration(), except it works + * with AVCodecParameters instead of an AVCodecContext. + */ +int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes); +#if FF_API_OLD_BSF typedef struct AVBitStreamFilterContext { void *priv_data; struct AVBitStreamFilter *filter; @@ -5146,19 +5660,102 @@ typedef struct AVBitStreamFilterContext { */ char *args; } AVBitStreamFilterContext; +#endif +typedef struct AVBSFInternal AVBSFInternal; + +/** + * The bitstream filter state. + * + * This struct must be allocated with av_bsf_alloc() and freed with + * av_bsf_free(). + * + * The fields in the struct will only be changed (by the caller or by the + * filter) as described in their documentation, and are to be considered + * immutable otherwise. + */ +typedef struct AVBSFContext { + /** + * A class for logging and AVOptions + */ + const AVClass *av_class; + + /** + * The bitstream filter this context is an instance of. + */ + const struct AVBitStreamFilter *filter; + + /** + * Opaque libavcodec internal data. Must not be touched by the caller in any + * way. + */ + AVBSFInternal *internal; + + /** + * Opaque filter-specific private data. If filter->priv_class is non-NULL, + * this is an AVOptions-enabled struct. + */ + void *priv_data; + + /** + * Parameters of the input stream. Set by the caller before av_bsf_init(). + */ + AVCodecParameters *par_in; + + /** + * Parameters of the output stream. Set by the filter in av_bsf_init(). + */ + AVCodecParameters *par_out; + + /** + * The timebase used for the timestamps of the input packets. Set by the + * caller before av_bsf_init(). + */ + AVRational time_base_in; + + /** + * The timebase used for the timestamps of the output packets. Set by the + * filter in av_bsf_init(). + */ + AVRational time_base_out; +} AVBSFContext; typedef struct AVBitStreamFilter { const char *name; + + /** + * A list of codec ids supported by the filter, terminated by + * AV_CODEC_ID_NONE. + * May be NULL, in that case the bitstream filter works with any codec id. + */ + const enum AVCodecID *codec_ids; + + /** + * A class for the private data, used to declare bitstream filter private + * AVOptions. This field is NULL for bitstream filters that do not declare + * any options. + * + * If this field is non-NULL, the first member of the filter private data + * must be a pointer to AVClass, which will be set by libavcodec generic + * code to this class. + */ + const AVClass *priv_class; + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavcodec and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + int priv_data_size; - int (*filter)(AVBitStreamFilterContext *bsfc, - AVCodecContext *avctx, const char *args, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe); - void (*close)(AVBitStreamFilterContext *bsfc); - struct AVBitStreamFilter *next; + int (*init)(AVBSFContext *ctx); + int (*filter)(AVBSFContext *ctx, AVPacket *pkt); + void (*close)(AVBSFContext *ctx); } AVBitStreamFilter; +#if FF_API_OLD_BSF /** * Register a bitstream filter. * @@ -5168,6 +5765,7 @@ typedef struct AVBitStreamFilter { * * @see avcodec_register_all() */ +attribute_deprecated void av_register_bitstream_filter(AVBitStreamFilter *bsf); /** @@ -5180,6 +5778,7 @@ void av_register_bitstream_filter(AVBitStreamFilter *bsf); * @return a bitstream filter context if a matching filter was found * and successfully initialized, NULL otherwise */ +attribute_deprecated AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); /** @@ -5208,8 +5807,10 @@ AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); * If the return value is 0, the output buffer is not allocated and * should be considered identical to the input buffer, or in case * *poutbuf was set it points to the input buffer (not necessarily to - * its starting address). + * its starting address). A special case is if *poutbuf was set to NULL and + * *poutbuf_size was set to 0, which indicates the packet should be dropped. */ +attribute_deprecated int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, @@ -5221,6 +5822,7 @@ int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, * @param bsf the bitstream filter context created with * av_bitstream_filter_init(), can be NULL */ +attribute_deprecated void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); /** @@ -5231,7 +5833,103 @@ void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); * This function can be used to iterate over all registered bitstream * filters. */ +attribute_deprecated AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f); +#endif + +/** + * @return a bitstream filter with the specified name or NULL if no such + * bitstream filter exists. + */ +const AVBitStreamFilter *av_bsf_get_by_name(const char *name); + +/** + * Iterate over all registered bitstream filters. + * + * @param opaque a pointer where libavcodec will store the iteration state. Must + * point to NULL to start the iteration. + * + * @return the next registered bitstream filter or NULL when the iteration is + * finished + */ +const AVBitStreamFilter *av_bsf_next(void **opaque); + +/** + * Allocate a context for a given bitstream filter. The caller must fill in the + * context parameters as described in the documentation and then call + * av_bsf_init() before sending any data to the filter. + * + * @param filter the filter for which to allocate an instance. + * @param ctx a pointer into which the pointer to the newly-allocated context + * will be written. It must be freed with av_bsf_free() after the + * filtering is done. + * + * @return 0 on success, a negative AVERROR code on failure + */ +int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx); + +/** + * Prepare the filter for use, after all the parameters and options have been + * set. + */ +int av_bsf_init(AVBSFContext *ctx); + +/** + * Submit a packet for filtering. + * + * After sending each packet, the filter must be completely drained by calling + * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or + * AVERROR_EOF. + * + * @param pkt the packet to filter. The bitstream filter will take ownership of + * the packet and reset the contents of pkt. pkt is not touched if an error occurs. + * This parameter may be NULL, which signals the end of the stream (i.e. no more + * packets will be sent). That will cause the filter to output any packets it + * may have buffered internally. + * + * @return 0 on success, a negative AVERROR on error. + */ +int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt); + +/** + * Retrieve a filtered packet. + * + * @param[out] pkt this struct will be filled with the contents of the filtered + * packet. It is owned by the caller and must be freed using + * av_packet_unref() when it is no longer needed. + * This parameter should be "clean" (i.e. freshly allocated + * with av_packet_alloc() or unreffed with av_packet_unref()) + * when this function is called. If this function returns + * successfully, the contents of pkt will be completely + * overwritten by the returned data. On failure, pkt is not + * touched. + * + * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the + * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there + * will be no further output from the filter. Another negative AVERROR value if + * an error occurs. + * + * @note one input packet may result in several output packets, so after sending + * a packet with av_bsf_send_packet(), this function needs to be called + * repeatedly until it stops returning 0. It is also possible for a filter to + * output fewer packets than were sent to it, so this function may return + * AVERROR(EAGAIN) immediately after a successful av_bsf_send_packet() call. + */ +int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt); + +/** + * Free a bitstream filter context and everything associated with it; write NULL + * into the supplied pointer. + */ +void av_bsf_free(AVBSFContext **ctx); + +/** + * Get the AVClass for AVBSFContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *av_bsf_get_class(void); /* memory */ @@ -5268,7 +5966,7 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v); * a pointer to an AVClass struct * @param[in] feature string containing the name of the missing feature * @param[in] want_sample indicates if samples are wanted which exhibit this feature. - * If want_sample is non-zero, additional verbage will be added to the log + * If want_sample is non-zero, additional verbiage will be added to the log * message which tells the user how to report samples to the development * mailing list. * @deprecated Use avpriv_report_missing_feature() instead. diff --git a/ThirdParty/ffmpeg/include/libavcodec/jni.h b/ThirdParty/ffmpeg/include/libavcodec/jni.h new file mode 100644 index 000000000..dd99e9261 --- /dev/null +++ b/ThirdParty/ffmpeg/include/libavcodec/jni.h @@ -0,0 +1,46 @@ +/* + * JNI public API functions + * + * Copyright (c) 2015-2016 Matthieu Bouron + * + * 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_JNI_H +#define AVCODEC_JNI_H + +/* + * Manually set a Java virtual machine which will be used to retrieve the JNI + * environment. Once a Java VM is set it cannot be changed afterwards, meaning + * you can call multiple times av_jni_set_java_vm with the same Java VM pointer + * however it will error out if you try to set a different Java VM. + * + * @param vm Java virtual machine + * @param log_ctx context used for logging, can be NULL + * @return 0 on success, < 0 otherwise + */ +int av_jni_set_java_vm(void *vm, void *log_ctx); + +/* + * Get the Java virtual machine which has been set with av_jni_set_java_vm. + * + * @param vm Java virtual machine + * @return a pointer to the Java virtual machine + */ +void *av_jni_get_java_vm(void *log_ctx); + +#endif /* AVCODEC_JNI_H */ diff --git a/ThirdParty/ffmpeg/include/libavcodec/version.h b/ThirdParty/ffmpeg/include/libavcodec/version.h index 37a35e05e..4f6423b15 100644 --- a/ThirdParty/ffmpeg/include/libavcodec/version.h +++ b/ThirdParty/ffmpeg/include/libavcodec/version.h @@ -1,5 +1,4 @@ /* - * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or @@ -29,8 +28,8 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 24 -#define LIBAVCODEC_VERSION_MICRO 102 +#define LIBAVCODEC_VERSION_MINOR 48 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ @@ -212,5 +211,20 @@ #ifndef FF_API_PRIVATE_OPT #define FF_API_PRIVATE_OPT (LIBAVCODEC_VERSION_MAJOR < 59) #endif +#ifndef FF_API_ASS_TIMING +#define FF_API_ASS_TIMING (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_OLD_BSF +#define FF_API_OLD_BSF (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_COPY_CONTEXT +#define FF_API_COPY_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_GET_CONTEXT_DEFAULTS +#define FF_API_GET_CONTEXT_DEFAULTS (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_NVENC_OLD_NAME +#define FF_API_NVENC_OLD_NAME (LIBAVCODEC_VERSION_MAJOR < 59) +#endif #endif /* AVCODEC_VERSION_H */ diff --git a/ThirdParty/ffmpeg/include/libavcodec/vorbis_parser.h b/ThirdParty/ffmpeg/include/libavcodec/vorbis_parser.h index 81fda3b08..92050277e 100644 --- a/ThirdParty/ffmpeg/include/libavcodec/vorbis_parser.h +++ b/ThirdParty/ffmpeg/include/libavcodec/vorbis_parser.h @@ -1,5 +1,4 @@ /* - * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or diff --git a/ThirdParty/ffmpeg/include/libavformat/avformat.h b/ThirdParty/ffmpeg/include/libavformat/avformat.h index 34bad436c..818184e5a 100644 --- a/ThirdParty/ffmpeg/include/libavformat/avformat.h +++ b/ThirdParty/ffmpeg/include/libavformat/avformat.h @@ -161,8 +161,8 @@ * av_read_frame() on it. Each call, if successful, will return an AVPacket * containing encoded data for one AVStream, identified by * AVPacket.stream_index. This packet may be passed straight into the libavcodec - * decoding functions avcodec_decode_video2(), avcodec_decode_audio4() or - * avcodec_decode_subtitle2() if the caller wishes to decode the data. + * decoding functions avcodec_send_packet() or avcodec_decode_subtitle2() if the + * caller wishes to decode the data. * * AVPacket.pts, AVPacket.dts and AVPacket.duration timing information will be * set if known. They may also be unset (i.e. AV_NOPTS_VALUE for @@ -203,15 +203,15 @@ * avio_open2() or a custom one. * - Unless the format is of the AVFMT_NOSTREAMS type, at least one stream must * be created with the avformat_new_stream() function. The caller should fill - * the @ref AVStream.codec "stream codec context" information, such as the - * codec @ref AVCodecContext.codec_type "type", @ref AVCodecContext.codec_id + * the @ref AVStream.codecpar "stream codec parameters" information, such as the + * codec @ref AVCodecParameters.codec_type "type", @ref AVCodecParameters.codec_id * "id" and other parameters (e.g. width / height, the pixel or sample format, * etc.) as known. The @ref AVStream.time_base "stream timebase" should * be set to the timebase that the caller desires to use for this stream (note * that the timebase actually used by the muxer can be different, as will be * described later). * - It is advised to manually initialize only the relevant fields in - * AVCodecContext, rather than using @ref avcodec_copy_context() during + * AVCodecParameters, rather than using @ref avcodec_parameters_copy() during * remuxing: there is no guarantee that the codec context values remain valid * for both input and output format contexts. * - The caller may fill in additional information, such as @ref @@ -310,7 +310,6 @@ * @{ * @} * @} - * */ #include @@ -528,7 +527,7 @@ typedef struct AVOutputFormat { * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, - * AVFMT_TS_NONSTRICT + * AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE */ int flags; @@ -873,18 +872,13 @@ typedef struct AVStream { * encoding: set by the user, replaced by libavformat if left unset */ int id; +#if FF_API_LAVF_AVCTX /** - * Codec context associated with this stream. Allocated and freed by - * libavformat. - * - * - decoding: The demuxer exports codec information stored in the headers - * here. - * - encoding: The user sets codec information, the muxer writes it to the - * output. Mandatory fields as specified in AVCodecContext - * documentation must be set even if this AVCodecContext is - * not actually used for encoding. + * @deprecated use the codecpar struct instead */ + attribute_deprecated AVCodecContext *codec; +#endif void *priv_data; #if FF_API_LAVF_FRAC @@ -1212,6 +1206,17 @@ typedef struct AVStream { * Must not be accessed in any way by callers. */ AVStreamInternal *internal; + + /* + * Codec parameters associated with this stream. Allocated and freed by + * libavformat in avformat_new_stream() and avformat_free_context() + * respectively. + * + * - demuxing: filled by libavformat on stream creation or in + * avformat_find_stream_info() + * - muxing: filled by the caller before avformat_write_header() + */ + AVCodecParameters *codecpar; } AVStream; AVRational av_stream_get_r_frame_rate(const AVStream *s); @@ -1300,6 +1305,12 @@ typedef struct AVFormatInternal AVFormatInternal; * version bump. * sizeof(AVFormatContext) must not be used outside libav*, use * avformat_alloc_context() to create an AVFormatContext. + * + * Fields can be accessed through AVOptions (av_opt*), + * the name string used matches the associated command line parameter name and + * can be found in libavformat/options_table.h. + * The AVOption/command line parameter names differ in some cases from the C + * structure field names for historic reasons or brevity. */ typedef struct AVFormatContext { /** @@ -1842,9 +1853,9 @@ typedef struct AVFormatContext { /* * A callback for opening new IO streams. * - * Certain muxers or demuxers (e.g. for various playlist-based formats) need - * to open additional files during muxing or demuxing. This callback allows - * the caller to provide custom IO in such cases. + * Whenever a muxer or a demuxer needs to open an IO stream (typically from + * avformat_open_input() for demuxers, but for certain formats can happen at + * other times as well), it will call this callback to obtain an IO context. * * @param s the format context * @param pb on success, the newly opened IO context should be returned here @@ -1866,6 +1877,13 @@ typedef struct AVFormatContext { * A callback for closing the streams opened with AVFormatContext.io_open(). */ void (*io_close)(struct AVFormatContext *s, AVIOContext *pb); + + /** + * ',' separated list of disallowed protocols. + * - encoding: unused + * - decoding: set by user through AVOptions (NO direct access) + */ + char *protocol_blacklist; } AVFormatContext; int av_format_get_probe_score(const AVFormatContext *s); @@ -2409,6 +2427,10 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt); * increasing dts. Callers doing their own interleaving should call * av_write_frame() instead of this function. * + * Using this function instead of av_write_frame() can give muxers advance + * knowledge of future packets, improving e.g. the behaviour of the mp4 + * muxer for VFR content in fragmenting mode. + * * @param s media file handle * @param pkt The packet containing the data to be written. *
@@ -2443,7 +2465,7 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt); int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); /** - * Write a uncoded frame to an output media file. + * Write an uncoded frame to an output media file. * * The frame must be correctly interleaved according to the container * specification; if not, then av_interleaved_write_frame() must be used. @@ -2454,7 +2476,7 @@ int av_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame); /** - * Write a uncoded frame to an output media file. + * Write an uncoded frame to an output media file. * * If the muxer supports it, this function makes it possible to write an AVFrame * structure directly, without encoding it into a packet. @@ -2844,13 +2866,18 @@ int avformat_queue_attached_pictures(AVFormatContext *s); * Apply a list of bitstream filters to a packet. * * @param codec AVCodecContext, usually from an AVStream - * @param pkt the packet to apply filters to + * @param pkt the packet to apply filters to. If, on success, the returned + * packet has size == 0 and side_data_elems == 0, it indicates that + * the packet should be dropped * @param bsfc a NULL-terminated list of filters to apply * @return >=0 on success; * AVERROR code on failure */ +#if FF_API_OLD_BSF +attribute_deprecated int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt, AVBitStreamFilterContext *bsfc); +#endif /** * @} diff --git a/ThirdParty/ffmpeg/include/libavformat/avio.h b/ThirdParty/ffmpeg/include/libavformat/avio.h index 7fbce32b6..b1ce1d1c7 100644 --- a/ThirdParty/ffmpeg/include/libavformat/avio.h +++ b/ThirdParty/ffmpeg/include/libavformat/avio.h @@ -96,6 +96,42 @@ typedef struct AVIODirContext { struct URLContext *url_context; } AVIODirContext; +/** + * Different data types that can be returned via the AVIO + * write_data_type callback. + */ +enum AVIODataMarkerType { + /** + * Header data; this needs to be present for the stream to be decodeable. + */ + AVIO_DATA_MARKER_HEADER, + /** + * A point in the output bytestream where a decoder can start decoding + * (i.e. a keyframe). A demuxer/decoder given the data flagged with + * AVIO_DATA_MARKER_HEADER, followed by any AVIO_DATA_MARKER_SYNC_POINT, + * should give decodeable results. + */ + AVIO_DATA_MARKER_SYNC_POINT, + /** + * A point in the output bytestream where a demuxer can start parsing + * (for non self synchronizing bytestream formats). That is, any + * non-keyframe packet start point. + */ + AVIO_DATA_MARKER_BOUNDARY_POINT, + /** + * This is any, unlabelled data. It can either be a muxer not marking + * any positions at all, it can be an actual boundary/sync point + * that the muxer chooses not to mark, or a later part of a packet/fragment + * that is cut into multiple write callbacks due to limited IO buffer size. + */ + AVIO_DATA_MARKER_UNKNOWN, + /** + * Trailer data, which doesn't contain actual content, but only for + * finalizing the output file. + */ + AVIO_DATA_MARKER_TRAILER +}; + /** * Bytestream IO Context. * New fields can be added to the end with minor version bumps. @@ -254,9 +290,30 @@ typedef struct AVIOContext { * ',' separated list of allowed protocols. */ const char *protocol_whitelist; -} AVIOContext; -/* unbuffered I/O */ + /** + * ',' separated list of disallowed protocols. + */ + const char *protocol_blacklist; + + /** + * A callback that is used instead of write_packet. + */ + int (*write_data_type)(void *opaque, uint8_t *buf, int buf_size, + enum AVIODataMarkerType type, int64_t time); + /** + * If set, don't call write_data_type separately for AVIO_DATA_MARKER_BOUNDARY_POINT, + * but ignore them and treat them as AVIO_DATA_MARKER_UNKNOWN (to avoid needlessly + * small chunks of data returned from the callback). + */ + int ignore_boundary_point; + + /** + * Internal, not meant to be used from outside of AVIOContext. + */ + enum AVIODataMarkerType current_type; + int64_t last_time; +} AVIOContext; /** * Return the name of the protocol that will handle the passed URL. @@ -409,14 +466,26 @@ int avio_put_str16le(AVIOContext *s, const char *str); int avio_put_str16be(AVIOContext *s, const char *str); /** - * Passing this as the "whence" parameter to a seek function causes it to + * Mark the written bytestream as a specific type. + * + * Zero-length ranges are omitted from the output. + * + * @param time the stream time the current bytestream pos corresponds to + * (in AV_TIME_BASE units), or AV_NOPTS_VALUE if unknown or not + * applicable + * @param type the kind of data written starting at the current pos + */ +void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type); + +/** + * ORing this as the "whence" parameter to a seek function causes it to * return the filesize without seeking anywhere. Supporting this is optional. * If it is not supported then the seek function will return <0. */ #define AVSEEK_SIZE 0x10000 /** - * Oring this flag as into the "whence" parameter to a seek function causes it to + * Passing this flag as the "whence" parameter to a seek function causes it to * seek by any means (like reopening and linear reading) or other normally unreasonable * means that can be extremely slow. * This may be ignored by the seek code. diff --git a/ThirdParty/ffmpeg/include/libavformat/url.h b/ThirdParty/ffmpeg/include/libavformat/url.h deleted file mode 100644 index 0b4f2ee37..000000000 --- a/ThirdParty/ffmpeg/include/libavformat/url.h +++ /dev/null @@ -1,327 +0,0 @@ -/* - * - * 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 - * unbuffered private I/O API - */ - -#ifndef AVFORMAT_URL_H -#define AVFORMAT_URL_H - -#include "avio.h" -#include "libavformat/version.h" - -#include "libavutil/dict.h" -#include "libavutil/log.h" - -#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */ -#define URL_PROTOCOL_FLAG_NETWORK 2 /*< The protocol uses network */ - -extern const AVClass ffurl_context_class; - -typedef struct URLContext { - const AVClass *av_class; /**< information for av_log(). Set by url_open(). */ - struct URLProtocol *prot; - void *priv_data; - char *filename; /**< specified URL */ - int flags; - int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ - int is_streamed; /**< true if streamed (no seek possible), default = false */ - int is_connected; - AVIOInterruptCB interrupt_callback; - int64_t rw_timeout; /**< maximum time to wait for (network) read/write operation completion, in mcs */ - const char *protocol_whitelist; -} URLContext; - -typedef struct URLProtocol { - const char *name; - int (*url_open)( URLContext *h, const char *url, int flags); - /** - * This callback is to be used by protocols which open further nested - * protocols. options are then to be passed to ffurl_open()/ffurl_connect() - * for those nested protocols. - */ - int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options); - int (*url_accept)(URLContext *s, URLContext **c); - int (*url_handshake)(URLContext *c); - - /** - * Read data from the protocol. - * If data is immediately available (even less than size), EOF is - * reached or an error occurs (including EINTR), return immediately. - * Otherwise: - * In non-blocking mode, return AVERROR(EAGAIN) immediately. - * In blocking mode, wait for data/EOF/error with a short timeout (0.1s), - * and return AVERROR(EAGAIN) on timeout. - * Checking interrupt_callback, looping on EINTR and EAGAIN and until - * enough data has been read is left to the calling function; see - * retry_transfer_wrapper in avio.c. - */ - int (*url_read)( URLContext *h, unsigned char *buf, int size); - int (*url_write)(URLContext *h, const unsigned char *buf, int size); - int64_t (*url_seek)( URLContext *h, int64_t pos, int whence); - int (*url_close)(URLContext *h); - struct URLProtocol *next; - int (*url_read_pause)(URLContext *h, int pause); - int64_t (*url_read_seek)(URLContext *h, int stream_index, - int64_t timestamp, int flags); - int (*url_get_file_handle)(URLContext *h); - int (*url_get_multi_file_handle)(URLContext *h, int **handles, - int *numhandles); - int (*url_shutdown)(URLContext *h, int flags); - int priv_data_size; - const AVClass *priv_data_class; - int flags; - int (*url_check)(URLContext *h, int mask); - int (*url_open_dir)(URLContext *h); - int (*url_read_dir)(URLContext *h, AVIODirEntry **next); - int (*url_close_dir)(URLContext *h); - int (*url_delete)(URLContext *h); - int (*url_move)(URLContext *h_src, URLContext *h_dst); - const char *default_whitelist; -} URLProtocol; - -/** - * Create a URLContext for accessing to the resource indicated by - * url, but do not initiate the connection yet. - * - * @param puc pointer to the location where, in case of success, the - * function puts the pointer to the created URLContext - * @param flags flags which control how the resource indicated by url - * is to be opened - * @param int_cb interrupt callback to use for the URLContext, may be - * NULL - * @return >= 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure - */ -int ffurl_alloc(URLContext **puc, const char *filename, int flags, - const AVIOInterruptCB *int_cb); - -/** - * Connect an URLContext that has been allocated by ffurl_alloc - * - * @param options A dictionary filled with options for nested protocols, - * i.e. it will be passed to url_open2() for protocols implementing it. - * This parameter will be destroyed and replaced with a dict containing options - * that were not found. May be NULL. - */ -int ffurl_connect(URLContext *uc, AVDictionary **options); - -/** - * Create an URLContext for accessing to the resource indicated by - * url, and open it. - * - * @param puc pointer to the location where, in case of success, the - * function puts the pointer to the created URLContext - * @param flags flags which control how the resource indicated by url - * is to be opened - * @param int_cb interrupt callback to use for the URLContext, may be - * NULL - * @param options A dictionary filled with protocol-private options. On return - * this parameter will be destroyed and replaced with a dict containing options - * that were not found. May be NULL. - * @return >= 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure - */ -int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, - const AVIOInterruptCB *int_cb, AVDictionary **options, - const char *whitelist); - -int ffurl_open(URLContext **puc, const char *filename, int flags, - const AVIOInterruptCB *int_cb, AVDictionary **options); - -/** - * Accept an URLContext c on an URLContext s - * - * @param s server context - * @param c client context, must be unallocated. - * @return >= 0 on success, ff_neterrno() on failure. - */ -int ffurl_accept(URLContext *s, URLContext **c); - -/** - * Perform one step of the protocol handshake to accept a new client. - * See avio_handshake() for details. - * Implementations should try to return decreasing values. - * If the protocol uses an underlying protocol, the underlying handshake is - * usually the first step, and the return value can be: - * (largest value for this protocol) + (return value from other protocol) - * - * @param c the client context - * @return >= 0 on success or a negative value corresponding - * to an AVERROR code on failure - */ -int ffurl_handshake(URLContext *c); - -/** - * Read up to size bytes from the resource accessed by h, and store - * the read bytes in buf. - * - * @return The number of bytes actually read, or a negative value - * corresponding to an AVERROR code in case of error. A value of zero - * indicates that it is not possible to read more from the accessed - * resource (except if the value of the size argument is also zero). - */ -int ffurl_read(URLContext *h, unsigned char *buf, int size); - -/** - * Read as many bytes as possible (up to size), calling the - * read function multiple times if necessary. - * This makes special short-read handling in applications - * unnecessary, if the return value is < size then it is - * certain there was either an error or the end of file was reached. - */ -int ffurl_read_complete(URLContext *h, unsigned char *buf, int size); - -/** - * Write size bytes from buf to the resource accessed by h. - * - * @return the number of bytes actually written, or a negative value - * corresponding to an AVERROR code in case of failure - */ -int ffurl_write(URLContext *h, const unsigned char *buf, int size); - -/** - * Change the position that will be used by the next read/write - * operation on the resource accessed by h. - * - * @param pos specifies the new position to set - * @param whence specifies how pos should be interpreted, it must be - * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the - * current position), SEEK_END (seek from the end), or AVSEEK_SIZE - * (return the filesize of the requested resource, pos is ignored). - * @return a negative value corresponding to an AVERROR code in case - * of failure, or the resulting file position, measured in bytes from - * the beginning of the file. You can use this feature together with - * SEEK_CUR to read the current file position. - */ -int64_t ffurl_seek(URLContext *h, int64_t pos, int whence); - -/** - * Close the resource accessed by the URLContext h, and free the - * memory used by it. Also set the URLContext pointer to NULL. - * - * @return a negative value if an error condition occurred, 0 - * otherwise - */ -int ffurl_closep(URLContext **h); -int ffurl_close(URLContext *h); - -/** - * Return the filesize of the resource accessed by h, AVERROR(ENOSYS) - * if the operation is not supported by h, or another negative value - * corresponding to an AVERROR error code in case of failure. - */ -int64_t ffurl_size(URLContext *h); - -/** - * Return the file descriptor associated with this URL. For RTP, this - * will return only the RTP file descriptor, not the RTCP file descriptor. - * - * @return the file descriptor associated with this URL, or <0 on error. - */ -int ffurl_get_file_handle(URLContext *h); - -/** - * Return the file descriptors associated with this URL. - * - * @return 0 on success or <0 on error. - */ -int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles); - -/** - * Signal the URLContext that we are done reading or writing the stream. - * - * @param h pointer to the resource - * @param flags flags which control how the resource indicated by url - * is to be shutdown - * - * @return a negative value if an error condition occurred, 0 - * otherwise - */ -int ffurl_shutdown(URLContext *h, int flags); - -/** - * Register the URLProtocol protocol. - */ -int ffurl_register_protocol(URLProtocol *protocol); - -/** - * Check if the user has requested to interrup a blocking function - * associated with cb. - */ -int ff_check_interrupt(AVIOInterruptCB *cb); - -/** - * Iterate over all available protocols. - * - * @param prev result of the previous call to this functions or NULL. - */ -URLProtocol *ffurl_protocol_next(const URLProtocol *prev); - -/* udp.c */ -int ff_udp_set_remote_url(URLContext *h, const char *uri); -int ff_udp_get_local_port(URLContext *h); - -/** - * Assemble a URL string from components. This is the reverse operation - * of av_url_split. - * - * Note, this requires networking to be initialized, so the caller must - * ensure ff_network_init has been called. - * - * @see av_url_split - * - * @param str the buffer to fill with the url - * @param size the size of the str buffer - * @param proto the protocol identifier, if null, the separator - * after the identifier is left out, too - * @param authorization an optional authorization string, may be null. - * An empty string is treated the same as a null string. - * @param hostname the host name string - * @param port the port number, left out from the string if negative - * @param fmt a generic format string for everything to add after the - * host/port, may be null - * @return the number of characters written to the destination buffer - */ -int ff_url_join(char *str, int size, const char *proto, - const char *authorization, const char *hostname, - int port, const char *fmt, ...) av_printf_format(7, 8); - -/** - * Convert a relative url into an absolute url, given a base url. - * - * @param buf the buffer where output absolute url is written - * @param size the size of buf - * @param base the base url, may be equal to buf. - * @param rel the new url, which is interpreted relative to base - */ -void ff_make_absolute_url(char *buf, int size, const char *base, - const char *rel); - -/** - * Allocate directory entry with default values. - * - * @return entry or NULL on error - */ -AVIODirEntry *ff_alloc_dir_entry(void); - - -#endif /* AVFORMAT_URL_H */ diff --git a/ThirdParty/ffmpeg/include/libavformat/version.h b/ThirdParty/ffmpeg/include/libavformat/version.h index 024ab9152..47a8afbb2 100644 --- a/ThirdParty/ffmpeg/include/libavformat/version.h +++ b/ThirdParty/ffmpeg/include/libavformat/version.h @@ -29,8 +29,10 @@ #include "libavutil/version.h" +// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) +// Also please add any ticket numbers that you belive might be affected here #define LIBAVFORMAT_VERSION_MAJOR 57 -#define LIBAVFORMAT_VERSION_MINOR 25 +#define LIBAVFORMAT_VERSION_MINOR 41 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ @@ -74,6 +76,9 @@ #ifndef FF_API_OLD_OPEN_CALLBACKS #define FF_API_OLD_OPEN_CALLBACKS (LIBAVFORMAT_VERSION_MAJOR < 58) #endif +#ifndef FF_API_LAVF_AVCTX +#define FF_API_LAVF_AVCTX (LIBAVFORMAT_VERSION_MAJOR < 58) +#endif #ifndef FF_API_R_FRAME_RATE #define FF_API_R_FRAME_RATE 1 diff --git a/ThirdParty/ffmpeg/include/libavutil/audio_fifo.h b/ThirdParty/ffmpeg/include/libavutil/audio_fifo.h index 24f91dab7..d8a9194a8 100644 --- a/ThirdParty/ffmpeg/include/libavutil/audio_fifo.h +++ b/ThirdParty/ffmpeg/include/libavutil/audio_fifo.h @@ -110,6 +110,23 @@ int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples); */ int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples); +/** + * Peek data from an AVAudioFifo. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param af AVAudioFifo to read from + * @param data audio data plane pointers + * @param nb_samples number of samples to peek + * @param offset offset from current read position + * @return number of samples actually peek, or negative AVERROR code + * on failure. The number of samples actually peek will not + * be greater than nb_samples, and will only be less than + * nb_samples if av_audio_fifo_size is less than nb_samples. + */ +int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset); + /** * Read data from an AVAudioFifo. * diff --git a/ThirdParty/ffmpeg/include/libavutil/avassert.h b/ThirdParty/ffmpeg/include/libavutil/avassert.h index 41f5e0eea..f47363764 100644 --- a/ThirdParty/ffmpeg/include/libavutil/avassert.h +++ b/ThirdParty/ffmpeg/include/libavutil/avassert.h @@ -45,7 +45,7 @@ /** * assert() equivalent, that does not lie in speed critical code. - * These asserts() thus can be enabled without fearing speedloss. + * These asserts() thus can be enabled without fearing speed loss. */ #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0 #define av_assert1(cond) av_assert0(cond) diff --git a/ThirdParty/ffmpeg/include/libavutil/avstring.h b/ThirdParty/ffmpeg/include/libavutil/avstring.h index 15b04babe..dd2876990 100644 --- a/ThirdParty/ffmpeg/include/libavutil/avstring.h +++ b/ThirdParty/ffmpeg/include/libavutil/avstring.h @@ -156,7 +156,7 @@ static inline size_t av_strnlen(const char *s, size_t len) char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2); /** - * Convert a number to a av_malloced string. + * Convert a number to an av_malloced string. */ char *av_d2str(double d); diff --git a/ThirdParty/ffmpeg/include/libavutil/avutil.h b/ThirdParty/ffmpeg/include/libavutil/avutil.h index 9bcf67412..c1f76c16e 100644 --- a/ThirdParty/ffmpeg/include/libavutil/avutil.h +++ b/ThirdParty/ffmpeg/include/libavutil/avutil.h @@ -266,7 +266,7 @@ enum AVPictureType { AV_PICTURE_TYPE_I, ///< Intra AV_PICTURE_TYPE_P, ///< Predicted AV_PICTURE_TYPE_B, ///< Bi-dir predicted - AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG4 + AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG-4 AV_PICTURE_TYPE_SI, ///< Switching Intra AV_PICTURE_TYPE_SP, ///< Switching Predicted AV_PICTURE_TYPE_BI, ///< BI type diff --git a/ThirdParty/ffmpeg/include/libavutil/base64.h b/ThirdParty/ffmpeg/include/libavutil/base64.h index 514498eac..2954c12d4 100644 --- a/ThirdParty/ffmpeg/include/libavutil/base64.h +++ b/ThirdParty/ffmpeg/include/libavutil/base64.h @@ -29,19 +29,24 @@ * @{ */ - /** * Decode a base64-encoded string. * * @param out buffer for decoded data * @param in null-terminated input string * @param out_size size in bytes of the out buffer, must be at - * least 3/4 of the length of in + * least 3/4 of the length of in, that is AV_BASE64_DECODE_SIZE(strlen(in)) * @return number of bytes written, or a negative value in case of * invalid input */ int av_base64_decode(uint8_t *out, const char *in, int out_size); +/** + * Calculate the output size in bytes needed to decode a base64 string + * with length x to a data buffer. + */ +#define AV_BASE64_DECODE_SIZE(x) ((x) * 3LL / 4) + /** * Encode data to base64 and null-terminate. * diff --git a/ThirdParty/ffmpeg/include/libavutil/buffer.h b/ThirdParty/ffmpeg/include/libavutil/buffer.h index b4399fd39..0c0ce12cf 100644 --- a/ThirdParty/ffmpeg/include/libavutil/buffer.h +++ b/ThirdParty/ffmpeg/include/libavutil/buffer.h @@ -248,6 +248,23 @@ typedef struct AVBufferPool AVBufferPool; */ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)); +/** + * Allocate and initialize a buffer pool with a more complex allocator. + * + * @param size size of each buffer in this pool + * @param opaque arbitrary user data used by the allocator + * @param alloc a function that will be used to allocate new buffers when the + * pool is empty. + * @param pool_free a function that will be called immediately before the pool + * is freed. I.e. after av_buffer_pool_can_uninit() is called + * by the pool and all the frames are returned to the pool and + * freed. It is intended to uninitialize the user opaque data. + * @return newly created buffer pool on success, NULL on error. + */ +AVBufferPool *av_buffer_pool_init2(int size, void *opaque, + AVBufferRef* (*alloc)(void *opaque, int size), + void (*pool_free)(void *opaque)); + /** * Mark the pool as being available for freeing. It will actually be freed only * once all the allocated buffers associated with the pool are released. Thus it @@ -255,7 +272,6 @@ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)); * in use. * * @param pool pointer to the pool to be freed. It will be set to NULL. - * @see av_buffer_pool_can_uninit() */ void av_buffer_pool_uninit(AVBufferPool **pool); diff --git a/ThirdParty/ffmpeg/include/libavutil/cpu.h b/ThirdParty/ffmpeg/include/libavutil/cpu.h index cc4e30c4c..4bff16714 100644 --- a/ThirdParty/ffmpeg/include/libavutil/cpu.h +++ b/ThirdParty/ffmpeg/include/libavutil/cpu.h @@ -70,7 +70,7 @@ /** * Return the flags which specify extensions supported by the CPU. * The returned value is affected by av_force_cpu_flags() if that was used - * before. So av_get_cpu_flags() can easily be used in a application to + * before. So av_get_cpu_flags() can easily be used in an application to * detect the enabled cpu flags. */ int av_get_cpu_flags(void); diff --git a/ThirdParty/ffmpeg/include/libavutil/dict.h b/ThirdParty/ffmpeg/include/libavutil/dict.h index 5b8d00339..118f1f00e 100644 --- a/ThirdParty/ffmpeg/include/libavutil/dict.h +++ b/ThirdParty/ffmpeg/include/libavutil/dict.h @@ -1,5 +1,4 @@ /* - * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or @@ -65,7 +64,6 @@ } av_dict_free(&d); @endcode - * */ #define AV_DICT_MATCH_CASE 1 /**< Only get an entry with exact-case key match. Only relevant in av_dict_get(). */ @@ -78,6 +76,7 @@ #define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries. #define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no delimiter is added, the strings are simply concatenated. */ +#define AV_DICT_MULTIKEY 64 /**< Allow to store several equal keys in the dictionary */ typedef struct AVDictionaryEntry { char *key; @@ -118,10 +117,13 @@ int av_dict_count(const AVDictionary *m); * Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set, * these arguments will be freed on error. * + * Warning: Adding a new entry to a dictionary invalidates all existing entries + * previously returned with av_dict_get. + * * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL * a dictionary struct is allocated and put in *pm. - * @param key entry key to add to *pm (will be av_strduped depending on flags) - * @param value entry value to add to *pm (will be av_strduped depending on flags). + * @param key entry key to add to *pm (will either be av_strduped or added as a new key depending on flags) + * @param value entry value to add to *pm (will be av_strduped or added as a new key depending on flags). * Passing a NULL value will cause an existing entry to be deleted. * @return >= 0 on success otherwise an error code <0 */ diff --git a/ThirdParty/ffmpeg/include/libavutil/display.h b/ThirdParty/ffmpeg/include/libavutil/display.h index c0cfee326..39c15ee6b 100644 --- a/ThirdParty/ffmpeg/include/libavutil/display.h +++ b/ThirdParty/ffmpeg/include/libavutil/display.h @@ -22,6 +22,7 @@ #define AVUTIL_DISPLAY_H #include +#include "common.h" /** * The display transformation matrix specifies an affine transformation that diff --git a/ThirdParty/ffmpeg/include/libavutil/ffversion.h b/ThirdParty/ffmpeg/include/libavutil/ffversion.h index 983454d71..89ff62f45 100644 --- a/ThirdParty/ffmpeg/include/libavutil/ffversion.h +++ b/ThirdParty/ffmpeg/include/libavutil/ffversion.h @@ -1,5 +1,5 @@ /* Automatically generated by version.sh, do not manually edit! */ #ifndef AVUTIL_FFVERSION_H #define AVUTIL_FFVERSION_H -#define FFMPEG_VERSION "n3.0.2" +#define FFMPEG_VERSION "n3.1.1" #endif /* AVUTIL_FFVERSION_H */ diff --git a/ThirdParty/ffmpeg/include/libavutil/file.h b/ThirdParty/ffmpeg/include/libavutil/file.h index e931be71e..8666c7b1d 100644 --- a/ThirdParty/ffmpeg/include/libavutil/file.h +++ b/ThirdParty/ffmpeg/include/libavutil/file.h @@ -62,6 +62,7 @@ void av_file_unmap(uint8_t *bufptr, size_t size); * @note On very old libcs it is necessary to set a secure umask before * calling this, av_tempfile() can't call umask itself as it is used in * libraries and could interfere with the calling application. + * @deprecated as fd numbers cannot be passed saftely between libs on some platforms */ int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx); diff --git a/ThirdParty/ffmpeg/include/libavutil/frame.h b/ThirdParty/ffmpeg/include/libavutil/frame.h index 8dc404907..2b5c3320c 100644 --- a/ThirdParty/ffmpeg/include/libavutil/frame.h +++ b/ThirdParty/ffmpeg/include/libavutil/frame.h @@ -1,5 +1,4 @@ /* - * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or @@ -177,6 +176,10 @@ typedef struct AVFrameSideData { * Similarly fields that are marked as to be only accessed by * av_opt_ptr() can be reordered. This allows 2 forks to add fields * without breaking compatibility with each other. + * + * Fields can be accessed through AVOptions, the name string used, matches the + * C structure field name for fields accessable through AVOptions. The AVClass + * for AVFrame can be obtained from avcodec_get_frame_class() */ typedef struct AVFrame { #define AV_NUM_DATA_POINTERS 8 @@ -188,6 +191,9 @@ typedef struct AVFrame { * see avcodec_align_dimensions2(). Some filters and swscale can read * up to 16 bytes beyond the planes, if these filters are to be used, * then 16 extra bytes must be allocated. + * + * NOTE: Except for hwaccel formats, pointers not needed by the format + * MUST be set to NULL. */ uint8_t *data[AV_NUM_DATA_POINTERS]; @@ -322,7 +328,7 @@ typedef struct AVFrame { int palette_has_changed; /** - * reordered opaque 64bit (generally an integer or a double precision float + * reordered opaque 64 bits (generally an integer or a double precision float * PTS but can be anything). * The user sets AVCodecContext.reordered_opaque to represent the input at * that time, @@ -512,6 +518,11 @@ typedef struct AVFrame { */ AVBufferRef *qp_table_buf; #endif + /** + * For hwaccel-format frames, this should be a reference to the + * AVHWFramesContext describing the frame. + */ + AVBufferRef *hw_frames_ctx; } AVFrame; /** @@ -583,6 +594,10 @@ void av_frame_free(AVFrame **frame); * If src is not reference counted, new buffers are allocated and the data is * copied. * + * @warning: dst MUST have been either unreferenced with av_frame_unref(dst), + * or newly allocated with av_frame_alloc() before calling this + * function, or undefined behavior will occur. + * * @return 0 on success, a negative AVERROR on error */ int av_frame_ref(AVFrame *dst, const AVFrame *src); @@ -603,6 +618,10 @@ void av_frame_unref(AVFrame *frame); /** * Move everything contained in src to dst and reset src. + * + * @warning: dst is not unreferenced, but directly overwritten without reading + * or deallocating its contents. Call av_frame_unref(dst) manually + * before calling this function to ensure that no memory is leaked. */ void av_frame_move_ref(AVFrame *dst, AVFrame *src); @@ -618,6 +637,10 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src); * necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf. * For planar formats, one buffer will be allocated for each plane. * + * @warning: if frame already has been allocated, calling this function will + * leak memory. In addition, undefined behavior can occur in certain + * cases. + * * @param frame frame in which to store the new buffers. * @param align required buffer size alignment * diff --git a/ThirdParty/ffmpeg/include/libavutil/hwcontext.h b/ThirdParty/ffmpeg/include/libavutil/hwcontext.h new file mode 100644 index 000000000..4e9da0224 --- /dev/null +++ b/ThirdParty/ffmpeg/include/libavutil/hwcontext.h @@ -0,0 +1,428 @@ +/* + * 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 AVUTIL_HWCONTEXT_H +#define AVUTIL_HWCONTEXT_H + +#include "buffer.h" +#include "frame.h" +#include "log.h" +#include "pixfmt.h" + +enum AVHWDeviceType { + AV_HWDEVICE_TYPE_VDPAU, + AV_HWDEVICE_TYPE_CUDA, + AV_HWDEVICE_TYPE_VAAPI, + AV_HWDEVICE_TYPE_DXVA2, +}; + +typedef struct AVHWDeviceInternal AVHWDeviceInternal; + +/** + * This struct aggregates all the (hardware/vendor-specific) "high-level" state, + * i.e. state that is not tied to a concrete processing configuration. + * E.g., in an API that supports hardware-accelerated encoding and decoding, + * this struct will (if possible) wrap the state that is common to both encoding + * and decoding and from which specific instances of encoders or decoders can be + * derived. + * + * This struct is reference-counted with the AVBuffer mechanism. The + * av_hwdevice_ctx_alloc() constructor yields a reference, whose data field + * points to the actual AVHWDeviceContext. Further objects derived from + * AVHWDeviceContext (such as AVHWFramesContext, describing a frame pool with + * specific properties) will hold an internal reference to it. After all the + * references are released, the AVHWDeviceContext itself will be freed, + * optionally invoking a user-specified callback for uninitializing the hardware + * state. + */ +typedef struct AVHWDeviceContext { + /** + * A class for logging. Set by av_hwdevice_ctx_alloc(). + */ + const AVClass *av_class; + + /** + * Private data used internally by libavutil. Must not be accessed in any + * way by the caller. + */ + AVHWDeviceInternal *internal; + + /** + * This field identifies the underlying API used for hardware access. + * + * This field is set when this struct is allocated and never changed + * afterwards. + */ + enum AVHWDeviceType type; + + /** + * The format-specific data, allocated and freed by libavutil along with + * this context. + * + * Should be cast by the user to the format-specific context defined in the + * corresponding header (hwcontext_*.h) and filled as described in the + * documentation before calling av_hwdevice_ctx_init(). + * + * After calling av_hwdevice_ctx_init() this struct should not be modified + * by the caller. + */ + void *hwctx; + + /** + * This field may be set by the caller before calling av_hwdevice_ctx_init(). + * + * If non-NULL, this callback will be called when the last reference to + * this context is unreferenced, immediately before it is freed. + * + * @note when other objects (e.g an AVHWFramesContext) are derived from this + * struct, this callback will be invoked after all such child objects + * are fully uninitialized and their respective destructors invoked. + */ + void (*free)(struct AVHWDeviceContext *ctx); + + /** + * Arbitrary user data, to be used e.g. by the free() callback. + */ + void *user_opaque; +} AVHWDeviceContext; + +typedef struct AVHWFramesInternal AVHWFramesInternal; + +/** + * This struct describes a set or pool of "hardware" frames (i.e. those with + * data not located in normal system memory). All the frames in the pool are + * assumed to be allocated in the same way and interchangeable. + * + * This struct is reference-counted with the AVBuffer mechanism and tied to a + * given AVHWDeviceContext instance. The av_hwframe_ctx_alloc() constructor + * yields a reference, whose data field points to the actual AVHWFramesContext + * struct. + */ +typedef struct AVHWFramesContext { + /** + * A class for logging. + */ + const AVClass *av_class; + + /** + * Private data used internally by libavutil. Must not be accessed in any + * way by the caller. + */ + AVHWFramesInternal *internal; + + /** + * A reference to the parent AVHWDeviceContext. This reference is owned and + * managed by the enclosing AVHWFramesContext, but the caller may derive + * additional references from it. + */ + AVBufferRef *device_ref; + + /** + * The parent AVHWDeviceContext. This is simply a pointer to + * device_ref->data provided for convenience. + * + * Set by libavutil in av_hwframe_ctx_init(). + */ + AVHWDeviceContext *device_ctx; + + /** + * The format-specific data, allocated and freed automatically along with + * this context. + * + * Should be cast by the user to the format-specific context defined in the + * corresponding header (hwframe_*.h) and filled as described in the + * documentation before calling av_hwframe_ctx_init(). + * + * After any frames using this context are created, the contents of this + * struct should not be modified by the caller. + */ + void *hwctx; + + /** + * This field may be set by the caller before calling av_hwframe_ctx_init(). + * + * If non-NULL, this callback will be called when the last reference to + * this context is unreferenced, immediately before it is freed. + */ + void (*free)(struct AVHWFramesContext *ctx); + + /** + * Arbitrary user data, to be used e.g. by the free() callback. + */ + void *user_opaque; + + /** + * A pool from which the frames are allocated by av_hwframe_get_buffer(). + * This field may be set by the caller before calling av_hwframe_ctx_init(). + * The buffers returned by calling av_buffer_pool_get() on this pool must + * have the properties described in the documentation in the corresponding hw + * type's header (hwcontext_*.h). The pool will be freed strictly before + * this struct's free() callback is invoked. + * + * This field may be NULL, then libavutil will attempt to allocate a pool + * internally. Note that certain device types enforce pools allocated at + * fixed size (frame count), which cannot be extended dynamically. In such a + * case, initial_pool_size must be set appropriately. + */ + AVBufferPool *pool; + + /** + * Initial size of the frame pool. If a device type does not support + * dynamically resizing the pool, then this is also the maximum pool size. + * + * May be set by the caller before calling av_hwframe_ctx_init(). Must be + * set if pool is NULL and the device type does not support dynamic pools. + */ + int initial_pool_size; + + /** + * The pixel format identifying the underlying HW surface type. + * + * Must be a hwaccel format, i.e. the corresponding descriptor must have the + * AV_PIX_FMT_FLAG_HWACCEL flag set. + * + * Must be set by the user before calling av_hwframe_ctx_init(). + */ + enum AVPixelFormat format; + + /** + * The pixel format identifying the actual data layout of the hardware + * frames. + * + * Must be set by the caller before calling av_hwframe_ctx_init(). + * + * @note when the underlying API does not provide the exact data layout, but + * only the colorspace/bit depth, this field should be set to the fully + * planar version of that format (e.g. for 8-bit 420 YUV it should be + * AV_PIX_FMT_YUV420P, not AV_PIX_FMT_NV12 or anything else). + */ + enum AVPixelFormat sw_format; + + /** + * The allocated dimensions of the frames in this pool. + * + * Must be set by the user before calling av_hwframe_ctx_init(). + */ + int width, height; +} AVHWFramesContext; + +/** + * Allocate an AVHWDeviceContext for a given pixel format. + * + * @param format a hwaccel pixel format (AV_PIX_FMT_FLAG_HWACCEL must be set + * on the corresponding format descriptor) + * @return a reference to the newly created AVHWDeviceContext on success or NULL + * on failure. + */ +AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type); + +/** + * Finalize the device context before use. This function must be called after + * the context is filled with all the required information and before it is + * used in any way. + * + * @param ref a reference to the AVHWDeviceContext + * @return 0 on success, a negative AVERROR code on failure + */ +int av_hwdevice_ctx_init(AVBufferRef *ref); + +/** + * Open a device of the specified type and create an AVHWDeviceContext for it. + * + * This is a convenience function intended to cover the simple cases. Callers + * who need to fine-tune device creation/management should open the device + * manually and then wrap it in an AVHWDeviceContext using + * av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init(). + * + * The returned context is already initialized and ready for use, the caller + * should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of + * the created AVHWDeviceContext are set by this function and should not be + * touched by the caller. + * + * @param device_ctx On success, a reference to the newly-created device context + * will be written here. The reference is owned by the caller + * and must be released with av_buffer_unref() when no longer + * needed. On failure, NULL will be written to this pointer. + * @param type The type of the device to create. + * @param device A type-specific string identifying the device to open. + * @param opts A dictionary of additional (type-specific) options to use in + * opening the device. The dictionary remains owned by the caller. + * @param flags currently unused + * + * @return 0 on success, a negative AVERROR code on failure. + */ +int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type, + const char *device, AVDictionary *opts, int flags); + +/** + * Allocate an AVHWFramesContext tied to a given device context. + * + * @param device_ctx a reference to a AVHWDeviceContext. This function will make + * a new reference for internal use, the one passed to the + * function remains owned by the caller. + * @return a reference to the newly created AVHWFramesContext on success or NULL + * on failure. + */ +AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ctx); + +/** + * Finalize the context before use. This function must be called after the + * context is filled with all the required information and before it is attached + * to any frames. + * + * @param ref a reference to the AVHWFramesContext + * @return 0 on success, a negative AVERROR code on failure + */ +int av_hwframe_ctx_init(AVBufferRef *ref); + +/** + * Allocate a new frame attached to the given AVHWFramesContext. + * + * @param hwframe_ctx a reference to an AVHWFramesContext + * @param frame an empty (freshly allocated or unreffed) frame to be filled with + * newly allocated buffers. + * @param flags currently unused, should be set to zero + * @return 0 on success, a negative AVERROR code on failure + */ +int av_hwframe_get_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame, int flags); + +/** + * Copy data to or from a hw surface. At least one of dst/src must have an + * AVHWFramesContext attached. + * + * If src has an AVHWFramesContext attached, then the format of dst (if set) + * must use one of the formats returned by av_hwframe_transfer_get_formats(src, + * AV_HWFRAME_TRANSFER_DIRECTION_FROM). + * If dst has an AVHWFramesContext attached, then the format of src must use one + * of the formats returned by av_hwframe_transfer_get_formats(dst, + * AV_HWFRAME_TRANSFER_DIRECTION_TO) + * + * dst may be "clean" (i.e. with data/buf pointers unset), in which case the + * data buffers will be allocated by this function using av_frame_get_buffer(). + * If dst->format is set, then this format will be used, otherwise (when + * dst->format is AV_PIX_FMT_NONE) the first acceptable format will be chosen. + * + * @param dst the destination frame. dst is not touched on failure. + * @param src the source frame. + * @param flags currently unused, should be set to zero + * @return 0 on success, a negative AVERROR error code on failure. + */ +int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags); + +enum AVHWFrameTransferDirection { + /** + * Transfer the data from the queried hw frame. + */ + AV_HWFRAME_TRANSFER_DIRECTION_FROM, + + /** + * Transfer the data to the queried hw frame. + */ + AV_HWFRAME_TRANSFER_DIRECTION_TO, +}; + +/** + * Get a list of possible source or target formats usable in + * av_hwframe_transfer_data(). + * + * @param hwframe_ctx the frame context to obtain the information for + * @param dir the direction of the transfer + * @param formats the pointer to the output format list will be written here. + * The list is terminated with AV_PIX_FMT_NONE and must be freed + * by the caller when no longer needed using av_free(). + * If this function returns successfully, the format list will + * have at least one item (not counting the terminator). + * On failure, the contents of this pointer are unspecified. + * @param flags currently unused, should be set to zero + * @return 0 on success, a negative AVERROR code on failure. + */ +int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ctx, + enum AVHWFrameTransferDirection dir, + enum AVPixelFormat **formats, int flags); + + +/** + * This struct describes the constraints on hardware frames attached to + * a given device with a hardware-specific configuration. This is returned + * by av_hwdevice_get_hwframe_constraints() and must be freed by + * av_hwframe_constraints_free() after use. + */ +typedef struct AVHWFramesConstraints { + /** + * A list of possible values for format in the hw_frames_ctx, + * terminated by AV_PIX_FMT_NONE. This member will always be filled. + */ + enum AVPixelFormat *valid_hw_formats; + + /** + * A list of possible values for sw_format in the hw_frames_ctx, + * terminated by AV_PIX_FMT_NONE. Can be NULL if this information is + * not known. + */ + enum AVPixelFormat *valid_sw_formats; + + /** + * The minimum size of frames in this hw_frames_ctx. + * (Zero if not known.) + */ + int min_width; + int min_height; + + /** + * The maximum size of frames in this hw_frames_ctx. + * (INT_MAX if not known / no limit.) + */ + int max_width; + int max_height; +} AVHWFramesConstraints; + +/** + * Allocate a HW-specific configuration structure for a given HW device. + * After use, the user must free all members as required by the specific + * hardware structure being used, then free the structure itself with + * av_free(). + * + * @param device_ctx a reference to the associated AVHWDeviceContext. + * @return The newly created HW-specific configuration structure on + * success or NULL on failure. + */ +void *av_hwdevice_hwconfig_alloc(AVBufferRef *device_ctx); + +/** + * Get the constraints on HW frames given a device and the HW-specific + * configuration to be used with that device. If no HW-specific + * configuration is provided, returns the maximum possible capabilities + * of the device. + * + * @param device_ctx a reference to the associated AVHWDeviceContext. + * @param hwconfig a filled HW-specific configuration structure, or NULL + * to return the maximum possible capabilities of the device. + * @return AVHWFramesConstraints structure describing the constraints + * on the device, or NULL if not available. + */ +AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, + const void *hwconfig); + +/** + * Free an AVHWFrameConstraints structure. + * + * @param constraints The (filled or unfilled) AVHWFrameConstraints structure. + */ +void av_hwframe_constraints_free(AVHWFramesConstraints **constraints); + +#endif /* AVUTIL_HWCONTEXT_H */ diff --git a/ThirdParty/ffmpeg/include/libavutil/hwcontext_cuda.h b/ThirdParty/ffmpeg/include/libavutil/hwcontext_cuda.h new file mode 100644 index 000000000..23a77cee7 --- /dev/null +++ b/ThirdParty/ffmpeg/include/libavutil/hwcontext_cuda.h @@ -0,0 +1,46 @@ +/* + * 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 AVUTIL_HWCONTEXT_CUDA_H +#define AVUTIL_HWCONTEXT_CUDA_H + +#include + +#include "pixfmt.h" + +/** + * @file + * An API-specific header for AV_HWDEVICE_TYPE_CUDA. + * + * This API supports dynamic frame pools. AVHWFramesContext.pool must return + * AVBufferRefs whose data pointer is a CUdeviceptr. + */ + +/** + * This struct is allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVCUDADeviceContext { + CUcontext cuda_ctx; +} AVCUDADeviceContext; + +/** + * AVHWFramesContext.hwctx is currently not used + */ + +#endif /* AVUTIL_HWCONTEXT_CUDA_H */ diff --git a/ThirdParty/ffmpeg/include/libavutil/hwcontext_dxva2.h b/ThirdParty/ffmpeg/include/libavutil/hwcontext_dxva2.h new file mode 100644 index 000000000..6c36cb4b6 --- /dev/null +++ b/ThirdParty/ffmpeg/include/libavutil/hwcontext_dxva2.h @@ -0,0 +1,72 @@ +/* + * 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 AVUTIL_HWCONTEXT_DXVA2_H +#define AVUTIL_HWCONTEXT_DXVA2_H + +/** + * @file + * An API-specific header for AV_HWDEVICE_TYPE_DXVA2. + * + * Only fixed-size pools are supported. + * + * For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs + * with the data pointer set to a pointer to IDirect3DSurface9. + */ + +#include +#include + +/** + * This struct is allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVDXVA2DeviceContext { + IDirect3DDeviceManager9 *devmgr; +} AVDXVA2DeviceContext; + +/** + * This struct is allocated as AVHWFramesContext.hwctx + */ +typedef struct AVDXVA2FramesContext { + /** + * The surface type (e.g. DXVA2_VideoProcessorRenderTarget or + * DXVA2_VideoDecoderRenderTarget). Must be set by the caller. + */ + DWORD surface_type; + + /** + * The surface pool. When an external pool is not provided by the caller, + * this will be managed (allocated and filled on init, freed on uninit) by + * libavutil. + */ + IDirect3DSurface9 **surfaces; + int nb_surfaces; + + /** + * Certain drivers require the decoder to be destroyed before the surfaces. + * To allow internally managed pools to work properly in such cases, this + * field is provided. + * + * If it is non-NULL, libavutil will call IDirectXVideoDecoder_Release() on + * it just before the internal surface pool is freed. + */ + IDirectXVideoDecoder *decoder_to_release; +} AVDXVA2FramesContext; + +#endif /* AVUTIL_HWCONTEXT_DXVA2_H */ diff --git a/ThirdParty/ffmpeg/include/libavutil/hwcontext_vaapi.h b/ThirdParty/ffmpeg/include/libavutil/hwcontext_vaapi.h new file mode 100644 index 000000000..7fd1a36e8 --- /dev/null +++ b/ThirdParty/ffmpeg/include/libavutil/hwcontext_vaapi.h @@ -0,0 +1,82 @@ +/* + * 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 AVUTIL_HWCONTEXT_VAAPI_H +#define AVUTIL_HWCONTEXT_VAAPI_H + +#include + +/** + * @file + * API-specific header for AV_HWDEVICE_TYPE_VAAPI. + * + * Dynamic frame pools are supported, but note that any pool used as a render + * target is required to be of fixed size in order to be be usable as an + * argument to vaCreateContext(). + * + * For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs + * with the data pointer set to a VASurfaceID. + */ + +/** + * VAAPI connection details. + * + * Allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVVAAPIDeviceContext { + /** + * The VADisplay handle, to be filled by the user. + */ + VADisplay display; +} AVVAAPIDeviceContext; + +/** + * VAAPI-specific data associated with a frame pool. + * + * Allocated as AVHWFramesContext.hwctx. + */ +typedef struct AVVAAPIFramesContext { + /** + * Set by the user to apply surface attributes to all surfaces in + * the frame pool. If null, default settings are used. + */ + VASurfaceAttrib *attributes; + int nb_attributes; + /** + * The surfaces IDs of all surfaces in the pool after creation. + * Only valid if AVHWFramesContext.initial_pool_size was positive. + * These are intended to be used as the render_targets arguments to + * vaCreateContext(). + */ + VASurfaceID *surface_ids; + int nb_surfaces; +} AVVAAPIFramesContext; + +/** + * VAAPI hardware pipeline configuration details. + * + * Allocated with av_hwdevice_hwconfig_alloc(). + */ +typedef struct AVVAAPIHWConfig { + /** + * ID of a VAAPI pipeline configuration. + */ + VAConfigID config_id; +} AVVAAPIHWConfig; + +#endif /* AVUTIL_HWCONTEXT_VAAPI_H */ diff --git a/ThirdParty/ffmpeg/include/libavutil/hwcontext_vdpau.h b/ThirdParty/ffmpeg/include/libavutil/hwcontext_vdpau.h new file mode 100644 index 000000000..1b7ea1e44 --- /dev/null +++ b/ThirdParty/ffmpeg/include/libavutil/hwcontext_vdpau.h @@ -0,0 +1,44 @@ +/* + * 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 AVUTIL_HWCONTEXT_VDPAU_H +#define AVUTIL_HWCONTEXT_VDPAU_H + +#include + +/** + * @file + * An API-specific header for AV_HWDEVICE_TYPE_VDPAU. + * + * This API supports dynamic frame pools. AVHWFramesContext.pool must return + * AVBufferRefs whose data pointer is a VdpVideoSurface. + */ + +/** + * This struct is allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVVDPAUDeviceContext { + VdpDevice device; + VdpGetProcAddress *get_proc_address; +} AVVDPAUDeviceContext; + +/** + * AVHWFramesContext.hwctx is currently not used + */ + +#endif /* AVUTIL_HWCONTEXT_VDPAU_H */ diff --git a/ThirdParty/ffmpeg/include/libavutil/log.h b/ThirdParty/ffmpeg/include/libavutil/log.h index 321748cd8..0acc1b921 100644 --- a/ThirdParty/ffmpeg/include/libavutil/log.h +++ b/ThirdParty/ffmpeg/include/libavutil/log.h @@ -317,6 +317,23 @@ AVClassCategory av_default_get_category(void *ptr); void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix); +/** + * Format a line of log the same way as the default callback. + * @param line buffer to receive the formatted line; + * may be NULL if line_size is 0 + * @param line_size size of the buffer; at most line_size-1 characters will + * be written to the buffer, plus one null terminator + * @param print_prefix used to store whether the prefix must be printed; + * must point to a persistent integer initially set to 1 + * @return Returns a negative value if an error occurred, otherwise returns + * the number of characters that would have been written for a + * sufficiently large buffer, not including the terminating null + * character. If the return value is not less than line_size, it means + * that the log message was truncated to fit the buffer. + */ +int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, + char *line, int line_size, int *print_prefix); + #if FF_API_DLOG /** * av_dlog macros diff --git a/ThirdParty/ffmpeg/include/libavutil/opt.h b/ThirdParty/ffmpeg/include/libavutil/opt.h index 753434d62..9a76a47f7 100644 --- a/ThirdParty/ffmpeg/include/libavutil/opt.h +++ b/ThirdParty/ffmpeg/include/libavutil/opt.h @@ -281,7 +281,7 @@ typedef struct AVOption { #define AV_OPT_FLAG_VIDEO_PARAM 16 #define AV_OPT_FLAG_SUBTITLE_PARAM 32 /** - * The option is inteded for exporting values to the caller. + * The option is intended for exporting values to the caller. */ #define AV_OPT_FLAG_EXPORT 64 /** diff --git a/ThirdParty/ffmpeg/include/libavutil/pixdesc.h b/ThirdParty/ffmpeg/include/libavutil/pixdesc.h index b1d218db4..3b0bcdb3d 100644 --- a/ThirdParty/ffmpeg/include/libavutil/pixdesc.h +++ b/ThirdParty/ffmpeg/include/libavutil/pixdesc.h @@ -85,16 +85,16 @@ typedef struct AVPixFmtDescriptor { /** * Amount to shift the luma width right to find the chroma width. * For YV12 this is 1 for example. - * chroma_width = -((-luma_width) >> log2_chroma_w) + * chroma_width = AV_CEIL_RSHIFT(luma_width, log2_chroma_w) * The note above is needed to ensure rounding up. * This value only refers to the chroma components. */ - uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w) + uint8_t log2_chroma_w; /** * Amount to shift the luma height right to find the chroma height. * For YV12 this is 1 for example. - * chroma_height= -((-luma_height) >> log2_chroma_h) + * chroma_height= AV_CEIL_RSHIFT(luma_height, log2_chroma_h) * The note above is needed to ensure rounding up. * This value only refers to the chroma components. */ diff --git a/ThirdParty/ffmpeg/include/libavutil/pixfmt.h b/ThirdParty/ffmpeg/include/libavutil/pixfmt.h index c01c0575f..0ed01c484 100644 --- a/ThirdParty/ffmpeg/include/libavutil/pixfmt.h +++ b/ThirdParty/ffmpeg/include/libavutil/pixfmt.h @@ -24,7 +24,6 @@ /** * @file * pixel format definitions - * */ #include "libavutil/avconfig.h" @@ -54,7 +53,7 @@ * to run on the IBM VGA graphics adapter use 6-bit palette components. * * @par - * For all the 8bit per pixel formats, an RGB32 palette is in data[1] like + * For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like * for pal8. This palette is filled in automatically by the function * allocating the picture. */ @@ -71,7 +70,7 @@ enum AVPixelFormat { AV_PIX_FMT_GRAY8, ///< Y , 8bpp AV_PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb AV_PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb - AV_PIX_FMT_PAL8, ///< 8 bit with AV_PIX_FMT_RGB32 palette + AV_PIX_FMT_PAL8, ///< 8 bits with AV_PIX_FMT_RGB32 palette AV_PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting color_range AV_PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting color_range AV_PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting color_range @@ -126,7 +125,7 @@ enum AVPixelFormat { /**@{*/ AV_PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers AV_PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers - AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a VASurfaceID /**@}*/ AV_PIX_FMT_VAAPI = AV_PIX_FMT_VAAPI_VLD, #else @@ -144,7 +143,7 @@ enum AVPixelFormat { AV_PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian AV_PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian #if FF_API_VDPAU - AV_PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VDPAU_MPEG4, ///< MPEG-4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers #endif AV_PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer @@ -152,7 +151,7 @@ enum AVPixelFormat { AV_PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined AV_PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined AV_PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined - AV_PIX_FMT_YA8, ///< 8bit gray, 8bit alpha + AV_PIX_FMT_YA8, ///< 8 bits gray, 8 bits alpha AV_PIX_FMT_Y400A = AV_PIX_FMT_YA8, ///< alias for AV_PIX_FMT_YA8 AV_PIX_FMT_GRAY8A= AV_PIX_FMT_YA8, ///< alias for AV_PIX_FMT_YA8 @@ -223,8 +222,8 @@ enum AVPixelFormat { AV_PIX_FMT_VDA, ///< HW acceleration through VDA, data[3] contains a CVPixelBufferRef - AV_PIX_FMT_YA16BE, ///< 16bit gray, 16bit alpha (big-endian) - AV_PIX_FMT_YA16LE, ///< 16bit gray, 16bit alpha (little-endian) + AV_PIX_FMT_YA16BE, ///< 16 bits gray, 16 bits alpha (big-endian) + AV_PIX_FMT_YA16LE, ///< 16 bits gray, 16 bits alpha (little-endian) AV_PIX_FMT_GBRAP, ///< planar GBRA 4:4:4:4 32bpp AV_PIX_FMT_GBRAP16BE, ///< planar GBRA 4:4:4:4 64bpp, big-endian @@ -242,6 +241,12 @@ enum AVPixelFormat { AV_PIX_FMT_D3D11VA_VLD, ///< HW decoding through Direct3D11, Picture.data[3] contains a ID3D11VideoDecoderOutputView pointer + /** + * HW acceleration through CUDA. data[i] contain CUdeviceptr pointers + * exactly as for system memory frames. + */ + AV_PIX_FMT_CUDA, + AV_PIX_FMT_0RGB=0x123+4,///< packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined AV_PIX_FMT_RGB0, ///< packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined AV_PIX_FMT_0BGR, ///< packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined @@ -292,6 +297,12 @@ enum AVPixelFormat { AV_PIX_FMT_P010LE, ///< like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, little-endian AV_PIX_FMT_P010BE, ///< like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, big-endian + AV_PIX_FMT_GBRAP12BE, ///< planar GBR 4:4:4:4 48bpp, big-endian + AV_PIX_FMT_GBRAP12LE, ///< planar GBR 4:4:4:4 48bpp, little-endian + + AV_PIX_FMT_GBRAP10BE, ///< planar GBR 4:4:4:4 40bpp, big-endian + AV_PIX_FMT_GBRAP10LE, ///< planar GBR 4:4:4:4 40bpp, little-endian + AV_PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -347,6 +358,8 @@ enum AVPixelFormat { #define AV_PIX_FMT_GBRP12 AV_PIX_FMT_NE(GBRP12BE, GBRP12LE) #define AV_PIX_FMT_GBRP14 AV_PIX_FMT_NE(GBRP14BE, GBRP14LE) #define AV_PIX_FMT_GBRP16 AV_PIX_FMT_NE(GBRP16BE, GBRP16LE) +#define AV_PIX_FMT_GBRAP10 AV_PIX_FMT_NE(GBRAP10BE, GBRAP10LE) +#define AV_PIX_FMT_GBRAP12 AV_PIX_FMT_NE(GBRAP12BE, GBRAP12LE) #define AV_PIX_FMT_GBRAP16 AV_PIX_FMT_NE(GBRAP16BE, GBRAP16LE) #define AV_PIX_FMT_BAYER_BGGR16 AV_PIX_FMT_NE(BAYER_BGGR16BE, BAYER_BGGR16LE) @@ -407,10 +420,11 @@ enum AVColorTransferCharacteristic { AVCOL_TRC_IEC61966_2_4 = 11, ///< IEC 61966-2-4 AVCOL_TRC_BT1361_ECG = 12, ///< ITU-R BT1361 Extended Colour Gamut AVCOL_TRC_IEC61966_2_1 = 13, ///< IEC 61966-2-1 (sRGB or sYCC) - AVCOL_TRC_BT2020_10 = 14, ///< ITU-R BT2020 for 10 bit system - AVCOL_TRC_BT2020_12 = 15, ///< ITU-R BT2020 for 12 bit system - AVCOL_TRC_SMPTEST2084 = 16, ///< SMPTE ST 2084 for 10, 12, 14 and 16 bit systems + AVCOL_TRC_BT2020_10 = 14, ///< ITU-R BT2020 for 10-bit system + AVCOL_TRC_BT2020_12 = 15, ///< ITU-R BT2020 for 12-bit system + AVCOL_TRC_SMPTEST2084 = 16, ///< SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems AVCOL_TRC_SMPTEST428_1 = 17, ///< SMPTE ST 428-1 + AVCOL_TRC_ARIB_STD_B67 = 18, ///< ARIB STD-B67, known as "Hybrid log-gamma" AVCOL_TRC_NB, ///< Not part of ABI }; @@ -424,8 +438,8 @@ enum AVColorSpace { AVCOL_SPC_RESERVED = 3, AVCOL_SPC_FCC = 4, ///< FCC Title 47 Code of Federal Regulations 73.682 (a)(20) AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 - AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above - AVCOL_SPC_SMPTE240M = 7, + AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC + AVCOL_SPC_SMPTE240M = 7, ///< functionally identical to above AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 AVCOL_SPC_BT2020_NCL = 9, ///< ITU-R BT2020 non-constant luminance system AVCOL_SPC_BT2020_CL = 10, ///< ITU-R BT2020 constant luminance system @@ -461,8 +475,8 @@ enum AVColorRange { */ enum AVChromaLocation { AVCHROMA_LOC_UNSPECIFIED = 0, - AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4 4:2:0, h264 default for 4:2:0 - AVCHROMA_LOC_CENTER = 2, ///< mpeg1 4:2:0, jpeg 4:2:0, h263 4:2:0 + AVCHROMA_LOC_LEFT = 1, ///< MPEG-2/4 4:2:0, H.264 default for 4:2:0 + AVCHROMA_LOC_CENTER = 2, ///< MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0 AVCHROMA_LOC_TOPLEFT = 3, ///< ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2 AVCHROMA_LOC_TOP = 4, AVCHROMA_LOC_BOTTOMLEFT = 5, diff --git a/ThirdParty/ffmpeg/include/libavutil/replaygain.h b/ThirdParty/ffmpeg/include/libavutil/replaygain.h index 5c03e1993..b49bf1a3d 100644 --- a/ThirdParty/ffmpeg/include/libavutil/replaygain.h +++ b/ThirdParty/ffmpeg/include/libavutil/replaygain.h @@ -1,5 +1,4 @@ /* - * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or diff --git a/ThirdParty/ffmpeg/include/libavutil/samplefmt.h b/ThirdParty/ffmpeg/include/libavutil/samplefmt.h index 6a8a031c0..57da2784d 100644 --- a/ThirdParty/ffmpeg/include/libavutil/samplefmt.h +++ b/ThirdParty/ffmpeg/include/libavutil/samplefmt.h @@ -32,7 +32,6 @@ * * Audio sample format enumeration and related convenience functions. * @{ - * */ /** diff --git a/ThirdParty/ffmpeg/include/libavutil/stereo3d.h b/ThirdParty/ffmpeg/include/libavutil/stereo3d.h index 1135dc9dd..19c541643 100644 --- a/ThirdParty/ffmpeg/include/libavutil/stereo3d.h +++ b/ThirdParty/ffmpeg/include/libavutil/stereo3d.h @@ -149,4 +149,22 @@ AVStereo3D *av_stereo3d_alloc(void); */ AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame); +/** + * Provide a human-readable name of a given stereo3d type. + * + * @param type The input stereo3d type value. + * + * @return The name of the stereo3d value, or "unknown". + */ +const char *av_stereo3d_type_name(unsigned int type); + +/** + * Get the AVStereo3DType form a human-readable name. + * + * @param type The input string. + * + * @return The AVStereo3DType value, or -1 if not found. + */ +int av_stereo3d_from_name(const char *name); + #endif /* AVUTIL_STEREO3D_H */ diff --git a/ThirdParty/ffmpeg/include/libavutil/threadmessage.h b/ThirdParty/ffmpeg/include/libavutil/threadmessage.h index e256cae9d..8480a0a3d 100644 --- a/ThirdParty/ffmpeg/include/libavutil/threadmessage.h +++ b/ThirdParty/ffmpeg/include/libavutil/threadmessage.h @@ -69,10 +69,10 @@ int av_thread_message_queue_recv(AVThreadMessageQueue *mq, /** * Set the sending error code. * - * If the error code is set to non-zero, av_thread_message_queue_recv() will - * return it immediately when there are no longer available messages. - * Conventional values, such as AVERROR_EOF or AVERROR(EAGAIN), can be used - * to cause the receiving thread to stop or suspend its operation. + * If the error code is set to non-zero, av_thread_message_queue_send() will + * return it immediately. Conventional values, such as AVERROR_EOF or + * AVERROR(EAGAIN), can be used to cause the sending thread to stop or + * suspend its operation. */ void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, int err); @@ -80,10 +80,10 @@ void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, /** * Set the receiving error code. * - * If the error code is set to non-zero, av_thread_message_queue_send() will - * return it immediately. Conventional values, such as AVERROR_EOF or - * AVERROR(EAGAIN), can be used to cause the sending thread to stop or - * suspend its operation. + * If the error code is set to non-zero, av_thread_message_queue_recv() will + * return it immediately when there are no longer available messages. + * Conventional values, such as AVERROR_EOF or AVERROR(EAGAIN), can be used + * to cause the receiving thread to stop or suspend its operation. */ void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, int err); diff --git a/ThirdParty/ffmpeg/include/libavutil/tree.h b/ThirdParty/ffmpeg/include/libavutil/tree.h index e1aefaa9f..9a9e11b92 100644 --- a/ThirdParty/ffmpeg/include/libavutil/tree.h +++ b/ThirdParty/ffmpeg/include/libavutil/tree.h @@ -120,8 +120,8 @@ void av_tree_destroy(struct AVTreeNode *t); /** * Apply enu(opaque, &elem) to all the elements in the tree in a given range. * - * @param cmp a comparison function that returns < 0 for a element below the - * range, > 0 for a element above the range and == 0 for a + * @param cmp a comparison function that returns < 0 for an element below the + * range, > 0 for an element above the range and == 0 for an * element inside the range * * @note The cmp function should use the same ordering used to construct the diff --git a/ThirdParty/ffmpeg/include/libavutil/version.h b/ThirdParty/ffmpeg/include/libavutil/version.h index 0ea8c7946..07618fc0b 100644 --- a/ThirdParty/ffmpeg/include/libavutil/version.h +++ b/ThirdParty/ffmpeg/include/libavutil/version.h @@ -64,8 +64,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 17 -#define LIBAVUTIL_VERSION_MICRO 103 +#define LIBAVUTIL_VERSION_MINOR 28 +#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/ThirdParty/ffmpeg/lib/libavcodec.a b/ThirdParty/ffmpeg/lib/libavcodec.a index c8b905214..0e870492b 100644 Binary files a/ThirdParty/ffmpeg/lib/libavcodec.a and b/ThirdParty/ffmpeg/lib/libavcodec.a differ diff --git a/ThirdParty/ffmpeg/lib/libavformat.a b/ThirdParty/ffmpeg/lib/libavformat.a index 811c006ee..58177698b 100644 Binary files a/ThirdParty/ffmpeg/lib/libavformat.a and b/ThirdParty/ffmpeg/lib/libavformat.a differ diff --git a/ThirdParty/ffmpeg/lib/libavutil.a b/ThirdParty/ffmpeg/lib/libavutil.a index 4d1058035..833475995 100644 Binary files a/ThirdParty/ffmpeg/lib/libavutil.a and b/ThirdParty/ffmpeg/lib/libavutil.a differ diff --git a/ThirdParty/ffmpeg/lib/pkgconfig/libavcodec.pc b/ThirdParty/ffmpeg/lib/pkgconfig/libavcodec.pc index 6d13066a4..6992a4a50 100644 --- a/ThirdParty/ffmpeg/lib/pkgconfig/libavcodec.pc +++ b/ThirdParty/ffmpeg/lib/pkgconfig/libavcodec.pc @@ -5,10 +5,10 @@ includedir=${prefix}/include Name: libavcodec Description: FFmpeg codec library -Version: 57.24.102 -Requires: libavutil >= 55.17.103 +Version: 57.48.101 +Requires: libavutil >= 55.28.100 Requires.private: Conflicts: -Libs: -L${libdir} -lavcodec -framework CoreFoundation -framework VideoToolbox -framework CoreMedia -framework QuartzCore -framework CoreVideo -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore -liconv -Wl,-framework,CoreFoundation -Wl,-framework,Security -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -L/usr/local/Cellar/dcadec/0.2.0/lib -ldcadec -lm -lz -pthread -framework CoreServices +Libs: -L${libdir} -lavcodec -framework QuartzCore -framework CoreFoundation -framework VideoToolbox -framework CoreMedia -framework CoreVideo -framework CoreFoundation -framework AudioToolbox -framework CoreMedia -framework VideoDecodeAcceleration -framework CoreFoundation -framework QuartzCore -liconv -Wl,-framework,CoreFoundation -Wl,-framework,Security -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -lm -lz -pthread -framework CoreServices Libs.private: Cflags: -I${includedir} diff --git a/ThirdParty/ffmpeg/lib/pkgconfig/libavformat.pc b/ThirdParty/ffmpeg/lib/pkgconfig/libavformat.pc index add252287..621696d01 100644 --- a/ThirdParty/ffmpeg/lib/pkgconfig/libavformat.pc +++ b/ThirdParty/ffmpeg/lib/pkgconfig/libavformat.pc @@ -5,10 +5,10 @@ includedir=${prefix}/include Name: libavformat Description: FFmpeg container format library -Version: 57.25.100 -Requires: libavcodec >= 57.24.102, libavutil >= 55.17.103 +Version: 57.41.100 +Requires: libavcodec >= 57.48.101, libavutil >= 55.28.100 Requires.private: Conflicts: -Libs: -L${libdir} -lavformat -framework CoreFoundation -framework VideoToolbox -framework CoreMedia -framework QuartzCore -framework CoreVideo -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore -liconv -Wl,-framework,CoreFoundation -Wl,-framework,Security -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -L/usr/local/Cellar/dcadec/0.2.0/lib -ldcadec -lm -lz -pthread -framework CoreServices +Libs: -L${libdir} -lavformat -framework QuartzCore -framework CoreFoundation -framework VideoToolbox -framework CoreMedia -framework CoreVideo -framework CoreFoundation -framework AudioToolbox -framework CoreMedia -framework VideoDecodeAcceleration -framework CoreFoundation -framework QuartzCore -liconv -Wl,-framework,CoreFoundation -Wl,-framework,Security -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -lm -lz -pthread -framework CoreServices Libs.private: Cflags: -I${includedir} diff --git a/ThirdParty/ffmpeg/lib/pkgconfig/libavutil.pc b/ThirdParty/ffmpeg/lib/pkgconfig/libavutil.pc index c4828f41d..5567d47f5 100644 --- a/ThirdParty/ffmpeg/lib/pkgconfig/libavutil.pc +++ b/ThirdParty/ffmpeg/lib/pkgconfig/libavutil.pc @@ -5,7 +5,7 @@ includedir=${prefix}/include Name: libavutil Description: FFmpeg utility library -Version: 55.17.103 +Version: 55.28.100 Requires: Requires.private: Conflicts: