History

Merge commit 'bd2ab27c488ae92c7820efe11d4f53d84e94d58e'

* commit 'bd2ab27c488ae92c7820efe11d4f53d84e94d58e': avconv: use read_file() for reading the 2pass stats Conflicts: cmdutils.c cmdutils.h ffmpeg_opt.c

Michael Niedermayer committed 11 years ago

Commit edd110e2 parents 247f4d1 bd2ab273 files · +3 −73Browse files

Unified · Split

3 files
  1. cmdutils.c +0 −58
  2. cmdutils.h +0 −12
  3. ffmpeg_opt.c +3 −3
cmdutils.c+0−58
@@ -1875,64 +1875,6 @@ int read_yesno(void) · 1874 unmodified lines
18751875 return yesno;
18761876 }
18771877
1878−int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
1879−{
1880− int64_t ret;
1881− FILE *f = av_fopen_utf8(filename, "rb");
1882−
1883− if (!f) {
1884− ret = AVERROR(errno);
1885− av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
1886− strerror(errno));
1887− return ret;
1888− }
1889−
1890− ret = fseek(f, 0, SEEK_END);
1891− if (ret == -1) {
1892− ret = AVERROR(errno);
1893− goto out;
1894− }
1895−
1896− ret = ftell(f);
1897− if (ret < 0) {
1898− ret = AVERROR(errno);
1899− goto out;
1900− }
1901− *size = ret;
1902−
1903− ret = fseek(f, 0, SEEK_SET);
1904− if (ret == -1) {
1905− ret = AVERROR(errno);
1906− goto out;
1907− }
1908−
1909− *bufptr = av_malloc(*size + 1);
1910− if (!*bufptr) {
1911− av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");
1912− ret = AVERROR(ENOMEM);
1913− goto out;
1914− }
1915− ret = fread(*bufptr, 1, *size, f);
1916− if (ret < *size) {
1917− av_free(*bufptr);
1918− if (ferror(f)) {
1919− ret = AVERROR(errno);
1920− av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
1921− filename, strerror(errno));
1922− } else
1923− ret = AVERROR_EOF;
1924− } else {
1925− ret = 0;
1926− (*bufptr)[(*size)++] = '\0';
1927− }
1928−
1929−out:
1930− if (ret < 0)
1931− av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", av_err2str(ret));
1932− fclose(f);
1933− return ret;
1934−}
1935−
19361878 FILE *get_preset_file(char *filename, size_t filename_size,
19371879 const char *preset_name, int is_path,
19381880 const char *codec_name)
cmdutils.h+0−12
@@ -529,18 +529,6 @@ int show_colors(void *optctx, const char *opt, const char *arg); · 528 unmodified lines
529529 */
530530 int read_yesno(void);
531531
532−/**
533− * Read the file with name filename, and put its content in a newly
534− * allocated 0-terminated buffer.
535− *
536− * @param filename file to read from
537− * @param bufptr location where pointer to buffer is returned
538− * @param size location where size of buffer is returned
539− * @return >= 0 in case of success, a negative value corresponding to an
540− * AVERROR error code in case of failure.
541− */
542−int cmdutils_read_file(const char *filename, char **bufptr, size_t *size);
543−
544532 /**
545533 * Get a file corresponding to a preset file.
546534 *
ffmpeg_opt.c+3−3
@@ -1482,9 +1482,9 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in · 1481 unmodified lines
14821482 av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
14831483 } else {
14841484 if (video_enc->flags & CODEC_FLAG_PASS2) {
1485− char *logbuffer;
1486− size_t logbuffer_size;
1487− if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
1485+ char *logbuffer = read_file(logfilename);
1486+
1487+ if (!logbuffer) {
14881488 av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
14891489 logfilename);
14901490 exit_program(1);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t