Commit graph

78 commits

Author SHA1 Message Date
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
Wim Taymans
ead14945aa avviddec: set output chroma-site
Use libav provided chroma-site and place it on the output caps.
2014-01-13 16:31:05 +01:00
Wim Taymans
81cef109e2 avviddec: release buffers when not direct rendering
New libav will not call the release_buffer callback anymore when
avcodec_default_get_buffer() is called from get_buffer. Releasing of the
memory in a picture should now be done by registering a callback to the
avbuffer objects in the picture. There is some compatibility code to
wrap the memory we provide in get_buffer in avbuffer with a callback to
release_buffer but that is not done when avcodec_default_get_buffer()
is called.

Work around this by adding a dummy avbuffer object to the picture that
will release the frame.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=721077
2014-01-10 17:28:22 +01:00
Sebastian Dröge
9887521a32 av: Enable HEVC / h265 support 2014-01-06 13:39:32 +01:00
Mark Nauwelaerts
47d5c2b6d6 avviddec: improve buffer handling and semantics
... so as to focus on providing *a* buffer rather than one (too) tied
to a frame, in particular allowing multiple allocations related to a frame.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=697806
2013-12-07 12:11:34 +01:00
Sebastian Dröge
423d9dcd71 avviddec: Use new gst_video_decoder_set_needs_format() API 2013-12-05 11:51:27 +01:00
Mark Nauwelaerts
039b608b24 avviddec: only use upstream framerate if really specified
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=704161
2013-12-02 20:21:34 +01:00
Mark Nauwelaerts
fa5865c0cd avviddec: discard unused input frames
... to avoid these piling up in list of pending frames.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=693772
2013-11-26 20:57:37 +01:00
Mark Nauwelaerts
2ec4008ea5 avviddec: really release frame at proper time
... by also removing it from the pending list of frames,
where it may still be in if it has never been submitted to _finish.
This could happen if is a decode-only frame, or in skipped decoding
situation, ...

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=693772
2013-11-26 20:55:43 +01:00
Sebastian Dröge
3c77754524 avviddec: Reset some more fields in ::stop() 2013-10-02 12:52:35 +02:00
Sebastian Dröge
5f5b6f465c avviddec: Don't believe we're negotiated if negotiation failed
It can happen that negotiation fails during get_buffer(), but then
we don't retry later and never return NOT_NEGOTIATED upstream...
and instead run into assertions.
2013-10-02 12:52:11 +02:00
Sebastian Dröge
677eaa6692 avviddec: Initialize strides with the ones of avcodec_default_get_buffer() if we ever call it
https://bugzilla.gnome.org/show_bug.cgi?id=704769
2013-09-12 13:57:41 +02:00
Sebastian Dröge
1277540b8c avviddec: Use the correct context for negotiation
During get_buffer() it can happen that the main context is not
updated yet and only the context passed here has the correct
width, height, etc.
2013-09-12 12:12:23 +02:00
Sebastian Dröge
faec0142e3 avviddec: Remember initially used stride and don't allow stride changes
libav does not allow stride changes currently, fall back to
non-direct rendering here:
https://bugzilla.gnome.org/show_bug.cgi?id=704769
https://bugzilla.libav.org/show_bug.cgi?id=556
2013-09-12 12:11:29 +02:00
Sebastian Dröge
6571196fb8 libav: avcodec_close() also resets fields like the AVCodec
We need to reload the defaults for the codec after closing it,
otherwise we can't access codec information like the supported
sample rates and can crash.

https://bugzilla.gnome.org/show_bug.cgi?id=707040
2013-08-29 16:53:28 +02:00
Sebastian Dröge
ae946bab1c libav: Use new flush vfunc of video codec base classes and remove reset implementations 2013-08-15 15:51:52 +02:00
Olivier Crête
2556cb325a avviddec: Initialise opaque from the start
https://bugzilla.gnome.org/show_bug.cgi?id=693581
2013-07-23 14:01:32 +02:00