Commit e9bb49f5 authored by Nathan Egge's avatar Nathan Egge Committed by Ronald S. Bultje

Add --demuxer CLI parameter.

parent 6d2e29a9
......@@ -82,7 +82,8 @@ int main(const int argc, char *const *const argv) {
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;
......
......@@ -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 @@ static const struct option long_opts[] = {
{ "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 @@ static void usage(const char *const app, const char *const reason, ...) {
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"
......@@ -136,6 +139,9 @@ void parse(const int argc, char *const *const argv,
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;
break;
......
......@@ -33,6 +33,7 @@
typedef struct {
const char *outputfile;
const char *inputfile;
const char *demuxer;
const char *muxer;
unsigned limit, skip;
int quiet;
......
......@@ -72,30 +72,44 @@ static const char *find_extension(const char *const f) {
&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;
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))) {
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment