mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
h265parser: Add APIs to allow update VPS/SPS/PPS
gst_h265_parser_parse_{vps,sps,pps} APIs were used to parse VPS/SPS/PPS and also in order to update parser's internal state at once. Meanwhile gst_h265_parse_{vps,sps,pps} APIs are to parse VPS/SPS/PPS without state update. This commit introduces new APIs so that only accepted VPS/SPS/PPS by user can be updated to be used by parser.
This commit is contained in:
parent
a61549cbde
commit
a2f68762b0
2 changed files with 133 additions and 0 deletions
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue