[FFmpeg-devel] Refactoring UUID functionality

Pierre-Anthony Lemieux pal at sandflow.com
Thu Jan 20 19:45:20 EET 2022


Hi all,

It was recently suggested that UUID functionality in the codebase
could be refactored into a single library.

Below is short explainer.

I would appreciate your review/feedback before I/we start writing code.

Best,

-- Pierre

# Common UUID library

## Why

In the course of the IMF demuxer code review [^1], it was suggested
that UUID handling should be delegated to `libuuid` [^2].

It was further pointed out that:
* `libuuid`, as-is, is not a great fit for the IMF demuxer [^3]
* other parts of FFmpeg use UUIDs, e.g. `libavformat/mov.c` and
`libavcodec/cbs_sei.h`
* `libuuid` does not build on Windows

[^1] https://patchwork.ffmpeg.org/project/ffmpeg/patch/20211206031853.21739-1-pal@sandflow.com/#68513
[^2]
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/libuuid [^3]
https://ffmpeg.org/pipermail/ffmpeg-devel/2021-December/290365.html

## Proposal

The proposal is to develop a single UUID library for use across
FFmpeg. The library would reuse (by copying) existing code whenever
possible, e.g. from libuuid. It would be implemented as
`libavutil/uuid.h` and `libavutil/uuid.c` and expose a public API,
e.g.
`int av_uuid_parse(...)`.

## Goals

The library would refactor into a single library the UUID
functionality currently in use by FFmpeg.

## Non-goals

The library is not intended to be a generic UUID library.

## Affected files

Below is an initial list of files that will probably require modifications:

* `libavcodec/cbs_sei.h`
* `libavcodec/cbs_sei_syntax_template.c`
* `libavcodec/h264_metadata_bsf.c`
* `libavcodec/vaapi_encode_h264.c`
* `libavfilter/vf_showinfo.c`
* `libavformat/imf_cpl.c`
* `libavformat/imf.h`
* `libavformat/imfdec.c`
* `libavformat/tests/imf.c`
* `libavformat/mov.c`
* `libavformat/movenc.c`
* `libavformat/smoothstreamingenc.c`
* `libavutil/hwcontext_cuda.c`
* `libavutil/hwcontext_vulkan.c`

`libavforamt/mxfenc.c` defines `mxf_write_uuid()` but it looks like
this is used to write hardcoded instance UIDs, and thus is not
really about generic UUIDs. Perhaps that function should be renamed
`mxf_write_uid()`.

## Pluses

* reduces code duplication

## Minuses

* requires touching stable FFmpeg code


More information about the ffmpeg-devel mailing list