0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
Commit Graph

53 Commits

Author SHA1 Message Date
derrod
ca2bc6b4b0 libff: Add override for codec compatability check
In some cases the result of the compatability check is wrong.
For example the format "mpegts" only shows "mpeg2video" as an
encoder even though other codecs such as h.264 are supported by
ffmpeg's muxer for that container and are used within that container
in some applications.

Closes jp9000/obs-studio#804
2017-02-25 09:08:02 -08:00
Richard Stanway
8b640fae24
Fix various null pointer issues detected by Coverity 2017-02-25 16:45:45 +01:00
jp9000
679c32086d deps/libff: Fix VP8/VP9/webm alpha support
FFmpeg by default decodes VP8/VP9 via its internal encoders, however
those internal encoders do not support alpha.  Encoded alpha is stored
via meta/side data in the container, so the only way to decode it
properly is via forcing FFmpeg to use libvpx for decoding.
2016-12-28 14:25:30 -08:00
Kurt Kartaltepe
aff26d9840 libff: Allow custom demuxer options 2016-11-28 19:15:30 -06:00
Richard Stanway
65fcd20242
libff: Improved handling of EOF in the decoder threads
(Also modifies obs-ffmpeg to handle empty frames on EOF)

Previously the demuxer could hit EOF before the decoder threads are
finished, resulting in truncated output. In the worse case scenario the
demuxer could read small files before ff_decoder_refresh even has a chance
to start the clocks, resulting in no output at all.
2016-04-28 23:58:28 +02:00
Richard Stanway
dd6f8120b3
libff: Seek to frame 0 for sources with no duration 2016-04-25 01:05:32 +02:00
Gol-D-Ace
674706ac6e Merge pull request #533 from sorayuki/patch-1
libff: Fix a race condition crash when handling clocks
2016-04-21 04:18:55 +02:00
sorayuki
a9b9b26afd libff: Fix a race condition crash when handling clocks
How to crash:
1. Use recent ffmpeg shared libraries.
2. Add a ffmpeg_source, a small static picture (e.g. jpeg) with loop
3. After a while of high cpu usage, it crashed. Seems reproduced more
easily on faster computer

Closes #533
2016-04-21 04:12:27 +02:00
Richard Stanway
4c0b316130
libff: Small audio decoder loop refactor 2016-04-20 03:05:18 +02:00
Richard Stanway
bebaeaeaa9
libff: Fix heap corruption caused by unnecessary av_dup_packet call
There's no need to duplicate the packet as the reference count will be 1
after the av_read_frame call. Duplicating causes heap corruption when a
synthetic clock packet is duplicated and assigned the buffer from the
stack-based temporary packet which is then double-freed by the decoder
thread.
2016-04-20 03:05:04 +02:00
Christoph Hohmann
5e768990f2 deps/libff: Fix that inputs are not closed when a demuxer is freed
avformat_free_context() only frees the memory used by an AVFormatContext
but it does not close the opened media file. This causes a leaked file
descriptor every time a media source frees a demuxer. Using
avformat_close_input() instead frees the context and closes the media
file.
2016-04-10 18:53:26 +02:00
jp9000
2fd30407e6 deps/libff: Fix warnings with FFmpeg 3.0.0+
Fixes warnings with deprecated packet functions (av_free_packet and
av_dup packet, which were replaced by av_packet_unref and av_packet_ref
respectively)
2016-04-09 18:10:48 -07:00
sorayuki
07ecdaf8d3 deps/libff: Fix incorrect timer triggering (twice)
Sometimes the timer will be triggered twice in one request.  GIF files
can be rendered in wrong speed.

Closes jp9000/obs-studio#513
2016-03-24 02:42:18 -07:00
jp9000
c2f796660d deps/libff: Make libff use default frame discard method 2016-01-26 11:49:24 -08:00
kc5nra
ff0c58e963 deps-libff: Adjust start_pts if invalid pts found
If the first guessed pts is less than the start_pts, it could
lead to a negative PTS being returned.

Change the behavior so that the first frame's pts, if zero, is
set to the start_pts.  If more than one frame is less than the
start_pts, the start_pts is determined invalid and set to 0.

