Commit graph

94 commits

Author SHA1 Message Date
Andreas Cadhalpun
6235a04ef3 libav: Remove usage of deprecated API
https://bugzilla.gnome.org/show_bug.cgi?id=757498
2016-01-16 16:47:40 +02:00
Vineeth TM
ae27b9c503 avviddec: remove realvideo slice_offset handling
Handling slice_offset in avviddec is resulting in invalid memory read.
Since rv decoders anyways handle slice_offset, removing the same to fix
memory mishandlings

https://bugzilla.gnome.org/show_bug.cgi?id=758726
2015-12-23 13:17:08 +01:00
Sebastian Dröge
5df8cc5e38 avviddec: Make sure to use a buffer pool with the correct width/height configured on it for pushing buffers downstream
If downstream does not provide a (usable) pool, we would use our internal
pool. But the internal pool might be configured with a different width/height
because of padding, which then will cause problems if we push buffers from it
directly downstream.
Instead create a new pool if the width/height is different.

This prevents crashes with vaapisink and d3dvideosink for example.

Based on the debugging results and discussions with
Nicolas Dufresne <nicolas.dufresne@collabora.com>

https://bugzilla.gnome.org/show_bug.cgi?id=758344
2015-12-01 12:34:27 +02:00
Vineeth T M
839a72f92c avviddec: Fix structure memory leak
gst_structure_copy already takes a reference for config_copy.
No need to take another reference while setting it to buffer pool

https://bugzilla.gnome.org/show_bug.cgi?id=758512
2015-11-23 12:05:26 -03:00
Nicolas Dufresne
2a7aaeb3da avviddec: Don't fallback on allocation failure
Allocation should keep working, falling back causes the stride to
change which is not supported in direct rendering.

https://bugzilla.gnome.org/show_bug.cgi?id=756028
2015-11-07 12:12:46 -05:00
Mark Nauwelaerts
67e55e47e2 avviddec: _drain and _finish need slightly different handling
... since they handle separate cases in video decoder with different requirements.
Consider e.g. x264enc ! rtph264pay ! identity drop-probability=0.1 ! rtph264depay
to illustrate a need for such separation.
2015-10-26 19:54:10 +01:00
Sebastian Dröge
dc4b9ef7e6 avviddec: Fix bufferpool config double free by taking a copy as needed
Also free the config in two code paths where we leaked it before.
2015-10-16 18:52:57 +03:00
Luis de Bethencourt
3999a29748 avviddec: only free config when pool doesn't take ownership
Since gst_buffer_pool_set_config() takes ownership of the config structure,
it is only necessary to free the structure before using it when the true
branch of if (gst_buffer_pool_config_validate_params) hasn't run.

gst_buffer_pool_set_config() always takes ownership of the structure
regardless of success or failure. Which means the return, checked with
if (!working_pool), has no relation to the state of the structure.
2015-10-02 11:49:39 +01:00
Luis de Bethencourt
074a128f0f avviddec: fix memory leak
Free config before overwriting.

CID #1320708
2015-09-29 16:44:47 +01:00
Tim-Philipp Müller
6fadf448de avvidec: increase default alignment to 32 bytes
Change default alignment from 16 to 32 bytes, which fixes crashes
when decoding H.265 using AVX2-based decoder code paths and when
using ximagesink/glimagesink.

https://bugzilla.gnome.org/show_bug.cgi?id=754120
2015-09-15 16:36:49 +01:00
Tim-Philipp Müller
a0ebef9637 avvideodec: ensure required mem alignment fixing avdec_h265 crashes with ximagesink/glimagesink
Make sure the alignment requirement in GstAllocationParams
matches the GstVideoAlignment requirements. This fixes
issues with avdec_h265 crashing in the avx2 code path when
used with playbin and ximagesink/glimagesink as videosink.

The internal video pool would allocate buffers with an
alignment of 15 even though GstVideoAlignment specified
a stride_align requirement of 31 (which comes from ffmpeg).

https://bugzilla.gnome.org/show_bug.cgi?id=754120
2015-09-15 16:36:30 +01:00
Nicolas Dufresne
6e590fe498 avviddec: Fix pool reallocation logic
Some check where incorect and also unsafe. The only reliable information
in get_buffer2 is the picture width/height really. The side effect is
that the width/height of the internal pool endup padded, so when we
switch we also need to switch to the a new width/height, hence we save
the pool info.

https://bugzilla.gnome.org/show_bug.cgi?id=753869
2015-08-20 16:23:23 -07:00
Nicolas Dufresne
e3bdfb5608 aviddec: Re-enable direct rendering
This is achieved by using a tempory internal pool. We can then switch to a
downstream pool if the downstream pool buffer have matching strides.

https://bugzilla.gnome.org/show_bug.cgi?id=752802
2015-08-17 10:47:53 +02:00
Thiago Santos
8cc2e1a76b avviddec: let videodecoder call the default pad query handler
Avoids repeating the same handling in many decoders
2015-08-15 13:51:35 -03:00
Thiago Santos
1a098de5eb avviddec: use template caps intersection for accept-caps
Avoid doing downstream caps queries when accept-caps should just
do a shallow caps check on the element itself

