History

avconv: use read_file() for reading the 2pass stats

Also, drop the now unused cmdutils_read_file(). There is no reason to have two functions doing essentially the same thing.

Anton Khirnov committed 11 years ago

Commit bd2ab271 parent 6d5d9243 files · +3 −70Browse files

Unified · Split

3 files
  1. avconv_opt.c +3 −3
  2. cmdutils.c +0 −55
  3. cmdutils.h +0 −12
avconv_opt.c+3−3
@@ -1196,9 +1196,9 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc) · 1195 unmodified lines
11961196 }
11971197 ost->logfile = f;
11981198 } else {
1199− char *logbuffer;
1200− size_t logbuffer_size;
1201− if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
1199+ char *logbuffer = read_file(logfilename);
1200+
1201+ if (!logbuffer) {
12021202 av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
12031203 logfilename);
12041204 exit_program(1);
cmdutils.c+0−55
@@ -1396,61 +1396,6 @@ int read_yesno(void) · 1395 unmodified lines
13961396 return yesno;
13971397 }
13981398
1399−int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
1400−{
1401− int ret;
1402− FILE *f = fopen(filename, "rb");
1403−
1404− if (!f) {
1405− av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
1406− strerror(errno));
1407− return AVERROR(errno);
1408− }
1409−
1410− ret = fseek(f, 0, SEEK_END);
1411− if (ret == -1) {
1412− ret = AVERROR(errno);
1413− goto out;
1414− }
1415−
1416− ret = ftell(f);
1417− if (ret < 0) {
1418− ret = AVERROR(errno);
1419− goto out;
1420− }
1421− *size = ret;
1422−
1423− ret = fseek(f, 0, SEEK_SET);
1424− if (ret == -1) {
1425− ret = AVERROR(errno);
1426− goto out;
1427− }
1428−
1429− *bufptr = av_malloc(*size + 1);
1430− if (!*bufptr) {
1431− av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");
1432− ret = AVERROR(ENOMEM);
1433− goto out;
1434− }
1435− ret = fread(*bufptr, 1, *size, f);
1436− if (ret < *size) {
1437− av_free(*bufptr);
1438− if (ferror(f)) {
1439− av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
1440− filename, strerror(errno));
1441− ret = AVERROR(errno);
1442− } else
1443− ret = AVERROR_EOF;
1444− } else {
1445− ret = 0;
1446− (*bufptr)[(*size)++] = '\0';
1447− }
1448−
1449−out:
1450− fclose(f);
1451− return ret;
1452−}
1453−
14541399 void init_pts_correction(PtsCorrectionContext *ctx)
14551400 {
14561401 ctx->num_faulty_pts = ctx->num_faulty_dts = 0;
cmdutils.h+0−12
@@ -460,18 +460,6 @@ int show_sample_fmts(void *optctx, const char *opt, const char *arg); · 459 unmodified lines
460460 */
461461 int read_yesno(void);
462462
463−/**
464− * Read the file with name filename, and put its content in a newly
465− * allocated 0-terminated buffer.
466− *
467− * @param filename file to read from
468− * @param bufptr location where pointer to buffer is returned
469− * @param size location where size of buffer is returned
470− * @return 0 in case of success, a negative value corresponding to an
471− * AVERROR error code in case of failure.
472− */
473−int cmdutils_read_file(const char *filename, char **bufptr, size_t *size);
474−
475463 typedef struct PtsCorrectionContext {
476464 int64_t num_faulty_pts; /// Number of incorrect PTS values so far
477465 int64_t num_faulty_dts; /// Number of incorrect DTS values so far

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