[FFmpeg-devel] [PATCH] Remove hard limit on number of files
Michael Niedermayer
michaelni
Sat Feb 6 11:06:21 CET 2010
On Fri, Feb 05, 2010 at 09:47:25PM -0200, Lucas Clemente Vella wrote:
> Michael Niedermayer escreveu:
[...]
>
> >
> >> @@ -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 meant the
nb_ocodecs -> fc->nb_codecs
change
anyway leave it there its related
>
> 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
> ffmpeg.c | 261 +++++++++++++++++++++++++++++++++++++++------------------------
> 1 file changed, 164 insertions(+), 97 deletions(-)
> bafefd1fcc960a7f82c6291ac67df7f67abbd25b no_file_limit.patch
> diff --git a/ffmpeg.c b/ffmpeg.c
> index e82194f..5913ace 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -89,25 +89,31 @@ 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;
> + AVCodec *codecs[MAX_STREAMS];
> + int nb_codecs;
> +} InputFileContext;
we have a AVinputFile struct, why a second input file struct ?
this is a mess without explanation at least
> +static InputFileContext *input_files = NULL;
> static int nb_input_files = 0;
> -static int nb_icodecs;
>
> -static AVFormatContext *output_files[MAX_FILES];
> -static AVCodec *output_codecs[MAX_FILES*MAX_STREAMS];
> +typedef struct OutputFileContext {
> + AVFormatContext *format;
> + AVCodec *codecs[MAX_STREAMS];
> + AVBitStreamFilterContext *bitstream_filters[MAX_STREAMS];
> + int nb_codecs;
> +} OutputFileContext;
> +static OutputFileContext *output_files = NULL;
> static int nb_output_files = 0;
> -static int nb_ocodecs;
>
> -static AVStreamMap stream_maps[MAX_FILES*MAX_STREAMS];
> +static AVStreamMap *stream_maps;
> static int nb_stream_maps;
>
> -static AVMetaDataMap meta_data_maps[MAX_FILES];
> +static AVMetaDataMap *meta_data_maps;
> static int nb_meta_data_maps;
you move half of the fields in a struct and these 2 become seperate arrays
this too is a mess without explanation
[...]
> @@ -1676,13 +1699,17 @@ static int av_encode(AVFormatContext **output_files,
> AVCodecContext *codec, *icodec;
> AVOutputStream *ost, **ost_table = NULL;
> AVInputStream *ist, **ist_table = NULL;
> - AVInputFile *file_table;
> + AVInputFile *file_table= NULL;
> + uint8_t *no_packet= NULL;
> char error[1024];
> int key;
> int want_sdp = 1;
> - uint8_t no_packet[MAX_FILES]={0};
> int no_packet_count=0;
>
> + no_packet= av_mallocz(nb_input_files * sizeof(uint8_t));
> + if (!no_packet)
> + goto fail;
> +
again, an array instead of the struct you added
[...]
> @@ -1827,7 +1854,8 @@ static int av_encode(AVFormatContext **output_files,
> }
> if (!found) {
> 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, "Could not find input stream matching output stream #%d.%d\n",
> ost->file_index, ost->index);
> av_exit(1);
annother random comment
[...]
> default:
> abort();
> }
> }
>
> - input_files[nb_input_files] = ic;
> - input_files_ts_offset[nb_input_files] = input_ts_offset - (copy_ts ? 0 : timestamp);
> + fc->input_file_ts_offset = input_ts_offset - (copy_ts ? 0 : timestamp);
> /* dump the file content */
> if (verbose >= 0)
> dump_format(ic, nb_input_files, filename, 0);
the setting of ic dissappears.
> @@ -3028,7 +3077,7 @@ static void check_audio_video_sub_inputs(int *has_video_ptr, int *has_audio_ptr,
> has_audio = 0;
> has_subtitle = 0;
> for(j=0;j<nb_input_files;j++) {
> - ic = input_files[j];
> + ic = input_files[j].format;
> for(i=0;i<ic->nb_streams;i++) {
> AVCodecContext *enc = ic->streams[i]->codec;
> switch(enc->codec_type) {
> @@ -3055,19 +3104,22 @@ static void check_audio_video_sub_inputs(int *has_video_ptr, int *has_audio_ptr,
> *has_subtitle_ptr = has_subtitle;
> }
>
> -static void new_video_stream(AVFormatContext *oc)
> +static void new_video_stream(OutputFileContext *fc)
> {
> + AVFormatContext *oc;
> AVStream *st;
> AVCodecContext *video_enc;
> enum CodecID codec_id;
>
> + oc = fc->format;
can be merged
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- 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/20100206/75c4d67c/attachment.pgp>
More information about the ffmpeg-devel
mailing list