https://bugzilla.gnome.org/show_bug.cgi?id=753623
2015-08-14 09:14:11 -03:00
Olivier Crête
c1333df059 avviddec: Remove unused force parameter
This parameter has been always false for a long time.
2015-08-03 21:45:07 -04:00
Olivier Crête
1c70fb229a avviddec: Use caps-like size in get_buffer2()
The size in the AVFrame in get_buffer2 don't match the output size,
instead they match ffmpeg's memory requirements, so we can't compare
them from the values of the output AVFrame. Those are comparable to
the values in the passed AVCodecContext.
2015-08-03 21:40:12 -04:00
Olivier Crête
e7ece560d6 avviddec: Reset current_dr on close and when not chosing it
https://bugzilla.gnome.org/show_bug.cgi?id=753189
2015-08-03 21:03:05 -04:00
Olivier Crête
0a0ee42752 avviddec: Disable direct rendering before a frame has been produces
ffmpeg doesn't provide the final's image width & height in the get_buffer2()
callback, so it's not possible to create an output state for GstVideoDecoder
at this stage. So only try to do direct rendering if the buffer pool has already
been negotiated based on the final decoded size.

This partially reverts the effects of 2e621f8db

https://bugzilla.gnome.org/show_bug.cgi?id=752802
2015-07-28 16:16:10 -04:00
Olivier Crête
1a127d19bb avviddec: Get code out of loop
Code was executed only on the first iteration, so just pull it out
of the loop entirely. This makes it clear it has nothing to do with the loop.
2015-07-27 18:49:49 -04:00
Olivier Crête
431f3e0e6f avviddec: Only create the AVBuffer once the stride is validated
If it is created earlier and the stride is invalid, then the frame
will be freed and it won't be possible to use it in the fallback path.
Not doing this causes a segfault because it will try to use
already freed memory.
2015-07-27 18:46:17 -04:00
Olivier Crête
2e621f8dbf avviddec: Re-enable direct rendering 2015-07-27 15:29:49 -04:00
Olivier Crête
6bfe79d903 avviddec: Ignore negotiation error on shutdown
https://bugzilla.gnome.org/show_bug.cgi?id=752800
2015-07-27 13:58:43 -04:00
Vineeth T M
7d3c7109ac avviddec: fix slice_offset memory leak
In case of real videos, slice_offset is being allocated,
but the same is not being freed.

https://bugzilla.gnome.org/show_bug.cgi?id=752404
2015-07-21 11:20:07 +01:00
Sebastian Dröge
3d9816ce7f avviddec: Free frame before the codec is freed
Who knows, maybe freeing the frame calls cleanup inside the codec.
2015-06-28 12:41:55 +02:00
Sebastian Dröge
982f5262d4 avviddec: Use undeprecated AVFrame API and unref frame once we're done with it 2015-06-28 12:41:55 +02:00
Sebastian Dröge
523ddb5346 avviddec: Use the new get_buffer2() API instead of the deprecated APIs
And do the frame reference counting by adding AVBufferRefs to the frame.
2015-06-28 12:41:55 +02:00
Sebastian Dröge
ad7613be0d avviddec: Also proxy the data/size pointers for our wrapper AVBufferRef 2015-06-28 12:41:55 +02:00
Sebastian Dröge
8cb8461f7e avviddec: Wrap the original AVBufferRef in our own buffer for the destroy function
Just adding a dummy buffer at the very end might not be enough as there
already might be too many buffers.
2015-06-26 16:58:55 +02:00
Sebastian Dröge
9b2c0c2dbc avviddec: libav will already copy the reordered_opaque pointer for us
If we do it ourselves, it might get the wrong value if our assumptions are
broken by libav at a later time.
2015-06-26 16:58:55 +02:00
Sebastian Dröge
5b6c8ee8c9 avviddec: Negotiate based on the AVFrame information, not the context information
The context contains the information from the latest input frame, we're
however interested in the information from the latest output frame. As we have
to negotiate for the buffer that is about to come next.

This should fix some crashes that happened when both information got out of
sync. If that happens now, we will do fallback allocation until the output
is renegotiated too.

https://bugzilla.gnome.org/show_bug.cgi?id=750865
2015-06-26 16:58:55 +02:00
Jan Schmidt
1f1e24f63f viddec: Replicate any 3D/multiview info from input caps onto output 2015-06-11 12:25:45 +10:00
Sebastian Dröge
b81cb99d9f avviddec: Release stream lock while calling avcodec_decode_video2()
It might call back into us from another thread and try to take the stream lock
again, e.g. to allocate a buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=726020
2015-06-05 11:57:37 +02:00
Olivier Crête
172f9c9823 avviddec: Post error message before returning a flow error
This is required.
2015-06-02 20:48:33 -04:00
Sebastian Dröge
4459d706c8 avviddec: Don't copy padding if handling a frame failed
We will return an error right afterwards anyway.
2015-03-09 22:02:38 +01:00
Sebastian Dröge
099ea5f2d1 avviddec: If a flow return during draining is not OK, don't drain any further 2015-03-09 22:02:19 +01:00
Sebastian Dröge
af91ba1620 avviddec: Error out if we try to allocate a buffer without being negotiated
Otherwise we just run into assertions because we should've errored out
already.
2015-03-09 22:01:43 +01:00
Jan Schmidt
904b53ab0d Add drain() vfunc implementation that does the same as finish()
finish() is called at EOS, drain() is called at all other times
when the decoder should be drained out. gst-libav decoder behaviour
is the same in both cases, so use the same implementation

