[FFmpeg-devel] [PATCH v2 1/3] libavformat/oggdec: Allow first parameter in ff_vorbis_comment to be a generic AVClass struct

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Feb 7 13:56:16 EET 2025


Romain Beauxis:
> Firt argument in these function is only used to pass to av_log. This
> makes it possible to re-use them with any type of AVClass struct.
> 
> ---
>  libavformat/oggdec.h         | 5 ++++-
>  libavformat/oggparsevorbis.c | 4 ++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
> index 43df23f4cb..6177254fd2 100644
> --- a/libavformat/oggdec.h
> +++ b/libavformat/oggdec.h
> @@ -136,8 +136,11 @@ extern const struct ogg_codec ff_vp8_codec;
>   *        so it needs to be writable. Furthermore it must be padded
>   *        by a single byte (not counted in size).
>   *        All changes will have been reverted upon return.
> + *
> + * @param avcl A pointer to an arbitrary struct of which the first field is a
> + *        pointer to an AVClass struct.
>   */
> -int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m,
> +int ff_vorbis_comment(void *avcl, AVDictionary **m,
>                        const uint8_t *buf, int size, int parse_picture);
>  
>  /**
> diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
> index 9f50ab9ffc..62eb8bbf70 100644
> --- a/libavformat/oggparsevorbis.c
> +++ b/libavformat/oggparsevorbis.c
> @@ -88,7 +88,7 @@ int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
>   * and reverts its changes before return. The input buffer needs to have
>   * at least one byte of padding.
>   */
> -static int vorbis_parse_single_comment(AVFormatContext *as, AVDictionary **m,
> +static int vorbis_parse_single_comment(void *as, AVDictionary **m,
>                                         const uint8_t *buf, uint32_t size,
>                                         int *updates, int parse_picture)
>  {
> @@ -146,7 +146,7 @@ end:
>      return 0;
>  }
>  
> -int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
> +int ff_vorbis_comment(void *as, AVDictionary **m,
>                        const uint8_t *buf, int size,
>                        int parse_picture)
>  {

This is wrong: ff_vorbis_comment() really requires an AVFormatContext*
(see e.g. ogm_chapter() or ff_flac_parse_picture()).
Anyway: Your comment could simply say "a logcontext". And the variable
could be renamed to logctx.

- Andreas



More information about the ffmpeg-devel mailing list