History

avcodec/tests/avpacket: use av_packet_alloc() to allocate packets

James Almer committed 5 years ago

Commit 2995a1f1 parent 4ab76701 file · +12 −7Browse files

Unified · Split

libavcodec/tests/avpacket.c+12−7
@@ -63,9 +63,6 @@ static int initializations(AVPacket* avpkt) · 62 unmodified lines
63 const static uint8_t* data = "selftest for av_packet_clone(...)";63 const static uint8_t* data = "selftest for av_packet_clone(...)";
64 int ret = 0;64 int ret = 0;
65 65
66 /* initialize avpkt */
67 av_init_packet(avpkt);
68
69 /* set values for avpkt */66 /* set values for avpkt */
70 avpkt->pts = 17;67 avpkt->pts = 17;
71 avpkt->dts = 2;68 avpkt->dts = 2;
@@ -82,16 +79,24 @@ static int initializations(AVPacket* avpkt) · 10 unmodified lines
82 79
83int main(void)80int main(void)
84{81{
85 AVPacket avpkt;82 AVPacket *avpkt = NULL;
86 AVPacket *avpkt_clone = NULL;83 AVPacket *avpkt_clone = NULL;
87 int ret = 0;84 int ret = 0;
88 85
89 if(initializations(&avpkt) < 0){86 /* test av_packet_alloc */
87 avpkt = av_packet_alloc();
88 if(!avpkt) {
89 av_log(NULL, AV_LOG_ERROR, "av_packet_alloc failed to allcoate AVPacket\n");
90 return 1;
91 }
92
93 if (initializations(avpkt) < 0) {
90 printf("failed to initialize variables\n");94 printf("failed to initialize variables\n");
95 av_packet_free(&avpkt);
91 return 1;96 return 1;
92 }97 }
93 /* test av_packet_clone*/98 /* test av_packet_clone*/
94 avpkt_clone = av_packet_clone(&avpkt);99 avpkt_clone = av_packet_clone(avpkt);
95 100
96 if(!avpkt_clone) {101 if(!avpkt_clone) {
97 av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone AVPacket\n");102 av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone AVPacket\n");
@@ -121,7 +126,7 @@ int main(void) · 23 unmodified lines
121 }126 }
122 /*clean up*/127 /*clean up*/
123 av_packet_free(&avpkt_clone);128 av_packet_free(&avpkt_clone);
124 av_packet_unref(&avpkt);129 av_packet_free(&avpkt);
125 130
126 131
127 return ret;132 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t