summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2021-09-02 08:38:54 +0300
committerTim-Philipp Müller <tim@centricular.com>2021-09-02 17:47:21 +0100
commit1e8d018ba2f0f6bc90a61ac59dd196a356ab4268 (patch)
tree54fccf11a344b2a3afa7f93d2d13a1ea1051b15e
parent250b844fba1f7c5e4aba5be7cf1e69707ddc3f6c (diff)
downloadgstreamer-plugins-good-1e8d018ba2f0f6bc90a61ac59dd196a356ab4268.tar.gz
avidemux: Also detect 0x000001 as H264 byte-stream start code in codec_data
This works around some AVI files storing byte-stream data in the codec_data. The previous workaround was only checking for 0x00000001 (4 bytes) instead of 0x000001 (3 bytes). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1073>
-rw-r--r--gst/avi/gstavidemux.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c
index 25c97da03..bd0e79518 100644
--- a/gst/avi/gstavidemux.c
+++ b/gst/avi/gstavidemux.c
@@ -1965,37 +1965,36 @@ gst_avi_demux_check_caps (GstAviDemux * avi, GstAviStream * stream,
gst_structure_remove_field (s, "palette_data");
return caps;
}
- } else if (!gst_structure_has_name (s, "video/x-h264")) {
- return caps;
- }
-
- GST_DEBUG_OBJECT (avi, "checking caps %" GST_PTR_FORMAT, caps);
-
- /* some muxers put invalid bytestream stuff in h264 extra data */
- val = gst_structure_get_value (s, "codec_data");
- if (val && (buf = gst_value_get_buffer (val))) {
- guint8 *data;
- gint size;
- GstMapInfo map;
-
- gst_buffer_map (buf, &map, GST_MAP_READ);
- data = map.data;
- size = map.size;
- if (size >= 4) {
- guint32 h = GST_READ_UINT32_BE (data);
- gst_buffer_unmap (buf, &map);
- if (h == 0x01) {
- /* can hardly be valid AVC codec data */
- GST_DEBUG_OBJECT (avi,
- "discarding invalid codec_data containing byte-stream");
- /* so do not pretend to downstream that it is packetized avc */
- gst_structure_remove_field (s, "codec_data");
- /* ... but rather properly parsed bytestream */
- gst_structure_set (s, "stream-format", G_TYPE_STRING, "byte-stream",
- "alignment", G_TYPE_STRING, "au", NULL);
+ } else if (gst_structure_has_name (s, "video/x-h264")) {
+ GST_DEBUG_OBJECT (avi, "checking caps %" GST_PTR_FORMAT, caps);
+
+ /* some muxers put invalid bytestream stuff in h264 extra data */
+ val = gst_structure_get_value (s, "codec_data");
+ if (val && (buf = gst_value_get_buffer (val))) {
+ guint8 *data;
+ gint size;
+ GstMapInfo map;
+
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
+ if (size >= 4) {
+ guint32 h = GST_READ_UINT32_BE (data);
+
+ gst_buffer_unmap (buf, &map);
+ if (h == 0x01 || (h >> 8) == 0x01) {
+ /* can hardly be valid AVC codec data */
+ GST_DEBUG_OBJECT (avi,
+ "discarding invalid codec_data containing byte-stream");
+ /* so do not pretend to downstream that it is packetized avc */
+ gst_structure_remove_field (s, "codec_data");
+ /* ... but rather properly parsed bytestream */
+ gst_structure_set (s, "stream-format", G_TYPE_STRING, "byte-stream",
+ "alignment", G_TYPE_STRING, "au", NULL);
+ }
+ } else {
+ gst_buffer_unmap (buf, &map);
}
- } else {
- gst_buffer_unmap (buf, &map);
}
}