diff mbox series

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

Message ID 20201118130517.585-4-git@gpost.dk
State New
Headers show
Series Use av_buffer_replace() | expand

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/h264_parser.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index aacd44cf3b..f39924595e 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -360,12 +360,12 @@  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)
+            ret = av_buffer_replace(&p->ps.pps_ref, p->ps.pps_list[pps_id]);
+            if (ret < 0) {
+                p->ps.pps = NULL;
+                p->ps.sps = NULL;
                 goto fail;
+            }
             p->ps.pps = (const PPS*)p->ps.pps_ref->data;
             p->ps.sps = p->ps.pps->sps;
             sps       = p->ps.sps;