summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'media-video/mpv/files/0.18.1/mpv-0.18.1-handle-ffmpeg-ABI-changes.patch')
-rw-r--r--media-video/mpv/files/0.18.1/mpv-0.18.1-handle-ffmpeg-ABI-changes.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/media-video/mpv/files/0.18.1/mpv-0.18.1-handle-ffmpeg-ABI-changes.patch b/media-video/mpv/files/0.18.1/mpv-0.18.1-handle-ffmpeg-ABI-changes.patch
new file mode 100644
index 000000000000..7c006b8506ae
--- /dev/null
+++ b/media-video/mpv/files/0.18.1/mpv-0.18.1-handle-ffmpeg-ABI-changes.patch
@@ -0,0 +1,69 @@
+commit dcfde2934dd7b5401b29d6a604fa3eca1b867d5c
+Author: wm4 <wm4@nowhere>
+Date: Sun Jul 24 19:31:47 2016 +0200
+
+audio: use idiotic FFmpeg ABI rules for public-except-not-public fields
+
+The FFmpeg API is incredibly weird and inconsistent about this. This is
+also a FFmpeg-only issue and nothing like this is in Libav - which
+doesn't really show FFmpeg in a very positive light.
+
+(To make it even worse: this is a full-blown Libav API incompatibility,
+even though this crap was added for Libav ABI-compatibility. It's
+absurd.)
+
+Quoting the FFmpeg header for the AVFrame.channels field:
+
+ /**
+ * number of audio channels, only used for audio.
+ * Code outside libavutil should access this field using:
+ * av_frame_get_channels(frame)
+ * - encoding: unused
+ * - decoding: Read by user.
+ */
+ int channels;
+
+It says "should" not must, and it doesn't even mention
+av_frame_set_channels(). It's also in the section for public fields (not
+below a marker that indicates private fields in a public struct, like
+it's done e.g. in AVCodecContext).
+
+But not using the accessor will cause silent failures on ABI changes.
+The failure that happened due to this code didn't even make it apparent
+what was wrong. So just use the idiotic accessor.
+
+Also harmonize the FFmpeg-cursing in the code. (It's fully justified.)
+
+Fixes #3295.
+
+Note that mpv will still check the exact library version numbers, and
+reject mismatches - to protect itself from such issues in the future.
+
+diff --git a/audio/audio.c b/audio/audio.c
+index 710cc03..4c67a9a 100644
+--- a/audio/audio.c
++++ b/audio/audio.c
+@@ -347,9 +347,9 @@ struct mp_audio *mp_audio_from_avframe(struct AVFrame *avframe)
+ mp_chmap_from_lavc(&lavc_chmap, avframe->channel_layout);
+
+ #if LIBAVUTIL_VERSION_MICRO >= 100
+- // FFmpeg being special again
+- if (lavc_chmap.num != avframe->channels)
+- mp_chmap_from_channels(&lavc_chmap, avframe->channels);
++ // FFmpeg being stupid POS again
++ if (lavc_chmap.num != av_frame_get_channels(avframe))
++ mp_chmap_from_channels(&lavc_chmap, av_frame_get_channels(avframe));
+ #endif
+
+ new->rate = avframe->sample_rate;
+@@ -407,8 +407,8 @@ int mp_audio_to_avframe(struct mp_audio *frame, struct AVFrame *avframe)
+ if (!avframe->channel_layout)
+ goto fail;
+ #if LIBAVUTIL_VERSION_MICRO >= 100
+- // FFmpeg being a stupid POS (but I respect it)
+- avframe->channels = frame->channels.num;
++ // FFmpeg being a stupid POS again
++ av_frame_set_channels(avframe, frame->channels.num);
+ #endif
+ avframe->sample_rate = frame->rate;
+