[FFmpeg-devel] [PATCH 5/6] avformat/argo_asf: add name option

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sat Aug 8 13:20:32 EEST 2020


Zane van Iperen:
> Signed-off-by: Zane van Iperen <zane at zanevaniperen.com>
> ---
>  libavformat/argo_asf.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
> index 9845cb955b..3499519903 100644
> --- a/libavformat/argo_asf.c
> +++ b/libavformat/argo_asf.c
> @@ -69,6 +69,7 @@ typedef struct ArgoASFContext {
>      ArgoASFFileHeader   fhdr;
>      ArgoASFChunkHeader  ckhdr;
>      uint32_t            blocks_read;
> +    const char         *name;
>  } ArgoASFContext;
>  
>  #if CONFIG_ARGO_ASF_DEMUXER
> @@ -301,7 +302,10 @@ static int argo_asf_write_header(AVFormatContext *s)
>      /* version_{major,minor} set by options. */
>      ctx->fhdr.num_chunks         = 1;
>      ctx->fhdr.chunk_offset       = ASF_FILE_HEADER_SIZE;
> -    strncpy(ctx->fhdr.name, av_basename(s->url), FF_ARRAY_ELEMS(ctx->fhdr.name));
> +    if (ctx->name)
> +        strncpy(ctx->fhdr.name, ctx->name, FF_ARRAY_ELEMS(ctx->fhdr.name));
> +    else
> +        strncpy(ctx->fhdr.name, av_basename(s->url), FF_ARRAY_ELEMS(ctx->fhdr.name));

FF_ARRAY_ELEMS() is actually inappropriate here: Use sizeof() directly.
No need to make a separate patch for it.

>  
>      ctx->ckhdr.num_blocks        = 0;
>      ctx->ckhdr.num_samples       = ASF_SAMPLE_COUNT;
> @@ -362,6 +366,14 @@ static const AVOption argo_asf_options[] = {
>          .max         = UINT16_MAX,
>          .flags       = AV_OPT_FLAG_ENCODING_PARAM
>      },
> +    {
> +        .name        = "name",
> +        .help        = "embedded file name (max 8 characters)",
> +        .offset      = offsetof(ArgoASFContext, name),
> +        .type        = AV_OPT_TYPE_STRING,
> +        .default_val = {.str = NULL},
> +        .flags       = AV_OPT_FLAG_ENCODING_PARAM
> +    },
>      { NULL }
>  };
I wonder whether it would not be better to set this via metadata (that
the demuxer could export so that it survives a roundtrip).

- Andreas


More information about the ffmpeg-devel mailing list