[FFmpeg-devel] [PATCH] Remove hard limit on number of files

Lucas Clemente Vella lvella
Sat Feb 6 00:47:25 CET 2010


Michael Niedermayer escreveu:
>>  ffmpeg.c |  266 +++++++++++++++++++++++++++++++++++++++------------------------
>>  1 file changed, 167 insertions(+), 99 deletions(-)
>> eed361a815e09c07b2eed16864cadf6cf1360c54  no_file_limit.patch
>> diff --git a/ffmpeg.c b/ffmpeg.c
>> index e82194f..1f094f1 100644
>> --- a/ffmpeg.c
>> +++ b/ffmpeg.c
>> @@ -89,26 +89,32 @@ typedef struct AVMetaDataMap {
>>  
>>  static const OptionDef options[];
>>  
>> -#define MAX_FILES 100
>> -
>>  static const char *last_asked_format = NULL;
>> -static AVFormatContext *input_files[MAX_FILES];
>> -static int64_t input_files_ts_offset[MAX_FILES];
>> -static double input_files_ts_scale[MAX_FILES][MAX_STREAMS];
>> -static AVCodec *input_codecs[MAX_FILES*MAX_STREAMS];
>> +
>> +typedef struct InputFileContext {
>> +    double input_file_ts_scale[MAX_STREAMS];
>> +    int64_t input_file_ts_offset;
>> +	AVFormatContext *format;
> 
> tabs are forbidden in our svn
> also try tools/patcheck please

Sorry for that. Changed.

>> -static int nb_stream_maps;
>> +static int nb_stream_maps = 0;
> 
> unrelated and rejected

It is superfluous, but not unrelated. Since I thought it would make the
code more coherent, I thought it was acceptable. Changed.

> [...]
>>                  /* Sanity check that the stream types match */
>>                  if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {
>>                      int i= ost->file_index;
>> -                    dump_format(output_files[i], i, output_files[i]->filename, 1);
>> +                    /* Shouldn't be output_files[k] ? */
>> +                    dump_format(output_files[i].format, i, output_files[i].format->filename, 1);
>>                      fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n",
>>                          stream_maps[n].file_index, stream_maps[n].stream_index,
>>                          ost->file_index, ost->index);
> 
> if you think theres a bug that goes in a sperate patch with explanation
> of what is buggy
> please dont put such questions in patches

Sorry for that. Changed.

> [...]
>> -static void new_audio_stream(AVFormatContext *oc)
>> +static void new_audio_stream(OutputFileContext *fc)
>>  {
>> +    AVFormatContext *oc;
>>      AVStream *st;
>>      AVCodecContext *audio_enc;
>>      enum CodecID codec_id;
>>  
>> +    oc = fc->format;
>> +
>>      st = av_new_stream(oc, oc->nb_streams);
>>      if (!st) {
>>          fprintf(stderr, "Could not alloc stream\n");
>> @@ -3212,7 +3268,7 @@ static void new_audio_stream(AVFormatContext *oc)
>>      }
>>      avcodec_get_context_defaults2(st->codec, CODEC_TYPE_AUDIO);
>>  
>> -    bitstream_filters[nb_output_files][oc->nb_streams - 1]= audio_bitstream_filters;
>> +    fc->bitstream_filters[oc->nb_streams - 1]= audio_bitstream_filters;
>>      audio_bitstream_filters= NULL;
>>  
>>      avcodec_thread_init(st->codec, thread_count);
> 
> this appears to be an unrelated change

It is not unrelated. The changes are needed because bitstream_filters is
no longer global, but member of OutputFileContext. I moved in there
everything that is one per output file.

> 
>> @@ -3238,7 +3294,7 @@ static void new_audio_stream(AVFormatContext *oc)
>>          if (audio_codec_name) {
>>              codec_id = find_codec_or_die(audio_codec_name, CODEC_TYPE_AUDIO, 1);
>>              codec = avcodec_find_encoder_by_name(audio_codec_name);
>> -            output_codecs[nb_ocodecs] = codec;
>> +            fc->codecs[fc->nb_codecs] = codec;
> 
> same
> 
> 
>>          } else {
>>              codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_AUDIO);
>>              codec = avcodec_find_encoder(codec_id);
>> @@ -3265,7 +3321,7 @@ static void new_audio_stream(AVFormatContext *oc)
>>                  audio_enc->sample_fmt = codec->sample_fmts[0];
>>          }
>>      }
>> -    nb_ocodecs++;
>> +    fc->nb_codecs++;
> 
> ...

Same explanation. Now there is one list of codecs per file, not one
(much bigger) global list.

I intent to work on removing hard limit on number of streams too, but
for now, this is all I have. The new patch is attached. Is it acceptable
now?

-- 
Lucas Clemente Vella
lvella at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: no_file_limit.patch
Type: text/x-patch
Size: 32510 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100205/d5a25621/attachment.bin>



More information about the ffmpeg-devel mailing list