Commit Graph

46 Commits

Author SHA1 Message Date
trav90 f07e44834a Update code comment 2018-07-25 06:24:50 +08:00
trav90 44558c1af2 [ffmpeg] Request YUVJ420P format explicitly
Requesting YUV420P can cause crashes with some versions of FFmpeg.
2018-07-25 06:24:48 +08:00
trav90 b9ab7404d4 [ffmpeg] Add support for YUV444P pixel format in FFmpeg
We also prefer YUV444 format when the decoder supports it.
2018-07-25 06:24:45 +08:00
trav90 5a4f0a6ba5 Don't use all CPUs available when decoding with FFmpeg 2018-07-25 06:24:39 +08:00
trav90 7666710f2a Do not create extra threads when decoding small videos with FFmpeg
Instead we use our current decoding's taskqueue.
2018-07-25 06:24:38 +08:00
trav90 39d24eae19 Fix build bustage
"LogToBrowserConsole" function doesn't exist in our tree.
2018-07-25 06:24:28 +08:00
trav90 c864fb268e Don't assume AVFrame has a constant size
An AVFrame has a different size between FFmpeg 0.10 and LibAV 0.8 though both have the same version number.
2018-07-25 06:24:25 +08:00
trav90 f96e952e66 Don't use libav to decode VP9 2018-07-25 06:24:24 +08:00
trav90 021f2ef2e2 Block libav versions below 54.35.1 2018-07-25 06:24:21 +08:00
trav90 2b7b316204 Tweak compiler flags for FFmpeg headers
To keep some versions of clang happy.
2018-07-25 06:24:08 +08:00
trav90 4d5cec6777 Accept libavcodec 57.100+ 2018-07-25 06:24:06 +08:00
trav90 1258bc5bfe Add support for libavcodec 57
At this point only the original FFmpeg project is supported.
2018-07-25 06:24:04 +08:00
trav90 760c19a381 Add FFmpeg n2.9 headers
libavcodec and libavutil minimal headers.
2018-07-25 06:24:02 +08:00
trav90 5fdc41c7bc Remove now unused AVFormat headers 2018-07-25 06:24:01 +08:00
trav90 2d6373247d Remove unneeded AVFormat functions
Additionally, do not attempt to resolve unused symbols.
2018-07-25 06:23:58 +08:00
trav90 4291ecc27c Provide finer granularity on which FFmpeg symbols are to be loaded 2018-07-25 06:23:56 +08:00
trav90 5031c1f157 Reduce threads used in FFmpeg video decoder
FFmpeg PDM currently uses as many cores (virtual or otherwise) as available *per* decoder. This means on a typical quad-core machine (for example), that's 8 threads per video.

