Message ID | 20240130173218.63297-6-jamrial@gmail.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,1/7,v2] avcodec: add an Immersive Audio Model and Formats frame split bsf | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
yinshiyou/make_loongarch64 | warning | New warnings during build |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_x86 | warning | New warnings during build |
James Almer: > Signed-off-by: James Almer <jamrial@gmail.com> > --- > libavcodec/put_bits.h | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h > index 4561dc131a..04dedd3342 100644 > --- a/libavcodec/put_bits.h > +++ b/libavcodec/put_bits.h > @@ -370,6 +370,22 @@ static inline void put_sbits63(PutBitContext *pb, int n, int64_t value) > put_bits64(pb, n, (uint64_t)(value) & (~(UINT64_MAX << n))); > } > > +static inline void put_leb(PutBitContext *s, unsigned value) > +{ > + int len; > + uint8_t byte; > + > + len = (av_log2(value) + 7) / 7; > + > + for (int i = 0; i < len; i++) { > + byte = value >> (7 * i) & 0x7f; > + if (i < len - 1) > + byte |= 0x80; > + > + put_bits_no_assert(s, 8, byte); > + } > +} > + > /** > * Return the pointer to the byte where the bitstream writer will put > * the next bit. This function does use any internals of PutBitContext and should therefore be in user-code. In fact, get_leb() should not exist in get_bits.h. - Andreas
James Almer: > On 1/30/2024 6:53 PM, Andreas Rheinhardt wrote: >> James Almer: >>> Signed-off-by: James Almer <jamrial@gmail.com> >>> --- >>> libavcodec/put_bits.h | 16 ++++++++++++++++ >>> 1 file changed, 16 insertions(+) >>> >>> diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h >>> index 4561dc131a..04dedd3342 100644 >>> --- a/libavcodec/put_bits.h >>> +++ b/libavcodec/put_bits.h >>> @@ -370,6 +370,22 @@ static inline void put_sbits63(PutBitContext >>> *pb, int n, int64_t value) >>> put_bits64(pb, n, (uint64_t)(value) & (~(UINT64_MAX << n))); >>> } >>> +static inline void put_leb(PutBitContext *s, unsigned value) >>> +{ >>> + int len; >>> + uint8_t byte; >>> + >>> + len = (av_log2(value) + 7) / 7; >>> + >>> + for (int i = 0; i < len; i++) { >>> + byte = value >> (7 * i) & 0x7f; >>> + if (i < len - 1) >>> + byte |= 0x80; >>> + >>> + put_bits_no_assert(s, 8, byte); >>> + } >>> +} >>> + >>> /** >>> * Return the pointer to the byte where the bitstream writer will put >>> * the next bit. >> >> This function does use any internals of PutBitContext and should >> therefore be in user-code. In fact, get_leb() should not exist in >> get_bits.h. > > You could say the same about skip_1stop_8data_bits(), decode210(), > decode012() and get_vlc_multi(). Old errors do not justify new errors. (skip_1stop_8data_bits() is mostly mpegvideodec and if it were not for SVQ3 it would have been moved there already.) > > And the idea is to have these be reusable. leb is evidently going to be > used by anything AOMedia will make. Then it should be in some AOMedia header. If it should exist at all: Byte-aligned lebs should not use a GetBitContext at all. And all current users are byte-aligned. - Andreas
On 1/30/2024 7:10 PM, Andreas Rheinhardt wrote: > James Almer: >> On 1/30/2024 6:53 PM, Andreas Rheinhardt wrote: >>> James Almer: >>>> Signed-off-by: James Almer <jamrial@gmail.com> >>>> --- >>>> libavcodec/put_bits.h | 16 ++++++++++++++++ >>>> 1 file changed, 16 insertions(+) >>>> >>>> diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h >>>> index 4561dc131a..04dedd3342 100644 >>>> --- a/libavcodec/put_bits.h >>>> +++ b/libavcodec/put_bits.h >>>> @@ -370,6 +370,22 @@ static inline void put_sbits63(PutBitContext >>>> *pb, int n, int64_t value) >>>> put_bits64(pb, n, (uint64_t)(value) & (~(UINT64_MAX << n))); >>>> } >>>> +static inline void put_leb(PutBitContext *s, unsigned value) >>>> +{ >>>> + int len; >>>> + uint8_t byte; >>>> + >>>> + len = (av_log2(value) + 7) / 7; >>>> + >>>> + for (int i = 0; i < len; i++) { >>>> + byte = value >> (7 * i) & 0x7f; >>>> + if (i < len - 1) >>>> + byte |= 0x80; >>>> + >>>> + put_bits_no_assert(s, 8, byte); >>>> + } >>>> +} >>>> + >>>> /** >>>> * Return the pointer to the byte where the bitstream writer will put >>>> * the next bit. >>> >>> This function does use any internals of PutBitContext and should >>> therefore be in user-code. In fact, get_leb() should not exist in >>> get_bits.h. >> >> You could say the same about skip_1stop_8data_bits(), decode210(), >> decode012() and get_vlc_multi(). > > Old errors do not justify new errors. > (skip_1stop_8data_bits() is mostly mpegvideodec and if it were not for > SVQ3 it would have been moved there already.) > >> >> And the idea is to have these be reusable. leb is evidently going to be >> used by anything AOMedia will make. > > Then it should be in some AOMedia header. If it should exist at all: > Byte-aligned lebs should not use a GetBitContext at all. And all current > users are byte-aligned. All lebs are byte aligned. And of course we need a GetBitContext implementation when we need to read elements as small as 1 bit followed by a leb followed by some other form of vlc when parsing a single header. And ok, I can move these to an AOM specific header if you prefer. > > - Andreas > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index 4561dc131a..04dedd3342 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -370,6 +370,22 @@ static inline void put_sbits63(PutBitContext *pb, int n, int64_t value) put_bits64(pb, n, (uint64_t)(value) & (~(UINT64_MAX << n))); } +static inline void put_leb(PutBitContext *s, unsigned value) +{ + int len; + uint8_t byte; + + len = (av_log2(value) + 7) / 7; + + for (int i = 0; i < len; i++) { + byte = value >> (7 * i) & 0x7f; + if (i < len - 1) + byte |= 0x80; + + put_bits_no_assert(s, 8, byte); + } +} + /** * Return the pointer to the byte where the bitstream writer will put * the next bit.
Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/put_bits.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)