Commit Graph

62 Commits

Author SHA1 Message Date
trav90 9dcbebf1ca Don't skip audio samples with a negative presentation time
This makes WMF have the same decoding behavior as other platforms.
2018-07-25 07:02:59 +08:00
trav90 b90879402e Reset video frame geometry on each init 2018-07-25 07:02:57 +08:00
trav90 5643bfba66 Ensure mUseHwAccel is set appropriately when WMFVideoMFTManager::Init() is called after Shutdown() 2018-07-25 07:02:56 +08:00
trav90 9366d733b3 Remove a couple member variables from WMFVideoMFTManager
These shouldn't be used by anything.
2018-07-25 07:02:53 +08:00
trav90 8a3f415c23 Fix Windows build bustage
Followup to #954
2018-07-25 06:57:43 +08:00
trav90 4b50ae13c8 Release internal drain monitor before calling Flush()
The DrainComplete() caught with mWaitForInternalDrain still won't necessarily be from the internal Drain(), but all we need is that one DrainComplete() is caught for the internal Drain() because one more will be generated if there is a Drain() in progress.

What protecting mWaitForInternalDrain access with the monitor provides here is that the compiler won't use its address for storage of other data meaningless in the context of mWaitForInternalDrain and so, for example, two DrainComplete() calls won't unintentionally think that they are both for one internal drain.
2018-07-25 06:52:39 +08:00
trav90 fc907f06c6 Always read SDM::mWaitForInternalDrain while holding monitor 2018-07-25 06:52:36 +08:00
trav90 870eefecb1 Don't wait for a drain complete that will never happen
This prevents a deadlock that is due to the HTMLMediaElement calling MediaDecoder::NotifyOwnerActivityChanged() , attempt to grab the monitor, which is held by the SharedDecoderManager which is waiting for SetIdle() to complete.
2018-07-25 06:52:35 +08:00
trav90 356b85aeef Ensure DrainComplete() is called when draining
If no samples were ever passed to the H264 wrapper, no decoder would have been created.
2018-07-25 06:47:35 +08:00
CNAmira a2957b9c5d Fix a build failed on macOS
caused by commit 112e89b2bea522ece7bbdd159e429b531d7e2978
2018-07-25 06:44:19 +08:00
trav90 6d11377099 Put platform specific media pref caches behind #ifdef's 2018-07-25 06:24:53 +08:00
trav90 5e4900291c Remove "fragmented-mp4" from media prefs
Shortens and simplifies some pref names.
2018-07-25 06:24:52 +08:00
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 9bc4e6a5e4 Enable FFmpeg by default if available 2018-07-25 06:24:31 +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 a5de85d358 Use getter to access MediaRawData mData and mSize member in WMFVideoMFTManager 2018-07-25 06:20:11 +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