This reduces the number of threads FFmpeg uses using the same logic as what is used by libvpx to ensure that we won't get a regression due to excessive memory/thread use.
2018-07-25 06:22:43 +08:00
trav90 95a8f149db Have specialized AVCodecContext initialization
A common initialization procedure is too restrictive, and we end up setting up audio configuration for video decoding and vice-versa.
2018-07-25 06:22:41 +08:00
trav90 4d1ef4248d Let FFmpeg manage its own memory allocation
The API to override memory allocation was deprecated years ago and was completely removed in libavcodec 57.
2018-07-25 06:22:39 +08:00
trav90 1d6f670a27 Align FFmpeg library names for logging purposes 2018-07-25 06:22:38 +08:00
trav90 9d1938950d Don't rely on library name to determine version of libavcodec
Also use portable way to dynamically open libraries.
2018-07-25 06:22:35 +08:00
trav90 6f315285f9 Fix VP9 decoding with recent version of libav.
Recent libav do not require a codec parser to decode VP9.
2018-07-25 06:21:46 +08:00
trav90 ea47e5bd62 Disable ffvpx with libav0.8 and earlier 2018-07-25 06:21:44 +08:00
trav90 023bd79e39 Allow VP8/VP9 decoding via FFmpeg 2018-07-25 06:21:42 +08:00
trav90 eb5ceada68 Parse raw data to identify single frames before decoding
A VP9 or VP9 packet may contains alternate frames. They need to be fed separately to the FFmpeg decoder.
2018-07-25 06:21:40 +08:00
trav90 bfafa7aaa9 Properly assign the decoded sample duration
We default to the previous logic if for some unlikely condition we couldn't find the frame's duration (using the last input frame's duration).
2018-07-25 06:21:14 +08:00
trav90 0ab9d0b05a Properly set the keyframe flag
We were incorrectly setting the keyframe flag of the last input sample rather than of the decoded one.
2018-07-25 06:21:12 +08:00
trav90 0a7eb3d9c0 Use LibAV/FFmpeg logic to detect invalid pts
The logic was extracted from LibAV cmdutils.c. FFmpeg provides an API for that (av_frame_get_best_effort_timestamp()) unfortunately this isn't provided by LibAV.
So copy the logic instead in order to keep compatibility with the two forks.
2018-07-25 06:21:09 +08:00
trav90 61c7b38e08 Fix pts calculation in FFmpeg video decoder 2018-07-25 06:21:08 +08:00
trav90 0f0d8c765b Have FFMpegDecoderModule properly return if a codec is supported
Our current PlatformDecoderModule::SupportsMimeType implementations only check for support by performing a lookup on the mimetype as a strink and always assume that the underlying decoder is usable and is working.

This is an invalid assumption; especially with the FFMpeg decoder that may not be compiled with some particular codec support (like if it was compiled with --disable-nonfree).
2018-07-25 06:21:06 +08:00
trav90 8b514b3576 Revert "Use demuxed dimensions to determine picture size and offset"
Causes build bustage. Also doesn't apply to H.264 video (which is currently our only use for FFmpeg).
2018-07-25 06:20:33 +08:00
trav90 c09f5b9f68 Use demuxed dimensions to determine picture size and offset
Don't assume it always has an offset of (0,0)
2018-07-25 06:20:23 +08:00
trav90 cdd9c93bb6 Delete codec context upon initialization failure 2018-07-25 06:20:21 +08:00
trav90 c6fce7f64d Always request 16 bits audio for libavcodec 53 2018-07-25 06:20:19 +08:00
trav90 9992910055 Support YUV420J pixel format
YUV420J is 12bpp YUV420P.
2018-07-25 06:20:10 +08:00
trav90 6b219443fd Remove dependency on libavformat
When searching for ffmpeg or libav we currently look for libavformat and search for a specific version. We have no use for the libavformat library as we only use libavcodec and (indirectly) libavutil. The version numbering in libavformat is also completely irrelevant for our use.

With this commit, we will look for libavcodec instead.
2018-07-25 06:20:04 +08:00
trav90 45c02334a5 Fix FFmpeg shutdown crash should decoder not be initialised 2018-07-25 06:20:02 +08:00
trav90 c945261c27 Prevent potential null deref when flushing FFmpeg decoder 2018-07-25 01:31:43 +08:00
trav90 52c9efbf75 Request S16 audio for libav 0.8 and earlier 2018-07-25 01:31:42 +08:00
trav90 b20af88870 Work around bug in some versions of LibAV
When multi-threading decoding is enabled; the frames dimensions were incorrectly set with some versions of LibAV.
2018-07-25 01:31:40 +08:00
trav90 f5157f3254 Add method to determine which version of libavcodec is available 2018-07-25 01:31:38 +08:00
trav90 8492676d0d Fix image alignment allocation 2018-07-25 01:31:36 +08:00
trav90 2c5c4a6d69 Fix pts calculations in older LibAV versions 2018-07-25 01:31:34 +08:00
trav90 4699afe3ca Use libavformat-ffmpeg.so.56 if available
Some Debian based distro's install FFmpeg as libavformat-ffmpeg.so.56 alongside LibAV.
2018-07-25 01:31:32 +08:00
trav90 9a6b3eb6b1 Use getter to access MediaRawData mData and mSize member 2018-07-25 01:31:17 +08:00
trav90 538539f5c3 Move PlatformDecoderModule outside fmp4 2018-07-25 01:29:11 +08:00