[FFmpeg-devel] [PATCH 6/7] Factorize opt_new_{audio, video, subtitle} definitions.
Stefano Sabatini
stefano.sabatini-lala
Sat Aug 14 02:15:24 CEST 2010
On date Friday 2010-08-13 22:05:52 +0200, Aurelien Jacobs encoded:
> On Mon, Jul 26, 2010 at 01:53:09PM +0200, Stefano Sabatini wrote:
> > ---
> > ffmpeg.c | 36 ++++++++++--------------------------
> > 1 files changed, 10 insertions(+), 26 deletions(-)
> >
> > diff --git a/ffmpeg.c b/ffmpeg.c
> > index 5c035b4..ff5bfcc 100644
> > --- a/ffmpeg.c
> > +++ b/ffmpeg.c
> > @@ -3603,37 +3603,21 @@ static void new_subtitle_stream(AVFormatContext *oc)
> > subtitle_stream_copy = 0;
> > }
> >
> > -static void opt_new_audio_stream(void)
> > +static void opt_new_stream(const char *opt, const char *arg)
> > {
> > AVFormatContext *oc;
> > - if (nb_output_files <= 0) {
> > - fprintf(stderr, "At least one output file must be specified\n");
> > - ffmpeg_exit(1);
> > - }
> > - oc = output_files[nb_output_files - 1];
> > - new_audio_stream(oc);
> > -}
> > + static void (*fn)(AVFormatContext *oc);
> > + fn = !strcmp(opt, "newvideo" ) ? new_video_stream :
> > + !strcmp(opt, "newaudio" ) ? new_audio_stream :
> > + !strcmp(opt, "newsubtitle") ? new_subtitle_stream : NULL;
> > + assert(fn);
>
> I think it would be simpler without fn. Something like:
>
> if (!strcmp(opt, "newvideo" )) new_video_stream(oc);
> else if (!strcmp(opt, "newaudio" )) new_audio_stream(oc);
> else if (!strcmp(opt, "newsubtitle")) new_subtitle_stream(oc);
> else assert(0);
Good point, updated.
--
FFmpeg = Fabulous and Freak Mega Proud Erotic Gargoyle
More information about the ffmpeg-devel
mailing list