diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 19:26:27 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 19:26:27 +0000 |
commit | 11309735fce8bf91f70643e955c6153b79f40095 (patch) | |
tree | 6a87158dbb3995246322c135de4112336ff38e45 | |
parent | bfd71998f58c08dafbdb58ebf59e56b1c7845fc3 (diff) | |
download | chromium_src-11309735fce8bf91f70643e955c6153b79f40095.zip chromium_src-11309735fce8bf91f70643e955c6153b79f40095.tar.gz chromium_src-11309735fce8bf91f70643e955c6153b79f40095.tar.bz2 |
New FFmpeg public API headers to match our source tarball in deps.
Review URL: http://codereview.chromium.org/113748
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16771 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | media/base/media_posix.cc | 200 | ||||
-rw-r--r-- | media/bench/bench.cc | 8 | ||||
-rw-r--r-- | media/filters/ffmpeg_audio_decoder.cc | 11 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer_unittest.cc | 8 | ||||
-rw-r--r-- | media/filters/ffmpeg_video_decoder.cc | 13 | ||||
-rw-r--r-- | third_party/ffmpeg/README.chromium | 17 | ||||
-rw-r--r-- | third_party/ffmpeg/avcodec-52.def | 10 | ||||
-rwxr-xr-x | third_party/ffmpeg/ffmpeg.gyp | 1 | ||||
-rw-r--r-- | third_party/ffmpeg/include/libavcodec/avcodec.h | 383 | ||||
-rw-r--r-- | third_party/ffmpeg/include/libavdevice/avdevice.h | 46 | ||||
-rw-r--r-- | third_party/ffmpeg/include/libavformat/avformat.h | 98 | ||||
-rw-r--r-- | third_party/ffmpeg/include/libavutil/avutil.h | 2 | ||||
-rw-r--r-- | third_party/ffmpeg/include/libavutil/fifo.h | 8 | ||||
-rw-r--r-- | third_party/ffmpeg/include/libavutil/pixfmt.h | 11 |
14 files changed, 519 insertions, 297 deletions
diff --git a/media/base/media_posix.cc b/media/base/media_posix.cc index 57e1b77..cd6bbe3 100644 --- a/media/base/media_posix.cc +++ b/media/base/media_posix.cc @@ -13,28 +13,56 @@ #include "base/path_service.h" #include "media/filters/ffmpeg_common.h" -// We create stub references to dynamically loaded functions in ffmpeg +// We create stub references to dynamically loaded functions in FFmpeg // for ease of linking. // // TODO(ajwong): We need to find a more maintainable way to have this work. -// Also, this code should really be in the ffmpeg wrapper, and not here +// Also, this code should really be in the FFmpeg wrapper, and not here // in the media level. The concept of "weak symbols" looks like it might // be promising, but I don't quite understand it yet. +// +// TODO(scherkus): I am *this close* to writing the world's coolest macro to +// make modifying this file easier. extern "C" { -int (*av_get_bits_per_sample_format_ptr)(enum SampleFormat sample_fmt); +// libavcodec functions. +void (*av_free_packet_ptr)(AVPacket* pkt) = NULL; +void av_free_packet(AVPacket* pkt) { + av_free_packet_ptr(pkt); +} + +int (*av_get_bits_per_sample_format_ptr)(enum SampleFormat sample_fmt) = NULL; int av_get_bits_per_sample_format(enum SampleFormat sample_fmt) { return av_get_bits_per_sample_format_ptr(sample_fmt); } -int (*av_new_packet_ptr)(AVPacket* pkt, int size); +void (*av_init_packet_ptr)(AVPacket* pkt) = NULL; +void av_init_packet(AVPacket* pkt) { + av_init_packet_ptr(pkt); +} + +int (*av_new_packet_ptr)(AVPacket* pkt, int size) = NULL; int av_new_packet(AVPacket* pkt, int size) { return av_new_packet_ptr(pkt, size); } -void (*avcodec_init_ptr)(void) = NULL; -void avcodec_init(void) { - avcodec_init_ptr(); +AVFrame* (*avcodec_alloc_frame_ptr)(void) = NULL; +AVFrame* avcodec_alloc_frame(void) { + return avcodec_alloc_frame_ptr(); +} + +int (*avcodec_decode_audio3_ptr)(AVCodecContext* avctx, int16_t* samples, + int* frame_size_ptr, AVPacket* avpkt) = NULL; +int avcodec_decode_audio3(AVCodecContext* avctx, int16_t* samples, + int* frame_size_ptr, AVPacket* avpkt) { + return avcodec_decode_audio3_ptr(avctx, samples, frame_size_ptr, avpkt); +} + +int (*avcodec_decode_video2_ptr)(AVCodecContext* avctx, AVFrame* picture, + int* got_picture_ptr, AVPacket* avpkt) = NULL; +int avcodec_decode_video2(AVCodecContext* avctx, AVFrame* picture, + int* got_picture_ptr, AVPacket* avpkt) { + return avcodec_decode_video2_ptr(avctx, picture, got_picture_ptr, avpkt); } AVCodec* (*avcodec_find_decoder_ptr)(enum CodecID id) = NULL; @@ -42,9 +70,9 @@ AVCodec* avcodec_find_decoder(enum CodecID id) { return avcodec_find_decoder_ptr(id); } -int (*avcodec_thread_init_ptr)(AVCodecContext* s, int thread_count) = NULL; -int avcodec_thread_init(AVCodecContext* s, int thread_count) { - return avcodec_thread_init_ptr(s, thread_count); +void (*avcodec_init_ptr)(void) = NULL; +void avcodec_init(void) { + avcodec_init_ptr(); } int (*avcodec_open_ptr)(AVCodecContext* avctx, AVCodec* codec) = NULL; @@ -52,37 +80,16 @@ int avcodec_open(AVCodecContext* avctx, AVCodec* codec) { return avcodec_open_ptr(avctx, codec); } -AVFrame* (*avcodec_alloc_frame_ptr)(void) = NULL; -AVFrame* avcodec_alloc_frame(void) { - return avcodec_alloc_frame_ptr(); -} - -int (*avcodec_decode_audio2_ptr)(AVCodecContext* avctx, int16_t* samples, - int* frame_size_ptr, const uint8_t* buf, - int buf_size) = NULL; -int avcodec_decode_audio2(AVCodecContext* avctx, int16_t* samples, - int* frame_size_ptr, - const uint8_t* buf, int buf_size) { - - return avcodec_decode_audio2_ptr(avctx, samples, frame_size_ptr, buf, - buf_size); -} - - -int (*avcodec_decode_video_ptr)(AVCodecContext* avctx, AVFrame* picture, - int* got_picture_ptr, const uint8_t* buf, - int buf_size) = NULL; -int avcodec_decode_video(AVCodecContext* avctx, AVFrame* picture, - int* got_picture_ptr, const uint8_t* buf, - int buf_size) { - return avcodec_decode_video_ptr(avctx, picture, got_picture_ptr, buf, - buf_size); +int (*avcodec_thread_init_ptr)(AVCodecContext* s, int thread_count) = NULL; +int avcodec_thread_init(AVCodecContext* s, int thread_count) { + return avcodec_thread_init_ptr(s, thread_count); } -void (*av_register_all_ptr)(void); -void av_register_all(void) { - av_register_all_ptr(); +// libavformat functions. +int (*av_find_stream_info_ptr)(AVFormatContext* ic) = NULL; +int av_find_stream_info(AVFormatContext* ic) { + return av_find_stream_info_ptr(ic); } int (*av_open_input_file_ptr)(AVFormatContext** ic_ptr, const char* filename, @@ -94,21 +101,14 @@ int av_open_input_file(AVFormatContext** ic_ptr, const char* filename, return av_open_input_file_ptr(ic_ptr, filename, fmt, buf_size, ap); } -int (*av_find_stream_info_ptr)(AVFormatContext* ic) = NULL; -int av_find_stream_info(AVFormatContext* ic) { - return av_find_stream_info_ptr(ic); -} - int (*av_read_frame_ptr)(AVFormatContext* s, AVPacket* pkt) = NULL; int av_read_frame(AVFormatContext* s, AVPacket* pkt) { return av_read_frame_ptr(s, pkt); } -int (*av_seek_frame_ptr)(AVFormatContext* s, int stream_index, - int64_t timestamp, int flags) = NULL; -int av_seek_frame(AVFormatContext* s, int stream_index, - int64_t timestamp, int flags) { - return av_seek_frame_ptr(s, stream_index, timestamp, flags); +void (*av_register_all_ptr)(void) = NULL; +void av_register_all(void) { + av_register_all_ptr(); } int (*av_register_protocol_ptr)(URLProtocol* protocol) = NULL; @@ -116,17 +116,25 @@ int av_register_protocol(URLProtocol* protocol) { return av_register_protocol_ptr(protocol); } - -void* (*av_malloc_ptr)(unsigned int size) = NULL; -void* av_malloc(unsigned int size) { - return av_malloc_ptr(size); +int (*av_seek_frame_ptr)(AVFormatContext* s, int stream_index, + int64_t timestamp, int flags) = NULL; +int av_seek_frame(AVFormatContext* s, int stream_index, + int64_t timestamp, int flags) { + return av_seek_frame_ptr(s, stream_index, timestamp, flags); } + +// libavutil functions. void (*av_free_ptr)(void* ptr) = NULL; void av_free(void* ptr) { return av_free_ptr(ptr); } +void* (*av_malloc_ptr)(unsigned int size) = NULL; +void* av_malloc(unsigned int size) { + return av_malloc_ptr(size); +} + int64_t (*av_rescale_q_ptr)(int64_t a, AVRational bq, AVRational cq) = NULL; int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) { return av_rescale_q_ptr(a, bq, cq); @@ -196,87 +204,97 @@ bool InitializeMediaLibrary(const FilePath& module_dir) { // TODO(ajwong): Extract this to somewhere saner, and hopefully // autogenerate the bindings from the .def files. Having all this // code here is incredibly ugly. + + // libavcodec functions. + av_free_packet_ptr = + reinterpret_cast<void (*)(AVPacket*)>( + dlsym(libs[FILE_LIBAVCODEC], "av_free_packet")); av_get_bits_per_sample_format_ptr = reinterpret_cast<int (*)(enum SampleFormat)>( dlsym(libs[FILE_LIBAVCODEC], "av_get_bits_per_sample_format")); + av_init_packet_ptr = + reinterpret_cast<void (*)(AVPacket*)>( + dlsym(libs[FILE_LIBAVCODEC], "av_init_packet")); av_new_packet_ptr = reinterpret_cast<int (*)(AVPacket*, int)>( dlsym(libs[FILE_LIBAVCODEC], "av_new_packet")); - avcodec_init_ptr = - reinterpret_cast<void(*)(void)>( - dlsym(libs[FILE_LIBAVCODEC], "avcodec_init")); + avcodec_alloc_frame_ptr = + reinterpret_cast<AVFrame* (*)(void)>( + dlsym(libs[FILE_LIBAVCODEC], "avcodec_alloc_frame")); + avcodec_decode_audio3_ptr = + reinterpret_cast<int (*)(AVCodecContext*, int16_t*, int*, AVPacket*)>( + dlsym(libs[FILE_LIBAVCODEC], "avcodec_decode_audio3")); + avcodec_decode_video2_ptr = + reinterpret_cast<int (*)(AVCodecContext*, AVFrame*, int*, AVPacket*)>( + dlsym(libs[FILE_LIBAVCODEC], "avcodec_decode_video2")); avcodec_find_decoder_ptr = reinterpret_cast<AVCodec* (*)(enum CodecID)>( dlsym(libs[FILE_LIBAVCODEC], "avcodec_find_decoder")); - avcodec_thread_init_ptr = - reinterpret_cast<int (*)(AVCodecContext*, int)>( - dlsym(libs[FILE_LIBAVCODEC], "avcodec_thread_init")); + avcodec_init_ptr = + reinterpret_cast<void (*)(void)>( + dlsym(libs[FILE_LIBAVCODEC], "avcodec_init")); avcodec_open_ptr = reinterpret_cast<int (*)(AVCodecContext*, AVCodec*)>( dlsym(libs[FILE_LIBAVCODEC], "avcodec_open")); - avcodec_alloc_frame_ptr = - reinterpret_cast<AVFrame* (*)(void)>( - dlsym(libs[FILE_LIBAVCODEC], "avcodec_alloc_frame")); - avcodec_decode_audio2_ptr = - reinterpret_cast<int (*)(AVCodecContext*, int16_t*, int*, - const uint8_t*, int)>( - dlsym(libs[FILE_LIBAVCODEC], "avcodec_decode_audio2")); - avcodec_decode_video_ptr = - reinterpret_cast<int (*)(AVCodecContext*, AVFrame*, int*, - const uint8_t*, int)>( - dlsym(libs[FILE_LIBAVCODEC], "avcodec_decode_video")); + avcodec_thread_init_ptr = + reinterpret_cast<int (*)(AVCodecContext*, int)>( + dlsym(libs[FILE_LIBAVCODEC], "avcodec_thread_init")); - av_register_all_ptr = - reinterpret_cast<void(*)(void)>( - dlsym(libs[FILE_LIBAVFORMAT], "av_register_all")); + // libavformat functions. + av_find_stream_info_ptr = + reinterpret_cast<int (*)(AVFormatContext*)>( + dlsym(libs[FILE_LIBAVFORMAT], "av_find_stream_info")); av_open_input_file_ptr = reinterpret_cast<int (*)(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)>( dlsym(libs[FILE_LIBAVFORMAT], "av_open_input_file")); - av_find_stream_info_ptr = - reinterpret_cast<int (*)(AVFormatContext*)>( - dlsym(libs[FILE_LIBAVFORMAT], "av_find_stream_info")); av_read_frame_ptr = reinterpret_cast<int (*)(AVFormatContext*, AVPacket*)>( dlsym(libs[FILE_LIBAVFORMAT], "av_read_frame")); - av_seek_frame_ptr = - reinterpret_cast<int (*)(AVFormatContext*, int, int64_t, int)>( - dlsym(libs[FILE_LIBAVFORMAT], "av_seek_frame")); + av_register_all_ptr = + reinterpret_cast<void (*)(void)>( + dlsym(libs[FILE_LIBAVFORMAT], "av_register_all")); av_register_protocol_ptr = reinterpret_cast<int (*)(URLProtocol*)>( dlsym(libs[FILE_LIBAVFORMAT], "av_register_protocol")); + av_seek_frame_ptr = + reinterpret_cast<int (*)(AVFormatContext*, int, int64_t, int)>( + dlsym(libs[FILE_LIBAVFORMAT], "av_seek_frame")); - av_malloc_ptr = - reinterpret_cast<void* (*)(unsigned int)>( - dlsym(libs[FILE_LIBAVUTIL], "av_malloc")); + // libavutil functions. av_free_ptr = reinterpret_cast<void (*)(void*)>( dlsym(libs[FILE_LIBAVUTIL], "av_free")); + av_malloc_ptr = + reinterpret_cast<void* (*)(unsigned int)>( + dlsym(libs[FILE_LIBAVUTIL], "av_malloc")); av_rescale_q_ptr = reinterpret_cast<int64_t (*)(int64_t, AVRational, AVRational)>( dlsym(libs[FILE_LIBAVUTIL], "av_rescale_q")); // Check that all the symbols were loaded correctly before returning true. - if (av_get_bits_per_sample_format_ptr && + if (av_free_packet_ptr && + av_get_bits_per_sample_format_ptr && + av_init_packet_ptr && av_new_packet_ptr && - avcodec_init_ptr && + avcodec_alloc_frame_ptr && + avcodec_decode_audio3_ptr && + avcodec_decode_video2_ptr && avcodec_find_decoder_ptr && - avcodec_thread_init_ptr && + avcodec_init_ptr && avcodec_open_ptr && - avcodec_alloc_frame_ptr && - avcodec_decode_audio2_ptr && - avcodec_decode_video_ptr && + avcodec_thread_init_ptr && - av_register_all_ptr && - av_open_input_file_ptr && av_find_stream_info_ptr && + av_open_input_file_ptr && av_read_frame_ptr && - av_seek_frame_ptr && + av_register_all_ptr && av_register_protocol_ptr && + av_seek_frame_ptr && - av_malloc_ptr && av_free_ptr && + av_malloc_ptr && av_rescale_q_ptr) { return true; } diff --git a/media/bench/bench.cc b/media/bench/bench.cc index 42deacf..147b91a 100644 --- a/media/bench/bench.cc +++ b/media/bench/bench.cc @@ -189,12 +189,12 @@ int main(int argc, const char** argv) { base::TimeTicks decode_start = base::TimeTicks::HighResNow(); if (target_codec == CODEC_TYPE_AUDIO) { int size_out = AVCODEC_MAX_AUDIO_FRAME_SIZE; - result = avcodec_decode_audio2(codec_context, samples, &size_out, - packet.data, packet.size); + result = avcodec_decode_audio3(codec_context, samples, &size_out, + &packet); } else if (target_codec == CODEC_TYPE_VIDEO) { int got_picture = 0; - result = avcodec_decode_video(codec_context, frame, &got_picture, - packet.data, packet.size); + result = avcodec_decode_video2(codec_context, frame, &got_picture, + &packet); } else { NOTREACHED(); } diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc index e44880a..808904c7 100644 --- a/media/filters/ffmpeg_audio_decoder.cc +++ b/media/filters/ffmpeg_audio_decoder.cc @@ -74,13 +74,18 @@ void FFmpegAudioDecoder::OnStop() { } void FFmpegAudioDecoder::OnDecode(Buffer* input) { + // Due to FFmpeg API changes we no longer have const read-only pointers. + AVPacket packet; + av_init_packet(&packet); + packet.data = const_cast<uint8*>(input->GetData()); + packet.size = input->GetDataSize(); + int16_t* output_buffer = reinterpret_cast<int16_t*>(output_buffer_.get()); int output_buffer_size = kOutputBufferSize; - int result = avcodec_decode_audio2(codec_context_, + int result = avcodec_decode_audio3(codec_context_, output_buffer, &output_buffer_size, - input->GetData(), - input->GetDataSize()); + &packet); // TODO(ajwong): Consider if kOutputBufferSize should just be an int instead // of a size_t. diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc index 6b4f06d..157f2ae 100644 --- a/media/filters/ffmpeg_demuxer_unittest.cc +++ b/media/filters/ffmpeg_demuxer_unittest.cc @@ -143,6 +143,14 @@ int64 av_rescale_q(int64 a, AVRational bq, AVRational cq) { return a * num / den; } +void av_free_packet(AVPacket* packet) { + if (packet->destruct) { + packet->destruct(packet); + packet->data = NULL; + packet->size = 0; + } +} + void DestructPacket(AVPacket* packet) { delete [] packet->data; --g_outstanding_packets_av_new_frame; diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc index 6d5505a4..b80d215 100644 --- a/media/filters/ffmpeg_video_decoder.cc +++ b/media/filters/ffmpeg_video_decoder.cc @@ -81,17 +81,20 @@ void FFmpegVideoDecoder::OnDecode(Buffer* buffer) { times.duration = buffer->GetDuration(); time_queue_.push(times); - // Cast everything to FFmpeg types. - const uint8_t* data_in = buffer->GetData(); - const size_t size_in = buffer->GetDataSize(); + // Create a packet for input data. + // Due to FFmpeg API changes we no longer have const read-only pointers. + AVPacket packet; + av_init_packet(&packet); + packet.data = const_cast<uint8*>(buffer->GetData()); + packet.size = buffer->GetDataSize(); // We don't allocate AVFrame on the stack since different versions of FFmpeg // may change the size of AVFrame, causing stack corruption. The solution is // to let FFmpeg allocate the structure via avcodec_alloc_frame(). int decoded = 0; scoped_ptr_malloc<AVFrame, ScopedPtrAVFree> yuv_frame(avcodec_alloc_frame()); - int result = avcodec_decode_video(codec_context_, yuv_frame.get(), &decoded, - data_in, size_in); + int result = avcodec_decode_video2(codec_context_, yuv_frame.get(), &decoded, + &packet); // Log the problem if we can't decode a video frame. if (result < 0) { diff --git a/third_party/ffmpeg/README.chromium b/third_party/ffmpeg/README.chromium index 816d4d0..9548c1d 100644 --- a/third_party/ffmpeg/README.chromium +++ b/third_party/ffmpeg/README.chromium @@ -1,12 +1,16 @@ This contains FFmpeg's public header files from the output of a "make install" -command. The header files are from FFmpeg revision 18286. +command. The header files are from Chromium's copy of FFmpeg. Steps to reproduce: - 1) If on Windows, refer to http://ffmpeg.arrozcru.org for environment setup - 2) Check out FFmpeg from their repository - 3) ./configure --prefix=/path/to/chrome/src/third_party/ffmpeg - 4) make && make install - 5) Remove bin and lib folders, leaving the include folder behind + 1) If on Windows, refer to our MinGW/MSYS environment setup: + http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/mingw/ + 2) Grab Chromium's copy of FFmpeg: + http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/ffmpeg/ + 3) Follow the instructions to build and install. + 4) Go to your install location and copy the following into the Chromium tree: + /path/to/install/include/libavcodec + /path/to/install/include/libavformat + /path/to/install/include/libavutil The project contains some hand-written DEF files used to generate import libraries to permit dynamically loading FFmpeg. The libaries are linked in @@ -17,4 +21,3 @@ export every method by ordinal, which makes binary compatability with different builds of FFmpeg difficult if not impossible. Furthermore, it is much easier to update a DEF file instead of rebuilding FFmpeg to generate new import libraries. - diff --git a/third_party/ffmpeg/avcodec-52.def b/third_party/ffmpeg/avcodec-52.def index 5c0ebab..cadf0c0a 100644 --- a/third_party/ffmpeg/avcodec-52.def +++ b/third_party/ffmpeg/avcodec-52.def @@ -1,15 +1,13 @@ LIBRARY avcodec-52 EXPORTS + av_free_packet av_get_bits_per_sample_format + av_init_packet av_new_packet - avcodec_alloc_context avcodec_alloc_frame - avcodec_decode_audio2 - avcodec_decode_video + avcodec_decode_audio3 + avcodec_decode_video2 avcodec_find_decoder - avcodec_get_frame_defaults avcodec_init avcodec_open - avcodec_thread_execute - avcodec_thread_free avcodec_thread_init diff --git a/third_party/ffmpeg/ffmpeg.gyp b/third_party/ffmpeg/ffmpeg.gyp index 0b069c8..30d03b7 100755 --- a/third_party/ffmpeg/ffmpeg.gyp +++ b/third_party/ffmpeg/ffmpeg.gyp @@ -23,7 +23,6 @@ 'include/libavcodec/opt.h', 'include/libavcodec/vdpau.h', 'include/libavcodec/xvmc.h', - 'include/libavdevice/avdevice.h', 'include/libavformat/avformat.h', 'include/libavformat/avio.h', 'include/libavutil/adler32.h', diff --git a/third_party/ffmpeg/include/libavcodec/avcodec.h b/third_party/ffmpeg/include/libavcodec/avcodec.h index 2b9adf2..55935e39 100644 --- a/third_party/ffmpeg/include/libavcodec/avcodec.h +++ b/third_party/ffmpeg/include/libavcodec/avcodec.h @@ -30,8 +30,8 @@ #include "libavutil/avutil.h" #define LIBAVCODEC_VERSION_MAJOR 52 -#define LIBAVCODEC_VERSION_MINOR 22 -#define LIBAVCODEC_VERSION_MICRO 3 +#define LIBAVCODEC_VERSION_MINOR 28 +#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ @@ -193,6 +193,8 @@ enum CodecID { CODEC_ID_TQI, CODEC_ID_AURA, CODEC_ID_AURA2, + CODEC_ID_V210X, + CODEC_ID_TMV, /* various PCM "codecs" */ CODEC_ID_PCM_S16LE= 0x10000, @@ -313,6 +315,7 @@ enum CodecID { CODEC_ID_MP1, CODEC_ID_TWINVQ, CODEC_ID_TRUEHD, + CODEC_ID_MP4ALS, /* subtitle codecs */ CODEC_ID_DVD_SUBTITLE= 0x17000, @@ -379,13 +382,17 @@ enum SampleFormat { /* Audio channel convenience macros */ #define CH_LAYOUT_MONO (CH_FRONT_CENTER) #define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT) +#define CH_LAYOUT_2_1 (CH_LAYOUT_STEREO|CH_BACK_CENTER) #define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER) +#define CH_LAYOUT_4POINT0 (CH_LAYOUT_SURROUND|CH_BACK_CENTER) +#define CH_LAYOUT_2_2 (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT) #define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT) #define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT) #define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY) +#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT) +#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY) #define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT) -#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_SURROUND|CH_LOW_FREQUENCY|\ - CH_BACK_LEFT|CH_BACK_RIGHT|\ +#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\ CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER) #define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT) @@ -435,6 +442,43 @@ enum AVDiscard{ AVDISCARD_ALL = 48, ///< discard all }; +enum AVColorPrimaries{ + AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B + AVCOL_PRI_UNSPECIFIED=2, + AVCOL_PRI_BT470M =4, + AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM + AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC + AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above + AVCOL_PRI_FILM =8, + AVCOL_PRI_NB , ///< Not part of ABI +}; + +enum AVColorTransferCharacteristic{ + AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361 + AVCOL_TRC_UNSPECIFIED=2, + AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM + AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG + AVCOL_TRC_NB , ///< Not part of ABI +}; + +enum AVColorSpace{ + AVCOL_SPC_RGB =0, + AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B + AVCOL_SPC_UNSPECIFIED=2, + AVCOL_SPC_FCC =4, + 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_NB , ///< Not part of ABI +}; + +enum AVColorRange{ + AVCOL_RANGE_UNSPECIFIED=0, + AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges + AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges + AVCOL_RANGE_NB , ///< Not part of ABI +}; + typedef struct RcOverride{ int start_frame; int end_frame; @@ -538,6 +582,10 @@ typedef struct RcOverride{ * Codec can export data for HW decoding (VDPAU). */ #define CODEC_CAP_HWACCEL_VDPAU 0x0080 +/** + * Codec supports frame-based multithreading. + */ +#define CODEC_CAP_FRAME_THREADS 0x0100 //The following defines may change, don't expect compatibility if you use them. #define MB_TYPE_INTRA4x4 0x0001 @@ -817,7 +865,20 @@ typedef struct AVPanScan{ * - decoding: Set by libavcodec\ */\ void *hwaccel_picture_private;\ - +\ + /**\ + * the AVCodecContext which ff_get_buffer was last called on\ + * - encoding: Set by libavcodec.\ + * - decoding: Set by libavcodec.\ + */\ + struct AVCodecContext *owner;\ +\ + /**\ + * used by multithreading to store frame-specific info\ + * - encoding: Set by libavcodec.\ + * - decoding: Set by libavcodec.\ + */\ + void *thread_opaque; #define FF_QSCALE_TYPE_MPEG1 0 #define FF_QSCALE_TYPE_MPEG2 1 @@ -842,6 +903,55 @@ typedef struct AVPanScan{ #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update). +typedef struct AVPacket { + /** + * Presentation timestamp in AVStream->time_base units; the time at which + * the decompressed packet will be presented to the user. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + * pts MUST be larger or equal to dts as presentation cannot happen before + * decompression, unless one wants to view hex dumps. Some formats misuse + * the terms dts and pts/cts to mean something different. Such timestamps + * must be converted to true pts/dts before they are stored in AVPacket. + */ + int64_t pts; + /** + * Decompression timestamp in AVStream->time_base units; the time at which + * the packet is decompressed. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + */ + int64_t dts; + uint8_t *data; + int size; + int stream_index; + int flags; + /** + * Duration of this packet in AVStream->time_base units, 0 if unknown. + * Equals next_pts - this_pts in presentation order. + */ + int duration; + void (*destruct)(struct AVPacket *); + void *priv; + int64_t pos; ///< byte position in stream, -1 if unknown + + /** + * Time difference in AVStream->time_base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current packet. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + */ + int64_t convergence_duration; +} AVPacket; +#define PKT_FLAG_KEY 0x0001 + /** * Audio Video Frame. * New fields can be added to the end of FF_COMMON_FRAME with minor version @@ -971,7 +1081,7 @@ typedef struct AVCodecContext { * If non NULL, 'draw_horiz_band' is called by the libavcodec * decoder to draw a horizontal band. It improves cache usage. Not * all codecs can do that. You must check the codec capabilities - * beforehand. + * beforehand. May be called by different threads at the same time. * The function is also used by hardware acceleration APIs. * It is called at least once during frame decoding to pass * the data needed for hardware render. @@ -1006,7 +1116,7 @@ typedef struct AVCodecContext { * Samples per packet, initialized when calling 'init'. */ int frame_size; - int frame_number; ///< audio or video frame number + int frame_number; ///< Number of audio or video frames returned so far int real_pict_num; ///< Returns the real picture number of previous encoded frame. /** @@ -1216,6 +1326,8 @@ typedef struct AVCodecContext { * If pic.reference is set then the frame will be read later by libavcodec. * avcodec_align_dimensions() should be used to find the required width and * height, as they normally need to be rounded up to the next multiple of 16. + * May be called by different threads if frame threading is enabled, but not + * by more than one at the same time. * - encoding: unused * - decoding: Set by libavcodec., user can override. */ @@ -1224,7 +1336,9 @@ typedef struct AVCodecContext { /** * Called to release buffers which were allocated with get_buffer. * A released buffer can be reused in get_buffer(). - * pic.data[*] must be set to NULL. + * pic.data[*] must be set to NULL. May be called by different threads + * if frame threading is enabled, but not more than one at the same time. + * * - encoding: unused * - decoding: Set by libavcodec., user can override. */ @@ -1456,12 +1570,17 @@ typedef struct AVCodecContext { /* lower 16 bits - CPU features */ #define FF_MM_MMX 0x0001 ///< standard MMX #define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW +#if LIBAVCODEC_VERSION_MAJOR < 53 #define FF_MM_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext +#endif +#define FF_MM_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext #define FF_MM_SSE 0x0008 ///< SSE functions #define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions #define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt #define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions #define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions +#define FF_MM_SSE4 0x0100 ///< Penryn SSE4.1 functions +#define FF_MM_SSE42 0x0200 ///< Nehalem SSE4.2 functions #define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT #define FF_MM_ALTIVEC 0x0001 ///< standard AltiVec @@ -2328,7 +2447,7 @@ typedef struct AVCodecContext { */ float rc_min_vbv_overflow_use; - /** + /** * Hardware accelerator in use * - encoding: unused. * - decoding: Set by libavcodec @@ -2355,6 +2474,60 @@ typedef struct AVCodecContext { * - decoding: Set by user */ void *hwaccel_context; + + /** + * Chromaticity coordinates of the source primaries. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorPrimaries color_primaries; + + /** + * Color Transfer Characteristic. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorTransferCharacteristic color_trc; + + /** + * YUV colorspace type. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorSpace colorspace; + + /** + * MPEG vs JPEG YUV range. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorRange color_range; + + /** + * Whether this is a copy of the context which had init() called on it. + * This is used by multithreading - shared tables and picture pointers + * should be freed from the original context only. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int is_copy; + + /** + * Which multithreading methods to use, for codecs that support more than one. + * - encoding: Set by user, otherwise the default is used. + * - decoding: Set by user, otherwise the default is used. + */ + int thread_type; +#define FF_THREAD_FRAME 1 //< Decode more than one frame at once +#define FF_THREAD_SLICE 2 //< Decode more than one part of a single frame at once +#define FF_THREAD_DEFAULT 3 //< Use both if possible. + + /** + * Which multithreading methods are actually active at the moment. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int active_thread_type; } AVCodecContext; /** @@ -2374,8 +2547,7 @@ typedef struct AVCodec { int (*init)(AVCodecContext *); int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); int (*close)(AVCodecContext *); - int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, - const uint8_t *buf, int buf_size); + int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); /** * Codec capabilities. * see CODEC_CAP_* @@ -2397,6 +2569,26 @@ typedef struct AVCodec { const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 const enum SampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 + + /** + * @defgroup framethreading Frame threading support functions. + * @{ + */ + /** + * If the codec allocates writable tables in init(), define init_copy() to re-allocate + * them in the copied contexts. Before calling it, priv_data will be set to a copy of + * the original. + */ + int (*init_copy)(AVCodecContext *); + /** + * Copy all necessary context variables from the last thread before starting the next one. + * If the codec doesn't define this, the next thread will start automatically; otherwise, + * the codec must call ff_report_frame_setup_done(). Do not assume anything about the + * contents of priv data except that it has been copied from the original some time after + * codec init. Will not be called if frame threading is disabled. + */ + int (*update_context)(AVCodecContext *, AVCodecContext *from); + /** @} */ } AVCodec; /** @@ -2574,6 +2766,55 @@ typedef struct AVSubtitle { AVSubtitleRect **rects; } AVSubtitle; +/* packet functions */ + +/** + * @deprecated use NULL instead + */ +attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt); + +/** + * Default packet destructor. + */ +void av_destruct_packet(AVPacket *pkt); + +/** + * Initialize optional fields of a packet with default values. + * + * @param pkt packet + */ +void av_init_packet(AVPacket *pkt); + +/** + * Allocate the payload of a packet and initialize its fields with + * default values. + * + * @param pkt packet + * @param size wanted payload size + * @return 0 if OK, AVERROR_xxx otherwise + */ +int av_new_packet(AVPacket *pkt, int size); + +/** + * Reduce packet size, correctly zeroing padding + * + * @param pkt packet + * @param size new size + */ +void av_shrink_packet(AVPacket *pkt, int size); + +/** + * @warning This is a hack - the packet memory allocation stuff is broken. The + * packet is allocated if it was not really allocated. + */ +int av_dup_packet(AVPacket *pkt); + +/** + * Free a packet. + * + * @param pkt packet to free + */ +void av_free_packet(AVPacket *pkt); /* resample.c */ @@ -2965,26 +3206,44 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, v */ int avcodec_open(AVCodecContext *avctx, AVCodec *codec); +#if LIBAVCODEC_VERSION_MAJOR < 53 /** * Decodes an audio frame from \p buf into \p samples. - * The avcodec_decode_audio2() function decodes an audio frame from the input - * buffer \p buf of size \p buf_size. To decode it, it makes use of the - * audio codec which was coupled with \p avctx using avcodec_open(). The - * resulting decoded frame is stored in output buffer \p samples. If no frame + * Wrapper function which calls avcodec_decode_audio3. + * + * @deprecated Use avcodec_decode_audio3 instead. + * @param avctx the codec context + * @param[out] samples the output buffer + * @param[in,out] frame_size_ptr the output buffer size in bytes + * @param[in] buf the input buffer + * @param[in] buf_size the input buffer size in bytes + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + */ +attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, + const uint8_t *buf, int buf_size); +#endif + +/** + * Decodes the audio frame of size avpkt->size from avpkt->data into samples. + * Some decoders may support multiple frames in a single AVPacket, such + * decoders would then just decode the first frame. + * If no frame * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the * decompressed frame size in \e bytes. * * @warning You \e must set \p frame_size_ptr to the allocated size of the - * output buffer before calling avcodec_decode_audio2(). + * output buffer before calling avcodec_decode_audio3(). * * @warning The input buffer must be \c FF_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 The end of the input buffer \p buf should be set to 0 to ensure that + * @warning The end of the input buffer \p avpkt->data should be set to 0 to ensure that * no overreading happens for damaged MPEG streams. * - * @note You might have to align the input buffer \p buf and output buffer \p + * @note You might have to align the input buffer \p avpkt->data and output buffer \p * samples. The alignment requirements depend on the CPU: On some CPUs it isn't * necessary at all, on others it won't work at all if not aligned and on others * it will work but it will have an impact on performance. In practice, the @@ -2996,21 +3255,37 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec); * @param avctx the codec context * @param[out] samples the output buffer * @param[in,out] frame_size_ptr the output buffer size in bytes - * @param[in] buf the input buffer - * @param[in] buf_size the input buffer size in bytes + * @param[in] avpkt The input AVPacket containing the input buffer. * @return On error a negative value is returned, otherwise the number of bytes * used or zero if no frame could be decompressed. */ -int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, +int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, - const uint8_t *buf, int buf_size); + AVPacket *avpkt); +#if LIBAVCODEC_VERSION_MAJOR < 53 /** * Decodes a video frame from \p buf into \p picture. - * The avcodec_decode_video() function decodes a video frame from the input - * buffer \p buf of size \p buf_size. To decode it, it makes use of the - * video codec which was coupled with \p avctx using avcodec_open(). The - * resulting decoded frame is stored in \p picture. + * Wrapper function which calls avcodec_decode_video2. + * + * @deprecated Use avcodec_decode_video2 instead. + * @param avctx the codec context + * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * @param[in] buf the input buffer + * @param[in] buf_size the size of the input buffer in bytes + * @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. + */ +attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + const uint8_t *buf, int buf_size); +#endif + +/** + * Decodes the video frame of size avpkt->size from avpkt->data into picture. + * Some decoders may support multiple frames in a single AVPacket, such + * decoders would then just decode the first frame. * * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than * the actual read bytes because some optimized bitstream readers read 32 or 64 @@ -3019,7 +3294,7 @@ int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, * @warning The end of the input buffer \p buf should be set to 0 to ensure that * no overreading happens for damaged MPEG streams. * - * @note You might have to align the input buffer \p buf and output buffer \p + * @note You might have to align the input buffer \p avpkt->data and output buffer \p * samples. The alignment requirements depend on the CPU: on some CPUs it isn't * necessary at all, on others it won't work at all if not aligned and on others * it will work but it will have an impact on performance. In practice, the @@ -3029,38 +3304,53 @@ int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, * start of the buffer to 16. * * @note Some codecs have a delay between input and output, these need to be - * feeded with buf=NULL, buf_size=0 at the end to return the remaining frames. + * feeded with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. * * @param avctx the codec context * @param[out] picture The AVFrame in which the decoded video frame will be stored. - * @param[in] buf the input buffer - * @param[in] buf_size the size of the input buffer in bytes + * @param[in] avpkt The input AVpacket containing the input buffer. * @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. */ -int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, +int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, - const uint8_t *buf, int buf_size); + AVPacket *avpkt); +#if LIBAVCODEC_VERSION_MAJOR < 53 /* Decode a subtitle message. Return -1 if error, otherwise return the * number of bytes used. If no subtitle could be decompressed, * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ -int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, +attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const uint8_t *buf, int buf_size); +#endif + +/** + * Decodes a subtitle message. + * Returns a negative value on error, otherwise returns the number of bytes used. + * If no subtitle could be decompressed, \p got_sub_ptr is zero. + * Otherwise, the subtitle is stored in \p *sub. + * + * @param avctx the codec context + * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored. + * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. + * @param[in] avpkt The input AVPacket containing the input buffer. + */ +int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + AVPacket *avpkt); int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, int *data_size_ptr, uint8_t *buf, int buf_size); /** * Encodes an audio frame from \p samples into \p buf. - * The avcodec_encode_audio() function encodes an audio frame from the input - * buffer \p samples. To encode it, it makes use of the audio codec which was - * coupled with \p avctx using avcodec_open(). The resulting encoded frame is - * stored in output buffer \p buf. * * @note The output buffer should be at least \c FF_MIN_BUFFER_SIZE bytes large. + * However, for PCM audio the user will know how much space is needed + * because it depends on the value passed in \p buf_size as described + * below. In that case a lower value can be used. * * @param avctx the codec context * @param[out] buf the output buffer @@ -3078,10 +3368,7 @@ int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, /** * Encodes a video frame from \p pict into \p buf. - * The avcodec_encode_video() function encodes a video frame from the input - * \p pict. To encode it, it makes use of the video codec which was coupled with - * \p avctx using avcodec_open(). The resulting encoded bytes representing the - * frame are stored in the output buffer \p buf. The input picture should be + * The input picture should be * stored using a specific format, namely \c avctx.pix_fmt. * * @param avctx the codec context @@ -3376,6 +3663,20 @@ AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); /** + * Allocates a buffer, reusing the given one if large enough. + * + * Contrary to av_fast_realloc the current buffer contents might not be + * preserved and on error the old buffer is freed, thus no special + * handling to avoid memleaks is necessary. + * + * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer + * @param size size of the buffer *ptr points to + * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and + * *size 0 if an error occurred. + */ +void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size); + +/** * Copy image 'src' to 'dst'. */ void av_picture_copy(AVPicture *dst, const AVPicture *src, diff --git a/third_party/ffmpeg/include/libavdevice/avdevice.h b/third_party/ffmpeg/include/libavdevice/avdevice.h deleted file mode 100644 index 7e6d461..0000000 --- a/third_party/ffmpeg/include/libavdevice/avdevice.h +++ /dev/null @@ -1,46 +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 - */ - -#ifndef AVDEVICE_AVDEVICE_H -#define AVDEVICE_AVDEVICE_H - -#define LIBAVDEVICE_VERSION_MAJOR 52 -#define LIBAVDEVICE_VERSION_MINOR 1 -#define LIBAVDEVICE_VERSION_MICRO 0 - -#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ - LIBAVDEVICE_VERSION_MINOR, \ - LIBAVDEVICE_VERSION_MICRO) -#define LIBAVDEVICE_VERSION AV_VERSION(LIBAVDEVICE_VERSION_MAJOR, \ - LIBAVDEVICE_VERSION_MINOR, \ - LIBAVDEVICE_VERSION_MICRO) -#define LIBAVDEVICE_BUILD LIBAVDEVICE_VERSION_INT - -/** - * Returns the LIBAVDEVICE_VERSION_INT constant. - */ -unsigned avdevice_version(void); - -/** - * Initialize libavdevice and register all the input and output devices. - * @warning This function is not thread safe. - */ -void avdevice_register_all(void); - -#endif /* AVDEVICE_AVDEVICE_H */ - diff --git a/third_party/ffmpeg/include/libavformat/avformat.h b/third_party/ffmpeg/include/libavformat/avformat.h index 5458db9..8732b56 100644 --- a/third_party/ffmpeg/include/libavformat/avformat.h +++ b/third_party/ffmpeg/include/libavformat/avformat.h @@ -63,7 +63,7 @@ struct AVFormatContext; * want to store, e.g., the email address of the child of producer Alice * and actor Bob, that could have key=alice_and_bobs_childs_email_address. * 3. A tag whose value is localized for a particular language is appended - * with a dash character ('-') and the ISO 639 3-letter language code. + * with a dash character ('-') and the ISO 639-2/B 3-letter language code. * For example: Author-ger=Michael, Author-eng=Mike * The original/default language is in the unqualified "Author" tag. * A demuxer should set a default if it sets any translated tag. @@ -114,78 +114,6 @@ void av_metadata_free(AVMetadata **m); /* packet functions */ -typedef struct AVPacket { - /** - * Presentation timestamp in time_base units; the time at which the - * decompressed packet will be presented to the user. - * Can be AV_NOPTS_VALUE if it is not stored in the file. - * pts MUST be larger or equal to dts as presentation cannot happen before - * decompression, unless one wants to view hex dumps. Some formats misuse - * the terms dts and pts/cts to mean something different. Such timestamps - * must be converted to true pts/dts before they are stored in AVPacket. - */ - int64_t pts; - /** - * Decompression timestamp in time_base units; the time at which the - * packet is decompressed. - * Can be AV_NOPTS_VALUE if it is not stored in the file. - */ - int64_t dts; - uint8_t *data; - int size; - int stream_index; - int flags; - /** - * Duration of this packet in time_base units, 0 if unknown. - * Equals next_pts - this_pts in presentation order. - */ - int duration; - void (*destruct)(struct AVPacket *); - void *priv; - int64_t pos; ///< byte position in stream, -1 if unknown - - /** - * Time difference in stream time base units from the pts of this - * packet to the point at which the output from the decoder has converged - * independent from the availability of previous frames. That is, the - * frames are virtually identical no matter if decoding started from - * the very first frame or from this keyframe. - * Is AV_NOPTS_VALUE if unknown. - * This field is not the display duration of the current packet. - * - * The purpose of this field is to allow seeking in streams that have no - * keyframes in the conventional sense. It corresponds to the - * recovery point SEI in H.264 and match_time_delta in NUT. It is also - * essential for some types of subtitle streams to ensure that all - * subtitles are correctly displayed after seeking. - */ - int64_t convergence_duration; -} AVPacket; -#define PKT_FLAG_KEY 0x0001 - -void av_destruct_packet_nofree(AVPacket *pkt); - -/** - * Default packet destructor. - */ -void av_destruct_packet(AVPacket *pkt); - -/** - * Initialize optional fields of a packet with default values. - * - * @param pkt packet - */ -void av_init_packet(AVPacket *pkt); - -/** - * Allocate the payload of a packet and initialize its fields with - * default values. - * - * @param pkt packet - * @param size wanted payload size - * @return 0 if OK, AVERROR_xxx otherwise - */ -int av_new_packet(AVPacket *pkt, int size); /** * Allocate and read the payload of a packet and initialize its fields with @@ -197,23 +125,6 @@ int av_new_packet(AVPacket *pkt, int size); */ int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size); -/** - * @warning This is a hack - the packet memory allocation stuff is broken. The - * packet is allocated if it was not really allocated. - */ -int av_dup_packet(AVPacket *pkt); - -/** - * Free a packet. - * - * @param pkt packet to free - */ -static inline void av_free_packet(AVPacket *pkt) -{ - if (pkt && pkt->destruct) { - pkt->destruct(pkt); - } -} /*************************************************/ /* fractional numbers for exact pts handling */ @@ -338,7 +249,10 @@ typedef struct AVInputFormat { AVFormatParameters *ap); /** Read one packet and put it in 'pkt'. pts and flags are also set. 'av_new_stream' can be called only if the flag - AVFMTCTX_NOHEADER is used. */ + AVFMTCTX_NOHEADER is used. + @return 0 on success, < 0 on error. + When returning an error, pkt must not have been allocated + or must be freed before returning */ int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); /** Close the stream. The AVFormatContext and AVStreams are not freed by this function */ @@ -476,7 +390,7 @@ typedef struct AVStream { int64_t duration; #if LIBAVFORMAT_VERSION_INT < (53<<16) - char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */ + char language[4]; /** ISO 639-2/B 3-letter language code (empty string if undefined) */ #endif /* av_read_frame() support */ diff --git a/third_party/ffmpeg/include/libavutil/avutil.h b/third_party/ffmpeg/include/libavutil/avutil.h index dfc129b..fac1f5e 100644 --- a/third_party/ffmpeg/include/libavutil/avutil.h +++ b/third_party/ffmpeg/include/libavutil/avutil.h @@ -35,7 +35,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 50 -#define LIBAVUTIL_VERSION_MINOR 2 +#define LIBAVUTIL_VERSION_MINOR 3 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/third_party/ffmpeg/include/libavutil/fifo.h b/third_party/ffmpeg/include/libavutil/fifo.h index d353844..a904dfd 100644 --- a/third_party/ffmpeg/include/libavutil/fifo.h +++ b/third_party/ffmpeg/include/libavutil/fifo.h @@ -62,6 +62,14 @@ void av_fifo_reset(AVFifoBuffer *f); int av_fifo_size(AVFifoBuffer *f); /** + * Returns the amount of space in bytes in the AVFifoBuffer, that is the + * amount of data you can write into it. + * @param *f AVFifoBuffer to write into + * @return size + */ +int av_fifo_space(AVFifoBuffer *f); + +/** * Feeds data from an AVFifoBuffer to a user-supplied callback. * @param *f AVFifoBuffer to read from * @param buf_size number of bytes to read diff --git a/third_party/ffmpeg/include/libavutil/pixfmt.h b/third_party/ffmpeg/include/libavutil/pixfmt.h index 21a72a8..4995a4da 100644 --- a/third_party/ffmpeg/include/libavutil/pixfmt.h +++ b/third_party/ffmpeg/include/libavutil/pixfmt.h @@ -116,6 +116,13 @@ enum PixelFormat { 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 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 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 + + PIX_FMT_YUV420PLE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + PIX_FMT_YUV420PBE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + PIX_FMT_YUV422PLE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + PIX_FMT_YUV422PBE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV444PLE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV444PBE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian 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 }; @@ -137,4 +144,8 @@ enum PixelFormat { #define PIX_FMT_BGR565 PIX_FMT_NE(BGR565BE, BGR565LE) #define PIX_FMT_BGR555 PIX_FMT_NE(BGR555BE, BGR555LE) +#define PIX_FMT_YUV420P16 PIX_FMT_NE(YUV420PBE, YUV420PLE) +#define PIX_FMT_YUV422P16 PIX_FMT_NE(YUV422PBE, YUV422PLE) +#define PIX_FMT_YUV444P16 PIX_FMT_NE(YUV444PBE, YUV444PLE) + #endif /* AVUTIL_PIXFMT_H */ |