avcodec/chomp: move the reference in the bsf internal buffer
authorJames Almer <jamrial@gmail.com>
Sun, 11 Mar 2018 16:53:04 +0000 (13:53 -0300)
committerJames Almer <jamrial@gmail.com>
Sun, 11 Mar 2018 18:38:24 +0000 (15:38 -0300)
There's no need to allocate a new packet for it.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/chomp_bsf.c

index cc94380..3ba45f3 100644 (file)
 #include "bsf.h"
 #include "internal.h"
 
-static int chomp_filter(AVBSFContext *ctx, AVPacket *out)
+static int chomp_filter(AVBSFContext *ctx, AVPacket *pkt)
 {
-    AVPacket *in;
     int ret;
 
-    ret = ff_bsf_get_packet(ctx, &in);
+    ret = ff_bsf_get_packet_ref(ctx, pkt);
     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 (pkt->size > 0 && !pkt->data[pkt->size - 1])
+        pkt->size--;
 
     return 0;
 }