summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-19 13:33:44 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-19 13:33:44 +0200
commitedd110ee4526849da487bb6be9c63fc77cb5a65a (patch)
tree4c0b9bd163f24be2ede535cc91dc6382bc006b24
parent247f4d1f181c2801b8321a7ddb88818dc4861155 (diff)
parentbd2ab27c488ae92c7820efe11d4f53d84e94d58e (diff)
Merge commit 'bd2ab27c488ae92c7820efe11d4f53d84e94d58e'
* commit 'bd2ab27c488ae92c7820efe11d4f53d84e94d58e': avconv: use read_file() for reading the 2pass stats Conflicts: cmdutils.c cmdutils.h ffmpeg_opt.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--cmdutils.c58
-rw-r--r--cmdutils.h12
-rw-r--r--ffmpeg_opt.c6
3 files changed, 3 insertions, 73 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 6e7a0bb09b..15b1bccd44 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -1875,64 +1875,6 @@ int read_yesno(void)
return yesno;
}
-int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
-{
- int64_t ret;
- FILE *f = av_fopen_utf8(filename, "rb");
-
- if (!f) {
- ret = AVERROR(errno);
- av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
- strerror(errno));
- return ret;
- }
-
- ret = fseek(f, 0, SEEK_END);
- if (ret == -1) {
- ret = AVERROR(errno);
- goto out;
- }
-
- ret = ftell(f);
- if (ret < 0) {
- ret = AVERROR(errno);
- goto out;
- }
- *size = ret;
-
- ret = fseek(f, 0, SEEK_SET);
- if (ret == -1) {
- ret = AVERROR(errno);
- goto out;
- }
-
- *bufptr = av_malloc(*size + 1);
- if (!*bufptr) {
- av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");
- ret = AVERROR(ENOMEM);
- goto out;
- }
- ret = fread(*bufptr, 1, *size, f);
- if (ret < *size) {
- av_free(*bufptr);
- if (ferror(f)) {
- ret = AVERROR(errno);
- av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
- filename, strerror(errno));
- } else
- ret = AVERROR_EOF;
- } else {
- ret = 0;
- (*bufptr)[(*size)++] = '\0';
- }
-
-out:
- if (ret < 0)
- av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", av_err2str(ret));
- fclose(f);
- return ret;
-}
-
FILE *get_preset_file(char *filename, size_t filename_size,
const char *preset_name, int is_path,
const char *codec_name)
diff --git a/cmdutils.h b/cmdutils.h
index a21ce35fa8..55134ff27b 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -530,18 +530,6 @@ int show_colors(void *optctx, const char *opt, const char *arg);
int read_yesno(void);
/**
- * Read the file with name filename, and put its content in a newly
- * allocated 0-terminated buffer.
- *
- * @param filename file to read from
- * @param bufptr location where pointer to buffer is returned
- * @param size location where size of buffer is returned
- * @return >= 0 in case of success, a negative value corresponding to an
- * AVERROR error code in case of failure.
- */
-int cmdutils_read_file(const char *filename, char **bufptr, size_t *size);
-
-/**
* Get a file corresponding to a preset file.
*
* If is_path is non-zero, look for the file in the path preset_name.
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 172a2255d1..91100447d1 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -1482,9 +1482,9 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
} else {
if (video_enc->flags & CODEC_FLAG_PASS2) {
- char *logbuffer;
- size_t logbuffer_size;
- if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
+ char *logbuffer = read_file(logfilename);
+
+ if (!logbuffer) {
av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
logfilename);
exit_program(1);