Remove now redundant (and broken/undocumented) opt_programid.
Anton Khirnov authored on 2011/09/01 05:24:06... | ... |
@@ -140,7 +140,6 @@ static int copy_tb; |
140 | 140 |
static int opt_shortest = 0; |
141 | 141 |
static char *vstats_filename; |
142 | 142 |
static FILE *vstats_file; |
143 |
-static int opt_programid = 0; |
|
144 | 143 |
static int copy_initial_nonkeyframes = 0; |
145 | 144 |
|
146 | 145 |
static int audio_volume = 256; |
... | ... |
@@ -1892,7 +1891,7 @@ static int transcode_init(OutputFile *output_files, |
1892 | 1892 |
InputFile *input_files, |
1893 | 1893 |
int nb_input_files) |
1894 | 1894 |
{ |
1895 |
- int ret = 0, i, j; |
|
1895 |
+ int ret = 0, i, j, k; |
|
1896 | 1896 |
AVFormatContext *os; |
1897 | 1897 |
AVCodecContext *codec, *icodec; |
1898 | 1898 |
OutputStream *ost; |
... | ... |
@@ -2190,6 +2189,22 @@ static int transcode_init(OutputFile *output_files, |
2190 | 2190 |
if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error))) < 0) |
2191 | 2191 |
goto dump_format; |
2192 | 2192 |
|
2193 |
+ /* discard unused programs */ |
|
2194 |
+ for (i = 0; i < nb_input_files; i++) { |
|
2195 |
+ InputFile *ifile = &input_files[i]; |
|
2196 |
+ for (j = 0; j < ifile->ctx->nb_programs; j++) { |
|
2197 |
+ AVProgram *p = ifile->ctx->programs[j]; |
|
2198 |
+ int discard = AVDISCARD_ALL; |
|
2199 |
+ |
|
2200 |
+ for (k = 0; k < p->nb_stream_indexes; k++) |
|
2201 |
+ if (!input_streams[ifile->ist_index + p->stream_index[k]].discard) { |
|
2202 |
+ discard = AVDISCARD_DEFAULT; |
|
2203 |
+ break; |
|
2204 |
+ } |
|
2205 |
+ p->discard = discard; |
|
2206 |
+ } |
|
2207 |
+ } |
|
2208 |
+ |
|
2193 | 2209 |
/* open files and write file headers */ |
2194 | 2210 |
for (i = 0; i < nb_output_files; i++) { |
2195 | 2211 |
os = output_files[i].ctx; |
... | ... |
@@ -2904,30 +2919,6 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena |
2904 | 2904 |
} |
2905 | 2905 |
assert_avoptions(format_opts); |
2906 | 2906 |
|
2907 |
- if(opt_programid) { |
|
2908 |
- int i, j; |
|
2909 |
- int found=0; |
|
2910 |
- for(i=0; i<ic->nb_streams; i++){ |
|
2911 |
- ic->streams[i]->discard= AVDISCARD_ALL; |
|
2912 |
- } |
|
2913 |
- for(i=0; i<ic->nb_programs; i++){ |
|
2914 |
- AVProgram *p= ic->programs[i]; |
|
2915 |
- if(p->id != opt_programid){ |
|
2916 |
- p->discard = AVDISCARD_ALL; |
|
2917 |
- }else{ |
|
2918 |
- found=1; |
|
2919 |
- for(j=0; j<p->nb_stream_indexes; j++){ |
|
2920 |
- ic->streams[p->stream_index[j]]->discard= AVDISCARD_DEFAULT; |
|
2921 |
- } |
|
2922 |
- } |
|
2923 |
- } |
|
2924 |
- if(!found){ |
|
2925 |
- fprintf(stderr, "Specified program id not found\n"); |
|
2926 |
- exit_program(1); |
|
2927 |
- } |
|
2928 |
- opt_programid=0; |
|
2929 |
- } |
|
2930 |
- |
|
2931 | 2907 |
/* apply forced codec ids */ |
2932 | 2908 |
for (i = 0; i < ic->nb_streams; i++) |
2933 | 2909 |
choose_codec(o, ic, ic->streams[i], ic->streams[i]->codec->codec_type); |
... | ... |
@@ -4018,7 +4009,6 @@ static const OptionDef options[] = { |
4018 | 4018 |
{ "copytb", OPT_BOOL | OPT_EXPERT, {(void*)©_tb}, "copy input stream time base when stream copying" }, |
4019 | 4019 |
{ "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, // |
4020 | 4020 |
{ "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" }, |
4021 |
- { "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid}, "desired program number", "" }, |
|
4022 | 4021 |
{ "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" }, |
4023 | 4022 |
{ "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)©_initial_nonkeyframes}, "copy initial non-keyframes" }, |
4024 | 4023 |
{ "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, {.off = OFFSET(max_frames)}, "set the number of frames to record", "number" }, |
... | ... |
@@ -841,6 +841,26 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) |
841 | 841 |
return 0; |
842 | 842 |
} |
843 | 843 |
return 1; |
844 |
+ } else if (*spec == 'p' && *(spec + 1) == ':') { |
|
845 |
+ int prog_id, i, j; |
|
846 |
+ char *endptr; |
|
847 |
+ spec += 2; |
|
848 |
+ prog_id = strtol(spec, &endptr, 0); |
|
849 |
+ for (i = 0; i < s->nb_programs; i++) { |
|
850 |
+ if (s->programs[i]->id != prog_id) |
|
851 |
+ continue; |
|
852 |
+ |
|
853 |
+ if (*endptr++ == ':') { |
|
854 |
+ int stream_idx = strtol(endptr, NULL, 0); |
|
855 |
+ return (stream_idx >= 0 && stream_idx < s->programs[i]->nb_stream_indexes && |
|
856 |
+ st->index == s->programs[i]->stream_index[stream_idx]); |
|
857 |
+ } |
|
858 |
+ |
|
859 |
+ for (j = 0; j < s->programs[i]->nb_stream_indexes; j++) |
|
860 |
+ if (st->index == s->programs[i]->stream_index[j]) |
|
861 |
+ return 1; |
|
862 |
+ } |
|
863 |
+ return 0; |
|
844 | 864 |
} else if (!*spec) /* empty specifier, matches everything */ |
845 | 865 |
return 1; |
846 | 866 |
|