[PATCH 3/4] Use read_file() function for reading the second pass encoding log file. Simplify.

Stefano Sabatini stefano.sabatini-lala
Sun Mar 28 16:41:43 CEST 2010


---
 ffmpeg.c |   16 ++--------------
 1 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 951b0da..c8afb73 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2048,22 +2048,10 @@ static int av_encode(AVFormatContext **output_files,
                     ost->logfile = f;
                 } else {
                     /* read the log file */
-                    f = fopen(logfilename, "r");
-                    if (!f) {
-                        fprintf(stderr, "Cannot read log file '%s' for pass-2 encoding: %s\n", logfilename, strerror(errno));
-                        av_exit(1);
-                    }
-                    fseek(f, 0, SEEK_END);
-                    size = ftell(f);
-                    fseek(f, 0, SEEK_SET);
-                    logbuffer = av_malloc(size + 1);
-                    if (!logbuffer) {
-                        fprintf(stderr, "Could not allocate log buffer\n");
+                    if (read_file(logfilename, &logbuffer, &size) < 0) {
+                        fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
                         av_exit(1);
                     }
-                    size = fread(logbuffer, 1, size, f);
-                    fclose(f);
-                    logbuffer[size] = '\0';
                     codec->stats_in = logbuffer;
                 }
             }
-- 
1.7.0


--wzJLGUyc3ArbnUjN--



More information about the ffmpeg-devel mailing list