upgrade-gst-bad-to-1-14-4
diff --git a/gst/jpegformat/gstjpegformat.c b/gst/jpegformat/gstjpegformat.c
index b410466..1faf1ce 100644
--- a/gst/jpegformat/gstjpegformat.c
+++ b/gst/jpegformat/gstjpegformat.c
@@ -30,7 +30,7 @@
static gboolean
plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "jpegparse", GST_RANK_NONE,
+ if (!gst_element_register (plugin, "jpegparse", GST_RANK_PRIMARY,
GST_TYPE_JPEG_PARSE))
return FALSE;
if (!gst_element_register (plugin, "jifmux", GST_RANK_SECONDARY,
diff --git a/gst/jpegformat/gstjpegparse.c b/gst/jpegformat/gstjpegparse.c
index 0bfdc80..b9f1853 100644
--- a/gst/jpegformat/gstjpegparse.c
+++ b/gst/jpegformat/gstjpegparse.c
@@ -151,7 +151,7 @@
gst_element_class_set_static_metadata (gstelement_class,
"JPEG stream parser",
- "Video/Parser",
+ "Video/Parser/Codec",
"Parse JPEG images into single-frame buffers",
"Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>");
diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c
index 7751ea2..ceb2f58 100644
--- a/gst/videoparsers/gsth264parse.c
+++ b/gst/videoparsers/gsth264parse.c
@@ -167,6 +167,7 @@
h264parse->aud_needed = TRUE;
h264parse->aud_insert = TRUE;
+ h264parse->caps_flag = FALSE;
}
@@ -1835,13 +1836,21 @@
caps = gst_caps_copy (sink_caps);
/* sps should give this but upstream overrides */
- if (s && gst_structure_has_field (s, "width"))
- gst_structure_get_int (s, "width", &width);
+ if (s && gst_structure_has_field (s, "width")) {
+ gst_structure_get_int (s, "width", &width);
+ if (width != h264parse->width) {
+ width = h264parse->width;
+ }
+ }
else
width = h264parse->width;
- if (s && gst_structure_has_field (s, "height"))
- gst_structure_get_int (s, "height", &height);
+ if (s && gst_structure_has_field (s, "height")) {
+ gst_structure_get_int (s, "height", &height);
+ if (height != h264parse->height) {
+ height = h264parse->height;
+ }
+ }
else
height = h264parse->height;
@@ -1988,7 +1997,10 @@
gst_buffer_replace (&h264parse->codec_data, NULL);
}
- gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (h264parse), caps);
+ if (sps && !h264parse->caps_flag) {
+ h264parse->caps_flag = TRUE;
+ gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (h264parse), caps);
+ }
}
if (src_caps)
@@ -2581,11 +2593,11 @@
if (format == GST_H264_PARSE_FORMAT_NONE) {
/* codec_data implies avc */
if (codec_data_value != NULL) {
- GST_ERROR ("video/x-h264 caps with codec_data but no stream-format=avc");
+ GST_LOG ("video/x-h264 caps with codec_data but no stream-format=avc");
format = GST_H264_PARSE_FORMAT_AVC;
} else {
/* otherwise assume bytestream input */
- GST_ERROR ("video/x-h264 caps without codec_data or stream-format");
+ GST_LOG ("video/x-h264 caps without codec_data or stream-format");
format = GST_H264_PARSE_FORMAT_BYTE;
}
}
diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h
index 137c2cd..997c0e3 100644
--- a/gst/videoparsers/gsth264parse.h
+++ b/gst/videoparsers/gsth264parse.h
@@ -132,6 +132,7 @@
/* For insertion of AU Delimiter */
gboolean aud_needed;
gboolean aud_insert;
+ gboolean caps_flag;
};
struct _GstH264ParseClass
diff --git a/gst/videoparsers/gsth265parse.c b/gst/videoparsers/gsth265parse.c
index 775cd24..13c93ea 100644
--- a/gst/videoparsers/gsth265parse.c
+++ b/gst/videoparsers/gsth265parse.c
@@ -154,6 +154,7 @@
gst_h265_parse_init (GstH265Parse * h265parse)
{
h265parse->frame_out = gst_adapter_new ();
+ h265parse->has_caps_flag = FALSE;
gst_base_parse_set_pts_interpolation (GST_BASE_PARSE (h265parse), FALSE);
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (h265parse));
GST_PAD_SET_ACCEPT_TEMPLATE (GST_BASE_PARSE_SINK_PAD (h265parse));
@@ -1761,7 +1762,12 @@
gst_buffer_replace (&h265parse->codec_data, NULL);
}
- gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (h265parse), caps);
+ if (h265parse->has_caps_flag == FALSE) {
+ GST_INFO_OBJECT (h265parse, "h265parse->has_caps_flag=FALSE");
+ gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (h265parse), caps);
+ h265parse->has_caps_flag = TRUE;
+ }
+
}
if (src_caps)
diff --git a/gst/videoparsers/gsth265parse.h b/gst/videoparsers/gsth265parse.h
index eb82f6f..0d6be87 100644
--- a/gst/videoparsers/gsth265parse.h
+++ b/gst/videoparsers/gsth265parse.h
@@ -86,6 +86,7 @@
/* frame parsing */
gint idr_pos, sei_pos;
gboolean update_caps;
+ gboolean has_caps_flag;
GstAdapter *frame_out;
gboolean keyframe;
gboolean header;
diff --git a/gst/videoparsers/gstmpeg4videoparse.c b/gst/videoparsers/gstmpeg4videoparse.c
index 38e1f45..780d2db 100644
--- a/gst/videoparsers/gstmpeg4videoparse.c
+++ b/gst/videoparsers/gstmpeg4videoparse.c
@@ -210,6 +210,7 @@
mp4vparse->pending_key_unit_ts = GST_CLOCK_TIME_NONE;
mp4vparse->force_key_unit_event = NULL;
mp4vparse->discont = FALSE;
+ mp4vparse->vop_flag = FALSE;
gst_buffer_replace (&mp4vparse->config, NULL);
memset (&mp4vparse->vol, 0, sizeof (mp4vparse->vol));
@@ -338,6 +339,7 @@
if (packet->type == GST_MPEG4_VIDEO_OBJ_PLANE) {
GST_LOG_OBJECT (mp4vparse, "startcode is VOP");
mp4vparse->vop_offset = packet->offset;
+ mp4vparse->vop_flag = TRUE;
} else if (packet->type == GST_MPEG4_GROUP_OF_VOP) {
GST_LOG_OBJECT (mp4vparse, "startcode is GOP");
} else {
@@ -527,6 +529,7 @@
GST_BUFFER_FLAG_SET (frame->buffer, GST_BUFFER_FLAG_DISCONT);
mp4vparse->discont = FALSE;
}
+ mp4vparse->vop_flag = FALSE;
return gst_base_parse_finish_frame (parse, frame, framesize);
}
@@ -540,8 +543,8 @@
GstStructure *s = NULL;
/* only update if no src caps yet or explicitly triggered */
- if (G_LIKELY (gst_pad_has_current_caps (GST_BASE_PARSE_SRC_PAD (mp4vparse)) &&
- !mp4vparse->update_caps))
+ if (G_LIKELY (gst_pad_has_current_caps (GST_BASE_PARSE_SRC_PAD (mp4vparse)) ||
+ !mp4vparse->update_caps || (mp4vparse->vop_flag == FALSE)))
return;
GST_LOG_OBJECT (mp4vparse, "Updating caps");
@@ -641,7 +644,7 @@
else
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
- if (G_UNLIKELY (mp4vparse->drop && !mp4vparse->config)) {
+ if (G_UNLIKELY (mp4vparse->drop && !mp4vparse->config && (mp4vparse->vop_flag == FALSE))) {
GST_LOG_OBJECT (mp4vparse, "dropping frame as no config yet");
return GST_BASE_PARSE_FLOW_DROPPED;
} else
diff --git a/gst/videoparsers/gstmpeg4videoparse.h b/gst/videoparsers/gstmpeg4videoparse.h
index 149289a..73e4407 100644
--- a/gst/videoparsers/gstmpeg4videoparse.h
+++ b/gst/videoparsers/gstmpeg4videoparse.h
@@ -54,6 +54,7 @@
gboolean config_found;
gboolean update_caps;
gboolean sent_codec_tag;
+ gboolean vop_flag;
GstMpeg4VisualObject vo;
gint vo_offset;
diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c
index 6896339..6547517 100644
--- a/gst/videoparsers/gstmpegvideoparse.c
+++ b/gst/videoparsers/gstmpegvideoparse.c
@@ -561,10 +561,10 @@
ret = FALSE;
} else {
/* TSN is stored in first 10 bits */
- int tsn = info->data[off] << 2 | (info->data[off + 1] & 0xC0) >> 6;
+ //int tsn = info->data[off] << 2 | (info->data[off + 1] & 0xC0) >> 6;
- if (tsn == mpvparse->pichdr.tsn) /* prevent termination if TSN is same */
- ret = FALSE;
+ //if (tsn == mpvparse->pichdr.tsn) /* prevent termination if TSN is same */
+ // ret = FALSE;
}
}
}
@@ -731,12 +731,18 @@
{
GstCaps *caps = NULL;
GstStructure *s = NULL;
+ static gboolean is_first_in=TRUE;
/* only update if no src caps yet or explicitly triggered */
if (G_LIKELY (gst_pad_has_current_caps (GST_BASE_PARSE_SRC_PAD (mpvparse)) &&
!mpvparse->update_caps))
return;
+ if (!is_first_in) {
+ return;
+ }
+ is_first_in = FALSE;
+
/* carry over input caps as much as possible; override with our own stuff */
caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (mpvparse));
if (caps) {
@@ -758,24 +764,12 @@
"parsed", G_TYPE_BOOLEAN, TRUE, NULL);
if (mpvparse->sequencehdr.width > 0 && mpvparse->sequencehdr.height > 0) {
- GstMpegVideoSequenceDisplayExt *seqdispext;
+
gint width, height;
width = mpvparse->sequencehdr.width;
height = mpvparse->sequencehdr.height;
- if (mpvparse->config_flags & FLAG_SEQUENCE_DISPLAY_EXT) {
- seqdispext = &mpvparse->sequencedispext;
-
- if (seqdispext->display_horizontal_size <= width
- && seqdispext->display_vertical_size <= height) {
- width = seqdispext->display_horizontal_size;
- height = seqdispext->display_vertical_size;
- GST_INFO_OBJECT (mpvparse,
- "stream has display extension: display_width=%d display_height=%d",
- width, height);
- }
- }
gst_caps_set_simple (caps, "width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, NULL);
}
@@ -927,6 +921,61 @@
}
static GstFlowReturn
+gst_mpegv_parse_frame_max_slice_no (const GstBuffer * buf, guint * max_slice_no)
+{
+ GstFlowReturn ret = GST_FLOW_OK;
+ GstBuffer *buffer = buf;
+ GstMapInfo map;
+ guint8 *data = NULL;
+ size_t size = 0;
+ size_t offset = 0;
+ guint max_no = 0;
+
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
+
+ for (offset=0; offset + 3 < size; offset++) {
+ if (!memcmp(data+offset, "\x00\x00\x01", 3)) {
+ guint currentStartCode = data[offset+3];
+
+ if ((currentStartCode <= GST_MPEG_VIDEO_PACKET_SLICE_MAX) && (currentStartCode > max_no)) {
+ max_no = currentStartCode;
+ }
+ }
+ }
+
+ gst_buffer_unmap (buffer, &map);
+
+ *max_slice_no = max_no;
+ return ret;
+}
+
+static gboolean
+gst_mpegv_parse_frame_is_invalid (GstBaseParse * parse, GstBaseParseFrame * frame)
+{
+ GstMpegvParse *mpvparse = GST_MPEGVIDEO_PARSE (parse);
+ GstBuffer *buffer = frame->buffer;
+ static guint preFrameMaxSliceNo = 0;
+ guint curFrameMaxSliceNo = 0;
+ static gboolean shouldDrop = FALSE;
+
+ if (G_UNLIKELY (mpvparse->pichdr.pic_type != GST_MPEG_VIDEO_PICTURE_TYPE_I)) {
+ return shouldDrop;
+ }
+
+ gst_mpegv_parse_frame_max_slice_no (buffer, &curFrameMaxSliceNo);
+ if ((curFrameMaxSliceNo + 13) <= preFrameMaxSliceNo) {
+ shouldDrop = TRUE;
+ } else {
+ shouldDrop = FALSE;
+ }
+
+ preFrameMaxSliceNo = curFrameMaxSliceNo;
+ return shouldDrop;
+}
+
+static GstFlowReturn
gst_mpegv_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
{
GstMpegvParse *mpvparse = GST_MPEGVIDEO_PARSE (parse);
@@ -939,6 +988,16 @@
GstMpegVideoPictureExt *pic_ext = NULL;
GstMpegVideoQuantMatrixExt *quant_ext = NULL;
+ if (gst_mpegv_parse_frame_is_invalid (parse, frame)) {
+ frame->flags |= GST_BASE_PARSE_FRAME_FLAG_DROP;
+ return GST_FLOW_OK;
+ }
+
+ GstBuffer *buffer = frame->buffer;
+ if (!GST_BUFFER_PTS_IS_VALID (buffer)) {
+ GST_BUFFER_PTS (buffer) = GST_BUFFER_DTS (buffer);
+ }
+
/* tag sending done late enough in hook to ensure pending events
* have already been sent */