diff mbox series

[FFmpeg-devel,11/48] avcodec/tests/avpacket: use av_packet_alloc() to allocate packets

Message ID 20210305163339.63164-12-jamrial@gmail.com
State New
Headers show
Series deprecate av_init_packet() and sizeof(AVPacket) as part of the ABI
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer March 5, 2021, 4:33 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/tests/avpacket.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/tests/avpacket.c b/libavcodec/tests/avpacket.c
index 90b72341f4..7a70ade4c3 100644
--- a/libavcodec/tests/avpacket.c
+++ b/libavcodec/tests/avpacket.c
@@ -63,9 +63,6 @@  static int initializations(AVPacket* avpkt)
     const static uint8_t* data = "selftest for av_packet_clone(...)";
     int ret = 0;
 
-    /* initialize avpkt */
-    av_init_packet(avpkt);
-
     /* set values for avpkt */
     avpkt->pts = 17;
     avpkt->dts = 2;
@@ -82,16 +79,24 @@  static int initializations(AVPacket* avpkt)
 
 int main(void)
 {
-    AVPacket avpkt;
+    AVPacket *avpkt = NULL;
     AVPacket *avpkt_clone = NULL;
     int ret = 0;
 
-    if(initializations(&avpkt) < 0){
+    /* test av_packet_alloc */
+    avpkt = av_packet_alloc();
+    if(!avpkt) {
+        av_log(NULL, AV_LOG_ERROR, "av_packet_alloc failed to allcoate AVPacket\n");
+        return 1;
+    }
+
+    if (initializations(avpkt) < 0) {
         printf("failed to initialize variables\n");
+        av_packet_free(&avpkt);
         return 1;
     }
     /* test av_packet_clone*/
-    avpkt_clone = av_packet_clone(&avpkt);
+    avpkt_clone = av_packet_clone(avpkt);
 
     if(!avpkt_clone) {
         av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone AVPacket\n");
@@ -121,7 +126,7 @@  int main(void)
     }
     /*clean up*/
     av_packet_free(&avpkt_clone);
-    av_packet_unref(&avpkt);
+    av_packet_free(&avpkt);
 
 
     return ret;