Commit e79067fb authored by pulento's avatar pulento

- Fix memory leak and others bugs for ppmpipe. Thanks to Rudolf Opalla.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@373 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 2ff5153e
...@@ -302,15 +302,14 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture, ...@@ -302,15 +302,14 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
UINT8 *buf, *src, *dest; UINT8 *buf, *src, *dest;
int size, j, i; int size, j, i;
size = avpicture_get_size(pix_fmt, w, h);
buf = malloc(size);
if (!buf)
return;
/* XXX: not efficient, should add test if we can take /* XXX: not efficient, should add test if we can take
directly the AVPicture */ directly the AVPicture */
switch(pix_fmt) { switch(pix_fmt) {
case PIX_FMT_YUV420P: case PIX_FMT_YUV420P:
size = avpicture_get_size(pix_fmt, w, h);
buf = malloc(size);
if (!buf)
return;
dest = buf; dest = buf;
for(i=0;i<3;i++) { for(i=0;i<3;i++) {
if (i == 1) { if (i == 1) {
...@@ -328,6 +327,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture, ...@@ -328,6 +327,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
case PIX_FMT_YUV422P: case PIX_FMT_YUV422P:
size = (w * h) * 2; size = (w * h) * 2;
buf = malloc(size); buf = malloc(size);
if (!buf)
return;
dest = buf; dest = buf;
for(i=0;i<3;i++) { for(i=0;i<3;i++) {
if (i == 1) { if (i == 1) {
...@@ -344,6 +345,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture, ...@@ -344,6 +345,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
case PIX_FMT_YUV444P: case PIX_FMT_YUV444P:
size = (w * h) * 3; size = (w * h) * 3;
buf = malloc(size); buf = malloc(size);
if (!buf)
return;
dest = buf; dest = buf;
for(i=0;i<3;i++) { for(i=0;i<3;i++) {
src = picture->data[i]; src = picture->data[i];
...@@ -357,6 +360,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture, ...@@ -357,6 +360,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
case PIX_FMT_YUV422: case PIX_FMT_YUV422:
size = (w * h) * 2; size = (w * h) * 2;
buf = malloc(size); buf = malloc(size);
if (!buf)
return;
dest = buf; dest = buf;
src = picture->data[0]; src = picture->data[0];
for(j=0;j<h;j++) { for(j=0;j<h;j++) {
...@@ -369,6 +374,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture, ...@@ -369,6 +374,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
case PIX_FMT_BGR24: case PIX_FMT_BGR24:
size = (w * h) * 3; size = (w * h) * 3;
buf = malloc(size); buf = malloc(size);
if (!buf)
return;
dest = buf; dest = buf;
src = picture->data[0]; src = picture->data[0];
for(j=0;j<h;j++) { for(j=0;j<h;j++) {
......
...@@ -169,10 +169,14 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -169,10 +169,14 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
int ret; int ret;
ByteIOContext f1, *f; ByteIOContext f1, *f;
/*
This if-statement destroys pipes - I do not see why it is necessary
if (get_frame_filename(filename, sizeof(filename), if (get_frame_filename(filename, sizeof(filename),
s->path, s->img_number) < 0) s->path, s->img_number) < 0)
return -EIO; return -EIO;
*/
get_frame_filename(filename, sizeof(filename),
s->path, s->img_number);
if (!s->is_pipe) { if (!s->is_pipe) {
f = &f1; f = &f1;
if (url_fopen(f, filename, URL_RDONLY) < 0) if (url_fopen(f, filename, URL_RDONLY) < 0)
...@@ -547,10 +551,14 @@ static int img_write_packet(AVFormatContext *s, int stream_index, ...@@ -547,10 +551,14 @@ static int img_write_packet(AVFormatContext *s, int stream_index,
return -EIO; return -EIO;
} }
/*
This if-statement destroys pipes - I do not see why it is necessary
if (get_frame_filename(filename, sizeof(filename), if (get_frame_filename(filename, sizeof(filename),
img->path, img->img_number) < 0) img->path, img->img_number) < 0)
return -EIO; return -EIO;
*/
get_frame_filename(filename, sizeof(filename),
img->path, img->img_number);
if (!img->is_pipe) { if (!img->is_pipe) {
pb = &pb1; pb = &pb1;
if (url_fopen(pb, filename, URL_WRONLY) < 0) if (url_fopen(pb, filename, URL_WRONLY) < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment