[FFmpeg-devel] [PATCH] better reporting of programs
Michael Niedermayer
michaelni
Sat Oct 20 20:27:45 CEST 2007
On Wed, Oct 17, 2007 at 11:52:54PM +0200, Nico Sabbi wrote:
> Il Tuesday 16 October 2007 23:20:55 Michael Niedermayer ha scritto:
>
> > wouldnt it be better to use the index (like in
> > AVFormatContext.streams[index]) or even a AVStream pointer
> > instead of AVStream.id ? it would be easier to find the AVStream
> > with the index/pointer, also finding the id from the index is a
> > mere .streams[index].id the other way around is slightly harder and
> > less efficient
>
> implemented with an index
>
> >
> > by how much would the complexity increas if this where (re)alloc()
> > instead of fixed 64 ?
> >
> > also the minor version should be bumped
> both done
>
> > could you split the cosmetic code moving from the functional
> > changes?
> >
> > [...]
>
> done.
> Patches are in this order:
> f1: cosmetical; moved the core of the stream description to a separate
> function
> f2: API extension
> f3: actual use of the API in mpegts.c
> f4: changes to ffmpeg.c to support the programid switch
> (currently 1 program alone until Reimar implements the
> code to assign arrays)
>
>
[...]
> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c (revisione 10578)
> +++ ffmpeg.c (copia locale)
> @@ -184,6 +184,7 @@
> static int video_global_header = 0;
> static char *vstats_filename;
> static FILE *vstats_file;
> +static int opt_programid = 0;
>
> static int rate_emu = 0;
>
> @@ -1473,8 +1474,27 @@
> }
>
> } else {
> + found = 0;
> + if(opt_programid) {
> + int p, q, r, z;
> + for(z=0; !found, z<nb_input_files; z++) {
while this is valid c it doesnt do what you want it to do, also i think gcc
prints warnings about it
> + AVFormatContext *ic = input_files[z];
> + for(p=0; !found, p<ic->nb_programs; p++) {
> + AVProgram *program = ic->programs[p];
> + if(program->id == opt_programid) {
> + for(q=0; !found, q<program->nb_stream_indexes; q++) {
> + int sidx = program->stream_index[q];
> + if(ic->streams[sidx]->codec->codec_type == ost->st->codec->codec_type) {
> + ost->source_index = file_table[z].ist_index + sidx;
> + found = 1;
> + break;
this is a classic case where goto should be used or it should be a seperate
function which uses return
> + }
> + }
> + }
> + }
> + }
> + } else {
> /* get corresponding input stream index : we select the first one with the right type */
> - found = 0;
cosmetic, the found= 0 is moved
[...]
> @@ -2587,6 +2608,12 @@
> print_error(filename, err);
> exit(1);
> }
> + if(opt_programid) {
> + int i;
> + for(i=0; i<ic->nb_programs; i++)
> + if(ic->programs[i]->id != opt_programid)
> + ic->programs[i]->discard = AVDISCARD_ALL;
> + }
indention is not 4 spaces
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071020/ab422080/attachment.pgp>
More information about the ffmpeg-devel
mailing list