Valid start_pts example:
  start_pts = 500

  first frame (pts = 0)
    pts = 500 (< start_pts)
    pts -= 500 (offset by start_pts)

    ret 0

  second frame (pts = 700)
    pts = 700 (no change, > start_pts)
    pts -= 500 (offset by start_pts)

    ret 200

Invalid start_pts example:
  start_pts = 500

  first frame (pts = 0)
    pts = 500 (< start_pts)
    pts -= 500 (offset by start_pts)

    ret 0
  second frame (pts = 300)
    pts = 300 (< start_pts, start_pts set to 0)
    pts -= 0 (start_pts is now 0)

    ret 300
2015-08-02 15:54:35 -05:00
jp9000
c87d3b1f12 cmake: Rename FindFFMpeg to FindFFmpeg
This was sort of driving me crazy: The 'm' in FFmpeg isn't supposed to
be capitalized.
2015-07-18 16:32:26 -07:00
Christoph Hohmann
e96c7c86b6 deps-libff: Fix stack corruption
ff_clock_init expects a parameter with a pointer where it stores the
address of the newly allocated ff_clock, but ff_demuxer_reset does not
provide this parameter. That somehow writes the pointer to the ff_clock
into the packet->base->buf field on the stack of the ff_demuxer_reset
function. This later causes a segmentation fault when the packet is freed.

Closes jp9000/obs-studio#448
2015-07-07 15:23:23 -07:00
jp9000
6ed694f617 deps-libff: Fix starting timestamp bug
Certain input streams (such as remote streams that are already active)
can start up mid-stream with a very high initial timestamp values.
Because of this, it would cause the libff timer to delay for that
initial timestamp, which often would cause it to not render at all
because it was stuck waiting.

