Add a new function new_aligned_buffer() which creates a GstBuffer of
the requested size/caps, with the memory being allocated/freed by ffmpeg's
av_malloc/av_free which guarantees properly aligned memory.
Added a can_allocate_aligned internal property which we use to figure out
whether downstream can provide us with 128bit aligned buffers.
Without a frame_size configured in the context, the ffmpeg encoders do nothing.
Since the G726 does not configure a size itself, we set ourselves a frame_size
that corresponds to 20ms of audio, which is a reasonable default.
We do this, because the demuxer is initialized in the loop function. If it's not
initialized yet, that means the loop hasn't been entered... and therefore the
PIPE GCond will never be signalled.
We simply allocate the memory using ffmpeg's av_malloc which provides us
with properly memalign'ed data.
This avoids write-outside-of-bounds when sse/altivec code is being used.
The internal resampling functions seem to require a slightly bigger buffer
for output than what we require. Therefore we give it an extra 64bytes (although
16 should have been enough).
We should post a STREAM DECODE error message on the bus when we return
GST_FLOW_ERROR, otherwise the user ends up seeing an ugly internal flow
error message, which isn't very nice.
The problem is that the ffmpeg aac decoder fails... but still accepts
the following buffers as if nothing happened. But because some things
were not properly set in the internal code, all hell breaks loose.
AVOutputFormat does *NOT* contain the full list of codecs a muxer can handle,
but does contain the recommended audio and video codecs. Therefore we use that
information to expose more muxers, until AVOutputFormat contains a list of
*ALL* compatible codecs.
For a given AVCodec, when the sample_fmts field is non-NULL, that means that
that codec can only handle a specific set of SampleFormat.
With this patch, we now look for its presence and create the proper pad template
caps.
Fixes#569441
Where no more data is available, av_read_frame just returns an error code
instead of making the difference between "I am not returning anything because
we finished reading" and "I am not returning anything because the underlying
read failed".
We differentiate between the two by looking at whether we outputted any
data previously or not.