Commit graph

147 commits

Author SHA1 Message Date
Sebastian Dröge
0db6ce0f11 avdemux: Fix deadlock when serialized events are received from upstream while opening
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3657

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7362>
2024-08-16 09:55:11 +00:00
Jesper Jensen
825f52d38b avprotocol: Return EOF when stream is out of data
According to the ffmpeg documentation[1] the read_packet function should never
return 0. ffmpegdata_peek returns 0 when the stream is EOF causing us to fail
detecting EOF and never close the pipeline, continually spinning on more data.
ffmpeg instead wants an AVERROR_EOF code for to signal EOF.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4999>
2024-08-05 10:23:32 +00:00
Edward Hervey
f7337b7477 ffmpeg: Don't register elements for which we have no caps
We would previously register a whole bunch of encoder/decoder for which the caps
were ... "unknown/unknown".

Add a function to quickly check (without generating caps) whether a given
AVCodecID has a known mapping (which can include the {video|audio}/x-gst-av-*
ones) without generating the caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6237>
2024-07-25 12:14:50 +00:00
Ruben Gonzalez
3e4c8f1b16 avmux: Fix crash when muxer doesn't get codecid
gst_ffmpeg_formatid_get_codecids from gst_ffmpegmux_base_init to gst_ffmpegmux_base_init

FFmpeg 7.0 included new muxer rcwt for Raw Captions with Time
(RCWT). Commit [1].  GStreamer couldn't get sink caps for muxer it.

Calling gst_ffmpeg_formatid_get_codecids in gst_ffmpegmux_register to
avoid create muxer without pad templates.

[1] https://github.com/FFmpeg/FFmpeg/commit/3525544e48

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7168>
2024-07-23 18:42:22 +00:00
Seungha Yang
75d8dbc556 avauddec: Fix crash on stop()
GstFFMpegAudDec.context can be nullptr if decoder got closed
without opening new context. Note that we don't need to clear
AVCodecContext.extradata there since avcodec_free_context()
will do clear the data if needed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7180>
2024-07-16 20:49:13 +09:00
Sebastian Dröge
a7bba83ded typefind: Add typefinders for formats that were previously available via ffmpeg
Co-Authored-By: Matthew Waters <matthew@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:39 +00:00
Sebastian Dröge
e52f0bbc03 avvidenc: Make sure to pass always increasing PTS to the encoder
All MPEG1/2/4-based encoders at least are ignoring input frames if
backwards PTS or PTS that are equal to the previous one are passed in.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:39 +00:00
Sebastian Dröge
1953bc6122 avviddec: Only use 2 ticks per frame if decoding interlaced video
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:39 +00:00
Sebastian Dröge
dc0aebbea0 avvidenc: Set the DTS to 0 if it is negative, not the PTS
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:39 +00:00
Sebastian Dröge
ee518b9c7e avvidenc: Only use 2 ticks per frame if encoding interlaced video
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3518

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:39 +00:00
Sebastian Dröge
03465d0904 avmux: Reset input context to NULL after closing in the muxer
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:39 +00:00
Sebastian Dröge
2a3f791c90 avdemux: Fix leak of demuxer input context in error cases
Also simplify context lifetime management a bit.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:39 +00:00
Sebastian Dröge
73d0cac16c libav: Update AVCodecContext lifetime to work properly with ffmpeg 7
avcodec_close() is deprecated and it's not supported anymore to re-open
a codec, so we only ever allocate the codec in set_format() now and
always free it after usage.

As part of this, also fix various memory leaks in related code paths.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:39 +00:00
Sebastian Dröge
0871a55c8a libav: Fix signature of avprotocol write function for ffmpeg 7
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:38 +00:00
Sebastian Dröge
9d465d9e68 avdemux: Remove typefinder implementation
Direct access to AVInputFormat::read_probe() is not possible anymore
with ffmpeg 7.0, and the usefulness of this typefinder seems limited
anyway. An alternative implementation around av_probe_input_format3() or
similar would be possible but it would be going over all possible ffmpeg
probes at once.

