From 8074a48594acd17eaa2a2e7ea3fd03d85f41a664 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 7 Aug 2013 09:04:39 +0200 Subject: [PATCH] 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 --- gst/videoparsers/gsth264parse.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 0a2f69d..1a1e391 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -453,10 +453,6 @@ _nal_name (GstH264NalUnitType nal_type) } #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 */ static void 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 */ nal_type = nalu->type; - h264parse->keyframe |= NAL_TYPE_IS_KEY (nal_type); GST_DEBUG_OBJECT (h264parse, "processing nal of type %u %s, size %u", 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; } GST_DEBUG_OBJECT (h264parse, "frame start: %i", h264parse->frame_start); -#ifndef GST_DISABLE_GST_DEBUG { GstH264SliceHdr slice; - GstH264ParserResult pres; pres = gst_h264_parser_parse_slice_hdr (nalparser, nalu, &slice, FALSE, FALSE); GST_DEBUG_OBJECT (h264parse, "parse result %d, first MB: %u, slice type: %u", 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 && !h264parse->push_codec)) break; -- 2.7.4