aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h264_parser.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-08-04 05:18:58 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-10-07 22:34:20 +0200
commit787351a68e9f3cbe46c3dcf6d0d9b001bcd139b3 (patch)
treebce539cf25bdf3a277be5c2a1dd7c9b438608e64 /libavcodec/h264_parser.c
parent78c9ed26b6e83ea29b55420c2c88dc1860810042 (diff)
downloadffmpeg-787351a68e9f3cbe46c3dcf6d0d9b001bcd139b3.tar.gz
avcodec/h264_ps: Use RefStruct API for SPS/PPS
Avoids allocations and error checks for these allocations; e.g. syncing buffers across threads can't fail any more and needn't be checked. It also avoids having to keep H264ParamSets.pps and H264ParamSets.pps_ref and PPS.sps and PPS.sps_ref in sync and gets rid of casts and indirections. (The removal of these checks and the syncing code even more than offset the additional code for RefStruct.) Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/h264_parser.c')
-rw-r--r--libavcodec/h264_parser.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 43abc45f9c..3574010a64 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -47,6 +47,7 @@
#include "h264data.h"
#include "mpegutils.h"
#include "parser.h"
+#include "refstruct.h"
#include "startcode.h"
typedef struct H264ParseContext {
@@ -373,13 +374,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
goto fail;
}
- av_buffer_unref(&p->ps.pps_ref);
- p->ps.pps = NULL;
- p->ps.sps = NULL;
- p->ps.pps_ref = av_buffer_ref(p->ps.pps_list[pps_id]);
- if (!p->ps.pps_ref)
- goto fail;
- p->ps.pps = (const PPS*)p->ps.pps_ref->data;
+ ff_refstruct_replace(&p->ps.pps, p->ps.pps_list[pps_id]);
p->ps.sps = p->ps.pps->sps;
sps = p->ps.sps;