def findSynchronizeBits(parser, start, max_size):
 address0 = parser.absolute_address
 end = (start + max_size)
 size = 0
 while (start < end):
  length = parser.stream.searchBytesLength('\xff', False, start, end)
  if (length is None):
   return None
  size += length
  start += (length * 8)
  try:
   frame = createOrphanField(parser, (start - address0), Frame, 'frame')
   valid = frame.isValid()
  except HACHOIR_ERRORS:
   valid = False
  if valid:
   return size
  start += 8
  size += 1
 return None

def findSynchronizeBits ( parser , start , max_size ) : address0 = parser . absolute_address end = ( start + max_size ) size = 0 while ( start < end ) : length = parser . stream . searchBytesLength ( '\xff' , False , start , end ) if ( length is None ) : return None size += length start += ( length * 8 ) try : frame = createOrphanField ( parser , ( start - address0 ) , Frame , 'frame' ) valid = frame . isValid ( ) except HACHOIR_ERRORS : valid = False if valid : return size start += 8 size += 1 return None
find synchronisation bits returns none on error .