[FFmpeg-devel] [PATCH 1/3] avutil/frame: add a (private) struct_version to AVFrame

Ivan Kalvachev ikalvachev at gmail.com
Tue Dec 17 15:56:43 CET 2013


On 12/17/13, wm4 <nfxjfg at googlemail.com> wrote:
> On Tue, 17 Dec 2013 14:34:08 +0100
> Michael Niedermayer <michaelni at gmx.at> wrote:
>
>> This will be used to check for mixups of AVFrame allocations, like when
>> multiple libavutil versions get linked in.
>>
>> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
>> ---
>>  libavutil/frame.c |    2 ++
>>  libavutil/frame.h |    6 ++++++
>>  2 files changed, 8 insertions(+)
>>
>> diff --git a/libavutil/frame.c b/libavutil/frame.c
>> index 1b44400..013e439 100644
>> --- a/libavutil/frame.c
>> +++ b/libavutil/frame.c
>> @@ -92,6 +92,7 @@ static void get_frame_defaults(AVFrame *frame)
>>          av_freep(&frame->extended_data);
>>
>>      memset(frame, 0, sizeof(*frame));
>> +    frame->struct_version        = LIBAVUTIL_VERSION_MAJOR +
>> (sizeof(AVFrame)<<8) + ((uint64_t)MKTAG('A','V','F','r')<<32);
>>
>>      frame->pts                   =
>>      frame->pkt_dts               =
>> @@ -414,6 +415,7 @@ int av_frame_make_writable(AVFrame *frame)
>>          return 0;
>>
>>      memset(&tmp, 0, sizeof(tmp));
>> +    tmp.struct_version = frame->struct_version;
>>      tmp.format         = frame->format;
>>      tmp.width          = frame->width;
>>      tmp.height         = frame->height;
>> diff --git a/libavutil/frame.h b/libavutil/frame.h
>> index b31cc3e..c1c2c17 100644
>> --- a/libavutil/frame.h
>> +++ b/libavutil/frame.h
>> @@ -502,6 +502,12 @@ typedef struct AVFrame {
>>       * Not to be accessed directly from outside libavutil
>>       */
>>      AVBufferRef *qp_table_buf;
>> +
>> +    /**
>> +     * Not to be accessed from outside libavutil
>> +     */
>> +    uint64_t struct_version;
>> +
>>  } AVFrame;
>>
On 12/17/13, Michael Niedermayer <michaelni at gmx.at> wrote:
> This will be used to check for mixups of AVFrame allocations, like when
> multiple libavutil versions get linked in.
>
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavutil/frame.c |    2 ++
>  libavutil/frame.h |    6 ++++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 1b44400..013e439 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -92,6 +92,7 @@ static void get_frame_defaults(AVFrame *frame)
>          av_freep(&frame->extended_data);
>
>      memset(frame, 0, sizeof(*frame));
> +    frame->struct_version        = LIBAVUTIL_VERSION_MAJOR +
> (sizeof(AVFrame)<<8) + ((uint64_t)MKTAG('A','V','F','r')<<32);
>
>      frame->pts                   =
>      frame->pkt_dts               =
> @@ -414,6 +415,7 @@ int av_frame_make_writable(AVFrame *frame)
>          return 0;
>
>      memset(&tmp, 0, sizeof(tmp));
> +    tmp.struct_version = frame->struct_version;
>      tmp.format         = frame->format;
>      tmp.width          = frame->width;
>      tmp.height         = frame->height;
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index b31cc3e..c1c2c17 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -502,6 +502,12 @@ typedef struct AVFrame {
>       * Not to be accessed directly from outside libavutil
>       */
>      AVBufferRef *qp_table_buf;
> +
> +    /**
> +     * Not to be accessed from outside libavutil
> +     */
> +    uint64_t struct_version;
> +
>  } AVFrame;
>
> This is really starting to get awkward. Why not stop pretending that
> libavcodec, libavutil, etc. are independent libraries instead?

I think that the problem is that library dependence is like a tree.
libavutil is used by all other libraries, so it is the root of the tree.

Some of the libraries are self-contained and they can break ABI/API
without affecting the others. They are like leafs.
(And yes, the branches of that tree look like mesh graph.)

The problem is that we might have to declare avutil n+1 incompatible
with previous version, just because libavfliter have decided to add a
new member to some obscure struct.

It would break programs that don't even link to libavfilter.


More information about the ffmpeg-devel mailing list