Quoting Janne Grunau (2016-03-21 23:11:05)
> On 2016-03-21 15:00:21 +0100, Anton Khirnov wrote:
> > This is required by h264.
> > ---
> > libavcodec/h2645_parse.c | 38 +++++++++++++++++++++++++++++++++++---
> > libavcodec/h2645_parse.h | 6 ++++++
> > 2 files changed, 41 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
> > index 6be79ac..88eb78a 100644
> > --- a/libavcodec/h2645_parse.c
> > +++ b/libavcodec/h2645_parse.c
> > @@ -22,13 +22,12 @@
> >
> > #include "config.h"
> >
> > +#include "libavutil/intmath.h"
> > #include "libavutil/intreadwrite.h"
> > #include "libavutil/mem.h"
> >
> > #include "h2645_parse.h"
> >
> > -/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
> > - * between these functions would be nice. */
> > int ff_h2645_extract_rbsp(const uint8_t *src, int length,
> > H2645NAL *nal)
> > {
> > @@ -128,6 +127,30 @@ nsc:
> > return si;
> > }
> >
> > +static int get_bit_length(H2645NAL *nal, int skip_padding_zeros)
> > +{
> > + int size = nal->size;
> > + int v;
> > +
> > + while (skip_padding_zeros && size > 0 && nal->data[size - 1] == 0)
> > + size--;
> > +
> > + if (!size)
> > + return 0;
> > +
> > + v = nal->data[size - 1];
> > +
> > + if (size > INT_MAX / 8)
> > + return AVERROR(ERANGE);
> > + size *= 8;
> > +
> > + /* remove the stop bit and following trailing zeros */
>
> maybe add "or nothing for damaged bitstreams". the 'if (v)' is a little
> too tricky for my taste.
Tricky how? av_ctx is undefined for zero input.
> It also limits the av_ctz() to 8.
And why is that a problem?
>
> > + if (v)
> > + size -= av_ctz(v) + 1;
> > +
> > + return size;
> > +}
> > +
> > /**
> > * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
> > * 0 if the unit should be skipped, 1 otherwise
> > @@ -181,6 +204,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const
> > uint8_t *buf, int length,
> > while (length >= 4) {
> > H2645NAL *nal;
> > int extract_length = 0;
> > + int skip_trailing_zeros = 1;
>
> is there a reason to use two different names for the same thing?
Not really, renamed locally.
--
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel