mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
mpeg2: optimize scan for the end of the frame.
Heuristic: if the second start-code is available, check whether that one marks the start of a new frame because e.g. this is a sequence or picture header. This doesn't save much, since we already cache the results.
This commit is contained in:
parent
3bc6078f32
commit
0ecb3a627b
1 changed files with 14 additions and 3 deletions
|
@ -1323,7 +1323,7 @@ gst_vaapi_decoder_mpeg2_parse(GstVaapiDecoder *base_decoder,
|
||||||
GST_VAAPI_DECODER_MPEG2_CAST(base_decoder);
|
GST_VAAPI_DECODER_MPEG2_CAST(base_decoder);
|
||||||
GstVaapiParserState * const ps = GST_VAAPI_PARSER_STATE(base_decoder);
|
GstVaapiParserState * const ps = GST_VAAPI_PARSER_STATE(base_decoder);
|
||||||
GstVaapiDecoderStatus status;
|
GstVaapiDecoderStatus status;
|
||||||
GstMpegVideoPacketTypeCode type;
|
GstMpegVideoPacketTypeCode type, type2 = GST_MPEG_VIDEO_PACKET_NONE;
|
||||||
const guchar *buf;
|
const guchar *buf;
|
||||||
guint buf_size, flags;
|
guint buf_size, flags;
|
||||||
gint ofs, ofs1, ofs2;
|
gint ofs, ofs1, ofs2;
|
||||||
|
@ -1350,7 +1350,7 @@ gst_vaapi_decoder_mpeg2_parse(GstVaapiDecoder *base_decoder,
|
||||||
ofs2 = ofs1 + 4;
|
ofs2 = ofs1 + 4;
|
||||||
|
|
||||||
ofs = G_UNLIKELY(buf_size < ofs2 + 4) ? -1 :
|
ofs = G_UNLIKELY(buf_size < ofs2 + 4) ? -1 :
|
||||||
scan_for_start_code(&buf[ofs2], buf_size - ofs2, NULL);
|
scan_for_start_code(&buf[ofs2], buf_size - ofs2, &type2);
|
||||||
if (ofs < 0) {
|
if (ofs < 0) {
|
||||||
// Assume the whole packet is present if end-of-stream
|
// Assume the whole packet is present if end-of-stream
|
||||||
if (!at_eos) {
|
if (!at_eos) {
|
||||||
|
@ -1386,8 +1386,19 @@ gst_vaapi_decoder_mpeg2_parse(GstVaapiDecoder *base_decoder,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (type >= GST_MPEG_VIDEO_PACKET_SLICE_MIN &&
|
if (type >= GST_MPEG_VIDEO_PACKET_SLICE_MIN &&
|
||||||
type <= GST_MPEG_VIDEO_PACKET_SLICE_MAX)
|
type <= GST_MPEG_VIDEO_PACKET_SLICE_MAX) {
|
||||||
flags |= GST_VAAPI_DECODER_UNIT_FLAG_SLICE;
|
flags |= GST_VAAPI_DECODER_UNIT_FLAG_SLICE;
|
||||||
|
switch (type2) {
|
||||||
|
case GST_MPEG_VIDEO_PACKET_USER_DATA:
|
||||||
|
case GST_MPEG_VIDEO_PACKET_SEQUENCE:
|
||||||
|
case GST_MPEG_VIDEO_PACKET_GOP:
|
||||||
|
case GST_MPEG_VIDEO_PACKET_PICTURE:
|
||||||
|
flags |= GST_VAAPI_DECODER_UNIT_FLAG_FRAME_END;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore system start codes (PES headers)
|
// Ignore system start codes (PES headers)
|
||||||
else if (type >= 0xb9 && type <= 0xff)
|
else if (type >= 0xb9 && type <= 0xff)
|
||||||
|
|
Loading…
Reference in a new issue