To fix the problem, we should ignore the timestamp difference of the
first frame when it's above a certain threshold.
2015-07-04 22:16:22 -07:00
jp9000
171f0e3d26 deps-libff: Offset start of stream by start pts
Now that we're using the timestamps from the stream for playback,
certain types of streams and certain file formats will not start from a
pts of 0.  This causes the start of the playback to be delayed.  This
code simply ensures that there's no delay on startup.  This is basically
the same code as used in FFmpeg itself for handling this situation.
2015-07-04 16:25:37 -07:00
John Bradley
6c4be20932 deps-libff: Fix pts diffs being adjusted wrongly
Removed code where if a PTS diff was greater than a certain
threshold it was forced to the previous PTS diff.  This breaks
variable length frame media like GIF.
2015-05-13 11:12:10 -05:00
kc5nra
091a002c37 deps-libff: Add extensions to format description 2015-04-26 22:29:11 -05:00
Ethan Lee
fd4f2e29aa Buildfix for older FFmpeg versions (F20 RPMFusion) 2015-04-01 06:50:22 -04:00
kc5nra
0976126ebb deps-libff: Add ff codec/format utility functions
This adds utility functions for determining which
codecs and formats are supported by loaded FFMpeg
libraries.  This includes validating the codecs that
a particular format supports.
2015-03-30 17:30:29 -05:00
kc5nra
9f301cda94 deps-libff: Add extern "C" to all headers 2015-03-30 17:26:15 -05:00
kc5nra
36820a05e0 deps-libff: Link FFmpeg libraries 2015-03-30 17:26:15 -05:00
kc5nra
8effe2c635 deps-libff: Send NULL frame to callback if EOF
A null frame send to the frame callback signals
the end of media being played.  Null frames are not
sent for looped media
2015-03-24 00:18:48 -05:00
kc5nra
94e58057fd deps-libff: Fix sequence-point warning
Silly code that pre-incremented a value while also assigning
it to the same value.
2015-03-23 22:28:08 -05:00
kc5nra
f1f5484b16 deps-libff: Skip further decode refresh if aborted
Skip decode refresh scheduling if the abort flag is
set when the timer fails to start.  This avoids extraneous
refresh scheduling when tearing down the decoders.
2015-03-23 22:16:39 -05:00
kc5nra
f47b02df3f deps-libff: Add proper ff_timer_init error checks 2015-03-23 22:16:39 -05:00
kc5nra
e868af285e deps-libff: Fix mingw using wrong pthread header
When compiling under mingw it was using the w32-pthreads
instead of the shared mingw pthread library.
2015-03-23 22:16:39 -05:00
kc5nra
798f38cf72 deps-libff: Fix if hw accel fails to load codec
Fixes a bug where get_format was overloaded by our own version
when forcing the codec to load with a HW decoder and not
reset to the original get_format if it failed to load.
2015-03-22 18:58:49 -05:00
John Bradley
aa8363bb87 deps-libff: Fix other multithreaded image decoders
In the same manner that PNG doesn't appear to work properly
with multiple threads, TIFF, JPEG2000 and WEBP also appears
to not render correctly (use of FFmpeg's ff_thread_* routines)
if decode is called before the automatic thread detection
has returned a suggested thread count for the decoder.
2015-03-20 17:51:54 -05:00
John Bradley
c78fa63b47 deps-libff: Fix memory leak in ff_demuxer_reset
The reset method unnecessarily malloced a packet passed into
the packet buffer which does a dereferencing copy.
2015-03-20 17:14:23 -05:00
John Bradley
5465fcb4a2 deps-libff: Initialize FFmpeg network
If this is omitted and you use an input that requires the network
you get a warning message about future versions not automatically
doing this for you.
2015-03-19 14:40:24 -05:00
John Bradley
b2d5b47833 deps-libff: Remove extra whitespace 2015-03-19 14:40:24 -05:00
John Bradley
f8c38d1fcf deps-libff: Remove misleading comment 2015-03-19 14:40:24 -05:00
John Bradley
312d59da02 deps-libff: Fix comment formatting 2015-03-19 14:40:24 -05:00
John Bradley
3628d3402d deps-libff: Add frame dropping
This, if set, instructs the decoders to drop
frames if a specific timing window is not met.
2015-03-19 14:40:24 -05:00
John Bradley
6b36d39345 deps-libff: Add clock chaining to packets/frames
This attaches clocks to packets and frames and defers
the start time until that particular frame is presented.
Any packets/frames in the future with the same clock
will reference that start time.

This fixes issues when there are multiple start times
in a large buffer (looped video/images/audio) and different
frames need different reference clocks to present correctly.
2015-03-19 14:40:24 -05:00
John Bradley
a5e0462a88 deps-libff: set master clock sync type based on default stream 2015-03-19 14:40:24 -05:00
John Bradley
6e42f38386 deps-libff: Add master/slave deferred clock methods
Enables clocks to wait if the main sync clock has not been started yet.  An example of this is a video stream (video/audio) being synced to the video clock.  If an audio frame gets produced before the video clock has started it will wait.
2015-03-19 14:40:19 -05:00
John Bradley
5b3190593c deps-libff: Add reference counting to clock
Add referencing counting to determine when to release a clock Due to no fixed ownership of clocks (packets, frames, decoders and  refresh thread all may own a clock at some point).
2015-03-19 11:56:00 -05:00
kc5nra
164cbeeede deps-libff: Add atomic long inc/dec functions 2015-03-19 11:56:00 -05:00
John Bradley
47783f26c7 deps-libff: Abort timer thread instead of cancelling 2015-03-19 11:56:00 -05:00
John Bradley
7a4a5e3fad deps-libff: Move timer callback outside of lock 2015-03-19 11:55:51 -05:00
John Bradley
d9fe44f021 deps-libff: Only sleep if the timed wait didn't expire 2015-03-19 11:55:43 -05:00
John Bradley
de574e99e3 deps-libff: Fix bug where rel time was used instead of abs
The bug was undetected because it accidentally fell into an error case that slept the correct amount of time.  pthread_cond_timedwait takes an absolute time in the future to wait until.  The value we were passing was always in the past so it was immediately failing with a TIMEDOUT error code.
2015-03-19 11:55:23 -05:00
John Bradley
2b3d82aeac deps-libff: Add flag whether a decoder is hardware accelerated
This lets the decoder make decisions based on whether it is a hardware decoder or not.  Specifically, hardware decoders are more strict as to which frames can be dropped in an h264 stream.
2015-03-19 11:54:53 -05:00
John Bradley
b91a98ed44 deps-libff: Refactor AVPacket into ff_packet
This also replaces AVPacketList with ff_packet_list.
2015-03-19 11:54:51 -05:00
John Bradley
a7e81d6f3f deps-libff: (unsigned char *) -> (uint8_t *) cast fix 2015-03-19 11:53:13 -05:00