Having a typefinder here means that basically every application will
load the gst-libav plugin when typefinding is necessary, which has
unnecessary performance impacts. If a typefinder from here was indeed
missing from typefindfunctions in gst-plugins-base then it would be
better to add it there directly.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3378

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6505>
2024-07-08 14:31:38 +00:00
Edward Hervey
aab2f59d02 avviddec: Rename variables and fuse function
* gst_ffmpegviddec_frame() is the only caller of gst_ffmpegviddec_video_frame()
  and has the same signature. Just move the checks into a single function and
  use that.
* Make it clear which frames are the input and output ones in
  gst_ffmpegviddec_video_frame() to make issues like the one fixed in the previous
  commit more obvious.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6851>
2024-05-15 13:20:54 +00:00
Edward Hervey
64cac1ed99 avvidec: Fix dropping wrong "ghost" frames
This fixes the code regarding dropping "ghost frames", that is to say input
frames which ended up not producing any decoded frame.

The iteration itself makes sense.. but it was stopping at the "input" frame and
not the decoded frame we just got back.

When dealing with I-frame codecs, ffmpeg will decode frames in separate frames,
so there is no guarantee that they are decoding in order.

Fixes playback issues with such codecs

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6842>
2024-05-14 13:52:52 +02:00
Seungha Yang
bc8a3ca526 avviddec: Fix AVPacket leak
av_packet_unref() does not release allocated memory.
av_packet_free() is the correct free function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6544>
2024-04-04 19:39:09 +00:00
U. Artie Eoff
5fb2bbc2eb libav: guard dropped AV_OPT_TYPE_CHANNEL_LAYOUT
The FF_API_OLD_CHANNEL_LAYOUT api was dropped in upstream:

https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/65ddc7498824

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6341>
2024-04-02 07:12:37 +00:00
U. Artie Eoff
b699341ac9 libav: guard dropped AV_CODEC_ID_AYUV api
The FF_API_AYUV_CODECID api was dropped in upstream:

https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/9ee59b63f5ea

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6341>
2024-04-02 07:12:37 +00:00
Piotr Brzeziński
2ec7f9f9b3 avaudenc: Add simple 16 channel encoding test
Used to be crashing because of a double-free introduced years ago and never really noticed, so let's add a test to
make sure it doesn't happen again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6373>
2024-03-15 12:30:04 +00:00
Piotr Brzeziński
55136c30c4 avaudenc: Avoid double-freeing frame's extended data
This occured when attempting to encode 16 channel audio, would crash on the first buffer.
We only need to store ext_data, old ext_data_array (frame->extended_data) is already freed by `av_frame_unref`.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6359>
2024-03-14 16:35:21 +00:00
Piotr Brzeziński
a53ea3c61c avcodecmap: Increase max AAC channels to 16
This is the maximum amount supported by aacenc. 8-channel output fully works.
16-channel also encodes fine, but codec-utils isn't able to parse its channel config,
so output level will not be shown in caps. For that to work, GASpecificConfig parsing
needs to be implemented. It's not a critical issue and can be worked on at a later date.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6359>
2024-03-14 16:35:21 +00:00
Edward Hervey
086ecb008f avviddec: Fix how we get back the codec frame
With the new copy_opaque system, the corresponding frame is stored in the
picture opaque ref.

This also handles the case where the "regular" opaque might be empty in the
case of "DECODE_ONLY" frames, since it that field is set in `get_buffer2()`
which might not be called for those frames

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6301>
2024-03-11 10:17:41 +00:00
Edward Hervey
eacd5c1cb1 avviddec: Improve debug statements
Add SFN to better track what is going on

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6301>
2024-03-11 10:17:41 +00:00
Seungha Yang
37578454b9 avviddec: Fix interlaced mode detection
Fixing regression introduced by the commit b46559102b

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6285>
2024-03-07 11:53:07 +00:00
Tim-Philipp Müller
756064b9c3 Back to development
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6261>
2024-03-05 12:58:57 +00:00
Tim-Philipp Müller
b125253cad Release 1.24.0 2024-03-04 23:59:25 +00:00
Edward Hervey
a3980f4838 docs: Use Discourse and Matrix as prefered communication channels
Part of: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6220
2024-02-27 09:35:47 +01:00
Tim-Philipp Müller
d474de8ff0 Release 1.23.90 2024-02-23 18:20:11 +00:00
Sebastian Dröge
00bbd6961c libav: Don't add -Werror=deprecated-declarations
It will fail the build for anybody who has an older FFmpeg version
than 6.1 and doesn't use the FFmpeg subproject.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6199>
2024-02-23 13:24:22 +00:00
Seungha Yang
781fc4a1b6 avviddec: Fix crash with FFmpeg n6.0
FFmpeg version 6.0 has an AV_CODEC_FLAG_COPY_OPAQUE related bug.

