Commit bf5af568 authored by Fabrice Bellard's avatar Fabrice Bellard

license/copyright change - fixed memory leaks

Originally committed as revision 587 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 5cbcf02c
/* /*
* FFmpeg main * FFmpeg main
* Copyright (c) 2000, 2001, 2002 Gerard Lantau * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
* *
* This program is free software; you can redistribute it and/or modify * This library is free software; you can redistribute it and/or
* it under the terms of the GNU General Public License as published by * modify it under the terms of the GNU Lesser General Public
* the Free Software Foundation; either version 2 of the License, or * License as published by the Free Software Foundation; either
* (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU Lesser General Public
* along with this program; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define HAVE_AV_CONFIG_H #define HAVE_AV_CONFIG_H
#include "avformat.h" #include "avformat.h"
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/time.h> #include <sys/time.h>
#include <termios.h> #include <termios.h>
#include <time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <ctype.h>
#endif #endif
#include <time.h>
#include <ctype.h>
#define MAXINT64 INT64_C(0x7fffffffffffffff) #define MAXINT64 INT64_C(0x7fffffffffffffff)
...@@ -114,6 +114,13 @@ static int do_psnr = 0; ...@@ -114,6 +114,13 @@ static int do_psnr = 0;
static int do_vstats = 0; static int do_vstats = 0;
static int mpeg_vcd = 0; static int mpeg_vcd = 0;
#ifndef CONFIG_AUDIO_OSS
const char *audio_device = "none";
#endif
#ifndef CONFIG_VIDEO4LINUX
const char *v4l_device = "none";
#endif
typedef struct AVOutputStream { typedef struct AVOutputStream {
int file_index; /* file index */ int file_index; /* file index */
int index; /* stream index in the output file */ int index; /* stream index in the output file */
...@@ -517,9 +524,9 @@ static void do_video_stats(AVOutputStream *ost, ...@@ -517,9 +524,9 @@ static void do_video_stats(AVOutputStream *ost,
{ {
static FILE *fvstats=NULL; static FILE *fvstats=NULL;
static INT64 total_size = 0; static INT64 total_size = 0;
struct tm *today;
time_t today2;
char filename[40]; char filename[40];
time_t today2;
struct tm *today;
AVCodecContext *enc; AVCodecContext *enc;
int frame_number; int frame_number;
INT64 ti; INT64 ti;
...@@ -902,11 +909,13 @@ static int av_encode(AVFormatContext **output_files, ...@@ -902,11 +909,13 @@ static int av_encode(AVFormatContext **output_files,
/* if none, if is finished */ /* if none, if is finished */
if (file_index < 0) { if (file_index < 0) {
if (stream_no_data) { if (stream_no_data) {
#ifndef CONFIG_WIN32
struct timespec ts; struct timespec ts;
ts.tv_sec = 0; ts.tv_sec = 0;
ts.tv_nsec = 1000 * 1000 * 10; ts.tv_nsec = 1000 * 1000 * 10;
nanosleep(&ts, 0); nanosleep(&ts, 0);
#endif
stream_no_data = 0; stream_no_data = 0;
continue; continue;
} }
...@@ -929,12 +938,11 @@ static int av_encode(AVFormatContext **output_files, ...@@ -929,12 +938,11 @@ static int av_encode(AVFormatContext **output_files,
/* the following test is needed in case new streams appear /* the following test is needed in case new streams appear
dynamically in stream : we ignore them */ dynamically in stream : we ignore them */
if (pkt.stream_index >= file_table[file_index].nb_streams) if (pkt.stream_index >= file_table[file_index].nb_streams)
continue; goto discard_packet;
ist_index = file_table[file_index].ist_index + pkt.stream_index; ist_index = file_table[file_index].ist_index + pkt.stream_index;
ist = ist_table[ist_index]; ist = ist_table[ist_index];
if (ist->discard) { if (ist->discard)
continue; goto discard_packet;
}
if (pkt.flags & PKT_FLAG_DROPPED_FRAME) if (pkt.flags & PKT_FLAG_DROPPED_FRAME)
ist->frame_number++; ist->frame_number++;
...@@ -1079,6 +1087,7 @@ static int av_encode(AVFormatContext **output_files, ...@@ -1079,6 +1087,7 @@ static int av_encode(AVFormatContext **output_files,
} }
} }
} }
discard_packet:
av_free_packet(&pkt); av_free_packet(&pkt);
/* dump report by using the first video and audio streams */ /* dump report by using the first video and audio streams */
...@@ -1219,6 +1228,8 @@ static int av_encode(AVFormatContext **output_files, ...@@ -1219,6 +1228,8 @@ static int av_encode(AVFormatContext **output_files,
for(i=0;i<nb_ostreams;i++) { for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i]; ost = ost_table[i];
if (ost) { if (ost) {
fifo_free(&ost->fifo); /* works even if fifo is not
initialized but set to zero */
av_free(ost->pict_tmp.data[0]); av_free(ost->pict_tmp.data[0]);
if (ost->video_resample) if (ost->video_resample)
img_resample_close(ost->img_resample_ctx); img_resample_close(ost->img_resample_ctx);
...@@ -1261,20 +1272,20 @@ void show_licence(void) ...@@ -1261,20 +1272,20 @@ void show_licence(void)
{ {
printf( printf(
"ffmpeg version " FFMPEG_VERSION "\n" "ffmpeg version " FFMPEG_VERSION "\n"
"Copyright (c) 2000, 2001, 2002 Gerard Lantau\n" "Copyright (c) 2000, 2001, 2002 Fabrice Bellard\n"
"This program is free software; you can redistribute it and/or modify\n" "This library is free software; you can redistribute it and/or\n"
"it under the terms of the GNU General Public License as published by\n" "modify it under the terms of the GNU Lesser General Public\n"
"the Free Software Foundation; either version 2 of the License, or\n" "License as published by the Free Software Foundation; either\n"
"(at your option) any later version.\n" "version 2 of the License, or (at your option) any later version.\n"
"\n" "\n"
"This program is distributed in the hope that it will be useful,\n" "This library is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
"GNU General Public License for more details.\n" "Lesser General Public License for more details.\n"
"\n" "\n"
"You should have received a copy of the GNU General Public License\n" "You should have received a copy of the GNU Lesser General Public\n"
"along with this program; if not, write to the Free Software\n" "License along with this library; if not, write to the Free Software\n"
"Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n" "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"
); );
exit(1); exit(1);
} }
...@@ -1399,7 +1410,6 @@ void opt_audio_channels(const char *arg) ...@@ -1399,7 +1410,6 @@ void opt_audio_channels(const char *arg)
audio_channels = atoi(arg); audio_channels = atoi(arg);
} }
#ifdef CONFIG_GRAB
void opt_video_device(const char *arg) void opt_video_device(const char *arg)
{ {
v4l_device = strdup(arg); v4l_device = strdup(arg);
...@@ -1409,7 +1419,6 @@ void opt_audio_device(const char *arg) ...@@ -1409,7 +1419,6 @@ void opt_audio_device(const char *arg)
{ {
audio_device = strdup(arg); audio_device = strdup(arg);
} }
#endif
void opt_audio_codec(const char *arg) void opt_audio_codec(const char *arg)
{ {
...@@ -1562,6 +1571,8 @@ void opt_input_file(const char *filename) ...@@ -1562,6 +1571,8 @@ void opt_input_file(const char *filename)
i, (float)enc->frame_rate / FRAME_RATE_BASE, i, (float)enc->frame_rate / FRAME_RATE_BASE,
(float)rfps / FRAME_RATE_BASE); (float)rfps / FRAME_RATE_BASE);
} }
/* update the current frame rate to match the stream frame rate */
frame_rate = rfps;
break; break;
default: default:
abort(); abort();
...@@ -1823,8 +1834,6 @@ void opt_output_file(const char *filename) ...@@ -1823,8 +1834,6 @@ void opt_output_file(const char *filename)
video_codec_id = CODEC_ID_NONE; video_codec_id = CODEC_ID_NONE;
} }
#ifdef CONFIG_GRAB
/* prepare dummy protocols for grab */ /* prepare dummy protocols for grab */
void prepare_grab(void) void prepare_grab(void)
{ {
...@@ -1873,7 +1882,7 @@ void prepare_grab(void) ...@@ -1873,7 +1882,7 @@ void prepare_grab(void)
AVInputFormat *fmt1; AVInputFormat *fmt1;
fmt1 = av_find_input_format("video_grab_device"); fmt1 = av_find_input_format("video_grab_device");
if (av_open_input_file(&ic, "", fmt1, 0, ap) < 0) { if (av_open_input_file(&ic, "", fmt1, 0, ap) < 0) {
fprintf(stderr, "Could not open video grab device\n"); fprintf(stderr, "Could not find video grab device\n");
exit(1); exit(1);
} }
/* by now video grab has one stream */ /* by now video grab has one stream */
...@@ -1886,7 +1895,7 @@ void prepare_grab(void) ...@@ -1886,7 +1895,7 @@ void prepare_grab(void)
AVInputFormat *fmt1; AVInputFormat *fmt1;
fmt1 = av_find_input_format("audio_device"); fmt1 = av_find_input_format("audio_device");
if (av_open_input_file(&ic, "", fmt1, 0, ap) < 0) { if (av_open_input_file(&ic, "", fmt1, 0, ap) < 0) {
fprintf(stderr, "Could not open audio grab device\n"); fprintf(stderr, "Could not find audio grab device\n");
exit(1); exit(1);
} }
input_files[nb_input_files] = ic; input_files[nb_input_files] = ic;
...@@ -1895,22 +1904,12 @@ void prepare_grab(void) ...@@ -1895,22 +1904,12 @@ void prepare_grab(void)
} }
} }
#else
void prepare_grab(void)
{
fprintf(stderr, "Must supply at least one input file\n");
exit(1);
}
#endif
/* open the necessary output devices for playing */ /* open the necessary output devices for playing */
void prepare_play(void) void prepare_play(void)
{ {
AVOutputFormat *ofmt; file_iformat = NULL;
ofmt = guess_format("audio_device", NULL, NULL); file_oformat = guess_format("audio_device", NULL, NULL);
if (!ofmt) { if (!file_oformat) {
fprintf(stderr, "Could not find audio device\n"); fprintf(stderr, "Could not find audio device\n");
exit(1); exit(1);
} }
...@@ -2008,7 +2007,7 @@ void show_help(void) ...@@ -2008,7 +2007,7 @@ void show_help(void)
prog = do_play ? "ffplay" : "ffmpeg"; prog = do_play ? "ffplay" : "ffmpeg";
printf("%s version " FFMPEG_VERSION ", Copyright (c) 2000, 2001, 2002 Gerard Lantau\n", printf("%s version " FFMPEG_VERSION ", Copyright (c) 2000, 2001, 2002 Fabrice Bellard\n",
prog); prog);
if (!do_play) { if (!do_play) {
...@@ -2069,9 +2068,7 @@ const OptionDef options[] = { ...@@ -2069,9 +2068,7 @@ const OptionDef options[] = {
{ "qblur", HAS_ARG | OPT_EXPERT, {(void*)opt_qblur}, "video quantiser scale blur (VBR)", "blur" }, { "qblur", HAS_ARG | OPT_EXPERT, {(void*)opt_qblur}, "video quantiser scale blur (VBR)", "blur" },
{ "qcomp", HAS_ARG | OPT_EXPERT, {(void*)opt_qcomp}, "video quantiser scale compression (VBR)", "compression" }, { "qcomp", HAS_ARG | OPT_EXPERT, {(void*)opt_qcomp}, "video quantiser scale compression (VBR)", "compression" },
{ "bt", HAS_ARG, {(void*)opt_video_bitrate_tolerance}, "set video bitrate tolerance (in kbit/s)", "tolerance" }, { "bt", HAS_ARG, {(void*)opt_video_bitrate_tolerance}, "set video bitrate tolerance (in kbit/s)", "tolerance" },
#ifdef CONFIG_GRAB { "vd", HAS_ARG | OPT_EXPERT, {(void*)opt_video_device}, "set video grab device", "device" },
{ "vd", HAS_ARG | OPT_EXPERT, {(void*)opt_video_device}, "set video device", "device" },
#endif
{ "vcodec", HAS_ARG | OPT_EXPERT, {(void*)opt_video_codec}, "force video codec", "codec" }, { "vcodec", HAS_ARG | OPT_EXPERT, {(void*)opt_video_codec}, "force video codec", "codec" },
{ "me", HAS_ARG | OPT_EXPERT, {(void*)opt_motion_estimation}, "set motion estimation method", { "me", HAS_ARG | OPT_EXPERT, {(void*)opt_motion_estimation}, "set motion estimation method",
"method" }, "method" },
...@@ -2085,9 +2082,7 @@ const OptionDef options[] = { ...@@ -2085,9 +2082,7 @@ const OptionDef options[] = {
{ "ar", HAS_ARG, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" }, { "ar", HAS_ARG, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" },
{ "ac", HAS_ARG, {(void*)opt_audio_channels}, "set number of audio channels", "channels" }, { "ac", HAS_ARG, {(void*)opt_audio_channels}, "set number of audio channels", "channels" },
{ "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" }, { "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" },
#ifdef CONFIG_GRAB
{ "ad", HAS_ARG | OPT_EXPERT, {(void*)opt_audio_device}, "set audio device", "device" }, { "ad", HAS_ARG | OPT_EXPERT, {(void*)opt_audio_device}, "set audio device", "device" },
#endif
{ "acodec", HAS_ARG | OPT_EXPERT, {(void*)opt_audio_codec}, "force audio codec", "codec" }, { "acodec", HAS_ARG | OPT_EXPERT, {(void*)opt_audio_codec}, "force audio codec", "codec" },
{ "deinterlace", OPT_BOOL | OPT_EXPERT, {(void*)&do_deinterlace}, { "deinterlace", OPT_BOOL | OPT_EXPERT, {(void*)&do_deinterlace},
"deinterlace pictures" }, "deinterlace pictures" },
......
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