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

Showing the changes to libavcodec/tests (1 of 1 file). Show all

Unified · Split

libavcodec/tests/avpacket.c+12−7
@@ -63,9 +63,6 @@ static int initializations(AVPacket* avpkt) · 62 unmodified lines
6363 const static uint8_t* data = "selftest for av_packet_clone(...)";
6464 int ret = 0;
6565
66− /* initialize avpkt */
67− av_init_packet(avpkt);
68−
6966 /* set values for avpkt */
7067 avpkt->pts = 17;
7168 avpkt->dts = 2;
@@ -82,16 +79,24 @@ static int initializations(AVPacket* avpkt) · 10 unmodified lines
8279
8380 int main(void)
8481 {
85− AVPacket avpkt;
82+ AVPacket *avpkt = NULL;
8683 AVPacket *avpkt_clone = NULL;
8784 int ret = 0;
8885
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) {
9094 printf("failed to initialize variables\n");
95+ av_packet_free(&avpkt);
9196 return 1;
9297 }
9398 /* test av_packet_clone*/
94− avpkt_clone = av_packet_clone(&avpkt);
99+ avpkt_clone = av_packet_clone(avpkt);
95100
96101 if(!avpkt_clone) {
97102 av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone AVPacket\n");
@@ -121,7 +126,7 @@ int main(void) · 23 unmodified lines
121126 }
122127 /*clean up*/
123128 av_packet_free(&avpkt_clone);
124− av_packet_unref(&avpkt);
129+ av_packet_free(&avpkt);
125130
126131
127132 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