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

Gil Pedersen git at gpost.dk
Wed Nov 18 15:05:14 EET 2020


Signed-off-by: Gil Pedersen <git at gpost.dk>
---
 libavcodec/h264_parser.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

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;
-- 
2.17.1



More information about the ffmpeg-devel mailing list