[FFmpeg-devel,5/6] avcodec/chomp: move the reference in the bsf internal buffer

Submitted by James Almer on March 11, 2018, 5:58 p.m.

Details

Message ID 20180311175854.10096-5-jamrial@gmail.com
State Accepted
Headers show

Commit Message

James Almer March 11, 2018, 5:58 p.m.
There's no need to allocate a new packet for it.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/chomp_bsf.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/chomp_bsf.c b/libavcodec/chomp_bsf.c
index cc94380535..0d29a9a1d9 100644
--- a/libavcodec/chomp_bsf.c
+++ b/libavcodec/chomp_bsf.c
@@ -25,18 +25,14 @@ 
 
 static int chomp_filter(AVBSFContext *ctx, AVPacket *out)
 {
-    AVPacket *in;
     int ret;
 
-    ret = ff_bsf_get_packet(ctx, &in);
+    ret = ff_bsf_get_packet_ref(ctx, out);
     if (ret < 0)
         return ret;
 
-    while (in->size > 0 && !in->data[in->size - 1])
-        in->size--;
-
-    av_packet_move_ref(out, in);
-    av_packet_free(&in);
+    while (out->size > 0 && !out->data[out->size - 1])
+        out->size--;
 
     return 0;
 }