See a3bf63c26e

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6184>
2024-02-22 18:54:45 +00:00
Tim-Philipp Müller
88412ef100 Back to development
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6126>
2024-02-15 16:38:53 +00:00
Tim-Philipp Müller
88751d4110 Release 1.23.2 2024-02-15 15:37:17 +00:00
Edward Hervey
a1cbe351ec musepack: Prefer using FFmpeg musepack decoder/demuxer
* Bump the rank of the musepack v7/v8 FFmpeg demuxers to SECONDARY
* Bump the rank of the musepack v7/v8 FFmpeg audio decoders to SECONDARY
* Demote the rank of the musepackdec element to MARGINAL

This is for two reasons:
* The musepack library is no longer maintained, whereas the FFmpeg
  implementation can/will receive fixes
* The `musepackdec` implementation was a all-in-one "parsing and decoding" blob
  which doesn't play nicely with decodebin3 and others

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3033

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6074>
2024-02-09 12:15:14 +00:00
Tim-Philipp Müller
2111d6f015 Back to development
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6066>
2024-02-06 18:29:31 +00:00
Tim-Philipp Müller
9255e397f0 Release 1.23.1 2024-02-06 16:43:27 +00:00
Tim-Philipp Müller
c84285d44d meson: bump Meson requirement to >= 1.1 for all modules
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6002>
2024-01-29 01:11:55 +00:00
Edward Hervey
978b75b18a avauddec: Use proper version guard
Just like we do with avviddec

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5931>
2024-01-17 17:24:49 +01:00
L. E. Segovia
396c5aef7c meson: Ensure FFmpeg deprecated APIs are rejected
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5186>
2024-01-17 08:39:13 +00:00
L. E. Segovia
b46559102b libav: Port deprecated AVFrame fields to flags
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5186>
2024-01-17 08:39:13 +00:00
L. E. Segovia
09de59477a libav: Port AVCodecContext.ticks_per_frame to AV_CODEC_PROP_FIELDS
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5186>
2024-01-17 08:39:13 +00:00
L. E. Segovia
4dc955e94a libav: Port reordered_opaque usage to ref-counted opaque_ref
Instead of passing along the system frame number, we pass along a reference to
the GstVideoCodecFrame.

In order for all internal cleanup to happen properly, this also requires
switching to the proper AVPacket creation/destruction methods (av_packet_alloc()
and av_packet_unref())

Fixes #2568

Co-authored-by: Edward Hervey <edward@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5186>
2024-01-17 08:39:13 +00:00
L. E. Segovia
f2c9d9baa1 libav: Port frame counting to frame_num
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5186>
2024-01-17 08:39:13 +00:00
L. E. Segovia
bbf6b4e634 libav: Port channel layout and counting to AVChannelLayout
Fixes #2833

Co-authored-by: Edward Hervey <edward@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5186>
2024-01-17 08:39:13 +00:00
Philippe Normand
84d9e5b6e7 avviddec: Calculate latency only for fixed framerate
The framerate was checked correctly in _negotiate, but not in _set_format.

Also fix loss of precision in _negotiate when calculating the framerate.

Fixes #3093

Co-authored-by: Sebastian Dröge <sebastian@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5600>
2023-12-17 12:48:44 +00:00
Seungha Yang
d2c9200828 avviddec: Unlock stream lock while waiting for decoded frame
FFmpeg might request buffer from other threads, it will result
in deadlock

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2558
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5681>
2023-11-16 18:02:30 +00:00
Seungha Yang
5e147ed3b8 meson: Fix MSVC build with GST_DISABLE_GST_DEBUG
MSVC does not understand Wno-unused

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5585>
2023-11-03 13:31:03 +00:00
Jordan Petridis
656bea80ea meson: Fix typo
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5526>
2023-10-22 08:06:29 +03:00
Jordan Petridis
88e6dd0555 ci: switch the Fedora base image to f34
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1060>
2023-10-22 05:23:28 +03:00