MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / get_bit_length

Function get_bit_length

libavcodec/h2645_parse.c:348–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348static int get_bit_length(H2645NAL *nal, int min_size, int skip_trailing_zeros)
349{
350 int size = nal->size;
351 int trailing_padding = 0;
352
353 while (skip_trailing_zeros && size > 0 && nal->data[size - 1] == 0)
354 size--;
355
356 if (!size)
357 return 0;
358
359 if (size <= min_size) {
360 if (nal->size < min_size)
361 return AVERROR_INVALIDDATA;
362 size = min_size;
363 } else {
364 int v = nal->data[size - 1];
365 /* remove the stop bit and following trailing zeros,
366 * or nothing for damaged bitstreams */
367 if (v)
368 trailing_padding = ff_ctz(v) + 1;
369 }
370
371 if (size > INT_MAX / 8)
372 return AVERROR(ERANGE);
373 size *= 8;
374
375 return size - trailing_padding;
376}
377
378/**
379 * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,

Callers 1

ff_h2645_packet_splitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected