mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
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/1072>
This commit is contained in:
parent
ab6cb4c2c7
commit
fedd6c2a28
1 changed files with 26 additions and 27 deletions
|
@ -1968,37 +1968,36 @@ gst_avi_demux_check_caps (GstAviDemux * avi, GstAviStream * stream,
|
||||||
gst_structure_remove_field (s, "palette_data");
|
gst_structure_remove_field (s, "palette_data");
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
} else if (!gst_structure_has_name (s, "video/x-h264")) {
|
} else if (gst_structure_has_name (s, "video/x-h264")) {
|
||||||
return caps;
|
GST_DEBUG_OBJECT (avi, "checking caps %" GST_PTR_FORMAT, 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;
|
||||||
|
|
||||||
/* some muxers put invalid bytestream stuff in h264 extra data */
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
val = gst_structure_get_value (s, "codec_data");
|
data = map.data;
|
||||||
if (val && (buf = gst_value_get_buffer (val))) {
|
size = map.size;
|
||||||
guint8 *data;
|
if (size >= 4) {
|
||||||
gint size;
|
guint32 h = GST_READ_UINT32_BE (data);
|
||||||
GstMapInfo map;
|
|
||||||
|
|
||||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
gst_buffer_unmap (buf, &map);
|
||||||
data = map.data;
|
if (h == 0x01 || (h >> 8) == 0x01) {
|
||||||
size = map.size;
|
/* can hardly be valid AVC codec data */
|
||||||
if (size >= 4) {
|
GST_DEBUG_OBJECT (avi,
|
||||||
guint32 h = GST_READ_UINT32_BE (data);
|
"discarding invalid codec_data containing byte-stream");
|
||||||
gst_buffer_unmap (buf, &map);
|
/* so do not pretend to downstream that it is packetized avc */
|
||||||
if (h == 0x01) {
|
gst_structure_remove_field (s, "codec_data");
|
||||||
/* can hardly be valid AVC codec data */
|
/* ... but rather properly parsed bytestream */
|
||||||
GST_DEBUG_OBJECT (avi,
|
gst_structure_set (s, "stream-format", G_TYPE_STRING, "byte-stream",
|
||||||
"discarding invalid codec_data containing byte-stream");
|
"alignment", G_TYPE_STRING, "au", NULL);
|
||||||
/* so do not pretend to downstream that it is packetized avc */
|
}
|
||||||
gst_structure_remove_field (s, "codec_data");
|
} else {
|
||||||
/* ... but rather properly parsed bytestream */
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_structure_set (s, "stream-format", G_TYPE_STRING, "byte-stream",
|
|
||||||
"alignment", G_TYPE_STRING, "au", NULL);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
gst_buffer_unmap (buf, &map);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue