diff --git a/gst-libs/gst/codecparsers/gsth265parser.c b/gst-libs/gst/codecparsers/gsth265parser.c index 6217ca13b4..c1611f4b64 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.c +++ b/gst-libs/gst/codecparsers/gsth265parser.c @@ -2824,6 +2824,127 @@ gst_h265_parser_parse_sei (GstH265Parser * nalparser, GstH265NalUnit * nalu, return res; } +/** + * gst_h265_parser_update_vps: + * @parser: a #GstH265Parser + * @vps: (transfer none): a #GstH265VPS. + * + * Replace internal Video Parameter Set struct corresponding to id of @vps + * with @vps. @nalparser will mark @vps as last parsed vps. + * + * Returns: a #GstH265ParserResult + * + * Since: 1.18 + */ +GstH265ParserResult +gst_h265_parser_update_vps (GstH265Parser * parser, GstH265VPS * vps) +{ + g_return_val_if_fail (parser != NULL, GST_H265_PARSER_ERROR); + g_return_val_if_fail (vps != NULL, GST_H265_PARSER_ERROR); + g_return_val_if_fail (vps->id >= 0 && vps->id < GST_H265_MAX_VPS_COUNT, + GST_H265_PARSER_ERROR); + + if (!vps->valid) { + GST_WARNING ("Cannot update with invalid VPS"); + return GST_H265_PARSER_ERROR; + } + + GST_DEBUG ("Updating video parameter set with id: %d", vps->id); + + parser->vps[vps->id] = *vps; + parser->last_vps = &parser->vps[vps->id]; + + return GST_H265_PARSER_OK; +} + +/** + * gst_h265_parser_update_sps: + * @parser: a #GstH265Parser + * @sps: (transfer none): a #GstH265SPS. + * + * Replace internal Sequence Parameter Set struct corresponding to id of @sps + * with @sps. @nalparser will mark @sps as last parsed sps. + * + * Returns: a #GstH265ParserResult + * + * Since: 1.18 + */ +GstH265ParserResult +gst_h265_parser_update_sps (GstH265Parser * parser, GstH265SPS * sps) +{ + g_return_val_if_fail (parser != NULL, GST_H265_PARSER_ERROR); + g_return_val_if_fail (sps != NULL, GST_H265_PARSER_ERROR); + g_return_val_if_fail (sps->id >= 0 && sps->id < GST_H265_MAX_SPS_COUNT, + GST_H265_PARSER_ERROR); + + if (!sps->valid) { + GST_WARNING ("Cannot update with invalid SPS"); + return GST_H265_PARSER_ERROR; + } + + if (sps->vps) { + GstH265VPS *vps = NULL; + + vps = gst_h265_parser_get_vps (parser, vps->id); + if (!vps || vps != sps->vps) { + GST_WARNING ("Linked VPS is not identical to internal VPS"); + return GST_H265_PARSER_BROKEN_LINK; + } + } + + GST_DEBUG ("Updating sequence parameter set with id: %d", sps->id); + + parser->sps[sps->id] = *sps; + parser->last_sps = &parser->sps[sps->id]; + + return GST_H265_PARSER_OK; +} + +/** + * gst_h265_parser_update_pps: + * @parser: a #GstH265Parser + * @pps: (transfer none): a #GstH265PPS. + * + * Replace internal Sequence Parameter Set struct corresponding to id of @pps + * with @pps. @nalparser will mark @pps as last parsed sps. + * + * Returns: a #GstH265ParserResult + * + * Since: 1.18 + */ +GstH265ParserResult +gst_h265_parser_update_pps (GstH265Parser * parser, GstH265PPS * pps) +{ + GstH265SPS *sps; + + g_return_val_if_fail (parser != NULL, GST_H265_PARSER_ERROR); + g_return_val_if_fail (pps != NULL, GST_H265_PARSER_ERROR); + g_return_val_if_fail (pps->id >= 0 && pps->id < GST_H265_MAX_PPS_COUNT, + GST_H265_PARSER_ERROR); + + if (!pps->valid) { + GST_WARNING ("Cannot update with invalid PPS"); + return GST_H265_PARSER_ERROR; + } + + if (!pps->sps) { + GST_WARNING ("No linked SPS struct"); + return GST_H265_PARSER_BROKEN_LINK; + } + + sps = gst_h265_parser_get_sps (parser, pps->sps->id); + if (!sps || sps != pps->sps) { + GST_WARNING ("Linked SPS is not identical to internal SPS"); + return GST_H265_PARSER_BROKEN_LINK; + } + + GST_DEBUG ("Updating picture parameter set with id: %d", pps->id); + + parser->pps[pps->id] = *pps; + parser->last_pps = &parser->pps[pps->id]; + + return GST_H265_PARSER_OK; +} /** * gst_h265_quant_matrix_4x4_get_zigzag_from_raster: diff --git a/gst-libs/gst/codecparsers/gsth265parser.h b/gst-libs/gst/codecparsers/gsth265parser.h index 5b6a9a2eed..28de0e8ce0 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.h +++ b/gst-libs/gst/codecparsers/gsth265parser.h @@ -1578,6 +1578,18 @@ GstH265ParserResult gst_h265_parser_parse_sei (GstH265Parser * parser, GstH265NalUnit * nalu, GArray **messages); +GST_CODEC_PARSERS_API +GstH265ParserResult gst_h265_parser_update_vps (GstH265Parser * parser, + GstH265VPS * vps); + +GST_CODEC_PARSERS_API +GstH265ParserResult gst_h265_parser_update_sps (GstH265Parser * parser, + GstH265SPS * sps); + +GST_CODEC_PARSERS_API +GstH265ParserResult gst_h265_parser_update_pps (GstH265Parser * parser, + GstH265PPS * pps); + GST_CODEC_PARSERS_API void gst_h265_parser_free (GstH265Parser * parser);