Skip to content
Snippets Groups Projects
Commit b386b522 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6113: use av_malloc, not malloc with libav

parent ecc93a55
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ void print_and_save_sdp(AVFormatContext **avc) ...@@ -29,7 +29,7 @@ void print_and_save_sdp(AVFormatContext **avc)
{ {
size_t sdp_size = avc[0]->streams[0]->codec->extradata_size + 2048; size_t sdp_size = avc[0]->streams[0]->codec->extradata_size + 2048;
char *sdp = reinterpret_cast<char*>(malloc(sdp_size)); /* theora sdp can be huge */ char *sdp = reinterpret_cast<char*>(malloc(sdp_size)); /* theora sdp can be huge */
printf("sdp_size:%ld\n", sdp_size); printf("sdp_size:%ud\n", sdp_size);
av_sdp_create(avc, 1, sdp, sdp_size); av_sdp_create(avc, 1, sdp, sdp_size);
printf("SDP:\n%s\n", sdp); printf("SDP:\n%s\n", sdp);
fflush(stdout); fflush(stdout);
...@@ -224,8 +224,8 @@ int main(int argc, char *argv[]) ...@@ -224,8 +224,8 @@ int main(int argc, char *argv[])
/* alloc image and output buffer */ /* alloc image and output buffer */
int size = encoderCtx->width * encoderCtx->height; int size = encoderCtx->width * encoderCtx->height;
int outbuf_size = size; int outbuf_size = size;
uint8_t *outbuf = reinterpret_cast<uint8_t*>(malloc(outbuf_size)); uint8_t *outbuf = reinterpret_cast<uint8_t*>(av_malloc(outbuf_size));
uint8_t *scaled_picture_buf = reinterpret_cast<uint8_t*>(malloc((size * 3) / 2)); /* size for YUV 420 */ uint8_t *scaled_picture_buf = reinterpret_cast<uint8_t*>(av_malloc((size * 3) / 2)); /* size for YUV 420 */
scaled_picture->data[0] = scaled_picture_buf; scaled_picture->data[0] = scaled_picture_buf;
scaled_picture->data[1] = scaled_picture->data[0] + size; scaled_picture->data[1] = scaled_picture->data[0] + size;
...@@ -297,8 +297,8 @@ int main(int argc, char *argv[]) ...@@ -297,8 +297,8 @@ int main(int argc, char *argv[])
// free the packet that was allocated by av_read_frame // free the packet that was allocated by av_read_frame
av_free_packet(&inpacket); av_free_packet(&inpacket);
} }
free(scaled_picture_buf); av_free(scaled_picture_buf);
free(outbuf); av_free(outbuf);
/* write the trailer, if any. the trailer must be written /* write the trailer, if any. the trailer must be written
* before you close the CodecContexts open when you wrote the * before you close the CodecContexts open when you wrote the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment