mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-10-01 09:39:47 +00:00
h265timestamper: Use gst_h265_parser_parse_decoder_config_record()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2759>
This commit is contained in:
parent
b5fb709be7
commit
837d8d1b20
1 changed files with 19 additions and 41 deletions
|
@ -139,6 +139,7 @@ gst_h265_timestamper_set_caps (GstCodecTimestamper * timestamper,
|
||||||
const gchar *str;
|
const gchar *str;
|
||||||
gboolean found_format = FALSE;
|
gboolean found_format = FALSE;
|
||||||
const GValue *codec_data_val;
|
const GValue *codec_data_val;
|
||||||
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
self->packetized = FALSE;
|
self->packetized = FALSE;
|
||||||
self->nal_length_size = 4;
|
self->nal_length_size = 4;
|
||||||
|
@ -155,70 +156,47 @@ gst_h265_timestamper_set_caps (GstCodecTimestamper * timestamper,
|
||||||
GstBuffer *codec_data = gst_value_get_buffer (codec_data_val);
|
GstBuffer *codec_data = gst_value_get_buffer (codec_data_val);
|
||||||
GstH265Parser *parser = self->parser;
|
GstH265Parser *parser = self->parser;
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
GstH265NalUnit nalu;
|
|
||||||
GstH265ParserResult pres;
|
GstH265ParserResult pres;
|
||||||
guint num_nal_arrays;
|
GstH265DecoderConfigRecord *config = NULL;
|
||||||
guint off;
|
guint i, j;
|
||||||
guint num_nals, i, j;
|
|
||||||
guint8 *data;
|
|
||||||
gsize size;
|
|
||||||
|
|
||||||
if (!gst_buffer_map (codec_data, &map, GST_MAP_READ)) {
|
if (!gst_buffer_map (codec_data, &map, GST_MAP_READ)) {
|
||||||
GST_ERROR_OBJECT (self, "Unable to map codec-data buffer");
|
GST_ERROR_OBJECT (self, "Unable to map codec-data buffer");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = map.data;
|
pres = gst_h265_parser_parse_decoder_config_record (parser,
|
||||||
size = map.size;
|
map.data, map.size, &config);
|
||||||
|
if (pres != GST_H265_PARSER_OK) {
|
||||||
/* parse the hvcC data */
|
GST_WARNING_OBJECT (self, "Failed to parse hvcC data");
|
||||||
if (size < 23) {
|
ret = FALSE;
|
||||||
GST_WARNING_OBJECT (self, "hvcC too small");
|
|
||||||
goto unmap;
|
goto unmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wrong hvcC version */
|
self->nal_length_size = config->length_size_minus_one + 1;
|
||||||
if (data[0] != 0 && data[0] != 1) {
|
|
||||||
goto unmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->nal_length_size = (data[21] & 0x03) + 1;
|
|
||||||
GST_DEBUG_OBJECT (self, "nal length size %u", self->nal_length_size);
|
GST_DEBUG_OBJECT (self, "nal length size %u", self->nal_length_size);
|
||||||
|
|
||||||
num_nal_arrays = data[22];
|
for (i = 0; i < config->nalu_array->len; i++) {
|
||||||
off = 23;
|
GstH265DecoderConfigRecordNalUnitArray *array =
|
||||||
|
&g_array_index (config->nalu_array,
|
||||||
|
GstH265DecoderConfigRecordNalUnitArray, i);
|
||||||
|
|
||||||
for (i = 0; i < num_nal_arrays; i++) {
|
for (j = 0; j < array->nalu->len; j++) {
|
||||||
if (off + 3 >= size) {
|
GstH265NalUnit *nalu = &g_array_index (array->nalu, GstH265NalUnit, j);
|
||||||
GST_WARNING_OBJECT (self, "hvcC too small");
|
gst_h265_timestamper_process_nal (self, nalu);
|
||||||
goto unmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
num_nals = GST_READ_UINT16_BE (data + off + 1);
|
|
||||||
off += 3;
|
|
||||||
for (j = 0; j < num_nals; j++) {
|
|
||||||
pres = gst_h265_parser_identify_nalu_hevc (parser,
|
|
||||||
data, off, size, 2, &nalu);
|
|
||||||
|
|
||||||
if (pres != GST_H265_PARSER_OK) {
|
|
||||||
GST_WARNING_OBJECT (self, "hvcC too small");
|
|
||||||
goto unmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_h265_timestamper_process_nal (self, &nalu);
|
|
||||||
|
|
||||||
off = nalu.offset + nalu.size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* codec_data would mean packetized format */
|
/* codec_data would mean packetized format */
|
||||||
if (!found_format)
|
if (!found_format)
|
||||||
self->packetized = TRUE;
|
self->packetized = TRUE;
|
||||||
|
|
||||||
unmap:
|
unmap:
|
||||||
gst_buffer_unmap (codec_data, &map);
|
gst_buffer_unmap (codec_data, &map);
|
||||||
|
gst_h265_decoder_config_record_free (config);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue