mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-25 23:46:45 +00:00
h264parse: Use slice type to determine if frame is keyframe
This is the same behaviour as pre-baseparse-refactoring https://bugzilla.gnome.org/show_bug.cgi?id=705598
This commit is contained in:
parent
b17676a1d5
commit
8074a48594
1 changed files with 12 additions and 8 deletions
|
@ -453,10 +453,6 @@ _nal_name (GstH264NalUnitType nal_type)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* SPS/PPS/IDR considered key, all others DELTA;
|
|
||||||
* so downstream waiting for keyframe can pick up at SPS/PPS/IDR */
|
|
||||||
#define NAL_TYPE_IS_KEY(nt) (((nt) == 5) || ((nt) == 7) || ((nt) == 8))
|
|
||||||
|
|
||||||
/* caller guarantees 2 bytes of nal payload */
|
/* caller guarantees 2 bytes of nal payload */
|
||||||
static void
|
static void
|
||||||
gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
|
gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
|
||||||
|
@ -476,7 +472,6 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
|
||||||
|
|
||||||
/* we have a peek as well */
|
/* we have a peek as well */
|
||||||
nal_type = nalu->type;
|
nal_type = nalu->type;
|
||||||
h264parse->keyframe |= NAL_TYPE_IS_KEY (nal_type);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (h264parse, "processing nal of type %u %s, size %u",
|
GST_DEBUG_OBJECT (h264parse, "processing nal of type %u %s, size %u",
|
||||||
nal_type, _nal_name (nal_type), nalu->size);
|
nal_type, _nal_name (nal_type), nalu->size);
|
||||||
|
@ -572,18 +567,27 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
|
||||||
h264parse->frame_start = TRUE;
|
h264parse->frame_start = TRUE;
|
||||||
}
|
}
|
||||||
GST_DEBUG_OBJECT (h264parse, "frame start: %i", h264parse->frame_start);
|
GST_DEBUG_OBJECT (h264parse, "frame start: %i", h264parse->frame_start);
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
|
||||||
{
|
{
|
||||||
GstH264SliceHdr slice;
|
GstH264SliceHdr slice;
|
||||||
GstH264ParserResult pres;
|
|
||||||
|
|
||||||
pres = gst_h264_parser_parse_slice_hdr (nalparser, nalu, &slice,
|
pres = gst_h264_parser_parse_slice_hdr (nalparser, nalu, &slice,
|
||||||
FALSE, FALSE);
|
FALSE, FALSE);
|
||||||
GST_DEBUG_OBJECT (h264parse,
|
GST_DEBUG_OBJECT (h264parse,
|
||||||
"parse result %d, first MB: %u, slice type: %u",
|
"parse result %d, first MB: %u, slice type: %u",
|
||||||
pres, slice.first_mb_in_slice, slice.type);
|
pres, slice.first_mb_in_slice, slice.type);
|
||||||
|
if (pres == GST_H264_PARSER_OK) {
|
||||||
|
switch (slice.type) {
|
||||||
|
case 2:
|
||||||
|
case 4:
|
||||||
|
case 7:
|
||||||
|
case 9:
|
||||||
|
h264parse->keyframe |= TRUE;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (G_LIKELY (nal_type != GST_H264_NAL_SLICE_IDR &&
|
if (G_LIKELY (nal_type != GST_H264_NAL_SLICE_IDR &&
|
||||||
!h264parse->push_codec))
|
!h264parse->push_codec))
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue