ref: e9bb49f5d9bc41f28b08cf887276fd38f0962f4f
parent: 6d2e29a96f19bf6752f6125fe6b20c4939057102
author: Nathan E. Egge <[email protected]>
date: Mon Oct 15 09:50:48 EDT 2018
Add --demuxer CLI parameter.
--- a/tools/dav1d.c
+++ b/tools/dav1d.c
@@ -82,7 +82,8 @@
init_muxers();
parse(argc, argv, &cli_settings, &lib_settings);
- if ((res = input_open(&in, cli_settings.inputfile,
+ if ((res = input_open(&in, cli_settings.demuxer,
+ cli_settings.inputfile,
fps, &total)) < 0)
{
return res;
--- a/tools/dav1d_cli_parse.c
+++ b/tools/dav1d_cli_parse.c
@@ -43,6 +43,7 @@
static const char short_opts[] = "i:o:vql:";
enum {
+ ARG_DEMUXER,
ARG_MUXER,
ARG_FRAME_THREADS,
ARG_TILE_THREADS,
@@ -52,6 +53,7 @@
{ "input", 1, NULL, 'i' },
{ "output", 1, NULL, 'o' },
{ "quiet", 0, NULL, 'q' },
+ { "demuxer", 1, NULL, ARG_DEMUXER },
{ "muxer", 1, NULL, ARG_MUXER },
{ "version", 0, NULL, 'v' },
{ "limit", 1, NULL, 'l' },
@@ -74,7 +76,8 @@
fprintf(stderr, "Supported options:\n"
" --input/-i $file: input file\n"
" --output/-o $file: output file\n"
- " --muxer $name: force muxer type (default: detect from extension)\n"
+ " --demuxer $name: force demuxer type (must be 'ivf'; default: detect from extension)\n"
+ " --muxer $name: force muxer type ('md5', 'yuv' or 'yuv4mpeg'; default: detect from extension)\n"
" --quiet/-q: disable status messages\n"
" --limit/-l $num: stop decoding after $num frames\n"
" --skip/-s $num: skip decoding of the first $num frames\n"
@@ -135,6 +138,9 @@
break;
case 's':
cli_settings->skip = parse_unsigned(optarg, 's', argv[0]);
+ break;
+ case ARG_DEMUXER:
+ cli_settings->demuxer = optarg;
break;
case ARG_MUXER:
cli_settings->muxer = optarg;
--- a/tools/dav1d_cli_parse.h
+++ b/tools/dav1d_cli_parse.h
@@ -33,6 +33,7 @@
typedef struct {
const char *outputfile;
const char *inputfile;
+ const char *demuxer;
const char *muxer;
unsigned limit, skip;
int quiet;
--- a/tools/input/input.c
+++ b/tools/input/input.c
@@ -72,7 +72,8 @@
&step[1] : NULL;
}
-int input_open(DemuxerContext **const c_out, const char *const filename,
+int input_open(DemuxerContext **const c_out,
+ const char *const name, const char *const filename,
unsigned fps[2], unsigned *const num_frames)
{
const Demuxer *impl;
@@ -79,23 +80,36 @@
DemuxerContext *c;
int res, i;
- const char *const ext = find_extension(filename);
- if (!ext) {
- fprintf(stderr, "No extension found for file %s\n", filename);
- return -1;
- }
+ if (name) {
+ for (i = 0; i < num_demuxers; i++) {
+ if (!strcmp(demuxers[i]->name, name)) {
+ impl = demuxers[i];
+ break;
+ }
+ }
+ if (i == num_demuxers) {
+ fprintf(stderr, "Failed to find demuxer named \"%s\"\n", name);
+ return -ENOPROTOOPT;
+ }
+ } else {
+ const char *const ext = find_extension(filename);
+ if (!ext) {
+ fprintf(stderr, "No extension found for file %s\n", filename);
+ return -1;
+ }
- for (i = 0; i < num_demuxers; i++) {
- if (!strcmp(demuxers[i]->extension, ext)) {
- impl = demuxers[i];
- break;
+ for (i = 0; i < num_demuxers; i++) {
+ if (!strcmp(demuxers[i]->extension, ext)) {
+ impl = demuxers[i];
+ break;
+ }
}
- }
- if (i == num_demuxers) {
- fprintf(stderr,
- "Failed to find demuxer for file %s (\"%s\")\n",
- filename, ext);
- return -ENOPROTOOPT;
+ if (i == num_demuxers) {
+ fprintf(stderr,
+ "Failed to find demuxer for file %s (\"%s\")\n",
+ filename, ext);
+ return -ENOPROTOOPT;
+ }
}
if (!(c = malloc(sizeof(DemuxerContext) + impl->priv_data_size))) {
--- a/tools/input/input.h
+++ b/tools/input/input.h
@@ -33,7 +33,8 @@
typedef struct DemuxerContext DemuxerContext;
void init_demuxers(void);
-int input_open(DemuxerContext **c, const char *filename,
+int input_open(DemuxerContext **const c_out,
+ const char *const name, const char *const filename,
unsigned fps[2], unsigned *num_frames);
int input_read(DemuxerContext *ctx, Dav1dData *data);
void input_close(DemuxerContext *ctx);