[FFmpeg-devel] [PATCH 2/2] avformat: Make AVChapter.id an int64_t on next major bump

Anton Khirnov anton at khirnov.net
Tue Mar 16 12:06:32 EET 2021


Quoting Andreas Rheinhardt (2021-03-16 10:34:22)
> Anton Khirnov:
> > Quoting Andreas Rheinhardt (2021-03-16 09:29:53)
> >> 64 bits are needed in order to retain the uid values of Matroska
> >> chapters; the type is kept signed because the semantics of NUT chapters
> >> depend upon whether the id is > 0 or < 0.
> >>
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> >> ---
> >> Apologies for being so late.
> >>
> >>  doc/APIchanges            | 4 ++++
> >>  libavformat/aadec.c       | 2 +-
> >>  libavformat/avformat.h    | 4 ++++
> >>  libavformat/internal.h    | 4 ++++
> >>  libavformat/matroskaenc.c | 4 ++++
> >>  libavformat/nutdec.c      | 4 ++--
> >>  libavformat/utils.c       | 4 ++++
> >>  libavformat/version.h     | 5 ++++-
> >>  8 files changed, 27 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/doc/APIchanges b/doc/APIchanges
> >> index c0d955b1fa..8b93adebe1 100644
> >> --- a/doc/APIchanges
> >> +++ b/doc/APIchanges
> >> @@ -15,6 +15,10 @@ libavutil:     2017-10-21
> >>  
> >>  API changes, most recent first:
> >>  
> >> +2021-03-16 - xxxxxxxxxx - lavf 58.75.100  - avformat.h
> >> +  AVChapter.id will be changed from int to int64_t
> >> +  on the next major version bump.
> >> +
> >>  2021-03-12 - xxxxxxxxxx - lavc 58.131.100 - avcodec.h codec.h
> >>    Add a get_encode_buffer callback to AVCodecContext, similar to
> >>    get_buffer2 but for encoders.
> >> diff --git a/libavformat/aadec.c b/libavformat/aadec.c
> >> index e88cdb89df..80ca2c12d7 100644
> >> --- a/libavformat/aadec.c
> >> +++ b/libavformat/aadec.c
> >> @@ -222,7 +222,7 @@ static int aa_read_header(AVFormatContext *s)
> >>      c->content_end = start + largest_size;
> >>  
> >>      while ((chapter_pos = avio_tell(pb)) >= 0 && chapter_pos < c->content_end) {
> >> -        int chapter_idx = s->nb_chapters;
> >> +        unsigned chapter_idx = s->nb_chapters;
> > 
> > unrelated?
> > 
> The chapter ids created by aadec are just 0,1,... And in the
> hypothetical scenario that there are more than INT_MAX of them the
> INT_MAX+1U chapter would have a negative id if I didn't change it to
> unsigned above. (I don't think it can happen, but nb_chapters is an
> unsigned, so it is better anyway.)

Right, ok then.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list