See https://bugzilla.gnome.org/show_bug.cgi?id=734617
2015-02-24 01:50:11 +11:00
Jan Schmidt
5758e82eaf avviddec: Implement SKIP and new SKIP_KEY_UNITS_ONLY flags
Respect any skip flags set in the incoming segment.

https://bugzilla.gnome.org/show_bug.cgi?id=735666
2015-01-27 04:35:08 +11:00
Nicolas Dufresne
9919c274b9 videodec: Ensure update_pool is initialized
This was probably not causing any issues, but we would randomly
and needlessly update the pool in the query due to uninitialized
variable.
2014-11-16 16:11:53 -05:00
IBM Thinklab
25ab0036c0 avviddec: drain frames until libav doesn't have more data
We use have_data (that comes from libav), instead of only trying 10 times,
to know if there are more frames available. The old code was machine
dependant as different amount of frames could be decoded by different
type of (more powerful) machines, and 10 times was not always sufficient.

https://bugzilla.gnome.org/show_bug.cgi?id=736515
2014-09-12 16:26:21 +03:00
Jan Schmidt
8c00a359d0 avviddec: After draining frames, flush the libav decoder
Makes sure that there's really nothing stale left in the decoder
after draining.

https://bugzilla.gnome.org/show_bug.cgi?id=734661
2014-08-12 22:48:59 +10:00
Aleix Conchillo Flaqué
1307b31e1c avviddec: Don't lose frames on EOS
have_data is not propagated from gst_ffmpegviddec_video_frame to
gst_ffmpegviddec_frame. have_data is only set to 1 in
gst_ffmpegviddec_frame if a frame pointer is passed. However, this is
not true while draining, which means that have_data from libav will be
ignored.

https://bugzilla.gnome.org/show_bug.cgi?id=734608
2014-08-11 18:06:33 +03:00
Mathieu Duponchelle
7bb4f93de9 gstavviddec: Sanitize and fix qos handling.
gst_video_decoder_get_max_decding_time doesn't return a GstClockTime
but a GstClockTimeDiff, and thus one needs to compare it against
G_MAXINT_64.

The returning of a boolean and the extra subsequent code in _video_frame
was uselessly complicated.

The previous behaviour led to artefacts when the decoder tried to
hurry up.

https://bugzilla.gnome.org/show_bug.cgi?id=730075
2014-05-16 13:51:50 +02:00
Nicolas Dufresne
62a4d065ed videodec: Don't use non-growable pool
As we don't know how many output buffers we need to operate, we need to
avoid pool that can't grow. Otherwise the pipeline may stall, waiting
for buffers. For now, we require it to be able to grow to at least
32 buffers, which I think is a fair amount of buffers for decoders.

https://bugzilla.gnome.org/show_bug.cgi?id=726299
2014-05-08 15:33:39 -04:00
Thijs Vermeir
9a1c9096dc avviddec: rename hevc decoder element to h265 for consistency
We use h265 for the parser, typefinder, caps, etc. everywhere.

https://bugzilla.gnome.org/show_bug.cgi?id=724823
2014-02-22 16:10:49 +01:00
Tim-Philipp Müller
74b769751d avvidec: don't crash on EOS when no buffers have been received
Fixes crash on EOS when no buffers have been received for some
reason, e.g. because the parser didn't output any.

fakesrc num-buffers=0 format=time ! avdec_h264 ! fakesink
2014-02-21 13:18:47 +00:00
Aleix Conchillo Flaqué
60f7b00db3 avviddec: Add output-corrupt property
The output-corrupt property will set the CODEC_FLAG_OUTPUT_CORRUPT flag
in the codec context. The user can now decide whether libav outputs
corrupt frames or not.

Previous libav versions had this flag always set.

https://bugzilla.gnome.org/show_bug.cgi?id=722453
2014-01-17 22:08:33 +01:00
Sebastian Dröge
b278ca55be avviddec: Mark frames as corrupted if libav tells us they are
This is currently only implemented by the h264 codec.

https://bugzilla.gnome.org/show_bug.cgi?id=722290
2014-01-16 13:46:26 +01:00
Vincent Penquerc'h
ca1b5d8576 gst-libav: fix context leaks
A AVCodecContext needs cleaning up before being freed.
Go through all of the allocations/setups to ensure none of them
can leak a context or its contents.
2014-01-15 09:02:33 +00:00