aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h264_picture.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_picture.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_picture.c')
-rw-r--r--libavcodec/h264_picture.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index 31b5e231c2..25d0d96ddb 100644
--- a/libavcodec/h264_picture.c
+++ b/libavcodec/h264_picture.c
@@ -32,6 +32,7 @@
#include "h264dec.h"
#include "hwaccel_internal.h"
#include "mpegutils.h"
+#include "refstruct.h"
#include "thread.h"
#include "threadframe.h"
@@ -49,7 +50,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
av_buffer_unref(&pic->qscale_table_buf);
av_buffer_unref(&pic->mb_type_buf);
- av_buffer_unref(&pic->pps_buf);
+ ff_refstruct_unref(&pic->pps);
for (i = 0; i < 2; i++) {
av_buffer_unref(&pic->motion_val_buf[i]);
av_buffer_unref(&pic->ref_index_buf[i]);
@@ -61,9 +62,10 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
static void h264_copy_picture_params(H264Picture *dst, const H264Picture *src)
{
+ ff_refstruct_replace(&dst->pps, src->pps);
+
dst->qscale_table = src->qscale_table;
dst->mb_type = src->mb_type;
- dst->pps = src->pps;
for (int i = 0; i < 2; i++) {
dst->motion_val[i] = src->motion_val[i];
@@ -113,8 +115,7 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src)
dst->qscale_table_buf = av_buffer_ref(src->qscale_table_buf);
dst->mb_type_buf = av_buffer_ref(src->mb_type_buf);
- dst->pps_buf = av_buffer_ref(src->pps_buf);
- if (!dst->qscale_table_buf || !dst->mb_type_buf || !dst->pps_buf) {
+ if (!dst->qscale_table_buf || !dst->mb_type_buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
@@ -174,7 +175,6 @@ int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture
ret = av_buffer_replace(&dst->qscale_table_buf, src->qscale_table_buf);
ret |= av_buffer_replace(&dst->mb_type_buf, src->mb_type_buf);
- ret |= av_buffer_replace(&dst->pps_buf, src->pps_buf);
if (ret < 0)
goto fail;