This is an optimization to av_buffer_replace() to avoid a redundant allocation
when the src and dst are non-NULL.
Instead of doing a unref + ref, the dst buffer is reused and buffer counters
updated accordingly.
Signed-off-by: Gil Pedersen
---
libavutil/buffer.c | 26
Signed-off-by: Gil Pedersen
---
libavcodec/cbs_av1.c | 22 ++
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 9badfe31e4..cf680aed6c 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -896,12
Signed-off-by: Gil Pedersen
---
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
Signed-off-by: Gil Pedersen
---
libavcodec/h264_slice.c | 10 +-
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index fa7a639053..b937ebebcf 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1018,11
Signed-off-by: Gil Pedersen
---
libavcodec/wavpack.c | 7 +++
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index f77548e5a5..58122c948c 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -1024,13 +1024,12 @@ static int
Also fixes potential leaks in failing av_frame_ref().
Signed-off-by: Gil Pedersen
---
libavutil/frame.c | 37 -
1 file changed, 12 insertions(+), 25 deletions(-)
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 3ab1aa3242..b019779b1a 100644
--- a
Included are six patches to refactor code to use av_buffer_replace().
This is extra relevant if my 'reuse AVBufferRef alloction' patch is merged.
/Gil
Gil Pedersen (6):
avcodec/cbs_av1: use av_buffer_replace() to simplify code
avcodec/cbs_h2645: use av_buffer_replace() to sim
Signed-off-by: Gil Pedersen
---
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