[FFmpeg-devel] [PATCH] Define a set_preset() function shared between ffmpeg.c and ffserver.c, factorize.

Michael Niedermayer michaelni
Fri Oct 29 22:26:46 CEST 2010


On Thu, Oct 28, 2010 at 07:21:39PM -0700, Stefano Sabatini wrote:
> ---
>  cmdutils.c |   51 +++++++++++++++++++++++++++++++++++++++++
>  cmdutils.h |    3 ++
>  ffmpeg.c   |   71 ++++++++++++++-------------------------------------------
>  ffserver.c |   73 +++++++++++++++++------------------------------------------
>  4 files changed, 93 insertions(+), 105 deletions(-)
> 
> diff --git a/cmdutils.c b/cmdutils.c
> index 49c6ad5..86fd5da 100644
> --- a/cmdutils.c
> +++ b/cmdutils.c
> @@ -748,6 +748,57 @@ int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts, int6
>      return pts;
>  }
>  
> +int set_preset( const char *codec_name, const char *preset_name, int is_filename,
> +               int (*set_preset_opt)(const char *opt, const char *arg, void *priv), void *priv)
> +{
> +    FILE *file = NULL;
> +    char filename[1000], tmp[1000], tmp2[1000], line[1000];
[..]
>
> +static int set_preset_opt(const char *opt, const char *arg, void *priv)
>  {
> +    int ret = 0;
> +
> +    if (!strcmp(opt, "acodec")) {
> +        opt_audio_codec(arg);
> +    } else if (!strcmp(opt, "vcodec")) {
> +        opt_video_codec(arg);
> +    } else if (!strcmp(opt, "scodec")) {
> +        opt_subtitle_codec(arg);
>      } else {
> +        ret = opt_default(opt, arg);
>      }
>  
> +    return ret;
> +}
[...]
> +static int set_preset_opt(const char *opt, const char *arg, void *priv)
>  {
> +    int ret = 0;
> +    struct presets_context *ctx = priv;
>  
> +    if (!strcmp(opt, "acodec")){
> +        *ctx->audio_id = opt_audio_codec(arg);
> +    } else if (!strcmp(opt, "vcodec")){
> +        *ctx->video_id = opt_video_codec(arg);
> +    } else {
> +        ret = ffserver_opt_default(opt, arg, ctx->avctx, ctx->type);
>      }
>  
> +    return ret;
> +}

i dont think this mess used in callbacks is a good idea
IMHO to factorize the code ffserver and ffmpeg should be made more similar first
but maybe there are issues with this, i dont know ive not really investigated
this

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101029/43d67896/attachment.pgp>



More information about the ffmpeg-devel mailing list