mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 05:01:23 +00:00
qsvh265dec: Use gst_h265_parser_parse_decoder_config_record()
Stop duplicating code and use newly added parsing method instead Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2759>
This commit is contained in:
parent
bc8a862e20
commit
b5fb709be7
1 changed files with 28 additions and 44 deletions
|
@ -236,89 +236,73 @@ gst_qsv_h265_dec_parse_codec_data (GstQsvH265Dec * self, const guint8 * data,
|
||||||
gsize size)
|
gsize size)
|
||||||
{
|
{
|
||||||
GstH265Parser *parser = self->parser;
|
GstH265Parser *parser = self->parser;
|
||||||
guint num_nal_arrays;
|
|
||||||
guint off;
|
|
||||||
guint num_nals, i, j;
|
|
||||||
GstH265ParserResult pres;
|
GstH265ParserResult pres;
|
||||||
GstH265NalUnit nalu;
|
|
||||||
GstH265VPS vps;
|
GstH265VPS vps;
|
||||||
GstH265SPS sps;
|
GstH265SPS sps;
|
||||||
GstH265PPS pps;
|
GstH265PPS pps;
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
GstH265DecoderConfigRecord *config = nullptr;
|
||||||
|
|
||||||
/* parse the hvcC data */
|
pres = gst_h265_parser_parse_decoder_config_record (parser,
|
||||||
if (size < 23) {
|
data, size, &config);
|
||||||
GST_WARNING_OBJECT (self, "hvcC too small");
|
if (pres != GST_H265_PARSER_OK) {
|
||||||
|
GST_WARNING_OBJECT (self, "Failed to parse hvcC data");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wrong hvcC version */
|
self->nal_length_size = config->length_size_minus_one + 1;
|
||||||
if (data[0] != 0 && data[0] != 1) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 (guint 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 (guint 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");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
num_nals = GST_READ_UINT16_BE (data + off + 1);
|
switch (nalu->type) {
|
||||||
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");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (nalu.type) {
|
|
||||||
case GST_H265_NAL_VPS:
|
case GST_H265_NAL_VPS:
|
||||||
pres = gst_h265_parser_parse_vps (parser, &nalu, &vps);
|
pres = gst_h265_parser_parse_vps (parser, nalu, &vps);
|
||||||
if (pres != GST_H265_PARSER_OK) {
|
if (pres != GST_H265_PARSER_OK) {
|
||||||
GST_WARNING_OBJECT (self, "Failed to parse VPS");
|
GST_WARNING_OBJECT (self, "Failed to parse VPS");
|
||||||
return FALSE;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_qsv_h265_dec_store_nal (self, vps.id,
|
gst_qsv_h265_dec_store_nal (self, vps.id,
|
||||||
(GstH265NalUnitType) nalu.type, &nalu);
|
(GstH265NalUnitType) nalu->type, nalu);
|
||||||
break;
|
break;
|
||||||
case GST_H265_NAL_SPS:
|
case GST_H265_NAL_SPS:
|
||||||
pres = gst_h265_parser_parse_sps (self->parser, &nalu, &sps, FALSE);
|
pres = gst_h265_parser_parse_sps (self->parser, nalu, &sps, FALSE);
|
||||||
if (pres != GST_H265_PARSER_OK) {
|
if (pres != GST_H265_PARSER_OK) {
|
||||||
GST_WARNING_OBJECT (self, "Failed to parse SPS");
|
GST_WARNING_OBJECT (self, "Failed to parse SPS");
|
||||||
return FALSE;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_qsv_h265_dec_store_nal (self, sps.id,
|
gst_qsv_h265_dec_store_nal (self, sps.id,
|
||||||
(GstH265NalUnitType) nalu.type, &nalu);
|
(GstH265NalUnitType) nalu->type, nalu);
|
||||||
break;
|
break;
|
||||||
case GST_H265_NAL_PPS:
|
case GST_H265_NAL_PPS:
|
||||||
pres = gst_h265_parser_parse_pps (parser, &nalu, &pps);
|
pres = gst_h265_parser_parse_pps (parser, nalu, &pps);
|
||||||
if (pres != GST_H265_PARSER_OK) {
|
if (pres != GST_H265_PARSER_OK) {
|
||||||
GST_WARNING_OBJECT (self, "Failed to parse PPS");
|
GST_WARNING_OBJECT (self, "Failed to parse PPS");
|
||||||
return FALSE;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_qsv_h265_dec_store_nal (self, pps.id,
|
gst_qsv_h265_dec_store_nal (self, pps.id,
|
||||||
(GstH265NalUnitType) nalu.type, &nalu);
|
(GstH265NalUnitType) nalu->type, nalu);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
off = nalu.offset + nalu.size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
|
out:
|
||||||
|
gst_h265_decoder_config_record_free (config);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue