* commit 'bd2ab27c488ae92c7820efe11d4f53d84e94d58e': avconv: use read_file() for reading the 2pass stats Conflicts: cmdutils.c cmdutils.h ffmpeg_opt.c
Unified · Split
| @@ -1875,64 +1875,6 @@ int read_yesno(void) · 1874 unmodified lines | ||
| 1875 | 1875 | return yesno; |
| 1876 | 1876 | } |
| 1877 | 1877 | |
| 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 | − | |
| 1936 | 1878 | FILE *get_preset_file(char *filename, size_t filename_size, |
| 1937 | 1879 | const char *preset_name, int is_path, |
| 1938 | 1880 | const char *codec_name) |
| @@ -529,18 +529,6 @@ int show_colors(void *optctx, const char *opt, const char *arg); · 528 unmodified lines | ||
| 529 | 529 | */ |
| 530 | 530 | int read_yesno(void); |
| 531 | 531 | |
| 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 | − | |
| 544 | 532 | /** |
| 545 | 533 | * Get a file corresponding to a preset file. |
| 546 | 534 | * |
| @@ -1482,9 +1482,9 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in · 1481 unmodified lines | ||
| 1482 | 1482 | av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE); |
| 1483 | 1483 | } else { |
| 1484 | 1484 | 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) { | |
| 1488 | 1488 | av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n", |
| 1489 | 1489 | logfilename); |
| 1490 | 1490 | exit_program(1); |