diff mbox series

[FFmpeg-devel,2/6] avcodec/cbs_h2645: use av_buffer_replace() to simplify code

Message ID 20201118130517.585-3-git@gpost.dk
State New
Headers show
Series Use av_buffer_replace()
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Gil Pedersen Nov. 18, 2020, 1:05 p.m. UTC
Signed-off-by: Gil Pedersen <git@gpost.dk>
---
 libavcodec/cbs_h2645.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

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)); \