[FFmpeg-devel] [PATCH 2/6] avcodec/cbs_h2645: use av_buffer_replace() to simplify code
Gil Pedersen
git at gpost.dk
Wed Nov 18 15:05:13 EET 2020
Signed-off-by: Gil Pedersen <git at gpost.dk>
---
libavcodec/cbs_h2645.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index b6d77dd17f..09841af5e6 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -665,11 +665,10 @@ static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \
return err; \
if (priv->ps_var[id] == priv->active_ ## ps_var) \
priv->active_ ## ps_var = NULL ; \
- av_buffer_unref(&priv->ps_var ## _ref[id]); \
+ err = av_buffer_replace(&priv->ps_var ## _ref[id], unit->content_ref); \
av_assert0(unit->content_ref); \
- priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
- if (!priv->ps_var ## _ref[id]) \
- return AVERROR(ENOMEM); \
+ if (err < 0) \
+ return err; \
priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## _ref[id]->data; \
if (!unit->content_ref) \
memcpy(priv->ps_var[id], ps_var, sizeof(*ps_var)); \
--
2.17.1
More information about the ffmpeg-devel
mailing list